cleaning up episode/series air date/time
This commit is contained in:
parent
cbe4be814c
commit
42849d3276
|
@ -112,8 +112,6 @@
|
||||||
<Compile Include="Missing\MissingModule.cs" />
|
<Compile Include="Missing\MissingModule.cs" />
|
||||||
<Compile Include="NzbDroneRestModule.cs" />
|
<Compile Include="NzbDroneRestModule.cs" />
|
||||||
<Compile Include="PagingResource.cs" />
|
<Compile Include="PagingResource.cs" />
|
||||||
<Compile Include="Resolvers\EndTimeResolver.cs" />
|
|
||||||
<Compile Include="Resolvers\NextAiringResolver.cs" />
|
|
||||||
<Compile Include="Resolvers\NullableDatetimeToString.cs" />
|
<Compile Include="Resolvers\NullableDatetimeToString.cs" />
|
||||||
<Compile Include="REST\BadRequestException.cs" />
|
<Compile Include="REST\BadRequestException.cs" />
|
||||||
<Compile Include="REST\ResourceValidator.cs" />
|
<Compile Include="REST\ResourceValidator.cs" />
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using AutoMapper;
|
|
||||||
using NzbDrone.Api.QualityProfiles;
|
|
||||||
using NzbDrone.Core.Tv;
|
|
||||||
|
|
||||||
namespace NzbDrone.Api.Resolvers
|
|
||||||
{
|
|
||||||
public class EndTimeResolver : ValueResolver<Episode, DateTime>
|
|
||||||
{
|
|
||||||
protected override DateTime ResolveCore(Episode source)
|
|
||||||
{
|
|
||||||
return source.AirDate.Value.AddMinutes(source.Series.Runtime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using AutoMapper;
|
|
||||||
|
|
||||||
namespace NzbDrone.Api.Resolvers
|
|
||||||
{
|
|
||||||
public class NextAiringResolver : ValueResolver<Core.Tv.Series, DateTime?>
|
|
||||||
{
|
|
||||||
protected override DateTime? ResolveCore(Core.Tv.Series source)
|
|
||||||
{
|
|
||||||
if (String.IsNullOrWhiteSpace(source.AirTime) || !source.NextAiring.HasValue)
|
|
||||||
return source.NextAiring;
|
|
||||||
|
|
||||||
return source.NextAiring.Value.Add(Convert.ToDateTime(source.AirTime).TimeOfDay)
|
|
||||||
.AddHours(source.UtcOffset * -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,6 +4,7 @@ using FluentAssertions;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Core.MetadataSource;
|
using NzbDrone.Core.MetadataSource;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
using NzbDrone.Core.Tv;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.MetadataSourceTests
|
namespace NzbDrone.Core.Test.MetadataSourceTests
|
||||||
{
|
{
|
||||||
|
@ -18,6 +19,7 @@ namespace NzbDrone.Core.Test.MetadataSourceTests
|
||||||
var result = Subject.SearchForNewSeries(title);
|
var result = Subject.SearchForNewSeries(title);
|
||||||
|
|
||||||
result.Should().NotBeEmpty();
|
result.Should().NotBeEmpty();
|
||||||
|
|
||||||
result[0].Title.Should().Be(title);
|
result[0].Title.Should().Be(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,28 +36,51 @@ namespace NzbDrone.Core.Test.MetadataSourceTests
|
||||||
{
|
{
|
||||||
var details = Subject.GetSeriesInfo(75978);
|
var details = Subject.GetSeriesInfo(75978);
|
||||||
|
|
||||||
details.Should().NotBeNull();
|
ValidateSeries(details);
|
||||||
details.Images.Should().NotBeEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void none_unique_season_episode_number()
|
|
||||||
{
|
|
||||||
var result = Subject.GetEpisodeInfo(75978);//Family guy
|
|
||||||
|
|
||||||
result.GroupBy(e => e.SeasonNumber.ToString("000") + e.EpisodeNumber.ToString("000"))
|
|
||||||
.Max(e => e.Count()).Should().Be(1);
|
|
||||||
|
|
||||||
result.Select(c => c.TvDbEpisodeId).Should().OnlyHaveUniqueItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_be_able_to_get_list_of_episodes()
|
public void should_be_able_to_get_list_of_episodes()
|
||||||
{
|
{
|
||||||
var details = Subject.GetEpisodeInfo(75978);
|
var details = Subject.GetEpisodeInfo(75978);
|
||||||
|
|
||||||
details.Should().NotBeEmpty();
|
details.Should().NotBeEmpty();
|
||||||
|
|
||||||
|
details.GroupBy(e => e.SeasonNumber.ToString("000") + e.EpisodeNumber.ToString("000"))
|
||||||
|
.Max(e => e.Count()).Should().Be(1);
|
||||||
|
|
||||||
|
details.Select(c => c.TvDbEpisodeId).Should().OnlyHaveUniqueItems();
|
||||||
|
|
||||||
|
details.Should().Contain(c => c.SeasonNumber > 0);
|
||||||
|
details.Should().Contain(c => !string.IsNullOrWhiteSpace(c.Overview));
|
||||||
|
|
||||||
|
foreach (var episode in details)
|
||||||
|
{
|
||||||
|
episode.AirDate.Should().HaveValue();
|
||||||
|
episode.AirDate.Value.Kind.Should().Be(DateTimeKind.Utc);
|
||||||
|
episode.EpisodeNumber.Should().NotBe(0);
|
||||||
|
episode.Title.Should().NotBeBlank();
|
||||||
|
episode.TvDbEpisodeId.Should().NotBe(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void ValidateSeries(Series series)
|
||||||
|
{
|
||||||
|
series.Should().NotBeNull();
|
||||||
|
series.Title.Should().NotBeBlank();
|
||||||
|
series.Overview.Should().NotBeBlank();
|
||||||
|
series.AirTime.Should().NotBeBlank();
|
||||||
|
series.FirstAired.Should().HaveValue();
|
||||||
|
series.FirstAired.Value.Kind.Should().Be(DateTimeKind.Utc);
|
||||||
|
series.Images.Should().NotBeEmpty();
|
||||||
|
series.ImdbId.Should().NotBeBlank();
|
||||||
|
series.Network.Should().NotBeBlank();
|
||||||
|
series.Runtime.Should().BeGreaterThan(0);
|
||||||
|
series.TitleSlug.Should().NotBeBlank();
|
||||||
|
series.TvRageId.Should().BeGreaterThan(0);
|
||||||
|
series.TvdbId.Should().BeGreaterThan(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,6 @@ namespace NzbDrone.Core.Datastore.Migration
|
||||||
.WithColumn("Network").AsString().Nullable()
|
.WithColumn("Network").AsString().Nullable()
|
||||||
.WithColumn("CustomStartDate").AsDateTime().Nullable()
|
.WithColumn("CustomStartDate").AsDateTime().Nullable()
|
||||||
.WithColumn("UseSceneNumbering").AsBoolean()
|
.WithColumn("UseSceneNumbering").AsBoolean()
|
||||||
.WithColumn("UtcOffSet").AsInt32()
|
|
||||||
.WithColumn("FirstAired").AsDateTime().Nullable()
|
.WithColumn("FirstAired").AsDateTime().Nullable()
|
||||||
.WithColumn("NextAiring").AsDateTime().Nullable();
|
.WithColumn("NextAiring").AsDateTime().Nullable();
|
||||||
|
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
namespace NzbDrone.Core.MetadataSource.Trakt
|
|
||||||
{
|
|
||||||
public class Actor
|
|
||||||
{
|
|
||||||
public string name { get; set; }
|
|
||||||
public string character { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,4 @@
|
||||||
using System;
|
namespace NzbDrone.Core.MetadataSource.Trakt
|
||||||
|
|
||||||
namespace NzbDrone.Core.MetadataSource.Trakt
|
|
||||||
{
|
{
|
||||||
public class Episode
|
public class Episode
|
||||||
{
|
{
|
||||||
|
@ -10,9 +8,10 @@ namespace NzbDrone.Core.MetadataSource.Trakt
|
||||||
public int tvdb_id { get; set; }
|
public int tvdb_id { get; set; }
|
||||||
public string title { get; set; }
|
public string title { get; set; }
|
||||||
public string overview { get; set; }
|
public string overview { get; set; }
|
||||||
public DateTime? first_aired { get; set; }
|
public int first_aired { get; set; }
|
||||||
|
public string first_aired_iso { get; set; }
|
||||||
|
public int first_aired_utc { get; set; }
|
||||||
public string url { get; set; }
|
public string url { get; set; }
|
||||||
public string screen { get; set; }
|
public string screen { get; set; }
|
||||||
public Ratings ratings { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +0,0 @@
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.MetadataSource.Trakt
|
|
||||||
{
|
|
||||||
public class People
|
|
||||||
{
|
|
||||||
public List<Actor> actors { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
namespace NzbDrone.Core.MetadataSource.Trakt
|
|
||||||
{
|
|
||||||
public class Ratings
|
|
||||||
{
|
|
||||||
public int percentage { get; set; }
|
|
||||||
public int votes { get; set; }
|
|
||||||
public int loved { get; set; }
|
|
||||||
public int hated { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.MetadataSource.Trakt
|
namespace NzbDrone.Core.MetadataSource.Trakt
|
||||||
{
|
{
|
||||||
|
@ -8,14 +7,18 @@ namespace NzbDrone.Core.MetadataSource.Trakt
|
||||||
public string title { get; set; }
|
public string title { get; set; }
|
||||||
public int year { get; set; }
|
public int year { get; set; }
|
||||||
public string url { get; set; }
|
public string url { get; set; }
|
||||||
public DateTime? first_aired { get; set; }
|
public int first_aired { get; set; }
|
||||||
|
public string first_aired_iso { get; set; }
|
||||||
|
public int first_aired_utc { get; set; }
|
||||||
public string country { get; set; }
|
public string country { get; set; }
|
||||||
public string overview { get; set; }
|
public string overview { get; set; }
|
||||||
public int runtime { get; set; }
|
public int runtime { get; set; }
|
||||||
public string status { get; set; }
|
public string status { get; set; }
|
||||||
public string network { get; set; }
|
public string network { get; set; }
|
||||||
public string air_day { get; set; }
|
public string air_day { get; set; }
|
||||||
|
public string air_day_utc { get; set; }
|
||||||
public string air_time { get; set; }
|
public string air_time { get; set; }
|
||||||
|
public string air_time_utc { get; set; }
|
||||||
public string certification { get; set; }
|
public string certification { get; set; }
|
||||||
public string imdb_id { get; set; }
|
public string imdb_id { get; set; }
|
||||||
public int tvdb_id { get; set; }
|
public int tvdb_id { get; set; }
|
||||||
|
@ -23,11 +26,6 @@ namespace NzbDrone.Core.MetadataSource.Trakt
|
||||||
public int last_updated { get; set; }
|
public int last_updated { get; set; }
|
||||||
public string poster { get; set; }
|
public string poster { get; set; }
|
||||||
public Images images { get; set; }
|
public Images images { get; set; }
|
||||||
public List<TopWatcher> top_watchers { get; set; }
|
|
||||||
public List<TopEpisode> top_episodes { get; set; }
|
|
||||||
public Ratings ratings { get; set; }
|
|
||||||
public Stats stats { get; set; }
|
|
||||||
public People people { get; set; }
|
|
||||||
public List<string> genres { get; set; }
|
public List<string> genres { get; set; }
|
||||||
public List<Season> seasons { get; set; }
|
public List<Season> seasons { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
namespace NzbDrone.Core.MetadataSource.Trakt
|
|
||||||
{
|
|
||||||
public class Stats
|
|
||||||
{
|
|
||||||
public int watchers { get; set; }
|
|
||||||
public int plays { get; set; }
|
|
||||||
public int scrobbles { get; set; }
|
|
||||||
public int scrobbles_unique { get; set; }
|
|
||||||
public int checkins { get; set; }
|
|
||||||
public int checkins_unique { get; set; }
|
|
||||||
public int collection { get; set; }
|
|
||||||
public int collection_unique { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
namespace NzbDrone.Core.MetadataSource.Trakt
|
|
||||||
{
|
|
||||||
public class TopEpisode
|
|
||||||
{
|
|
||||||
public int plays { get; set; }
|
|
||||||
public int season { get; set; }
|
|
||||||
public int number { get; set; }
|
|
||||||
public string title { get; set; }
|
|
||||||
public string url { get; set; }
|
|
||||||
public int first_aired { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
namespace NzbDrone.Core.MetadataSource.Trakt
|
|
||||||
{
|
|
||||||
public class TopWatcher
|
|
||||||
{
|
|
||||||
public int plays { get; set; }
|
|
||||||
public string username { get; set; }
|
|
||||||
public bool @protected { get; set; }
|
|
||||||
public object full_name { get; set; }
|
|
||||||
public object gender { get; set; }
|
|
||||||
public string age { get; set; }
|
|
||||||
public object location { get; set; }
|
|
||||||
public object about { get; set; }
|
|
||||||
public int joined { get; set; }
|
|
||||||
public string avatar { get; set; }
|
|
||||||
public string url { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -52,11 +52,11 @@ namespace NzbDrone.Core.MetadataSource
|
||||||
series.TvRageId = show.tvrage_id;
|
series.TvRageId = show.tvrage_id;
|
||||||
series.ImdbId = show.imdb_id;
|
series.ImdbId = show.imdb_id;
|
||||||
series.Title = show.title;
|
series.Title = show.title;
|
||||||
series.FirstAired = show.first_aired;
|
series.FirstAired =FromEpoc(show.first_aired_utc);
|
||||||
series.Overview = show.overview;
|
series.Overview = show.overview;
|
||||||
series.Runtime = show.runtime;
|
series.Runtime = show.runtime;
|
||||||
series.Network = show.network;
|
series.Network = show.network;
|
||||||
series.AirTime = show.air_time;
|
series.AirTime = show.air_time_utc;
|
||||||
series.TitleSlug = show.url.ToLower().Replace("http://trakt.tv/show/", "");
|
series.TitleSlug = show.url.ToLower().Replace("http://trakt.tv/show/", "");
|
||||||
series.Status = GetSeriesStatus(show.status);
|
series.Status = GetSeriesStatus(show.status);
|
||||||
|
|
||||||
|
@ -75,14 +75,14 @@ namespace NzbDrone.Core.MetadataSource
|
||||||
episode.EpisodeNumber = traktEpisode.number;
|
episode.EpisodeNumber = traktEpisode.number;
|
||||||
episode.TvDbEpisodeId = traktEpisode.tvdb_id;
|
episode.TvDbEpisodeId = traktEpisode.tvdb_id;
|
||||||
episode.Title = traktEpisode.title;
|
episode.Title = traktEpisode.title;
|
||||||
episode.AirDate = traktEpisode.first_aired;
|
episode.AirDate =FromEpoc(traktEpisode.first_aired_utc);
|
||||||
|
|
||||||
return episode;
|
return episode;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetPosterThumbnailUrl(string posterUrl)
|
private static string GetPosterThumbnailUrl(string posterUrl)
|
||||||
{
|
{
|
||||||
if(posterUrl.Contains("poster-small.jpg")) return posterUrl;
|
if (posterUrl.Contains("poster-small.jpg")) return posterUrl;
|
||||||
|
|
||||||
var extension = Path.GetExtension(posterUrl);
|
var extension = Path.GetExtension(posterUrl);
|
||||||
var withoutExtension = posterUrl.Substring(0, posterUrl.Length - extension.Length);
|
var withoutExtension = posterUrl.Substring(0, posterUrl.Length - extension.Length);
|
||||||
|
@ -95,5 +95,12 @@ namespace NzbDrone.Core.MetadataSource
|
||||||
if (status.Equals("Ended", StringComparison.InvariantCultureIgnoreCase)) return SeriesStatusType.Ended;
|
if (status.Equals("Ended", StringComparison.InvariantCultureIgnoreCase)) return SeriesStatusType.Ended;
|
||||||
return SeriesStatusType.Continuing;
|
return SeriesStatusType.Continuing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static DateTime? FromEpoc(long ticks)
|
||||||
|
{
|
||||||
|
if (ticks == 0) return null;
|
||||||
|
|
||||||
|
return new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(ticks);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -304,16 +304,10 @@
|
||||||
<Compile Include="MetadataSource\IProvideSeriesInfo.cs" />
|
<Compile Include="MetadataSource\IProvideSeriesInfo.cs" />
|
||||||
<Compile Include="MetadataSource\ISearchForNewSeries.cs" />
|
<Compile Include="MetadataSource\ISearchForNewSeries.cs" />
|
||||||
<Compile Include="MetadataSource\TraktProxy.cs" />
|
<Compile Include="MetadataSource\TraktProxy.cs" />
|
||||||
<Compile Include="MetadataSource\Trakt\Actor.cs" />
|
|
||||||
<Compile Include="MetadataSource\Trakt\Episode.cs" />
|
<Compile Include="MetadataSource\Trakt\Episode.cs" />
|
||||||
<Compile Include="MetadataSource\Trakt\Images.cs" />
|
<Compile Include="MetadataSource\Trakt\Images.cs" />
|
||||||
<Compile Include="MetadataSource\Trakt\People.cs" />
|
|
||||||
<Compile Include="MetadataSource\Trakt\Ratings.cs" />
|
|
||||||
<Compile Include="MetadataSource\Trakt\Season.cs" />
|
<Compile Include="MetadataSource\Trakt\Season.cs" />
|
||||||
<Compile Include="MetadataSource\Trakt\Show.cs" />
|
<Compile Include="MetadataSource\Trakt\Show.cs" />
|
||||||
<Compile Include="MetadataSource\Trakt\Stats.cs" />
|
|
||||||
<Compile Include="MetadataSource\Trakt\TopEpisode.cs" />
|
|
||||||
<Compile Include="MetadataSource\Trakt\TopWatcher.cs" />
|
|
||||||
<Compile Include="Organizer\EpisodeSortingType.cs" />
|
<Compile Include="Organizer\EpisodeSortingType.cs" />
|
||||||
<Compile Include="Organizer\FileNameBuilder.cs" />
|
<Compile Include="Organizer\FileNameBuilder.cs" />
|
||||||
<Compile Include="Instrumentation\LogService.cs" />
|
<Compile Include="Instrumentation\LogService.cs" />
|
||||||
|
|
|
@ -44,17 +44,6 @@ namespace NzbDrone.Core.Tv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime? EndTime
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (!AirDate.HasValue) return null;
|
|
||||||
if (Series == null) return null;
|
|
||||||
|
|
||||||
return AirDate.Value.AddMinutes(Series.Runtime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String SeriesTitle { get; private set; }
|
public String SeriesTitle { get; private set; }
|
||||||
|
|
||||||
public Series Series { get; set; }
|
public Series Series { get; set; }
|
||||||
|
|
|
@ -172,17 +172,10 @@ namespace NzbDrone.Core.Tv
|
||||||
episodeToUpdate.TvDbEpisodeId = episode.TvDbEpisodeId;
|
episodeToUpdate.TvDbEpisodeId = episode.TvDbEpisodeId;
|
||||||
episodeToUpdate.EpisodeNumber = episode.EpisodeNumber;
|
episodeToUpdate.EpisodeNumber = episode.EpisodeNumber;
|
||||||
episodeToUpdate.SeasonNumber = episode.SeasonNumber;
|
episodeToUpdate.SeasonNumber = episode.SeasonNumber;
|
||||||
episodeToUpdate.AbsoluteEpisodeNumber = episode.AbsoluteEpisodeNumber;
|
|
||||||
episodeToUpdate.Title = episode.Title;
|
episodeToUpdate.Title = episode.Title;
|
||||||
episodeToUpdate.Overview = episode.Overview;
|
episodeToUpdate.Overview = episode.Overview;
|
||||||
episodeToUpdate.AirDate = episode.AirDate;
|
episodeToUpdate.AirDate = episode.AirDate;
|
||||||
|
|
||||||
if (!String.IsNullOrWhiteSpace(series.AirTime) && episodeToUpdate.AirDate.HasValue)
|
|
||||||
{
|
|
||||||
episodeToUpdate.AirDate = episodeToUpdate.AirDate.Value.Add(Convert.ToDateTime(series.AirTime).TimeOfDay)
|
|
||||||
.AddHours(series.UtcOffset * -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
successCount++;
|
successCount++;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
|
@ -55,11 +55,7 @@ namespace NzbDrone.Core.Tv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Todo: This should be a double since there are timezones that aren't on a full hour offset
|
|
||||||
public int UtcOffset { get; set; }
|
|
||||||
|
|
||||||
public DateTime? FirstAired { get; set; }
|
public DateTime? FirstAired { get; set; }
|
||||||
public LazyLoaded<QualityProfile> QualityProfile { get; set; }
|
public LazyLoaded<QualityProfile> QualityProfile { get; set; }
|
||||||
public DateTime? NextAiring { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue