Skip to content

Commit

Permalink
Merge pull request #2667 from crobibero/emby-naming-warnings
Browse files Browse the repository at this point in the history
Fix warnings in Emby.Naming
  • Loading branch information
dkanada committed Mar 27, 2020
2 parents 10050a5 + ea49514 commit bd4269c
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 49 deletions.
2 changes: 1 addition & 1 deletion Emby.Naming/AudioBook/AudioBookFileInfo.cs
Expand Up @@ -37,7 +37,7 @@ public class AudioBookFileInfo : IComparable<AudioBookFileInfo>
/// <value>The type.</value>
public bool IsDirectory { get; set; }

/// <inheritdoc/>
/// <inheritdoc />
public int CompareTo(AudioBookFileInfo other)
{
if (ReferenceEquals(this, other))
Expand Down
12 changes: 2 additions & 10 deletions Emby.Naming/AudioBook/AudioBookListResolver.cs
Expand Up @@ -29,11 +29,7 @@ public IEnumerable<AudioBookInfo> Resolve(IEnumerable<FileSystemMetadata> files)
// Filter out all extras, otherwise they could cause stacks to not be resolved
// See the unit test TestStackedWithTrailer
var metadata = audiobookFileInfos
.Select(i => new FileSystemMetadata
{
FullName = i.Path,
IsDirectory = i.IsDirectory
});
.Select(i => new FileSystemMetadata { FullName = i.Path, IsDirectory = i.IsDirectory });

var stackResult = new StackResolver(_options)
.ResolveAudioBooks(metadata);
Expand All @@ -42,11 +38,7 @@ public IEnumerable<AudioBookInfo> Resolve(IEnumerable<FileSystemMetadata> files)
{
var stackFiles = stack.Files.Select(i => audioBookResolver.Resolve(i, stack.IsDirectoryStack)).ToList();
stackFiles.Sort();
var info = new AudioBookInfo
{
Files = stackFiles,
Name = stack.Name
};
var info = new AudioBookInfo { Files = stackFiles, Name = stack.Name };

yield return info;
}
Expand Down
3 changes: 2 additions & 1 deletion Emby.Naming/Subtitles/SubtitleParser.cs
Expand Up @@ -37,7 +37,8 @@ public SubtitleInfo ParseFile(string path)
IsForced = _options.SubtitleForcedFlags.Any(i => flags.Contains(i, StringComparer.OrdinalIgnoreCase))
};

var parts = flags.Where(i => !_options.SubtitleDefaultFlags.Contains(i, StringComparer.OrdinalIgnoreCase) && !_options.SubtitleForcedFlags.Contains(i, StringComparer.OrdinalIgnoreCase))
var parts = flags.Where(i => !_options.SubtitleDefaultFlags.Contains(i, StringComparer.OrdinalIgnoreCase)
&& !_options.SubtitleForcedFlags.Contains(i, StringComparer.OrdinalIgnoreCase))
.ToList();

// Should have a name, language and file extension
Expand Down
10 changes: 8 additions & 2 deletions Emby.Naming/TV/EpisodePathParser.cs
Expand Up @@ -18,7 +18,13 @@ public EpisodePathParser(NamingOptions options)
_options = options;
}

public EpisodePathParserResult Parse(string path, bool isDirectory, bool? isNamed = null, bool? isOptimistic = null, bool? supportsAbsoluteNumbers = null, bool fillExtendedInfo = true)
public EpisodePathParserResult Parse(
string path,
bool isDirectory,
bool? isNamed = null,
bool? isOptimistic = null,
bool? supportsAbsoluteNumbers = null,
bool fillExtendedInfo = true)
{
// Added to be able to use regex patterns which require a file extension.
// There were no failed tests without this block, but to be safe, we can keep it until
Expand Down Expand Up @@ -64,7 +70,7 @@ public EpisodePathParserResult Parse(string path, bool isDirectory, bool? isName
{
result.SeriesName = result.SeriesName
.Trim()
.Trim(new[] { '_', '.', '-' })
.Trim('_', '.', '-')
.Trim();
}
}
Expand Down
2 changes: 1 addition & 1 deletion Emby.Naming/TV/SeasonPathParserResult.cs
Expand Up @@ -11,7 +11,7 @@ public class SeasonPathParserResult
public int? SeasonNumber { get; set; }

/// <summary>
/// Gets or sets a value indicating whether this <see cref="SeasonPathParserResult"/> is success.
/// Gets or sets a value indicating whether this <see cref="SeasonPathParserResult" /> is success.
/// </summary>
/// <value><c>true</c> if success; otherwise, <c>false</c>.</value>
public bool Success { get; set; }
Expand Down
25 changes: 9 additions & 16 deletions Emby.Naming/Video/StackResolver.cs
Expand Up @@ -21,31 +21,24 @@ public StackResolver(NamingOptions options)

public IEnumerable<FileStack> ResolveDirectories(IEnumerable<string> files)
{
return Resolve(files.Select(i => new FileSystemMetadata
{
FullName = i,
IsDirectory = true
}));
return Resolve(files.Select(i => new FileSystemMetadata { FullName = i, IsDirectory = true }));
}

public IEnumerable<FileStack> ResolveFiles(IEnumerable<string> files)
{
return Resolve(files.Select(i => new FileSystemMetadata
{
FullName = i,
IsDirectory = false
}));
return Resolve(files.Select(i => new FileSystemMetadata { FullName = i, IsDirectory = false }));
}

public IEnumerable<FileStack> ResolveAudioBooks(IEnumerable<FileSystemMetadata> files)
{
foreach (var directory in files.GroupBy(file => file.IsDirectory ? file.FullName : Path.GetDirectoryName(file.FullName)))
var groupedDirectoryFiles = files.GroupBy(file =>
file.IsDirectory
? file.FullName
: Path.GetDirectoryName(file.FullName));

foreach (var directory in groupedDirectoryFiles)
{
var stack = new FileStack()
{
Name = Path.GetFileName(directory.Key),
IsDirectoryStack = false
};
var stack = new FileStack { Name = Path.GetFileName(directory.Key), IsDirectoryStack = false };
foreach (var file in directory)
{
if (file.IsDirectory)
Expand Down
4 changes: 3 additions & 1 deletion Emby.Naming/Video/VideoFileInfo.cs
Expand Up @@ -77,7 +77,9 @@ public class VideoFileInfo
/// Gets the file name without extension.
/// </summary>
/// <value>The file name without extension.</value>
public string FileNameWithoutExtension => !IsDirectory ? System.IO.Path.GetFileNameWithoutExtension(Path) : System.IO.Path.GetFileName(Path);
public string FileNameWithoutExtension => !IsDirectory
? System.IO.Path.GetFileNameWithoutExtension(Path)
: System.IO.Path.GetFileName(Path);

/// <inheritdoc />
public override string ToString()
Expand Down
24 changes: 7 additions & 17 deletions Emby.Naming/Video/VideoListResolver.cs
Expand Up @@ -33,11 +33,7 @@ public IEnumerable<VideoInfo> Resolve(List<FileSystemMetadata> files, bool suppo
// See the unit test TestStackedWithTrailer
var nonExtras = videoInfos
.Where(i => i.ExtraType == null)
.Select(i => new FileSystemMetadata
{
FullName = i.Path,
IsDirectory = i.IsDirectory
});
.Select(i => new FileSystemMetadata { FullName = i.Path, IsDirectory = i.IsDirectory });

var stackResult = new StackResolver(_options)
.Resolve(nonExtras).ToList();
Expand All @@ -57,11 +53,7 @@ public IEnumerable<VideoInfo> Resolve(List<FileSystemMetadata> files, bool suppo

info.Year = info.Files[0].Year;

var extraBaseNames = new List<string>
{
stack.Name,
Path.GetFileNameWithoutExtension(stack.Files[0])
};
var extraBaseNames = new List<string> { stack.Name, Path.GetFileNameWithoutExtension(stack.Files[0]) };

var extras = GetExtras(remainingFiles, extraBaseNames);

Expand All @@ -83,10 +75,7 @@ public IEnumerable<VideoInfo> Resolve(List<FileSystemMetadata> files, bool suppo

foreach (var media in standaloneMedia)
{
var info = new VideoInfo(media.Name)
{
Files = new List<VideoFileInfo> { media }
};
var info = new VideoInfo(media.Name) { Files = new List<VideoFileInfo> { media } };

info.Year = info.Files[0].Year;

Expand Down Expand Up @@ -222,8 +211,8 @@ private bool IsEligibleForMultiVersion(string folderName, string testFilename)
{
testFilename = testFilename.Substring(folderName.Length).Trim();
return string.IsNullOrEmpty(testFilename)
|| testFilename[0] == '-'
|| string.IsNullOrWhiteSpace(Regex.Replace(testFilename, @"\[([^]]*)\]", string.Empty));
|| testFilename[0] == '-'
|| string.IsNullOrWhiteSpace(Regex.Replace(testFilename, @"\[([^]]*)\]", string.Empty));
}

return false;
Expand All @@ -239,7 +228,8 @@ private List<VideoFileInfo> GetExtras(IEnumerable<VideoFileInfo> remainingFiles,

return remainingFiles
.Where(i => i.ExtraType == null)
.Where(i => baseNames.Any(b => i.FileNameWithoutExtension.StartsWith(b, StringComparison.OrdinalIgnoreCase)))
.Where(i => baseNames.Any(b =>
i.FileNameWithoutExtension.StartsWith(b, StringComparison.OrdinalIgnoreCase)))
.ToList();
}
}
Expand Down
1 change: 1 addition & 0 deletions MediaBrowser.Model/Entities/ChapterInfo.cs
Expand Up @@ -26,6 +26,7 @@ public class ChapterInfo
/// </summary>
/// <value>The image path.</value>
public string ImagePath { get; set; }

public DateTime ImageDateModified { get; set; }

public string ImageTag { get; set; }
Expand Down

0 comments on commit bd4269c

Please sign in to comment.