|
|
|
@ -1,4 +1,3 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
|
|
|
|
|
@ -6,7 +5,7 @@ namespace NzbDrone.Core.Providers
|
|
|
|
|
{
|
|
|
|
|
public class EpisodeProvider
|
|
|
|
|
{
|
|
|
|
|
private static readonly Regex _parseRegex = new Regex(@"(?<showName>.*)
|
|
|
|
|
private static readonly Regex ParseRegex = new Regex(@"(?<showName>.*)
|
|
|
|
|
(?:
|
|
|
|
|
s(?<seasonNumber>\d+)e(?<episodeNumber>\d+)-?e(?<episodeNumber2>\d+)
|
|
|
|
|
| s(?<seasonNumber>\d+)e(?<episodeNumber>\d+)
|
|
|
|
@ -23,16 +22,26 @@ namespace NzbDrone.Core.Providers
|
|
|
|
|
|
|
|
|
|
public static Episode Parse(string title)
|
|
|
|
|
{
|
|
|
|
|
Match match = _parseRegex.Match(title);
|
|
|
|
|
Match match = ParseRegex.Match(title);
|
|
|
|
|
|
|
|
|
|
if (!match.Success) return null;
|
|
|
|
|
if (!match.Success)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
return new Episode {Season = ParseInt(match.Groups["seasonNumber"].Value), EpisodeNumber = ParseInt(match.Groups["episodeNumber"].Value), EpisodeNumber2 = ParseInt(match.Groups["episodeNumber2"].Value), Title = ReplaceSeparatorChars(match.Groups["episodeName"].Value), Release = ReplaceSeparatorChars(match.Groups["release"].Value), Proper = title.Contains("PROPER")};
|
|
|
|
|
return new Episode {
|
|
|
|
|
Season = ParseInt(match.Groups["seasonNumber"].Value),
|
|
|
|
|
EpisodeNumber = ParseInt(match.Groups["episodeNumber"].Value),
|
|
|
|
|
EpisodeNumber2 = ParseInt(match.Groups["episodeNumber2"].Value),
|
|
|
|
|
Title = ReplaceSeparatorChars(match.Groups["episodeName"].Value),
|
|
|
|
|
Release = ReplaceSeparatorChars(match.Groups["release"].Value),
|
|
|
|
|
Proper = title.Contains("PROPER")
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static string ReplaceSeparatorChars(string s)
|
|
|
|
|
{
|
|
|
|
|
if (s == null) return string.Empty;
|
|
|
|
|
if (s == null)
|
|
|
|
|
return string.Empty;
|
|
|
|
|
|
|
|
|
|
return s.Replace('.', ' ').Replace('-', ' ').Replace('_', ' ').Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -42,12 +51,5 @@ namespace NzbDrone.Core.Providers
|
|
|
|
|
int.TryParse(s, out i);
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static DateTime ParseAirDate(string s)
|
|
|
|
|
{
|
|
|
|
|
DateTime d;
|
|
|
|
|
if (DateTime.TryParse(ReplaceSeparatorChars(s).Replace(' ', '-'), out d)) return d;
|
|
|
|
|
return DateTime.MinValue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|