SceneNaming is now stored on NzbDrone webserver.
Database will update every 12 hours from CSV on server.
This commit is contained in:
parent
6dda51d0e7
commit
ab2007cb6f
|
@ -1,11 +1,19 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using AutoMoq;
|
||||||
|
using FizzWare.NBuilder;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Core.Helpers;
|
using NzbDrone.Core.Helpers;
|
||||||
|
using NzbDrone.Core.Providers;
|
||||||
|
using NzbDrone.Core.Repository;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
using SubSonic.Repository;
|
||||||
|
using TvdbLib.Data;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test
|
namespace NzbDrone.Core.Test
|
||||||
{
|
{
|
||||||
|
@ -13,20 +21,92 @@ namespace NzbDrone.Core.Test
|
||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||||
public class SceneNameHelperTest : TestBase
|
public class SceneNameHelperTest : TestBase
|
||||||
{
|
{
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void GetIdByName_exists()
|
public void GetSceneName_exists()
|
||||||
{
|
{
|
||||||
var id = SceneNameHelper.GetIdByName("CSI New York");
|
//Setup
|
||||||
id.Should().Be(73696);
|
var fakeMap = Builder<SceneNameMapping>.CreateNew()
|
||||||
|
.With(f => f.SeriesId = 12345)
|
||||||
|
.With(f => f.SceneName = "Law and Order")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var mocker = new AutoMoqer();
|
||||||
|
|
||||||
|
mocker.GetMock<IRepository>()
|
||||||
|
.Setup(f => f.Single<SceneNameMapping>(It.IsAny<Expression<Func<SceneNameMapping, bool>>>()))
|
||||||
|
.Returns(fakeMap);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var sceneName = mocker.Resolve<SceneNameMappingProvider>().GetSceneName(fakeMap.SeriesId);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
Assert.AreEqual(fakeMap.SceneName, sceneName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetSeriesId_exists()
|
||||||
|
{
|
||||||
|
//Setup
|
||||||
|
var fakeMap = Builder<SceneNameMapping>.CreateNew()
|
||||||
|
.With(f => f.SeriesId = 12345)
|
||||||
|
.With(f => f.SceneName = "Law and Order")
|
||||||
|
.With(f => f.SceneName = "laworder")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var mocker = new AutoMoqer();
|
||||||
|
|
||||||
|
mocker.GetMock<IRepository>()
|
||||||
|
.Setup(f => f.Single<SceneNameMapping>(It.IsAny<Expression<Func<SceneNameMapping, bool>>>()))
|
||||||
|
.Returns(fakeMap);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var seriesId = mocker.Resolve<SceneNameMappingProvider>().GetSeriesId(fakeMap.SceneCleanName);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
Assert.AreEqual(fakeMap.SeriesId, seriesId);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void GetTitleById_exists()
|
public void GetSceneName_null()
|
||||||
{
|
{
|
||||||
var title = SceneNameHelper.GetTitleById(71256);
|
//Setup
|
||||||
title.Should().Be("The Daily Show");
|
var fakeMap = Builder<SceneNameMapping>.CreateNew()
|
||||||
|
.With(f => f.SeriesId = 12345)
|
||||||
|
.With(f => f.SceneName = "Law and Order")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var mocker = new AutoMoqer();
|
||||||
|
|
||||||
|
mocker.GetMock<IRepository>()
|
||||||
|
.Setup(f => f.Single<SceneNameMapping>(It.IsAny<Expression<Func<SceneNameMapping, bool>>>()));
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var sceneName = mocker.Resolve<SceneNameMappingProvider>().GetSceneName(fakeMap.SeriesId);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
Assert.AreEqual(null, sceneName);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetSeriesId_null()
|
||||||
|
{
|
||||||
|
//Setup
|
||||||
|
var fakeMap = Builder<SceneNameMapping>.CreateNew()
|
||||||
|
.With(f => f.SeriesId = 12345)
|
||||||
|
.With(f => f.SceneName = "Law and Order")
|
||||||
|
.With(f => f.SceneName = "laworder")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var mocker = new AutoMoqer();
|
||||||
|
|
||||||
|
mocker.GetMock<IRepository>()
|
||||||
|
.Setup(f => f.Single<SceneNameMapping>(It.IsAny<Expression<Func<SceneNameMapping, bool>>>()));
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var seriesId = mocker.Resolve<SceneNameMappingProvider>().GetSeriesId(fakeMap.SceneCleanName);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
Assert.AreEqual(null, seriesId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,6 +122,7 @@ namespace NzbDrone.Core
|
||||||
_kernel.Bind<IJob>().To<EpisodeSearchJob>().InTransientScope();
|
_kernel.Bind<IJob>().To<EpisodeSearchJob>().InTransientScope();
|
||||||
_kernel.Bind<IJob>().To<RenameEpisodeJob>().InTransientScope();
|
_kernel.Bind<IJob>().To<RenameEpisodeJob>().InTransientScope();
|
||||||
_kernel.Bind<IJob>().To<PostDownloadScanJob>().InTransientScope();
|
_kernel.Bind<IJob>().To<PostDownloadScanJob>().InTransientScope();
|
||||||
|
_kernel.Bind<IJob>().To<UpdateSceneMappingsJob>().InTransientScope();
|
||||||
|
|
||||||
_kernel.Get<JobProvider>().Initialize();
|
_kernel.Get<JobProvider>().Initialize();
|
||||||
_kernel.Get<WebTimer>().StartTimer(30);
|
_kernel.Get<WebTimer>().StartTimer(30);
|
||||||
|
|
|
@ -58,6 +58,7 @@ namespace NzbDrone.Core.Datastore
|
||||||
repository.Single<QualityProfile>(1);
|
repository.Single<QualityProfile>(1);
|
||||||
repository.Single<History>(1);
|
repository.Single<History>(1);
|
||||||
repository.Single<IndexerSetting>(1);
|
repository.Single<IndexerSetting>(1);
|
||||||
|
repository.Single<SceneNameMapping>(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,146 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
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 Dictionary<String, Int32> SeriesIdLookupList = new Dictionary<string, int>();
|
|
||||||
private static readonly Dictionary<Int32, String> SceneNameLookupList = new Dictionary<Int32, String>();
|
|
||||||
|
|
||||||
|
|
||||||
static SceneNameHelper()
|
|
||||||
{
|
|
||||||
//These values are used to match report titles parsed out of RSS to a series in the DB
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("CSI"), 72546);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("CSI New York"), 73696);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("CSI NY"), 73696);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Archer"), 110381);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Life After People The Series"), 83897);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Life After People"), 83897);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Kitchen Nightmares US"), 80552);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("The Daily Show"), 71256);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("The Daily Show with Jon Stewart"), 71256);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Law and Order SVU"), 75692);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Law and Order Special Victims Unit"), 75692);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Law and Order Criminal Intent"), 71489);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Law and Order CI"), 71489);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Dancing With The Stars US"), 79590);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Craig Ferguson"), 73387);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Jimmy Fallon"), 85355);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("David Letterman"), 75088);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Big Brother US"), 76706);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("The Colony"), 105521);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("The Colony US"), 105521);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Americas Funniest Home Videos"), 76235);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("AFHV"), 76235);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Childrens Hospital US"), 139941);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Childrens Hospital"), 139941);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Merlin"), 83123);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Merlin 2008"), 83123);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("WWE Monday Night RAW"), 76779);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Shit My Dad Says"), 164951);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Genius with Dave Gorman"), 83714);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Law and Order LA"), 168161);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Star Trek TOS"), 77526);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Star Trek DS9"), 72073);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Ellen Degeneres"), 72194);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Drinking Made Easy"), 195831);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Zane Lampreys Drinking Made Easy"), 195831);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Poirot"), 76133);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Agatha Christies Poirot"), 76133);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("The Real World Road Rules Challenge"), 70870);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("The Challenge Cutthroat"), 70870);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("This Old House Program"), 77444);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("60 Minutes US"), 73290);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Conan"), 194751);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Conan 2010"), 194751);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Carlos 2010"), 164451);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Babalon 5"), 70726);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Babalon5"), 70726);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Genius"), 83714);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Genius With Dave Gormand"), 83714);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Come Fly With Me 2010"), 212571);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Border Security"), 81563);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Border Security Australias Frontline"), 81563);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Silent Library US"), 172381);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Sci-Fi Science"), 131791);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Frontline"), 80646);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("Frontline US"), 80646);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("RBT AU"), 189931);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("House"), 73255);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("House MD"), 73255);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("The Office"), 73244);
|
|
||||||
SeriesIdLookupList.Add(Parser.NormalizeTitle("The Office US"), 73244);
|
|
||||||
|
|
||||||
//These values are used when doing an indexer search.
|
|
||||||
SceneNameLookupList.Add(72546, "CSI"); //CSI
|
|
||||||
SceneNameLookupList.Add(73696, "CSI"); //CSI NY
|
|
||||||
SceneNameLookupList.Add(110381, "Archer");
|
|
||||||
SceneNameLookupList.Add(83897, "Life After People");
|
|
||||||
SceneNameLookupList.Add(80552, "Kitchen Nightmares US");
|
|
||||||
SceneNameLookupList.Add(71256, "The Daily Show"); //The Daily Show with Jon Stewart
|
|
||||||
SceneNameLookupList.Add(75692, "Law and Order"); //SVU
|
|
||||||
SceneNameLookupList.Add(71489, "Law and Order");//CI
|
|
||||||
SceneNameLookupList.Add(79590, "Dancing With The Stars US");
|
|
||||||
SceneNameLookupList.Add(73387, "Craig Ferguson");
|
|
||||||
SceneNameLookupList.Add(85355, "Jimmy Fallon");
|
|
||||||
SceneNameLookupList.Add(75088, "David Letterman");
|
|
||||||
SceneNameLookupList.Add(76706, "Big Brother US");
|
|
||||||
SceneNameLookupList.Add(105521, "The Colony");
|
|
||||||
SceneNameLookupList.Add(76235, "Americas Funniest Home Videos");
|
|
||||||
SceneNameLookupList.Add(139941, "Childrens Hospital");
|
|
||||||
SceneNameLookupList.Add(83123, "Merlin");
|
|
||||||
SceneNameLookupList.Add(76779, "WWE Monday Night RAW");
|
|
||||||
SceneNameLookupList.Add(164951, "Shit My Dad Says");
|
|
||||||
SceneNameLookupList.Add(168161, "Law and Order LA");
|
|
||||||
SceneNameLookupList.Add(77526, "Star Trek TOS");
|
|
||||||
SceneNameLookupList.Add(72073, "Star Trek DS9");
|
|
||||||
SceneNameLookupList.Add(72194, "Ellen Degeneres");
|
|
||||||
SceneNameLookupList.Add(195831, "Drinking Made Easy");//Zane Lampreys Drinking Made Easy
|
|
||||||
SceneNameLookupList.Add(76133, "Poirot"); //Agatha Christies Poirot
|
|
||||||
SceneNameLookupList.Add(70870, "The Real World Road Rules Challenge");
|
|
||||||
SceneNameLookupList.Add(77444, "This Old House Program");
|
|
||||||
SceneNameLookupList.Add(73290, "60 Minutes US");
|
|
||||||
SceneNameLookupList.Add(194751, "Conan");
|
|
||||||
SceneNameLookupList.Add(164451, "Carlos 2010");
|
|
||||||
SceneNameLookupList.Add(70726, "Babalon"); //5
|
|
||||||
SceneNameLookupList.Add(83714, "Genius"); //Genius With Dave Gormand
|
|
||||||
SceneNameLookupList.Add(212571, "Come Fly With Me 2010");
|
|
||||||
SceneNameLookupList.Add(81563, "Border Security");
|
|
||||||
SceneNameLookupList.Add(172381, "Silent Library US");
|
|
||||||
SceneNameLookupList.Add(131791, "Sci-Fi Science");
|
|
||||||
SceneNameLookupList.Add(80646, "Frontline");
|
|
||||||
SceneNameLookupList.Add(189931, "RBT AU");
|
|
||||||
SceneNameLookupList.Add(73255, "House");
|
|
||||||
SceneNameLookupList.Add(73244, "The Office");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static Nullable<Int32> GetIdByName(string cleanSeriesName)
|
|
||||||
{
|
|
||||||
int id;
|
|
||||||
|
|
||||||
if (SeriesIdLookupList.TryGetValue(Parser.NormalizeTitle(cleanSeriesName), out id))
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String GetTitleById(int seriesId)
|
|
||||||
{
|
|
||||||
string title;
|
|
||||||
|
|
||||||
if (SceneNameLookupList.TryGetValue(seriesId, out title))
|
|
||||||
{
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -168,7 +168,6 @@
|
||||||
<Compile Include="Helpers\EpisodeRenameHelper.cs" />
|
<Compile Include="Helpers\EpisodeRenameHelper.cs" />
|
||||||
<Compile Include="Helpers\EpisodeSortingHelper.cs" />
|
<Compile Include="Helpers\EpisodeSortingHelper.cs" />
|
||||||
<Compile Include="Helpers\FileSizeFormatHelpercs.cs" />
|
<Compile Include="Helpers\FileSizeFormatHelpercs.cs" />
|
||||||
<Compile Include="Helpers\SceneNameHelper.cs" />
|
|
||||||
<Compile Include="Instrumentation\LogProvider.cs" />
|
<Compile Include="Instrumentation\LogProvider.cs" />
|
||||||
<Compile Include="Instrumentation\SubsonicTarget.cs" />
|
<Compile Include="Instrumentation\SubsonicTarget.cs" />
|
||||||
<Compile Include="Instrumentation\ExceptioneerTarget.cs" />
|
<Compile Include="Instrumentation\ExceptioneerTarget.cs" />
|
||||||
|
@ -185,6 +184,7 @@
|
||||||
<Compile Include="Providers\Indexer\SyndicationFeedXmlReader.cs" />
|
<Compile Include="Providers\Indexer\SyndicationFeedXmlReader.cs" />
|
||||||
<Compile Include="Providers\AutoConfigureProvider.cs" />
|
<Compile Include="Providers\AutoConfigureProvider.cs" />
|
||||||
<Compile Include="Providers\Indexer\NzbMatrix.cs" />
|
<Compile Include="Providers\Indexer\NzbMatrix.cs" />
|
||||||
|
<Compile Include="Providers\Jobs\UpdateSceneMappingsJob.cs" />
|
||||||
<Compile Include="Providers\Jobs\PostDownloadScanJob.cs" />
|
<Compile Include="Providers\Jobs\PostDownloadScanJob.cs" />
|
||||||
<Compile Include="Providers\Jobs\RenameEpisodeJob.cs" />
|
<Compile Include="Providers\Jobs\RenameEpisodeJob.cs" />
|
||||||
<Compile Include="Providers\Jobs\EpisodeSearchJob.cs" />
|
<Compile Include="Providers\Jobs\EpisodeSearchJob.cs" />
|
||||||
|
@ -197,6 +197,7 @@
|
||||||
<Compile Include="Providers\Jobs\IJob.cs" />
|
<Compile Include="Providers\Jobs\IJob.cs" />
|
||||||
<Compile Include="Providers\Jobs\RssSyncJob.cs" />
|
<Compile Include="Providers\Jobs\RssSyncJob.cs" />
|
||||||
<Compile Include="Providers\Jobs\UpdateInfoJob.cs" />
|
<Compile Include="Providers\Jobs\UpdateInfoJob.cs" />
|
||||||
|
<Compile Include="Providers\SceneNameMappingProvider.cs" />
|
||||||
<Compile Include="Providers\StatsProvider.cs" />
|
<Compile Include="Providers\StatsProvider.cs" />
|
||||||
<Compile Include="Repository\ExternalNotificationSetting.cs" />
|
<Compile Include="Repository\ExternalNotificationSetting.cs" />
|
||||||
<Compile Include="Repository\JobSetting.cs" />
|
<Compile Include="Repository\JobSetting.cs" />
|
||||||
|
@ -241,6 +242,7 @@
|
||||||
<Compile Include="Repository\Quality\QualityProfile.cs" />
|
<Compile Include="Repository\Quality\QualityProfile.cs" />
|
||||||
<Compile Include="Repository\RootDir.cs" />
|
<Compile Include="Repository\RootDir.cs" />
|
||||||
<Compile Include="Repository\Quality\QualityTypes.cs" />
|
<Compile Include="Repository\Quality\QualityTypes.cs" />
|
||||||
|
<Compile Include="Repository\SceneNameMapping.cs" />
|
||||||
<Compile Include="Repository\Series.cs" />
|
<Compile Include="Repository\Series.cs" />
|
||||||
<Compile Include="CentralDispatch.cs" />
|
<Compile Include="CentralDispatch.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
|
|
@ -16,16 +16,19 @@ namespace NzbDrone.Core.Providers.Jobs
|
||||||
private readonly DownloadProvider _downloadProvider;
|
private readonly DownloadProvider _downloadProvider;
|
||||||
private readonly IndexerProvider _indexerProvider;
|
private readonly IndexerProvider _indexerProvider;
|
||||||
private readonly EpisodeProvider _episodeProvider;
|
private readonly EpisodeProvider _episodeProvider;
|
||||||
|
private readonly SceneNameMappingProvider _sceneNameMappingProvider;
|
||||||
|
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public EpisodeSearchJob(InventoryProvider inventoryProvider, DownloadProvider downloadProvider, IndexerProvider indexerProvider, EpisodeProvider episodeProvider)
|
public EpisodeSearchJob(InventoryProvider inventoryProvider, DownloadProvider downloadProvider,
|
||||||
|
IndexerProvider indexerProvider, EpisodeProvider episodeProvider,
|
||||||
|
SceneNameMappingProvider sceneNameMappingProvider)
|
||||||
{
|
{
|
||||||
_inventoryProvider = inventoryProvider;
|
_inventoryProvider = inventoryProvider;
|
||||||
_downloadProvider = downloadProvider;
|
_downloadProvider = downloadProvider;
|
||||||
_indexerProvider = indexerProvider;
|
_indexerProvider = indexerProvider;
|
||||||
_episodeProvider = episodeProvider;
|
_episodeProvider = episodeProvider;
|
||||||
|
_sceneNameMappingProvider = sceneNameMappingProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
|
@ -56,7 +59,7 @@ namespace NzbDrone.Core.Providers.Jobs
|
||||||
var indexers = _indexerProvider.GetEnabledIndexers();
|
var indexers = _indexerProvider.GetEnabledIndexers();
|
||||||
var reports = new List<EpisodeParseResult>();
|
var reports = new List<EpisodeParseResult>();
|
||||||
|
|
||||||
var title = SceneNameHelper.GetTitleById(series.SeriesId);
|
var title = _sceneNameMappingProvider.GetSceneName(series.SeriesId);
|
||||||
|
|
||||||
if(string.IsNullOrWhiteSpace(title))
|
if(string.IsNullOrWhiteSpace(title))
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using NzbDrone.Core.Model.Notification;
|
||||||
|
using NzbDrone.Core.Repository;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Providers.Jobs
|
||||||
|
{
|
||||||
|
public class UpdateSceneMappingsJob : IJob
|
||||||
|
{
|
||||||
|
private readonly SceneNameMappingProvider _sceneNameMappingProvider;
|
||||||
|
|
||||||
|
public UpdateSceneMappingsJob(SceneNameMappingProvider sceneNameMappingProvider)
|
||||||
|
{
|
||||||
|
_sceneNameMappingProvider = sceneNameMappingProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UpdateSceneMappingsJob()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return "Update Scene Mappings"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int DefaultInterval
|
||||||
|
{
|
||||||
|
get { return 720; } //Every 12 hours
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void Start(ProgressNotification notification, int targetId)
|
||||||
|
{
|
||||||
|
notification.CurrentMessage = "Updating Scene Mappings";
|
||||||
|
if (_sceneNameMappingProvider.UpdateMappings())
|
||||||
|
notification.CurrentMessage = "Scene Mappings Completed";
|
||||||
|
|
||||||
|
else
|
||||||
|
notification.CurrentMessage = "Scene Mappings Failed";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,91 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
using NLog;
|
||||||
|
using NzbDrone.Core.Providers.Core;
|
||||||
|
using NzbDrone.Core.Repository;
|
||||||
|
using SubSonic.Repository;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Providers
|
||||||
|
{
|
||||||
|
public class SceneNameMappingProvider
|
||||||
|
{
|
||||||
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
|
private readonly IRepository _repository;
|
||||||
|
private readonly HttpProvider _httpProvider;
|
||||||
|
|
||||||
|
public SceneNameMappingProvider(IRepository repository, HttpProvider httpProvider)
|
||||||
|
{
|
||||||
|
_repository = repository;
|
||||||
|
_httpProvider = httpProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool UpdateMappings()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var mapping = _httpProvider.DownloadString("http://vps.nzbdrone.com/SceneNameMappings.csv");
|
||||||
|
var newMaps = new List<SceneNameMapping>();
|
||||||
|
|
||||||
|
using (var reader = new StringReader(mapping))
|
||||||
|
{
|
||||||
|
string line;
|
||||||
|
while ((line = reader.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
var split = line.Split(',');
|
||||||
|
var seriesId = 0;
|
||||||
|
Int32.TryParse(split[1], out seriesId);
|
||||||
|
|
||||||
|
var map = new SceneNameMapping();
|
||||||
|
map.SceneCleanName = split[0];
|
||||||
|
map.SeriesId = seriesId;
|
||||||
|
map.SceneName = split[2];
|
||||||
|
|
||||||
|
newMaps.Add(map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.Debug("Deleting all existing Scene Mappings.");
|
||||||
|
_repository.DeleteMany<SceneNameMapping>(GetAll());
|
||||||
|
|
||||||
|
Logger.Debug("Adding Scene Mappings");
|
||||||
|
_repository.AddMany(newMaps);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.InfoException("Failed to Update Scene Mappings", ex);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual List<SceneNameMapping> GetAll()
|
||||||
|
{
|
||||||
|
return _repository.All<SceneNameMapping>().ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual string GetSceneName(int seriesId)
|
||||||
|
{
|
||||||
|
var item = _repository.Single<SceneNameMapping>(s => s.SeriesId == seriesId);
|
||||||
|
|
||||||
|
if (item == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return item.SceneName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual Nullable<Int32> GetSeriesId(string cleanName)
|
||||||
|
{
|
||||||
|
var item = _repository.Single<SceneNameMapping>(s => s.SceneCleanName == cleanName);
|
||||||
|
|
||||||
|
if (item == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return item.SeriesId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,12 +22,15 @@ namespace NzbDrone.Core.Providers
|
||||||
private readonly IRepository _repository;
|
private readonly IRepository _repository;
|
||||||
private readonly ConfigProvider _configProvider;
|
private readonly ConfigProvider _configProvider;
|
||||||
private readonly TvDbProvider _tvDbProvider;
|
private readonly TvDbProvider _tvDbProvider;
|
||||||
|
private readonly SceneNameMappingProvider _sceneNameMappingProvider;
|
||||||
|
|
||||||
public SeriesProvider(ConfigProvider configProviderProvider, IRepository repository, TvDbProvider tvDbProviderProvider)
|
public SeriesProvider(ConfigProvider configProviderProvider, IRepository repository,
|
||||||
|
TvDbProvider tvDbProviderProvider, SceneNameMappingProvider sceneNameMappingProvider)
|
||||||
{
|
{
|
||||||
_configProvider = configProviderProvider;
|
_configProvider = configProviderProvider;
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
_tvDbProvider = tvDbProviderProvider;
|
_tvDbProvider = tvDbProviderProvider;
|
||||||
|
_sceneNameMappingProvider = sceneNameMappingProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SeriesProvider()
|
public SeriesProvider()
|
||||||
|
@ -105,7 +108,7 @@ namespace NzbDrone.Core.Providers
|
||||||
{
|
{
|
||||||
var normalizeTitle = Parser.NormalizeTitle(title);
|
var normalizeTitle = Parser.NormalizeTitle(title);
|
||||||
|
|
||||||
var seriesId = SceneNameHelper.GetIdByName(normalizeTitle);
|
var seriesId = _sceneNameMappingProvider.GetSeriesId(normalizeTitle);
|
||||||
if (seriesId != null)
|
if (seriesId != null)
|
||||||
{
|
{
|
||||||
return GetSeries(seriesId.Value);
|
return GetSeries(seriesId.Value);
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using SubSonic.SqlGeneration.Schema;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Repository
|
||||||
|
{
|
||||||
|
public class SceneNameMapping
|
||||||
|
{
|
||||||
|
[SubSonicPrimaryKey]
|
||||||
|
public virtual string SceneCleanName { get; set; }
|
||||||
|
|
||||||
|
public virtual int SeriesId { get; set; }
|
||||||
|
|
||||||
|
public virtual string SceneName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
csinewyork,73696,CSI
|
||||||
|
csiny,73696,CSI
|
||||||
|
archer,110381,Archer
|
||||||
|
lifeafterpeopleseries,83897,Life After People
|
||||||
|
lifeafterpeople,83897,Life After People
|
||||||
|
kitchennightmaresus,80552,Kitchen Nightmares US
|
||||||
|
dailyshow,71256,The Daily Show
|
||||||
|
dailyshowwithjonstewart,71256,The Daily Show
|
||||||
|
lawordersvu,75692,Law and Order SVU
|
||||||
|
laworderspecialvictimsunit,75692,Law and Order
|
||||||
|
lawordercriminalintent,71489,Law and Order
|
||||||
|
laworderci,71489,Law and Order
|
||||||
|
dancingwithstarsus,79590,Dancing With The Stars
|
||||||
|
craigferguson,73387,Craig Ferguson
|
||||||
|
jimmyfallon,85355,Jimmy Fallon
|
||||||
|
davidletterman,75088,David Letterman
|
||||||
|
bigbrotherus,76706,Big Brother
|
||||||
|
colony,105521,The Colony
|
||||||
|
colonyus,105521,The Colony
|
||||||
|
americasfunniesthomevideos,76235,Americas Funniest Home Videos
|
||||||
|
afhv,76235,Americas Funniest Home Videos
|
||||||
|
childrenshospitalus,139941,Childrens Hospital
|
||||||
|
childrenshospital,139941,Childrens Hospital
|
||||||
|
merlin,83123,Merlin
|
||||||
|
merlin2008,83123,Merlin
|
||||||
|
wwemondaynightraw,76779,WWE Monday Night RAW
|
||||||
|
shitmydadsays,164951,Shit My Dad Says
|
||||||
|
geniuswithdavegorman,83714,Genius with Dave Gorman
|
||||||
|
laworderla,168161,Law and Order
|
||||||
|
startrektos,77526,Star Trek TOS
|
||||||
|
startrekds,72073,Star Trek DS9
|
||||||
|
ellendegeneres,72194,Ellen Degeneres
|
||||||
|
drinkingmadeeasy,195831,Drinking Made Easy
|
||||||
|
zanelampreysdrinkingmadeeasy,195831,Drinking Made Easy
|
||||||
|
poirot,76133,Poirot
|
||||||
|
agathachristiespoirot,76133,Poirot
|
||||||
|
realworldroadruleschallenge,70870,The Real World Road Rules Challenge
|
||||||
|
challengecutthroat,70870,The Challenge Cutthroat
|
||||||
|
thisoldhouseprogram,77444,This Old House Program
|
||||||
|
minutesus,73290,60 Minutes
|
||||||
|
conan,194751,Conan
|
||||||
|
conan2010,194751,Conan
|
||||||
|
carlos2010,164451,Carlos 2010
|
||||||
|
babalon,70726,Babalon
|
||||||
|
genius,83714,Genius
|
||||||
|
geniuswithdavegormand,83714,Genius With Dave Gormand
|
||||||
|
comeflywithme2010,212571,Come Fly With Me 2010
|
||||||
|
bordersecurity,81563,Border Security
|
||||||
|
bordersecurityaustraliasfrontline,81563,Border Security Australias Frontline
|
||||||
|
silentlibraryus,172381,Silent Library US
|
||||||
|
scifiscience,131791,Sci Fi Science
|
||||||
|
frontline,80646,Frontline
|
||||||
|
frontlineus,80646,Frontline
|
||||||
|
rbtau,189931,RBT AU
|
||||||
|
house,73255,House
|
||||||
|
housemd,73255,House
|
||||||
|
office,73244,The Office
|
||||||
|
officeus,73244,The Office
|
|
Loading…
Reference in New Issue