1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-09-11 12:02:35 +02:00

Added StatsProvider.

Bound AutoConfigureProvider to kernel.
Feed Item Parsing will now check for a SceneName match in SceneNameHelper.
This commit is contained in:
Mark McDowall 2011-04-25 22:54:12 -07:00
parent 76a9a0c6f0
commit cb992f1b52
5 changed files with 100 additions and 14 deletions

View File

@ -99,6 +99,7 @@ public static void BindKernel()
_kernel.Bind<JobProvider>().ToSelf().InSingletonScope();
_kernel.Bind<IndexerProvider>().ToSelf().InSingletonScope();
_kernel.Bind<WebTimer>().ToSelf().InSingletonScope();
_kernel.Bind<AutoConfigureProvider>().ToSelf().InSingletonScope();
_kernel.Bind<IRepository>().ToMethod(
c => new SimpleRepository(dbProvider, SimpleRepositoryOptions.RunMigrations)).InSingletonScope();

View File

@ -7,6 +7,8 @@ namespace NzbDrone.Core.Helpers
{
public static class SceneNameHelper
{
//Todo: Move this to a publically available location (so updates can be applied without releasing a new version of NzbDrone)
//Todo: GoogleDocs? WCF Web Services on NzbDrone.com?
private static readonly List<SceneNameModel> SceneNameMappings = new List<SceneNameModel>
{
new SceneNameModel
@ -147,11 +149,6 @@ public static class SceneNameHelper
SeriesId = 83714,
Name = "Genius with Dave Gorman"
},
new SceneNameModel
{
SeriesId = 168161,
Name = "Law and Order Los Angeles"
},
new SceneNameModel
{
SeriesId = 168161,

View File

@ -177,6 +177,7 @@
<Compile Include="Providers\Jobs\IJob.cs" />
<Compile Include="Providers\Jobs\RssSyncJob.cs" />
<Compile Include="Providers\Jobs\UpdateInfoJob.cs" />
<Compile Include="Providers\StatsProvider.cs" />
<Compile Include="Repository\JobSetting.cs" />
<Compile Include="Repository\IndexerSetting.cs" />
<Compile Include="Model\EpisodeParseResult.cs" />

View File

@ -4,6 +4,7 @@
using System.Net;
using System.ServiceModel.Syndication;
using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
@ -147,17 +148,17 @@ internal void ProcessItem(SyndicationItem feedItem)
return;
}
//var sabTitle = _sabProvider.GetSabTitle(parseResult);
var sabTitle = _sabProvider.GetSabTitle(parseResult);
//if (_sabProvider.IsInQueue(sabTitle))
//{
// return;
//}
if (_sabProvider.IsInQueue(sabTitle))
{
return;
}
//if (!_sabProvider.AddByUrl(NzbDownloadUrl(feedItem), sabTitle))
//{
// return;
//}
if (!_sabProvider.AddByUrl(NzbDownloadUrl(feedItem), sabTitle))
{
return;
}
foreach (var episode in episodes)
{
@ -185,6 +186,14 @@ public EpisodeParseResult ParseFeed(SyndicationItem item)
var seriesInfo = _seriesProvider.FindSeries(episodeParseResult.CleanTitle);
if (seriesInfo == null)
{
var seriesId = SceneNameHelper.FindByName(episodeParseResult.CleanTitle);
if (seriesId != 0)
seriesInfo = _seriesProvider.GetSeries(seriesId);
}
if (seriesInfo != null)
{
episodeParseResult.SeriesId = seriesInfo.SeriesId;

View File

@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Providers
{
public class StatsProvider
{
private readonly SeriesProvider _seriesProvider;
public StatsProvider(SeriesProvider seriesProvider)
{
_seriesProvider = seriesProvider;
}
public virtual int SeriesCount()
{
return _seriesProvider.GetAllSeries().Count();
}
public virtual int ActiveSeriesCount()
{
return _seriesProvider.GetAllSeries().Where(s => s.Status == "Continuing").Count();
}
public virtual int EndedSeriesCount()
{
return _seriesProvider.GetAllSeries().Where(s => s.Status == "Ended").Count();
}
public virtual int TotalEpisodesCount()
{
var count = 0;
var series = _seriesProvider.GetAllSeries();
foreach (var s in series)
{
count += s.Episodes.Count;
}
return count;
}
public virtual int TotalAiredEpisodesCount()
{
var count = 0;
var series = _seriesProvider.GetAllSeries();
foreach (var s in series)
{
count += s.Episodes.Where(e => e.AirDate.Date <= DateTime.Today).Count();
}
return count;
}
public virtual int TotalUnairedEpisodesCount()
{
var count = 0;
var series = _seriesProvider.GetAllSeries();
foreach (var s in series)
{
count += s.Episodes.Where(e => e.AirDate.Date > DateTime.Today).Count();
}
return count;
}
public virtual int TotalEpisodesOnDisk()
{
var count = 0;
var series = _seriesProvider.GetAllSeries();
foreach (var s in series)
{
count += s.Episodes.Where(e => e.EpisodeFileId != 0).Count();
}
return count;
}
}
}