mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 18:08:53 -07:00
add new naming project
This commit is contained in:
parent
4edcab9c11
commit
5fdd7ec672
@ -306,7 +306,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||
{
|
||||
if (!IndexNumber.HasValue && !string.IsNullOrEmpty(Path))
|
||||
{
|
||||
IndexNumber = TVUtils.GetEpisodeNumberFromFile(Path, true);
|
||||
IndexNumber = LibraryManager.GetEpisodeNumberFromFile(Path, true);
|
||||
|
||||
// If a change was made record it
|
||||
if (IndexNumber.HasValue)
|
||||
@ -317,7 +317,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||
|
||||
if (!IndexNumberEnd.HasValue && !string.IsNullOrEmpty(Path))
|
||||
{
|
||||
IndexNumberEnd = TVUtils.GetEndingEpisodeNumberFromFile(Path);
|
||||
IndexNumberEnd = LibraryManager.GetEndingEpisodeNumberFromFile(Path);
|
||||
|
||||
// If a change was made record it
|
||||
if (IndexNumberEnd.HasValue)
|
||||
@ -338,7 +338,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||
|
||||
if (!ParentIndexNumber.HasValue && !string.IsNullOrEmpty(Path))
|
||||
{
|
||||
ParentIndexNumber = TVUtils.GetSeasonNumberFromEpisodeFile(Path);
|
||||
ParentIndexNumber = LibraryManager.GetSeasonNumberFromEpisodeFile(Path);
|
||||
}
|
||||
|
||||
// If a change was made record it
|
||||
|
@ -298,7 +298,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||
{
|
||||
if (!IndexNumber.HasValue && !string.IsNullOrEmpty(Path))
|
||||
{
|
||||
IndexNumber = IndexNumber ?? TVUtils.GetSeasonNumberFromPath(Path);
|
||||
IndexNumber = IndexNumber ?? LibraryManager.GetSeasonNumberFromPath(Path);
|
||||
|
||||
// If a change was made record it
|
||||
if (IndexNumber.HasValue)
|
||||
|
@ -347,7 +347,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if ((i.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
|
||||
{
|
||||
return !string.Equals(i.FullName, path, StringComparison.OrdinalIgnoreCase) && EntityResolutionHelper.IsMultiPartFolder(i.FullName);
|
||||
return !string.Equals(i.FullName, path, StringComparison.OrdinalIgnoreCase) && LibraryManager.IsMultiPartFolder(i.FullName);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -362,7 +362,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
return false;
|
||||
}
|
||||
|
||||
return !string.Equals(i.FullName, path, StringComparison.OrdinalIgnoreCase) && EntityResolutionHelper.IsVideoFile(i.FullName) && EntityResolutionHelper.IsMultiPartFile(i.Name);
|
||||
return !string.Equals(i.FullName, path, StringComparison.OrdinalIgnoreCase) && LibraryManager.IsVideoFile(i.FullName) && LibraryManager.IsMultiPartFile(i.Name);
|
||||
});
|
||||
}
|
||||
|
||||
@ -472,7 +472,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
|
||||
return !string.Equals(i.FullName, path, StringComparison.OrdinalIgnoreCase) &&
|
||||
EntityResolutionHelper.IsVideoFile(i.FullName) &&
|
||||
LibraryManager.IsVideoFile(i.FullName) &&
|
||||
i.Name.StartsWith(filenamePrefix + " - ", StringComparison.OrdinalIgnoreCase);
|
||||
});
|
||||
}
|
||||
|
@ -353,5 +353,57 @@ namespace MediaBrowser.Controller.Library
|
||||
string viewType,
|
||||
string sortName,
|
||||
CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is video file] [the specified path].
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns><c>true</c> if [is video file] [the specified path]; otherwise, <c>false</c>.</returns>
|
||||
bool IsVideoFile(string path);
|
||||
|
||||
bool IsAudioFile(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is multi part file] [the specified path].
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns><c>true</c> if [is multi part file] [the specified path]; otherwise, <c>false</c>.</returns>
|
||||
bool IsMultiPartFile(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is multi part folder] [the specified path].
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns><c>true</c> if [is multi part folder] [the specified path]; otherwise, <c>false</c>.</returns>
|
||||
bool IsMultiPartFolder(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the season number from path.
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>System.Nullable<System.Int32>.</returns>
|
||||
int? GetSeasonNumberFromPath(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the season number from episode file.
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>System.Nullable<System.Int32>.</returns>
|
||||
int? GetSeasonNumberFromEpisodeFile(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ending episode number from file.
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>System.Nullable<System.Int32>.</returns>
|
||||
int? GetEndingEpisodeNumberFromFile(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the episode number from file.
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <param name="considerSeasonless">if set to <c>true</c> [consider seasonless].</param>
|
||||
/// <returns>System.Nullable<System.Int32>.</returns>
|
||||
int? GetEpisodeNumberFromFile(string path, bool considerSeasonless);
|
||||
}
|
||||
}
|
@ -1,14 +1,5 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using MediaBrowser.Model.Logging;
|
||||
|
||||
namespace MediaBrowser.Controller.Library
|
||||
{
|
||||
@ -26,436 +17,6 @@ namespace MediaBrowser.Controller.Library
|
||||
/// </summary>
|
||||
public static readonly string BannerUrl = "http://www.thetvdb.com/banners/";
|
||||
|
||||
/// <summary>
|
||||
/// A season folder must contain one of these somewhere in the name
|
||||
/// </summary>
|
||||
private static readonly string[] SeasonFolderNames =
|
||||
{
|
||||
"season",
|
||||
"sæson",
|
||||
"temporada",
|
||||
"saison",
|
||||
"staffel",
|
||||
"series",
|
||||
"сезон"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Used to detect paths that represent episodes, need to make sure they don't also
|
||||
/// match movie titles like "2001 A Space..."
|
||||
/// Currently we limit the numbers here to 2 digits to try and avoid this
|
||||
/// </summary>
|
||||
private static readonly Regex[] EpisodeExpressions =
|
||||
{
|
||||
new Regex(
|
||||
@".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)[sS](?<seasonnumber>\d{1,4})[x,X]?[eE](?<epnumber>\d{1,3})[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})[^\\\/]*$",
|
||||
RegexOptions.Compiled)
|
||||
};
|
||||
private static readonly Regex[] MultipleEpisodeExpressions =
|
||||
{
|
||||
new Regex(
|
||||
@".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})((-| - )\d{1,4}[eExX](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})((-| - )\d{1,4}[xX][eE](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})((-| - )?[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})(-[xE]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))((-| - )\d{1,4}[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))((-| - )\d{1,4}[xX][eE](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))((-| - )?[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))(-[xX]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})((-| - )?[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})(-[xX]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
RegexOptions.Compiled)
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// To avoid the following matching movies they are only valid when contained in a folder which has been matched as a being season, or the media type is TV series
|
||||
/// </summary>
|
||||
private static readonly Regex[] EpisodeExpressionsWithoutSeason =
|
||||
{
|
||||
new Regex(
|
||||
@".*[\\\/](?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*\.\w+$",
|
||||
RegexOptions.Compiled),
|
||||
// "01.avi"
|
||||
new Regex(
|
||||
@".*(\\|\/)(?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*\s?-\s?[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
// "01 - blah.avi", "01-blah.avi"
|
||||
new Regex(
|
||||
@".*(\\|\/)(?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*\.[^\\\/]+$",
|
||||
RegexOptions.Compiled),
|
||||
// "01.blah.avi"
|
||||
new Regex(
|
||||
@".*[\\\/][^\\\/]* - (?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
// "blah - 01.avi", "blah 2 - 01.avi", "blah - 01 blah.avi", "blah 2 - 01 blah", "blah - 01 - blah.avi", "blah 2 - 01 - blah"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the season number from path.
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>System.Nullable{System.Int32}.</returns>
|
||||
public static int? GetSeasonNumberFromPath(string path)
|
||||
{
|
||||
var filename = Path.GetFileName(path);
|
||||
|
||||
if (string.Equals(filename, "specials", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int val;
|
||||
if (int.TryParse(filename, NumberStyles.Integer, CultureInfo.InvariantCulture, out val))
|
||||
{
|
||||
return val;
|
||||
}
|
||||
|
||||
if (filename.StartsWith("s", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var testFilename = filename.Substring(1);
|
||||
|
||||
if (int.TryParse(testFilename, NumberStyles.Integer, CultureInfo.InvariantCulture, out val))
|
||||
{
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
// Look for one of the season folder names
|
||||
foreach (var name in SeasonFolderNames)
|
||||
{
|
||||
var index = filename.IndexOf(name, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
return GetSeasonNumberFromPathSubstring(filename.Substring(index + name.Length));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extracts the season number from the second half of the Season folder name (everything after "Season", or "Staffel")
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>System.Nullable{System.Int32}.</returns>
|
||||
private static int? GetSeasonNumberFromPathSubstring(string path)
|
||||
{
|
||||
var numericStart = -1;
|
||||
var length = 0;
|
||||
|
||||
// Find out where the numbers start, and then keep going until they end
|
||||
for (var i = 0; i < path.Length; i++)
|
||||
{
|
||||
if (char.IsNumber(path, i))
|
||||
{
|
||||
if (numericStart == -1)
|
||||
{
|
||||
numericStart = i;
|
||||
}
|
||||
length++;
|
||||
}
|
||||
else if (numericStart != -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (numericStart == -1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return int.Parse(path.Substring(numericStart, length), CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is season folder] [the specified path].
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <param name="directoryService">The directory service.</param>
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
/// <returns><c>true</c> if [is season folder] [the specified path]; otherwise, <c>false</c>.</returns>
|
||||
private static bool IsSeasonFolder(string path, IDirectoryService directoryService, IFileSystem fileSystem)
|
||||
{
|
||||
var seasonNumber = GetSeasonNumberFromPath(path);
|
||||
var hasSeasonNumber = seasonNumber != null;
|
||||
|
||||
if (!hasSeasonNumber)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//// It's a season folder if it's named as such and does not contain any audio files, apart from theme.mp3
|
||||
//foreach (var fileSystemInfo in directoryService.GetFileSystemEntries(path))
|
||||
//{
|
||||
// var attributes = fileSystemInfo.Attributes;
|
||||
|
||||
// if ((attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// // Can't enforce this because files saved by Bitcasa are always marked System
|
||||
// //if ((attributes & FileAttributes.System) == FileAttributes.System)
|
||||
// //{
|
||||
// // continue;
|
||||
// //}
|
||||
|
||||
// if ((attributes & FileAttributes.Directory) == FileAttributes.Directory)
|
||||
// {
|
||||
// //if (IsBadFolder(fileSystemInfo.Name))
|
||||
// //{
|
||||
// // return false;
|
||||
// //}
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (EntityResolutionHelper.IsAudioFile(fileSystemInfo.FullName) &&
|
||||
// !string.Equals(fileSystem.GetFileNameWithoutExtension(fileSystemInfo), BaseItem.ThemeSongFilename))
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is series folder] [the specified path].
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <param name="considerSeasonlessEntries">if set to <c>true</c> [consider seasonless entries].</param>
|
||||
/// <param name="fileSystemChildren">The file system children.</param>
|
||||
/// <param name="directoryService">The directory service.</param>
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
/// <returns><c>true</c> if [is series folder] [the specified path]; otherwise, <c>false</c>.</returns>
|
||||
public static bool IsSeriesFolder(string path, bool considerSeasonlessEntries, IEnumerable<FileSystemInfo> fileSystemChildren, IDirectoryService directoryService, IFileSystem fileSystem, ILogger logger)
|
||||
{
|
||||
// A folder with more than 3 non-season folders in will not becounted as a series
|
||||
var nonSeriesFolders = 0;
|
||||
|
||||
foreach (var child in fileSystemChildren)
|
||||
{
|
||||
var attributes = child.Attributes;
|
||||
|
||||
if ((attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
|
||||
{
|
||||
//logger.Debug("Igoring series file or folder marked hidden: {0}", child.FullName);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Can't enforce this because files saved by Bitcasa are always marked System
|
||||
//if ((attributes & FileAttributes.System) == FileAttributes.System)
|
||||
//{
|
||||
// logger.Debug("Igoring series subfolder marked system: {0}", child.FullName);
|
||||
// continue;
|
||||
//}
|
||||
|
||||
if ((attributes & FileAttributes.Directory) == FileAttributes.Directory)
|
||||
{
|
||||
if (IsSeasonFolder(child.FullName, directoryService, fileSystem))
|
||||
{
|
||||
//logger.Debug("{0} is a series because of season folder {1}.", path, child.FullName);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (IsBadFolder(child.Name))
|
||||
{
|
||||
logger.Debug("Invalid folder under series: {0}", child.FullName);
|
||||
|
||||
nonSeriesFolders++;
|
||||
}
|
||||
|
||||
if (nonSeriesFolders >= 3)
|
||||
{
|
||||
logger.Debug("{0} not a series due to 3 or more invalid folders.", path);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var fullName = child.FullName;
|
||||
|
||||
if (EntityResolutionHelper.IsVideoFile(fullName) || EntityResolutionHelper.IsVideoPlaceHolder(fullName))
|
||||
{
|
||||
if (GetEpisodeNumberFromFile(fullName, considerSeasonlessEntries).HasValue)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logger.Debug("{0} is not a series folder.", path);
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsBadFolder(string name)
|
||||
{
|
||||
if (string.Equals(name, BaseItem.ThemeSongsFolderName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (string.Equals(name, BaseItem.ThemeVideosFolderName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (string.Equals(name, BaseItem.TrailerFolderName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return !EntityResolutionHelper.IgnoreFolders.Contains(name, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Episodes the number from file.
|
||||
/// </summary>
|
||||
/// <param name="fullPath">The full path.</param>
|
||||
/// <param name="considerSeasonlessNames">if set to <c>true</c> [is in season].</param>
|
||||
/// <returns>System.String.</returns>
|
||||
public static int? GetEpisodeNumberFromFile(string fullPath, bool considerSeasonlessNames)
|
||||
{
|
||||
string fl = fullPath.ToLower();
|
||||
foreach (var r in EpisodeExpressions)
|
||||
{
|
||||
Match m = r.Match(fl);
|
||||
if (m.Success)
|
||||
return ParseEpisodeNumber(m.Groups["epnumber"].Value);
|
||||
}
|
||||
if (considerSeasonlessNames)
|
||||
{
|
||||
var match = EpisodeExpressionsWithoutSeason.Select(r => r.Match(fl))
|
||||
.FirstOrDefault(m => m.Success);
|
||||
|
||||
if (match != null)
|
||||
{
|
||||
return ParseEpisodeNumber(match.Groups["epnumber"].Value);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int? GetEndingEpisodeNumberFromFile(string fullPath)
|
||||
{
|
||||
var fl = fullPath.ToLower();
|
||||
foreach (var r in MultipleEpisodeExpressions)
|
||||
{
|
||||
var m = r.Match(fl);
|
||||
if (m.Success && !string.IsNullOrEmpty(m.Groups["endingepnumber"].Value))
|
||||
return ParseEpisodeNumber(m.Groups["endingepnumber"].Value);
|
||||
}
|
||||
foreach (var r in EpisodeExpressionsWithoutSeason)
|
||||
{
|
||||
var m = r.Match(fl);
|
||||
if (m.Success && !string.IsNullOrEmpty(m.Groups["endingepnumber"].Value))
|
||||
return ParseEpisodeNumber(m.Groups["endingepnumber"].Value);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||
|
||||
private static int? ParseEpisodeNumber(string val)
|
||||
{
|
||||
int num;
|
||||
|
||||
if (!string.IsNullOrEmpty(val) && int.TryParse(val, NumberStyles.Integer, UsCulture, out num))
|
||||
{
|
||||
return num;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Seasons the number from episode file.
|
||||
/// </summary>
|
||||
/// <param name="fullPath">The full path.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
public static int? GetSeasonNumberFromEpisodeFile(string fullPath)
|
||||
{
|
||||
string fl = fullPath.ToLower();
|
||||
foreach (var r in EpisodeExpressions)
|
||||
{
|
||||
Match m = r.Match(fl);
|
||||
if (m.Success)
|
||||
{
|
||||
Group g = m.Groups["seasonnumber"];
|
||||
if (g != null)
|
||||
{
|
||||
var val = g.Value;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(val))
|
||||
{
|
||||
int num;
|
||||
|
||||
if (int.TryParse(val, NumberStyles.Integer, UsCulture, out num))
|
||||
{
|
||||
return num;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetSeriesNameFromEpisodeFile(string fullPath)
|
||||
{
|
||||
var fl = fullPath.ToLower();
|
||||
foreach (var r in EpisodeExpressions)
|
||||
{
|
||||
var m = r.Match(fl);
|
||||
if (m.Success)
|
||||
{
|
||||
var g = m.Groups["seriesname"];
|
||||
if (g != null)
|
||||
{
|
||||
var val = g.Value;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(val))
|
||||
{
|
||||
return val;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the air days.
|
||||
/// </summary>
|
||||
|
@ -306,7 +306,6 @@
|
||||
<Compile Include="MediaEncoding\MediaEncoderHelpers.cs" />
|
||||
<Compile Include="Providers\MetadataProviderPriority.cs" />
|
||||
<Compile Include="Resolvers\BaseItemResolver.cs" />
|
||||
<Compile Include="Resolvers\BaseVideoResolver.cs" />
|
||||
<Compile Include="Resolvers\IItemResolver.cs" />
|
||||
<Compile Include="Library\ILibraryManager.cs" />
|
||||
<Compile Include="Library\IUserManager.cs" />
|
||||
@ -325,7 +324,6 @@
|
||||
<Compile Include="Providers\IImageEnhancer.cs" />
|
||||
<Compile Include="Providers\ProviderRefreshStatus.cs" />
|
||||
<Compile Include="Resolvers\IResolverIgnoreRule.cs" />
|
||||
<Compile Include="Resolvers\EntityResolutionHelper.cs" />
|
||||
<Compile Include="Resolvers\ResolverPriority.cs" />
|
||||
<Compile Include="Library\TVUtils.cs" />
|
||||
<Compile Include="Library\ItemResolveArgs.cs" />
|
||||
|
@ -1,137 +0,0 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace MediaBrowser.Controller.Resolvers
|
||||
{
|
||||
/// <summary>
|
||||
/// Resolves a Path into a Video or Video subclass
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public abstract class BaseVideoResolver<T> : ItemResolver<T>
|
||||
where T : Video, new()
|
||||
{
|
||||
/// <summary>
|
||||
/// Resolves the specified args.
|
||||
/// </summary>
|
||||
/// <param name="args">The args.</param>
|
||||
/// <returns>`0.</returns>
|
||||
protected override T Resolve(ItemResolveArgs args)
|
||||
{
|
||||
return ResolveVideo<T>(args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the video.
|
||||
/// </summary>
|
||||
/// <typeparam name="TVideoType">The type of the T video type.</typeparam>
|
||||
/// <param name="args">The args.</param>
|
||||
/// <returns>``0.</returns>
|
||||
protected TVideoType ResolveVideo<TVideoType>(ItemResolveArgs args)
|
||||
where TVideoType : Video, new()
|
||||
{
|
||||
// If the path is a file check for a matching extensions
|
||||
if (!args.IsDirectory)
|
||||
{
|
||||
// http://wiki.xbmc.org/index.php?title=Media_stubs
|
||||
var isPlaceHolder = EntityResolutionHelper.IsVideoPlaceHolder(args.Path);
|
||||
|
||||
var extension = Path.GetExtension(args.Path);
|
||||
|
||||
var isShortcut = string.Equals(extension, ".strm", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (EntityResolutionHelper.IsVideoFile(args.Path) || isPlaceHolder || isShortcut)
|
||||
{
|
||||
var type = string.Equals(extension, ".iso", StringComparison.OrdinalIgnoreCase) || string.Equals(extension, ".img", StringComparison.OrdinalIgnoreCase) ?
|
||||
VideoType.Iso : VideoType.VideoFile;
|
||||
|
||||
var path = args.Path;
|
||||
|
||||
var video = new TVideoType
|
||||
{
|
||||
VideoType = type,
|
||||
Path = args.Path,
|
||||
IsInMixedFolder = true,
|
||||
IsPlaceHolder = isPlaceHolder,
|
||||
IsShortcut = isShortcut
|
||||
};
|
||||
|
||||
if (isPlaceHolder)
|
||||
{
|
||||
if (args.Path.EndsWith("dvd.disc", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
video.VideoType = VideoType.Dvd;
|
||||
}
|
||||
else if (args.Path.EndsWith("hddvd.disc", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
video.VideoType = VideoType.HdDvd;
|
||||
}
|
||||
else if (args.Path.EndsWith("bluray.disc", StringComparison.OrdinalIgnoreCase) ||
|
||||
args.Path.EndsWith("brrip.disc", StringComparison.OrdinalIgnoreCase) ||
|
||||
args.Path.EndsWith("bd25.disc", StringComparison.OrdinalIgnoreCase) ||
|
||||
args.Path.EndsWith("bd50.disc", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
video.VideoType = VideoType.BluRay;
|
||||
}
|
||||
}
|
||||
|
||||
return video;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the initial item values.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="args">The args.</param>
|
||||
protected override void SetInitialItemValues(T item, ItemResolveArgs args)
|
||||
{
|
||||
base.SetInitialItemValues(item, args);
|
||||
|
||||
if (item.Path.IndexOf("[3d]", StringComparison.OrdinalIgnoreCase) != -1 || item.Path.IndexOf("[sbs3d]", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
{
|
||||
item.Video3DFormat = Video3DFormat.HalfSideBySide;
|
||||
}
|
||||
else if (item.Path.IndexOf("[hsbs]", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
{
|
||||
item.Video3DFormat = Video3DFormat.HalfSideBySide;
|
||||
}
|
||||
else if (item.Path.IndexOf("[fsbs]", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
{
|
||||
item.Video3DFormat = Video3DFormat.FullSideBySide;
|
||||
}
|
||||
else if (item.Path.IndexOf("[ftab]", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
{
|
||||
item.Video3DFormat = Video3DFormat.FullTopAndBottom;
|
||||
}
|
||||
else if (item.Path.IndexOf("[htab]", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
{
|
||||
item.Video3DFormat = Video3DFormat.HalfTopAndBottom;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Support Xbmc conventions:
|
||||
// http://wiki.xbmc.org/index.php?title=3D
|
||||
var name = Path.GetFileName(item.Path);
|
||||
|
||||
name = name.Replace('.', ' ').Replace('_', ' ').Replace('-', ' ');
|
||||
|
||||
if (name.IndexOf(" 3d hsbs ", StringComparison.OrdinalIgnoreCase) != -1 ||
|
||||
name.IndexOf(" 3d sbs ", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
{
|
||||
item.Video3DFormat = Video3DFormat.HalfSideBySide;
|
||||
}
|
||||
else if (name.IndexOf(" 3d htab ", StringComparison.OrdinalIgnoreCase) != -1 ||
|
||||
name.IndexOf(" 3d tab ", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
{
|
||||
item.Video3DFormat = Video3DFormat.HalfTopAndBottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,263 +0,0 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace MediaBrowser.Controller.Resolvers
|
||||
{
|
||||
/// <summary>
|
||||
/// Class EntityResolutionHelper
|
||||
/// </summary>
|
||||
public static class EntityResolutionHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Any folder named in this list will be ignored - can be added to at runtime for extensibility
|
||||
/// </summary>
|
||||
public static readonly List<string> IgnoreFolders = new List<string>
|
||||
{
|
||||
"metadata",
|
||||
"ps3_update",
|
||||
"ps3_vprm",
|
||||
"extrafanart",
|
||||
"extrathumbs",
|
||||
".actors",
|
||||
".wd_tv"
|
||||
|
||||
};
|
||||
|
||||
private static readonly Regex MultiFileRegex = new Regex(
|
||||
@"(.*?)([ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck]|d)[ _.-]*[0-9]+)(.*?)(\.[^.]+)$",
|
||||
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
private static readonly Regex MultiFolderRegex = new Regex(
|
||||
@"(.*?)([ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck]|d)[ _.-]*[0-9]+)$",
|
||||
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is multi part file] [the specified path].
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns><c>true</c> if [is multi part file] [the specified path]; otherwise, <c>false</c>.</returns>
|
||||
public static bool IsMultiPartFile(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new ArgumentNullException("path");
|
||||
}
|
||||
|
||||
path = Path.GetFileName(path);
|
||||
|
||||
return MultiFileRegex.Match(path).Success;
|
||||
}
|
||||
|
||||
public static bool IsMultiPartFolder(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new ArgumentNullException("path");
|
||||
}
|
||||
|
||||
path = Path.GetFileName(path);
|
||||
|
||||
return MultiFolderRegex.Match(path).Success;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The audio file extensions
|
||||
/// </summary>
|
||||
public static readonly string[] AudioFileExtensions =
|
||||
{
|
||||
".mp3",
|
||||
".flac",
|
||||
".wma",
|
||||
".aac",
|
||||
".acc",
|
||||
".m4a",
|
||||
".m4b",
|
||||
".wav",
|
||||
".ape",
|
||||
".ogg",
|
||||
".oga"
|
||||
|
||||
//".asf",
|
||||
//".mp4"
|
||||
};
|
||||
|
||||
private static readonly Dictionary<string, string> AudioFileExtensionsDictionary = AudioFileExtensions.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is audio file] [the specified args].
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns><c>true</c> if [is audio file] [the specified args]; otherwise, <c>false</c>.</returns>
|
||||
public static bool IsAudioFile(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new ArgumentNullException("path");
|
||||
}
|
||||
|
||||
var extension = Path.GetExtension(path);
|
||||
|
||||
if (string.IsNullOrEmpty(extension))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return AudioFileExtensionsDictionary.ContainsKey(extension);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is video file] [the specified path].
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns><c>true</c> if [is video file] [the specified path]; otherwise, <c>false</c>.</returns>
|
||||
public static bool IsVideoFile(string path)
|
||||
{
|
||||
return MimeTypes.IsVideoFile(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is place holder] [the specified path].
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns><c>true</c> if [is place holder] [the specified path]; otherwise, <c>false</c>.</returns>
|
||||
/// <exception cref="System.ArgumentNullException">path</exception>
|
||||
public static bool IsVideoPlaceHolder(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new ArgumentNullException("path");
|
||||
}
|
||||
|
||||
var extension = Path.GetExtension(path);
|
||||
|
||||
return string.Equals(extension, ".disc", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is multi disc album folder] [the specified path].
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns><c>true</c> if [is multi disc album folder] [the specified path]; otherwise, <c>false</c>.</returns>
|
||||
public static bool IsMultiDiscAlbumFolder(string path)
|
||||
{
|
||||
var filename = Path.GetFileName(path);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(filename))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Normalize
|
||||
// Remove whitespace
|
||||
filename = filename.Replace("-", " ");
|
||||
filename = filename.Replace(".", " ");
|
||||
filename = filename.Replace("(", " ");
|
||||
filename = filename.Replace(")", " ");
|
||||
filename = Regex.Replace(filename, @"\s+", " ");
|
||||
|
||||
var prefixes = new[] { "disc", "cd", "disk", "vol", "volume" };
|
||||
|
||||
filename = filename.TrimStart();
|
||||
|
||||
foreach (var prefix in prefixes)
|
||||
{
|
||||
if (filename.IndexOf(prefix, StringComparison.OrdinalIgnoreCase) == 0)
|
||||
{
|
||||
var tmp = filename.Substring(prefix.Length);
|
||||
|
||||
tmp = tmp.Trim().Split(' ').FirstOrDefault() ?? string.Empty;
|
||||
|
||||
int val;
|
||||
if (int.TryParse(tmp, NumberStyles.Any, CultureInfo.InvariantCulture, out val))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures DateCreated and DateModified have values
|
||||
/// </summary>
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="args">The args.</param>
|
||||
/// <param name="includeCreationTime">if set to <c>true</c> [include creation time].</param>
|
||||
public static void EnsureDates(IFileSystem fileSystem, BaseItem item, ItemResolveArgs args, bool includeCreationTime)
|
||||
{
|
||||
if (fileSystem == null)
|
||||
{
|
||||
throw new ArgumentNullException("fileSystem");
|
||||
}
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException("item");
|
||||
}
|
||||
if (args == null)
|
||||
{
|
||||
throw new ArgumentNullException("args");
|
||||
}
|
||||
|
||||
// See if a different path came out of the resolver than what went in
|
||||
if (!string.Equals(args.Path, item.Path, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var childData = args.IsDirectory ? args.GetFileSystemEntryByPath(item.Path) : null;
|
||||
|
||||
if (childData != null)
|
||||
{
|
||||
if (includeCreationTime)
|
||||
{
|
||||
SetDateCreated(item, fileSystem, childData);
|
||||
}
|
||||
|
||||
item.DateModified = fileSystem.GetLastWriteTimeUtc(childData);
|
||||
}
|
||||
else
|
||||
{
|
||||
var fileData = fileSystem.GetFileSystemInfo(item.Path);
|
||||
|
||||
if (fileData.Exists)
|
||||
{
|
||||
if (includeCreationTime)
|
||||
{
|
||||
SetDateCreated(item, fileSystem, fileData);
|
||||
}
|
||||
item.DateModified = fileSystem.GetLastWriteTimeUtc(fileData);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (includeCreationTime)
|
||||
{
|
||||
SetDateCreated(item, fileSystem, args.FileInfo);
|
||||
}
|
||||
item.DateModified = fileSystem.GetLastWriteTimeUtc(args.FileInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetDateCreated(BaseItem item, IFileSystem fileSystem, FileSystemInfo info)
|
||||
{
|
||||
var config = BaseItem.ConfigurationManager.GetMetadataConfiguration();
|
||||
|
||||
if (config.UseFileCreationTimeForDateAdded)
|
||||
{
|
||||
item.DateCreated = fileSystem.GetCreationTimeUtc(info);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.DateCreated = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -161,7 +161,7 @@ namespace MediaBrowser.Dlna.Didl
|
||||
AddVideoResource(container, video, deviceId, filter, contentFeature, streamInfo);
|
||||
}
|
||||
|
||||
foreach (var subtitle in streamInfo.GetExternalSubtitles(_serverAddress))
|
||||
foreach (var subtitle in streamInfo.GetExternalSubtitles(_serverAddress, false))
|
||||
{
|
||||
AddSubtitleElement(container, subtitle);
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
return string.Format("Params={0}", string.Join(";", list.ToArray()));
|
||||
}
|
||||
|
||||
public List<SubtitleStreamInfo> GetExternalSubtitles(string baseUrl)
|
||||
public List<SubtitleStreamInfo> GetExternalSubtitles(string baseUrl, bool includeSelectedTrackOnly)
|
||||
{
|
||||
if (string.IsNullOrEmpty(baseUrl))
|
||||
{
|
||||
@ -164,40 +164,55 @@ namespace MediaBrowser.Model.Dlna
|
||||
return list;
|
||||
}
|
||||
|
||||
if (!SubtitleStreamIndex.HasValue)
|
||||
{
|
||||
return list;
|
||||
}
|
||||
|
||||
// HLS will preserve timestamps so we can just grab the full subtitle stream
|
||||
long startPositionTicks = StringHelper.EqualsIgnoreCase(Protocol, "hls")
|
||||
? 0
|
||||
: StartPositionTicks;
|
||||
|
||||
// First add the selected track
|
||||
if (SubtitleStreamIndex.HasValue)
|
||||
{
|
||||
foreach (MediaStream stream in MediaSource.MediaStreams)
|
||||
{
|
||||
if (stream.Type == MediaStreamType.Subtitle && stream.IsTextSubtitleStream && stream.Index == SubtitleStreamIndex.Value)
|
||||
{
|
||||
AddSubtitle(list, stream, baseUrl, startPositionTicks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!includeSelectedTrackOnly)
|
||||
{
|
||||
foreach (MediaStream stream in MediaSource.MediaStreams)
|
||||
{
|
||||
if (stream.Type == MediaStreamType.Subtitle && stream.IsTextSubtitleStream && (!SubtitleStreamIndex.HasValue || stream.Index != SubtitleStreamIndex.Value))
|
||||
{
|
||||
AddSubtitle(list, stream, baseUrl, startPositionTicks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private void AddSubtitle(List<SubtitleStreamInfo> list, MediaStream stream, string baseUrl, long startPositionTicks)
|
||||
{
|
||||
string url = string.Format("{0}/Videos/{1}/{2}/Subtitles/{3}/{4}/Stream.{5}",
|
||||
baseUrl,
|
||||
ItemId,
|
||||
MediaSourceId,
|
||||
StringHelper.ToStringCultureInvariant(SubtitleStreamIndex.Value),
|
||||
StringHelper.ToStringCultureInvariant(stream.Index),
|
||||
StringHelper.ToStringCultureInvariant(startPositionTicks),
|
||||
SubtitleFormat);
|
||||
|
||||
foreach (MediaStream stream in MediaSource.MediaStreams)
|
||||
list.Add(new SubtitleStreamInfo
|
||||
{
|
||||
if (stream.Type == MediaStreamType.Subtitle && stream.Index == SubtitleStreamIndex.Value)
|
||||
{
|
||||
list.Add(new SubtitleStreamInfo
|
||||
{
|
||||
Url = url,
|
||||
IsForced = stream.IsForced,
|
||||
Language = stream.Language,
|
||||
Name = stream.Language ?? "Unknown",
|
||||
Format = SubtitleFormat
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
Url = url,
|
||||
IsForced = stream.IsForced,
|
||||
Language = stream.Language,
|
||||
Name = stream.Language ?? "Unknown",
|
||||
Format = SubtitleFormat
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -53,6 +53,10 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\MediaBrowser.BdInfo.1.0.0.10\lib\net35\DvdLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MediaBrowser.Naming, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\MediaBrowser.Naming.1.0.0.1\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MoreLinq, Version=1.1.17511.0, Culture=neutral, PublicKeyToken=384d532d7e88985d, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\morelinq.1.1.0\lib\net35\MoreLinq.dll</HintPath>
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MediaBrowser.BdInfo" version="1.0.0.10" targetFramework="net45" />
|
||||
<package id="MediaBrowser.Naming" version="1.0.0.1" targetFramework="net45" />
|
||||
<package id="morelinq" version="1.1.0" targetFramework="net45" />
|
||||
<package id="taglib" version="2.1.0.0" targetFramework="net45" />
|
||||
</packages>
|
@ -26,6 +26,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Server.Implementations.Library;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Channels
|
||||
{
|
||||
@ -318,13 +319,13 @@ namespace MediaBrowser.Server.Implementations.Channels
|
||||
|
||||
if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
files = files.Where(i => EntityResolutionHelper.IsVideoFile(i.FullName));
|
||||
files = files.Where(i => _libraryManager.IsVideoFile(i.FullName));
|
||||
}
|
||||
else
|
||||
{
|
||||
files = files.Where(i => EntityResolutionHelper.IsAudioFile(i.FullName));
|
||||
files = files.Where(i => _libraryManager.IsAudioFile(i.FullName));
|
||||
}
|
||||
|
||||
|
||||
var file = files
|
||||
.FirstOrDefault(i => i.Name.StartsWith(filenamePrefix, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
|
@ -1,15 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Connect
|
||||
{
|
||||
public static class Validator
|
||||
{
|
||||
static Regex ValidEmailRegex = CreateValidEmailRegex();
|
||||
static readonly Regex ValidEmailRegex = CreateValidEmailRegex();
|
||||
|
||||
/// <summary>
|
||||
/// Taken from http://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx
|
||||
@ -17,9 +12,9 @@ namespace MediaBrowser.Server.Implementations.Connect
|
||||
/// <returns></returns>
|
||||
private static Regex CreateValidEmailRegex()
|
||||
{
|
||||
string validEmailPattern = @"^(?!\.)(""([^""\r\\]|\\[""\r\\])*""|"
|
||||
+ @"([-a-z0-9!#$%&'*+/=?^_`{|}~]|(?<!\.)\.)*)(?<!\.)"
|
||||
+ @"@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$";
|
||||
const string validEmailPattern = @"^(?!\.)(""([^""\r\\]|\\[""\r\\])*""|"
|
||||
+ @"([-a-z0-9!#$%&'*+/=?^_`{|}~]|(?<!\.)\.)*)(?<!\.)"
|
||||
+ @"@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$";
|
||||
|
||||
return new Regex(validEmailPattern, RegexOptions.IgnoreCase);
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Server.Implementations.Library;
|
||||
using MediaBrowser.Server.Implementations.Library.Resolvers.TV;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||
{
|
||||
@ -55,18 +57,18 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||
FileSize = new FileInfo(path).Length
|
||||
};
|
||||
|
||||
var seriesName = TVUtils.GetSeriesNameFromEpisodeFile(path);
|
||||
var seriesName = SeriesResolver.GetSeriesNameFromEpisodeFile(path);
|
||||
|
||||
if (!string.IsNullOrEmpty(seriesName))
|
||||
{
|
||||
var season = TVUtils.GetSeasonNumberFromEpisodeFile(path);
|
||||
var season = SeriesResolver.GetSeasonNumberFromEpisodeFile(path);
|
||||
|
||||
result.ExtractedSeasonNumber = season;
|
||||
|
||||
if (season.HasValue)
|
||||
{
|
||||
// Passing in true will include a few extra regex's
|
||||
var episode = TVUtils.GetEpisodeNumberFromFile(path, true);
|
||||
var episode = SeriesResolver.GetEpisodeNumberFromFile(path, true);
|
||||
|
||||
result.ExtractedEpisodeNumber = episode;
|
||||
|
||||
@ -74,7 +76,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||
{
|
||||
_logger.Debug("Extracted information from {0}. Series name {1}, Season {2}, Episode {3}", path, seriesName, season, episode);
|
||||
|
||||
var endingEpisodeNumber = TVUtils.GetEndingEpisodeNumberFromFile(path);
|
||||
var endingEpisodeNumber = SeriesResolver.GetEndingEpisodeNumberFromFile(path);
|
||||
|
||||
result.ExtractedEndingEpisodeNumber = endingEpisodeNumber;
|
||||
|
||||
@ -253,7 +255,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||
try
|
||||
{
|
||||
var filesOfOtherExtensions = Directory.EnumerateFiles(folder, "*", SearchOption.TopDirectoryOnly)
|
||||
.Where(i => EntityResolutionHelper.IsVideoFile(i) && string.Equals(_fileSystem.GetFileNameWithoutExtension(i), targetFileNameWithoutExtension, StringComparison.OrdinalIgnoreCase));
|
||||
.Where(i => _libraryManager.IsVideoFile(i) && string.Equals(_fileSystem.GetFileNameWithoutExtension(i), targetFileNameWithoutExtension, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
episodePaths.AddRange(filesOfOtherExtensions);
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Server.Implementations.Library;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||
{
|
||||
@ -45,7 +46,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||
|
||||
var eligibleFiles = watchLocations.SelectMany(GetFilesToOrganize)
|
||||
.OrderBy(_fileSystem.GetCreationTimeUtc)
|
||||
.Where(i => EntityResolutionHelper.IsVideoFile(i.FullName) && i.Length >= minFileBytes)
|
||||
.Where(i => _libraryManager.IsVideoFile(i.FullName) && i.Length >= minFileBytes)
|
||||
.ToList();
|
||||
|
||||
progress.Report(10);
|
||||
|
@ -6,7 +6,6 @@ using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Localization;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using MediaBrowser.Model.Channels;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Entities;
|
||||
@ -25,13 +24,15 @@ namespace MediaBrowser.Server.Implementations.Intros
|
||||
private readonly IChannelManager _channelManager;
|
||||
private readonly ILocalizationManager _localization;
|
||||
private readonly IConfigurationManager _serverConfig;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
public DefaultIntroProvider(ISecurityManager security, IChannelManager channelManager, ILocalizationManager localization, IConfigurationManager serverConfig)
|
||||
public DefaultIntroProvider(ISecurityManager security, IChannelManager channelManager, ILocalizationManager localization, IConfigurationManager serverConfig, ILibraryManager libraryManager)
|
||||
{
|
||||
_security = security;
|
||||
_channelManager = channelManager;
|
||||
_localization = localization;
|
||||
_serverConfig = serverConfig;
|
||||
_libraryManager = libraryManager;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<IntroInfo>> GetIntros(BaseItem item, User user)
|
||||
@ -226,7 +227,7 @@ namespace MediaBrowser.Server.Implementations.Intros
|
||||
}
|
||||
|
||||
return Directory.EnumerateFiles(options.CustomIntroPath, "*", SearchOption.AllDirectories)
|
||||
.Where(EntityResolutionHelper.IsVideoFile);
|
||||
.Where(_libraryManager.IsVideoFile);
|
||||
}
|
||||
|
||||
private bool FilterByParentalRating(int? ratingLevel, BaseItem item)
|
||||
|
@ -14,10 +14,12 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
public class CoreResolutionIgnoreRule : IResolverIgnoreRule
|
||||
{
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
public CoreResolutionIgnoreRule(IFileSystem fileSystem)
|
||||
public CoreResolutionIgnoreRule(IFileSystem fileSystem, ILibraryManager libraryManager)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_libraryManager = libraryManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -89,7 +91,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
if (args.Parent != null)
|
||||
{
|
||||
// Don't resolve these into audio files
|
||||
if (string.Equals(_fileSystem.GetFileNameWithoutExtension(filename), BaseItem.ThemeSongFilename) && EntityResolutionHelper.IsAudioFile(filename))
|
||||
if (string.Equals(_fileSystem.GetFileNameWithoutExtension(filename), BaseItem.ThemeSongFilename) && _libraryManager.IsAudioFile(filename))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -0,0 +1,104 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Library
|
||||
{
|
||||
/// <summary>
|
||||
/// Class EntityResolutionHelper
|
||||
/// </summary>
|
||||
public static class EntityResolutionHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Any folder named in this list will be ignored - can be added to at runtime for extensibility
|
||||
/// </summary>
|
||||
public static readonly List<string> IgnoreFolders = new List<string>
|
||||
{
|
||||
"metadata",
|
||||
"ps3_update",
|
||||
"ps3_vprm",
|
||||
"extrafanart",
|
||||
"extrathumbs",
|
||||
".actors",
|
||||
".wd_tv"
|
||||
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Ensures DateCreated and DateModified have values
|
||||
/// </summary>
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="args">The args.</param>
|
||||
/// <param name="includeCreationTime">if set to <c>true</c> [include creation time].</param>
|
||||
public static void EnsureDates(IFileSystem fileSystem, BaseItem item, ItemResolveArgs args, bool includeCreationTime)
|
||||
{
|
||||
if (fileSystem == null)
|
||||
{
|
||||
throw new ArgumentNullException("fileSystem");
|
||||
}
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException("item");
|
||||
}
|
||||
if (args == null)
|
||||
{
|
||||
throw new ArgumentNullException("args");
|
||||
}
|
||||
|
||||
// See if a different path came out of the resolver than what went in
|
||||
if (!string.Equals(args.Path, item.Path, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var childData = args.IsDirectory ? args.GetFileSystemEntryByPath(item.Path) : null;
|
||||
|
||||
if (childData != null)
|
||||
{
|
||||
if (includeCreationTime)
|
||||
{
|
||||
SetDateCreated(item, fileSystem, childData);
|
||||
}
|
||||
|
||||
item.DateModified = fileSystem.GetLastWriteTimeUtc(childData);
|
||||
}
|
||||
else
|
||||
{
|
||||
var fileData = fileSystem.GetFileSystemInfo(item.Path);
|
||||
|
||||
if (fileData.Exists)
|
||||
{
|
||||
if (includeCreationTime)
|
||||
{
|
||||
SetDateCreated(item, fileSystem, fileData);
|
||||
}
|
||||
item.DateModified = fileSystem.GetLastWriteTimeUtc(fileData);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (includeCreationTime)
|
||||
{
|
||||
SetDateCreated(item, fileSystem, args.FileInfo);
|
||||
}
|
||||
item.DateModified = fileSystem.GetLastWriteTimeUtc(args.FileInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetDateCreated(BaseItem item, IFileSystem fileSystem, FileSystemInfo info)
|
||||
{
|
||||
var config = BaseItem.ConfigurationManager.GetMetadataConfiguration();
|
||||
|
||||
if (config.UseFileCreationTimeForDateAdded)
|
||||
{
|
||||
item.DateCreated = fileSystem.GetCreationTimeUtc(info);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.DateCreated = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -15,6 +15,10 @@ using MediaBrowser.Controller.Sorting;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Naming.Audio;
|
||||
using MediaBrowser.Naming.IO;
|
||||
using MediaBrowser.Naming.Video;
|
||||
using MediaBrowser.Server.Implementations.Library.Resolvers.TV;
|
||||
using MediaBrowser.Server.Implementations.Library.Validators;
|
||||
using MediaBrowser.Server.Implementations.ScheduledTasks;
|
||||
using MoreLinq;
|
||||
@ -1628,5 +1632,49 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public bool IsVideoFile(string path)
|
||||
{
|
||||
var parser = new VideoFileParser(new ExpandedVideoOptions(), new Naming.Logging.NullLogger());
|
||||
return parser.IsVideoFile(path);
|
||||
}
|
||||
|
||||
public bool IsAudioFile(string path)
|
||||
{
|
||||
var parser = new AudioFileParser(new AudioOptions());
|
||||
return parser.IsAudioFile(path);
|
||||
}
|
||||
|
||||
public bool IsMultiPartFile(string path)
|
||||
{
|
||||
var parser = new MultiPartParser(new ExpandedVideoOptions(), new Naming.Logging.NullLogger());
|
||||
return parser.Parse(path, FileInfoType.File).IsMultiPart;
|
||||
}
|
||||
|
||||
public bool IsMultiPartFolder(string path)
|
||||
{
|
||||
var parser = new MultiPartParser(new ExpandedVideoOptions(), new Naming.Logging.NullLogger());
|
||||
return parser.Parse(path, FileInfoType.Directory).IsMultiPart;
|
||||
}
|
||||
|
||||
public int? GetSeasonNumberFromPath(string path)
|
||||
{
|
||||
return SeriesResolver.GetSeasonNumberFromPath(path);
|
||||
}
|
||||
|
||||
public int? GetSeasonNumberFromEpisodeFile(string path)
|
||||
{
|
||||
return SeriesResolver.GetSeasonNumberFromEpisodeFile(path);
|
||||
}
|
||||
|
||||
public int? GetEndingEpisodeNumberFromFile(string path)
|
||||
{
|
||||
return SeriesResolver.GetEndingEpisodeNumberFromFile(path);
|
||||
}
|
||||
|
||||
public int? GetEpisodeNumberFromFile(string path, bool considerSeasonless)
|
||||
{
|
||||
return SeriesResolver.GetEpisodeNumberFromFile(path, considerSeasonless);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@ -63,14 +62,14 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
if (string.IsNullOrEmpty(item.Name) && !string.IsNullOrEmpty(item.Path))
|
||||
{
|
||||
//we use our resolve args name here to get the name of the containg folder, not actual video file
|
||||
item.Name = GetMBName(args.FileInfo.Name, (args.FileInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory);
|
||||
item.Name = GetMbName(args.FileInfo.Name, (args.FileInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The MB name regex
|
||||
/// </summary>
|
||||
private static readonly Regex MBNameRegex = new Regex(@"(\[.*?\])", RegexOptions.Compiled);
|
||||
private static readonly Regex MbNameRegex = new Regex(@"(\[.*?\])", RegexOptions.Compiled);
|
||||
|
||||
/// <summary>
|
||||
/// Strip out attribute items and return just the name we will use for items
|
||||
@ -78,7 +77,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <param name="path">Assumed to be a file or directory path</param>
|
||||
/// <param name="isDirectory">if set to <c>true</c> [is directory].</param>
|
||||
/// <returns>The cleaned name</returns>
|
||||
private static string GetMBName(string path, bool isDirectory)
|
||||
private static string GetMbName(string path, bool isDirectory)
|
||||
{
|
||||
//first just get the file or directory name
|
||||
var fn = isDirectory ? Path.GetFileName(path) : Path.GetFileNameWithoutExtension(path);
|
||||
@ -89,8 +88,9 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
return fn;
|
||||
}
|
||||
|
||||
public static string StripBrackets(string inputString) {
|
||||
var output = MBNameRegex.Replace(inputString, string.Empty).Trim();
|
||||
private static string StripBrackets(string inputString)
|
||||
{
|
||||
var output = MbNameRegex.Replace(inputString, string.Empty).Trim();
|
||||
return Regex.Replace(output, @"\s+", " ");
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,13 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
/// </summary>
|
||||
public class AudioResolver : ItemResolver<Controller.Entities.Audio.Audio>
|
||||
{
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
public AudioResolver(ILibraryManager libraryManager)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the priority.
|
||||
/// </summary>
|
||||
@ -30,15 +37,14 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
|
||||
if (!args.IsDirectory)
|
||||
{
|
||||
if (EntityResolutionHelper.IsAudioFile(args.Path))
|
||||
if (_libraryManager.IsAudioFile(args.Path))
|
||||
{
|
||||
var collectionType = args.GetCollectionType();
|
||||
|
||||
var isStandalone = args.Parent == null;
|
||||
|
||||
if (isStandalone ||
|
||||
string.Equals(collectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase) ||
|
||||
string.IsNullOrEmpty(collectionType))
|
||||
string.Equals(collectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return new Controller.Entities.Audio.Audio();
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Naming.Audio;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@ -21,11 +22,13 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
public MusicAlbumResolver(ILogger logger, IFileSystem fileSystem)
|
||||
public MusicAlbumResolver(ILogger logger, IFileSystem fileSystem, ILibraryManager libraryManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_fileSystem = fileSystem;
|
||||
_libraryManager = libraryManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -68,7 +71,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
return null;
|
||||
}
|
||||
|
||||
return IsMusicAlbum(args, isMusicMediaFolder) ? new MusicAlbum() : null;
|
||||
return IsMusicAlbum(args) ? new MusicAlbum() : null;
|
||||
}
|
||||
|
||||
|
||||
@ -76,29 +79,29 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
/// Determine if the supplied file data points to a music album
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <param name="isMusicMediaFolder">if set to <c>true</c> [is music media folder].</param>
|
||||
/// <param name="directoryService">The directory service.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <returns><c>true</c> if [is music album] [the specified data]; otherwise, <c>false</c>.</returns>
|
||||
public static bool IsMusicAlbum(string path, bool isMusicMediaFolder, IDirectoryService directoryService, ILogger logger, IFileSystem fileSystem)
|
||||
public static bool IsMusicAlbum(string path, IDirectoryService directoryService, ILogger logger, IFileSystem fileSystem,
|
||||
ILibraryManager libraryManager)
|
||||
{
|
||||
return ContainsMusic(directoryService.GetFileSystemEntries(path), isMusicMediaFolder, true, directoryService, logger, fileSystem);
|
||||
return ContainsMusic(directoryService.GetFileSystemEntries(path), true, directoryService, logger, fileSystem, libraryManager);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine if the supplied resolve args should be considered a music album
|
||||
/// </summary>
|
||||
/// <param name="args">The args.</param>
|
||||
/// <param name="isMusicMediaFolder">if set to <c>true</c> [is music media folder].</param>
|
||||
/// <returns><c>true</c> if [is music album] [the specified args]; otherwise, <c>false</c>.</returns>
|
||||
private bool IsMusicAlbum(ItemResolveArgs args, bool isMusicMediaFolder)
|
||||
private bool IsMusicAlbum(ItemResolveArgs args)
|
||||
{
|
||||
// Args points to an album if parent is an Artist folder or it directly contains music
|
||||
if (args.IsDirectory)
|
||||
{
|
||||
//if (args.Parent is MusicArtist) return true; //saves us from testing children twice
|
||||
if (ContainsMusic(args.FileSystemChildren, isMusicMediaFolder, true, args.DirectoryService, _logger, _fileSystem)) return true;
|
||||
if (ContainsMusic(args.FileSystemChildren, true, args.DirectoryService, _logger, _fileSystem, _libraryManager)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -108,41 +111,34 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
/// Determine if the supplied list contains what we should consider music
|
||||
/// </summary>
|
||||
/// <param name="list">The list.</param>
|
||||
/// <param name="isMusicMediaFolder">if set to <c>true</c> [is music media folder].</param>
|
||||
/// <param name="allowSubfolders">if set to <c>true</c> [allow subfolders].</param>
|
||||
/// <param name="directoryService">The directory service.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <returns><c>true</c> if the specified list contains music; otherwise, <c>false</c>.</returns>
|
||||
private static bool ContainsMusic(IEnumerable<FileSystemInfo> list,
|
||||
bool isMusicMediaFolder,
|
||||
bool allowSubfolders,
|
||||
IDirectoryService directoryService,
|
||||
ILogger logger,
|
||||
IFileSystem fileSystem)
|
||||
IFileSystem fileSystem,
|
||||
ILibraryManager libraryManager)
|
||||
{
|
||||
// If list contains at least 2 audio files or at least one and no video files consider it to contain music
|
||||
var foundAudio = 0;
|
||||
|
||||
var discSubfolderCount = 0;
|
||||
|
||||
foreach (var fileSystemInfo in list)
|
||||
{
|
||||
if ((fileSystemInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
|
||||
{
|
||||
if (isMusicMediaFolder && allowSubfolders && IsAlbumSubfolder(fileSystemInfo, true, directoryService, logger, fileSystem))
|
||||
if (allowSubfolders && IsAlbumSubfolder(fileSystemInfo, directoryService, logger, fileSystem, libraryManager))
|
||||
{
|
||||
discSubfolderCount++;
|
||||
}
|
||||
if (!IsAdditionalSubfolderAllowed(fileSystemInfo))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var fullName = fileSystemInfo.FullName;
|
||||
|
||||
if (EntityResolutionHelper.IsAudioFile(fullName))
|
||||
if (libraryManager.IsAudioFile(fullName))
|
||||
{
|
||||
// Don't resolve these into audio files
|
||||
if (string.Equals(fileSystem.GetFileNameWithoutExtension(fullName), BaseItem.ThemeSongFilename))
|
||||
@ -150,22 +146,14 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
continue;
|
||||
}
|
||||
|
||||
foundAudio++;
|
||||
}
|
||||
else if (EntityResolutionHelper.IsVideoFile(fullName)) return false;
|
||||
else if (EntityResolutionHelper.IsVideoPlaceHolder(fullName)) return false;
|
||||
|
||||
if (foundAudio >= 2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// or a single audio file and no video files
|
||||
return foundAudio > 0 || discSubfolderCount > 0;
|
||||
return discSubfolderCount > 0;
|
||||
}
|
||||
|
||||
private static bool IsAlbumSubfolder(FileSystemInfo directory, bool isMusicMediaFolder, IDirectoryService directoryService, ILogger logger, IFileSystem fileSystem)
|
||||
private static bool IsAlbumSubfolder(FileSystemInfo directory, IDirectoryService directoryService, ILogger logger, IFileSystem fileSystem, ILibraryManager libraryManager)
|
||||
{
|
||||
var path = directory.FullName;
|
||||
|
||||
@ -173,7 +161,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
{
|
||||
logger.Debug("Found multi-disc folder: " + path);
|
||||
|
||||
return ContainsMusic(directoryService.GetFileSystemEntries(path), isMusicMediaFolder, false, directoryService, logger, fileSystem);
|
||||
return ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem, libraryManager);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -181,13 +169,20 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
|
||||
public static bool IsMultiDiscFolder(string path)
|
||||
{
|
||||
return EntityResolutionHelper.IsMultiDiscAlbumFolder(path);
|
||||
return IsMultiDiscAlbumFolder(path);
|
||||
}
|
||||
|
||||
private static bool IsAdditionalSubfolderAllowed(FileSystemInfo directory)
|
||||
/// <summary>
|
||||
/// Determines whether [is multi disc album folder] [the specified path].
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns><c>true</c> if [is multi disc album folder] [the specified path]; otherwise, <c>false</c>.</returns>
|
||||
private static bool IsMultiDiscAlbumFolder(string path)
|
||||
{
|
||||
// Resolver will ignore them based on rules engine
|
||||
return true;
|
||||
var parser = new AlbumParser(new AudioOptions(), new Naming.Logging.NullLogger());
|
||||
var result = parser.ParseMultiPart(path);
|
||||
|
||||
return result.IsMultiPart;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,13 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
public MusicArtistResolver(ILogger logger, IFileSystem fileSystem)
|
||||
public MusicArtistResolver(ILogger logger, IFileSystem fileSystem, ILibraryManager libraryManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_fileSystem = fileSystem;
|
||||
_libraryManager = libraryManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -74,7 +76,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
var directoryService = args.DirectoryService;
|
||||
|
||||
// If we contain an album assume we are an artist folder
|
||||
return args.FileSystemChildren.Where(i => (i.Attributes & FileAttributes.Directory) == FileAttributes.Directory).Any(i => MusicAlbumResolver.IsMusicAlbum(i.FullName, isMusicMediaFolder, directoryService, _logger, _fileSystem)) ? new MusicArtist() : null;
|
||||
return args.FileSystemChildren.Where(i => (i.Attributes & FileAttributes.Directory) == FileAttributes.Directory).Any(i => MusicAlbumResolver.IsMusicAlbum(i.FullName, directoryService, _logger, _fileSystem, _libraryManager)) ? new MusicArtist() : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,96 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Naming.Video;
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Library.Resolvers
|
||||
{
|
||||
/// <summary>
|
||||
/// Resolves a Path into a Video or Video subclass
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public abstract class BaseVideoResolver<T> : Controller.Resolvers.ItemResolver<T>
|
||||
where T : Video, new()
|
||||
{
|
||||
protected readonly ILibraryManager LibraryManager;
|
||||
|
||||
protected BaseVideoResolver(ILibraryManager libraryManager)
|
||||
{
|
||||
LibraryManager = libraryManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the specified args.
|
||||
/// </summary>
|
||||
/// <param name="args">The args.</param>
|
||||
/// <returns>`0.</returns>
|
||||
protected override T Resolve(ItemResolveArgs args)
|
||||
{
|
||||
return ResolveVideo<T>(args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the video.
|
||||
/// </summary>
|
||||
/// <typeparam name="TVideoType">The type of the T video type.</typeparam>
|
||||
/// <param name="args">The args.</param>
|
||||
/// <returns>``0.</returns>
|
||||
protected TVideoType ResolveVideo<TVideoType>(ItemResolveArgs args)
|
||||
where TVideoType : Video, new()
|
||||
{
|
||||
// If the path is a file check for a matching extensions
|
||||
if (!args.IsDirectory)
|
||||
{
|
||||
var parser = new VideoFileParser(new ExpandedVideoOptions(), new Naming.Logging.NullLogger());
|
||||
var videoInfo = parser.ParseFile(args.Path);
|
||||
|
||||
if (videoInfo == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var isShortcut = string.Equals(videoInfo.Container, "strm", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (LibraryManager.IsVideoFile(args.Path) || videoInfo.IsStub || isShortcut)
|
||||
{
|
||||
var type = string.Equals(videoInfo.Container, "iso", StringComparison.OrdinalIgnoreCase) || string.Equals(videoInfo.Container, "img", StringComparison.OrdinalIgnoreCase) ?
|
||||
VideoType.Iso :
|
||||
VideoType.VideoFile;
|
||||
|
||||
var path = args.Path;
|
||||
|
||||
var video = new TVideoType
|
||||
{
|
||||
VideoType = type,
|
||||
Path = path,
|
||||
IsInMixedFolder = true,
|
||||
IsPlaceHolder = videoInfo.IsStub,
|
||||
IsShortcut = isShortcut,
|
||||
Name = videoInfo.Name
|
||||
};
|
||||
|
||||
if (videoInfo.IsStub)
|
||||
{
|
||||
if (string.Equals(videoInfo.StubType, "dvd", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
video.VideoType = VideoType.Dvd;
|
||||
}
|
||||
else if (string.Equals(videoInfo.StubType, "hddvd", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
video.VideoType = VideoType.HdDvd;
|
||||
}
|
||||
else if (string.Equals(videoInfo.StubType, "bluray", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
video.VideoType = VideoType.BluRay;
|
||||
}
|
||||
}
|
||||
|
||||
return video;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
|
||||
{
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
public LocalTrailerResolver(IFileSystem fileSystem)
|
||||
public LocalTrailerResolver(ILibraryManager libraryManager, IFileSystem fileSystem) : base(libraryManager)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
@ -21,14 +21,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
public class MovieResolver : BaseVideoResolver<Video>
|
||||
{
|
||||
private readonly IServerApplicationPaths _applicationPaths;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
public MovieResolver(IServerApplicationPaths appPaths, ILibraryManager libraryManager, ILogger logger, IFileSystem fileSystem)
|
||||
public MovieResolver(ILibraryManager libraryManager, IServerApplicationPaths applicationPaths, ILogger logger, IFileSystem fileSystem) : base(libraryManager)
|
||||
{
|
||||
_applicationPaths = appPaths;
|
||||
_libraryManager = libraryManager;
|
||||
_applicationPaths = applicationPaths;
|
||||
_logger = logger;
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
@ -221,7 +219,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
};
|
||||
}
|
||||
|
||||
if (EntityResolutionHelper.IsMultiPartFolder(filename))
|
||||
if (LibraryManager.IsMultiPartFolder(filename))
|
||||
{
|
||||
multiDiscFolders.Add(child);
|
||||
}
|
||||
@ -235,7 +233,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
continue;
|
||||
}
|
||||
|
||||
var childArgs = new ItemResolveArgs(_applicationPaths, _libraryManager, directoryService)
|
||||
var childArgs = new ItemResolveArgs(_applicationPaths, LibraryManager, directoryService)
|
||||
{
|
||||
FileInfo = child,
|
||||
Path = child.FullName,
|
||||
@ -378,7 +376,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
var firstMovie = sortedMovies[0];
|
||||
|
||||
// They must all be part of the sequence if we're going to consider it a multi-part movie
|
||||
if (sortedMovies.All(i => EntityResolutionHelper.IsMultiPartFile(i.Path)))
|
||||
if (sortedMovies.All(i => LibraryManager.IsMultiPartFile(i.Path)))
|
||||
{
|
||||
// Only support up to 8 (matches Plex), to help avoid incorrect detection
|
||||
if (sortedMovies.Count <= 8)
|
||||
|
@ -11,6 +11,10 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
/// </summary>
|
||||
public class EpisodeResolver : BaseVideoResolver<Episode>
|
||||
{
|
||||
public EpisodeResolver(ILibraryManager libraryManager) : base(libraryManager)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the specified args.
|
||||
/// </summary>
|
||||
@ -73,7 +77,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
|
||||
if (episode.ParentIndexNumber == null)
|
||||
{
|
||||
episode.ParentIndexNumber = TVUtils.GetSeasonNumberFromEpisodeFile(args.Path);
|
||||
episode.ParentIndexNumber = SeriesResolver.GetSeasonNumberFromEpisodeFile(args.Path);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,9 +34,9 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
{
|
||||
var season = new Season
|
||||
{
|
||||
IndexNumber = TVUtils.GetSeasonNumberFromPath(args.Path)
|
||||
IndexNumber = SeriesResolver.GetSeasonNumberFromPath(args.Path)
|
||||
};
|
||||
|
||||
|
||||
if (season.IndexNumber.HasValue && season.IndexNumber.Value == 0)
|
||||
{
|
||||
season.Name = _config.Configuration.SeasonZeroDisplayName;
|
||||
|
@ -1,13 +1,19 @@
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
{
|
||||
@ -18,11 +24,13 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
{
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
public SeriesResolver(IFileSystem fileSystem, ILogger logger)
|
||||
public SeriesResolver(IFileSystem fileSystem, ILogger logger, ILibraryManager libraryManager)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_logger = logger;
|
||||
_libraryManager = libraryManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -71,7 +79,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
return null;
|
||||
}
|
||||
|
||||
if (TVUtils.IsSeriesFolder(args.Path, isTvShowsFolder, args.FileSystemChildren, args.DirectoryService, _fileSystem, _logger))
|
||||
if (IsSeriesFolder(args.Path, isTvShowsFolder, args.FileSystemChildren, args.DirectoryService, _fileSystem, _logger, _libraryManager))
|
||||
{
|
||||
return new Series();
|
||||
}
|
||||
@ -80,6 +88,454 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is series folder] [the specified path].
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <param name="considerSeasonlessEntries">if set to <c>true</c> [consider seasonless entries].</param>
|
||||
/// <param name="fileSystemChildren">The file system children.</param>
|
||||
/// <param name="directoryService">The directory service.</param>
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
/// <returns><c>true</c> if [is series folder] [the specified path]; otherwise, <c>false</c>.</returns>
|
||||
public static bool IsSeriesFolder(string path, bool considerSeasonlessEntries, IEnumerable<FileSystemInfo> fileSystemChildren, IDirectoryService directoryService, IFileSystem fileSystem, ILogger logger, ILibraryManager libraryManager)
|
||||
{
|
||||
// A folder with more than 3 non-season folders in will not becounted as a series
|
||||
var nonSeriesFolders = 0;
|
||||
|
||||
foreach (var child in fileSystemChildren)
|
||||
{
|
||||
var attributes = child.Attributes;
|
||||
|
||||
if ((attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
|
||||
{
|
||||
//logger.Debug("Igoring series file or folder marked hidden: {0}", child.FullName);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Can't enforce this because files saved by Bitcasa are always marked System
|
||||
//if ((attributes & FileAttributes.System) == FileAttributes.System)
|
||||
//{
|
||||
// logger.Debug("Igoring series subfolder marked system: {0}", child.FullName);
|
||||
// continue;
|
||||
//}
|
||||
|
||||
if ((attributes & FileAttributes.Directory) == FileAttributes.Directory)
|
||||
{
|
||||
if (IsSeasonFolder(child.FullName, directoryService, fileSystem))
|
||||
{
|
||||
//logger.Debug("{0} is a series because of season folder {1}.", path, child.FullName);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (IsBadFolder(child.Name))
|
||||
{
|
||||
logger.Debug("Invalid folder under series: {0}", child.FullName);
|
||||
|
||||
nonSeriesFolders++;
|
||||
}
|
||||
|
||||
if (nonSeriesFolders >= 3)
|
||||
{
|
||||
logger.Debug("{0} not a series due to 3 or more invalid folders.", path);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var fullName = child.FullName;
|
||||
|
||||
if (libraryManager.IsVideoFile(fullName) || IsVideoPlaceHolder(fullName))
|
||||
{
|
||||
if (GetEpisodeNumberFromFile(fullName, considerSeasonlessEntries).HasValue)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logger.Debug("{0} is not a series folder.", path);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is place holder] [the specified path].
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns><c>true</c> if [is place holder] [the specified path]; otherwise, <c>false</c>.</returns>
|
||||
/// <exception cref="System.ArgumentNullException">path</exception>
|
||||
private static bool IsVideoPlaceHolder(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new ArgumentNullException("path");
|
||||
}
|
||||
|
||||
var extension = Path.GetExtension(path);
|
||||
|
||||
return string.Equals(extension, ".disc", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private static bool IsBadFolder(string name)
|
||||
{
|
||||
if (string.Equals(name, BaseItem.ThemeSongsFolderName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (string.Equals(name, BaseItem.ThemeVideosFolderName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (string.Equals(name, BaseItem.TrailerFolderName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return !EntityResolutionHelper.IgnoreFolders.Contains(name, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is season folder] [the specified path].
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <param name="directoryService">The directory service.</param>
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
/// <returns><c>true</c> if [is season folder] [the specified path]; otherwise, <c>false</c>.</returns>
|
||||
private static bool IsSeasonFolder(string path, IDirectoryService directoryService, IFileSystem fileSystem)
|
||||
{
|
||||
var seasonNumber = GetSeasonNumberFromPath(path);
|
||||
var hasSeasonNumber = seasonNumber != null;
|
||||
|
||||
if (!hasSeasonNumber)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//// It's a season folder if it's named as such and does not contain any audio files, apart from theme.mp3
|
||||
//foreach (var fileSystemInfo in directoryService.GetFileSystemEntries(path))
|
||||
//{
|
||||
// var attributes = fileSystemInfo.Attributes;
|
||||
|
||||
// if ((attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// // Can't enforce this because files saved by Bitcasa are always marked System
|
||||
// //if ((attributes & FileAttributes.System) == FileAttributes.System)
|
||||
// //{
|
||||
// // continue;
|
||||
// //}
|
||||
|
||||
// if ((attributes & FileAttributes.Directory) == FileAttributes.Directory)
|
||||
// {
|
||||
// //if (IsBadFolder(fileSystemInfo.Name))
|
||||
// //{
|
||||
// // return false;
|
||||
// //}
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (EntityResolutionHelper.IsAudioFile(fileSystemInfo.FullName) &&
|
||||
// !string.Equals(fileSystem.GetFileNameWithoutExtension(fileSystemInfo), BaseItem.ThemeSongFilename))
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A season folder must contain one of these somewhere in the name
|
||||
/// </summary>
|
||||
private static readonly string[] SeasonFolderNames =
|
||||
{
|
||||
"season",
|
||||
"sæson",
|
||||
"temporada",
|
||||
"saison",
|
||||
"staffel",
|
||||
"series",
|
||||
"сезон"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Used to detect paths that represent episodes, need to make sure they don't also
|
||||
/// match movie titles like "2001 A Space..."
|
||||
/// Currently we limit the numbers here to 2 digits to try and avoid this
|
||||
/// </summary>
|
||||
private static readonly Regex[] EpisodeExpressions =
|
||||
{
|
||||
new Regex(
|
||||
@".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)[sS](?<seasonnumber>\d{1,4})[x,X]?[eE](?<epnumber>\d{1,3})[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})[^\\\/]*$",
|
||||
RegexOptions.Compiled)
|
||||
};
|
||||
private static readonly Regex[] MultipleEpisodeExpressions =
|
||||
{
|
||||
new Regex(
|
||||
@".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})((-| - )\d{1,4}[eExX](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})((-| - )\d{1,4}[xX][eE](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})((-| - )?[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})(-[xE]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))((-| - )\d{1,4}[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))((-| - )\d{1,4}[xX][eE](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))((-| - )?[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))(-[xX]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})((-| - )?[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
new Regex(
|
||||
@".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})(-[xX]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
RegexOptions.Compiled)
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// To avoid the following matching movies they are only valid when contained in a folder which has been matched as a being season, or the media type is TV series
|
||||
/// </summary>
|
||||
private static readonly Regex[] EpisodeExpressionsWithoutSeason =
|
||||
{
|
||||
new Regex(
|
||||
@".*[\\\/](?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*\.\w+$",
|
||||
RegexOptions.Compiled),
|
||||
// "01.avi"
|
||||
new Regex(
|
||||
@".*(\\|\/)(?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*\s?-\s?[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
// "01 - blah.avi", "01-blah.avi"
|
||||
new Regex(
|
||||
@".*(\\|\/)(?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*\.[^\\\/]+$",
|
||||
RegexOptions.Compiled),
|
||||
// "01.blah.avi"
|
||||
new Regex(
|
||||
@".*[\\\/][^\\\/]* - (?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*[^\\\/]*$",
|
||||
RegexOptions.Compiled),
|
||||
// "blah - 01.avi", "blah 2 - 01.avi", "blah - 01 blah.avi", "blah 2 - 01 blah", "blah - 01 - blah.avi", "blah 2 - 01 - blah"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the season number from path.
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>System.Nullable{System.Int32}.</returns>
|
||||
public static int? GetSeasonNumberFromPath(string path)
|
||||
{
|
||||
var filename = Path.GetFileName(path);
|
||||
|
||||
if (string.Equals(filename, "specials", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int val;
|
||||
if (int.TryParse(filename, NumberStyles.Integer, CultureInfo.InvariantCulture, out val))
|
||||
{
|
||||
return val;
|
||||
}
|
||||
|
||||
if (filename.StartsWith("s", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var testFilename = filename.Substring(1);
|
||||
|
||||
if (int.TryParse(testFilename, NumberStyles.Integer, CultureInfo.InvariantCulture, out val))
|
||||
{
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
// Look for one of the season folder names
|
||||
foreach (var name in SeasonFolderNames)
|
||||
{
|
||||
var index = filename.IndexOf(name, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
return GetSeasonNumberFromPathSubstring(filename.Substring(index + name.Length));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extracts the season number from the second half of the Season folder name (everything after "Season", or "Staffel")
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>System.Nullable{System.Int32}.</returns>
|
||||
private static int? GetSeasonNumberFromPathSubstring(string path)
|
||||
{
|
||||
var numericStart = -1;
|
||||
var length = 0;
|
||||
|
||||
// Find out where the numbers start, and then keep going until they end
|
||||
for (var i = 0; i < path.Length; i++)
|
||||
{
|
||||
if (char.IsNumber(path, i))
|
||||
{
|
||||
if (numericStart == -1)
|
||||
{
|
||||
numericStart = i;
|
||||
}
|
||||
length++;
|
||||
}
|
||||
else if (numericStart != -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (numericStart == -1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return int.Parse(path.Substring(numericStart, length), CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Episodes the number from file.
|
||||
/// </summary>
|
||||
/// <param name="fullPath">The full path.</param>
|
||||
/// <param name="considerSeasonlessNames">if set to <c>true</c> [is in season].</param>
|
||||
/// <returns>System.String.</returns>
|
||||
public static int? GetEpisodeNumberFromFile(string fullPath, bool considerSeasonlessNames)
|
||||
{
|
||||
string fl = fullPath.ToLower();
|
||||
foreach (var r in EpisodeExpressions)
|
||||
{
|
||||
Match m = r.Match(fl);
|
||||
if (m.Success)
|
||||
return ParseEpisodeNumber(m.Groups["epnumber"].Value);
|
||||
}
|
||||
if (considerSeasonlessNames)
|
||||
{
|
||||
var match = EpisodeExpressionsWithoutSeason.Select(r => r.Match(fl))
|
||||
.FirstOrDefault(m => m.Success);
|
||||
|
||||
if (match != null)
|
||||
{
|
||||
return ParseEpisodeNumber(match.Groups["epnumber"].Value);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int? GetEndingEpisodeNumberFromFile(string fullPath)
|
||||
{
|
||||
var fl = fullPath.ToLower();
|
||||
foreach (var r in MultipleEpisodeExpressions)
|
||||
{
|
||||
var m = r.Match(fl);
|
||||
if (m.Success && !string.IsNullOrEmpty(m.Groups["endingepnumber"].Value))
|
||||
return ParseEpisodeNumber(m.Groups["endingepnumber"].Value);
|
||||
}
|
||||
foreach (var r in EpisodeExpressionsWithoutSeason)
|
||||
{
|
||||
var m = r.Match(fl);
|
||||
if (m.Success && !string.IsNullOrEmpty(m.Groups["endingepnumber"].Value))
|
||||
return ParseEpisodeNumber(m.Groups["endingepnumber"].Value);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Seasons the number from episode file.
|
||||
/// </summary>
|
||||
/// <param name="fullPath">The full path.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
public static int? GetSeasonNumberFromEpisodeFile(string fullPath)
|
||||
{
|
||||
string fl = fullPath.ToLower();
|
||||
foreach (var r in EpisodeExpressions)
|
||||
{
|
||||
Match m = r.Match(fl);
|
||||
if (m.Success)
|
||||
{
|
||||
Group g = m.Groups["seasonnumber"];
|
||||
if (g != null)
|
||||
{
|
||||
var val = g.Value;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(val))
|
||||
{
|
||||
int num;
|
||||
|
||||
if (int.TryParse(val, NumberStyles.Integer, UsCulture, out num))
|
||||
{
|
||||
return num;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetSeriesNameFromEpisodeFile(string fullPath)
|
||||
{
|
||||
var fl = fullPath.ToLower();
|
||||
foreach (var r in EpisodeExpressions)
|
||||
{
|
||||
var m = r.Match(fl);
|
||||
if (m.Success)
|
||||
{
|
||||
var g = m.Groups["seriesname"];
|
||||
if (g != null)
|
||||
{
|
||||
var val = g.Value;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(val))
|
||||
{
|
||||
return val;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||
|
||||
private static int? ParseEpisodeNumber(string val)
|
||||
{
|
||||
int num;
|
||||
|
||||
if (!string.IsNullOrEmpty(val) && int.TryParse(val, NumberStyles.Integer, UsCulture, out num))
|
||||
{
|
||||
return num;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the initial item values.
|
||||
/// </summary>
|
||||
|
@ -1,5 +1,9 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Library.Resolvers
|
||||
{
|
||||
@ -8,6 +12,31 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
|
||||
/// </summary>
|
||||
public class VideoResolver : BaseVideoResolver<Video>
|
||||
{
|
||||
public VideoResolver(ILibraryManager libraryManager)
|
||||
: base(libraryManager)
|
||||
{
|
||||
}
|
||||
|
||||
protected override Video Resolve(ItemResolveArgs args)
|
||||
{
|
||||
if (args.Parent != null)
|
||||
{
|
||||
var collectionType = args.GetCollectionType() ?? string.Empty;
|
||||
var accepted = new[]
|
||||
{
|
||||
string.Empty,
|
||||
CollectionType.HomeVideos
|
||||
};
|
||||
|
||||
if (!accepted.Contains(collectionType, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return base.Resolve(args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the priority.
|
||||
/// </summary>
|
||||
|
@ -19,7 +19,6 @@ using MediaBrowser.Model.Events;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Model.Users;
|
||||
using MediaBrowser.Server.Implementations.Security;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
@ -49,6 +49,10 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\ThirdParty\libwebp\Imazen.WebP.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MediaBrowser.Naming, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\MediaBrowser.Naming.1.0.0.1\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Nat, Version=1.2.21.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Mono.Nat.1.2.21.0\lib\net40\Mono.Nat.dll</HintPath>
|
||||
@ -174,8 +178,10 @@
|
||||
<Compile Include="Intros\DefaultIntroProvider.cs" />
|
||||
<Compile Include="IO\LibraryMonitor.cs" />
|
||||
<Compile Include="Library\CoreResolutionIgnoreRule.cs" />
|
||||
<Compile Include="Library\EntityResolutionHelper.cs" />
|
||||
<Compile Include="Library\LibraryManager.cs" />
|
||||
<Compile Include="Library\MusicManager.cs" />
|
||||
<Compile Include="Library\Resolvers\BaseVideoResolver.cs" />
|
||||
<Compile Include="Library\Resolvers\PhotoAlbumResolver.cs" />
|
||||
<Compile Include="Library\Resolvers\PhotoResolver.cs" />
|
||||
<Compile Include="Library\Resolvers\PlaylistResolver.cs" />
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MediaBrowser.Naming" version="1.0.0.1" targetFramework="net45" />
|
||||
<package id="Mono.Nat" version="1.2.21.0" targetFramework="net45" />
|
||||
<package id="morelinq" version="1.1.0" targetFramework="net45" />
|
||||
</packages>
|
@ -53,12 +53,8 @@
|
||||
<Compile Include="MediaEncoding\Subtitles\AssParserTests.cs" />
|
||||
<Compile Include="MediaEncoding\Subtitles\SrtParserTests.cs" />
|
||||
<Compile Include="MediaEncoding\Subtitles\VttWriterTest.cs" />
|
||||
<Compile Include="Providers\MovieDbProviderTests.cs" />
|
||||
<Compile Include="Resolvers\MovieResolverTests.cs" />
|
||||
<Compile Include="Resolvers\MusicResolverTests.cs" />
|
||||
<Compile Include="Resolvers\TvUtilTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Server.Implementations\Library\ResolverHelperTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MediaBrowser.Controller\MediaBrowser.Controller.csproj">
|
||||
|
@ -1,41 +0,0 @@
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace MediaBrowser.Tests.Providers {
|
||||
[TestClass]
|
||||
public class MovieDbProviderTests {
|
||||
[TestMethod]
|
||||
public void TestNameMatches() {
|
||||
var name = string.Empty;
|
||||
int? year = null;
|
||||
|
||||
NameParser.ParseName("My Movie (2013)", out name, out year);
|
||||
Assert.AreEqual("My Movie", name);
|
||||
Assert.AreEqual(2013, year);
|
||||
|
||||
name = string.Empty;
|
||||
year = null;
|
||||
NameParser.ParseName("My Movie 2 (2013)", out name, out year);
|
||||
Assert.AreEqual("My Movie 2", name);
|
||||
Assert.AreEqual(2013, year);
|
||||
|
||||
name = string.Empty;
|
||||
year = null;
|
||||
NameParser.ParseName("My Movie 2001 (2013)", out name, out year);
|
||||
Assert.AreEqual("My Movie 2001", name);
|
||||
Assert.AreEqual(2013, year);
|
||||
|
||||
name = string.Empty;
|
||||
year = null;
|
||||
NameParser.ParseName("My Movie - 2 (2013)", out name, out year);
|
||||
Assert.AreEqual("My Movie - 2", name);
|
||||
Assert.AreEqual(2013, year);
|
||||
|
||||
name = string.Empty;
|
||||
year = null;
|
||||
NameParser.ParseName("curse.of.chucky.2013.stv.unrated.multi.1080p.bluray.x264-rough", out name, out year);
|
||||
Assert.AreEqual("curse.of.chucky", name);
|
||||
Assert.AreEqual(2013, year);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace MediaBrowser.Tests.Resolvers
|
||||
{
|
||||
[TestClass]
|
||||
public class MovieResolverTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestMultiPartFiles()
|
||||
{
|
||||
Assert.IsFalse(EntityResolutionHelper.IsMultiPartFile(@"Braveheart.mkv"));
|
||||
Assert.IsFalse(EntityResolutionHelper.IsMultiPartFile(@"Braveheart - 480p.mkv"));
|
||||
Assert.IsFalse(EntityResolutionHelper.IsMultiPartFile(@"Braveheart - 720p.mkv"));
|
||||
|
||||
Assert.IsFalse(EntityResolutionHelper.IsMultiPartFile(@"blah blah.mkv"));
|
||||
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFile(@"blah blah - cd1.mkv"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFile(@"blah blah - disc1.mkv"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFile(@"blah blah - disk1.mkv"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFile(@"blah blah - pt1.mkv"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFile(@"blah blah - part1.mkv"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFile(@"blah blah - dvd1.mkv"));
|
||||
|
||||
// Add a space
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFile(@"blah blah - cd 1.mkv"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFile(@"blah blah - disc 1.mkv"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFile(@"blah blah - disk 1.mkv"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFile(@"blah blah - pt 1.mkv"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFile(@"blah blah - part 1.mkv"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFile(@"blah blah - dvd 1.mkv"));
|
||||
|
||||
// Not case sensitive
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFile(@"blah blah - Disc1.mkv"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMultiPartFolders()
|
||||
{
|
||||
Assert.IsFalse(EntityResolutionHelper.IsMultiPartFolder(@"blah blah"));
|
||||
Assert.IsFalse(EntityResolutionHelper.IsMultiPartFolder(@"d:\\music\weezer\\03 Pinkerton"));
|
||||
Assert.IsFalse(EntityResolutionHelper.IsMultiPartFolder(@"d:\\music\\michael jackson\\Bad (2012 Remaster)"));
|
||||
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFolder(@"blah blah - cd1"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFolder(@"blah blah - disc1"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFolder(@"blah blah - disk1"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFolder(@"blah blah - pt1"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFolder(@"blah blah - part1"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFolder(@"blah blah - dvd1"));
|
||||
|
||||
// Add a space
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFolder(@"blah blah - cd 1"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFolder(@"blah blah - disc 1"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFolder(@"blah blah - disk 1"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFolder(@"blah blah - pt 1"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFolder(@"blah blah - part 1"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFolder(@"blah blah - dvd 1"));
|
||||
|
||||
// Not case sensitive
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiPartFolder(@"blah blah - Disc1"));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace MediaBrowser.Tests.Resolvers
|
||||
{
|
||||
[TestClass]
|
||||
public class MusicResolverTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestMultiDiscAlbums()
|
||||
{
|
||||
Assert.IsFalse(EntityResolutionHelper.IsMultiDiscAlbumFolder(@"blah blah"));
|
||||
Assert.IsFalse(EntityResolutionHelper.IsMultiDiscAlbumFolder(@"d:\\music\weezer\\03 Pinkerton"));
|
||||
Assert.IsFalse(EntityResolutionHelper.IsMultiDiscAlbumFolder(@"d:\\music\\michael jackson\\Bad (2012 Remaster)"));
|
||||
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiDiscAlbumFolder(@"cd1"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiDiscAlbumFolder(@"disc1"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiDiscAlbumFolder(@"disk1"));
|
||||
|
||||
// Add a space
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiDiscAlbumFolder(@"cd 1"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiDiscAlbumFolder(@"disc 1"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiDiscAlbumFolder(@"disk 1"));
|
||||
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiDiscAlbumFolder(@"cd - 1"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiDiscAlbumFolder(@"disc- 1"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiDiscAlbumFolder(@"disk - 1"));
|
||||
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiDiscAlbumFolder(@"Disc 01 (Hugo Wolf · 24 Lieder)"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiDiscAlbumFolder(@"Disc 04 (Encores and Folk Songs)"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiDiscAlbumFolder(@"Disc04 (Encores and Folk Songs)"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiDiscAlbumFolder(@"Disc 04(Encores and Folk Songs)"));
|
||||
Assert.IsTrue(EntityResolutionHelper.IsMultiDiscAlbumFolder(@"Disc04(Encores and Folk Songs)"));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Server.Implementations.Library.Resolvers.TV;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace MediaBrowser.Tests.Resolvers
|
||||
@ -9,237 +10,237 @@ namespace MediaBrowser.Tests.Resolvers
|
||||
[TestMethod]
|
||||
public void TestGetEpisodeNumberFromFile()
|
||||
{
|
||||
Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 02\S02E03 blah.avi", true));
|
||||
Assert.AreEqual(03, SeriesResolver.GetEpisodeNumberFromFile(@"Season 02\S02E03 blah.avi", true));
|
||||
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 1\01x02 blah.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 1\S01x02 blah.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 1\S01E02 blah.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 1\S01xE02 blah.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 1\seriesname 01x02 blah.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 1\seriesname S01x02 blah.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 1\seriesname S01E02 blah.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 1\seriesname S01xE02 blah.avi", true));
|
||||
Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2\Elementary - 02x03 - 02x04 - 02x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2\02x03 - 02x04 - 02x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2\02x03-04-15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2\Elementary - 02x03-04-15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 02\02x03-E15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 02\Elementary - 02x03-E15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 02\02x03 - x04 - x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 02\Elementary - 02x03 - x04 - x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 02\02x03x04x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 02\Elementary - 02x03x04x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(23, TVUtils.GetEpisodeNumberFromFile(@"Season 1\Elementary - S01E23-E24-E26 - The Woman.mp4", true));
|
||||
Assert.AreEqual(23, TVUtils.GetEpisodeNumberFromFile(@"Season 1\S01E23-E24-E26 - The Woman.mp4", true));
|
||||
Assert.AreEqual(9, TVUtils.GetEpisodeNumberFromFile(@"Season 25\The Simpsons.S25E09.Steal this episode.mp4", true));
|
||||
Assert.AreEqual(8, TVUtils.GetEpisodeNumberFromFile(@"The Simpsons\The Simpsons.S25E08.Steal this episode.mp4", false));
|
||||
Assert.AreEqual(136, TVUtils.GetEpisodeNumberFromFile(@"Season 2\[HorribleSubs] Hunter X Hunter - 136 [720p].mkv",true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"Season 1\01x02 blah.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"Season 1\S01x02 blah.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"Season 1\S01E02 blah.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"Season 1\S01xE02 blah.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"Season 1\seriesname 01x02 blah.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"Season 1\seriesname S01x02 blah.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"Season 1\seriesname S01E02 blah.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"Season 1\seriesname S01xE02 blah.avi", true));
|
||||
Assert.AreEqual(03, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2\Elementary - 02x03 - 02x04 - 02x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2\02x03 - 02x04 - 02x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2\02x03-04-15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2\Elementary - 02x03-04-15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, SeriesResolver.GetEpisodeNumberFromFile(@"Season 02\02x03-E15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, SeriesResolver.GetEpisodeNumberFromFile(@"Season 02\Elementary - 02x03-E15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, SeriesResolver.GetEpisodeNumberFromFile(@"Season 02\02x03 - x04 - x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, SeriesResolver.GetEpisodeNumberFromFile(@"Season 02\Elementary - 02x03 - x04 - x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, SeriesResolver.GetEpisodeNumberFromFile(@"Season 02\02x03x04x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, SeriesResolver.GetEpisodeNumberFromFile(@"Season 02\Elementary - 02x03x04x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(23, SeriesResolver.GetEpisodeNumberFromFile(@"Season 1\Elementary - S01E23-E24-E26 - The Woman.mp4", true));
|
||||
Assert.AreEqual(23, SeriesResolver.GetEpisodeNumberFromFile(@"Season 1\S01E23-E24-E26 - The Woman.mp4", true));
|
||||
Assert.AreEqual(9, SeriesResolver.GetEpisodeNumberFromFile(@"Season 25\The Simpsons.S25E09.Steal this episode.mp4", true));
|
||||
Assert.AreEqual(8, SeriesResolver.GetEpisodeNumberFromFile(@"The Simpsons\The Simpsons.S25E08.Steal this episode.mp4", false));
|
||||
Assert.AreEqual(136, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2\[HorribleSubs] Hunter X Hunter - 136 [720p].mkv",true));
|
||||
|
||||
//Four Digits seasons
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\2009x02 blah.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\S2009x02 blah.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\S2009E02 blah.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\S2009xE02 blah.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\seriesname 2009x02 blah.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\seriesname S2009x02 blah.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\seriesname S2009E02 blah.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\seriesname S2009xE02 blah.avi", true));
|
||||
Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03 - 2009x04 - 2009x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\2009x03 - 2009x04 - 2009x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\2009x03-04-15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03-04-15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\2009x03-E15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03-E15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\2009x03 - x04 - x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03 - x04 - x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\2009x03x04x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03x04x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(23, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\Elementary - S2009E23-E24-E26 - The Woman.mp4", true));
|
||||
Assert.AreEqual(23, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\S2009E23-E24-E26 - The Woman.mp4", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2009\2009x02 blah.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2009\S2009x02 blah.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2009\S2009E02 blah.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2009\S2009xE02 blah.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2009\seriesname 2009x02 blah.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2009\seriesname S2009x02 blah.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2009\seriesname S2009E02 blah.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2009\seriesname S2009xE02 blah.avi", true));
|
||||
Assert.AreEqual(03, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03 - 2009x04 - 2009x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2009\2009x03 - 2009x04 - 2009x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2009\2009x03-04-15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03-04-15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2009\2009x03-E15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03-E15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2009\2009x03 - x04 - x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03 - x04 - x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2009\2009x03x04x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(03, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03x04x15 - Ep Name.ext", true));
|
||||
Assert.AreEqual(23, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2009\Elementary - S2009E23-E24-E26 - The Woman.mp4", true));
|
||||
Assert.AreEqual(23, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2009\S2009E23-E24-E26 - The Woman.mp4", true));
|
||||
|
||||
//Without season number
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 1\02 - blah.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 2\02 - blah 14 blah.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 1\02 - blah-02 a.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 2\02.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"Season 1\02 - blah.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2\02 - blah 14 blah.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"Season 1\02 - blah-02 a.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"Season 2\02.avi", true));
|
||||
|
||||
//Without seasons
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"The Simpsons\02.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"The Simpsons\02 - Ep Name.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"The Simpsons\02-Ep Name.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"The Simpsons\02.EpName.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"The Simpsons\The Simpsons - 02.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"The Simpsons\The Simpsons - 02 - Ep Name.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"The Simpsons\The Simpsons - 02 Ep Name.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"The Simpsons\The Simpsons 5 - 02 - Ep Name.avi", true));
|
||||
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"The Simpsons\The Simpsons 5 - 02 Ep Name.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"The Simpsons\02.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"The Simpsons\02 - Ep Name.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"The Simpsons\02-Ep Name.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"The Simpsons\02.EpName.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"The Simpsons\The Simpsons - 02.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"The Simpsons\The Simpsons - 02 - Ep Name.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"The Simpsons\The Simpsons - 02 Ep Name.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"The Simpsons\The Simpsons 5 - 02 - Ep Name.avi", true));
|
||||
Assert.AreEqual(02, SeriesResolver.GetEpisodeNumberFromFile(@"The Simpsons\The Simpsons 5 - 02 Ep Name.avi", true));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestGetEndingEpisodeNumberFromFile()
|
||||
{
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\4x01 – 20 Hours in America (1).mkv"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 1\4x01 – 20 Hours in America (1).mkv"));
|
||||
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\01x02 blah.avi"));
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\S01x02 blah.avi"));
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\S01E02 blah.avi"));
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\S01xE02 blah.avi"));
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\seriesname 01x02 blah.avi"));
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\seriesname S01x02 blah.avi"));
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\seriesname S01E02 blah.avi"));
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\seriesname S01xE02 blah.avi"));
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\02x03 - 04 Ep Name.ext"));
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\My show name 02x03 - 04 Ep Name.ext"));
|
||||
Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\Elementary - 02x03 - 02x04 - 02x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\02x03 - 02x04 - 02x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\02x03-04-15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\Elementary - 02x03-04-15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 02\02x03-E15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 02\Elementary - 02x03-E15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 02\02x03 - x04 - x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 02\Elementary - 02x03 - x04 - x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 02\02x03x04x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 02\Elementary - 02x03x04x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(26, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\Elementary - S01E23-E24-E26 - The Woman.mp4"));
|
||||
Assert.AreEqual(26, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\S01E23-E24-E26 - The Woman.mp4"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 1\01x02 blah.avi"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 1\S01x02 blah.avi"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 1\S01E02 blah.avi"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 1\S01xE02 blah.avi"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 1\seriesname 01x02 blah.avi"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 1\seriesname S01x02 blah.avi"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 1\seriesname S01E02 blah.avi"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 1\seriesname S01xE02 blah.avi"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2\02x03 - 04 Ep Name.ext"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2\My show name 02x03 - 04 Ep Name.ext"));
|
||||
Assert.AreEqual(15, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2\Elementary - 02x03 - 02x04 - 02x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2\02x03 - 02x04 - 02x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2\02x03-04-15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2\Elementary - 02x03-04-15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 02\02x03-E15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 02\Elementary - 02x03-E15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 02\02x03 - x04 - x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 02\Elementary - 02x03 - x04 - x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 02\02x03x04x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 02\Elementary - 02x03x04x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(26, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 1\Elementary - S01E23-E24-E26 - The Woman.mp4"));
|
||||
Assert.AreEqual(26, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 1\S01E23-E24-E26 - The Woman.mp4"));
|
||||
|
||||
|
||||
//Four Digits seasons
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\2009x02 blah.avi"));
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\S2009x02 blah.avi"));
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\S2009E02 blah.avi"));
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\S2009xE02 blah.avi"));
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\seriesname 2009x02 blah.avi"));
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\seriesname S2009x02 blah.avi"));
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\seriesname S2009E02 blah.avi"));
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\seriesname S2009xE02 blah.avi"));
|
||||
Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03 - 2009x04 - 2009x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\2009x03 - 2009x04 - 2009x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\2009x03-04-15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03-04-15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\2009x03-E15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03-E15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\2009x03 - x04 - x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03 - x04 - x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\2009x03x04x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03x04x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(26, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\Elementary - S2009E23-E24-E26 - The Woman.mp4"));
|
||||
Assert.AreEqual(26, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\S2009E23-E24-E26 - The Woman.mp4"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2009\2009x02 blah.avi"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2009\S2009x02 blah.avi"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2009\S2009E02 blah.avi"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2009\S2009xE02 blah.avi"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2009\seriesname 2009x02 blah.avi"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2009\seriesname S2009x02 blah.avi"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2009\seriesname S2009E02 blah.avi"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2009\seriesname S2009xE02 blah.avi"));
|
||||
Assert.AreEqual(15, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03 - 2009x04 - 2009x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2009\2009x03 - 2009x04 - 2009x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2009\2009x03-04-15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03-04-15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2009\2009x03-E15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03-E15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2009\2009x03 - x04 - x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03 - x04 - x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2009\2009x03x04x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(15, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03x04x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(26, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2009\Elementary - S2009E23-E24-E26 - The Woman.mp4"));
|
||||
Assert.AreEqual(26, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2009\S2009E23-E24-E26 - The Woman.mp4"));
|
||||
|
||||
//Without season number
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\02 - blah.avi"));
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\02 - blah 14 blah.avi"));
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\02 - blah-02 a.avi"));
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\02.avi"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 1\02 - blah.avi"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2\02 - blah 14 blah.avi"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 1\02 - blah-02 a.avi"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2\02.avi"));
|
||||
|
||||
Assert.AreEqual(3, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\02-03 - blah.avi"));
|
||||
Assert.AreEqual(4, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\02-04 - blah 14 blah.avi"));
|
||||
Assert.AreEqual(5, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\02-05 - blah-02 a.avi"));
|
||||
Assert.AreEqual(4, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\02-04.avi"));
|
||||
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\[HorribleSubs] Hunter X Hunter - 136 [720p].mkv"));
|
||||
Assert.AreEqual(3, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 1\02-03 - blah.avi"));
|
||||
Assert.AreEqual(4, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2\02-04 - blah 14 blah.avi"));
|
||||
Assert.AreEqual(5, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 1\02-05 - blah-02 a.avi"));
|
||||
Assert.AreEqual(4, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2\02-04.avi"));
|
||||
Assert.AreEqual(null, SeriesResolver.GetEndingEpisodeNumberFromFile(@"Season 2\[HorribleSubs] Hunter X Hunter - 136 [720p].mkv"));
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestGetSeasonNumberFromPath() {
|
||||
|
||||
Assert.AreEqual(02, TVUtils.GetSeasonNumberFromEpisodeFile(@"\Show\Season 02\S02E03 blah.avi"));
|
||||
Assert.AreEqual(02, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"\Show\Season 02\S02E03 blah.avi"));
|
||||
|
||||
Assert.AreEqual(1, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 1"));
|
||||
Assert.AreEqual(1, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 1"));
|
||||
Assert.AreEqual(1, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 1"));
|
||||
Assert.AreEqual(1, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 1"));
|
||||
Assert.AreEqual(1, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 1"));
|
||||
Assert.AreEqual(1, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 1"));
|
||||
Assert.AreEqual(1, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 1"));
|
||||
Assert.AreEqual(1, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 1"));
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2"));
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2"));
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2"));
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2"));
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 02"));
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 02"));
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 02"));
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 02"));
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 02"));
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 02"));
|
||||
Assert.AreEqual(1, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 1"));
|
||||
Assert.AreEqual(1, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 1"));
|
||||
Assert.AreEqual(1, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 1"));
|
||||
Assert.AreEqual(1, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 1"));
|
||||
Assert.AreEqual(1, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 1"));
|
||||
Assert.AreEqual(1, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 1"));
|
||||
Assert.AreEqual(1, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 1"));
|
||||
Assert.AreEqual(1, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 1"));
|
||||
Assert.AreEqual(1, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 1"));
|
||||
Assert.AreEqual(1, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 1"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 02"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 02"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 02"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 02"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 02"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 02"));
|
||||
Assert.AreEqual(1, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 1"));
|
||||
Assert.AreEqual(1, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 1"));
|
||||
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Seinfeld\S02"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Seinfeld\S02"));
|
||||
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Seinfeld\2"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Seinfeld\2"));
|
||||
|
||||
//Four Digits seasons
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromPath(@"\Drive\Season 2009"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestGetSeasonNumberFromEpisodeFile()
|
||||
{
|
||||
Assert.AreEqual(1, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 1\01x02 blah.avi"));
|
||||
Assert.AreEqual(1, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 1\S01x02 blah.avi"));
|
||||
Assert.AreEqual(1, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 1\S01E02 blah.avi"));
|
||||
Assert.AreEqual(1, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 1\S01xE02 blah.avi"));
|
||||
Assert.AreEqual(1, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 1\seriesname 01x02 blah.avi"));
|
||||
Assert.AreEqual(1, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 1\seriesname S01x02 blah.avi"));
|
||||
Assert.AreEqual(1, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 1\seriesname S01E02 blah.avi"));
|
||||
Assert.AreEqual(1, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 1\seriesname S01xE02 blah.avi"));
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2\Elementary - 02x03 - 02x04 - 02x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2\02x03 - 02x04 - 02x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2\02x03-04-15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2\Elementary - 02x03-04-15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 02\02x03-E15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 02\Elementary - 02x03-E15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 02\02x03 - x04 - x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 02\Elementary - 02x03 - x04 - x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 02\02x03x04x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 02\Elementary - 02x03x04x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(1, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 1\Elementary - S01E23-E24-E26 - The Woman.mp4"));
|
||||
Assert.AreEqual(1, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 1\S01E23-E24-E26 - The Woman.mp4"));
|
||||
Assert.AreEqual(1, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 1\01x02 blah.avi"));
|
||||
Assert.AreEqual(1, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 1\S01x02 blah.avi"));
|
||||
Assert.AreEqual(1, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 1\S01E02 blah.avi"));
|
||||
Assert.AreEqual(1, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 1\S01xE02 blah.avi"));
|
||||
Assert.AreEqual(1, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 1\seriesname 01x02 blah.avi"));
|
||||
Assert.AreEqual(1, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 1\seriesname S01x02 blah.avi"));
|
||||
Assert.AreEqual(1, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 1\seriesname S01E02 blah.avi"));
|
||||
Assert.AreEqual(1, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 1\seriesname S01xE02 blah.avi"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2\Elementary - 02x03 - 02x04 - 02x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2\02x03 - 02x04 - 02x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2\02x03-04-15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2\Elementary - 02x03-04-15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 02\02x03-E15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 02\Elementary - 02x03-E15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 02\02x03 - x04 - x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 02\Elementary - 02x03 - x04 - x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 02\02x03x04x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 02\Elementary - 02x03x04x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(1, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 1\Elementary - S01E23-E24-E26 - The Woman.mp4"));
|
||||
Assert.AreEqual(1, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 1\S01E23-E24-E26 - The Woman.mp4"));
|
||||
|
||||
//Four Digits seasons
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\2009x02 blah.avi"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\S2009x02 blah.avi"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\S2009E02 blah.avi"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\S2009xE02 blah.avi"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\seriesname 2009x02 blah.avi"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\seriesname S2009x02 blah.avi"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\seriesname S2009E02 blah.avi"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\seriesname S2009xE02 blah.avi"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\Elementary - 2009x03 - 2009x04 - 2009x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\2009x03 - 2009x04 - 2009x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\2009x03-04-15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\Elementary - 2009x03-04-15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\2009x03-E15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\Elementary - 2009x03-E15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\2009x03 - x04 - x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\Elementary - 2009x03 - x04 - x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\2009x03x04x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\Elementary - 2009x03x04x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\Elementary - S2009E23-E24-E26 - The Woman.mp4"));
|
||||
Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\S2009E23-E24-E26 - The Woman.mp4"));
|
||||
Assert.AreEqual(25, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 25\The Simpsons.S25E09.Steal this episode.mp4"));
|
||||
Assert.AreEqual(25, TVUtils.GetSeasonNumberFromEpisodeFile(@"The Simpsons\The Simpsons.S25E09.Steal this episode.mp4"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2009\2009x02 blah.avi"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2009\S2009x02 blah.avi"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2009\S2009E02 blah.avi"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2009\S2009xE02 blah.avi"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2009\seriesname 2009x02 blah.avi"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2009\seriesname S2009x02 blah.avi"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2009\seriesname S2009E02 blah.avi"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2009\seriesname S2009xE02 blah.avi"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2009\Elementary - 2009x03 - 2009x04 - 2009x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2009\2009x03 - 2009x04 - 2009x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2009\2009x03-04-15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2009\Elementary - 2009x03-04-15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2009\2009x03-E15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2009\Elementary - 2009x03-E15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2009\2009x03 - x04 - x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2009\Elementary - 2009x03 - x04 - x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2009\2009x03x04x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2009\Elementary - 2009x03x04x15 - Ep Name.ext"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2009\Elementary - S2009E23-E24-E26 - The Woman.mp4"));
|
||||
Assert.AreEqual(2009, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 2009\S2009E23-E24-E26 - The Woman.mp4"));
|
||||
Assert.AreEqual(25, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"Season 25\The Simpsons.S25E09.Steal this episode.mp4"));
|
||||
Assert.AreEqual(25, SeriesResolver.GetSeasonNumberFromEpisodeFile(@"The Simpsons\The Simpsons.S25E09.Steal this episode.mp4"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
using MediaBrowser.Server.Implementations.Library;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace MediaBrowser.Tests.Server.Implementations.Library {
|
||||
[TestClass]
|
||||
public class ResolverHelperTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestStripBrackets()
|
||||
{
|
||||
Assert.AreEqual("My Movie", ResolverHelper.StripBrackets("My Movie [boxset] [blah blah]"));
|
||||
Assert.AreEqual("file 01", ResolverHelper.StripBrackets("[tag1] file 01 [tvdbid=12345]"));
|
||||
Assert.AreEqual("file 01", ResolverHelper.StripBrackets("[tag1] file 01 [tmdbid=12345]"));
|
||||
Assert.AreEqual("file 01", ResolverHelper.StripBrackets("[tag1] file [boxset] [tvdbid=12345] 01 [tmdbid=12345]"));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user