mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-18 21:34:28 -04:00
release endpoint now returns fully parsed rss info with decisions.
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Parser.Model
|
||||
@@ -9,10 +7,9 @@ namespace NzbDrone.Core.Parser.Model
|
||||
public class ParsedEpisodeInfo
|
||||
{
|
||||
public string SeriesTitle { get; set; }
|
||||
public string OriginalString { get; set; }
|
||||
public QualityModel Quality { get; set; }
|
||||
public int SeasonNumber { get; set; }
|
||||
public List<int> EpisodeNumbers { get; set; }
|
||||
public int[] EpisodeNumbers { get; set; }
|
||||
public DateTime? AirDate { get; set; }
|
||||
public Language Language { get; set; }
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Parser.Model
|
||||
@@ -9,100 +8,16 @@ namespace NzbDrone.Core.Parser.Model
|
||||
public class RemoteEpisode
|
||||
{
|
||||
public ReportInfo Report { get; set; }
|
||||
|
||||
public bool FullSeason { get; set; }
|
||||
|
||||
public ParsedEpisodeInfo ParsedEpisodeInfo { get; set; }
|
||||
|
||||
public Series Series { get; set; }
|
||||
|
||||
public List<Episode> Episodes { get; set; }
|
||||
|
||||
public QualityModel Quality { get; set; }
|
||||
|
||||
public Language Language { get; set; }
|
||||
|
||||
public int SeasonNumber
|
||||
public bool IsRecentEpisode()
|
||||
{
|
||||
get { return Episodes.Select(e => e.SeasonNumber).Distinct().SingleOrDefault(); }
|
||||
}
|
||||
|
||||
|
||||
public DateTime? AirDate
|
||||
{
|
||||
get
|
||||
{
|
||||
return Episodes.Single().AirDate;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<int> EpisodeNumbers
|
||||
{
|
||||
get
|
||||
{
|
||||
return Episodes.Select(c => c.EpisodeNumber).Distinct();
|
||||
}
|
||||
}
|
||||
|
||||
public string GetDownloadTitle()
|
||||
{
|
||||
var seriesTitle = FileNameBuilder.CleanFilename(Series.Title);
|
||||
|
||||
//Handle Full Naming
|
||||
if (FullSeason)
|
||||
{
|
||||
var seasonResult = String.Format("{0} - Season {1} [{2}]", seriesTitle, SeasonNumber, Quality);
|
||||
|
||||
if (Quality.Proper)
|
||||
seasonResult += " [Proper]";
|
||||
|
||||
return seasonResult;
|
||||
}
|
||||
|
||||
if (Series.SeriesType == SeriesTypes.Daily)
|
||||
{
|
||||
var dailyResult = String.Format("{0} - {1:yyyy-MM-dd} - {2} [{3}]", seriesTitle,
|
||||
AirDate, Episodes.First().Title, Quality);
|
||||
|
||||
if (Quality.Proper)
|
||||
dailyResult += " [Proper]";
|
||||
|
||||
return dailyResult;
|
||||
}
|
||||
|
||||
//Show Name - 1x01-1x02 - Episode Name
|
||||
//Show Name - 1x01 - Episode Name
|
||||
var episodeString = new List<string>();
|
||||
var episodeNames = new List<string>();
|
||||
|
||||
foreach (var episode in Episodes)
|
||||
{
|
||||
episodeString.Add(String.Format("{0}x{1:00}", episode.SeasonNumber, episode.EpisodeNumber));
|
||||
episodeNames.Add(Core.Parser.Parser.CleanupEpisodeTitle(episode.Title));
|
||||
}
|
||||
|
||||
var epNumberString = String.Join("-", episodeString);
|
||||
string episodeName;
|
||||
|
||||
|
||||
if (episodeNames.Distinct().Count() == 1)
|
||||
episodeName = episodeNames.First();
|
||||
|
||||
else
|
||||
episodeName = String.Join(" + ", episodeNames.Distinct());
|
||||
|
||||
var result = String.Format("{0} - {1} - {2} [{3}]", seriesTitle, epNumberString, episodeName, Quality);
|
||||
|
||||
if (Quality.Proper)
|
||||
{
|
||||
result += " [Proper]";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return Episodes.Any(e => e.AirDate >= DateTime.Today.AddDays(-7));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
@@ -90,11 +89,7 @@ namespace NzbDrone.Core.Parser
|
||||
result = ParseTitle(fileInfo.FullName);
|
||||
}
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
result.OriginalString = path;
|
||||
}
|
||||
else
|
||||
if (result == null)
|
||||
{
|
||||
Logger.Warn("Unable to parse episode info from path {0}", path);
|
||||
}
|
||||
@@ -124,7 +119,6 @@ namespace NzbDrone.Core.Parser
|
||||
|
||||
result.Language = ParseLanguage(title);
|
||||
result.Quality = ParseQuality(title);
|
||||
result.OriginalString = title;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -172,7 +166,7 @@ namespace NzbDrone.Core.Parser
|
||||
result = new ParsedEpisodeInfo
|
||||
{
|
||||
SeasonNumber = seasons.First(),
|
||||
EpisodeNumbers = new List<int>()
|
||||
EpisodeNumbers = new int[0],
|
||||
};
|
||||
|
||||
foreach (Match matchGroup in matchCollection)
|
||||
@@ -184,7 +178,7 @@ namespace NzbDrone.Core.Parser
|
||||
{
|
||||
var first = Convert.ToInt32(episodeCaptures.First().Value);
|
||||
var last = Convert.ToInt32(episodeCaptures.Last().Value);
|
||||
result.EpisodeNumbers = Enumerable.Range(first, last - first + 1).ToList();
|
||||
result.EpisodeNumbers = Enumerable.Range(first, last - first + 1).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
@@ -11,7 +10,7 @@ namespace NzbDrone.Core.Parser
|
||||
{
|
||||
LocalEpisode GetEpisodes(string fileName, Series series);
|
||||
Series GetSeries(string title);
|
||||
RemoteEpisode Map(ReportInfo reportInfo);
|
||||
RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo);
|
||||
}
|
||||
|
||||
public class ParsingService : IParsingService
|
||||
@@ -65,32 +64,23 @@ namespace NzbDrone.Core.Parser
|
||||
return _seriesService.FindByTitle(searchTitle);
|
||||
}
|
||||
|
||||
public RemoteEpisode Map(ReportInfo reportInfo)
|
||||
public RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo)
|
||||
{
|
||||
var parsedInfo = Parser.ParseTitle(reportInfo.Title);
|
||||
var remoteEpisode = new RemoteEpisode
|
||||
{
|
||||
ParsedEpisodeInfo = parsedEpisodeInfo,
|
||||
};
|
||||
|
||||
if (parsedInfo == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var series = _seriesService.FindByTitle(parsedInfo.SeriesTitle);
|
||||
var series = _seriesService.FindByTitle(parsedEpisodeInfo.SeriesTitle);
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
_logger.Trace("No matching series {0}", parsedInfo.SeriesTitle);
|
||||
return null;
|
||||
_logger.Trace("No matching series {0}", parsedEpisodeInfo.SeriesTitle);
|
||||
return remoteEpisode;
|
||||
}
|
||||
|
||||
var remoteEpisode = new RemoteEpisode
|
||||
{
|
||||
Series = series,
|
||||
Episodes = GetEpisodes(parsedInfo, series),
|
||||
FullSeason = parsedInfo.FullSeason,
|
||||
Language = parsedInfo.Language,
|
||||
Quality = parsedInfo.Quality,
|
||||
Report = reportInfo
|
||||
};
|
||||
remoteEpisode.Series = series;
|
||||
remoteEpisode.Episodes = GetEpisodes(parsedEpisodeInfo, series);
|
||||
|
||||
return remoteEpisode;
|
||||
}
|
||||
@@ -104,7 +94,7 @@ namespace NzbDrone.Core.Parser
|
||||
if (series.SeriesType == SeriesTypes.Standard)
|
||||
{
|
||||
//Todo: Collect this as a Series we want to treat as a daily series, or possible parsing error
|
||||
_logger.Warn("Found daily-style episode for non-daily series: {0}. {1}", series.Title, parsedEpisodeInfo.OriginalString);
|
||||
_logger.Warn("Found daily-style episode for non-daily series: {0}.", series.Title);
|
||||
return new List<Episode>();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user