mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Added support for tvmaze.
This commit is contained in:
parent
9162e97dd5
commit
84c7f4cd8c
@ -57,6 +57,7 @@ public int SeasonCount
|
||||
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 @@ public void SetUp()
|
||||
|
||||
_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 @@ public void should_search_by_tvdbid_if_supported()
|
||||
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 @@ public void should_update_tvrage_id_if_changed()
|
||||
.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()
|
||||
{
|
||||
|
15
src/NzbDrone.Core/Datastore/Migration/094_add_tvmazeid.cs
Normal file
15
src/NzbDrone.Core/Datastore/Migration/094_add_tvmazeid.cs
Normal file
@ -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 @@ private bool SupportsTvRageSearch
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ private void AddTvIdPageableRequests(IndexerPageableRequestChain chain, int maxP
|
||||
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 @@ private void AddTvIdPageableRequests(IndexerPageableRequestChain chain, int maxP
|
||||
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 @@ public ShowResource()
|
||||
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 @@ private static Series MapSeries(ShowResource show)
|
||||
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 @@ private void RefreshSeriesInfo(Series series)
|
||||
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 @@ public Series()
|
||||
|
||||
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…
Reference in New Issue
Block a user