mirror of https://github.com/lidarr/Lidarr
Rework Tests for Music, Start TV Code Cleanup
This commit is contained in:
parent
1688c0a8df
commit
42e25055a9
|
@ -4,7 +4,7 @@ using FluentAssertions;
|
|||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Test.Datastore
|
||||
{
|
||||
|
@ -14,8 +14,8 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
public void SingleOrDefault_should_return_null_on_empty_db()
|
||||
{
|
||||
Mocker.Resolve<IDatabase>()
|
||||
.GetDataMapper().Query<Series>()
|
||||
.SingleOrDefault(c => c.CleanTitle == "SomeTitle")
|
||||
.GetDataMapper().Query<Artist>()
|
||||
.SingleOrDefault(c => c.CleanName == "SomeTitle")
|
||||
.Should()
|
||||
.BeNull();
|
||||
}
|
||||
|
@ -33,4 +33,4 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
Mocker.Resolve<IDatabase>().Version.Should().BeGreaterThan(new Version("3.0.0"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ using NUnit.Framework;
|
|||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Languages;
|
||||
|
||||
namespace NzbDrone.Core.Test.Datastore
|
||||
|
@ -16,41 +16,41 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
[Test]
|
||||
public void one_to_one()
|
||||
{
|
||||
var episodeFile = Builder<EpisodeFile>.CreateNew()
|
||||
var trackFile = Builder<TrackFile>.CreateNew()
|
||||
.With(c => c.Quality = new QualityModel())
|
||||
.With(c => c.Language = Language.English)
|
||||
.BuildNew();
|
||||
|
||||
Db.Insert(episodeFile);
|
||||
Db.Insert(trackFile);
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(c => c.EpisodeFileId = episodeFile.Id)
|
||||
var track = Builder<Track>.CreateNew()
|
||||
.With(c => c.TrackFileId = trackFile.Id)
|
||||
.BuildNew();
|
||||
|
||||
Db.Insert(episode);
|
||||
Db.Insert(track);
|
||||
|
||||
var loadedEpisodeFile = Db.Single<Episode>().EpisodeFile.Value;
|
||||
var loadedTrackFile = Db.Single<Track>().TrackFile.Value;
|
||||
|
||||
loadedEpisodeFile.Should().NotBeNull();
|
||||
loadedEpisodeFile.ShouldBeEquivalentTo(episodeFile,
|
||||
loadedTrackFile.Should().NotBeNull();
|
||||
loadedTrackFile.ShouldBeEquivalentTo(trackFile,
|
||||
options => options
|
||||
.IncludingAllRuntimeProperties()
|
||||
.Excluding(c => c.DateAdded)
|
||||
.Excluding(c => c.Path)
|
||||
.Excluding(c => c.Series)
|
||||
.Excluding(c => c.Episodes));
|
||||
.Excluding(c => c.Artist)
|
||||
.Excluding(c => c.Tracks));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void one_to_one_should_not_query_db_if_foreign_key_is_zero()
|
||||
{
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(c => c.EpisodeFileId = 0)
|
||||
var track = Builder<Track>.CreateNew()
|
||||
.With(c => c.TrackFileId = 0)
|
||||
.BuildNew();
|
||||
|
||||
Db.Insert(episode);
|
||||
Db.Insert(track);
|
||||
|
||||
Db.Single<Episode>().EpisodeFile.Value.Should().BeNull();
|
||||
Db.Single<Track>().TrackFile.Value.Should().BeNull();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using FluentAssertions;
|
||||
using Marr.Data;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Datastore.Converters;
|
||||
using NzbDrone.Core.Datastore.Extensions;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Test.Datastore
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
|
||||
public class TypeWithNoMappableProperties
|
||||
{
|
||||
public Series Series { get; set; }
|
||||
public Artist Artist { get; set; }
|
||||
|
||||
public int ReadOnly { get; private set; }
|
||||
public int WriteOnly { private get; set; }
|
||||
|
@ -62,4 +62,4 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
properties.Should().NotContain(c => MappingExtensions.IsMappableProperty(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ using NUnit.Framework;
|
|||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Languages;
|
||||
|
@ -38,30 +38,30 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
profile = Db.Insert(profile);
|
||||
languageProfile = Db.Insert(languageProfile);
|
||||
|
||||
var series = Builder<Series>.CreateListOfSize(1)
|
||||
var artist = Builder<Artist>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(v => v.ProfileId = profile.Id)
|
||||
.With(v => v.LanguageProfileId = languageProfile.Id)
|
||||
.BuildListOfNew();
|
||||
|
||||
Db.InsertMany(series);
|
||||
Db.InsertMany(artist);
|
||||
|
||||
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(1)
|
||||
var trackFiles = Builder<TrackFile>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(v => v.SeriesId = series[0].Id)
|
||||
.With(v => v.ArtistId = artist[0].Id)
|
||||
.With(v => v.Quality = new QualityModel())
|
||||
.BuildListOfNew();
|
||||
|
||||
Db.InsertMany(episodeFiles);
|
||||
Db.InsertMany(trackFiles);
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(10)
|
||||
var tracks = Builder<Track>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(v => v.Monitored = true)
|
||||
.With(v => v.EpisodeFileId = episodeFiles[0].Id)
|
||||
.With(v => v.SeriesId = series[0].Id)
|
||||
.With(v => v.TrackFileId = trackFiles[0].Id)
|
||||
.With(v => v.ArtistId = artist[0].Id)
|
||||
.BuildListOfNew();
|
||||
|
||||
Db.InsertMany(episodes);
|
||||
Db.InsertMany(tracks);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -70,32 +70,32 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
var db = Mocker.Resolve<IDatabase>();
|
||||
var DataMapper = db.GetDataMapper();
|
||||
|
||||
var episodes = DataMapper.Query<Episode>()
|
||||
.Join<Episode, Series>(Marr.Data.QGen.JoinType.Inner, v => v.Series, (l, r) => l.SeriesId == r.Id)
|
||||
var tracks = DataMapper.Query<Track>()
|
||||
.Join<Track, Artist>(Marr.Data.QGen.JoinType.Inner, v => v.Artist, (l, r) => l.ArtistId == r.Id)
|
||||
.ToList();
|
||||
|
||||
foreach (var episode in episodes)
|
||||
foreach (var track in tracks)
|
||||
{
|
||||
Assert.IsNotNull(episode.Series);
|
||||
Assert.IsFalse(episode.Series.Profile.IsLoaded);
|
||||
Assert.IsFalse(episode.Series.LanguageProfile.IsLoaded);
|
||||
Assert.IsNotNull(track.Artist);
|
||||
Assert.IsFalse(track.Artist.Profile.IsLoaded);
|
||||
Assert.IsFalse(track.Artist.LanguageProfile.IsLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_explicit_load_episodefile_if_joined()
|
||||
public void should_explicit_load_trackfile_if_joined()
|
||||
{
|
||||
var db = Mocker.Resolve<IDatabase>();
|
||||
var DataMapper = db.GetDataMapper();
|
||||
|
||||
var episodes = DataMapper.Query<Episode>()
|
||||
.Join<Episode, EpisodeFile>(Marr.Data.QGen.JoinType.Inner, v => v.EpisodeFile, (l, r) => l.EpisodeFileId == r.Id)
|
||||
var tracks = DataMapper.Query<Track>()
|
||||
.Join<Track, TrackFile>(Marr.Data.QGen.JoinType.Inner, v => v.TrackFile, (l, r) => l.TrackFileId == r.Id)
|
||||
.ToList();
|
||||
|
||||
foreach (var episode in episodes)
|
||||
foreach (var track in tracks)
|
||||
{
|
||||
Assert.IsNull(episode.Series);
|
||||
Assert.IsTrue(episode.EpisodeFile.IsLoaded);
|
||||
Assert.IsNull(track.Artist);
|
||||
Assert.IsTrue(track.TrackFile.IsLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,16 +105,16 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
var db = Mocker.Resolve<IDatabase>();
|
||||
var DataMapper = db.GetDataMapper();
|
||||
|
||||
var episodes = DataMapper.Query<Episode>()
|
||||
.Join<Episode, Series>(Marr.Data.QGen.JoinType.Inner, v => v.Series, (l, r) => l.SeriesId == r.Id)
|
||||
.Join<Series, Profile>(Marr.Data.QGen.JoinType.Inner, v => v.Profile, (l, r) => l.ProfileId == r.Id)
|
||||
var tracks = DataMapper.Query<Track>()
|
||||
.Join<Track, Artist>(Marr.Data.QGen.JoinType.Inner, v => v.Artist, (l, r) => l.ArtistId == r.Id)
|
||||
.Join<Artist, Profile>(Marr.Data.QGen.JoinType.Inner, v => v.Profile, (l, r) => l.ProfileId == r.Id)
|
||||
.ToList();
|
||||
|
||||
foreach (var episode in episodes)
|
||||
foreach (var track in tracks)
|
||||
{
|
||||
Assert.IsNotNull(episode.Series);
|
||||
Assert.IsTrue(episode.Series.Profile.IsLoaded);
|
||||
Assert.IsFalse(episode.Series.LanguageProfile.IsLoaded);
|
||||
Assert.IsNotNull(track.Artist);
|
||||
Assert.IsTrue(track.Artist.Profile.IsLoaded);
|
||||
Assert.IsFalse(track.Artist.LanguageProfile.IsLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,16 +124,16 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
var db = Mocker.Resolve<IDatabase>();
|
||||
var DataMapper = db.GetDataMapper();
|
||||
|
||||
var episodes = DataMapper.Query<Episode>()
|
||||
.Join<Episode, Series>(Marr.Data.QGen.JoinType.Inner, v => v.Series, (l, r) => l.SeriesId == r.Id)
|
||||
.Join<Series, LanguageProfile>(Marr.Data.QGen.JoinType.Inner, v => v.LanguageProfile, (l, r) => l.ProfileId == r.Id)
|
||||
var tracks = DataMapper.Query<Track>()
|
||||
.Join<Track, Artist>(Marr.Data.QGen.JoinType.Inner, v => v.Artist, (l, r) => l.ArtistId == r.Id)
|
||||
.Join<Artist, LanguageProfile>(Marr.Data.QGen.JoinType.Inner, v => v.LanguageProfile, (l, r) => l.ProfileId == r.Id)
|
||||
.ToList();
|
||||
|
||||
foreach (var episode in episodes)
|
||||
foreach (var track in tracks)
|
||||
{
|
||||
Assert.IsNotNull(episode.Series);
|
||||
Assert.IsFalse(episode.Series.Profile.IsLoaded);
|
||||
Assert.IsTrue(episode.Series.LanguageProfile.IsLoaded);
|
||||
Assert.IsNotNull(track.Artist);
|
||||
Assert.IsFalse(track.Artist.Profile.IsLoaded);
|
||||
Assert.IsTrue(track.Artist.LanguageProfile.IsLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
using FluentAssertions;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Datastore.Extensions;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Test.Datastore.PagingSpecExtensionsTests
|
||||
{
|
||||
|
@ -14,12 +14,12 @@ namespace NzbDrone.Core.Test.Datastore.PagingSpecExtensionsTests
|
|||
[TestCase(1, 100, 0)]
|
||||
public void should_calcuate_expected_offset(int page, int pageSize, int expected)
|
||||
{
|
||||
var pagingSpec = new PagingSpec<Episode>
|
||||
var pagingSpec = new PagingSpec<Album>
|
||||
{
|
||||
Page = page,
|
||||
PageSize = pageSize,
|
||||
SortDirection = SortDirection.Ascending,
|
||||
SortKey = "AirDate"
|
||||
SortKey = "ReleaseDate"
|
||||
};
|
||||
|
||||
pagingSpec.PagingOffset().Should().Be(expected);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
using FluentAssertions;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Datastore.Extensions;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Test.Datastore.PagingSpecExtensionsTests
|
||||
{
|
||||
|
@ -11,12 +11,12 @@ namespace NzbDrone.Core.Test.Datastore.PagingSpecExtensionsTests
|
|||
[Test]
|
||||
public void should_convert_default_to_asc()
|
||||
{
|
||||
var pagingSpec = new PagingSpec<Episode>
|
||||
var pagingSpec = new PagingSpec<Album>
|
||||
{
|
||||
Page = 1,
|
||||
PageSize = 10,
|
||||
SortDirection = SortDirection.Default,
|
||||
SortKey = "AirDate"
|
||||
SortKey = "ReleaseDate"
|
||||
};
|
||||
|
||||
pagingSpec.ToSortDirection().Should().Be(Marr.Data.QGen.SortDirection.Asc);
|
||||
|
@ -25,13 +25,13 @@ namespace NzbDrone.Core.Test.Datastore.PagingSpecExtensionsTests
|
|||
[Test]
|
||||
public void should_convert_ascending_to_asc()
|
||||
{
|
||||
var pagingSpec = new PagingSpec<Episode>
|
||||
var pagingSpec = new PagingSpec<Album>
|
||||
{
|
||||
Page = 1,
|
||||
PageSize = 10,
|
||||
SortDirection = SortDirection.Ascending,
|
||||
SortKey = "AirDate"
|
||||
};
|
||||
SortKey = "ReleaseDate"
|
||||
};
|
||||
|
||||
pagingSpec.ToSortDirection().Should().Be(Marr.Data.QGen.SortDirection.Asc);
|
||||
}
|
||||
|
@ -39,12 +39,12 @@ namespace NzbDrone.Core.Test.Datastore.PagingSpecExtensionsTests
|
|||
[Test]
|
||||
public void should_convert_descending_to_desc()
|
||||
{
|
||||
var pagingSpec = new PagingSpec<Episode>
|
||||
var pagingSpec = new PagingSpec<Album>
|
||||
{
|
||||
Page = 1,
|
||||
PageSize = 10,
|
||||
SortDirection = SortDirection.Descending,
|
||||
SortKey = "AirDate"
|
||||
SortKey = "ReleaseDate"
|
||||
};
|
||||
|
||||
pagingSpec.ToSortDirection().Should().Be(Marr.Data.QGen.SortDirection.Desc);
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
using FizzWare.NBuilder;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications.Search;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ using NzbDrone.Core.Messaging.Events;
|
|||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
@ -8,7 +8,6 @@ using NzbDrone.Core.IndexerSearch.Definitions;
|
|||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
|
@ -7,7 +7,6 @@ using NzbDrone.Core.DecisionEngine;
|
|||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.IndexerSearch;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using FluentAssertions;
|
||||
using Marr.Data;
|
||||
|
@ -118,7 +118,7 @@ namespace NzbDrone.Core.Test.Instrumentation
|
|||
[Test]
|
||||
public void null_string_as_arg_should_not_fail()
|
||||
{
|
||||
var epFile = new EpisodeFile();
|
||||
var epFile = new TrackFile();
|
||||
_logger.Debug("File {0} no longer exists on disk. removing from database.", epFile.RelativePath);
|
||||
|
||||
Thread.Sleep(600);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
using System.Linq;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Profiles.Languages;
|
||||
|
||||
namespace NzbDrone.Core.Test.Languages
|
||||
|
@ -39,15 +39,15 @@ namespace NzbDrone.Core.Test.Languages
|
|||
|
||||
|
||||
[Test]
|
||||
public void should_not_be_able_to_delete_profile_if_assigned_to_series()
|
||||
public void should_not_be_able_to_delete_profile_if_assigned_to_artist()
|
||||
{
|
||||
var seriesList = Builder<Series>.CreateListOfSize(3)
|
||||
var artistList = Builder<Artist>.CreateListOfSize(3)
|
||||
.Random(1)
|
||||
.With(c => c.LanguageProfileId = 2)
|
||||
.Build().ToList();
|
||||
|
||||
|
||||
Mocker.GetMock<ISeriesService>().Setup(c => c.GetAllSeries()).Returns(seriesList);
|
||||
Mocker.GetMock<IArtistService>().Setup(c => c.GetAllArtists()).Returns(artistList);
|
||||
|
||||
Assert.Throws<LanguageProfileInUseException>(() => Subject.Delete(2));
|
||||
|
||||
|
@ -59,17 +59,17 @@ namespace NzbDrone.Core.Test.Languages
|
|||
[Test]
|
||||
public void should_delete_profile_if_not_assigned_to_series()
|
||||
{
|
||||
var seriesList = Builder<Series>.CreateListOfSize(3)
|
||||
var artistList = Builder<Artist>.CreateListOfSize(3)
|
||||
.All()
|
||||
.With(c => c.LanguageProfileId = 2)
|
||||
.Build().ToList();
|
||||
|
||||
|
||||
Mocker.GetMock<ISeriesService>().Setup(c => c.GetAllSeries()).Returns(seriesList);
|
||||
Mocker.GetMock<IArtistService>().Setup(c => c.GetAllArtists()).Returns(artistList);
|
||||
|
||||
Subject.Delete(1);
|
||||
|
||||
Mocker.GetMock<ILanguageProfileRepository>().Verify(c => c.Delete(1), Times.Once());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,14 +128,14 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_publish_EpisodeImportedEvent_for_new_downloads()
|
||||
{
|
||||
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true);
|
||||
//[Test]
|
||||
//public void should_publish_EpisodeImportedEvent_for_new_downloads()
|
||||
//{
|
||||
// Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true);
|
||||
|
||||
Mocker.GetMock<IEventAggregator>()
|
||||
.Verify(v => v.PublishEvent(It.IsAny<EpisodeImportedEvent>()), Times.Once());
|
||||
}
|
||||
// Mocker.GetMock<IEventAggregator>()
|
||||
// .Verify(v => v.PublishEvent(It.IsAny<EpisodeImportedEvent>()), Times.Once());
|
||||
//}
|
||||
|
||||
[Test]
|
||||
public void should_not_move_existing_files()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
|
@ -6,7 +6,6 @@ using Moq;
|
|||
using NUnit.Framework;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
|
@ -148,4 +147,4 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests
|
|||
Subject.FilterExistingFiles(files, _artist).Should().Contain(files.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ using NzbDrone.Common.Disk;
|
|||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
|
|
|
@ -331,7 +331,7 @@
|
|||
<Compile Include="ParserTests\MultiEpisodeParserFixture.cs" />
|
||||
<Compile Include="ParserTests\NormalizeTitleFixture.cs" />
|
||||
<Compile Include="ParserTests\ParserFixture.cs" />
|
||||
<Compile Include="ParserTests\ParsingServiceTests\GetSeriesFixture.cs" />
|
||||
<Compile Include="ParserTests\ParsingServiceTests\GetArtistFixture.cs" />
|
||||
<Compile Include="ParserTests\PathParserFixture.cs" />
|
||||
<Compile Include="ParserTests\QualityParserFixture.cs" />
|
||||
<Compile Include="ParserTests\ReleaseGroupParserFixture.cs" />
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class GetArtistFixture : CoreTest<ParsingService>
|
||||
{
|
||||
[Test]
|
||||
public void should_use_passed_in_title_when_it_cannot_be_parsed()
|
||||
{
|
||||
const string title = "30 Rock";
|
||||
|
||||
Subject.GetArtist(title);
|
||||
|
||||
Mocker.GetMock<IArtistService>()
|
||||
.Verify(s => s.FindByName(title), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_use_parsed_artist_title()
|
||||
{
|
||||
const string title = "30 Rock - Get Some [FLAC]";
|
||||
|
||||
Subject.GetArtist(title);
|
||||
|
||||
Mocker.GetMock<IArtistService>()
|
||||
.Verify(s => s.FindByName(Parser.Parser.ParseAlbumTitle(title).ArtistName), Times.Once());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class GetSeriesFixture : CoreTest<ParsingService>
|
||||
{
|
||||
[Test]
|
||||
public void should_use_passed_in_title_when_it_cannot_be_parsed()
|
||||
{
|
||||
const string title = "30 Rock";
|
||||
|
||||
Subject.GetSeries(title);
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Verify(s => s.FindByTitle(title), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_use_parsed_series_title()
|
||||
{
|
||||
const string title = "30.Rock.S01E01.720p.hdtv";
|
||||
|
||||
Subject.GetSeries(title);
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Verify(s => s.FindByTitle(Parser.Parser.ParseTitle(title).SeriesTitle), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_fallback_to_title_without_year_and_year_when_title_lookup_fails()
|
||||
{
|
||||
const string title = "House.2004.S01E01.720p.hdtv";
|
||||
var parsedEpisodeInfo = Parser.Parser.ParseTitle(title);
|
||||
|
||||
Subject.GetSeries(title);
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Verify(s => s.FindByTitle(parsedEpisodeInfo.SeriesTitleInfo.TitleWithoutYear,
|
||||
parsedEpisodeInfo.SeriesTitleInfo.Year), Times.Once());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ using NUnit.Framework;
|
|||
using NzbDrone.Core.Lifecycle;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Test.Profiles
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ namespace NzbDrone.Core.Test.Profiles
|
|||
Subject.Handle(new ApplicationStartedEvent());
|
||||
|
||||
Mocker.GetMock<IProfileRepository>()
|
||||
.Verify(v => v.Insert(It.IsAny<Profile>()), Times.Exactly(6));
|
||||
.Verify(v => v.Insert(It.IsAny<Profile>()), Times.Exactly(3));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -39,15 +39,15 @@ namespace NzbDrone.Core.Test.Profiles
|
|||
|
||||
|
||||
[Test]
|
||||
public void should_not_be_able_to_delete_profile_if_assigned_to_series()
|
||||
public void should_not_be_able_to_delete_profile_if_assigned_to_artist()
|
||||
{
|
||||
var seriesList = Builder<Series>.CreateListOfSize(3)
|
||||
var artistList = Builder<Artist>.CreateListOfSize(3)
|
||||
.Random(1)
|
||||
.With(c => c.ProfileId = 2)
|
||||
.Build().ToList();
|
||||
|
||||
|
||||
Mocker.GetMock<ISeriesService>().Setup(c => c.GetAllSeries()).Returns(seriesList);
|
||||
Mocker.GetMock<IArtistService>().Setup(c => c.GetAllArtists()).Returns(artistList);
|
||||
|
||||
Assert.Throws<ProfileInUseException>(() => Subject.Delete(2));
|
||||
|
||||
|
@ -57,15 +57,15 @@ namespace NzbDrone.Core.Test.Profiles
|
|||
|
||||
|
||||
[Test]
|
||||
public void should_delete_profile_if_not_assigned_to_series()
|
||||
public void should_delete_profile_if_not_assigned_to_artist()
|
||||
{
|
||||
var seriesList = Builder<Series>.CreateListOfSize(3)
|
||||
var artistList = Builder<Artist>.CreateListOfSize(3)
|
||||
.All()
|
||||
.With(c => c.ProfileId = 2)
|
||||
.Build().ToList();
|
||||
|
||||
|
||||
Mocker.GetMock<ISeriesService>().Setup(c => c.GetAllSeries()).Returns(seriesList);
|
||||
Mocker.GetMock<IArtistService>().Setup(c => c.GetAllArtists()).Returns(artistList);
|
||||
|
||||
Subject.Delete(1);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
|
@ -7,7 +7,7 @@ using NzbDrone.Core.Queue;
|
|||
using NzbDrone.Core.Test.Framework;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.Test.QueueTests
|
||||
|
@ -24,24 +24,24 @@ namespace NzbDrone.Core.Test.QueueTests
|
|||
.With(v => v.RemainingTime = TimeSpan.FromSeconds(10))
|
||||
.Build();
|
||||
|
||||
var series = Builder<Series>.CreateNew()
|
||||
var series = Builder<Artist>.CreateNew()
|
||||
.Build();
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(3)
|
||||
var episodes = Builder<Album>.CreateListOfSize(3)
|
||||
.All()
|
||||
.With(e => e.SeriesId = series.Id)
|
||||
.With(e => e.ArtistId = series.Id)
|
||||
.Build();
|
||||
|
||||
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||
.With(r => r.Series = series)
|
||||
.With(r => r.Episodes = new List<Episode>(episodes))
|
||||
.With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo())
|
||||
var remoteEpisode = Builder<RemoteAlbum>.CreateNew()
|
||||
.With(r => r.Artist = series)
|
||||
.With(r => r.Albums = new List<Album>(episodes))
|
||||
.With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo())
|
||||
.Build();
|
||||
|
||||
_trackedDownloads = Builder<TrackedDownload>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(v => v.DownloadItem = downloadItem)
|
||||
.With(v => v.RemoteEpisode = remoteEpisode)
|
||||
.With(v => v.RemoteAlbum = remoteEpisode)
|
||||
.Build()
|
||||
.ToList();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
|
@ -53,71 +53,71 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeServiceTests
|
|||
.Returns(_episodes);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_set_EpisodeFileId_to_zero()
|
||||
{
|
||||
GivenSingleEpisodeFile();
|
||||
//[Test]
|
||||
//public void should_set_EpisodeFileId_to_zero()
|
||||
//{
|
||||
// GivenSingleEpisodeFile();
|
||||
|
||||
Subject.Handle(new EpisodeFileDeletedEvent(_episodeFile, DeleteMediaFileReason.MissingFromDisk));
|
||||
// Subject.Handle(new EpisodeFileDeletedEvent(_episodeFile, DeleteMediaFileReason.MissingFromDisk));
|
||||
|
||||
Mocker.GetMock<IEpisodeRepository>()
|
||||
.Verify(v => v.Update(It.Is<Episode>(e => e.EpisodeFileId == 0)), Times.Once());
|
||||
}
|
||||
// Mocker.GetMock<IEpisodeRepository>()
|
||||
// .Verify(v => v.Update(It.Is<Episode>(e => e.EpisodeFileId == 0)), Times.Once());
|
||||
//}
|
||||
|
||||
[Test]
|
||||
public void should_update_each_episode_for_file()
|
||||
{
|
||||
GivenMultiEpisodeFile();
|
||||
//[Test]
|
||||
//public void should_update_each_episode_for_file()
|
||||
//{
|
||||
// GivenMultiEpisodeFile();
|
||||
|
||||
Subject.Handle(new EpisodeFileDeletedEvent(_episodeFile, DeleteMediaFileReason.MissingFromDisk));
|
||||
// Subject.Handle(new EpisodeFileDeletedEvent(_episodeFile, DeleteMediaFileReason.MissingFromDisk));
|
||||
|
||||
Mocker.GetMock<IEpisodeRepository>()
|
||||
.Verify(v => v.Update(It.Is<Episode>(e => e.EpisodeFileId == 0)), Times.Exactly(2));
|
||||
}
|
||||
// Mocker.GetMock<IEpisodeRepository>()
|
||||
// .Verify(v => v.Update(It.Is<Episode>(e => e.EpisodeFileId == 0)), Times.Exactly(2));
|
||||
//}
|
||||
|
||||
[Test]
|
||||
public void should_set_monitored_to_false_if_autoUnmonitor_is_true_and_is_not_for_an_upgrade()
|
||||
{
|
||||
GivenSingleEpisodeFile();
|
||||
//[Test]
|
||||
//public void should_set_monitored_to_false_if_autoUnmonitor_is_true_and_is_not_for_an_upgrade()
|
||||
//{
|
||||
// GivenSingleEpisodeFile();
|
||||
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.SetupGet(s => s.AutoUnmonitorPreviouslyDownloadedTracks)
|
||||
.Returns(true);
|
||||
// Mocker.GetMock<IConfigService>()
|
||||
// .SetupGet(s => s.AutoUnmonitorPreviouslyDownloadedTracks)
|
||||
// .Returns(true);
|
||||
|
||||
Subject.Handle(new EpisodeFileDeletedEvent(_episodeFile, DeleteMediaFileReason.MissingFromDisk));
|
||||
// Subject.Handle(new EpisodeFileDeletedEvent(_episodeFile, DeleteMediaFileReason.MissingFromDisk));
|
||||
|
||||
Mocker.GetMock<IEpisodeRepository>()
|
||||
.Verify(v => v.Update(It.Is<Episode>(e => e.Monitored == false)), Times.Once());
|
||||
}
|
||||
// Mocker.GetMock<IEpisodeRepository>()
|
||||
// .Verify(v => v.Update(It.Is<Episode>(e => e.Monitored == false)), Times.Once());
|
||||
//}
|
||||
|
||||
[Test]
|
||||
public void should_leave_monitored_to_true_if_autoUnmonitor_is_false()
|
||||
{
|
||||
GivenSingleEpisodeFile();
|
||||
//[Test]
|
||||
//public void should_leave_monitored_to_true_if_autoUnmonitor_is_false()
|
||||
//{
|
||||
// GivenSingleEpisodeFile();
|
||||
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.SetupGet(s => s.AutoUnmonitorPreviouslyDownloadedTracks)
|
||||
.Returns(false);
|
||||
// Mocker.GetMock<IConfigService>()
|
||||
// .SetupGet(s => s.AutoUnmonitorPreviouslyDownloadedTracks)
|
||||
// .Returns(false);
|
||||
|
||||
Subject.Handle(new EpisodeFileDeletedEvent(_episodeFile, DeleteMediaFileReason.Upgrade));
|
||||
// Subject.Handle(new EpisodeFileDeletedEvent(_episodeFile, DeleteMediaFileReason.Upgrade));
|
||||
|
||||
Mocker.GetMock<IEpisodeRepository>()
|
||||
.Verify(v => v.Update(It.Is<Episode>(e => e.Monitored == true)), Times.Once());
|
||||
}
|
||||
// Mocker.GetMock<IEpisodeRepository>()
|
||||
// .Verify(v => v.Update(It.Is<Episode>(e => e.Monitored == true)), Times.Once());
|
||||
//}
|
||||
|
||||
[Test]
|
||||
public void should_leave_monitored_to_true_if_autoUnmonitor_is_true_and_is_for_an_upgrade()
|
||||
{
|
||||
GivenSingleEpisodeFile();
|
||||
//[Test]
|
||||
//public void should_leave_monitored_to_true_if_autoUnmonitor_is_true_and_is_for_an_upgrade()
|
||||
//{
|
||||
// GivenSingleEpisodeFile();
|
||||
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.SetupGet(s => s.AutoUnmonitorPreviouslyDownloadedTracks)
|
||||
.Returns(true);
|
||||
// Mocker.GetMock<IConfigService>()
|
||||
// .SetupGet(s => s.AutoUnmonitorPreviouslyDownloadedTracks)
|
||||
// .Returns(true);
|
||||
|
||||
Subject.Handle(new EpisodeFileDeletedEvent(_episodeFile, DeleteMediaFileReason.Upgrade));
|
||||
// Subject.Handle(new EpisodeFileDeletedEvent(_episodeFile, DeleteMediaFileReason.Upgrade));
|
||||
|
||||
Mocker.GetMock<IEpisodeRepository>()
|
||||
.Verify(v => v.Update(It.Is<Episode>(e => e.Monitored == true)), Times.Once());
|
||||
}
|
||||
// Mocker.GetMock<IEpisodeRepository>()
|
||||
// .Verify(v => v.Update(It.Is<Episode>(e => e.Monitored == true)), Times.Once());
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads
|
|||
{
|
||||
public class DownloadMonitoringService : IExecute<CheckForFinishedDownloadCommand>,
|
||||
IHandle<AlbumGrabbedEvent>,
|
||||
IHandle<EpisodeImportedEvent>,
|
||||
IHandle<TrackImportedEvent>,
|
||||
IHandle<TrackedDownloadsRemovedEvent>
|
||||
|
||||
{
|
||||
|
@ -170,7 +170,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads
|
|||
_refreshDebounce.Execute();
|
||||
}
|
||||
|
||||
public void Handle(EpisodeImportedEvent message)
|
||||
public void Handle(TrackImportedEvent message)
|
||||
{
|
||||
_refreshDebounce.Execute();
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ namespace NzbDrone.Core.Download.TrackedDownloads
|
|||
public DownloadClientItem DownloadItem { get; set; }
|
||||
public TrackedDownloadStage State { get; set; }
|
||||
public TrackedDownloadStatus Status { get; private set; }
|
||||
public RemoteEpisode RemoteEpisode { get; set; }
|
||||
public RemoteAlbum RemoteAlbum { get; set; }
|
||||
public TrackedDownloadStatusMessage[] StatusMessages { get; private set; }
|
||||
public DownloadProtocol Protocol { get; set; }
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using NzbDrone.Common.EnsureThat;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.IndexerSearch.Definitions
|
||||
|
@ -14,12 +13,9 @@ namespace NzbDrone.Core.IndexerSearch.Definitions
|
|||
private static readonly Regex NonWord = new Regex(@"[\W]", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
private static readonly Regex BeginningThe = new Regex(@"^the\s", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
|
||||
[System.Obsolete("Sonarr TV Stuff -- Shouldn't be needed for Lidarr")]
|
||||
public Series Series { get; set; }
|
||||
[System.Obsolete("Sonarr TV Stuff -- Shouldn't be needed for Lidarr")]
|
||||
public List<string> SceneTitles { get; set; }
|
||||
[System.Obsolete("Sonarr TV Stuff -- Shouldn't be needed for Lidarr")]
|
||||
public List<Episode> Episodes { get; set; }
|
||||
|
||||
public virtual bool MonitoredEpisodesOnly { get; set; }
|
||||
public virtual bool UserInvokedSearch { get; set; }
|
||||
|
||||
|
@ -45,4 +41,4 @@ namespace NzbDrone.Core.IndexerSearch.Definitions
|
|||
return cleanTitle.Trim('+', ' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles.Events
|
||||
{
|
||||
public class EpisodeDownloadedEvent : IEvent
|
||||
{
|
||||
public LocalEpisode Episode { get; private set; }
|
||||
public EpisodeFile EpisodeFile { get; private set; }
|
||||
public List<EpisodeFile> OldFiles { get; private set; }
|
||||
|
||||
public EpisodeDownloadedEvent(LocalEpisode episode, EpisodeFile episodeFile, List<EpisodeFile> oldFiles)
|
||||
{
|
||||
Episode = episode;
|
||||
EpisodeFile = episodeFile;
|
||||
OldFiles = oldFiles;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
using NzbDrone.Common.Messaging;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles.Events
|
||||
{
|
||||
public class EpisodeFileAddedEvent : IEvent
|
||||
{
|
||||
public EpisodeFile EpisodeFile { get; private set; }
|
||||
|
||||
public EpisodeFileAddedEvent(EpisodeFile episodeFile)
|
||||
{
|
||||
EpisodeFile = episodeFile;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
using NzbDrone.Common.Messaging;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles.Events
|
||||
{
|
||||
public class EpisodeFileDeletedEvent : IEvent
|
||||
{
|
||||
public EpisodeFile EpisodeFile { get; private set; }
|
||||
public DeleteMediaFileReason Reason { get; private set; }
|
||||
|
||||
public EpisodeFileDeletedEvent(EpisodeFile episodeFile, DeleteMediaFileReason reason)
|
||||
{
|
||||
EpisodeFile = episodeFile;
|
||||
Reason = reason;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles.Events
|
||||
{
|
||||
public class EpisodeFolderCreatedEvent : IEvent
|
||||
{
|
||||
public Series Series { get; private set; }
|
||||
public EpisodeFile EpisodeFile { get; private set; }
|
||||
public string SeriesFolder { get; set; }
|
||||
public string SeasonFolder { get; set; }
|
||||
public string EpisodeFolder { get; set; }
|
||||
|
||||
public EpisodeFolderCreatedEvent(Series series, EpisodeFile episodeFile)
|
||||
{
|
||||
Series = series;
|
||||
EpisodeFile = episodeFile;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles.Events
|
||||
{
|
||||
public class EpisodeImportedEvent : IEvent
|
||||
{
|
||||
public LocalEpisode EpisodeInfo { get; private set; }
|
||||
public EpisodeFile ImportedEpisode { get; private set; }
|
||||
public bool NewDownload { get; private set; }
|
||||
public string DownloadClient { get; private set; }
|
||||
public string DownloadId { get; private set; }
|
||||
|
||||
public EpisodeImportedEvent(LocalEpisode episodeInfo, EpisodeFile importedEpisode, bool newDownload)
|
||||
{
|
||||
EpisodeInfo = episodeInfo;
|
||||
ImportedEpisode = importedEpisode;
|
||||
NewDownload = newDownload;
|
||||
}
|
||||
|
||||
public EpisodeImportedEvent(LocalEpisode episodeInfo, EpisodeFile importedEpisode, bool newDownload, string downloadClient, string downloadId)
|
||||
{
|
||||
EpisodeInfo = episodeInfo;
|
||||
ImportedEpisode = importedEpisode;
|
||||
NewDownload = newDownload;
|
||||
DownloadClient = downloadClient;
|
||||
DownloadId = downloadId;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles.Events
|
||||
{
|
||||
public class SeriesRenamedEvent : IEvent
|
||||
{
|
||||
public Series Series { get; private set; }
|
||||
|
||||
public SeriesRenamedEvent(Series series)
|
||||
{
|
||||
Series = series;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles.Events
|
||||
{
|
||||
public class SeriesScanSkippedEvent : IEvent
|
||||
{
|
||||
public Series Series { get; private set; }
|
||||
public SeriesScanSkippedReason Reason { get; set; }
|
||||
|
||||
public SeriesScanSkippedEvent(Series series, SeriesScanSkippedReason reason)
|
||||
{
|
||||
Series = series;
|
||||
Reason = reason;
|
||||
}
|
||||
}
|
||||
|
||||
public enum SeriesScanSkippedReason
|
||||
{
|
||||
RootFolderDoesNotExist,
|
||||
RootFolderIsEmpty
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles.Events
|
||||
{
|
||||
public class SeriesScannedEvent : IEvent
|
||||
{
|
||||
public Series Series { get; private set; }
|
||||
|
||||
public SeriesScannedEvent(Series series)
|
||||
{
|
||||
Series = series;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Tv;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -39,7 +38,7 @@ namespace NzbDrone.Core.Music
|
|||
public String AlbumType { get; set; } // TODO: Turn this into a type similar to Series Type in TV
|
||||
//public string ArtworkUrl { get; set; }
|
||||
//public string Explicitness { get; set; }
|
||||
public AddSeriesOptions AddOptions { get; set; }
|
||||
public AddArtistOptions AddOptions { get; set; }
|
||||
public Artist Artist { get; set; }
|
||||
public Ratings Ratings { get; set; }
|
||||
|
||||
|
|
|
@ -742,7 +742,6 @@
|
|||
<Compile Include="MediaFiles\Commands\CleanUpRecycleBinCommand.cs" />
|
||||
<Compile Include="MediaFiles\Commands\DownloadedAlbumsScanCommand.cs" />
|
||||
<Compile Include="MediaFiles\Commands\RenameArtistCommand.cs" />
|
||||
<Compile Include="MediaFiles\Events\EpisodeFolderCreatedEvent.cs" />
|
||||
<Compile Include="MediaFiles\Events\TrackFolderCreatedEvent.cs" />
|
||||
<Compile Include="MediaFiles\Events\TrackDownloadedEvent.cs" />
|
||||
<Compile Include="MediaFiles\MediaFileDeletionService.cs" />
|
||||
|
@ -778,14 +777,7 @@
|
|||
<Compile Include="MediaFiles\Events\ArtistRenamedEvent.cs" />
|
||||
<Compile Include="MediaFiles\Events\ArtistScannedEvent.cs" />
|
||||
<Compile Include="MediaFiles\Events\ArtistScanSkippedEvent.cs" />
|
||||
<Compile Include="MediaFiles\Events\EpisodeDownloadedEvent.cs" />
|
||||
<Compile Include="MediaFiles\Events\EpisodeFileAddedEvent.cs" />
|
||||
<Compile Include="MediaFiles\Events\EpisodeFileDeletedEvent.cs" />
|
||||
<Compile Include="MediaFiles\Events\EpisodeImportedEvent.cs" />
|
||||
<Compile Include="MediaFiles\Commands\RescanArtistCommand.cs" />
|
||||
<Compile Include="MediaFiles\Events\SeriesRenamedEvent.cs" />
|
||||
<Compile Include="MediaFiles\Events\SeriesScanSkippedEvent.cs" />
|
||||
<Compile Include="MediaFiles\Events\SeriesScannedEvent.cs" />
|
||||
<Compile Include="MediaFiles\Events\TrackFileAddedEvent.cs" />
|
||||
<Compile Include="MediaFiles\Events\TrackFileDeletedEvent.cs" />
|
||||
<Compile Include="MediaFiles\Events\TrackImportedEvent.cs" />
|
||||
|
@ -1180,7 +1172,6 @@
|
|||
<Compile Include="Tv\Season.cs" />
|
||||
<Compile Include="Tv\Series.cs" />
|
||||
<Compile Include="Tv\SeriesAddedHandler.cs" />
|
||||
<Compile Include="Tv\SeriesScannedHandler.cs" />
|
||||
<Compile Include="Tv\SeriesEditedService.cs" />
|
||||
<Compile Include="Tv\SeriesRepository.cs" />
|
||||
<Compile Include="Tv\SeriesService.cs">
|
||||
|
|
|
@ -7,7 +7,6 @@ using NzbDrone.Core.DataAugmentation.Scene;
|
|||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
using System;
|
||||
|
||||
|
@ -15,18 +14,11 @@ namespace NzbDrone.Core.Parser
|
|||
{
|
||||
public interface IParsingService
|
||||
{
|
||||
LocalEpisode GetLocalEpisode(string filename, Series series);
|
||||
LocalEpisode GetLocalEpisode(string filename, Series series, ParsedEpisodeInfo folderInfo, bool sceneSource);
|
||||
Series GetSeries(string title);
|
||||
Artist GetArtist(string title);
|
||||
Artist GetArtistFromTag(string file);
|
||||
RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria = null);
|
||||
RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, int seriesId, IEnumerable<int> episodeIds);
|
||||
RemoteAlbum Map(ParsedAlbumInfo parsedAlbumInfo, SearchCriteriaBase searchCriteria = null);
|
||||
RemoteAlbum Map(ParsedAlbumInfo parsedAlbumInfo, int artistId, IEnumerable<int> albumIds);
|
||||
List<Episode> GetEpisodes(ParsedEpisodeInfo parsedEpisodeInfo, Series series, bool sceneSource, SearchCriteriaBase searchCriteria = null);
|
||||
List<Album> GetAlbums(ParsedAlbumInfo parsedAlbumInfo, Artist artist, SearchCriteriaBase searchCriteria = null);
|
||||
ParsedEpisodeInfo ParseSpecialEpisodeTitle(string title, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria = null);
|
||||
|
||||
// Music stuff here
|
||||
LocalTrack GetLocalTrack(string filename, Artist artist);
|
||||
|
@ -36,23 +28,17 @@ namespace NzbDrone.Core.Parser
|
|||
|
||||
public class ParsingService : IParsingService
|
||||
{
|
||||
private readonly IEpisodeService _episodeService;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly IArtistService _artistService;
|
||||
private readonly IAlbumService _albumService;
|
||||
private readonly ITrackService _trackService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public ParsingService(IEpisodeService episodeService,
|
||||
ISeriesService seriesService,
|
||||
ITrackService trackService,
|
||||
public ParsingService(ITrackService trackService,
|
||||
IArtistService artistService,
|
||||
IAlbumService albumService,
|
||||
// ISceneMappingService sceneMappingService,
|
||||
Logger logger)
|
||||
{
|
||||
_episodeService = episodeService;
|
||||
_seriesService = seriesService;
|
||||
_albumService = albumService;
|
||||
_artistService = artistService;
|
||||
// _sceneMappingService = sceneMappingService;
|
||||
|
@ -60,84 +46,6 @@ namespace NzbDrone.Core.Parser
|
|||
_logger = logger;
|
||||
}
|
||||
|
||||
[System.Obsolete("Used for sonarr, not lidarr")]
|
||||
public LocalEpisode GetLocalEpisode(string filename, Series series)
|
||||
{
|
||||
return GetLocalEpisode(filename, series, null, false);
|
||||
}
|
||||
|
||||
[System.Obsolete("Used for sonarr, not lidarr")]
|
||||
public LocalEpisode GetLocalEpisode(string filename, Series series, ParsedEpisodeInfo folderInfo, bool sceneSource)
|
||||
{
|
||||
ParsedEpisodeInfo parsedEpisodeInfo;
|
||||
|
||||
if (folderInfo != null)
|
||||
{
|
||||
parsedEpisodeInfo = folderInfo.JsonClone();
|
||||
parsedEpisodeInfo.Quality = QualityParser.ParseQuality(Path.GetFileName(filename));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
parsedEpisodeInfo = Parser.ParsePath(filename);
|
||||
}
|
||||
|
||||
if (parsedEpisodeInfo == null || parsedEpisodeInfo.IsPossibleSpecialEpisode)
|
||||
{
|
||||
var title = Path.GetFileNameWithoutExtension(filename);
|
||||
var specialEpisodeInfo = ParseSpecialEpisodeTitle(title, series);
|
||||
|
||||
if (specialEpisodeInfo != null)
|
||||
{
|
||||
parsedEpisodeInfo = specialEpisodeInfo;
|
||||
}
|
||||
}
|
||||
|
||||
if (parsedEpisodeInfo == null)
|
||||
{
|
||||
if (MediaFileExtensions.Extensions.Contains(Path.GetExtension(filename)))
|
||||
{
|
||||
_logger.Warn("Unable to parse episode info from path {0}", filename);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
var episodes = GetEpisodes(parsedEpisodeInfo, series, sceneSource);
|
||||
|
||||
return new LocalEpisode
|
||||
{
|
||||
Series = series,
|
||||
Quality = parsedEpisodeInfo.Quality,
|
||||
Language = parsedEpisodeInfo.Language,
|
||||
Episodes = episodes,
|
||||
Path = filename,
|
||||
ParsedEpisodeInfo = parsedEpisodeInfo,
|
||||
ExistingFile = series.Path.IsParentPath(filename)
|
||||
};
|
||||
}
|
||||
|
||||
[System.Obsolete("Used for sonarr, not lidarr")]
|
||||
public Series GetSeries(string title)
|
||||
{
|
||||
var parsedEpisodeInfo = Parser.ParseTitle(title);
|
||||
|
||||
if (parsedEpisodeInfo == null)
|
||||
{
|
||||
return _seriesService.FindByTitle(title);
|
||||
}
|
||||
|
||||
var series = _seriesService.FindByTitle(parsedEpisodeInfo.SeriesTitle);
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
series = _seriesService.FindByTitle(parsedEpisodeInfo.SeriesTitleInfo.TitleWithoutYear,
|
||||
parsedEpisodeInfo.SeriesTitleInfo.Year);
|
||||
}
|
||||
|
||||
return series;
|
||||
}
|
||||
|
||||
public Artist GetArtist(string title)
|
||||
{
|
||||
var parsedAlbumInfo = Parser.ParseAlbumTitle(title);
|
||||
|
@ -176,27 +84,6 @@ namespace NzbDrone.Core.Parser
|
|||
|
||||
}
|
||||
|
||||
[System.Obsolete("Used for sonarr, not lidarr")]
|
||||
public RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria = null)
|
||||
{
|
||||
var remoteEpisode = new RemoteEpisode
|
||||
{
|
||||
ParsedEpisodeInfo = parsedEpisodeInfo,
|
||||
};
|
||||
|
||||
var series = GetSeries(parsedEpisodeInfo, tvdbId, tvRageId, searchCriteria);
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
return remoteEpisode;
|
||||
}
|
||||
|
||||
remoteEpisode.Series = series;
|
||||
remoteEpisode.Episodes = GetEpisodes(parsedEpisodeInfo, series, true, searchCriteria);
|
||||
|
||||
return remoteEpisode;
|
||||
}
|
||||
|
||||
public RemoteAlbum Map(ParsedAlbumInfo parsedAlbumInfo, SearchCriteriaBase searchCriteria = null)
|
||||
{
|
||||
var remoteAlbum = new RemoteAlbum
|
||||
|
@ -254,17 +141,6 @@ namespace NzbDrone.Core.Parser
|
|||
|
||||
}
|
||||
|
||||
[System.Obsolete("Used for sonarr, not lidarr")]
|
||||
public RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, int seriesId, IEnumerable<int> episodeIds)
|
||||
{
|
||||
return new RemoteEpisode
|
||||
{
|
||||
ParsedEpisodeInfo = parsedEpisodeInfo,
|
||||
Series = _seriesService.GetSeries(seriesId),
|
||||
Episodes = _episodeService.GetEpisodes(episodeIds)
|
||||
};
|
||||
}
|
||||
|
||||
public RemoteAlbum Map(ParsedAlbumInfo parsedAlbumInfo, int artistId, IEnumerable<int> albumIds)
|
||||
{
|
||||
return new RemoteAlbum
|
||||
|
@ -275,113 +151,6 @@ namespace NzbDrone.Core.Parser
|
|||
};
|
||||
}
|
||||
|
||||
[System.Obsolete("Used for sonarr, not lidarr")]
|
||||
public List<Episode> GetEpisodes(ParsedEpisodeInfo parsedEpisodeInfo, Series series, bool sceneSource, SearchCriteriaBase searchCriteria = null)
|
||||
{
|
||||
if (parsedEpisodeInfo.FullSeason)
|
||||
{
|
||||
return _episodeService.GetEpisodesBySeason(series.Id, parsedEpisodeInfo.SeasonNumber);
|
||||
}
|
||||
|
||||
if (parsedEpisodeInfo.IsDaily)
|
||||
{
|
||||
if (series.SeriesType == SeriesTypes.Standard)
|
||||
{
|
||||
_logger.Warn("Found daily-style episode for non-daily series: {0}.", series);
|
||||
return new List<Episode>();
|
||||
}
|
||||
|
||||
var episodeInfo = GetDailyEpisode(series, parsedEpisodeInfo.AirDate, searchCriteria);
|
||||
|
||||
if (episodeInfo != null)
|
||||
{
|
||||
return new List<Episode> { episodeInfo };
|
||||
}
|
||||
|
||||
return new List<Episode>();
|
||||
}
|
||||
|
||||
if (parsedEpisodeInfo.IsAbsoluteNumbering)
|
||||
{
|
||||
return GetAnimeEpisodes(series, parsedEpisodeInfo, sceneSource);
|
||||
}
|
||||
|
||||
return GetStandardEpisodes(series, parsedEpisodeInfo, sceneSource, searchCriteria);
|
||||
}
|
||||
|
||||
[System.Obsolete("Used for sonarr, not lidarr")]
|
||||
public ParsedEpisodeInfo ParseSpecialEpisodeTitle(string title, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria = null)
|
||||
{
|
||||
if (searchCriteria != null)
|
||||
{
|
||||
if (tvdbId == 0)
|
||||
tvdbId = 0; // _sceneMappingService.FindTvdbId(title) ?? 0;
|
||||
|
||||
if (tvdbId != 0 && tvdbId == searchCriteria.Series.TvdbId)
|
||||
{
|
||||
return ParseSpecialEpisodeTitle(title, searchCriteria.Series);
|
||||
}
|
||||
|
||||
if (tvRageId != 0 && tvRageId == searchCriteria.Series.TvRageId)
|
||||
{
|
||||
return ParseSpecialEpisodeTitle(title, searchCriteria.Series);
|
||||
}
|
||||
}
|
||||
|
||||
var series = GetSeries(title);
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
series = _seriesService.FindByTitleInexact(title);
|
||||
}
|
||||
|
||||
if (series == null && tvdbId > 0)
|
||||
{
|
||||
series = _seriesService.FindByTvdbId(tvdbId);
|
||||
}
|
||||
|
||||
if (series == null && tvRageId > 0)
|
||||
{
|
||||
series = _seriesService.FindByTvRageId(tvRageId);
|
||||
}
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
_logger.Debug("No matching series {0}", title);
|
||||
return null;
|
||||
}
|
||||
|
||||
return ParseSpecialEpisodeTitle(title, series);
|
||||
}
|
||||
|
||||
[System.Obsolete("Used for sonarr, not lidarr")]
|
||||
private ParsedEpisodeInfo ParseSpecialEpisodeTitle(string title, Series series)
|
||||
{
|
||||
// find special episode in series season 0
|
||||
var episode = _episodeService.FindEpisodeByTitle(series.Id, 0, title);
|
||||
|
||||
if (episode != null)
|
||||
{
|
||||
// create parsed info from tv episode
|
||||
var info = new ParsedEpisodeInfo();
|
||||
info.SeriesTitle = series.Title;
|
||||
info.SeriesTitleInfo = new SeriesTitleInfo();
|
||||
info.SeriesTitleInfo.Title = info.SeriesTitle;
|
||||
info.SeasonNumber = episode.SeasonNumber;
|
||||
info.EpisodeNumbers = new int[1] { episode.EpisodeNumber };
|
||||
info.FullSeason = false;
|
||||
info.Quality = QualityParser.ParseQuality(title);
|
||||
info.ReleaseGroup = Parser.ParseReleaseGroup(title);
|
||||
info.Language = LanguageParser.ParseLanguage(title);
|
||||
info.Special = true;
|
||||
|
||||
_logger.Debug("Found special episode {0} for title '{1}'", info, title);
|
||||
return info;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Artist GetArtist(ParsedAlbumInfo parsedAlbumInfo, SearchCriteriaBase searchCriteria)
|
||||
{
|
||||
Artist artist = null;
|
||||
|
@ -405,279 +174,6 @@ namespace NzbDrone.Core.Parser
|
|||
return artist;
|
||||
}
|
||||
|
||||
[System.Obsolete("Used for sonarr, not lidarr")]
|
||||
private Series GetSeries(ParsedEpisodeInfo parsedEpisodeInfo, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria)
|
||||
{
|
||||
Series series = null;
|
||||
|
||||
//var sceneMappingTvdbId = _sceneMappingService.FindTvdbId(parsedEpisodeInfo.SeriesTitle);
|
||||
//if (sceneMappingTvdbId.HasValue)
|
||||
//{
|
||||
// if (searchCriteria != null && searchCriteria.Series.TvdbId == sceneMappingTvdbId.Value)
|
||||
// {
|
||||
// return searchCriteria.Series;
|
||||
// }
|
||||
|
||||
// series = _seriesService.FindByTvdbId(sceneMappingTvdbId.Value);
|
||||
|
||||
// if (series == null)
|
||||
// {
|
||||
// _logger.Debug("No matching series {0}", parsedEpisodeInfo.SeriesTitle);
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// return series;
|
||||
//}
|
||||
|
||||
if (searchCriteria != null)
|
||||
{
|
||||
if (searchCriteria.Series.CleanTitle == parsedEpisodeInfo.SeriesTitle.CleanSeriesTitle())
|
||||
{
|
||||
return searchCriteria.Series;
|
||||
}
|
||||
|
||||
if (tvdbId > 0 && tvdbId == searchCriteria.Series.TvdbId)
|
||||
{
|
||||
//TODO: If series is found by TvdbId, we should report it as a scene naming exception, since it will fail to import
|
||||
return searchCriteria.Series;
|
||||
}
|
||||
|
||||
if (tvRageId > 0 && tvRageId == searchCriteria.Series.TvRageId)
|
||||
{
|
||||
//TODO: If series is found by TvRageId, we should report it as a scene naming exception, since it will fail to import
|
||||
return searchCriteria.Series;
|
||||
}
|
||||
}
|
||||
|
||||
series = _seriesService.FindByTitle(parsedEpisodeInfo.SeriesTitle);
|
||||
|
||||
if (series == null && parsedEpisodeInfo.SeriesTitleInfo.Year > 0)
|
||||
{
|
||||
series = _seriesService.FindByTitle(parsedEpisodeInfo.SeriesTitleInfo.TitleWithoutYear, parsedEpisodeInfo.SeriesTitleInfo.Year);
|
||||
}
|
||||
|
||||
if (series == null && tvdbId > 0)
|
||||
{
|
||||
//TODO: If series is found by TvdbId, we should report it as a scene naming exception, since it will fail to import
|
||||
series = _seriesService.FindByTvdbId(tvdbId);
|
||||
}
|
||||
|
||||
if (series == null && tvRageId > 0)
|
||||
{
|
||||
//TODO: If series is found by TvRageId, we should report it as a scene naming exception, since it will fail to import
|
||||
series = _seriesService.FindByTvRageId(tvRageId);
|
||||
}
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
_logger.Debug("No matching series {0}", parsedEpisodeInfo.SeriesTitle);
|
||||
return null;
|
||||
}
|
||||
|
||||
return series;
|
||||
}
|
||||
|
||||
[System.Obsolete("Used for sonarr, not lidarr")]
|
||||
private Episode GetDailyEpisode(Series series, string airDate, SearchCriteriaBase searchCriteria)
|
||||
{
|
||||
Episode episodeInfo = null;
|
||||
|
||||
if (searchCriteria != null)
|
||||
{
|
||||
episodeInfo = searchCriteria.Episodes.SingleOrDefault(
|
||||
e => e.AirDate == airDate);
|
||||
}
|
||||
|
||||
if (episodeInfo == null)
|
||||
{
|
||||
episodeInfo = _episodeService.FindEpisode(series.Id, airDate);
|
||||
}
|
||||
|
||||
return episodeInfo;
|
||||
}
|
||||
|
||||
[System.Obsolete("Used for sonarr, not lidarr")]
|
||||
private List<Episode> GetAnimeEpisodes(Series series, ParsedEpisodeInfo parsedEpisodeInfo, bool sceneSource)
|
||||
{
|
||||
var result = new List<Episode>();
|
||||
|
||||
// var sceneSeasonNumber = _sceneMappingService.GetSceneSeasonNumber(parsedEpisodeInfo.SeriesTitle);
|
||||
|
||||
foreach (var absoluteEpisodeNumber in parsedEpisodeInfo.AbsoluteEpisodeNumbers)
|
||||
{
|
||||
Episode episode = null;
|
||||
|
||||
if (parsedEpisodeInfo.Special)
|
||||
{
|
||||
episode = _episodeService.FindEpisode(series.Id, 0, absoluteEpisodeNumber);
|
||||
}
|
||||
|
||||
//else if (sceneSource)
|
||||
//{
|
||||
// // Is there a reason why we excluded season 1 from this handling before?
|
||||
// // Might have something to do with the scene name to season number check
|
||||
// // If this needs to be reverted tests will need to be added
|
||||
// if (sceneSeasonNumber.HasValue)
|
||||
// {
|
||||
// var episodes = _episodeService.FindEpisodesBySceneNumbering(series.Id, sceneSeasonNumber.Value, absoluteEpisodeNumber);
|
||||
|
||||
// if (episodes.Count == 1)
|
||||
// {
|
||||
// episode = episodes.First();
|
||||
// }
|
||||
|
||||
// if (episode == null)
|
||||
// {
|
||||
// episode = _episodeService.FindEpisode(series.Id, sceneSeasonNumber.Value, absoluteEpisodeNumber);
|
||||
// }
|
||||
// }
|
||||
|
||||
// else
|
||||
// {
|
||||
// episode = _episodeService.FindEpisodeBySceneNumbering(series.Id, absoluteEpisodeNumber);
|
||||
// }
|
||||
//}
|
||||
|
||||
if (episode == null)
|
||||
{
|
||||
episode = _episodeService.FindEpisode(series.Id, absoluteEpisodeNumber);
|
||||
}
|
||||
|
||||
if (episode != null)
|
||||
{
|
||||
_logger.Debug("Using absolute episode number {0} for: {1} - TVDB: {2}x{3:00}",
|
||||
absoluteEpisodeNumber,
|
||||
series.Title,
|
||||
episode.SeasonNumber,
|
||||
episode.EpisodeNumber);
|
||||
|
||||
result.Add(episode);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//private List<Track> GetStandardTracks(Artist artist, ParsedTrackInfo parsedTrackInfo, SearchCriteriaBase searchCriteria)
|
||||
//{
|
||||
// var result = new List<Track>();
|
||||
|
||||
// if (parsedTrackInfo.TrackNumbers == null)
|
||||
// {
|
||||
// return result;
|
||||
// }
|
||||
|
||||
// foreach (var trackNumber in parsedTrackInfo.TrackNumbers)
|
||||
// {
|
||||
// Track trackInfo = null;
|
||||
|
||||
// if (searchCriteria != null)
|
||||
// {
|
||||
// trackInfo = searchCriteria.Tracks.SingleOrDefault(e => e.TrackNumber == trackNumber); //e => e.SeasonNumber == seasonNumber && e.TrackNumber == trackNumber
|
||||
// }
|
||||
|
||||
// if (trackInfo == null)
|
||||
// {
|
||||
// // TODO: [ParsingService]: FindTrack by artistID and trackNumber (or albumID and trackNumber if we change db schema to album as base)
|
||||
// _logger.Debug("TrackInfo is null, we will not add as FindTrack(artistId, trackNumber) is not implemented");
|
||||
// //trackInfo = _trackService.FindTrack(artist.SpotifyId, trackNumber);
|
||||
// }
|
||||
|
||||
// if (trackInfo != null)
|
||||
// {
|
||||
// result.Add(trackInfo);
|
||||
// }
|
||||
|
||||
// else
|
||||
// {
|
||||
// _logger.Debug("Unable to find {0}", parsedTrackInfo);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// return result;
|
||||
//}
|
||||
|
||||
[System.Obsolete("Used for sonarr, not lidarr")]
|
||||
private List<Episode> GetStandardEpisodes(Series series, ParsedEpisodeInfo parsedEpisodeInfo, bool sceneSource, SearchCriteriaBase searchCriteria)
|
||||
{
|
||||
var result = new List<Episode>();
|
||||
var seasonNumber = parsedEpisodeInfo.SeasonNumber;
|
||||
|
||||
//if (sceneSource)
|
||||
//{
|
||||
// var sceneMapping = _sceneMappingService.FindSceneMapping(parsedEpisodeInfo.SeriesTitle);
|
||||
|
||||
// if (sceneMapping != null && sceneMapping.SeasonNumber.HasValue && sceneMapping.SeasonNumber.Value >= 0 &&
|
||||
// sceneMapping.SceneSeasonNumber == seasonNumber)
|
||||
// {
|
||||
// seasonNumber = sceneMapping.SeasonNumber.Value;
|
||||
// }
|
||||
//}
|
||||
|
||||
if (parsedEpisodeInfo.EpisodeNumbers == null)
|
||||
{
|
||||
return new List<Episode>();
|
||||
}
|
||||
|
||||
foreach (var episodeNumber in parsedEpisodeInfo.EpisodeNumbers)
|
||||
{
|
||||
if (series.UseSceneNumbering && sceneSource)
|
||||
{
|
||||
List<Episode> episodes = new List<Episode>();
|
||||
|
||||
if (searchCriteria != null)
|
||||
{
|
||||
episodes = searchCriteria.Episodes.Where(e => e.SceneSeasonNumber == parsedEpisodeInfo.SeasonNumber &&
|
||||
e.SceneEpisodeNumber == episodeNumber).ToList();
|
||||
}
|
||||
|
||||
if (!episodes.Any())
|
||||
{
|
||||
episodes = _episodeService.FindEpisodesBySceneNumbering(series.Id, seasonNumber, episodeNumber);
|
||||
}
|
||||
|
||||
if (episodes != null && episodes.Any())
|
||||
{
|
||||
_logger.Debug("Using Scene to TVDB Mapping for: {0} - Scene: {1}x{2:00} - TVDB: {3}",
|
||||
series.Title,
|
||||
episodes.First().SceneSeasonNumber,
|
||||
episodes.First().SceneEpisodeNumber,
|
||||
string.Join(", ", episodes.Select(e => string.Format("{0}x{1:00}", e.SeasonNumber, e.EpisodeNumber))));
|
||||
|
||||
result.AddRange(episodes);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Episode episodeInfo = null;
|
||||
|
||||
if (searchCriteria != null)
|
||||
{
|
||||
episodeInfo = searchCriteria.Episodes.SingleOrDefault(e => e.SeasonNumber == seasonNumber && e.EpisodeNumber == episodeNumber);
|
||||
}
|
||||
|
||||
if (episodeInfo == null)
|
||||
{
|
||||
episodeInfo = _episodeService.FindEpisode(series.Id, seasonNumber, episodeNumber);
|
||||
}
|
||||
|
||||
if (episodeInfo != null)
|
||||
{
|
||||
result.Add(episodeInfo);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
_logger.Debug("Unable to find {0}", parsedEpisodeInfo);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public LocalTrack GetLocalTrack(string filename, Artist artist)
|
||||
{
|
||||
return GetLocalTrack(filename, artist, null);
|
||||
|
|
|
@ -39,8 +39,8 @@ namespace NzbDrone.Core.Tv
|
|||
}
|
||||
|
||||
public class EpisodeService : IEpisodeService,
|
||||
IHandle<EpisodeFileDeletedEvent>,
|
||||
IHandle<EpisodeFileAddedEvent>,
|
||||
//IHandle<EpisodeFileDeletedEvent>,
|
||||
//IHandle<EpisodeFileAddedEvent>,
|
||||
IHandleAsync<SeriesDeletedEvent>
|
||||
{
|
||||
private readonly IEpisodeRepository _episodeRepository;
|
||||
|
@ -203,29 +203,29 @@ namespace NzbDrone.Core.Tv
|
|||
_episodeRepository.DeleteMany(episodes);
|
||||
}
|
||||
|
||||
public void Handle(EpisodeFileDeletedEvent message)
|
||||
{
|
||||
foreach (var episode in GetEpisodesByFileId(message.EpisodeFile.Id))
|
||||
{
|
||||
_logger.Debug("Detaching episode {0} from file.", episode.Id);
|
||||
episode.EpisodeFileId = 0;
|
||||
//public void Handle(EpisodeFileDeletedEvent message)
|
||||
//{
|
||||
// foreach (var episode in GetEpisodesByFileId(message.EpisodeFile.Id))
|
||||
// {
|
||||
// _logger.Debug("Detaching episode {0} from file.", episode.Id);
|
||||
// episode.EpisodeFileId = 0;
|
||||
|
||||
if (message.Reason != DeleteMediaFileReason.Upgrade && _configService.AutoUnmonitorPreviouslyDownloadedTracks)
|
||||
{
|
||||
episode.Monitored = false;
|
||||
}
|
||||
// if (message.Reason != DeleteMediaFileReason.Upgrade && _configService.AutoUnmonitorPreviouslyDownloadedTracks)
|
||||
// {
|
||||
// episode.Monitored = false;
|
||||
// }
|
||||
|
||||
UpdateEpisode(episode);
|
||||
}
|
||||
}
|
||||
// UpdateEpisode(episode);
|
||||
// }
|
||||
//}
|
||||
|
||||
public void Handle(EpisodeFileAddedEvent message)
|
||||
{
|
||||
foreach (var episode in message.EpisodeFile.Episodes.Value)
|
||||
{
|
||||
_episodeRepository.SetFileId(episode.Id, message.EpisodeFile.Id);
|
||||
_logger.Debug("Linking [{0}] > [{1}]", message.EpisodeFile.RelativePath, episode);
|
||||
}
|
||||
}
|
||||
//public void Handle(EpisodeFileAddedEvent message)
|
||||
//{
|
||||
// foreach (var episode in message.EpisodeFile.Episodes.Value)
|
||||
// {
|
||||
// _episodeRepository.SetFileId(episode.Id, message.EpisodeFile.Id);
|
||||
// _logger.Debug("Linking [{0}] > [{1}]", message.EpisodeFile.RelativePath, episode);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
using NLog;
|
||||
using NzbDrone.Core.IndexerSearch;
|
||||
using NzbDrone.Core.MediaFiles.Events;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
|
||||
namespace NzbDrone.Core.Tv
|
||||
{
|
||||
public class SeriesScannedHandler : IHandle<SeriesScannedEvent>,
|
||||
IHandle<SeriesScanSkippedEvent>
|
||||
{
|
||||
private readonly IEpisodeMonitoredService _episodeMonitoredService;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly IManageCommandQueue _commandQueueManager;
|
||||
private readonly IEpisodeAddedService _episodeAddedService;
|
||||
|
||||
private readonly Logger _logger;
|
||||
|
||||
public SeriesScannedHandler(IEpisodeMonitoredService episodeMonitoredService,
|
||||
ISeriesService seriesService,
|
||||
IManageCommandQueue commandQueueManager,
|
||||
IEpisodeAddedService episodeAddedService,
|
||||
Logger logger)
|
||||
{
|
||||
_episodeMonitoredService = episodeMonitoredService;
|
||||
_seriesService = seriesService;
|
||||
_commandQueueManager = commandQueueManager;
|
||||
_episodeAddedService = episodeAddedService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
private void HandleScanEvents(Series series)
|
||||
{
|
||||
if (series.AddOptions == null)
|
||||
{
|
||||
_episodeAddedService.SearchForRecentlyAdded(series.Id);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.Info("[{0}] was recently added, performing post-add actions", series.Title);
|
||||
_episodeMonitoredService.SetEpisodeMonitoredStatus(series, series.AddOptions);
|
||||
|
||||
if (series.AddOptions.SearchForMissingEpisodes)
|
||||
{
|
||||
_commandQueueManager.Push(new MissingAlbumSearchCommand(series.Id));
|
||||
}
|
||||
|
||||
series.AddOptions = null;
|
||||
_seriesService.RemoveAddOptions(series);
|
||||
}
|
||||
|
||||
public void Handle(SeriesScannedEvent message)
|
||||
{
|
||||
HandleScanEvents(message.Series);
|
||||
}
|
||||
|
||||
public void Handle(SeriesScanSkippedEvent message)
|
||||
{
|
||||
HandleScanEvents(message.Series);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue