started rss cleanup

pull/4/head
kay.one 14 years ago
parent 7a16a907a4
commit 62b2cd510f

@ -6,6 +6,7 @@ using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using SubSonic.Repository;

@ -7,6 +7,7 @@ using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using SubSonic.Repository;

@ -11,6 +11,7 @@ using Ninject;
using Ninject.Moq;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using SubSonic.Repository;

@ -9,6 +9,7 @@ using Moq;
using NLog;
using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using SubSonic.DataProviders;
using SubSonic.Repository;
using TvdbLib;

@ -8,6 +8,7 @@ using MbUnit.Framework.ContractVerifiers;
using Moq;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using Rss;
namespace NzbDrone.Core.Test

@ -7,6 +7,7 @@ using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using SubSonic.Repository;
namespace NzbDrone.Core.Test

@ -8,6 +8,7 @@ using NLog.Config;
using NLog.Targets;
using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.Fakes;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;

@ -8,7 +8,7 @@ namespace NzbDrone.Core.Helpers
{
public static class SceneNameHelper
{
private static List<SceneNameModel> _sceneNameMappings = new List<SceneNameModel>
private static readonly List<SceneNameModel> SceneNameMappings = new List<SceneNameModel>
{
new SceneNameModel { SeriesId = 72546, Name = "CSI" },
new SceneNameModel { SeriesId = 73696, Name = "CSI New York" },
@ -76,7 +76,7 @@ namespace NzbDrone.Core.Helpers
public static int FindByName(string cleanSeriesName)
{
var map = _sceneNameMappings.Find(s => Parser.NormalizeTitle(s.Name) == cleanSeriesName);
var map = SceneNameMappings.Find(s => Parser.NormalizeTitle(s.Name) == cleanSeriesName);
if (map == null)
return 0;
@ -88,7 +88,7 @@ namespace NzbDrone.Core.Helpers
{
List<String> results = new List<string>();
var maps = _sceneNameMappings.Where(s => s.SeriesId == seriesId);
var maps = SceneNameMappings.Where(s => s.SeriesId == seriesId);
foreach (var map in maps)
results.Add(map.Name);

@ -1,5 +1,5 @@
using NzbDrone.Core.Repository.Quality;
using SubSonic.SqlGeneration.Schema;
using System;
using System.Collections.Generic;
namespace NzbDrone.Core.Model
{
@ -7,12 +7,12 @@ namespace NzbDrone.Core.Model
{
internal string SeriesTitle { get; set; }
internal int SeasonNumber { get; set; }
internal int EpisodeNumber { get; set; }
internal List<int> Episodes { get; set; }
internal int Year { get; set; }
public override string ToString()
{
return string.Format("Series:{0} Season:{1} Episode:{2}", SeriesTitle, SeasonNumber, EpisodeNumber);
return string.Format("Series:{0} Season:{1} Episode:{2}", SeriesTitle, SeasonNumber, String.Join(",", Episodes));
}
}

@ -9,12 +9,9 @@ namespace NzbDrone.Core.Model
{
public class NzbInfoModel
{
public string Id { get; set; }
public string Title { get; set; }
public string TitleFix { get; set; }
public NzbSiteModel Site { get; set; }
public Uri Link { get; set; }
public string Description { get; set; }
public bool Proper { get; set; }
public QualityTypes Quality { get; set; }

@ -1,37 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace NzbDrone.Core.Model
{
public class NzbSiteModel
{
private static readonly IList<NzbSiteModel> Sites = new List<NzbSiteModel>
{
new NzbSiteModel {Name = "newzbin", Url = "newzbin.com", Pattern = @"\d{7,10}"},
new NzbSiteModel {Name = "nzbmatrix", Url = "nzbmatrix.com", Pattern = @"\d{6,10}"},
new NzbSiteModel {Name = "nzbsDotOrg", Url = "nzbs.org", Pattern = @"\d{5,10}"},
new NzbSiteModel {Name = "nzbsrus", Url = "nzbsrus.com", Pattern = @"\d{6,10}"},
new NzbSiteModel {Name = "lilx", Url = "lilx.net", Pattern = @"\d{6,10}"},
};
public string Name { get; set; }
public string Pattern { get; set; }
public string Url { get; set; }
// TODO: use HttpUtility.ParseQueryString();
// https://nzbmatrix.com/api-nzb-download.php?id=626526
public string ParseId(string url)
{
return Regex.Match(url, Pattern).Value;
}
public static NzbSiteModel Parse(string url)
{
return Sites.Where(site => url.Contains(site.Url)).SingleOrDefault() ??
new NzbSiteModel { Name = "unknown", Pattern = @"\d{6,10}" };
}
}
}

@ -1,21 +0,0 @@
using System.Collections.Generic;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository
{
public class Season
{
[SubSonicPrimaryKey(false)]
public virtual long SeasonId { get; set; }
public long SeriesId { get; set; }
public int SeasonNumber { get; set; }
public bool Monitored { get; set; }
public string Folder { get; set; }
[SubSonicToManyRelation]
public virtual List<Episode> Episodes { get; private set; }
[SubSonicToOneRelation(ThisClassContainsJoinKey = true)]
public virtual Series Series { get; private set; }
}
}

@ -1,15 +0,0 @@
using NzbDrone.Core.Repository.Quality;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Model
{
public class SeasonModel
{
public string SeriesTitle { get; set; }
public int SeriesId { get; set; }
public int SeasonNumber { get; set; }
public QualityTypes Quality { get; set; }
public long Size { get; set; }
public bool Proper { get; set; }
}
}

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model
{
public class SeriesMappingModel
{
public string Path { get; set; }
public int TvDbId { get; set; }
public int QualityProfileId { get; set; }
}
}

@ -168,21 +168,19 @@
<Compile Include="Instrumentation\SubsonicTarget.cs" />
<Compile Include="Instrumentation\ExceptioneerTarget.cs" />
<Compile Include="Instrumentation\NlogWriter.cs" />
<Compile Include="Model\SeasonModel.cs" />
<Compile Include="Model\SeasonParseResult.cs" />
<Compile Include="Model\EpisodeParseResult.cs" />
<Compile Include="Model\EpisodeModel.cs" />
<Compile Include="Model\EpisodeParseResult.cs" />
<Compile Include="Model\EpisodeRenameModel.cs" />
<Compile Include="Model\EpisodeSortingType.cs" />
<Compile Include="Model\EpisodeStatusType.cs" />
<Compile Include="Model\FeedInfoModel.cs" />
<Compile Include="Model\NzbInfoModel.cs" />
<Compile Include="Model\NzbSiteModel.cs" />
<Compile Include="Model\SabnzbdPriorityType.cs" />
<Compile Include="Model\SceneNameModel.cs" />
<Compile Include="Model\SeriesMappingModel.cs" />
<Compile Include="Model\SeasonParseResult.cs" />
<Compile Include="Model\UpcomingEpisodesModel.cs" />
<Compile Include="Providers\BacklogProvider.cs" />
<Compile Include="Providers\FeedProviderBase.cs" />
<Compile Include="Providers\ExternalNotificationProvider.cs" />
<Compile Include="Providers\HistoryProvider.cs" />
<Compile Include="Providers\IBacklogProvider.cs" />
@ -196,7 +194,7 @@
<Compile Include="Providers\IRootDirProvider.cs" />
<Compile Include="Providers\IRssItemProcessingProvider.cs" />
<Compile Include="Providers\IRssSyncProvider.cs" />
<Compile Include="Providers\IRssProvider.cs" />
<Compile Include="Providers\Core\IRssProvider.cs" />
<Compile Include="Providers\ITimerProvider.cs" />
<Compile Include="Providers\IUpcomingEpisodesProvider.cs" />
<Compile Include="Providers\IXbmcProvider.cs" />
@ -206,7 +204,7 @@
<Compile Include="Providers\RootDirProvider.cs" />
<Compile Include="Providers\RssItemProcessingProvider.cs" />
<Compile Include="Providers\RssSyncProvider.cs" />
<Compile Include="Providers\RssProvider.cs" />
<Compile Include="Providers\Core\RssProvider.cs" />
<Compile Include="Providers\TimerProvider.cs" />
<Compile Include="Providers\UpcomingEpisodesProvider.cs" />
<Compile Include="Providers\XbmcProvider.cs" />
@ -224,12 +222,12 @@
<Compile Include="Providers\SyncProvider.cs" />
<Compile Include="Model\Notification\ProgressNotification.cs" />
<Compile Include="Providers\NotificationProvider.cs" />
<Compile Include="Providers\ConfigProvider.cs" />
<Compile Include="Providers\Core\ConfigProvider.cs" />
<Compile Include="Providers\EpisodeProvider.cs" />
<Compile Include="Providers\HttpProvider.cs" />
<Compile Include="Providers\Core\HttpProvider.cs" />
<Compile Include="Providers\IDownloadProvider.cs" />
<Compile Include="Providers\IEpisodeProvider.cs" />
<Compile Include="Providers\IHttpProvider.cs" />
<Compile Include="Providers\Core\IHttpProvider.cs" />
<Compile Include="Providers\ISeasonProvider.cs" />
<Compile Include="Providers\ISeriesProvider.cs" />
<Compile Include="Providers\ITvDbProvider.cs" />
@ -247,9 +245,9 @@
<Compile Include="Repository\Series.cs" />
<Compile Include="CentralDispatch.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Providers\DiskProvider.cs" />
<Compile Include="Providers\IConfigProvider.cs" />
<Compile Include="Providers\IDiskProvider.cs" />
<Compile Include="Providers\Core\DiskProvider.cs" />
<Compile Include="Providers\Core\IConfigProvider.cs" />
<Compile Include="Providers\Core\IDiskProvider.cs" />
<Compile Include="Providers\SeriesProvider.cs" />
<Compile Include="Providers\TvDbProvider.cs" />
</ItemGroup>

@ -34,11 +34,11 @@ namespace NzbDrone.Core
/// </summary>
/// <param name="title">Title of the report</param>
/// <returns>List of episodes contained to the post</returns>
internal static List<EpisodeParseResult> ParseEpisodeInfo(string title)
internal static EpisodeParseResult ParseEpisodeInfo(string title)
{
Logger.Trace("Parsing string '{0}'", title);
var result = new List<EpisodeParseResult>();
var result = new EpisodeParseResult();
foreach (var regex in ReportTitleRegex)
{
@ -55,22 +55,22 @@ namespace NzbDrone.Core
year = 0;
}
foreach (Match matchGroup in match)
var parsedEpisode = new EpisodeParseResult
{
SeriesTitle = seriesName,
SeasonNumber = Convert.ToInt32(match[0].Groups["season"].Value),
Year = year,
Episodes = new List<int>()
};
var parsedEpisode = new EpisodeParseResult
{
SeriesTitle = seriesName,
SeasonNumber = Convert.ToInt32(matchGroup.Groups["season"].Value),
EpisodeNumber = Convert.ToInt32(matchGroup.Groups["episode"].Value),
Year = year
};
foreach (Match matchGroup in match)
{
parsedEpisode.Episodes.Add(Convert.ToInt32(matchGroup.Groups["episode"].Value));
}
result.Add(parsedEpisode);
Logger.Trace("Episode Parsed. {0}", parsedEpisode);
Logger.Trace("Episode Parsed. {0}", parsedEpisode);
}
break; //Break out of the for loop, we don't want to process every REGEX for each item otherwise we'll get duplicates
}
}
@ -111,7 +111,7 @@ namespace NzbDrone.Core
Year = year
};
Logger.Trace("Season Parsed. {0}", result);
return result;
@ -257,14 +257,11 @@ namespace NzbDrone.Core
public static NzbInfoModel ParseNzbInfo(FeedInfoModel feed, RssItem item)
{
NzbSiteModel site = NzbSiteModel.Parse(feed.Url.ToLower());
return new NzbInfoModel
{
Id = site.ParseId(item.Link.ToString()),
Title = item.Title,
Site = site,
Link = item.Link,
Description = item.Description
Link = item.Link
};
}
}

@ -8,6 +8,7 @@ using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using Rss;

@ -3,7 +3,7 @@ using NLog;
using NzbDrone.Core.Repository;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers
namespace NzbDrone.Core.Providers.Core
{
public class ConfigProvider : IConfigProvider
{

@ -1,7 +1,7 @@
using System;
using System.IO;
namespace NzbDrone.Core.Providers
namespace NzbDrone.Core.Providers.Core
{
public class DiskProvider : IDiskProvider
{

@ -2,7 +2,7 @@
using System.Net;
using NLog;
namespace NzbDrone.Core.Providers
namespace NzbDrone.Core.Providers.Core
{
internal class HttpProvider : IHttpProvider
{

@ -1,6 +1,6 @@
using System;
namespace NzbDrone.Core.Providers
namespace NzbDrone.Core.Providers.Core
{
public interface IConfigProvider
{

@ -1,7 +1,7 @@
using System;
using System.IO;
namespace NzbDrone.Core.Providers
namespace NzbDrone.Core.Providers.Core
{
public interface IDiskProvider
{

@ -1,4 +1,4 @@
namespace NzbDrone.Core.Providers
namespace NzbDrone.Core.Providers.Core
{
public interface IHttpProvider
{

@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using NzbDrone.Core.Model;
using Rss;
namespace NzbDrone.Core.Providers
namespace NzbDrone.Core.Providers.Core
{
public interface IRssProvider
{

@ -1,12 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog;
using NzbDrone.Core.Model;
using Rss;
namespace NzbDrone.Core.Providers
namespace NzbDrone.Core.Providers.Core
{
public class RssProvider : IRssProvider
{

@ -5,6 +5,7 @@ using System.Text;
using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers

@ -0,0 +1,85 @@
using System;
using System.ServiceModel.Syndication;
using System.Xml;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers
{
abstract class FeedProviderBase
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
/// <summary>
/// Gets the source URL for the feed
/// </summary>
protected abstract string[] URL { get; }
/// <summary>
/// Gets the name for this feed
/// </summary>
protected abstract string Name { get; }
public void Fetch()
{
Logger.Info("Fetching feeds from " + Name);
foreach (var url in URL)
{
var feed = SyndicationFeed.Load(XmlReader.Create(url)).Items;
foreach (var item in feed)
{
ProcessItem(item);
}
}
Logger.Info("Finished processing feeds from " + Name);
}
private void ProcessItem(SyndicationItem item)
{
var parseResult = ParseFeed(item);
}
public void DownloadIfWanted(NzbInfoModel nzb, Indexer indexer)
{
if (nzb.IsPassworded())
{
Logger.Debug("Skipping Passworded Report {0}", nzb.Title);
return;
}
var episodeParseResults = Parser.ParseEpisodeInfo(nzb.Title);
if (episodeParseResults.Episodes.Count > 0)
{
//ProcessStandardItem(nzb, indexer, episodeParseResults);
return;
}
//Handles Full Season NZBs
var seasonParseResult = Parser.ParseSeasonInfo(nzb.Title);
if (seasonParseResult != null)
{
//ProcessFullSeasonItem(nzb, indexer, seasonParseResult);
return;
}
Logger.Debug("Unsupported Title: {0}", nzb.Title);
}
protected EpisodeParseResult ParseFeed(SyndicationItem item)
{
return Parser.ParseEpisodeInfo(item.Title.ToString());
}
}
}

@ -12,6 +12,6 @@ namespace NzbDrone.Core.Providers
//This interface will contain methods to process individual RSS Feed Items (Queue if wanted)
void DownloadIfWanted(NzbInfoModel nzb, Indexer indexer);
string GetTitleFix(List<EpisodeParseResult> episodes, int seriesId);
string GetTitleFix(EpisodeParseResult episodes, int seriesId);
}
}

@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using SubSonic.Repository;
using NzbDrone.Core.Repository;

@ -6,6 +6,7 @@ using System.Text;
using System.Text.RegularExpressions;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using SubSonic.Repository;
@ -76,18 +77,17 @@ namespace NzbDrone.Core.Providers
//Stores the list of episodes to add to the EpisodeFile
var episodes = new List<Episode>();
foreach (var parsedEpisode in episodesInFile)
foreach (var episodeNumber in episodesInFile.Episodes)
{
EpisodeParseResult closureEpisode = parsedEpisode;
var episode = _episodeProvider.GetEpisode(series.SeriesId, closureEpisode.SeasonNumber,
closureEpisode.EpisodeNumber);
var episode = _episodeProvider.GetEpisode(series.SeriesId, episodesInFile.SeasonNumber, episodeNumber);
if (episode != null)
{
episodes.Add(episode);
}
else
Logger.Warn("Unable to find Series:{0} Season:{1} Episode:{2} in the database. File:{3}", series.Title, closureEpisode.SeasonNumber, closureEpisode.EpisodeNumber, filePath);
Logger.Warn("Unable to find Series:{0} Season:{1} Episode:{2} in the database. File:{3}", series.Title, episodesInFile.SeasonNumber, episodeNumber, filePath);
}
//Return null if no Episodes exist in the DB for the parsed episodes from file

@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using System.Xml.Linq;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers
{

@ -7,6 +7,7 @@ using System.Threading;
using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers

@ -6,6 +6,7 @@ using System.Text;
using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers
@ -23,7 +24,7 @@ namespace NzbDrone.Core.Providers
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public RssItemProcessingProvider(ISeriesProvider seriesProvider, ISeasonProvider seasonProvider,
public RssItemProcessingProvider(ISeriesProvider seriesProvider, ISeasonProvider seasonProvider,
IEpisodeProvider episodeProvider, IHistoryProvider historyProvider,
IDownloadProvider sabProvider, IConfigProvider configProvider,
IHttpProvider httpProvider, IDiskProvider diskProvider)
@ -53,7 +54,7 @@ namespace NzbDrone.Core.Providers
var episodeParseResults = Parser.ParseEpisodeInfo(nzb.Title);
if (episodeParseResults.Count() > 0)
if (episodeParseResults.Episodes.Count() > 0)
{
ProcessStandardItem(nzb, indexer, episodeParseResults);
return;
@ -78,7 +79,7 @@ namespace NzbDrone.Core.Providers
}
}
public string GetTitleFix(List<EpisodeParseResult> episodes, int seriesId)
public string GetTitleFix(EpisodeParseResult episodes, int seriesId)
{
var series = _seriesProvider.GetSeries(seriesId);
@ -86,16 +87,16 @@ namespace NzbDrone.Core.Providers
string episodeNumbers = String.Empty;
string episodeTitles = String.Empty;
foreach (var episode in episodes)
foreach (var episode in episodes.Episodes)
{
var episodeInDb = _episodeProvider.GetEpisode(seriesId, episode.SeasonNumber, episode.EpisodeNumber);
var episodeInDb = _episodeProvider.GetEpisode(seriesId, episodes.SeasonNumber, episode);
if (episodeInDb == null)
{
//Todo: Handle this some other way?
Logger.Debug("Episode Not found in Database, Fake it...");
//return String.Format("{0} - {1:00}x{2}", series.Title, episode.SeasonNumber, episode.EpisodeNumber);
episodeInDb = new Episode { EpisodeNumber = episode.EpisodeNumber, Title = "TBA" };
episodeInDb = new Episode { EpisodeNumber = episode, Title = "TBA" };
}
seasonNumber = episodeInDb.SeasonNumber;
@ -110,23 +111,23 @@ namespace NzbDrone.Core.Providers
#endregion
private void ProcessStandardItem(NzbInfoModel nzb, Indexer indexer, List<EpisodeParseResult> episodeParseResults)
private void ProcessStandardItem(NzbInfoModel nzb, Indexer indexer, EpisodeParseResult episodeParseResults)
{
//Will try to match via NormalizeTitle, if that fails it will look for a scene name and do a lookup for your shows
var series = _seriesProvider.FindSeries(episodeParseResults[0].SeriesTitle);
var series = _seriesProvider.FindSeries(episodeParseResults.SeriesTitle);
if (series == null)
{
//If we weren't able to find a title using the clean name, lets try again looking for a scene name
var sceneId = SceneNameHelper.FindByName(episodeParseResults[0].SeriesTitle);
var sceneId = SceneNameHelper.FindByName(episodeParseResults.SeriesTitle);
if (sceneId != 0)
series = _seriesProvider.GetSeries(sceneId);
if (series == null)
{
Logger.Debug("Show is not being watched: {0}", episodeParseResults[0].SeriesTitle);
Logger.Debug("Show is not being watched: {0}", episodeParseResults.SeriesTitle);
return;
}
}
@ -137,7 +138,7 @@ namespace NzbDrone.Core.Providers
nzb.Quality = Parser.ParseQuality(nzb.Title);
//Loop through the list of the episodeParseResults to ensure that all the episodes are needed
foreach (var episode in episodeParseResults)
foreach (var episode in episodeParseResults.Episodes)
{
//IsEpisodeWanted?
var episodeModel = new EpisodeModel();
@ -145,13 +146,13 @@ namespace NzbDrone.Core.Providers
episodeModel.SeriesId = series.SeriesId;
episodeModel.SeriesTitle = series.Title;
episodeModel.Quality = nzb.Quality;
episodeModel.SeasonNumber = episode.SeasonNumber;
episodeModel.EpisodeNumber = episode.EpisodeNumber;
episodeModel.SeasonNumber = episodeParseResults.SeasonNumber;
episodeModel.EpisodeNumber = episode;
if (!_episodeProvider.IsNeeded(episodeModel))
return;
var titleFix = GetTitleFix(new List<EpisodeParseResult> { episode }, episodeModel.SeriesId);
var titleFix = GetTitleFix(episodeParseResults, episodeModel.SeriesId);
titleFix = String.Format("{0} [{1}]", titleFix, nzb.Quality); //Add Quality to the titleFix
//If it is a PROPER we want to put PROPER in the titleFix
@ -172,15 +173,15 @@ namespace NzbDrone.Core.Providers
if (Convert.ToBoolean(_configProvider.GetValue("UseBlackHole", true, true)))
{
if (DownloadNzb(nzb))
AddToHistory(episodeParseResults, series, nzb, indexer);
//if (DownloadNzb(nzb))
//AddToHistory(episodeParseResults, nzb, indexer);
}
//Send it to SABnzbd
else
{
//Only need to do this check if it contains more than one episode (because we already checked individually before)
if (episodeParseResults.Count > 1)
if (episodeParseResults.Episodes.Count > 1)
{
if (_sabProvider.IsInQueue(nzb.TitleFix))
return;
@ -188,15 +189,11 @@ namespace NzbDrone.Core.Providers
if (indexer.IndexerName != "Newzbin")
{
if (_sabProvider.AddByUrl(nzb.Link.ToString(), nzb.TitleFix))
AddToHistory(episodeParseResults, series, nzb, indexer);
}
else
{
if (_sabProvider.AddById(nzb.Id, nzb.TitleFix))
AddToHistory(episodeParseResults, series, nzb, indexer);
//if (_sabProvider.AddByUrl(nzb.Link.ToString(), nzb.TitleFix))
//AddToHistory(_episodeProvider.GetEpisode(episodeParseResults.), series, nzb, indexer);
}
}
}
@ -285,8 +282,7 @@ namespace NzbDrone.Core.Providers
{
if (DownloadNzb(nzb))
{
var episodeParseResults = GetEpisodeParseList(season.Episodes);
AddToHistory(episodeParseResults, series, nzb, indexer);
AddToHistory(season.Episodes, nzb, indexer);
}
}
@ -300,54 +296,26 @@ namespace NzbDrone.Core.Providers
{
if (_sabProvider.AddByUrl(nzb.Link.ToString(), nzb.TitleFix))
{
var episodeParseResults = GetEpisodeParseList(season.Episodes);
AddToHistory(episodeParseResults, series, nzb, indexer);
AddToHistory(season.Episodes, nzb, indexer);
}
}
else
{
if (_sabProvider.AddById(nzb.Id, nzb.TitleFix))
{
var episodeParseResults = GetEpisodeParseList(season.Episodes);
AddToHistory(episodeParseResults, series, nzb, indexer);
}
}
}
}
//Possibly grab the whole season if a certain % of the season is missing, rather than for 1 or 2 episodes
}
private List<EpisodeParseResult> GetEpisodeParseList(List<Episode> episodes)
private void AddToHistory(IEnumerable<Episode> episodes, NzbInfoModel nzb, Indexer indexer)
{
var episodeParseResults = new List<EpisodeParseResult>();
episodeParseResults.AddRange(
episodes.Select(
e =>
new EpisodeParseResult { EpisodeNumber = e.EpisodeNumber, SeasonNumber = e.SeasonNumber }));
//Set episode status to grabbed
//episode.Status = EpisodeStatusType.Grabbed;
return episodeParseResults;
}
//Add to History
private void AddToHistory(List<EpisodeParseResult> episodeParseResults, Series series, NzbInfoModel nzb, Indexer indexer)
{
//We need to loop through the episodeParseResults so each episode in the NZB is properly handled
foreach (var epr in episodeParseResults)
foreach (var episode in episodes)
{
var episode = _episodeProvider.GetEpisode(series.SeriesId, epr.SeasonNumber, epr.EpisodeNumber);
if (episode == null)
{
//Not sure how we got this far, so lets throw an exception
throw new ArgumentOutOfRangeException();
}
//Set episode status to grabbed
episode.Status = EpisodeStatusType.Grabbed;
//Add to History
var history = new History();
history.Date = DateTime.Now;
history.EpisodeId = episode.EpisodeId;
@ -376,7 +344,7 @@ namespace NzbDrone.Core.Providers
var filename = path + Path.DirectorySeparatorChar + nzb.TitleFix + ".nzb";
if (_httpProvider.DownloadFile(nzb.Link.ToString(), filename))
return true;
return true;
}
Logger.Error("Blackhole Directory doesn't exist, not saving NZB: '{0}'", path);

@ -7,6 +7,7 @@ using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using Rss;

@ -3,6 +3,7 @@ using System.Linq;
using System.Web;
using System.Xml.Linq;
using NLog;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers
{

@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using NLog;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using SubSonic.Repository;

@ -7,6 +7,7 @@ using System.Threading;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers
{

@ -6,6 +6,7 @@ using System.Text;
using System.Xml.Linq;
using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers
{

@ -5,6 +5,7 @@ using System.Linq;
using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Web.Models;
namespace NzbDrone.Web.Controllers

@ -7,6 +7,7 @@ using System.Xml.Linq;
using NLog;
using NzbDrone.Core;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Web.Controllers
{

@ -8,6 +8,7 @@ using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Web.Models;

@ -9,6 +9,7 @@ using NzbDrone.Core;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Web.Models;

@ -27,7 +27,6 @@ Global
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D12F7F2F-8A3C-415F-88FA-6DD061A84869}.Debug|Any CPU.ActiveCfg = Debug|x86
{D12F7F2F-8A3C-415F-88FA-6DD061A84869}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{D12F7F2F-8A3C-415F-88FA-6DD061A84869}.Debug|Mixed Platforms.Build.0 = Debug|x86
{D12F7F2F-8A3C-415F-88FA-6DD061A84869}.Debug|x64.ActiveCfg = Debug|x86
{D12F7F2F-8A3C-415F-88FA-6DD061A84869}.Debug|x86.ActiveCfg = Debug|x86
{D12F7F2F-8A3C-415F-88FA-6DD061A84869}.Debug|x86.Build.0 = Debug|x86
@ -56,7 +55,6 @@ Global
{43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Debug|x64.ActiveCfg = Debug|Any CPU
{43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Debug|x86.ActiveCfg = Debug|Any CPU
{43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Debug|x86.Build.0 = Debug|Any CPU
@ -69,7 +67,6 @@ Global
{193ADD3B-792B-4173-8E4C-5A3F8F0237F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{193ADD3B-792B-4173-8E4C-5A3F8F0237F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{193ADD3B-792B-4173-8E4C-5A3F8F0237F0}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{193ADD3B-792B-4173-8E4C-5A3F8F0237F0}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{193ADD3B-792B-4173-8E4C-5A3F8F0237F0}.Debug|x64.ActiveCfg = Debug|Any CPU
{193ADD3B-792B-4173-8E4C-5A3F8F0237F0}.Debug|x86.ActiveCfg = Debug|Any CPU
{193ADD3B-792B-4173-8E4C-5A3F8F0237F0}.Debug|x86.Build.0 = Debug|Any CPU
@ -81,7 +78,6 @@ Global
{193ADD3B-792B-4173-8E4C-5A3F8F0237F0}.Release|x86.ActiveCfg = Release|Any CPU
{0C679573-736D-4F77-B934-FD8931AC1AA1}.Debug|Any CPU.ActiveCfg = Debug|x86
{0C679573-736D-4F77-B934-FD8931AC1AA1}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{0C679573-736D-4F77-B934-FD8931AC1AA1}.Debug|Mixed Platforms.Build.0 = Debug|x86
{0C679573-736D-4F77-B934-FD8931AC1AA1}.Debug|x64.ActiveCfg = Debug|x86
{0C679573-736D-4F77-B934-FD8931AC1AA1}.Debug|x86.ActiveCfg = Debug|x86
{0C679573-736D-4F77-B934-FD8931AC1AA1}.Debug|x86.Build.0 = Debug|x86

Loading…
Cancel
Save