Added support for tvmaze.

pull/2/head
Taloth Saldono 9 years ago
parent 9162e97dd5
commit 84c7f4cd8c

@ -57,6 +57,7 @@ namespace NzbDrone.Api.Series
public int Runtime { get; set; }
public int TvdbId { get; set; }
public int TvRageId { get; set; }
public int TvMazeId { get; set; }
public DateTime? FirstAired { get; set; }
public DateTime? LastInfoSync { get; set; }
public SeriesTypes SeriesType { get; set; }

@ -29,7 +29,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
_singleEpisodeSearchCriteria = new SingleEpisodeSearchCriteria
{
Series = new Tv.Series { TvRageId = 10, TvdbId = 20 },
Series = new Tv.Series { TvRageId = 10, TvdbId = 20, TvMazeId = 30 },
SceneTitles = new List<string> { "Monkey Island" },
SeasonNumber = 1,
EpisodeNumber = 2
@ -177,6 +177,19 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
page.Url.Query.Should().Contain("tvdbid=20");
}
[Test]
public void should_search_by_tvmaze_if_supported()
{
_capabilities.SupportedTvSearchParameters = new[] { "q", "tvmazeid", "season", "ep" };
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
results.GetTier(0).Should().HaveCount(1);
var page = results.GetAllTiers().First().First();
page.Url.Query.Should().Contain("tvmazeid=30");
}
[Test]
public void should_prefer_search_by_tvdbid_if_rid_supported()
{

@ -95,6 +95,20 @@ namespace NzbDrone.Core.Test.TvTests
.Verify(v => v.UpdateSeries(It.Is<Series>(s => s.TvRageId == newSeriesInfo.TvRageId)));
}
[Test]
public void should_update_tvmaze_id_if_changed()
{
var newSeriesInfo = _series.JsonClone();
newSeriesInfo.TvMazeId = _series.TvMazeId + 1;
GivenNewSeriesInfo(newSeriesInfo);
Subject.Execute(new RefreshSeriesCommand(_series.Id));
Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.Is<Series>(s => s.TvMazeId == newSeriesInfo.TvMazeId)));
}
[Test]
public void should_log_error_if_tvdb_id_not_found()
{

@ -0,0 +1,15 @@
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(94)]
public class add_tvmazeid : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Alter.Table("Series").AddColumn("TvMazeId").AsInt32().WithDefaultValue(0);
Create.Index().OnTable("Series").OnColumn("TvMazeId");
}
}
}

@ -72,6 +72,19 @@ namespace NzbDrone.Core.Indexers.Newznab
}
}
private bool SupportsTvMazeSearch
{
get
{
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
return capabilities.SupportedTvSearchParameters != null &&
capabilities.SupportedTvSearchParameters.Contains("tvmazeid") &&
capabilities.SupportedTvSearchParameters.Contains("season") &&
capabilities.SupportedTvSearchParameters.Contains("ep");
}
}
private bool SupportsAggregatedIdSearch
{
get
@ -184,6 +197,11 @@ namespace NzbDrone.Core.Indexers.Newznab
ids += "&rid=" + searchCriteria.Series.TvRageId;
}
if (searchCriteria.Series.TvMazeId > 0 && SupportsTvMazeSearch)
{
ids += "&tvmazeid=" + searchCriteria.Series.TvMazeId;
}
chain.Add(GetPagedRequests(maxPages, categories, "tvsearch", ids + parameters));
}
else
@ -198,6 +216,12 @@ namespace NzbDrone.Core.Indexers.Newznab
chain.Add(GetPagedRequests(maxPages, categories, "tvsearch",
string.Format("&rid={0}{1}", searchCriteria.Series.TvRageId, parameters)));
}
else if (searchCriteria.Series.TvMazeId > 0 && SupportsTvMazeSearch)
{
chain.Add(GetPagedRequests(maxPages, categories, "tvsearch",
string.Format("&tvmazeid={0}{1}", searchCriteria.Series.TvMazeId, parameters)));
}
}
if (SupportsTvSearch)

@ -20,6 +20,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook.Resource
public string Slug { get; set; }
public string FirstAired { get; set; }
public int? TvRageId { get; set; }
public int? TvMazeId { get; set; }
public string Status { get; set; }
public int? Runtime { get; set; }

@ -110,6 +110,11 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
series.TvRageId = show.TvRageId.Value;
}
if (show.TvMazeId.HasValue)
{
series.TvMazeId = show.TvMazeId.Value;
}
series.ImdbId = show.ImdbId;
series.Title = show.Title;
series.CleanTitle = Parser.Parser.CleanSeriesTitle(show.Title);

@ -272,6 +272,7 @@
<Compile Include="Datastore\Migration\091_added_indexerstatus.cs" />
<Compile Include="Datastore\Migration\093_naming_config_replace_characters.cs" />
<Compile Include="Datastore\Migration\092_add_unverifiedscenenumbering.cs" />
<Compile Include="Datastore\Migration\094_add_tvmazeid.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationDbFactory.cs" />

@ -73,6 +73,7 @@ namespace NzbDrone.Core.Tv
series.Title = seriesInfo.Title;
series.TitleSlug = seriesInfo.TitleSlug;
series.TvRageId = seriesInfo.TvRageId;
series.TvMazeId = seriesInfo.TvMazeId;
series.ImdbId = seriesInfo.ImdbId;
series.AirTime = seriesInfo.AirTime;
series.Overview = seriesInfo.Overview;

@ -20,6 +20,7 @@ namespace NzbDrone.Core.Tv
public int TvdbId { get; set; }
public int TvRageId { get; set; }
public int TvMazeId { get; set; }
public string ImdbId { get; set; }
public string Title { get; set; }
public string CleanTitle { get; set; }

@ -35,6 +35,10 @@ Handlebars.registerHelper('tvRageUrl', function() {
return 'http://www.tvrage.com/shows/id-' + this.tvRageId;
});
Handlebars.registerHelper('tvMazeUrl', function() {
return 'http://www.tvmaze.com/shows/' + this.tvMazeId + '/_';
});
Handlebars.registerHelper('route', function() {
return StatusModel.get('urlBase') + '/series/' + this.titleSlug;
});

@ -40,6 +40,10 @@
{{#if tvRageId}}
<a href="{{tvRageUrl}}" class="label label-info">TV Rage</a>
{{/if}}
{{#if tvMazeId}}
<a href="{{tvMazeUrl}}" class="label label-info">TV Maze</a>
{{/if}}
</span>
</div>
</div>

Loading…
Cancel
Save