Skip to content

Commit

Permalink
Merge pull request #126 from ptr727/develop
Browse files Browse the repository at this point in the history
Fix MediaInfo track id pattern match
  • Loading branch information
ptr727 authored Jul 29, 2022
2 parents 36e6026 + 1b00b3e commit eaec655
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion PlexCleaner/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class CommandLineOptions
public static int Invoke()
{
// TODO: https://github.com/dotnet/command-line-api/issues/1781
RootCommand rootCommand = CommandLineOptions.CreateRootCommand();
RootCommand rootCommand = CreateRootCommand();
return rootCommand.Invoke(CommandLineStringSplitter.Instance.Split(Environment.CommandLine).ToArray()[1..]);
}

Expand Down
4 changes: 2 additions & 2 deletions PlexCleaner/Process.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public bool ProcessFolders(List<string> folderList)
return ProcessFiles(fileList);
}

public static bool DeleteEmptyFolders(List<string> folderList)
public static bool DeleteEmptyFolders(IEnumerable<string> folderList)
{
if (!Program.Config.ProcessOptions.DeleteEmptyFolders)
{
Expand Down Expand Up @@ -687,7 +687,7 @@ public static bool RemoveSubtitlesFiles(List<string> fileList)
});
}

private static bool ProcessFilesDriver(List<string> fileList, string taskName, Func<string, bool> taskFunc)
private static bool ProcessFilesDriver(IReadOnlyCollection<string> fileList, string taskName, Func<string, bool> taskFunc)
{
// Start
Log.Logger.Information("Starting {TaskName}, processing {Count} files ...", taskName, fileList.Count);
Expand Down
13 changes: 10 additions & 3 deletions PlexCleaner/TrackInfo.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
using InsaneGenius.Utilities;
using Serilog;

Expand Down Expand Up @@ -171,9 +171,16 @@ internal TrackInfo(MediaInfoToolXmlSchema.Track track)
Language = "chi";
}

// ID can be an integer or an integer-type, e.g. 3-CC1
// ID can be in a variety of formats:
// 1
// 3-CC1
// 1 / 8876149d-48f0-4148-8225-dc0b53a50b90
// https://github.com/MediaArea/MediaInfo/issues/201
Id = int.Parse(track.Id.All(char.IsDigit) ? track.Id : track.Id[..track.Id.IndexOf('-', StringComparison.OrdinalIgnoreCase)], CultureInfo.InvariantCulture);
const string pattern = @"(?<id>\d)";
Regex regex = new(pattern);
Match match = regex.Match(track.Id);
Debug.Assert(match.Success);
Id = int.Parse(match.Groups["id"].Value);

// Use streamorder for number
Number = track.StreamOrder;
Expand Down

0 comments on commit eaec655

Please sign in to comment.