* Update Torrent and Usenet DownloadStation

* Update Download Tests

* Fix TorrentPotato not finding results #754

* Update UpdateMediaInfoService and Tests #572

* Ignore plex otimized versions w/ tests #391

* Remove Xem Serivce files and tests #386

* Ignore TV Episode from IMDb lists
Devin Buhl 8 years ago committed by GitHub
parent bab7bd20cd
commit 50fdbd896c

@ -1,312 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.DataAugmentation.Xem;
using NzbDrone.Core.DataAugmentation.Xem.Model;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Tv.Events;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.DataAugmentation.SceneNumbering
{
[TestFixture]
public class XemServiceFixture : CoreTest<XemService>
{
private Series _series;
private List<int> _theXemSeriesIds;
private List<XemSceneTvdbMapping> _theXemTvdbMappings;
private List<Episode> _episodes;
[SetUp]
public void SetUp()
{
_series = Builder<Series>.CreateNew()
.With(v => v.TvdbId = 10)
.With(v => v.UseSceneNumbering = false)
.BuildNew();
_theXemSeriesIds = new List<int> { 120 };
Mocker.GetMock<IXemProxy>()
.Setup(v => v.GetXemSeriesIds())
.Returns(_theXemSeriesIds);
_theXemTvdbMappings = new List<XemSceneTvdbMapping>();
Mocker.GetMock<IXemProxy>()
.Setup(v => v.GetSceneTvdbMappings(10))
.Returns(_theXemTvdbMappings);
_episodes = new List<Episode>();
_episodes.Add(new Episode { SeasonNumber = 1, EpisodeNumber = 1 });
_episodes.Add(new Episode { SeasonNumber = 1, EpisodeNumber = 2 });
_episodes.Add(new Episode { SeasonNumber = 2, EpisodeNumber = 1 });
_episodes.Add(new Episode { SeasonNumber = 2, EpisodeNumber = 2 });
_episodes.Add(new Episode { SeasonNumber = 2, EpisodeNumber = 3 });
_episodes.Add(new Episode { SeasonNumber = 2, EpisodeNumber = 4 });
_episodes.Add(new Episode { SeasonNumber = 2, EpisodeNumber = 5 });
_episodes.Add(new Episode { SeasonNumber = 3, EpisodeNumber = 1 });
_episodes.Add(new Episode { SeasonNumber = 3, EpisodeNumber = 2 });
Mocker.GetMock<IEpisodeService>()
.Setup(v => v.GetEpisodeBySeries(It.IsAny<int>()))
.Returns(_episodes);
}
private void GivenTvdbMappings()
{
_theXemSeriesIds.Add(10);
AddTvdbMapping(1, 1, 1, 1, 1, 1); // 1x01 -> 1x01
AddTvdbMapping(2, 1, 2, 2, 1, 2); // 1x02 -> 1x02
AddTvdbMapping(3, 2, 1, 3, 2, 1); // 2x01 -> 2x01
AddTvdbMapping(4, 2, 2, 4, 2, 2); // 2x02 -> 2x02
AddTvdbMapping(5, 2, 3, 5, 2, 3); // 2x03 -> 2x03
AddTvdbMapping(6, 3, 1, 6, 2, 4); // 3x01 -> 2x04
AddTvdbMapping(7, 3, 2, 7, 2, 5); // 3x02 -> 2x05
}
private void GivenExistingMapping()
{
_series.UseSceneNumbering = true;
_episodes[0].SceneSeasonNumber = 1;
_episodes[0].SceneEpisodeNumber = 1;
_episodes[1].SceneSeasonNumber = 1;
_episodes[1].SceneEpisodeNumber = 2;
_episodes[2].SceneSeasonNumber = 2;
_episodes[2].SceneEpisodeNumber = 1;
_episodes[3].SceneSeasonNumber = 2;
_episodes[3].SceneEpisodeNumber = 2;
_episodes[4].SceneSeasonNumber = 2;
_episodes[4].SceneEpisodeNumber = 3;
_episodes[5].SceneSeasonNumber = 3;
_episodes[5].SceneEpisodeNumber = 1;
_episodes[6].SceneSeasonNumber = 3;
_episodes[6].SceneEpisodeNumber = 1;
}
private void AddTvdbMapping(int sceneAbsolute, int sceneSeason, int sceneEpisode, int tvdbAbsolute, int tvdbSeason, int tvdbEpisode)
{
_theXemTvdbMappings.Add(new XemSceneTvdbMapping
{
Scene = new XemValues { Absolute = sceneAbsolute, Season = sceneSeason, Episode = sceneEpisode },
Tvdb = new XemValues { Absolute = tvdbAbsolute, Season = tvdbSeason, Episode = tvdbEpisode },
});
}
[Test]
public void should_not_fetch_scenenumbering_if_not_listed()
{
Subject.Handle(new SeriesUpdatedEvent(_series));
Mocker.GetMock<IXemProxy>()
.Verify(v => v.GetSceneTvdbMappings(10), Times.Never());
Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.IsAny<Series>()), Times.Never());
}
[Test]
public void should_fetch_scenenumbering()
{
GivenTvdbMappings();
Subject.Handle(new SeriesUpdatedEvent(_series));
Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.Is<Series>(s => s.UseSceneNumbering == true)), Times.Once());
}
[Test]
public void should_clear_scenenumbering_if_removed_from_thexem()
{
GivenExistingMapping();
Subject.Handle(new SeriesUpdatedEvent(_series));
Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.IsAny<Series>()), Times.Once());
}
[Test]
public void should_not_clear_scenenumbering_if_no_results_at_all_from_thexem()
{
GivenExistingMapping();
_theXemSeriesIds.Clear();
Subject.Handle(new SeriesUpdatedEvent(_series));
Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.IsAny<Series>()), Times.Never());
ExceptionVerification.ExpectedWarns(1);
}
[Test]
public void should_not_clear_scenenumbering_if_thexem_throws()
{
GivenExistingMapping();
Mocker.GetMock<IXemProxy>()
.Setup(v => v.GetXemSeriesIds())
.Throws(new InvalidOperationException());
Subject.Handle(new SeriesUpdatedEvent(_series));
Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.IsAny<Series>()), Times.Never());
ExceptionVerification.ExpectedWarns(1);
}
[Test]
public void should_flag_unknown_future_episodes_if_existing_season_is_mapped()
{
GivenTvdbMappings();
_theXemTvdbMappings.RemoveAll(v => v.Tvdb.Season == 2 && v.Tvdb.Episode == 5);
Subject.Handle(new SeriesUpdatedEvent(_series));
var episode = _episodes.First(v => v.SeasonNumber == 2 && v.EpisodeNumber == 5);
episode.UnverifiedSceneNumbering.Should().BeTrue();
}
[Test]
public void should_flag_unknown_future_season_if_future_season_is_shifted()
{
GivenTvdbMappings();
Subject.Handle(new SeriesUpdatedEvent(_series));
var episode = _episodes.First(v => v.SeasonNumber == 3 && v.EpisodeNumber == 1);
episode.UnverifiedSceneNumbering.Should().BeTrue();
}
[Test]
public void should_not_flag_unknown_future_season_if_future_season_is_not_shifted()
{
GivenTvdbMappings();
_theXemTvdbMappings.RemoveAll(v => v.Scene.Season == 3);
Subject.Handle(new SeriesUpdatedEvent(_series));
var episode = _episodes.First(v => v.SeasonNumber == 3 && v.EpisodeNumber == 1);
episode.UnverifiedSceneNumbering.Should().BeFalse();
}
[Test]
public void should_not_flag_past_episodes_if_not_causing_overlaps()
{
GivenTvdbMappings();
_theXemTvdbMappings.RemoveAll(v => v.Scene.Season == 2);
Subject.Handle(new SeriesUpdatedEvent(_series));
var episode = _episodes.First(v => v.SeasonNumber == 2 && v.EpisodeNumber == 1);
episode.UnverifiedSceneNumbering.Should().BeFalse();
}
[Test]
public void should_flag_past_episodes_if_causing_overlap()
{
GivenTvdbMappings();
_theXemTvdbMappings.RemoveAll(v => v.Scene.Season == 2 && v.Tvdb.Episode <= 1);
_theXemTvdbMappings.First(v => v.Scene.Season == 2 && v.Scene.Episode == 2).Scene.Episode = 1;
Subject.Handle(new SeriesUpdatedEvent(_series));
var episode = _episodes.First(v => v.SeasonNumber == 2 && v.EpisodeNumber == 1);
episode.UnverifiedSceneNumbering.Should().BeTrue();
}
[Test]
public void should_not_extrapolate_season_with_specials()
{
GivenTvdbMappings();
var specialMapping = _theXemTvdbMappings.First(v => v.Tvdb.Season == 2 && v.Tvdb.Episode == 5);
specialMapping.Tvdb.Season = 0;
specialMapping.Tvdb.Episode = 1;
Subject.Handle(new SeriesUpdatedEvent(_series));
var episode = _episodes.First(v => v.SeasonNumber == 2 && v.EpisodeNumber == 5);
episode.UnverifiedSceneNumbering.Should().BeTrue();
episode.SceneSeasonNumber.Should().NotHaveValue();
episode.SceneEpisodeNumber.Should().NotHaveValue();
}
[Test]
public void should_extrapolate_season_with_future_episodes()
{
GivenTvdbMappings();
_theXemTvdbMappings.RemoveAll(v => v.Tvdb.Season == 2 && v.Tvdb.Episode == 5);
Subject.Handle(new SeriesUpdatedEvent(_series));
var episode = _episodes.First(v => v.SeasonNumber == 2 && v.EpisodeNumber == 5);
episode.UnverifiedSceneNumbering.Should().BeTrue();
episode.SceneSeasonNumber.Should().Be(3);
episode.SceneEpisodeNumber.Should().Be(2);
}
[Test]
public void should_extrapolate_season_with_shifted_episodes()
{
GivenTvdbMappings();
_theXemTvdbMappings.RemoveAll(v => v.Tvdb.Season == 2 && v.Tvdb.Episode == 5);
var dualMapping = _theXemTvdbMappings.First(v => v.Tvdb.Season == 2 && v.Tvdb.Episode == 4);
dualMapping.Scene.Season = 2;
dualMapping.Scene.Episode = 3;
Subject.Handle(new SeriesUpdatedEvent(_series));
var episode = _episodes.First(v => v.SeasonNumber == 2 && v.EpisodeNumber == 5);
episode.UnverifiedSceneNumbering.Should().BeTrue();
episode.SceneSeasonNumber.Should().Be(2);
episode.SceneEpisodeNumber.Should().Be(4);
}
[Test]
public void should_extrapolate_shifted_future_seasons()
{
GivenTvdbMappings();
Subject.Handle(new SeriesUpdatedEvent(_series));
var episode = _episodes.First(v => v.SeasonNumber == 3 && v.EpisodeNumber == 2);
episode.UnverifiedSceneNumbering.Should().BeTrue();
episode.SceneSeasonNumber.Should().Be(4);
episode.SceneEpisodeNumber.Should().Be(2);
}
[Test]
public void should_not_extrapolate_matching_future_seasons()
{
GivenTvdbMappings();
_theXemTvdbMappings.RemoveAll(v => v.Scene.Season != 1);
Subject.Handle(new SeriesUpdatedEvent(_series));
var episode = _episodes.First(v => v.SeasonNumber == 3 && v.EpisodeNumber == 2);
episode.UnverifiedSceneNumbering.Should().BeFalse();
episode.SceneSeasonNumber.Should().NotHaveValue();
episode.SceneEpisodeNumber.Should().NotHaveValue();
}
}
}

@ -74,9 +74,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
.Returns(1000000);
}
protected override RemoteEpisode CreateRemoteEpisode()
protected override RemoteMovie CreateRemoteMovie()
{
var remoteEpisode = base.CreateRemoteEpisode();
var remoteEpisode = base.CreateRemoteMovie();
var torrentInfo = new TorrentInfo();
torrentInfo.Title = remoteEpisode.Release.Title;
@ -125,7 +125,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
[Test]
public void Download_should_download_file_if_it_doesnt_exist()
{
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
Subject.Download(remoteEpisode);
@ -139,7 +139,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
{
Subject.Definition.Settings.As<TorrentBlackholeSettings>().SaveMagnetFiles = true;
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
remoteEpisode.Release.DownloadUrl = null;
Subject.Download(remoteEpisode);
@ -153,7 +153,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
[Test]
public void Download_should_not_save_magnet_if_disabled()
{
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
remoteEpisode.Release.DownloadUrl = null;
Assert.Throws<ReleaseDownloadException>(() => Subject.Download(remoteEpisode));
@ -169,7 +169,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
{
Subject.Definition.Settings.As<TorrentBlackholeSettings>().SaveMagnetFiles = true;
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
Subject.Download(remoteEpisode);
@ -185,7 +185,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
var illegalTitle = "Saturday Night Live - S38E08 - Jeremy Renner/Maroon 5 [SDTV]";
var expectedFilename = Path.Combine(_blackholeFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV]" + Path.GetExtension(_filePath));
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
remoteEpisode.Release.Title = illegalTitle;
Subject.Download(remoteEpisode);
@ -198,7 +198,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
[Test]
public void Download_should_throw_if_magnet_and_torrent_url_does_not_exist()
{
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
remoteEpisode.Release.DownloadUrl = null;
Assert.Throws<ReleaseDownloadException>(() => Subject.Download(remoteEpisode));
@ -273,7 +273,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
[Test]
public void should_return_null_hash()
{
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
Subject.Download(remoteEpisode).Should().BeNull();
}

@ -104,7 +104,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
[Test]
public void Download_should_download_file_if_it_doesnt_exist()
{
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
Subject.Download(remoteEpisode);
@ -119,7 +119,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
var illegalTitle = "Saturday Night Live - S38E08 - Jeremy Renner/Maroon 5 [SDTV]";
var expectedFilename = Path.Combine(_blackholeFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV]" + Path.GetExtension(_filePath));
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
remoteEpisode.Release.Title = illegalTitle;
Subject.Download(remoteEpisode);

@ -196,7 +196,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
{
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -208,7 +208,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
{
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
remoteEpisode.Release.DownloadUrl = magnetUrl;
var id = Subject.Download(remoteEpisode);

@ -30,8 +30,8 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
.Returns(30);
Mocker.GetMock<IParsingService>()
.Setup(s => s.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>(), It.IsAny<int>(), (SearchCriteriaBase)null))
.Returns(() => CreateRemoteEpisode());
.Setup(s => s.Map(It.IsAny<ParsedMovieInfo>(), It.IsAny<string>(), (SearchCriteriaBase)null))
.Returns(() => CreateRemoteMovie());
Mocker.GetMock<IHttpClient>()
.Setup(s => s.Get(It.IsAny<HttpRequest>()))
@ -42,20 +42,20 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
.Returns<string, OsPath>((h, r) => r);
}
protected virtual RemoteEpisode CreateRemoteEpisode()
protected virtual RemoteMovie CreateRemoteMovie()
{
var remoteEpisode = new RemoteEpisode();
var remoteEpisode = new RemoteMovie();
remoteEpisode.Release = new ReleaseInfo();
remoteEpisode.Release.Title = _title;
remoteEpisode.Release.DownloadUrl = _downloadUrl;
remoteEpisode.Release.DownloadProtocol = Subject.Protocol;
remoteEpisode.ParsedEpisodeInfo = new ParsedEpisodeInfo();
remoteEpisode.ParsedEpisodeInfo.FullSeason = false;
remoteEpisode.ParsedMovieInfo = new ParsedMovieInfo();
//remoteEpisode.ParsedEpisodeInfo.FullSeason = false;
remoteEpisode.Episodes = new List<Episode>();
//remoteEpisode.Episodes = new List<Episode>();
remoteEpisode.Series = new Series();
remoteEpisode.Movie = new Movie();
return remoteEpisode;
}

@ -339,9 +339,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
.Callback(PrepareClientToReturnQueuedItem);
}
protected override RemoteEpisode CreateRemoteEpisode()
protected override RemoteMovie CreateRemoteMovie()
{
var episode = base.CreateRemoteEpisode();
var episode = base.CreateRemoteMovie();
episode.Release.DownloadUrl = DownloadURL;
@ -366,7 +366,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
GivenTvDirectory();
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -383,7 +383,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
GivenTvCategory();
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -399,7 +399,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
GivenSerialNumber();
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -474,7 +474,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
[Test]
public void Download_should_throw_and_not_add_task_if_cannot_get_serial_number()
{
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
Mocker.GetMock<ISerialNumberProvider>()
.Setup(s => s.GetSerialNumber(_settings))

@ -33,14 +33,14 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
protected string _defaultDestination = "somepath";
protected OsPath _physicalPath = new OsPath("/mnt/sdb1/mydata");
protected RemoteEpisode _remoteEpisode;
protected RemoteMovie _remoteEpisode;
protected Dictionary<string, object> _downloadStationConfigItems;
[SetUp]
public void Setup()
{
_remoteEpisode = CreateRemoteEpisode();
_remoteEpisode = CreateRemoteMovie();
_settings = new DownloadStationSettings()
{
@ -254,7 +254,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
GivenTvDirectory();
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -271,7 +271,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
GivenTvCategory();
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -287,7 +287,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
GivenSerialNumber();
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -362,7 +362,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
[Test]
public void Download_should_throw_and_not_add_task_if_cannot_get_serial_number()
{
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
Mocker.GetMock<ISerialNumberProvider>()
.Setup(s => s.GetSerialNumber(_settings))

@ -197,7 +197,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.HadoukenTests
{
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -276,7 +276,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.HadoukenTests
[Test]
public void Download_from_magnet_link_should_return_hash_uppercase()
{
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
remoteEpisode.Release.DownloadUrl = "magnet:?xt=urn:btih:a45129e59d8750f9da982f53552b1e4f0457ee9f";
@ -291,7 +291,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.HadoukenTests
[Test]
public void Download_from_torrent_file_should_return_hash_uppercase()
{
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
Mocker.GetMock<IHadoukenProxy>()
.Setup(v => v.AddTorrentFile(It.IsAny<HadoukenSettings>(), It.IsAny<byte[]>()))

@ -189,7 +189,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbVortexTests
{
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -201,7 +201,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbVortexTests
{
GivenFailedDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
Assert.Throws<DownloadClientException>(() => Subject.Download(remoteEpisode));
}

@ -303,7 +303,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests
{
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -315,7 +315,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests
{
GivenFailedDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
Assert.Throws<DownloadClientException>(() => Subject.Download(remoteEpisode));
}

@ -245,7 +245,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
{
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -257,7 +257,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
{
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
remoteEpisode.Release.DownloadUrl = magnetUrl;
var id = Subject.Download(remoteEpisode);
@ -290,7 +290,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
GivenRedirectToMagnet();
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -303,7 +303,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
GivenRedirectToTorrent();
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);

@ -116,7 +116,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.RTorrentTests
{
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);

@ -260,7 +260,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
{
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
remoteEpisode.Release.Title = title;
var id = Subject.Download(remoteEpisode);
@ -274,7 +274,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
{
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -315,12 +315,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
.Setup(s => s.DownloadNzb(It.IsAny<byte[]>(), It.IsAny<string>(), It.IsAny<string>(), (int)SabnzbdPriority.High, It.IsAny<SabnzbdSettings>()))
.Returns(new SabnzbdAddResponse());
var remoteEpisode = CreateRemoteEpisode();
remoteEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
.All()
.With(e => e.AirDate = DateTime.Today.ToString(Episode.AIR_DATE_FORMAT))
.Build()
.ToList();
var remoteEpisode = CreateRemoteMovie();
//remoteEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
// .All()
// .With(e => e.AirDate = DateTime.Today.ToString(Episode.AIR_DATE_FORMAT))
// .Build()
// .ToList();
Subject.Download(remoteEpisode);

@ -55,7 +55,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
{
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -68,7 +68,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
GivenTvDirectory();
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -84,7 +84,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
GivenTvCategory();
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -102,7 +102,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
_transmissionConfigItems["download-dir"] += "/";
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -117,7 +117,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
{
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -132,7 +132,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
{
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
remoteEpisode.Release.DownloadUrl = magnetUrl;
var id = Subject.Download(remoteEpisode);

@ -229,7 +229,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests
{
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -253,7 +253,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests
{
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
remoteEpisode.Release.DownloadUrl = magnetUrl;
var id = Subject.Download(remoteEpisode);
@ -351,7 +351,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests
GivenRedirectToMagnet();
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -364,7 +364,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests
GivenRedirectToTorrent();
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);

@ -57,7 +57,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests
{
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -70,7 +70,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests
GivenTvDirectory();
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -86,7 +86,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests
GivenTvCategory();
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -104,7 +104,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests
_transmissionConfigItems["download-dir"] += "/";
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -119,7 +119,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests
{
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
var id = Subject.Download(remoteEpisode);
@ -134,7 +134,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests
{
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var remoteEpisode = CreateRemoteMovie();
remoteEpisode.Release.DownloadUrl = magnetUrl;
var id = Subject.Download(remoteEpisode);

@ -1,7 +0,0 @@
{
"result": "failure",
"data": [ ],
"message": "no show with the tvdb_id 79488 found"
}

@ -1,10 +0,0 @@
{
"result": "success",
"data": [
"73141",
"79886",
],
"message": ""
}

@ -1,32 +0,0 @@
{
"result": "success",
"data": [
{
"scene": {
"season": 1,
"episode": 1,
"absolute": 1
},
"tvdb": {
"season": 1,
"episode": 1,
"absolute": 1
}
},
{
"scene": {
"season": 1,
"episode": 2,
"absolute": 2
},
"tvdb": {
"season": 1,
"episode": 2,
"absolute": 2
}
}
],
"message": "full mapping for 73388 on tvdb. this was a cached version"
}

@ -1,24 +0,0 @@
{
"result": "success",
"data": {
"220571": [
"Is This a Zombie? Of the Dead",
"Kore wa Zombie Desuka?",
"Kore wa Zombie Desuka? Of the Dead",
"Kore wa Zombie Desuka Of the Dead",
"Kore wa Zombie Desu ka - Of the Dead",
"Kore wa Zombie Desu ka of the Dead"
],
"79151": [
"Fate Stay Night",
"Fate/Zero",
"Fate Zero",
"Fate/Zero (2012)",
"Fate Zero S2",
"Fate Zero"
]
},
"message": ""
}

@ -16,12 +16,12 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
[TestFixture]
public class UpdateMediaInfoServiceFixture : CoreTest<UpdateMediaInfoService>
{
private Series _series;
private Movie _series;
[SetUp]
public void Setup()
{
_series = new Series
_series = new Movie
{
Id = 1,
Path = @"C:\series".AsOsAgnostic()
@ -56,7 +56,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
[Test]
public void should_skip_up_to_date_media_info()
{
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(3)
var episodeFiles = Builder<MovieFile>.CreateListOfSize(3)
.All()
.With(v => v.RelativePath = "media.mkv")
.TheFirst(1)
@ -64,25 +64,25 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
.BuildList();
Mocker.GetMock<IMediaFileService>()
.Setup(v => v.GetFilesBySeries(1))
.Setup(v => v.GetFilesByMovie(1))
.Returns(episodeFiles);
GivenFileExists();
GivenSuccessfulScan();
Subject.Handle(new SeriesScannedEvent(_series));
Subject.Handle(new MovieScannedEvent(_series));
Mocker.GetMock<IVideoFileInfoReader>()
.Verify(v => v.GetMediaInfo(Path.Combine(_series.Path, "media.mkv")), Times.Exactly(2));
Mocker.GetMock<IMediaFileService>()
.Verify(v => v.Update(It.IsAny<EpisodeFile>()), Times.Exactly(2));
.Verify(v => v.Update(It.IsAny<MovieFile>()), Times.Exactly(2));
}
[Test]
public void should_update_outdated_media_info()
{
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(3)
var episodeFiles = Builder<MovieFile>.CreateListOfSize(3)
.All()
.With(v => v.RelativePath = "media.mkv")
.TheFirst(1)
@ -90,48 +90,48 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
.BuildList();
Mocker.GetMock<IMediaFileService>()
.Setup(v => v.GetFilesBySeries(1))
.Setup(v => v.GetFilesByMovie(1))
.Returns(episodeFiles);
GivenFileExists();
GivenSuccessfulScan();
Subject.Handle(new SeriesScannedEvent(_series));
Subject.Handle(new MovieScannedEvent(_series));
Mocker.GetMock<IVideoFileInfoReader>()
.Verify(v => v.GetMediaInfo(Path.Combine(_series.Path, "media.mkv")), Times.Exactly(3));
Mocker.GetMock<IMediaFileService>()
.Verify(v => v.Update(It.IsAny<EpisodeFile>()), Times.Exactly(3));
.Verify(v => v.Update(It.IsAny<MovieFile>()), Times.Exactly(3));
}
[Test]
public void should_ignore_missing_files()
{
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(2)
var episodeFiles = Builder<MovieFile>.CreateListOfSize(2)
.All()
.With(v => v.RelativePath = "media.mkv")
.BuildList();
Mocker.GetMock<IMediaFileService>()
.Setup(v => v.GetFilesBySeries(1))
.Setup(v => v.GetFilesByMovie(1))
.Returns(episodeFiles);
GivenSuccessfulScan();
Subject.Handle(new SeriesScannedEvent(_series));
Subject.Handle(new MovieScannedEvent(_series));
Mocker.GetMock<IVideoFileInfoReader>()
.Verify(v => v.GetMediaInfo("media.mkv"), Times.Never());
Mocker.GetMock<IMediaFileService>()
.Verify(v => v.Update(It.IsAny<EpisodeFile>()), Times.Never());
.Verify(v => v.Update(It.IsAny<MovieFile>()), Times.Never());
}
[Test]
public void should_continue_after_failure()
{
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(2)
var episodeFiles = Builder<MovieFile>.CreateListOfSize(2)
.All()
.With(v => v.RelativePath = "media.mkv")
.TheFirst(1)
@ -139,20 +139,20 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
.BuildList();
Mocker.GetMock<IMediaFileService>()
.Setup(v => v.GetFilesBySeries(1))
.Setup(v => v.GetFilesByMovie(1))
.Returns(episodeFiles);
GivenFileExists();
GivenSuccessfulScan();
GivenFailedScan(Path.Combine(_series.Path, "media2.mkv"));
Subject.Handle(new SeriesScannedEvent(_series));
Subject.Handle(new MovieScannedEvent(_series));
Mocker.GetMock<IVideoFileInfoReader>()
.Verify(v => v.GetMediaInfo(Path.Combine(_series.Path, "media.mkv")), Times.Exactly(1));
Mocker.GetMock<IMediaFileService>()
.Verify(v => v.Update(It.IsAny<EpisodeFile>()), Times.Exactly(1));
.Verify(v => v.Update(It.IsAny<MovieFile>()), Times.Exactly(1));
}
}
}

@ -113,7 +113,6 @@
<Compile Include="Blacklisting\BlacklistServiceFixture.cs" />
<Compile Include="Configuration\ConfigCachingFixture.cs" />
<Compile Include="Configuration\ConfigServiceFixture.cs" />
<Compile Include="DataAugmentation\SceneNumbering\XemServiceFixture.cs" />
<Compile Include="DataAugmentation\Scene\SceneMappingProxyFixture.cs" />
<Compile Include="DataAugmentation\Scene\SceneMappingServiceFixture.cs" />
<Compile Include="DataAugmentation\DailySeries\DailySeriesDataProxyFixture.cs" />
@ -349,7 +348,6 @@
<Compile Include="Profiles\ProfileRepositoryFixture.cs" />
<Compile Include="Profiles\ProfileServiceFixture.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Providers\XemProxyFixture.cs" />
<Compile Include="ProviderTests\DiskProviderTests\ArchiveProviderFixture.cs" />
<Compile Include="ProviderTests\DiskScanProviderTests\GetVideoFilesFixture.cs" />
<Compile Include="ProviderTests\RecycleBinProviderTests\CleanupFixture.cs" />
@ -561,23 +559,12 @@
<None Include="Files\TestArchive.zip">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Content Include="Files\Xem\Failure.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Files\Xem\Ids.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Files\Xem\Mappings.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Files\Xem\Names.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="DataAugmentation\SceneNumbering\" />
<Folder Include="Providers\" />
<Folder Include="ProviderTests\UpdateProviderTests\" />
<Folder Include="BulkImport\" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />

@ -1,39 +1,47 @@
using System.IO;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common.Disk;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
{
public class GetVideoFilesFixture : CoreTest<DiskScanService>
{
private string[] _files;
private string[] _fileNames;
[SetUp]
public void Setup()
{
_files = new[]
_fileNames = new[]
{
@"C:\Test\30 Rock1.mkv",
@"C:\Test\30 Rock2.avi",
@"C:\Test\30 Rock3.MP4",
@"C:\Test\30 Rock4.wMv",
@"C:\Test\movie.exe",
@"C:\Test\movie"
@"30 Rock1.mkv",
@"30 Rock2.avi",
@"30 Rock3.MP4",
@"30 Rock4.wMv",
@"movie.exe",
@"movie"
};
}
GivenFiles();
private IEnumerable<string> GetFiles(string folder, string subFolder = "")
{
return _fileNames.Select(f => Path.Combine(folder, subFolder, f));
}
private void GivenFiles()
private void GivenFiles(IEnumerable<string> files)
{
var filesToReturn = files.ToArray();
Mocker.GetMock<IDiskProvider>()
.Setup(s => s.GetFiles(It.IsAny<string>(), SearchOption.AllDirectories))
.Returns(_files);
.Setup(s => s.GetFiles(It.IsAny<string>(), SearchOption.AllDirectories))
.Returns(filesToReturn);
}
[Test]
@ -73,8 +81,31 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
public void should_return_video_files_only()
{
var path = @"C:\Test\";
GivenFiles(GetFiles(path));
Subject.GetVideoFiles(path).Should().HaveCount(4);
}
[TestCase("Extras")]
[TestCase("@eadir")]
[TestCase("extrafanart")]
[TestCase("Plex Versions")]
[TestCase(".secret")]
[TestCase(".hidden")]
public void should_filter_certain_sub_folders(string subFolder)
{
var path = @"C:\Test\";
var files = GetFiles(path).ToList();
var specialFiles = GetFiles(path, subFolder).ToList();
var allFiles = files.Concat(specialFiles);
var series = Builder<Series>.CreateNew()
.With(s => s.Path = path)
.Build();
var filteredFiles = Subject.FilterFiles(series, allFiles);
filteredFiles.Should().NotContain(specialFiles);
filteredFiles.Count.Should().BeGreaterThan(0);
}
}
}
}

@ -1,54 +0,0 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.DataAugmentation.Xem;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.Categories;
namespace NzbDrone.Core.Test.Providers
{
[TestFixture]
[IntegrationTest]
public class XemProxyFixture : CoreTest<XemProxy>
{
[SetUp]
public void Setup()
{
UseRealHttp();
}
[Test]
public void get_series_ids()
{
var ids = Subject.GetXemSeriesIds();
ids.Should().NotBeEmpty();
ids.Should().Contain(i => i == 73141);
}
[TestCase(12345, Description = "invalid id")]
[TestCase(279042, Description = "no single connection")]
public void should_return_empty_when_known_error(int id)
{
Subject.GetSceneTvdbMappings(id).Should().BeEmpty();
}
[TestCase(82807)]
[TestCase(73141, Description = "American Dad!")]
public void should_get_mapping(int seriesId)
{
var result = Subject.GetSceneTvdbMappings(seriesId);
result.Should().NotBeEmpty();
result.Should().OnlyContain(c => c.Scene != null);
result.Should().OnlyContain(c => c.Tvdb != null);
}
[TestCase(78916)]
public void should_filter_out_episodes_without_scene_mapping(int seriesId)
{
var result = Subject.GetSceneTvdbMappings(seriesId);
result.Should().NotContain(c => c.Tvdb == null);
}
}
}

@ -1,12 +1,16 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common.Disk;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.RootFolders;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.RootFolderTests
@ -103,5 +107,48 @@ namespace NzbDrone.Core.Test.RootFolderTests
Assert.Throws<InvalidOperationException>(() => Subject.Add(new RootFolder { Path = path }));
}
[TestCase("$recycle.bin")]
[TestCase("system volume information")]
[TestCase("recycler")]
[TestCase("lost+found")]
[TestCase(".appledb")]
[TestCase(".appledesktop")]
[TestCase(".appledouble")]
[TestCase("@eadir")]
[TestCase(".grab")]
public void should_get_root_folder_with_subfolders_excluding_special_sub_folders(string subFolder)
{
var rootFolder = Builder<RootFolder>.CreateNew()
.With(r => r.Path = @"C:\Test\TV")
.Build();
var subFolders = new[]
{
"Series1",
"Series2",
"Series3",
subFolder
};
var folders = subFolders.Select(f => Path.Combine(@"C:\Test\TV", f)).ToArray();
Mocker.GetMock<IRootFolderRepository>()
.Setup(s => s.Get(It.IsAny<int>()))
.Returns(rootFolder);
Mocker.GetMock<ISeriesService>()
.Setup(s => s.GetAllSeries())
.Returns(new List<Series>());
Mocker.GetMock<IDiskProvider>()
.Setup(s => s.GetDirectories(rootFolder.Path))
.Returns(folders);
var unmappedFolders = Subject.Get(rootFolder.Id).UnmappedFolders;
unmappedFolders.Count.Should().BeGreaterThan(0);
unmappedFolders.Should().NotContain(u => u.Name == subFolder);
}
}
}

@ -1,9 +0,0 @@
namespace NzbDrone.Core.DataAugmentation.Xem.Model
{
public class XemResult<T>
{
public string Result { get; set; }
public T Data { get; set; }
public string Message { get; set; }
}
}

@ -1,8 +0,0 @@
namespace NzbDrone.Core.DataAugmentation.Xem.Model
{
public class XemSceneTvdbMapping
{
public XemValues Scene { get; set; }
public XemValues Tvdb { get; set; }
}
}

@ -1,9 +0,0 @@
namespace NzbDrone.Core.DataAugmentation.Xem.Model
{
public class XemValues
{
public int Season { get; set; }
public int Episode { get; set; }
public int Absolute { get; set; }
}
}

@ -1,127 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json.Linq;
using NLog;
using NzbDrone.Common.Http;
using NzbDrone.Core.DataAugmentation.Scene;
using NzbDrone.Core.DataAugmentation.Xem.Model;
namespace NzbDrone.Core.DataAugmentation.Xem
{
public interface IXemProxy
{
List<int> GetXemSeriesIds();
List<XemSceneTvdbMapping> GetSceneTvdbMappings(int id);
List<SceneMapping> GetSceneTvdbNames();
}
public class XemProxy : IXemProxy
{
private const string ROOT_URL = "http://thexem.de/map/";
private readonly Logger _logger;
private readonly IHttpClient _httpClient;
private readonly IHttpRequestBuilderFactory _xemRequestBuilder;
private static readonly string[] IgnoredErrors = { "no single connection", "no show with the tvdb_id" };
public XemProxy(IHttpClient httpClient, Logger logger)
{
_httpClient = httpClient;
_logger = logger;
_xemRequestBuilder = new HttpRequestBuilder(ROOT_URL)
.AddSuffixQueryParam("origin", "tvdb")
.CreateFactory();
}
public List<int> GetXemSeriesIds()
{
_logger.Debug("Fetching Series IDs from");
var request = _xemRequestBuilder.Create()
.Resource("/havemap")
.Build();
var response = _httpClient.Get<XemResult<List<string>>>(request).Resource;
CheckForFailureResult(response);
return response.Data.Select(d =>
{
int tvdbId = 0;
int.TryParse(d, out tvdbId);
return tvdbId;
}).Where(t => t > 0).ToList();
}
public List<XemSceneTvdbMapping> GetSceneTvdbMappings(int id)
{
_logger.Debug("Fetching Mappings for: {0}", id);
var request = _xemRequestBuilder.Create()
.Resource("/all")
.AddQueryParam("id", id)
.Build();
var response = _httpClient.Get<XemResult<List<XemSceneTvdbMapping>>>(request).Resource;
return response.Data.Where(c => c.Scene != null).ToList();
}
public List<SceneMapping> GetSceneTvdbNames()
{
_logger.Debug("Fetching alternate names");
var request = _xemRequestBuilder.Create()
.Resource("/allNames")
.AddQueryParam("seasonNumbers", true)
.Build();
var response = _httpClient.Get<XemResult<Dictionary<int, List<JObject>>>>(request).Resource;
var result = new List<SceneMapping>();
foreach (var series in response.Data)
{
foreach (var name in series.Value)
{
foreach (var n in name)
{
int seasonNumber;
if (!int.TryParse(n.Value.ToString(), out seasonNumber))
{
continue;
}
//hack to deal with Fate/Zero
if (series.Key == 79151 && seasonNumber > 1)
{
continue;
}
result.Add(new SceneMapping
{
Title = n.Key,
SearchTerm = n.Key,
SceneSeasonNumber = seasonNumber,
TvdbId = series.Key
});
}
}
}
return result;
}
private static void CheckForFailureResult<T>(XemResult<T> response)
{
if (response.Result.Equals("failure", StringComparison.InvariantCultureIgnoreCase) &&
!IgnoredErrors.Any(knowError => response.Message.Contains(knowError)))
{
throw new Exception("Error response received from Xem: " + response.Message);
}
}
}
}

@ -1,243 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Common.Cache;
using NzbDrone.Core.DataAugmentation.Scene;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Tv.Events;
namespace NzbDrone.Core.DataAugmentation.Xem
{
public class XemService : ISceneMappingProvider, IHandle<SeriesUpdatedEvent>, IHandle<SeriesRefreshStartingEvent>
{
private readonly IEpisodeService _episodeService;
private readonly IXemProxy _xemProxy;
private readonly ISeriesService _seriesService;
private readonly Logger _logger;
private readonly ICachedDictionary<bool> _cache;
public XemService(IEpisodeService episodeService,
IXemProxy xemProxy,
ISeriesService seriesService, ICacheManager cacheManager, Logger logger)
{
_episodeService = episodeService;
_xemProxy = xemProxy;
_seriesService = seriesService;
_logger = logger;
_cache = cacheManager.GetCacheDictionary<bool>(GetType(), "mappedTvdbid");
}
private void PerformUpdate(Series series)
{
_logger.Debug("Updating scene numbering mapping for: {0}", series);
try
{
var mappings = _xemProxy.GetSceneTvdbMappings(series.TvdbId);
if (!mappings.Any() && !series.UseSceneNumbering)
{
_logger.Debug("Mappings for: {0} are empty, skipping", series);
return;
}
var episodes = _episodeService.GetEpisodeBySeries(series.Id);
foreach (var episode in episodes)
{
episode.SceneAbsoluteEpisodeNumber = null;
episode.SceneSeasonNumber = null;
episode.SceneEpisodeNumber = null;
episode.UnverifiedSceneNumbering = false;
}
foreach (var mapping in mappings)
{
_logger.Debug("Setting scene numbering mappings for {0} S{1:00}E{2:00}", series, mapping.Tvdb.Season, mapping.Tvdb.Episode);
var episode = episodes.SingleOrDefault(e => e.SeasonNumber == mapping.Tvdb.Season && e.EpisodeNumber == mapping.Tvdb.Episode);
if (episode == null)
{
_logger.Debug("Information hasn't been added to TheTVDB yet, skipping.");
continue;
}
episode.SceneAbsoluteEpisodeNumber = mapping.Scene.Absolute;
episode.SceneSeasonNumber = mapping.Scene.Season;
episode.SceneEpisodeNumber = mapping.Scene.Episode;
}
if (episodes.Any(v => v.SceneEpisodeNumber.HasValue && v.SceneSeasonNumber != 0))
{
ExtrapolateMappings(series, episodes, mappings);
}
_episodeService.UpdateEpisodes(episodes);
series.UseSceneNumbering = mappings.Any();
_seriesService.UpdateSeries(series);
_logger.Debug("XEM mapping updated for {0}", series);
}
catch (Exception ex)
{
_logger.Error(ex, "Error updating scene numbering mappings for: " + series);
}
}
private void ExtrapolateMappings(Series series, List<Episode> episodes, List<Model.XemSceneTvdbMapping> mappings)
{
var mappedEpisodes = episodes.Where(v => v.SeasonNumber != 0 && v.SceneEpisodeNumber.HasValue).ToList();
var mappedSeasons = new HashSet<int>(mappedEpisodes.Select(v => v.SeasonNumber).Distinct());
var sceneEpisodeMappings = mappings.ToLookup(v => v.Scene.Season)
.ToDictionary(v => v.Key, e => new HashSet<int>(e.Select(v => v.Scene.Episode)));
var firstTvdbEpisodeBySeason = mappings.ToLookup(v => v.Tvdb.Season)
.ToDictionary(v => v.Key, e => e.Min(v => v.Tvdb.Episode));
var lastSceneSeason = mappings.Select(v => v.Scene.Season).Max();
var lastTvdbSeason = mappings.Select(v => v.Tvdb.Season).Max();
// Mark all episodes not on the xem as unverified.
foreach (var episode in episodes)
{
if (episode.SeasonNumber == 0) continue;
if (episode.SceneEpisodeNumber.HasValue) continue;
if (mappedSeasons.Contains(episode.SeasonNumber))
{
// Mark if a mapping exists for an earlier episode in this season.
if (firstTvdbEpisodeBySeason[episode.SeasonNumber] <= episode.EpisodeNumber)
{
episode.UnverifiedSceneNumbering = true;
continue;
}
// Mark if a mapping exists with a scene number to this episode.
if (sceneEpisodeMappings.ContainsKey(episode.SeasonNumber) &&
sceneEpisodeMappings[episode.SeasonNumber].Contains(episode.EpisodeNumber))
{
episode.UnverifiedSceneNumbering = true;
continue;
}
}
else if (lastSceneSeason != lastTvdbSeason && episode.SeasonNumber > lastTvdbSeason)
{
episode.UnverifiedSceneNumbering = true;
}
}
foreach (var episode in episodes)
{
if (episode.SeasonNumber == 0) continue;
if (episode.SceneEpisodeNumber.HasValue) continue;
if (episode.SeasonNumber < lastTvdbSeason) continue;
if (!episode.UnverifiedSceneNumbering) continue;
var seasonMappings = mappings.Where(v => v.Tvdb.Season == episode.SeasonNumber).ToList();
if (seasonMappings.Any(v => v.Tvdb.Episode >= episode.EpisodeNumber))
{
continue;
}
if (seasonMappings.Any())
{
var lastEpisodeMapping = seasonMappings.OrderBy(v => v.Tvdb.Episode).Last();
var lastSceneSeasonMapping = mappings.Where(v => v.Scene.Season == lastEpisodeMapping.Scene.Season).OrderBy(v => v.Scene.Episode).Last();
if (lastSceneSeasonMapping.Tvdb.Season == 0)
{
continue;
}
var offset = episode.EpisodeNumber - lastEpisodeMapping.Tvdb.Episode;
episode.SceneSeasonNumber = lastEpisodeMapping.Scene.Season;
episode.SceneEpisodeNumber = lastEpisodeMapping.Scene.Episode + offset;
episode.SceneAbsoluteEpisodeNumber = lastEpisodeMapping.Scene.Absolute + offset;
}
else if (lastTvdbSeason != lastSceneSeason)
{
var offset = episode.SeasonNumber - lastTvdbSeason;
episode.SceneSeasonNumber = lastSceneSeason + offset;
episode.SceneEpisodeNumber = episode.EpisodeNumber;
// TODO: SceneAbsoluteEpisodeNumber.
}
}
}
private void UpdateXemSeriesIds()
{
try
{
var ids = _xemProxy.GetXemSeriesIds();
if (ids.Any())
{
_cache.Update(ids.ToDictionary(v => v.ToString(), v => true));
return;
}
_cache.ExtendTTL();
_logger.Warn("Failed to update Xem series list.");
}
catch (Exception ex)
{
_cache.ExtendTTL();
_logger.Warn(ex, "Failed to update Xem series list.");
}
}
public List<SceneMapping> GetSceneMappings()
{
var mappings = _xemProxy.GetSceneTvdbNames();
return mappings.Where(m =>
{
int id;
if (int.TryParse(m.Title, out id))
{
_logger.Debug("Skipping all numeric name: {0} for {1}", m.Title, m.TvdbId);
return false;
}
return true;
}).ToList();
}
public void Handle(SeriesUpdatedEvent message)
{
if (_cache.IsExpired(TimeSpan.FromHours(3)))
{
UpdateXemSeriesIds();
}
if (_cache.Count == 0)
{
_logger.Debug("Scene numbering is not available");
return;
}
if (!_cache.Find(message.Series.TvdbId.ToString()) && !message.Series.UseSceneNumbering)
{
_logger.Debug("Scene numbering is not available for {0} [{1}]", message.Series.Title, message.Series.TvdbId);
return;
}
PerformUpdate(message.Series);
}
public void Handle(SeriesRefreshStartingEvent message)
{
if (message.ManualTrigger && _cache.IsExpired(TimeSpan.FromMinutes(1)))
{
UpdateXemSeriesIds();
}
}
}
}

@ -47,7 +47,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
protected IEnumerable<DownloadStationTask> GetTasks()
{
return _proxy.GetTasks(Settings).Where(v => v.Type == DownloadStationTaskType.BT.ToString());
return _proxy.GetTasks(Settings).Where(v => v.Type.ToLower() == DownloadStationTaskType.BT.ToString().ToLower());
}
public override IEnumerable<DownloadClientItem> GetItems()

@ -44,7 +44,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
protected IEnumerable<DownloadStationTask> GetTasks()
{
return _proxy.GetTasks(Settings).Where(v => v.Type == DownloadStationTaskType.NZB.ToString());
return _proxy.GetTasks(Settings).Where(v => v.Type.ToLower() == DownloadStationTaskType.NZB.ToString().ToLower());
}
public override IEnumerable<DownloadClientItem> GetItems()

@ -65,7 +65,7 @@ namespace NzbDrone.Core.Indexers.TorrentPotato
requestBuilder.AddQueryParam("user", "");
}
requestBuilder.AddQueryParam("search", "the");
requestBuilder.AddQueryParam("search", "-");
yield return new IndexerRequest(requestBuilder.Build());
}

@ -69,7 +69,7 @@ namespace NzbDrone.Core.MediaFiles
_logger = logger;
}
private static readonly Regex ExcludedSubFoldersRegex = new Regex(@"(?:\\|\/|^)(extras|@eadir|extrafanart|\..+)(?:\\|\/)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex ExcludedSubFoldersRegex = new Regex(@"(?:\\|\/|^)(extras|@eadir|extrafanart|plex\sversions|\..+)(?:\\|\/)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex ExcludedFilesRegex = new Regex(@"^\._|Thumbs\.db", RegexOptions.Compiled | RegexOptions.IgnoreCase);
public void Scan(Series series)

@ -10,7 +10,7 @@ using NzbDrone.Core.Configuration;
namespace NzbDrone.Core.MediaFiles.MediaInfo
{
public class UpdateMediaInfoService : IHandle<SeriesScannedEvent>
public class UpdateMediaInfoService : IHandle<MovieScannedEvent>
{
private readonly IDiskProvider _diskProvider;
private readonly IMediaFileService _mediaFileService;
@ -33,7 +33,7 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
_logger = logger;
}
private void UpdateMediaInfo(Series series, List<EpisodeFile> mediaFiles)
private void UpdateMediaInfo(Movie series, List<MovieFile> mediaFiles)
{
foreach (var mediaFile in mediaFiles)
{
@ -56,7 +56,7 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
}
}
public void Handle(SeriesScannedEvent message)
public void Handle(MovieScannedEvent message)
{
if (!_configService.EnableMediaInfo)
{
@ -64,10 +64,10 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
return;
}
var allMediaFiles = _mediaFileService.GetFilesBySeries(message.Series.Id);
var allMediaFiles = _mediaFileService.GetFilesByMovie(message.Movie.Id);
var filteredMediaFiles = allMediaFiles.Where(c => c.MediaInfo == null || c.MediaInfo.SchemaRevision < CURRENT_MEDIA_INFO_SCHEMA_REVISION).ToList();
UpdateMediaInfo(message.Series, filteredMediaFiles);
UpdateMediaInfo(message.Movie, filteredMediaFiles);
}
}
}

@ -135,7 +135,7 @@ namespace NzbDrone.Core.NetImport.RSSImport
var title = GetTitle(item);
// Loosely allow movies (will work with IMDB)
if (title.ContainsIgnoreCase("TV Series") || title.ContainsIgnoreCase("Mini-Series"))
if (title.ContainsIgnoreCase("TV Series") || title.ContainsIgnoreCase("Mini-Series") || title.ContainsIgnoreCase("TV Episode"))
{
return null;
}

@ -197,11 +197,6 @@
<Compile Include="DataAugmentation\Scene\SceneMappingsUpdatedEvent.cs" />
<Compile Include="DataAugmentation\Scene\ServicesProvider.cs" />
<Compile Include="DataAugmentation\Scene\UpdateSceneMappingCommand.cs" />
<Compile Include="DataAugmentation\Xem\Model\XemResult.cs" />
<Compile Include="DataAugmentation\Xem\Model\XemSceneTvdbMapping.cs" />
<Compile Include="DataAugmentation\Xem\Model\XemValues.cs" />
<Compile Include="DataAugmentation\Xem\XemProxy.cs" />
<Compile Include="DataAugmentation\Xem\XemService.cs" />
<Compile Include="Datastore\BasicRepository.cs" />
<Compile Include="Datastore\ConnectionStringFactory.cs" />
<Compile Include="Datastore\Converters\BooleanIntConverter.cs" />
@ -1343,4 +1338,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

@ -38,7 +38,8 @@ namespace NzbDrone.Core.RootFolders
".appledb",
".appledesktop",
".appledouble",
"@eadir"
"@eadir",
".grab"
};
@ -170,7 +171,9 @@ namespace NzbDrone.Core.RootFolders
{
_logger.Debug("Generating list of unmapped folders");
if (string.IsNullOrEmpty(path))
{
throw new ArgumentException("Invalid path provided", "path");
}
var results = new List<UnmappedFolder>();
var movies = _movieRepository.All().ToList();
@ -181,8 +184,11 @@ namespace NzbDrone.Core.RootFolders
return results;
}
var movieFolders = _diskProvider.GetDirectories(path).ToList();
var unmappedFolders = movieFolders.Except(movies.Select(s => s.Path), PathEqualityComparer.Instance).ToList();
//var movieFolders = _diskProvider.GetDirectories(path).ToList();
//var unmappedFolders = movieFolders.Except(movies.Select(s => s.Path), PathEqualityComparer.Instance).ToList();
var possibleMovieFolders = _diskProvider.GetDirectories(path).ToList();
var unmappedFolders = possibleMovieFolders.Except(movies.Select(s => s.Path), PathEqualityComparer.Instance).ToList();
foreach (string unmappedFolder in unmappedFolders)
{

Loading…
Cancel
Save