Attempt at fixing a potential bug found from #466

This commit is contained in:
tidusjar 2016-08-11 12:41:13 +01:00
commit a7d5378426
11 changed files with 222 additions and 133 deletions

View file

@ -72,6 +72,29 @@ namespace PlexRequests.Helpers
return ep;
}
}
public static int GetSeasonNumberFromTitle(string title)
{
if (string.IsNullOrEmpty(title))
{
return 0;
}
var split = title.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (split.Length < 2)
{
// Cannot get the season number, it's not in the usual format
return 0;
}
int season;
if (int.TryParse(split[1], out season))
{
return season;
}
return 0;
}
}
public class EpisodeModelHelper