|
@@ -1,4 +1,5 @@
|
|
-using MediaBrowser.Controller.Resolvers;
|
|
|
|
|
|
+using System.Globalization;
|
|
|
|
+using MediaBrowser.Controller.Resolvers;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.IO;
|
|
@@ -184,8 +185,7 @@ namespace MediaBrowser.Controller.Library
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- if (EntityResolutionHelper.IsVideoFile(child.FullName) &&
|
|
|
|
- !string.IsNullOrEmpty(EpisodeNumberFromFile(child.FullName, false)))
|
|
|
|
|
|
+ if (EntityResolutionHelper.IsVideoFile(child.FullName) && GetEpisodeNumberFromFile(child.FullName, false).HasValue)
|
|
{
|
|
{
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -201,14 +201,14 @@ namespace MediaBrowser.Controller.Library
|
|
/// <param name="fullPath">The full path.</param>
|
|
/// <param name="fullPath">The full path.</param>
|
|
/// <param name="isInSeason">if set to <c>true</c> [is in season].</param>
|
|
/// <param name="isInSeason">if set to <c>true</c> [is in season].</param>
|
|
/// <returns>System.String.</returns>
|
|
/// <returns>System.String.</returns>
|
|
- public static string EpisodeNumberFromFile(string fullPath, bool isInSeason)
|
|
|
|
|
|
+ public static int? GetEpisodeNumberFromFile(string fullPath, bool isInSeason)
|
|
{
|
|
{
|
|
string fl = fullPath.ToLower();
|
|
string fl = fullPath.ToLower();
|
|
foreach (var r in EpisodeExpressions)
|
|
foreach (var r in EpisodeExpressions)
|
|
{
|
|
{
|
|
Match m = r.Match(fl);
|
|
Match m = r.Match(fl);
|
|
if (m.Success)
|
|
if (m.Success)
|
|
- return m.Groups["epnumber"].Value;
|
|
|
|
|
|
+ return ParseEpisodeNumber(m.Groups["epnumber"].Value);
|
|
}
|
|
}
|
|
if (isInSeason)
|
|
if (isInSeason)
|
|
{
|
|
{
|
|
@@ -217,13 +217,27 @@ namespace MediaBrowser.Controller.Library
|
|
|
|
|
|
if (match != null)
|
|
if (match != null)
|
|
{
|
|
{
|
|
- return match.Value;
|
|
|
|
|
|
+ return ParseEpisodeNumber(match.Value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
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>
|
|
/// <summary>
|
|
/// Seasons the number from episode file.
|
|
/// Seasons the number from episode file.
|
|
/// </summary>
|
|
/// </summary>
|