diff --git a/frontend/src/Commands/commandNames.js b/frontend/src/Commands/commandNames.js index c5159daa5..8ac47fbac 100644 --- a/frontend/src/Commands/commandNames.js +++ b/frontend/src/Commands/commandNames.js @@ -3,21 +3,21 @@ export const BACKUP = 'Backup'; export const REFRESH_MONITORED_DOWNLOADS = 'RefreshMonitoredDownloads'; export const CLEAR_BLACKLIST = 'ClearBlacklist'; export const CLEAR_LOGS = 'ClearLog'; -export const CUTOFF_UNMET_ALBUM_SEARCH = 'CutoffUnmetAlbumSearch'; +export const CUTOFF_UNMET_ALBUM_SEARCH = 'CutoffUnmetBookSearch'; export const DELETE_LOG_FILES = 'DeleteLogFiles'; export const DELETE_UPDATE_LOG_FILES = 'DeleteUpdateLogFiles'; -export const DOWNLOADED_ALBUMS_SCAN = 'DownloadedAlbumsScan'; +export const DOWNLOADED_ALBUMS_SCAN = 'DownloadedBooksScan'; export const ALBUM_SEARCH = 'AlbumSearch'; export const INTERACTIVE_IMPORT = 'ManualImport'; -export const MISSING_ALBUM_SEARCH = 'MissingAlbumSearch'; -export const MOVE_ARTIST = 'MoveArtist'; -export const REFRESH_ARTIST = 'RefreshArtist'; +export const MISSING_ALBUM_SEARCH = 'MissingBookSearch'; +export const MOVE_ARTIST = 'MoveAuthor'; +export const REFRESH_ARTIST = 'RefreshAuthor'; export const RENAME_FILES = 'RenameFiles'; -export const RENAME_ARTIST = 'RenameArtist'; +export const RENAME_ARTIST = 'RenameAuthor'; export const RESCAN_FOLDERS = 'RescanFolders'; export const RETAG_FILES = 'RetagFiles'; -export const RETAG_ARTIST = 'RetagArtist'; +export const RETAG_ARTIST = 'RetagAuthor'; export const RESET_API_KEY = 'ResetApiKey'; export const RSS_SYNC = 'RssSync'; -export const SEASON_SEARCH = 'AlbumSearch'; -export const ARTIST_SEARCH = 'ArtistSearch'; +export const SEASON_SEARCH = 'BookSearch'; +export const ARTIST_SEARCH = 'AuthorSearch'; diff --git a/frontend/src/Organize/OrganizePreviewModalContentConnector.js b/frontend/src/Organize/OrganizePreviewModalContentConnector.js index 3e06ded42..ee6de407f 100644 --- a/frontend/src/Organize/OrganizePreviewModalContentConnector.js +++ b/frontend/src/Organize/OrganizePreviewModalContentConnector.js @@ -19,7 +19,7 @@ function createMapStateToProps() { props.isFetching = organizePreview.isFetching || naming.isFetching; props.isPopulated = organizePreview.isPopulated && naming.isPopulated; props.error = organizePreview.error || naming.error; - props.trackFormat = naming.item.standardTrackFormat; + props.trackFormat = naming.item.standardBookFormat; props.path = artist.path; return props; diff --git a/frontend/src/Settings/MediaManagement/Naming/Naming.js b/frontend/src/Settings/MediaManagement/Naming/Naming.js index c848f267c..c74998440 100644 --- a/frontend/src/Settings/MediaManagement/Naming/Naming.js +++ b/frontend/src/Settings/MediaManagement/Naming/Naming.js @@ -32,7 +32,7 @@ class Naming extends Component { this.setState({ isNamingModalOpen: true, namingModalOptions: { - name: 'standardTrackFormat', + name: 'standardBookFormat', album: true, track: true, additional: true @@ -40,11 +40,11 @@ class Naming extends Component { }); } - onArtistFolderNamingModalOpenClick = () => { + onAuthorFolderNamingModalOpenClick = () => { this.setState({ isNamingModalOpen: true, namingModalOptions: { - name: 'artistFolderFormat' + name: 'authorFolderFormat' } }); } @@ -73,24 +73,24 @@ class Naming extends Component { namingModalOptions } = this.state; - const renameTracks = hasSettings && settings.renameTracks.value; + const renameBooks = hasSettings && settings.renameBooks.value; - const standardTrackFormatHelpTexts = []; - const standardTrackFormatErrors = []; - const artistFolderFormatHelpTexts = []; - const artistFolderFormatErrors = []; + const standardBookFormatHelpTexts = []; + const standardBookFormatErrors = []; + const authorFolderFormatHelpTexts = []; + const authorFolderFormatErrors = []; if (examplesPopulated) { if (examples.singleTrackExample) { - standardTrackFormatHelpTexts.push(`Single Track: ${examples.singleTrackExample}`); + standardBookFormatHelpTexts.push(`Single Track: ${examples.singleTrackExample}`); } else { - standardTrackFormatErrors.push({ message: 'Single Track: Invalid Format' }); + standardBookFormatErrors.push({ message: 'Single Track: Invalid Format' }); } if (examples.artistFolderExample) { - artistFolderFormatHelpTexts.push(`Example: ${examples.artistFolderExample}`); + authorFolderFormatHelpTexts.push(`Example: ${examples.artistFolderExample}`); } else { - artistFolderFormatErrors.push({ message: 'Invalid Format' }); + authorFolderFormatErrors.push({ message: 'Invalid Format' }); } } @@ -114,10 +114,10 @@ class Naming extends Component { @@ -134,20 +134,20 @@ class Naming extends Component { { - renameTracks && + renameBooks &&
- Standard Track Format + Standard Book Format ?} onChange={onInputChange} - {...settings.standardTrackFormat} - helpTexts={standardTrackFormatHelpTexts} - errors={[...standardTrackFormatErrors, ...settings.standardTrackFormat.errors]} + {...settings.standardBookFormat} + helpTexts={standardBookFormatHelpTexts} + errors={[...standardBookFormatErrors, ...settings.standardBookFormat.errors]} />
@@ -162,12 +162,12 @@ class Naming extends Component { ?} + name="authorFolderFormat" + buttons={?} onChange={onInputChange} - {...settings.artistFolderFormat} - helpTexts={['Used when adding a new artist or moving an artist via the artist editor', ...artistFolderFormatHelpTexts]} - errors={[...artistFolderFormatErrors, ...settings.artistFolderFormat.errors]} + {...settings.authorFolderFormat} + helpTexts={['Used when adding a new artist or moving an author via the author editor', ...authorFolderFormatHelpTexts]} + errors={[...authorFolderFormatErrors, ...settings.authorFolderFormat.errors]} /> diff --git a/frontend/src/Settings/MediaManagement/Naming/NamingModal.js b/frontend/src/Settings/MediaManagement/Naming/NamingModal.js index f96d364e6..1360c4e10 100644 --- a/frontend/src/Settings/MediaManagement/Naming/NamingModal.js +++ b/frontend/src/Settings/MediaManagement/Naming/NamingModal.js @@ -28,35 +28,35 @@ const caseOptions = [ const fileNameTokens = [ { - token: '{Artist Name} - {Album Title} - {track:00} - {Track Title} {Quality Full}', - example: 'Artist Name - Album Title - 01 - Track Title MP3-320 Proper' + token: '{Author Name} - {Book Title} - {track:00} - {Track Title} {Quality Full}', + example: 'Author Name - Book Title - 01 - Track Title MP3-320 Proper' }, { - token: '{Artist.Name}.{Album.Title}.{track:00}.{TrackClean.Title}.{Quality.Full}', - example: 'Artist.Name.Album.Title.01.Track.Title.MP3-320' + token: '{Author.Name}.{Book.Title}.{track:00}.{TrackClean.Title}.{Quality.Full}', + example: 'Author.Name.Book.Title.01.Track.Title.MP3-320' } ]; const artistTokens = [ - { token: '{Artist Name}', example: 'Artist Name' }, + { token: '{Author Name}', example: 'Author Name' }, - { token: '{Artist NameThe}', example: 'Artist Name, The' }, + { token: '{Author NameThe}', example: 'Author Name, The' }, - { token: '{Artist CleanName}', example: 'Artist Name' }, + { token: '{Author CleanName}', example: 'Author Name' }, - { token: '{Artist Disambiguation}', example: 'Disambiguation' } + { token: '{Author Disambiguation}', example: 'Disambiguation' } ]; const albumTokens = [ - { token: '{Album Title}', example: 'Album Title' }, + { token: '{Book Title}', example: 'Book Title' }, - { token: '{Album TitleThe}', example: 'Album Title, The' }, + { token: '{Book TitleThe}', example: 'Book Title, The' }, - { token: '{Album CleanTitle}', example: 'Album Title' }, + { token: '{Book CleanTitle}', example: 'Book Title' }, - { token: '{Album Type}', example: 'Album Type' }, + { token: '{Book Type}', example: 'Book Type' }, - { token: '{Album Disambiguation}', example: 'Disambiguation' } + { token: '{Book Disambiguation}', example: 'Disambiguation' } ]; const mediumTokens = [ @@ -101,7 +101,7 @@ const otherTokens = [ ]; const originalTokens = [ - { token: '{Original Title}', example: 'Artist.Name.Album.Name.2018.FLAC-EVOLVE' }, + { token: '{Original Title}', example: 'Author.Name.Book.Name.2018.FLAC-EVOLVE' }, { token: '{Original Filename}', example: '01 - track name' } ]; @@ -243,7 +243,7 @@ class NamingModal extends Component { } -
+
{ artistTokens.map(({ token, example }) => { @@ -268,7 +268,7 @@ class NamingModal extends Component { { album &&
-
+
{ albumTokens.map(({ token, example }) => { diff --git a/src/NzbDrone.Core.Test/ArtistStatsTests/ArtistStatisticsFixture.cs b/src/NzbDrone.Core.Test/ArtistStatsTests/ArtistStatisticsFixture.cs index 7c5d8a0a9..e0ab1d989 100644 --- a/src/NzbDrone.Core.Test/ArtistStatsTests/ArtistStatisticsFixture.cs +++ b/src/NzbDrone.Core.Test/ArtistStatsTests/ArtistStatisticsFixture.cs @@ -3,16 +3,16 @@ using System.Linq; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; -using NzbDrone.Core.ArtistStats; +using NzbDrone.Core.AuthorStats; +using NzbDrone.Core.Books; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.ArtistStatsTests { [TestFixture] - public class ArtistStatisticsFixture : DbTest + public class ArtistStatisticsFixture : DbTest { private Author _artist; private Book _album; @@ -33,8 +33,8 @@ namespace NzbDrone.Core.Test.ArtistStatsTests Db.Insert(_album); _trackFile = Builder.CreateNew() - .With(e => e.Artist = _artist) - .With(e => e.Album = _album) + .With(e => e.Author = _artist) + .With(e => e.Book = _album) .With(e => e.BookId == _album.Id) .With(e => e.Quality = new QualityModel(Quality.MP3_320)) .BuildNew(); @@ -48,7 +48,7 @@ namespace NzbDrone.Core.Test.ArtistStatsTests [Test] public void should_get_stats_for_artist() { - var stats = Subject.ArtistStatistics(); + var stats = Subject.AuthorStatistics(); stats.Should().HaveCount(1); } @@ -56,10 +56,10 @@ namespace NzbDrone.Core.Test.ArtistStatsTests [Test] public void should_not_include_unmonitored_track_in_track_count() { - var stats = Subject.ArtistStatistics(); + var stats = Subject.AuthorStatistics(); stats.Should().HaveCount(1); - stats.First().TrackCount.Should().Be(0); + stats.First().BookCount.Should().Be(0); } [Test] @@ -67,16 +67,16 @@ namespace NzbDrone.Core.Test.ArtistStatsTests { GivenTrackFile(); - var stats = Subject.ArtistStatistics(); + var stats = Subject.AuthorStatistics(); stats.Should().HaveCount(1); - stats.First().TrackCount.Should().Be(1); + stats.First().BookCount.Should().Be(1); } [Test] public void should_have_size_on_disk_of_zero_when_no_track_file() { - var stats = Subject.ArtistStatistics(); + var stats = Subject.AuthorStatistics(); stats.Should().HaveCount(1); stats.First().SizeOnDisk.Should().Be(0); @@ -87,7 +87,7 @@ namespace NzbDrone.Core.Test.ArtistStatsTests { GivenTrackFile(); - var stats = Subject.ArtistStatistics(); + var stats = Subject.AuthorStatistics(); stats.Should().HaveCount(1); stats.First().SizeOnDisk.Should().Be(_trackFile.Size); diff --git a/src/NzbDrone.Core.Test/Datastore/Converters/CommandConverterFixture.cs b/src/NzbDrone.Core.Test/Datastore/Converters/CommandConverterFixture.cs index 08f6b85ac..633b92ce3 100644 --- a/src/NzbDrone.Core.Test/Datastore/Converters/CommandConverterFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/Converters/CommandConverterFixture.cs @@ -1,8 +1,8 @@ using System.Data.SQLite; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books.Commands; using NzbDrone.Core.Datastore.Converters; -using NzbDrone.Core.Music.Commands; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.Datastore.Converters @@ -21,7 +21,7 @@ namespace NzbDrone.Core.Test.Datastore.Converters [Test] public void should_return_json_string_when_saving_boolean_to_db() { - var command = new RefreshArtistCommand(); + var command = new RefreshAuthorCommand(); Subject.SetValue(_param, command); _param.Value.Should().BeOfType(); @@ -37,9 +37,9 @@ namespace NzbDrone.Core.Test.Datastore.Converters [Test] public void should_return_command_when_getting_json_from_db() { - var data = "{\"name\": \"RefreshArtist\"}"; + var data = "{\"name\": \"RefreshAuthor\"}"; - Subject.Parse(data).Should().BeOfType(); + Subject.Parse(data).Should().BeOfType(); } [Test] diff --git a/src/NzbDrone.Core.Test/Datastore/DatabaseFixture.cs b/src/NzbDrone.Core.Test/Datastore/DatabaseFixture.cs index c444751bd..52d6a5040 100644 --- a/src/NzbDrone.Core.Test/Datastore/DatabaseFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/DatabaseFixture.cs @@ -3,8 +3,8 @@ using System.Linq; using Dapper; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; -using NzbDrone.Core.Music; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.Datastore diff --git a/src/NzbDrone.Core.Test/Datastore/DatabaseRelationshipFixture.cs b/src/NzbDrone.Core.Test/Datastore/DatabaseRelationshipFixture.cs index 62fc6a4c7..4e4903c7f 100644 --- a/src/NzbDrone.Core.Test/Datastore/DatabaseRelationshipFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/DatabaseRelationshipFixture.cs @@ -3,7 +3,7 @@ using System.Linq; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; diff --git a/src/NzbDrone.Core.Test/Datastore/LazyLoadingFixture.cs b/src/NzbDrone.Core.Test/Datastore/LazyLoadingFixture.cs index f111c4cc8..5afd1eabd 100644 --- a/src/NzbDrone.Core.Test/Datastore/LazyLoadingFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/LazyLoadingFixture.cs @@ -3,9 +3,9 @@ using System.Linq; using Dapper; using FizzWare.NBuilder; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Profiles.Qualities; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; @@ -70,10 +70,10 @@ namespace NzbDrone.Core.Test.Datastore Assert.IsNotEmpty(tracks); foreach (var track in tracks) { - Assert.IsFalse(track.Artist.IsLoaded); - Assert.IsNotNull(track.Artist.Value); - Assert.IsTrue(track.Artist.IsLoaded); - Assert.IsTrue(track.Artist.Value.Metadata.IsLoaded); + Assert.IsFalse(track.Author.IsLoaded); + Assert.IsNotNull(track.Author.Value); + Assert.IsTrue(track.Author.IsLoaded); + Assert.IsTrue(track.Author.Value.Metadata.IsLoaded); } } @@ -104,9 +104,9 @@ namespace NzbDrone.Core.Test.Datastore Assert.IsNotEmpty(files); foreach (var file in files) { - Assert.IsTrue(file.Album.IsLoaded); - Assert.IsTrue(file.Artist.IsLoaded); - Assert.IsTrue(file.Artist.Value.Metadata.IsLoaded); + Assert.IsTrue(file.Book.IsLoaded); + Assert.IsTrue(file.Author.IsLoaded); + Assert.IsTrue(file.Author.Value.Metadata.IsLoaded); } } @@ -121,18 +121,18 @@ namespace NzbDrone.Core.Test.Datastore .Join((a, m) => a.AuthorMetadataId == m.Id), (file, album, artist, metadata) => { - file.Album = album; - file.Artist = artist; - file.Artist.Value.Metadata = metadata; + file.Book = album; + file.Author = artist; + file.Author.Value.Metadata = metadata; return file; }); Assert.IsNotEmpty(files); foreach (var file in files) { - Assert.IsTrue(file.Album.IsLoaded); - Assert.IsTrue(file.Artist.IsLoaded); - Assert.IsTrue(file.Artist.Value.Metadata.IsLoaded); + Assert.IsTrue(file.Book.IsLoaded); + Assert.IsTrue(file.Author.IsLoaded); + Assert.IsTrue(file.Author.Value.Metadata.IsLoaded); } } } diff --git a/src/NzbDrone.Core.Test/Datastore/TableMapperFixture.cs b/src/NzbDrone.Core.Test/Datastore/TableMapperFixture.cs index 9e94272a7..72660d1bb 100644 --- a/src/NzbDrone.Core.Test/Datastore/TableMapperFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/TableMapperFixture.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using Dapper; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore.Converters; -using NzbDrone.Core.Music; namespace NzbDrone.Core.Test.Datastore { diff --git a/src/NzbDrone.Core.Test/Datastore/WhereBuilderFixture.cs b/src/NzbDrone.Core.Test/Datastore/WhereBuilderFixture.cs index 402cf3a99..98ba39621 100644 --- a/src/NzbDrone.Core.Test/Datastore/WhereBuilderFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/WhereBuilderFixture.cs @@ -4,8 +4,8 @@ using System.Linq; using System.Linq.Expressions; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; -using NzbDrone.Core.Music; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.Datastore @@ -177,7 +177,7 @@ namespace NzbDrone.Core.Test.Datastore [Test] public void enum_as_int() { - _subject = WhereMetadata(x => x.Status == ArtistStatusType.Continuing); + _subject = WhereMetadata(x => x.Status == AuthorStatusType.Continuing); _subject.ToString().Should().Be($"(\"AuthorMetadata\".\"Status\" = @Clause1_P1)"); } @@ -185,7 +185,7 @@ namespace NzbDrone.Core.Test.Datastore [Test] public void enum_in_list() { - var allowed = new List { ArtistStatusType.Continuing, ArtistStatusType.Ended }; + var allowed = new List { AuthorStatusType.Continuing, AuthorStatusType.Ended }; _subject = WhereMetadata(x => allowed.Contains(x.Status)); _subject.ToString().Should().Be($"(\"AuthorMetadata\".\"Status\" IN @Clause1_P1)"); @@ -194,7 +194,7 @@ namespace NzbDrone.Core.Test.Datastore [Test] public void enum_in_array() { - var allowed = new ArtistStatusType[] { ArtistStatusType.Continuing, ArtistStatusType.Ended }; + var allowed = new AuthorStatusType[] { AuthorStatusType.Continuing, AuthorStatusType.Ended }; _subject = WhereMetadata(x => allowed.Contains(x.Status)); _subject.ToString().Should().Be($"(\"AuthorMetadata\".\"Status\" IN @Clause1_P1)"); diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/AlreadyImportedSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/AlreadyImportedSpecificationFixture.cs index 104ac354b..5677f785d 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/AlreadyImportedSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/AlreadyImportedSpecificationFixture.cs @@ -4,12 +4,12 @@ using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.History; using NzbDrone.Core.Indexers; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; @@ -25,7 +25,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests private Author _artist; private QualityModel _mp3; private QualityModel _flac; - private RemoteAlbum _remoteAlbum; + private RemoteBook _remoteAlbum; private List _history; private BookFile _firstFile; @@ -49,11 +49,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests _mp3 = new QualityModel(Quality.MP3_320, new Revision(version: 1)); _flac = new QualityModel(Quality.FLAC, new Revision(version: 1)); - _remoteAlbum = new RemoteAlbum + _remoteAlbum = new RemoteBook { - Artist = _artist, - ParsedAlbumInfo = new ParsedAlbumInfo { Quality = _mp3 }, - Albums = singleAlbumList, + Author = _artist, + ParsedBookInfo = new ParsedBookInfo { Quality = _mp3 }, + Books = singleAlbumList, Release = Builder.CreateNew() .Build() }; @@ -65,11 +65,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests .Returns(true); Mocker.GetMock() - .Setup(s => s.GetByAlbum(It.IsAny(), null)) + .Setup(s => s.GetByBook(It.IsAny(), null)) .Returns(_history); Mocker.GetMock() - .Setup(c => c.GetFilesByAlbum(It.IsAny())) + .Setup(c => c.GetFilesByBook(It.IsAny())) .Returns(new List { _firstFile }); } @@ -104,7 +104,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void should_be_accepted_if_album_does_not_have_a_file() { Mocker.GetMock() - .Setup(c => c.GetFilesByAlbum(It.IsAny())) + .Setup(c => c.GetFilesByBook(It.IsAny())) .Returns(new List { }); Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/BlockedIndexerSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/BlockedIndexerSpecificationFixture.cs index e5f872c0d..15b9c6b05 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/BlockedIndexerSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/BlockedIndexerSpecificationFixture.cs @@ -14,12 +14,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class BlockedIndexerSpecificationFixture : CoreTest { - private RemoteAlbum _remoteAlbum; + private RemoteBook _remoteAlbum; [SetUp] public void Setup() { - _remoteAlbum = new RemoteAlbum + _remoteAlbum = new RemoteBook { Release = new ReleaseInfo { IndexerId = 1 } }; diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/DiscographySpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/DiscographySpecificationFixture.cs index 1776836f0..c2adf4eb5 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/DiscographySpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/DiscographySpecificationFixture.cs @@ -5,8 +5,8 @@ using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine.Specifications; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; @@ -15,39 +15,39 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [TestFixture] public class DiscographySpecificationFixture : CoreTest { - private RemoteAlbum _remoteAlbum; + private RemoteBook _remoteAlbum; [SetUp] public void Setup() { var artist = Builder.CreateNew().With(s => s.Id = 1234).Build(); - _remoteAlbum = new RemoteAlbum + _remoteAlbum = new RemoteBook { - ParsedAlbumInfo = new ParsedAlbumInfo + ParsedBookInfo = new ParsedBookInfo { Discography = true }, - Albums = Builder.CreateListOfSize(3) + Books = Builder.CreateListOfSize(3) .All() .With(e => e.ReleaseDate = DateTime.UtcNow.AddDays(-8)) .With(s => s.AuthorId = artist.Id) .BuildList(), - Artist = artist, + Author = artist, Release = new ReleaseInfo { Title = "Artist.Discography.1978.2005.FLAC-RlsGrp" } }; - Mocker.GetMock().Setup(s => s.AlbumsBetweenDates(It.IsAny(), It.IsAny(), false)) + Mocker.GetMock().Setup(s => s.BooksBetweenDates(It.IsAny(), It.IsAny(), false)) .Returns(new List()); } [Test] public void should_return_true_if_is_not_a_discography() { - _remoteAlbum.ParsedAlbumInfo.Discography = false; - _remoteAlbum.Albums.Last().ReleaseDate = DateTime.UtcNow.AddDays(+2); + _remoteAlbum.ParsedBookInfo.Discography = false; + _remoteAlbum.Books.Last().ReleaseDate = DateTime.UtcNow.AddDays(+2); Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } @@ -60,14 +60,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [Test] public void should_return_false_if_one_album_has_not_released() { - _remoteAlbum.Albums.Last().ReleaseDate = DateTime.UtcNow.AddDays(+2); + _remoteAlbum.Books.Last().ReleaseDate = DateTime.UtcNow.AddDays(+2); Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } [Test] public void should_return_false_if_an_album_does_not_have_an_release_date() { - _remoteAlbum.Albums.Last().ReleaseDate = null; + _remoteAlbum.Books.Last().ReleaseDate = null; Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } } diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/DownloadDecisionMakerFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/DownloadDecisionMakerFixture.cs index 28af919eb..b6821d732 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/DownloadDecisionMakerFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/DownloadDecisionMakerFixture.cs @@ -4,11 +4,11 @@ using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; @@ -20,7 +20,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class DownloadDecisionMakerFixture : CoreTest { private List _reports; - private RemoteAlbum _remoteAlbum; + private RemoteBook _remoteAlbum; private Mock _pass1; private Mock _pass2; @@ -45,26 +45,26 @@ namespace NzbDrone.Core.Test.DecisionEngineTests _failDelayed1 = new Mock(); - _pass1.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Accept); - _pass2.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Accept); - _pass3.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Accept); + _pass1.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Accept); + _pass2.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Accept); + _pass3.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Accept); - _fail1.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Reject("fail1")); - _fail2.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Reject("fail2")); - _fail3.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Reject("fail3")); + _fail1.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Reject("fail1")); + _fail2.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Reject("fail2")); + _fail3.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Reject("fail3")); - _failDelayed1.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Reject("failDelayed1")); + _failDelayed1.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Reject("failDelayed1")); _failDelayed1.SetupGet(c => c.Priority).Returns(SpecificationPriority.Disk); _reports = new List { new ReleaseInfo { Title = "Coldplay-A Head Full Of Dreams-CD-FLAC-2015-PERFECT" } }; - _remoteAlbum = new RemoteAlbum + _remoteAlbum = new RemoteBook { - Artist = new Author(), - Albums = new List { new Book() } + Author = new Author(), + Books = new List { new Book() } }; Mocker.GetMock() - .Setup(c => c.Map(It.IsAny(), It.IsAny())) + .Setup(c => c.Map(It.IsAny(), It.IsAny())) .Returns(_remoteAlbum); } @@ -154,11 +154,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests var results = Subject.GetRssDecision(_reports).ToList(); - Mocker.GetMock().Verify(c => c.Map(It.IsAny(), It.IsAny()), Times.Never()); + Mocker.GetMock().Verify(c => c.Map(It.IsAny(), It.IsAny()), Times.Never()); - _pass1.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); - _pass2.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); - _pass3.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); + _pass1.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); + _pass2.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); + _pass3.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); results.Should().BeEmpty(); } @@ -171,11 +171,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests var results = Subject.GetRssDecision(_reports).ToList(); - Mocker.GetMock().Verify(c => c.Map(It.IsAny(), It.IsAny()), Times.Never()); + Mocker.GetMock().Verify(c => c.Map(It.IsAny(), It.IsAny()), Times.Never()); - _pass1.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); - _pass2.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); - _pass3.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); + _pass1.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); + _pass2.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); + _pass3.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); results.Should().BeEmpty(); } @@ -185,13 +185,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenSpecifications(_pass1, _pass2, _pass3); - _remoteAlbum.Artist = null; + _remoteAlbum.Author = null; Subject.GetRssDecision(_reports); - _pass1.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); - _pass2.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); - _pass3.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); + _pass1.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); + _pass2.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); + _pass3.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); } [Test] @@ -199,7 +199,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenSpecifications(_pass1); - Mocker.GetMock().Setup(c => c.Map(It.IsAny(), It.IsAny())) + Mocker.GetMock().Setup(c => c.Map(It.IsAny(), It.IsAny())) .Throws(); _reports = new List @@ -211,7 +211,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests Subject.GetRssDecision(_reports); - Mocker.GetMock().Verify(c => c.Map(It.IsAny(), It.IsAny()), Times.Exactly(_reports.Count)); + Mocker.GetMock().Verify(c => c.Map(It.IsAny(), It.IsAny()), Times.Exactly(_reports.Count)); ExceptionVerification.ExpectedErrors(3); } @@ -221,7 +221,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenSpecifications(_pass1, _pass2, _pass3); - _remoteAlbum.Artist = null; + _remoteAlbum.Author = null; var result = Subject.GetRssDecision(_reports); @@ -239,7 +239,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests .With(v => v.Author, new LazyLoaded(artist)) .BuildList(); - var criteria = new ArtistSearchCriteria { Albums = albums.Take(1).ToList() }; + var criteria = new AuthorSearchCriteria { Books = albums.Take(1).ToList() }; var reports = albums.Select(v => new ReleaseInfo() @@ -248,14 +248,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests }).ToList(); Mocker.GetMock() - .Setup(v => v.Map(It.IsAny(), It.IsAny())) - .Returns((p, c) => - new RemoteAlbum + .Setup(v => v.Map(It.IsAny(), It.IsAny())) + .Returns((p, c) => + new RemoteBook { DownloadAllowed = true, - ParsedAlbumInfo = p, - Artist = artist, - Albums = albums.Where(v => v.Title == p.AlbumTitle).ToList() + ParsedBookInfo = p, + Author = artist, + Books = albums.Where(v => v.Title == p.BookTitle).ToList() }); Mocker.SetConstant>(new List @@ -275,13 +275,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenSpecifications(_pass1, _pass2, _pass3); - _remoteAlbum.Artist = null; + _remoteAlbum.Author = null; var result = Subject.GetRssDecision(_reports); result.Should().HaveCount(1); - result.First().RemoteAlbum.DownloadAllowed.Should().BeFalse(); + result.First().RemoteBook.DownloadAllowed.Should().BeFalse(); } [Test] @@ -289,13 +289,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenSpecifications(_pass1, _pass2, _pass3); - _remoteAlbum.Albums = new List(); + _remoteAlbum.Books = new List(); var result = Subject.GetRssDecision(_reports); result.Should().HaveCount(1); - result.First().RemoteAlbum.DownloadAllowed.Should().BeFalse(); + result.First().RemoteBook.DownloadAllowed.Should().BeFalse(); } [Test] @@ -303,7 +303,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenSpecifications(_pass1); - Mocker.GetMock().Setup(c => c.Map(It.IsAny(), It.IsAny())) + Mocker.GetMock().Setup(c => c.Map(It.IsAny(), It.IsAny())) .Throws(); _reports = new List diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/EarlyReleaseSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/EarlyReleaseSpecificationFixture.cs index c0afce914..a76095fea 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/EarlyReleaseSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/EarlyReleaseSpecificationFixture.cs @@ -4,11 +4,11 @@ using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers.TorrentRss; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Test.Common; @@ -20,7 +20,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests private Author _artist; private Book _album1; private Book _album2; - private RemoteAlbum _remoteAlbum; + private RemoteBook _remoteAlbum; private IndexerDefinition _indexerDefinition; [SetUp] @@ -30,10 +30,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests _album1 = Builder.CreateNew().With(s => s.ReleaseDate = DateTime.Today).Build(); _album2 = Builder.CreateNew().With(s => s.ReleaseDate = DateTime.Today).Build(); - _remoteAlbum = new RemoteAlbum + _remoteAlbum = new RemoteBook { - Artist = _artist, - Albums = new List { _album1 }, + Author = _artist, + Books = new List { _album1 }, Release = new TorrentInfo { IndexerId = 1, @@ -68,7 +68,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [Test] public void should_return_true_if_release_contains_multiple_albums() { - _remoteAlbum.Albums.Add(_album2); + _remoteAlbum.Books.Add(_album2); Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/HistorySpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/HistorySpecificationFixture.cs index 3d3fed50a..f9962a37b 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/HistorySpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/HistorySpecificationFixture.cs @@ -4,12 +4,12 @@ using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.DecisionEngine.Specifications.RssSync; using NzbDrone.Core.History; using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Qualities; using NzbDrone.Core.Qualities; @@ -25,8 +25,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests private HistorySpecification _upgradeHistory; - private RemoteAlbum _parseResultMulti; - private RemoteAlbum _parseResultSingle; + private RemoteBook _parseResultMulti; + private RemoteBook _parseResultSingle; private QualityModel _upgradableQuality; private QualityModel _notupgradableQuality; private Author _fakeArtist; @@ -54,18 +54,18 @@ namespace NzbDrone.Core.Test.DecisionEngineTests }) .Build(); - _parseResultMulti = new RemoteAlbum + _parseResultMulti = new RemoteBook { - Artist = _fakeArtist, - ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) }, - Albums = doubleAlbumList + Author = _fakeArtist, + ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) }, + Books = doubleAlbumList }; - _parseResultSingle = new RemoteAlbum + _parseResultSingle = new RemoteBook { - Artist = _fakeArtist, - ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) }, - Albums = singleAlbumList + Author = _fakeArtist, + ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) }, + Books = singleAlbumList }; _upgradableQuality = new QualityModel(Quality.MP3_320, new Revision(version: 1)); @@ -78,7 +78,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests private void GivenMostRecentForAlbum(int bookId, string downloadId, QualityModel quality, DateTime date, HistoryEventType eventType) { - Mocker.GetMock().Setup(s => s.MostRecentForAlbum(bookId)) + Mocker.GetMock().Setup(s => s.MostRecentForBook(bookId)) .Returns(new History.History { DownloadId = downloadId, Quality = quality, Date = date, EventType = eventType }); } @@ -92,13 +92,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [Test] public void should_return_true_if_it_is_a_search() { - _upgradeHistory.IsSatisfiedBy(_parseResultMulti, new AlbumSearchCriteria()).Accepted.Should().BeTrue(); + _upgradeHistory.IsSatisfiedBy(_parseResultMulti, new BookSearchCriteria()).Accepted.Should().BeTrue(); } [Test] public void should_return_true_if_latest_history_item_is_null() { - Mocker.GetMock().Setup(s => s.MostRecentForAlbum(It.IsAny())).Returns((History.History)null); + Mocker.GetMock().Setup(s => s.MostRecentForBook(It.IsAny())).Returns((History.History)null); _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue(); } @@ -165,7 +165,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void should_not_be_upgradable_if_album_is_of_same_quality_as_existing() { _fakeArtist.QualityProfile = new QualityProfile { Cutoff = Quality.MP3_320.Id, Items = Qualities.QualityFixture.GetDefaultQualities() }; - _parseResultSingle.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_320, new Revision(version: 1)); + _parseResultSingle.ParsedBookInfo.Quality = new QualityModel(Quality.MP3_320, new Revision(version: 1)); _upgradableQuality = new QualityModel(Quality.MP3_320, new Revision(version: 1)); GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); @@ -177,7 +177,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void should_not_be_upgradable_if_cutoff_already_met() { _fakeArtist.QualityProfile = new QualityProfile { Cutoff = Quality.MP3_320.Id, Items = Qualities.QualityFixture.GetDefaultQualities() }; - _parseResultSingle.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_320, new Revision(version: 1)); + _parseResultSingle.ParsedBookInfo.Quality = new QualityModel(Quality.MP3_320, new Revision(version: 1)); _upgradableQuality = new QualityModel(Quality.MP3_320, new Revision(version: 1)); GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); @@ -205,7 +205,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenCdhDisabled(); _fakeArtist.QualityProfile = new QualityProfile { Cutoff = Quality.MP3_320.Id, Items = Qualities.QualityFixture.GetDefaultQualities() }; - _parseResultSingle.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_320, new Revision(version: 1)); + _parseResultSingle.ParsedBookInfo.Quality = new QualityModel(Quality.MP3_320, new Revision(version: 1)); _upgradableQuality = new QualityModel(Quality.MP3_320, new Revision(version: 1)); GivenMostRecentForAlbum(FIRST_ALBUM_ID, "test", _upgradableQuality, DateTime.UtcNow.AddDays(-100), HistoryEventType.Grabbed); diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/MaximumSizeSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/MaximumSizeSpecificationFixture.cs index d3a1ef88e..ac0822d21 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/MaximumSizeSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/MaximumSizeSpecificationFixture.cs @@ -9,12 +9,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { public class MaximumSizeSpecificationFixture : CoreTest { - private RemoteAlbum _remoteAlbum; + private RemoteBook _remoteAlbum; [SetUp] public void Setup() { - _remoteAlbum = new RemoteAlbum() { Release = new ReleaseInfo() }; + _remoteAlbum = new RemoteBook() { Release = new ReleaseInfo() }; } private void WithMaximumSize(int size) diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/MinimumAgeSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/MinimumAgeSpecificationFixture.cs index 522e0cc85..12c65f5f4 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/MinimumAgeSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/MinimumAgeSpecificationFixture.cs @@ -13,12 +13,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class MinimumAgeSpecificationFixture : CoreTest { - private RemoteAlbum _remoteAlbum; + private RemoteBook _remoteAlbum; [SetUp] public void Setup() { - _remoteAlbum = new RemoteAlbum + _remoteAlbum = new RemoteBook { Release = new ReleaseInfo() { DownloadProtocol = DownloadProtocol.Usenet } }; diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/MonitoredAlbumSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/MonitoredAlbumSpecificationFixture.cs index 034d22dbd..1b1f443f0 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/MonitoredAlbumSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/MonitoredAlbumSpecificationFixture.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine.Specifications.RssSync; using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; @@ -16,8 +16,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { private MonitoredAlbumSpecification _monitoredAlbumSpecification; - private RemoteAlbum _parseResultMulti; - private RemoteAlbum _parseResultSingle; + private RemoteBook _parseResultMulti; + private RemoteBook _parseResultSingle; private Author _fakeArtist; private Book _firstAlbum; private Book _secondAlbum; @@ -37,16 +37,16 @@ namespace NzbDrone.Core.Test.DecisionEngineTests var singleAlbumList = new List { _firstAlbum }; var doubleAlbumList = new List { _firstAlbum, _secondAlbum }; - _parseResultMulti = new RemoteAlbum + _parseResultMulti = new RemoteBook { - Artist = _fakeArtist, - Albums = doubleAlbumList + Author = _fakeArtist, + Books = doubleAlbumList }; - _parseResultSingle = new RemoteAlbum + _parseResultSingle = new RemoteBook { - Artist = _fakeArtist, - Albums = singleAlbumList + Author = _fakeArtist, + Books = singleAlbumList }; } @@ -107,28 +107,28 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void should_return_true_for_single_album_search() { _fakeArtist.Monitored = false; - _monitoredAlbumSpecification.IsSatisfiedBy(_parseResultSingle, new AlbumSearchCriteria()).Accepted.Should().BeTrue(); + _monitoredAlbumSpecification.IsSatisfiedBy(_parseResultSingle, new BookSearchCriteria()).Accepted.Should().BeTrue(); } [Test] public void should_return_true_if_album_is_not_monitored_and_monitoredEpisodesOnly_flag_is_false() { WithFirstAlbumUnmonitored(); - _monitoredAlbumSpecification.IsSatisfiedBy(_parseResultSingle, new AlbumSearchCriteria { MonitoredEpisodesOnly = false }).Accepted.Should().BeTrue(); + _monitoredAlbumSpecification.IsSatisfiedBy(_parseResultSingle, new BookSearchCriteria { MonitoredBooksOnly = false }).Accepted.Should().BeTrue(); } [Test] public void should_return_false_if_album_is_not_monitored_and_monitoredEpisodesOnly_flag_is_true() { WithFirstAlbumUnmonitored(); - _monitoredAlbumSpecification.IsSatisfiedBy(_parseResultSingle, new AlbumSearchCriteria { MonitoredEpisodesOnly = true }).Accepted.Should().BeFalse(); + _monitoredAlbumSpecification.IsSatisfiedBy(_parseResultSingle, new BookSearchCriteria { MonitoredBooksOnly = true }).Accepted.Should().BeFalse(); } [Test] public void should_return_false_if_all_albums_are_not_monitored_for_discography_pack_release() { WithSecondAlbumUnmonitored(); - _parseResultMulti.ParsedAlbumInfo = new ParsedAlbumInfo() + _parseResultMulti.ParsedBookInfo = new ParsedBookInfo() { Discography = true }; diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/PrioritizeDownloadDecisionFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/PrioritizeDownloadDecisionFixture.cs index d2893262c..2259506dd 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/PrioritizeDownloadDecisionFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/PrioritizeDownloadDecisionFixture.cs @@ -6,10 +6,10 @@ using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Indexers; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Delay; using NzbDrone.Core.Profiles.Qualities; @@ -34,21 +34,21 @@ namespace NzbDrone.Core.Test.DecisionEngineTests .Build(); } - private RemoteAlbum GivenRemoteAlbum(List albums, QualityModel quality, int age = 0, long size = 0, DownloadProtocol downloadProtocol = DownloadProtocol.Usenet) + private RemoteBook GivenRemoteAlbum(List albums, QualityModel quality, int age = 0, long size = 0, DownloadProtocol downloadProtocol = DownloadProtocol.Usenet) { - var remoteAlbum = new RemoteAlbum(); - remoteAlbum.ParsedAlbumInfo = new ParsedAlbumInfo(); - remoteAlbum.ParsedAlbumInfo.Quality = quality; + var remoteAlbum = new RemoteBook(); + remoteAlbum.ParsedBookInfo = new ParsedBookInfo(); + remoteAlbum.ParsedBookInfo.Quality = quality; - remoteAlbum.Albums = new List(); - remoteAlbum.Albums.AddRange(albums); + remoteAlbum.Books = new List(); + remoteAlbum.Books.AddRange(albums); remoteAlbum.Release = new ReleaseInfo(); remoteAlbum.Release.PublishDate = DateTime.Now.AddDays(-age); remoteAlbum.Release.Size = size; remoteAlbum.Release.DownloadProtocol = downloadProtocol; - remoteAlbum.Artist = Builder.CreateNew() + remoteAlbum.Author = Builder.CreateNew() .With(e => e.QualityProfile = new QualityProfile { Items = Qualities.QualityFixture.GetDefaultQualities() @@ -80,7 +80,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteAlbum.ParsedAlbumInfo.Quality.Revision.Version.Should().Be(2); + qualifiedReports.First().RemoteBook.ParsedBookInfo.Quality.Revision.Version.Should().Be(2); } [Test] @@ -94,7 +94,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteAlbum.ParsedAlbumInfo.Quality.Quality.Should().Be(Quality.MP3_320); + qualifiedReports.First().RemoteBook.ParsedBookInfo.Quality.Quality.Should().Be(Quality.MP3_320); } [Test] @@ -112,7 +112,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests decisions.Add(new DownloadDecision(remoteAlbumHdLargeYoung)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteAlbum.Should().Be(remoteAlbumHdLargeYoung); + qualifiedReports.First().RemoteBook.Should().Be(remoteAlbumHdLargeYoung); } [Test] @@ -126,7 +126,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteAlbum.Should().Be(remoteAlbum2); + qualifiedReports.First().RemoteBook.Should().Be(remoteAlbum2); } [Test] @@ -135,7 +135,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests var remoteAlbum1 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), size: 500.Megabytes()); var remoteAlbum2 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), size: 500.Megabytes()); - remoteAlbum1.Albums = new List(); + remoteAlbum1.Books = new List(); var decisions = new List(); decisions.Add(new DownloadDecision(remoteAlbum1)); @@ -157,7 +157,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteAlbum.Release.DownloadProtocol.Should().Be(DownloadProtocol.Usenet); + qualifiedReports.First().RemoteBook.Release.DownloadProtocol.Should().Be(DownloadProtocol.Usenet); } [Test] @@ -173,7 +173,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteAlbum.Release.DownloadProtocol.Should().Be(DownloadProtocol.Torrent); + qualifiedReports.First().RemoteBook.Release.DownloadProtocol.Should().Be(DownloadProtocol.Torrent); } [Test] @@ -182,14 +182,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests var remoteAlbum1 = GivenRemoteAlbum(new List { GivenAlbum(1), GivenAlbum(2) }, new QualityModel(Quality.FLAC)); var remoteAlbum2 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.FLAC)); - remoteAlbum1.ParsedAlbumInfo.Discography = true; + remoteAlbum1.ParsedBookInfo.Discography = true; var decisions = new List(); decisions.Add(new DownloadDecision(remoteAlbum1)); decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteAlbum.ParsedAlbumInfo.Discography.Should().BeTrue(); + qualifiedReports.First().RemoteBook.ParsedBookInfo.Discography.Should().BeTrue(); } [Test] @@ -198,14 +198,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests var remoteAlbum1 = GivenRemoteAlbum(new List { GivenAlbum(1), GivenAlbum(2) }, new QualityModel(Quality.MP3_320)); var remoteAlbum2 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.FLAC)); - remoteAlbum1.ParsedAlbumInfo.Discography = true; + remoteAlbum1.ParsedBookInfo.Discography = true; var decisions = new List(); decisions.Add(new DownloadDecision(remoteAlbum1)); decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteAlbum.ParsedAlbumInfo.Discography.Should().BeFalse(); + qualifiedReports.First().RemoteBook.ParsedBookInfo.Discography.Should().BeFalse(); } [Test] @@ -219,7 +219,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteAlbum.Albums.Count.Should().Be(remoteAlbum2.Albums.Count); + qualifiedReports.First().RemoteBook.Books.Count.Should().Be(remoteAlbum2.Books.Count); } [Test] @@ -245,7 +245,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - ((TorrentInfo)qualifiedReports.First().RemoteAlbum.Release).Seeders.Should().Be(torrentInfo2.Seeders); + ((TorrentInfo)qualifiedReports.First().RemoteBook.Release).Seeders.Should().Be(torrentInfo2.Seeders); } [Test] @@ -272,7 +272,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - ((TorrentInfo)qualifiedReports.First().RemoteAlbum.Release).Peers.Should().Be(torrentInfo2.Peers); + ((TorrentInfo)qualifiedReports.First().RemoteBook.Release).Peers.Should().Be(torrentInfo2.Peers); } [Test] @@ -300,7 +300,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - ((TorrentInfo)qualifiedReports.First().RemoteAlbum.Release).Peers.Should().Be(torrentInfo2.Peers); + ((TorrentInfo)qualifiedReports.First().RemoteBook.Release).Peers.Should().Be(torrentInfo2.Peers); } [Test] @@ -329,7 +329,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - ((TorrentInfo)qualifiedReports.First().RemoteAlbum.Release).Should().Be(torrentInfo1); + ((TorrentInfo)qualifiedReports.First().RemoteBook.Release).Should().Be(torrentInfo1); } [Test] @@ -349,7 +349,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteAlbum.Release.Should().Be(remoteAlbum1.Release); + qualifiedReports.First().RemoteBook.Release.Should().Be(remoteAlbum1.Release); } [Test] @@ -378,7 +378,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - ((TorrentInfo)qualifiedReports.First().RemoteAlbum.Release).Should().Be(torrentInfo1); + ((TorrentInfo)qualifiedReports.First().RemoteBook.Release).Should().Be(torrentInfo1); } [Test] @@ -392,7 +392,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteAlbum.ParsedAlbumInfo.Quality.Quality.Should().Be(Quality.MP3_320); + qualifiedReports.First().RemoteBook.ParsedBookInfo.Quality.Quality.Should().Be(Quality.MP3_320); } [Test] @@ -409,7 +409,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteAlbum.PreferredWordScore.Should().Be(10); + qualifiedReports.First().RemoteBook.PreferredWordScore.Should().Be(10); } [Test] @@ -430,7 +430,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteAlbum.ParsedAlbumInfo.Quality.Revision.Version.Should().Be(2); + qualifiedReports.First().RemoteBook.ParsedBookInfo.Quality.Revision.Version.Should().Be(2); } [Test] @@ -451,7 +451,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteAlbum.ParsedAlbumInfo.Quality.Revision.Version.Should().Be(2); + qualifiedReports.First().RemoteBook.ParsedBookInfo.Quality.Revision.Version.Should().Be(2); } [Test] @@ -472,9 +472,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteAlbum.ParsedAlbumInfo.Quality.Quality.Should().Be(Quality.FLAC); - qualifiedReports.First().RemoteAlbum.ParsedAlbumInfo.Quality.Revision.Version.Should().Be(1); - qualifiedReports.First().RemoteAlbum.PreferredWordScore.Should().Be(10); + qualifiedReports.First().RemoteBook.ParsedBookInfo.Quality.Quality.Should().Be(Quality.FLAC); + qualifiedReports.First().RemoteBook.ParsedBookInfo.Quality.Revision.Version.Should().Be(1); + qualifiedReports.First().RemoteBook.PreferredWordScore.Should().Be(10); } } } diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/ProtocolSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/ProtocolSpecificationFixture.cs index 7b42abfcd..02d678597 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/ProtocolSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/ProtocolSpecificationFixture.cs @@ -2,9 +2,9 @@ using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Indexers; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Delay; using NzbDrone.Core.Test.Framework; @@ -14,15 +14,15 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [TestFixture] public class ProtocolSpecificationFixture : CoreTest { - private RemoteAlbum _remoteAlbum; + private RemoteBook _remoteAlbum; private DelayProfile _delayProfile; [SetUp] public void Setup() { - _remoteAlbum = new RemoteAlbum(); + _remoteAlbum = new RemoteBook(); _remoteAlbum.Release = new ReleaseInfo(); - _remoteAlbum.Artist = new Author(); + _remoteAlbum.Author = new Author(); _delayProfile = new DelayProfile(); diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/QualityAllowedByProfileSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/QualityAllowedByProfileSpecificationFixture.cs index 444cbe094..7a50652da 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/QualityAllowedByProfileSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/QualityAllowedByProfileSpecificationFixture.cs @@ -1,8 +1,8 @@ using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine.Specifications; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Qualities; using NzbDrone.Core.Qualities; @@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class QualityAllowedByProfileSpecificationFixture : CoreTest { - private RemoteAlbum _remoteAlbum; + private RemoteBook _remoteAlbum; public static object[] AllowedTestCases = { @@ -36,10 +36,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests .With(c => c.QualityProfile = new QualityProfile { Cutoff = Quality.MP3_320.Id }) .Build(); - _remoteAlbum = new RemoteAlbum + _remoteAlbum = new RemoteBook { - Artist = fakeArtist, - ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) }, + Author = fakeArtist, + ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) }, }; } @@ -47,8 +47,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [TestCaseSource(nameof(AllowedTestCases))] public void should_allow_if_quality_is_defined_in_profile(Quality qualityType) { - _remoteAlbum.ParsedAlbumInfo.Quality.Quality = qualityType; - _remoteAlbum.Artist.QualityProfile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.MP3_320, Quality.MP3_320, Quality.MP3_320); + _remoteAlbum.ParsedBookInfo.Quality.Quality = qualityType; + _remoteAlbum.Author.QualityProfile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.MP3_320, Quality.MP3_320, Quality.MP3_320); Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } @@ -57,8 +57,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [TestCaseSource(nameof(DeniedTestCases))] public void should_not_allow_if_quality_is_not_defined_in_profile(Quality qualityType) { - _remoteAlbum.ParsedAlbumInfo.Quality.Quality = qualityType; - _remoteAlbum.Artist.QualityProfile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.MP3_320, Quality.MP3_320, Quality.MP3_320); + _remoteAlbum.ParsedBookInfo.Quality.Quality = qualityType; + _remoteAlbum.Author.QualityProfile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.MP3_320, Quality.MP3_320, Quality.MP3_320); Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs index 63a1d15bb..f0b970d8f 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs @@ -3,9 +3,9 @@ using System.Linq; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Download.TrackedDownloads; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Qualities; using NzbDrone.Core.Qualities; @@ -19,7 +19,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { private Author _artist; private Book _album; - private RemoteAlbum _remoteAlbum; + private RemoteBook _remoteAlbum; private Author _otherArtist; private Book _otherAlbum; @@ -55,10 +55,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests _releaseInfo = Builder.CreateNew() .Build(); - _remoteAlbum = Builder.CreateNew() - .With(r => r.Artist = _artist) - .With(r => r.Albums = new List { _album }) - .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_320) }) + _remoteAlbum = Builder.CreateNew() + .With(r => r.Author = _artist) + .With(r => r.Books = new List { _album }) + .With(r => r.ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320) }) .With(r => r.PreferredWordScore = 0) .Build(); } @@ -70,11 +70,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests .Returns(new List()); } - private void GivenQueue(IEnumerable remoteAlbums, TrackedDownloadState trackedDownloadState = TrackedDownloadState.Downloading) + private void GivenQueue(IEnumerable remoteAlbums, TrackedDownloadState trackedDownloadState = TrackedDownloadState.Downloading) { var queue = remoteAlbums.Select(remoteAlbum => new Queue.Queue { - RemoteAlbum = remoteAlbum, + RemoteBook = remoteAlbum, TrackedDownloadState = trackedDownloadState }); @@ -93,13 +93,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [Test] public void should_return_true_when_artist_doesnt_match() { - var remoteAlbum = Builder.CreateNew() - .With(r => r.Artist = _otherArtist) - .With(r => r.Albums = new List { _album }) + var remoteAlbum = Builder.CreateNew() + .With(r => r.Author = _otherArtist) + .With(r => r.Books = new List { _album }) .With(r => r.Release = _releaseInfo) .Build(); - GivenQueue(new List { remoteAlbum }); + GivenQueue(new List { remoteAlbum }); Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } @@ -108,17 +108,17 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { _artist.QualityProfile.Value.Cutoff = Quality.FLAC.Id; - var remoteAlbum = Builder.CreateNew() - .With(r => r.Artist = _artist) - .With(r => r.Albums = new List { _album }) - .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo + var remoteAlbum = Builder.CreateNew() + .With(r => r.Author = _artist) + .With(r => r.Books = new List { _album }) + .With(r => r.ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320) }) .With(r => r.Release = _releaseInfo) .Build(); - GivenQueue(new List { remoteAlbum }); + GivenQueue(new List { remoteAlbum }); Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } @@ -128,34 +128,34 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { _artist.QualityProfile.Value.Cutoff = Quality.MP3_320.Id; - var remoteAlbum = Builder.CreateNew() - .With(r => r.Artist = _artist) - .With(r => r.Albums = new List { _album }) - .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo + var remoteAlbum = Builder.CreateNew() + .With(r => r.Author = _artist) + .With(r => r.Books = new List { _album }) + .With(r => r.ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.AZW3) }) .With(r => r.Release = _releaseInfo) .Build(); - GivenQueue(new List { remoteAlbum }); + GivenQueue(new List { remoteAlbum }); Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] public void should_return_true_when_album_doesnt_match() { - var remoteAlbum = Builder.CreateNew() - .With(r => r.Artist = _artist) - .With(r => r.Albums = new List { _otherAlbum }) - .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo + var remoteAlbum = Builder.CreateNew() + .With(r => r.Author = _artist) + .With(r => r.Books = new List { _otherAlbum }) + .With(r => r.ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320) }) .With(r => r.Release = _releaseInfo) .Build(); - GivenQueue(new List { remoteAlbum }); + GivenQueue(new List { remoteAlbum }); Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } @@ -164,34 +164,34 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { _remoteAlbum.PreferredWordScore = 1; - var remoteAlbum = Builder.CreateNew() - .With(r => r.Artist = _artist) - .With(r => r.Albums = new List { _album }) - .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo + var remoteAlbum = Builder.CreateNew() + .With(r => r.Author = _artist) + .With(r => r.Books = new List { _album }) + .With(r => r.ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320) }) .With(r => r.Release = _releaseInfo) .Build(); - GivenQueue(new List { remoteAlbum }); + GivenQueue(new List { remoteAlbum }); Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] public void should_return_false_when_qualities_are_the_same() { - var remoteAlbum = Builder.CreateNew() - .With(r => r.Artist = _artist) - .With(r => r.Albums = new List { _album }) - .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo + var remoteAlbum = Builder.CreateNew() + .With(r => r.Author = _artist) + .With(r => r.Books = new List { _album }) + .With(r => r.ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320) }) .With(r => r.Release = _releaseInfo) .Build(); - GivenQueue(new List { remoteAlbum }); + GivenQueue(new List { remoteAlbum }); Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } @@ -200,93 +200,93 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { _artist.QualityProfile.Value.Cutoff = Quality.FLAC.Id; - var remoteAlbum = Builder.CreateNew() - .With(r => r.Artist = _artist) - .With(r => r.Albums = new List { _album }) - .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo + var remoteAlbum = Builder.CreateNew() + .With(r => r.Author = _artist) + .With(r => r.Books = new List { _album }) + .With(r => r.ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320) }) .With(r => r.Release = _releaseInfo) .Build(); - GivenQueue(new List { remoteAlbum }); + GivenQueue(new List { remoteAlbum }); Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } [Test] public void should_return_false_if_matching_multi_album_is_in_queue() { - var remoteAlbum = Builder.CreateNew() - .With(r => r.Artist = _artist) - .With(r => r.Albums = new List { _album, _otherAlbum }) - .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo + var remoteAlbum = Builder.CreateNew() + .With(r => r.Author = _artist) + .With(r => r.Books = new List { _album, _otherAlbum }) + .With(r => r.ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320) }) .With(r => r.Release = _releaseInfo) .Build(); - GivenQueue(new List { remoteAlbum }); + GivenQueue(new List { remoteAlbum }); Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } [Test] public void should_return_false_if_multi_album_has_one_album_in_queue() { - var remoteAlbum = Builder.CreateNew() - .With(r => r.Artist = _artist) - .With(r => r.Albums = new List { _album }) - .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo + var remoteAlbum = Builder.CreateNew() + .With(r => r.Author = _artist) + .With(r => r.Books = new List { _album }) + .With(r => r.ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320) }) .With(r => r.Release = _releaseInfo) .Build(); - _remoteAlbum.Albums.Add(_otherAlbum); + _remoteAlbum.Books.Add(_otherAlbum); - GivenQueue(new List { remoteAlbum }); + GivenQueue(new List { remoteAlbum }); Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } [Test] public void should_return_false_if_multi_part_album_is_already_in_queue() { - var remoteAlbum = Builder.CreateNew() - .With(r => r.Artist = _artist) - .With(r => r.Albums = new List { _album, _otherAlbum }) - .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo + var remoteAlbum = Builder.CreateNew() + .With(r => r.Author = _artist) + .With(r => r.Books = new List { _album, _otherAlbum }) + .With(r => r.ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320) }) .With(r => r.Release = _releaseInfo) .Build(); - _remoteAlbum.Albums.Add(_otherAlbum); + _remoteAlbum.Books.Add(_otherAlbum); - GivenQueue(new List { remoteAlbum }); + GivenQueue(new List { remoteAlbum }); Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } [Test] public void should_return_false_if_multi_part_album_has_two_albums_in_queue() { - var remoteAlbums = Builder.CreateListOfSize(2) + var remoteAlbums = Builder.CreateListOfSize(2) .All() - .With(r => r.Artist = _artist) - .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo + .With(r => r.Author = _artist) + .With(r => r.ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320) }) .With(r => r.Release = _releaseInfo) .TheFirst(1) - .With(r => r.Albums = new List { _album }) + .With(r => r.Books = new List { _album }) .TheNext(1) - .With(r => r.Albums = new List { _otherAlbum }) + .With(r => r.Books = new List { _otherAlbum }) .Build(); - _remoteAlbum.Albums.Add(_otherAlbum); + _remoteAlbum.Books.Add(_otherAlbum); GivenQueue(remoteAlbums); Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } @@ -297,17 +297,17 @@ namespace NzbDrone.Core.Test.DecisionEngineTests _artist.QualityProfile.Value.Cutoff = Quality.FLAC.Id; _artist.QualityProfile.Value.UpgradeAllowed = false; - var remoteAlbum = Builder.CreateNew() - .With(r => r.Artist = _artist) - .With(r => r.Albums = new List { _album }) - .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo + var remoteAlbum = Builder.CreateNew() + .With(r => r.Author = _artist) + .With(r => r.Books = new List { _album }) + .With(r => r.ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.FLAC) }) .With(r => r.Release = _releaseInfo) .Build(); - GivenQueue(new List { remoteAlbum }); + GivenQueue(new List { remoteAlbum }); Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } @@ -316,17 +316,17 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { _artist.QualityProfile.Value.Cutoff = Quality.FLAC.Id; - var remoteAlbum = Builder.CreateNew() - .With(r => r.Artist = _artist) - .With(r => r.Albums = new List { _album }) - .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo + var remoteAlbum = Builder.CreateNew() + .With(r => r.Author = _artist) + .With(r => r.Books = new List { _album }) + .With(r => r.ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320) }) .With(r => r.Release = _releaseInfo) .Build(); - GivenQueue(new List { remoteAlbum }, TrackedDownloadState.DownloadFailedPending); + GivenQueue(new List { remoteAlbum }, TrackedDownloadState.DownloadFailedPending); Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/RawDiskSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/RawDiskSpecificationFixture.cs index aff2e8850..222c66c2a 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/RawDiskSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/RawDiskSpecificationFixture.cs @@ -11,12 +11,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class RawDiskSpecificationFixture : CoreTest { - private RemoteAlbum _remoteAlbum; + private RemoteBook _remoteAlbum; [SetUp] public void Setup() { - _remoteAlbum = new RemoteAlbum + _remoteAlbum = new RemoteBook { Release = new ReleaseInfo() { DownloadProtocol = DownloadProtocol.Torrent } }; diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/ReleaseRestrictionsSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/ReleaseRestrictionsSpecificationFixture.cs index e95291700..910c4ebcb 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/ReleaseRestrictionsSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/ReleaseRestrictionsSpecificationFixture.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine.Specifications; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Releases; using NzbDrone.Core.Test.Framework; @@ -13,14 +13,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [TestFixture] public class ReleaseRestrictionsSpecificationFixture : CoreTest { - private RemoteAlbum _remoteAlbum; + private RemoteBook _remoteAlbum; [SetUp] public void Setup() { - _remoteAlbum = new RemoteAlbum + _remoteAlbum = new RemoteBook { - Artist = new Author + Author = new Author { Tags = new HashSet() }, diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/RepackSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/RepackSpecificationFixture.cs index c8174c81f..a7af0a934 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/RepackSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/RepackSpecificationFixture.cs @@ -4,9 +4,9 @@ using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; @@ -16,7 +16,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [TestFixture] public class RepackSpecificationFixture : CoreTest { - private ParsedAlbumInfo _parsedAlbumInfo; + private ParsedBookInfo _parsedAlbumInfo; private List _albums; private List _trackFiles; @@ -25,7 +25,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { Mocker.Resolve(); - _parsedAlbumInfo = Builder.CreateNew() + _parsedAlbumInfo = Builder.CreateNew() .With(p => p.Quality = new QualityModel(Quality.FLAC, new Revision(2, 0, false))) .With(p => p.ReleaseGroup = "Readarr") @@ -41,16 +41,16 @@ namespace NzbDrone.Core.Test.DecisionEngineTests .BuildList(); Mocker.GetMock() - .Setup(c => c.GetFilesByAlbum(It.IsAny())) + .Setup(c => c.GetFilesByBook(It.IsAny())) .Returns(_trackFiles); } [Test] public void should_return_true_if_it_is_not_a_repack() { - var remoteAlbum = Builder.CreateNew() - .With(e => e.ParsedAlbumInfo = _parsedAlbumInfo) - .With(e => e.Albums = _albums) + var remoteAlbum = Builder.CreateNew() + .With(e => e.ParsedBookInfo = _parsedAlbumInfo) + .With(e => e.Books = _albums) .Build(); Subject.IsSatisfiedBy(remoteAlbum, null) @@ -63,14 +63,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void should_return_true_if_there_are_is_no_track_files() { Mocker.GetMock() - .Setup(c => c.GetFilesByAlbum(It.IsAny())) + .Setup(c => c.GetFilesByBook(It.IsAny())) .Returns(new List()); _parsedAlbumInfo.Quality.Revision.IsRepack = true; - var remoteAlbum = Builder.CreateNew() - .With(e => e.ParsedAlbumInfo = _parsedAlbumInfo) - .With(e => e.Albums = _albums) + var remoteAlbum = Builder.CreateNew() + .With(e => e.ParsedBookInfo = _parsedAlbumInfo) + .With(e => e.Books = _albums) .Build(); Subject.IsSatisfiedBy(remoteAlbum, null) @@ -95,9 +95,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests return c; }).ToList(); - var remoteAlbum = Builder.CreateNew() - .With(e => e.ParsedAlbumInfo = _parsedAlbumInfo) - .With(e => e.Albums = _albums) + var remoteAlbum = Builder.CreateNew() + .With(e => e.ParsedBookInfo = _parsedAlbumInfo) + .With(e => e.Books = _albums) .Build(); Subject.IsSatisfiedBy(remoteAlbum, null) @@ -122,9 +122,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests return c; }).ToList(); - var remoteAlbum = Builder.CreateNew() - .With(e => e.ParsedAlbumInfo = _parsedAlbumInfo) - .With(e => e.Albums = _albums) + var remoteAlbum = Builder.CreateNew() + .With(e => e.ParsedBookInfo = _parsedAlbumInfo) + .With(e => e.Books = _albums) .Build(); Subject.IsSatisfiedBy(remoteAlbum, null) @@ -151,9 +151,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests _trackFiles.First().ReleaseGroup = "NotReadarr"; - var remoteAlbum = Builder.CreateNew() - .With(e => e.ParsedAlbumInfo = _parsedAlbumInfo) - .With(e => e.Albums = _albums) + var remoteAlbum = Builder.CreateNew() + .With(e => e.ParsedBookInfo = _parsedAlbumInfo) + .With(e => e.Books = _albums) .Build(); Subject.IsSatisfiedBy(remoteAlbum, null) @@ -178,9 +178,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests return c; }).ToList(); - var remoteAlbum = Builder.CreateNew() - .With(e => e.ParsedAlbumInfo = _parsedAlbumInfo) - .With(e => e.Albums = _albums) + var remoteAlbum = Builder.CreateNew() + .With(e => e.ParsedBookInfo = _parsedAlbumInfo) + .With(e => e.Books = _albums) .Build(); Subject.IsSatisfiedBy(remoteAlbum, null) @@ -205,9 +205,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests return c; }).ToList(); - var remoteAlbum = Builder.CreateNew() - .With(e => e.ParsedAlbumInfo = _parsedAlbumInfo) - .With(e => e.Albums = _albums) + var remoteAlbum = Builder.CreateNew() + .With(e => e.ParsedBookInfo = _parsedAlbumInfo) + .With(e => e.Books = _albums) .Build(); Subject.IsSatisfiedBy(remoteAlbum, null) @@ -234,9 +234,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests return c; }).ToList(); - var remoteAlbum = Builder.CreateNew() - .With(e => e.ParsedAlbumInfo = _parsedAlbumInfo) - .With(e => e.Albums = _albums) + var remoteAlbum = Builder.CreateNew() + .With(e => e.ParsedBookInfo = _parsedAlbumInfo) + .With(e => e.Books = _albums) .Build(); Subject.IsSatisfiedBy(remoteAlbum, null) diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs index f3ec183f1..4c577b79e 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs @@ -13,12 +13,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class RetentionSpecificationFixture : CoreTest { - private RemoteAlbum _remoteAlbum; + private RemoteBook _remoteAlbum; [SetUp] public void Setup() { - _remoteAlbum = new RemoteAlbum + _remoteAlbum = new RemoteBook { Release = new ReleaseInfo() { DownloadProtocol = DownloadProtocol.Usenet } }; diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DelaySpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DelaySpecificationFixture.cs index 62ce2a7e3..1f37fe3e9 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DelaySpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DelaySpecificationFixture.cs @@ -5,13 +5,13 @@ using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.DecisionEngine.Specifications.RssSync; using NzbDrone.Core.Download.Pending; using NzbDrone.Core.Indexers; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Delay; using NzbDrone.Core.Profiles.Qualities; @@ -25,7 +25,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync { private QualityProfile _profile; private DelayProfile _delayProfile; - private RemoteAlbum _remoteAlbum; + private RemoteBook _remoteAlbum; [SetUp] public void Setup() @@ -41,8 +41,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync .With(s => s.QualityProfile = _profile) .Build(); - _remoteAlbum = Builder.CreateNew() - .With(r => r.Artist = artist) + _remoteAlbum = Builder.CreateNew() + .With(r => r.Author = artist) .Build(); _profile.Items = new List(); @@ -52,14 +52,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync _profile.Cutoff = Quality.AZW3.Id; - _remoteAlbum.ParsedAlbumInfo = new ParsedAlbumInfo(); + _remoteAlbum.ParsedBookInfo = new ParsedBookInfo(); _remoteAlbum.Release = new ReleaseInfo(); _remoteAlbum.Release.DownloadProtocol = DownloadProtocol.Usenet; - _remoteAlbum.Albums = Builder.CreateListOfSize(1).Build().ToList(); + _remoteAlbum.Books = Builder.CreateListOfSize(1).Build().ToList(); Mocker.GetMock() - .Setup(s => s.GetFilesByAlbum(It.IsAny())) + .Setup(s => s.GetFilesByBook(It.IsAny())) .Returns(new List { }); Mocker.GetMock() @@ -67,14 +67,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync .Returns(_delayProfile); Mocker.GetMock() - .Setup(s => s.GetPendingRemoteAlbums(It.IsAny())) - .Returns(new List()); + .Setup(s => s.GetPendingRemoteBooks(It.IsAny())) + .Returns(new List()); } private void GivenExistingFile(QualityModel quality) { Mocker.GetMock() - .Setup(s => s.GetFilesByAlbum(It.IsAny())) + .Setup(s => s.GetFilesByBook(It.IsAny())) .Returns(new List { new BookFile @@ -94,18 +94,18 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync [Test] public void should_be_true_when_user_invoked_search() { - Subject.IsSatisfiedBy(new RemoteAlbum(), new AlbumSearchCriteria { UserInvokedSearch = true }).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(new RemoteBook(), new BookSearchCriteria { UserInvokedSearch = true }).Accepted.Should().BeTrue(); } [Test] public void should_be_false_when_system_invoked_search_and_release_is_younger_than_delay() { - _remoteAlbum.ParsedAlbumInfo.Quality = new QualityModel(Quality.MOBI); + _remoteAlbum.ParsedBookInfo.Quality = new QualityModel(Quality.MOBI); _remoteAlbum.Release.PublishDate = DateTime.UtcNow; _delayProfile.UsenetDelay = 720; - Subject.IsSatisfiedBy(_remoteAlbum, new AlbumSearchCriteria()).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteAlbum, new BookSearchCriteria()).Accepted.Should().BeFalse(); } [Test] @@ -119,7 +119,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync [Test] public void should_be_true_when_quality_is_last_allowed_in_profile() { - _remoteAlbum.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_320); + _remoteAlbum.ParsedBookInfo.Quality = new QualityModel(Quality.MP3_320); Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } @@ -127,7 +127,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync [Test] public void should_be_true_when_release_is_older_than_delay() { - _remoteAlbum.ParsedAlbumInfo.Quality = new QualityModel(Quality.MOBI); + _remoteAlbum.ParsedBookInfo.Quality = new QualityModel(Quality.MOBI); _remoteAlbum.Release.PublishDate = DateTime.UtcNow.AddHours(-10); _delayProfile.UsenetDelay = 60; @@ -138,7 +138,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync [Test] public void should_be_false_when_release_is_younger_than_delay() { - _remoteAlbum.ParsedAlbumInfo.Quality = new QualityModel(Quality.MOBI); + _remoteAlbum.ParsedBookInfo.Quality = new QualityModel(Quality.MOBI); _remoteAlbum.Release.PublishDate = DateTime.UtcNow; _delayProfile.UsenetDelay = 720; @@ -149,7 +149,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync [Test] public void should_be_true_when_release_is_a_proper_for_existing_album() { - _remoteAlbum.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)); + _remoteAlbum.ParsedBookInfo.Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)); _remoteAlbum.Release.PublishDate = DateTime.UtcNow; GivenExistingFile(new QualityModel(Quality.MP3_320)); @@ -167,7 +167,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync [Test] public void should_be_true_when_release_is_a_real_for_existing_album() { - _remoteAlbum.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_320, new Revision(real: 1)); + _remoteAlbum.ParsedBookInfo.Quality = new QualityModel(Quality.MP3_320, new Revision(real: 1)); _remoteAlbum.Release.PublishDate = DateTime.UtcNow; GivenExistingFile(new QualityModel(Quality.MP3_320)); @@ -185,7 +185,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync [Test] public void should_be_false_when_release_is_proper_for_existing_album_of_different_quality() { - _remoteAlbum.ParsedAlbumInfo.Quality = new QualityModel(Quality.AZW3, new Revision(version: 2)); + _remoteAlbum.ParsedBookInfo.Quality = new QualityModel(Quality.AZW3, new Revision(version: 2)); _remoteAlbum.Release.PublishDate = DateTime.UtcNow; GivenExistingFile(new QualityModel(Quality.PDF)); diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DeletedTrackFileSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DeletedTrackFileSpecificationFixture.cs index bdcc7ac4f..327803e41 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DeletedTrackFileSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DeletedTrackFileSpecificationFixture.cs @@ -5,11 +5,11 @@ using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; using NzbDrone.Core.DecisionEngine.Specifications.RssSync; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Qualities; using NzbDrone.Core.Qualities; @@ -19,10 +19,10 @@ using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync { [TestFixture] - public class DeletedTrackFileSpecificationFixture : CoreTest + public class DeletedTrackFileSpecificationFixture : CoreTest { - private RemoteAlbum _parseResultMulti; - private RemoteAlbum _parseResultSingle; + private RemoteBook _parseResultMulti; + private RemoteBook _parseResultSingle; private BookFile _firstFile; private BookFile _secondFile; @@ -60,18 +60,18 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync .With(c => c.Path = @"C:\Music\My.Artist".AsOsAgnostic()) .Build(); - _parseResultMulti = new RemoteAlbum + _parseResultMulti = new RemoteBook { - Artist = fakeArtist, - ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) }, - Albums = doubleAlbumList + Author = fakeArtist, + ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) }, + Books = doubleAlbumList }; - _parseResultSingle = new RemoteAlbum + _parseResultSingle = new RemoteBook { - Artist = fakeArtist, - ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) }, - Albums = singleAlbumList + Author = fakeArtist, + ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) }, + Books = singleAlbumList }; GivenUnmonitorDeletedTracks(true); @@ -87,7 +87,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync private void SetupMediaFile(List files) { Mocker.GetMock() - .Setup(v => v.GetFilesByAlbum(It.IsAny())) + .Setup(v => v.GetFilesByBook(It.IsAny())) .Returns(files); } @@ -111,7 +111,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync [Test] public void should_return_true_when_searching() { - Subject.IsSatisfiedBy(_parseResultSingle, new ArtistSearchCriteria()).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_parseResultSingle, new AuthorSearchCriteria()).Accepted.Should().BeTrue(); } [Test] diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/ProperSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/ProperSpecificationFixture.cs index 6b1fcbb60..a49c8b754 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/ProperSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/ProperSpecificationFixture.cs @@ -4,12 +4,12 @@ using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.DecisionEngine.Specifications.RssSync; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Qualities; using NzbDrone.Core.Qualities; @@ -21,8 +21,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync public class ProperSpecificationFixture : CoreTest { - private RemoteAlbum _parseResultMulti; - private RemoteAlbum _parseResultSingle; + private RemoteBook _parseResultMulti; + private RemoteBook _parseResultSingle; private BookFile _firstFile; private BookFile _secondFile; @@ -42,21 +42,21 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync .Build(); Mocker.GetMock() - .Setup(c => c.GetFilesByAlbum(It.IsAny())) + .Setup(c => c.GetFilesByBook(It.IsAny())) .Returns(new List { _firstFile, _secondFile }); - _parseResultMulti = new RemoteAlbum + _parseResultMulti = new RemoteBook { - Artist = fakeArtist, - ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MOBI, new Revision(version: 2)) }, - Albums = doubleAlbumList + Author = fakeArtist, + ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MOBI, new Revision(version: 2)) }, + Books = doubleAlbumList }; - _parseResultSingle = new RemoteAlbum + _parseResultSingle = new RemoteBook { - Artist = fakeArtist, - ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MOBI, new Revision(version: 2)) }, - Albums = singleAlbumList + Author = fakeArtist, + ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MOBI, new Revision(version: 2)) }, + Books = singleAlbumList }; } @@ -109,7 +109,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync WithFirstFileUpgradable(); _firstFile.DateAdded = DateTime.Today.AddDays(-30); - Subject.IsSatisfiedBy(_parseResultSingle, new AlbumSearchCriteria()).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_parseResultSingle, new BookSearchCriteria()).Accepted.Should().BeTrue(); } [Test] diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/Search/ArtistSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/Search/ArtistSpecificationFixture.cs index a79045bf8..43daed76f 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/Search/ArtistSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/Search/ArtistSpecificationFixture.cs @@ -1,21 +1,21 @@ using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine.Specifications.Search; using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.DecisionEngineTests.Search { [TestFixture] - public class ArtistSpecificationFixture : TestBase + public class ArtistSpecificationFixture : TestBase { private Author _artist1; private Author _artist2; - private RemoteAlbum _remoteAlbum = new RemoteAlbum(); - private SearchCriteriaBase _searchCriteria = new AlbumSearchCriteria(); + private RemoteBook _remoteAlbum = new RemoteBook(); + private SearchCriteriaBase _searchCriteria = new BookSearchCriteria(); [SetUp] public void Setup() @@ -23,13 +23,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search _artist1 = Builder.CreateNew().With(s => s.Id = 1).Build(); _artist2 = Builder.CreateNew().With(s => s.Id = 2).Build(); - _remoteAlbum.Artist = _artist1; + _remoteAlbum.Author = _artist1; } [Test] public void should_return_false_if_artist_doesnt_match() { - _searchCriteria.Artist = _artist2; + _searchCriteria.Author = _artist2; Subject.IsSatisfiedBy(_remoteAlbum, _searchCriteria).Accepted.Should().BeFalse(); } @@ -37,7 +37,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search [Test] public void should_return_true_when_artist_ids_match() { - _searchCriteria.Artist = _artist1; + _searchCriteria.Author = _artist1; Subject.IsSatisfiedBy(_remoteAlbum, _searchCriteria).Accepted.Should().BeTrue(); } diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/Search/TorrentSeedingSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/Search/TorrentSeedingSpecificationFixture.cs index 5480f3a02..d8576d114 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/Search/TorrentSeedingSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/Search/TorrentSeedingSpecificationFixture.cs @@ -2,11 +2,11 @@ using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers.TorrentRss; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Test.Common; @@ -16,7 +16,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search public class TorrentSeedingSpecificationFixture : TestBase { private Author _artist; - private RemoteAlbum _remoteAlbum; + private RemoteBook _remoteAlbum; private IndexerDefinition _indexerDefinition; [SetUp] @@ -24,9 +24,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search { _artist = Builder.CreateNew().With(s => s.Id = 1).Build(); - _remoteAlbum = new RemoteAlbum + _remoteAlbum = new RemoteBook { - Artist = _artist, + Author = _artist, Release = new TorrentInfo { IndexerId = 1, diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/UpgradeDiskSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/UpgradeDiskSpecificationFixture.cs index b1cac2179..fee5d855f 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/UpgradeDiskSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/UpgradeDiskSpecificationFixture.cs @@ -5,9 +5,9 @@ using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Qualities; using NzbDrone.Core.Qualities; @@ -19,8 +19,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [Ignore("Pending Readarr fixes")] public class UpgradeDiskSpecificationFixture : CoreTest { - private RemoteAlbum _parseResultMulti; - private RemoteAlbum _parseResultSingle; + private RemoteBook _parseResultMulti; + private RemoteBook _parseResultSingle; private BookFile _firstFile; private BookFile _secondFile; @@ -45,21 +45,21 @@ namespace NzbDrone.Core.Test.DecisionEngineTests .Build(); Mocker.GetMock() - .Setup(c => c.GetFilesByAlbum(It.IsAny())) + .Setup(c => c.GetFilesByBook(It.IsAny())) .Returns(new List { _firstFile, _secondFile }); - _parseResultMulti = new RemoteAlbum + _parseResultMulti = new RemoteBook { - Artist = fakeArtist, - ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) }, - Albums = doubleAlbumList + Author = fakeArtist, + ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) }, + Books = doubleAlbumList }; - _parseResultSingle = new RemoteAlbum + _parseResultSingle = new RemoteBook { - Artist = fakeArtist, - ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) }, - Albums = singleAlbumList + Author = fakeArtist, + ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) }, + Books = singleAlbumList }; } @@ -76,7 +76,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [Test] public void should_return_true_if_album_has_no_existing_file() { - _parseResultSingle.Albums.First().BookFiles = new List(); + _parseResultSingle.Books.First().BookFiles = new List(); Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue(); } @@ -97,7 +97,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [Test] public void should_return_true_if_single_album_doesnt_exist_on_disk() { - _parseResultSingle.Albums = new List(); + _parseResultSingle.Books = new List(); Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue(); } @@ -115,7 +115,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { _firstFile.Quality = new QualityModel(Quality.MP3_320); _secondFile.Quality = new QualityModel(Quality.MP3_320); - _parseResultSingle.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_320); + _parseResultSingle.ParsedBookInfo.Quality = new QualityModel(Quality.MP3_320); Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse(); } @@ -129,7 +129,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void should_be_true_if_some_tracks_are_upgradable_and_none_are_downgrades() { WithFirstFileUpgradable(); - _parseResultSingle.ParsedAlbumInfo.Quality = _secondFile.Quality; + _parseResultSingle.ParsedBookInfo.Quality = _secondFile.Quality; Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue(); } @@ -137,7 +137,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void should_be_false_if_some_tracks_are_upgradable_and_some_are_downgrades() { WithFirstFileUpgradable(); - _parseResultSingle.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_320); + _parseResultSingle.ParsedBookInfo.Quality = new QualityModel(Quality.MP3_320); Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse(); } } diff --git a/src/NzbDrone.Core.Test/DiskSpace/DiskSpaceServiceFixture.cs b/src/NzbDrone.Core.Test/DiskSpace/DiskSpaceServiceFixture.cs index 823878262..de0a3dcea 100644 --- a/src/NzbDrone.Core.Test/DiskSpace/DiskSpaceServiceFixture.cs +++ b/src/NzbDrone.Core.Test/DiskSpace/DiskSpaceServiceFixture.cs @@ -5,8 +5,8 @@ using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; +using NzbDrone.Core.Books; using NzbDrone.Core.DiskSpace; -using NzbDrone.Core.Music; using NzbDrone.Core.RootFolders; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; @@ -52,8 +52,8 @@ namespace NzbDrone.Core.Test.DiskSpace private void GivenArtist(params Author[] artist) { - Mocker.GetMock() - .Setup(v => v.GetAllArtists()) + Mocker.GetMock() + .Setup(v => v.GetAllAuthors()) .Returns(artist.ToList()); } diff --git a/src/NzbDrone.Core.Test/Download/CompletedDownloadServiceTests/ImportFixture.cs b/src/NzbDrone.Core.Test/Download/CompletedDownloadServiceTests/ImportFixture.cs index f918e61f4..fed07cd15 100644 --- a/src/NzbDrone.Core.Test/Download/CompletedDownloadServiceTests/ImportFixture.cs +++ b/src/NzbDrone.Core.Test/Download/CompletedDownloadServiceTests/ImportFixture.cs @@ -4,14 +4,14 @@ using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.History; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.MediaFiles.TrackImport; +using NzbDrone.Core.MediaFiles.BookImport; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; @@ -38,7 +38,7 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests _trackedDownload = Builder.CreateNew() .With(c => c.State = TrackedDownloadState.Downloading) .With(c => c.DownloadItem = completed) - .With(c => c.RemoteAlbum = remoteAlbum) + .With(c => c.RemoteBook = remoteAlbum) .Build(); Mocker.GetMock() @@ -55,7 +55,7 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests Mocker.GetMock() .Setup(s => s.GetArtist("Drone.S01E01.HDTV")) - .Returns(remoteAlbum.Artist); + .Returns(remoteAlbum.Author); } private Book CreateAlbum(int id) @@ -66,18 +66,18 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests }; } - private RemoteAlbum BuildRemoteAlbum() + private RemoteBook BuildRemoteAlbum() { - return new RemoteAlbum + return new RemoteBook { - Artist = new Author(), - Albums = new List { CreateAlbum(1) } + Author = new Author(), + Books = new List { CreateAlbum(1) } }; } private void GivenABadlyNamedDownload() { - _trackedDownload.RemoteAlbum.Artist = null; + _trackedDownload.RemoteBook.Author = null; _trackedDownload.DownloadItem.DownloadId = "1234"; _trackedDownload.DownloadItem.Title = "Droned Pilot"; // Set a badly named download Mocker.GetMock() @@ -90,30 +90,30 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests Mocker.GetMock() .Setup(s => s.GetArtist("Droned S01E01")) - .Returns(BuildRemoteAlbum().Artist); + .Returns(BuildRemoteAlbum().Author); } private void GivenArtistMatch() { Mocker.GetMock() .Setup(s => s.GetArtist(It.IsAny())) - .Returns(_trackedDownload.RemoteAlbum.Artist); + .Returns(_trackedDownload.RemoteBook.Author); } [Test] public void should_not_mark_as_imported_if_all_files_were_rejected() { - Mocker.GetMock() + Mocker.GetMock() .Setup(v => v.ProcessPath(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(new List { new ImportResult( - new ImportDecision( - new LocalTrack { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() }, new Rejection("Rejected!")), "Test Failure"), + new ImportDecision( + new LocalBook { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() }, new Rejection("Rejected!")), "Test Failure"), new ImportResult( - new ImportDecision( - new LocalTrack { Path = @"C:\TestPath\Droned.S01E02.mkv".AsOsAgnostic() }, new Rejection("Rejected!")), "Test Failure") + new ImportDecision( + new LocalBook { Path = @"C:\TestPath\Droned.S01E02.mkv".AsOsAgnostic() }, new Rejection("Rejected!")), "Test Failure") }); Subject.Import(_trackedDownload); @@ -127,20 +127,20 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests [Test] public void should_not_mark_as_imported_if_no_tracks_were_parsed() { - Mocker.GetMock() + Mocker.GetMock() .Setup(v => v.ProcessPath(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(new List { new ImportResult( - new ImportDecision( - new LocalTrack { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() }, new Rejection("Rejected!")), "Test Failure"), + new ImportDecision( + new LocalBook { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() }, new Rejection("Rejected!")), "Test Failure"), new ImportResult( - new ImportDecision( - new LocalTrack { Path = @"C:\TestPath\Droned.S01E02.mkv".AsOsAgnostic() }, new Rejection("Rejected!")), "Test Failure") + new ImportDecision( + new LocalBook { Path = @"C:\TestPath\Droned.S01E02.mkv".AsOsAgnostic() }, new Rejection("Rejected!")), "Test Failure") }); - _trackedDownload.RemoteAlbum.Albums.Clear(); + _trackedDownload.RemoteBook.Books.Clear(); Subject.Import(_trackedDownload); @@ -150,12 +150,12 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests [Test] public void should_not_mark_as_imported_if_all_files_were_skipped() { - Mocker.GetMock() + Mocker.GetMock() .Setup(v => v.ProcessPath(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(new List { - new ImportResult(new ImportDecision(new LocalTrack { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() }), "Test Failure"), - new ImportResult(new ImportDecision(new LocalTrack { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() }), "Test Failure") + new ImportResult(new ImportDecision(new LocalBook { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() }), "Test Failure"), + new ImportResult(new ImportDecision(new LocalBook { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() }), "Test Failure") }); Subject.Import(_trackedDownload); @@ -168,17 +168,17 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests { GivenArtistMatch(); - _trackedDownload.RemoteAlbum.Albums = new List + _trackedDownload.RemoteBook.Books = new List { CreateAlbum(1) }; - Mocker.GetMock() + Mocker.GetMock() .Setup(v => v.ProcessPath(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(new List { - new ImportResult(new ImportDecision(new LocalTrack { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() })), - new ImportResult(new ImportDecision(new LocalTrack { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() }), "Test Failure") + new ImportResult(new ImportDecision(new LocalBook { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() })), + new ImportResult(new ImportDecision(new LocalBook { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() }), "Test Failure") }); Subject.Import(_trackedDownload); @@ -189,22 +189,22 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests [Test] public void should_not_mark_as_imported_if_some_tracks_were_not_imported() { - _trackedDownload.RemoteAlbum.Albums = new List + _trackedDownload.RemoteBook.Books = new List { CreateAlbum(1), CreateAlbum(1), CreateAlbum(1) }; - Mocker.GetMock() + Mocker.GetMock() .Setup(v => v.ProcessPath(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(new List { - new ImportResult(new ImportDecision(new LocalTrack { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() })), - new ImportResult(new ImportDecision(new LocalTrack { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() })), - new ImportResult(new ImportDecision(new LocalTrack { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() }), "Test Failure"), - new ImportResult(new ImportDecision(new LocalTrack { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() }), "Test Failure"), - new ImportResult(new ImportDecision(new LocalTrack { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() }), "Test Failure") + new ImportResult(new ImportDecision(new LocalBook { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() })), + new ImportResult(new ImportDecision(new LocalBook { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() })), + new ImportResult(new ImportDecision(new LocalBook { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() }), "Test Failure"), + new ImportResult(new ImportDecision(new LocalBook { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() }), "Test Failure"), + new ImportResult(new ImportDecision(new LocalBook { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() }), "Test Failure") }); var history = Builder.CreateListOfSize(2) @@ -228,15 +228,15 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests { var albums = Builder.CreateListOfSize(3).BuildList(); - _trackedDownload.RemoteAlbum.Albums = albums; + _trackedDownload.RemoteBook.Books = albums; - Mocker.GetMock() + Mocker.GetMock() .Setup(v => v.ProcessPath(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(new List { - new ImportResult(new ImportDecision(new LocalTrack { Path = @"C:\TestPath\Droned.S01E01.mkv" })), - new ImportResult(new ImportDecision(new LocalTrack { Path = @"C:\TestPath\Droned.S01E01.mkv" }), "Test Failure"), - new ImportResult(new ImportDecision(new LocalTrack { Path = @"C:\TestPath\Droned.S01E01.mkv" }), "Test Failure") + new ImportResult(new ImportDecision(new LocalBook { Path = @"C:\TestPath\Droned.S01E01.mkv" })), + new ImportResult(new ImportDecision(new LocalBook { Path = @"C:\TestPath\Droned.S01E01.mkv" }), "Test Failure"), + new ImportResult(new ImportDecision(new LocalBook { Path = @"C:\TestPath\Droned.S01E01.mkv" }), "Test Failure") }); var history = Builder.CreateListOfSize(2) @@ -258,22 +258,22 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests [Test] public void should_mark_as_imported_if_all_tracks_were_imported() { - _trackedDownload.RemoteAlbum.Albums = new List + _trackedDownload.RemoteBook.Books = new List { CreateAlbum(1) }; - Mocker.GetMock() + Mocker.GetMock() .Setup(v => v.ProcessPath(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(new List { new ImportResult( - new ImportDecision( - new LocalTrack { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() })), + new ImportDecision( + new LocalBook { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() })), new ImportResult( - new ImportDecision( - new LocalTrack { Path = @"C:\TestPath\Droned.S01E02.mkv".AsOsAgnostic() })) + new ImportDecision( + new LocalBook { Path = @"C:\TestPath\Droned.S01E02.mkv".AsOsAgnostic() })) }); Subject.Import(_trackedDownload); @@ -286,19 +286,19 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests { var albums = Builder.CreateListOfSize(2).BuildList(); - _trackedDownload.RemoteAlbum.Albums = albums; + _trackedDownload.RemoteBook.Books = albums; - Mocker.GetMock() + Mocker.GetMock() .Setup(v => v.ProcessPath(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(new List { new ImportResult( - new ImportDecision( - new LocalTrack { Path = @"C:\TestPath\Droned.S01E01.mkv", Album = albums[0] })), + new ImportDecision( + new LocalBook { Path = @"C:\TestPath\Droned.S01E01.mkv", Book = albums[0] })), new ImportResult( - new ImportDecision( - new LocalTrack { Path = @"C:\TestPath\Droned.S01E02.mkv", Album = albums[1] }), "Test Failure") + new ImportDecision( + new LocalBook { Path = @"C:\TestPath\Droned.S01E02.mkv", Book = albums[1] }), "Test Failure") }); var history = Builder.CreateListOfSize(2) @@ -322,11 +322,11 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests { GivenABadlyNamedDownload(); - Mocker.GetMock() + Mocker.GetMock() .Setup(v => v.ProcessPath(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(new List { - new ImportResult(new ImportDecision(new LocalTrack { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() })) + new ImportResult(new ImportDecision(new LocalBook { Path = @"C:\TestPath\Droned.S01E01.mkv".AsOsAgnostic() })) }); Subject.Import(_trackedDownload); @@ -344,8 +344,8 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests private void AssertImported() { - Mocker.GetMock() - .Verify(v => v.ProcessPath(_trackedDownload.DownloadItem.OutputPath.FullPath, ImportMode.Auto, _trackedDownload.RemoteAlbum.Artist, _trackedDownload.DownloadItem), Times.Once()); + Mocker.GetMock() + .Verify(v => v.ProcessPath(_trackedDownload.DownloadItem.OutputPath.FullPath, ImportMode.Auto, _trackedDownload.RemoteBook.Author, _trackedDownload.DownloadItem), Times.Once()); Mocker.GetMock() .Verify(v => v.PublishEvent(It.IsAny()), Times.Once()); diff --git a/src/NzbDrone.Core.Test/Download/CompletedDownloadServiceTests/ProcessFixture.cs b/src/NzbDrone.Core.Test/Download/CompletedDownloadServiceTests/ProcessFixture.cs index ea980c277..e0b539f42 100644 --- a/src/NzbDrone.Core.Test/Download/CompletedDownloadServiceTests/ProcessFixture.cs +++ b/src/NzbDrone.Core.Test/Download/CompletedDownloadServiceTests/ProcessFixture.cs @@ -4,10 +4,10 @@ using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; +using NzbDrone.Core.Books; using NzbDrone.Core.Download; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.History; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; @@ -34,7 +34,7 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests _trackedDownload = Builder.CreateNew() .With(c => c.State = TrackedDownloadState.Downloading) .With(c => c.DownloadItem = completed) - .With(c => c.RemoteAlbum = remoteAlbum) + .With(c => c.RemoteBook = remoteAlbum) .Build(); Mocker.GetMock() @@ -51,15 +51,15 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests Mocker.GetMock() .Setup(s => s.GetArtist("Drone.S01E01.HDTV")) - .Returns(remoteAlbum.Artist); + .Returns(remoteAlbum.Author); } - private RemoteAlbum BuildRemoteAlbum() + private RemoteBook BuildRemoteAlbum() { - return new RemoteAlbum + return new RemoteBook { - Artist = new Author(), - Albums = new List { new Book { Id = 1 } } + Author = new Author(), + Books = new List { new Book { Id = 1 } } }; } @@ -74,7 +74,7 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests { Mocker.GetMock() .Setup(s => s.GetArtist(It.IsAny())) - .Returns(_trackedDownload.RemoteAlbum.Artist); + .Returns(_trackedDownload.RemoteBook.Author); } private void GivenABadlyNamedDownload() @@ -91,7 +91,7 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests Mocker.GetMock() .Setup(s => s.GetArtist("Droned S01E01")) - .Returns(BuildRemoteAlbum().Artist); + .Returns(BuildRemoteAlbum().Author); } [TestCase(DownloadItemStatus.Downloading)] @@ -145,7 +145,7 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests public void should_not_process_if_the_download_cannot_be_tracked_using_the_source_title_as_it_was_initiated_externally() { GivenABadlyNamedDownload(); - _trackedDownload.RemoteAlbum.Artist = null; + _trackedDownload.RemoteBook.Author = null; Mocker.GetMock() .Setup(s => s.MostRecentForDownloadId(It.Is(i => i == "1234"))); @@ -158,7 +158,7 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests [Test] public void should_not_process_when_there_is_a_title_mismatch() { - _trackedDownload.RemoteAlbum.Artist = null; + _trackedDownload.RemoteBook.Author = null; Mocker.GetMock() .Setup(s => s.GetArtist("Drone.S01E01.HDTV")) .Returns((Author)null); diff --git a/src/NzbDrone.Core.Test/Download/DownloadApprovedReportsTests/DownloadApprovedFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadApprovedReportsTests/DownloadApprovedFixture.cs index 17b4456e8..31741484e 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadApprovedReportsTests/DownloadApprovedFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadApprovedReportsTests/DownloadApprovedFixture.cs @@ -4,13 +4,13 @@ using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Download.Clients; using NzbDrone.Core.Download.Pending; using NzbDrone.Core.Exceptions; using NzbDrone.Core.Indexers; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Qualities; using NzbDrone.Core.Qualities; @@ -37,20 +37,20 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests .Build(); } - private RemoteAlbum GetRemoteAlbum(List albums, QualityModel quality, DownloadProtocol downloadProtocol = DownloadProtocol.Usenet) + private RemoteBook GetRemoteAlbum(List albums, QualityModel quality, DownloadProtocol downloadProtocol = DownloadProtocol.Usenet) { - var remoteAlbum = new RemoteAlbum(); - remoteAlbum.ParsedAlbumInfo = new ParsedAlbumInfo(); - remoteAlbum.ParsedAlbumInfo.Quality = quality; + var remoteAlbum = new RemoteBook(); + remoteAlbum.ParsedBookInfo = new ParsedBookInfo(); + remoteAlbum.ParsedBookInfo.Quality = quality; - remoteAlbum.Albums = new List(); - remoteAlbum.Albums.AddRange(albums); + remoteAlbum.Books = new List(); + remoteAlbum.Books.AddRange(albums); remoteAlbum.Release = new ReleaseInfo(); remoteAlbum.Release.DownloadProtocol = downloadProtocol; remoteAlbum.Release.PublishDate = DateTime.UtcNow; - remoteAlbum.Artist = Builder.CreateNew() + remoteAlbum.Author = Builder.CreateNew() .With(e => e.QualityProfile = new QualityProfile { Items = Qualities.QualityFixture.GetDefaultQualities() }) .Build(); @@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests decisions.Add(new DownloadDecision(remoteAlbum)); Subject.ProcessDecisions(decisions); - Mocker.GetMock().Verify(v => v.DownloadReport(It.IsAny()), Times.Once()); + Mocker.GetMock().Verify(v => v.DownloadReport(It.IsAny()), Times.Once()); } [Test] @@ -81,7 +81,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests decisions.Add(new DownloadDecision(remoteAlbum)); Subject.ProcessDecisions(decisions); - Mocker.GetMock().Verify(v => v.DownloadReport(It.IsAny()), Times.Once()); + Mocker.GetMock().Verify(v => v.DownloadReport(It.IsAny()), Times.Once()); } [Test] @@ -100,7 +100,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests decisions.Add(new DownloadDecision(remoteAlbum2)); Subject.ProcessDecisions(decisions); - Mocker.GetMock().Verify(v => v.DownloadReport(It.IsAny()), Times.Once()); + Mocker.GetMock().Verify(v => v.DownloadReport(It.IsAny()), Times.Once()); } [Test] @@ -165,7 +165,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests var decisions = new List(); decisions.Add(new DownloadDecision(remoteAlbum)); - Mocker.GetMock().Setup(s => s.DownloadReport(It.IsAny())).Throws(new Exception()); + Mocker.GetMock().Setup(s => s.DownloadReport(It.IsAny())).Throws(new Exception()); Subject.ProcessDecisions(decisions).Grabbed.Should().BeEmpty(); ExceptionVerification.ExpectedWarns(1); } @@ -174,8 +174,8 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests public void should_return_an_empty_list_when_none_are_appproved() { var decisions = new List(); - decisions.Add(new DownloadDecision(new RemoteAlbum(), new Rejection("Failure!"))); - decisions.Add(new DownloadDecision(new RemoteAlbum(), new Rejection("Failure!"))); + decisions.Add(new DownloadDecision(new RemoteBook(), new Rejection("Failure!"))); + decisions.Add(new DownloadDecision(new RemoteBook(), new Rejection("Failure!"))); Subject.GetQualifiedReports(decisions).Should().BeEmpty(); } @@ -190,7 +190,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests decisions.Add(new DownloadDecision(remoteAlbum, new Rejection("Failure!", RejectionType.Temporary))); Subject.ProcessDecisions(decisions); - Mocker.GetMock().Verify(v => v.DownloadReport(It.IsAny()), Times.Never()); + Mocker.GetMock().Verify(v => v.DownloadReport(It.IsAny()), Times.Never()); } [Test] @@ -231,11 +231,11 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests decisions.Add(new DownloadDecision(remoteAlbum)); decisions.Add(new DownloadDecision(remoteAlbum)); - Mocker.GetMock().Setup(s => s.DownloadReport(It.IsAny())) + Mocker.GetMock().Setup(s => s.DownloadReport(It.IsAny())) .Throws(new DownloadClientUnavailableException("Download client failed")); Subject.ProcessDecisions(decisions); - Mocker.GetMock().Verify(v => v.DownloadReport(It.IsAny()), Times.Once()); + Mocker.GetMock().Verify(v => v.DownloadReport(It.IsAny()), Times.Once()); } [Test] @@ -249,12 +249,12 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests decisions.Add(new DownloadDecision(remoteAlbum)); decisions.Add(new DownloadDecision(remoteAlbum2)); - Mocker.GetMock().Setup(s => s.DownloadReport(It.Is(r => r.Release.DownloadProtocol == DownloadProtocol.Usenet))) + Mocker.GetMock().Setup(s => s.DownloadReport(It.Is(r => r.Release.DownloadProtocol == DownloadProtocol.Usenet))) .Throws(new DownloadClientUnavailableException("Download client failed")); Subject.ProcessDecisions(decisions); - Mocker.GetMock().Verify(v => v.DownloadReport(It.Is(r => r.Release.DownloadProtocol == DownloadProtocol.Usenet)), Times.Once()); - Mocker.GetMock().Verify(v => v.DownloadReport(It.Is(r => r.Release.DownloadProtocol == DownloadProtocol.Torrent)), Times.Once()); + Mocker.GetMock().Verify(v => v.DownloadReport(It.Is(r => r.Release.DownloadProtocol == DownloadProtocol.Usenet)), Times.Once()); + Mocker.GetMock().Verify(v => v.DownloadReport(It.Is(r => r.Release.DownloadProtocol == DownloadProtocol.Torrent)), Times.Once()); } [Test] @@ -267,7 +267,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests decisions.Add(new DownloadDecision(remoteAlbum)); Mocker.GetMock() - .Setup(s => s.DownloadReport(It.IsAny())) + .Setup(s => s.DownloadReport(It.IsAny())) .Throws(new ReleaseUnavailableException(remoteAlbum.Release, "That 404 Error is not just a Quirk")); var result = Subject.ProcessDecisions(decisions); diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/TorrentBlackholeFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/TorrentBlackholeFixture.cs index 13be200cb..a5e7bb63a 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/TorrentBlackholeFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/TorrentBlackholeFixture.cs @@ -87,7 +87,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole _magnetFilePath = Path.ChangeExtension(_filePath, extension); } - protected override RemoteAlbum CreateRemoteAlbum() + protected override RemoteBook CreateRemoteAlbum() { var remoteAlbum = base.CreateRemoteAlbum(); var torrentInfo = new TorrentInfo(); diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs index 1b0468945..c9c6f76ab 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs @@ -5,10 +5,10 @@ using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; using NzbDrone.Common.Http; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; using NzbDrone.Core.Download; using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.RemotePathMappings; @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests .Returns(30); Mocker.GetMock() - .Setup(s => s.Map(It.IsAny(), null)) + .Setup(s => s.Map(It.IsAny(), null)) .Returns(() => CreateRemoteAlbum()); Mocker.GetMock() @@ -42,19 +42,19 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests .Returns((h, r) => r); } - protected virtual RemoteAlbum CreateRemoteAlbum() + protected virtual RemoteBook CreateRemoteAlbum() { - var remoteAlbum = new RemoteAlbum(); + var remoteAlbum = new RemoteBook(); remoteAlbum.Release = new ReleaseInfo(); remoteAlbum.Release.Title = _title; remoteAlbum.Release.DownloadUrl = _downloadUrl; remoteAlbum.Release.DownloadProtocol = Subject.Protocol; - remoteAlbum.ParsedAlbumInfo = new ParsedAlbumInfo(); + remoteAlbum.ParsedBookInfo = new ParsedBookInfo(); - remoteAlbum.Albums = new List(); + remoteAlbum.Books = new List(); - remoteAlbum.Artist = new Author(); + remoteAlbum.Author = new Author(); return remoteAlbum; } diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/TorrentDownloadStationFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/TorrentDownloadStationFixture.cs index 82d710ed2..96452673b 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/TorrentDownloadStationFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/TorrentDownloadStationFixture.cs @@ -360,7 +360,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests .Callback(PrepareClientToReturnQueuedItem); } - protected override RemoteAlbum CreateRemoteAlbum() + protected override RemoteBook CreateRemoteAlbum() { var album = base.CreateRemoteAlbum(); diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/UsenetDownloadStationFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/UsenetDownloadStationFixture.cs index c6848c5b0..8a0ff0c79 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/UsenetDownloadStationFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/UsenetDownloadStationFixture.cs @@ -33,7 +33,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests protected string _defaultDestination = "somepath"; protected OsPath _physicalPath = new OsPath("/mnt/sdb1/mydata"); - protected RemoteAlbum _remoteAlbum; + protected RemoteBook _remoteAlbum; protected Dictionary _downloadStationConfigItems; diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs index 7f4cdfcb1..0e75bd7a6 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs @@ -20,7 +20,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests private string _pneumaticFolder; private string _strmFolder; private string _nzbPath; - private RemoteAlbum _remoteAlbum; + private RemoteBook _remoteAlbum; [SetUp] public void Setup() @@ -30,12 +30,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests _nzbPath = Path.Combine(_pneumaticFolder, _title + ".nzb").AsOsAgnostic(); _strmFolder = @"d:\unsorted tv\".AsOsAgnostic(); - _remoteAlbum = new RemoteAlbum(); + _remoteAlbum = new RemoteBook(); _remoteAlbum.Release = new ReleaseInfo(); _remoteAlbum.Release.Title = _title; _remoteAlbum.Release.DownloadUrl = _nzbUrl; - _remoteAlbum.ParsedAlbumInfo = new ParsedAlbumInfo(); + _remoteAlbum.ParsedBookInfo = new ParsedBookInfo(); Subject.Definition = new DownloadClientDefinition(); Subject.Definition.Settings = new PneumaticSettings @@ -70,7 +70,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests public void should_throw_if_discography_download() { _remoteAlbum.Release.Title = "Alien Ant Farm - Discography"; - _remoteAlbum.ParsedAlbumInfo.Discography = true; + _remoteAlbum.ParsedBookInfo.Discography = true; Assert.Throws(() => Subject.Download(_remoteAlbum)); } diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs index fa2345ab7..bc9e02cdb 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs @@ -6,10 +6,10 @@ using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; +using NzbDrone.Core.Books; using NzbDrone.Core.Download; using NzbDrone.Core.Download.Clients.Sabnzbd; using NzbDrone.Core.Download.Clients.Sabnzbd.Responses; -using NzbDrone.Core.Music; using NzbDrone.Core.RemotePathMappings; using NzbDrone.Core.Validation; using NzbDrone.Test.Common; @@ -354,7 +354,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests .Returns(new SabnzbdAddResponse { Ids = new List { "readarrtest" } }); var remoteAlbum = CreateRemoteAlbum(); - remoteAlbum.Albums = Builder.CreateListOfSize(1) + remoteAlbum.Books = Builder.CreateListOfSize(1) .All() .With(e => e.ReleaseDate = DateTime.Today) .Build() diff --git a/src/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs index 21b50228c..c1ba20ce1 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs @@ -6,11 +6,11 @@ using FizzWare.NBuilder; using Moq; using NUnit.Framework; using NzbDrone.Common.Http; +using NzbDrone.Core.Books; using NzbDrone.Core.Download; using NzbDrone.Core.Download.Clients; using NzbDrone.Core.Exceptions; using NzbDrone.Core.Indexers; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; @@ -19,7 +19,7 @@ namespace NzbDrone.Core.Test.Download [TestFixture] public class DownloadServiceFixture : CoreTest { - private RemoteAlbum _parseResult; + private RemoteBook _parseResult; private List _downloadClients; [SetUp] public void Setup() @@ -45,10 +45,10 @@ namespace NzbDrone.Core.Test.Download .With(v => v.DownloadUrl = "http://test.site/download1.ext") .Build(); - _parseResult = Builder.CreateNew() - .With(c => c.Artist = Builder.CreateNew().Build()) + _parseResult = Builder.CreateNew() + .With(c => c.Author = Builder.CreateNew().Build()) .With(c => c.Release = releaseInfo) - .With(c => c.Albums = episodes) + .With(c => c.Books = episodes) .Build(); } @@ -80,42 +80,42 @@ namespace NzbDrone.Core.Test.Download public void Download_report_should_publish_on_grab_event() { var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())); + mock.Setup(s => s.Download(It.IsAny())); Subject.DownloadReport(_parseResult); - VerifyEventPublished(); + VerifyEventPublished(); } [Test] public void Download_report_should_grab_using_client() { var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())); + mock.Setup(s => s.Download(It.IsAny())); Subject.DownloadReport(_parseResult); - mock.Verify(s => s.Download(It.IsAny()), Times.Once()); + mock.Verify(s => s.Download(It.IsAny()), Times.Once()); } [Test] public void Download_report_should_not_publish_on_failed_grab_event() { var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())) + mock.Setup(s => s.Download(It.IsAny())) .Throws(new WebException()); Assert.Throws(() => Subject.DownloadReport(_parseResult)); - VerifyEventNotPublished(); + VerifyEventNotPublished(); } [Test] public void Download_report_should_trigger_indexer_backoff_on_indexer_error() { var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())) - .Callback(v => + mock.Setup(s => s.Download(It.IsAny())) + .Callback(v => { throw new ReleaseDownloadException(v.Release, "Error", new WebException()); }); @@ -134,8 +134,8 @@ namespace NzbDrone.Core.Test.Download response.Headers["Retry-After"] = "300"; var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())) - .Callback(v => + mock.Setup(s => s.Download(It.IsAny())) + .Callback(v => { throw new ReleaseDownloadException(v.Release, "Error", new TooManyRequestsException(request, response)); }); @@ -154,8 +154,8 @@ namespace NzbDrone.Core.Test.Download response.Headers["Retry-After"] = DateTime.UtcNow.AddSeconds(300).ToString("r"); var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())) - .Callback(v => + mock.Setup(s => s.Download(It.IsAny())) + .Callback(v => { throw new ReleaseDownloadException(v.Release, "Error", new TooManyRequestsException(request, response)); }); @@ -171,7 +171,7 @@ namespace NzbDrone.Core.Test.Download public void Download_report_should_not_trigger_indexer_backoff_on_downloadclient_error() { var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())) + mock.Setup(s => s.Download(It.IsAny())) .Throws(new DownloadClientException("Some Error")); Assert.Throws(() => Subject.DownloadReport(_parseResult)); @@ -184,8 +184,8 @@ namespace NzbDrone.Core.Test.Download public void Download_report_should_not_trigger_indexer_backoff_on_indexer_404_error() { var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())) - .Callback(v => + mock.Setup(s => s.Download(It.IsAny())) + .Callback(v => { throw new ReleaseUnavailableException(v.Release, "Error", new WebException()); }); @@ -201,8 +201,8 @@ namespace NzbDrone.Core.Test.Download { Assert.Throws(() => Subject.DownloadReport(_parseResult)); - Mocker.GetMock().Verify(c => c.Download(It.IsAny()), Times.Never()); - VerifyEventNotPublished(); + Mocker.GetMock().Verify(c => c.Download(It.IsAny()), Times.Never()); + VerifyEventNotPublished(); } [Test] @@ -224,8 +224,8 @@ namespace NzbDrone.Core.Test.Download Subject.DownloadReport(_parseResult); Mocker.GetMock().Verify(c => c.GetBlockedProviders(), Times.Never()); - mockUsenet.Verify(c => c.Download(It.IsAny()), Times.Once()); - VerifyEventPublished(); + mockUsenet.Verify(c => c.Download(It.IsAny()), Times.Once()); + VerifyEventPublished(); } [Test] @@ -236,8 +236,8 @@ namespace NzbDrone.Core.Test.Download Subject.DownloadReport(_parseResult); - mockTorrent.Verify(c => c.Download(It.IsAny()), Times.Never()); - mockUsenet.Verify(c => c.Download(It.IsAny()), Times.Once()); + mockTorrent.Verify(c => c.Download(It.IsAny()), Times.Never()); + mockUsenet.Verify(c => c.Download(It.IsAny()), Times.Once()); } [Test] @@ -250,8 +250,8 @@ namespace NzbDrone.Core.Test.Download Subject.DownloadReport(_parseResult); - mockTorrent.Verify(c => c.Download(It.IsAny()), Times.Once()); - mockUsenet.Verify(c => c.Download(It.IsAny()), Times.Never()); + mockTorrent.Verify(c => c.Download(It.IsAny()), Times.Once()); + mockUsenet.Verify(c => c.Download(It.IsAny()), Times.Never()); } } } diff --git a/src/NzbDrone.Core.Test/Download/FailedDownloadServiceTests/ProcessFailedFixture.cs b/src/NzbDrone.Core.Test/Download/FailedDownloadServiceTests/ProcessFailedFixture.cs index cf7f19d42..8f66f49bf 100644 --- a/src/NzbDrone.Core.Test/Download/FailedDownloadServiceTests/ProcessFailedFixture.cs +++ b/src/NzbDrone.Core.Test/Download/FailedDownloadServiceTests/ProcessFailedFixture.cs @@ -4,11 +4,11 @@ using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; +using NzbDrone.Core.Books; using NzbDrone.Core.Download; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.History; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; @@ -32,16 +32,16 @@ namespace NzbDrone.Core.Test.Download.FailedDownloadServiceTests _grabHistory = Builder.CreateListOfSize(2).BuildList(); - var remoteAlbum = new RemoteAlbum + var remoteAlbum = new RemoteBook { - Artist = new Author(), - Albums = new List { new Book { Id = 1 } } + Author = new Author(), + Books = new List { new Book { Id = 1 } } }; _trackedDownload = Builder.CreateNew() .With(c => c.State = TrackedDownloadState.DownloadFailedPending) .With(c => c.DownloadItem = completed) - .With(c => c.RemoteAlbum = remoteAlbum) + .With(c => c.RemoteBook = remoteAlbum) .Build(); Mocker.GetMock() diff --git a/src/NzbDrone.Core.Test/Download/FailedDownloadServiceTests/ProcessFixture.cs b/src/NzbDrone.Core.Test/Download/FailedDownloadServiceTests/ProcessFixture.cs index 16b8eb744..6735e1c96 100644 --- a/src/NzbDrone.Core.Test/Download/FailedDownloadServiceTests/ProcessFixture.cs +++ b/src/NzbDrone.Core.Test/Download/FailedDownloadServiceTests/ProcessFixture.cs @@ -4,11 +4,11 @@ using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; +using NzbDrone.Core.Books; using NzbDrone.Core.Download; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.History; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; @@ -32,16 +32,16 @@ namespace NzbDrone.Core.Test.Download.FailedDownloadServiceTests _grabHistory = Builder.CreateListOfSize(2).BuildList(); - var remoteAlbum = new RemoteAlbum + var remoteAlbum = new RemoteBook { - Artist = new Author(), - Albums = new List { new Book { Id = 1 } } + Author = new Author(), + Books = new List { new Book { Id = 1 } } }; _trackedDownload = Builder.CreateNew() .With(c => c.State = TrackedDownloadState.Downloading) .With(c => c.DownloadItem = completed) - .With(c => c.RemoteAlbum = remoteAlbum) + .With(c => c.RemoteBook = remoteAlbum) .Build(); Mocker.GetMock() diff --git a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/AddFixture.cs b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/AddFixture.cs index 79ac001c4..1615c811e 100644 --- a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/AddFixture.cs +++ b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/AddFixture.cs @@ -5,10 +5,10 @@ using FizzWare.NBuilder; using Moq; using NUnit.Framework; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download.Pending; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Qualities; @@ -25,8 +25,8 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests private Book _album; private QualityProfile _profile; private ReleaseInfo _release; - private ParsedAlbumInfo _parsedAlbumInfo; - private RemoteAlbum _remoteAlbum; + private ParsedBookInfo _parsedAlbumInfo; + private RemoteBook _remoteAlbum; private List _heldReleases; [SetUp] @@ -54,13 +54,13 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests _release = Builder.CreateNew().Build(); - _parsedAlbumInfo = Builder.CreateNew().Build(); + _parsedAlbumInfo = Builder.CreateNew().Build(); _parsedAlbumInfo.Quality = new QualityModel(Quality.MP3_320); - _remoteAlbum = new RemoteAlbum(); - _remoteAlbum.Albums = new List { _album }; - _remoteAlbum.Artist = _artist; - _remoteAlbum.ParsedAlbumInfo = _parsedAlbumInfo; + _remoteAlbum = new RemoteBook(); + _remoteAlbum.Books = new List { _album }; + _remoteAlbum.Author = _artist; + _remoteAlbum.ParsedBookInfo = _parsedAlbumInfo; _remoteAlbum.Release = _release; _temporarilyRejected = new DownloadDecision(_remoteAlbum, new Rejection("Temp Rejected", RejectionType.Temporary)); @@ -75,16 +75,16 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests .Setup(s => s.AllByAuthorId(It.IsAny())) .Returns(i => _heldReleases.Where(v => v.AuthorId == i).ToList()); - Mocker.GetMock() - .Setup(s => s.GetArtist(It.IsAny())) + Mocker.GetMock() + .Setup(s => s.GetAuthor(It.IsAny())) .Returns(_artist); - Mocker.GetMock() - .Setup(s => s.GetArtists(It.IsAny>())) + Mocker.GetMock() + .Setup(s => s.GetAuthors(It.IsAny>())) .Returns(new List { _artist }); Mocker.GetMock() - .Setup(s => s.GetAlbums(It.IsAny(), _artist, null)) + .Setup(s => s.GetAlbums(It.IsAny(), _artist, null)) .Returns(new List { _album }); Mocker.GetMock() diff --git a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveGrabbedFixture.cs b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveGrabbedFixture.cs index e3a251548..c34d20618 100644 --- a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveGrabbedFixture.cs +++ b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveGrabbedFixture.cs @@ -4,11 +4,11 @@ using FizzWare.NBuilder; using Moq; using NUnit.Framework; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Download.Pending; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Qualities; @@ -25,8 +25,8 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests private Book _album; private QualityProfile _profile; private ReleaseInfo _release; - private ParsedAlbumInfo _parsedAlbumInfo; - private RemoteAlbum _remoteAlbum; + private ParsedBookInfo _parsedAlbumInfo; + private RemoteBook _remoteAlbum; private List _heldReleases; [SetUp] @@ -54,13 +54,13 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests _release = Builder.CreateNew().Build(); - _parsedAlbumInfo = Builder.CreateNew().Build(); + _parsedAlbumInfo = Builder.CreateNew().Build(); _parsedAlbumInfo.Quality = new QualityModel(Quality.MP3_320); - _remoteAlbum = new RemoteAlbum(); - _remoteAlbum.Albums = new List { _album }; - _remoteAlbum.Artist = _artist; - _remoteAlbum.ParsedAlbumInfo = _parsedAlbumInfo; + _remoteAlbum = new RemoteBook(); + _remoteAlbum.Books = new List { _album }; + _remoteAlbum.Author = _artist; + _remoteAlbum.ParsedBookInfo = _parsedAlbumInfo; _remoteAlbum.Release = _release; _temporarilyRejected = new DownloadDecision(_remoteAlbum, new Rejection("Temp Rejected", RejectionType.Temporary)); @@ -75,16 +75,16 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests .Setup(s => s.AllByAuthorId(It.IsAny())) .Returns(i => _heldReleases.Where(v => v.AuthorId == i).ToList()); - Mocker.GetMock() - .Setup(s => s.GetArtist(It.IsAny())) + Mocker.GetMock() + .Setup(s => s.GetAuthor(It.IsAny())) .Returns(_artist); - Mocker.GetMock() - .Setup(s => s.GetArtists(It.IsAny>())) + Mocker.GetMock() + .Setup(s => s.GetAuthors(It.IsAny>())) .Returns(new List { _artist }); Mocker.GetMock() - .Setup(s => s.GetAlbums(It.IsAny(), _artist, null)) + .Setup(s => s.GetAlbums(It.IsAny(), _artist, null)) .Returns(new List { _album }); Mocker.GetMock() @@ -101,7 +101,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests .All() .With(h => h.AuthorId = _artist.Id) .With(h => h.Release = _release.JsonClone()) - .With(h => h.ParsedAlbumInfo = parsedEpisodeInfo) + .With(h => h.ParsedBookInfo = parsedEpisodeInfo) .Build(); _heldReleases.AddRange(heldReleases); @@ -112,7 +112,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests { GivenHeldRelease(_parsedAlbumInfo.Quality); - Subject.Handle(new AlbumGrabbedEvent(_remoteAlbum)); + Subject.Handle(new BookGrabbedEvent(_remoteAlbum)); VerifyDelete(); } @@ -122,7 +122,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests { GivenHeldRelease(new QualityModel(Quality.MP3_320)); - Subject.Handle(new AlbumGrabbedEvent(_remoteAlbum)); + Subject.Handle(new BookGrabbedEvent(_remoteAlbum)); VerifyDelete(); } @@ -132,7 +132,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests { GivenHeldRelease(new QualityModel(Quality.FLAC)); - Subject.Handle(new AlbumGrabbedEvent(_remoteAlbum)); + Subject.Handle(new BookGrabbedEvent(_remoteAlbum)); VerifyNoDelete(); } diff --git a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemovePendingFixture.cs b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemovePendingFixture.cs index 78d9eb823..f6383ac8e 100644 --- a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemovePendingFixture.cs +++ b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemovePendingFixture.cs @@ -4,8 +4,8 @@ using FizzWare.NBuilder; using Moq; using NUnit.Framework; using NzbDrone.Common.Crypto; +using NzbDrone.Core.Books; using NzbDrone.Core.Download.Pending; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; @@ -34,16 +34,16 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests .Setup(s => s.All()) .Returns(_pending); - Mocker.GetMock() - .Setup(s => s.GetArtist(It.IsAny())) + Mocker.GetMock() + .Setup(s => s.GetAuthor(It.IsAny())) .Returns(new Author()); - Mocker.GetMock() - .Setup(s => s.GetArtists(It.IsAny>())) + Mocker.GetMock() + .Setup(s => s.GetAuthors(It.IsAny>())) .Returns(new List { new Author() }); Mocker.GetMock() - .Setup(s => s.GetAlbums(It.IsAny(), It.IsAny(), null)) + .Setup(s => s.GetAlbums(It.IsAny(), It.IsAny(), null)) .Returns(new List { _album }); } @@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests _pending.Add(new PendingRelease { Id = id, - ParsedAlbumInfo = new ParsedAlbumInfo { AlbumTitle = album } + ParsedBookInfo = new ParsedBookInfo { BookTitle = album } }); } @@ -61,7 +61,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests { AddPending(id: 1, album: "Album"); - var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-album{1}", 1, _album.Id)); + var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-book{1}", 1, _album.Id)); Subject.RemovePendingQueueItems(queueId); @@ -76,7 +76,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests AddPending(id: 3, album: "Album 3"); AddPending(id: 4, album: "Album 3"); - var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-album{1}", 3, _album.Id)); + var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-book{1}", 3, _album.Id)); Subject.RemovePendingQueueItems(queueId); @@ -91,7 +91,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests AddPending(id: 3, album: "Album 2"); AddPending(id: 4, album: "Album 3"); - var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-album{1}", 1, _album.Id)); + var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-book{1}", 1, _album.Id)); Subject.RemovePendingQueueItems(queueId); diff --git a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveRejectedFixture.cs b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveRejectedFixture.cs index 3e44836d3..adc475a9f 100644 --- a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveRejectedFixture.cs +++ b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveRejectedFixture.cs @@ -4,12 +4,12 @@ using FizzWare.NBuilder; using Moq; using NUnit.Framework; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Download.Pending; using NzbDrone.Core.Indexers; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Qualities; @@ -26,8 +26,8 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests private Book _album; private QualityProfile _profile; private ReleaseInfo _release; - private ParsedAlbumInfo _parsedAlbumInfo; - private RemoteAlbum _remoteAlbum; + private ParsedBookInfo _parsedAlbumInfo; + private RemoteBook _remoteAlbum; [SetUp] public void Setup() @@ -54,13 +54,13 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests _release = Builder.CreateNew().Build(); - _parsedAlbumInfo = Builder.CreateNew().Build(); + _parsedAlbumInfo = Builder.CreateNew().Build(); _parsedAlbumInfo.Quality = new QualityModel(Quality.MP3_320); - _remoteAlbum = new RemoteAlbum(); - _remoteAlbum.Albums = new List { _album }; - _remoteAlbum.Artist = _artist; - _remoteAlbum.ParsedAlbumInfo = _parsedAlbumInfo; + _remoteAlbum = new RemoteBook(); + _remoteAlbum.Books = new List { _album }; + _remoteAlbum.Author = _artist; + _remoteAlbum.ParsedBookInfo = _parsedAlbumInfo; _remoteAlbum.Release = _release; _temporarilyRejected = new DownloadDecision(_remoteAlbum, new Rejection("Temp Rejected", RejectionType.Temporary)); @@ -69,16 +69,16 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests .Setup(s => s.All()) .Returns(new List()); - Mocker.GetMock() - .Setup(s => s.GetArtist(It.IsAny())) + Mocker.GetMock() + .Setup(s => s.GetAuthor(It.IsAny())) .Returns(_artist); - Mocker.GetMock() - .Setup(s => s.GetArtists(It.IsAny>())) + Mocker.GetMock() + .Setup(s => s.GetAuthors(It.IsAny>())) .Returns(new List { _artist }); Mocker.GetMock() - .Setup(s => s.GetAlbums(It.IsAny(), _artist, null)) + .Setup(s => s.GetAlbums(It.IsAny(), _artist, null)) .Returns(new List { _album }); Mocker.GetMock() diff --git a/src/NzbDrone.Core.Test/Download/RedownloadFailedDownloadServiceFixture.cs b/src/NzbDrone.Core.Test/Download/RedownloadFailedDownloadServiceFixture.cs index f17cdc696..77ddeac88 100644 --- a/src/NzbDrone.Core.Test/Download/RedownloadFailedDownloadServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Download/RedownloadFailedDownloadServiceFixture.cs @@ -2,11 +2,11 @@ using System.Collections.Generic; using FizzWare.NBuilder; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; using NzbDrone.Core.Download; using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Messaging.Commands; -using NzbDrone.Core.Music; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.Download @@ -21,8 +21,8 @@ namespace NzbDrone.Core.Test.Download .Setup(x => x.AutoRedownloadFailed) .Returns(true); - Mocker.GetMock() - .Setup(x => x.GetAlbumsByArtist(It.IsAny())) + Mocker.GetMock() + .Setup(x => x.GetBooksByAuthor(It.IsAny())) .Returns(Builder.CreateListOfSize(3).Build() as List); } @@ -75,14 +75,14 @@ namespace NzbDrone.Core.Test.Download Subject.Handle(failedEvent); Mocker.GetMock() - .Verify(x => x.Push(It.Is(c => c.BookIds.Count == 1 && + .Verify(x => x.Push(It.Is(c => c.BookIds.Count == 1 && c.BookIds[0] == 2), It.IsAny(), It.IsAny()), Times.Once()); Mocker.GetMock() - .Verify(x => x.Push(It.IsAny(), It.IsAny(), It.IsAny()), + .Verify(x => x.Push(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); } @@ -98,7 +98,7 @@ namespace NzbDrone.Core.Test.Download Subject.Handle(failedEvent); Mocker.GetMock() - .Verify(x => x.Push(It.Is(c => c.BookIds.Count == 2 && + .Verify(x => x.Push(It.Is(c => c.BookIds.Count == 2 && c.BookIds[0] == 2 && c.BookIds[1] == 3), It.IsAny(), @@ -106,7 +106,7 @@ namespace NzbDrone.Core.Test.Download Times.Once()); Mocker.GetMock() - .Verify(x => x.Push(It.IsAny(), It.IsAny(), It.IsAny()), + .Verify(x => x.Push(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); } @@ -123,13 +123,13 @@ namespace NzbDrone.Core.Test.Download Subject.Handle(failedEvent); Mocker.GetMock() - .Verify(x => x.Push(It.Is(c => c.AuthorId == failedEvent.AuthorId), + .Verify(x => x.Push(It.Is(c => c.AuthorId == failedEvent.AuthorId), It.IsAny(), It.IsAny()), Times.Once()); Mocker.GetMock() - .Verify(x => x.Push(It.IsAny(), It.IsAny(), It.IsAny()), + .Verify(x => x.Push(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); } } diff --git a/src/NzbDrone.Core.Test/Download/TrackedDownloads/TrackedDownloadAlreadyImportedFixture.cs b/src/NzbDrone.Core.Test/Download/TrackedDownloads/TrackedDownloadAlreadyImportedFixture.cs index 71258e544..2f9bb3fce 100644 --- a/src/NzbDrone.Core.Test/Download/TrackedDownloads/TrackedDownloadAlreadyImportedFixture.cs +++ b/src/NzbDrone.Core.Test/Download/TrackedDownloads/TrackedDownloadAlreadyImportedFixture.cs @@ -2,9 +2,9 @@ using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.History; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; @@ -22,12 +22,12 @@ namespace NzbDrone.Core.Test.Download.TrackedDownloads { _albums = new List(); - var remoteAlbum = Builder.CreateNew() - .With(r => r.Albums = _albums) + var remoteAlbum = Builder.CreateNew() + .With(r => r.Books = _albums) .Build(); _trackedDownload = Builder.CreateNew() - .With(t => t.RemoteAlbum = remoteAlbum) + .With(t => t.RemoteBook = remoteAlbum) .Build(); _historyItems = new List(); diff --git a/src/NzbDrone.Core.Test/Download/TrackedDownloads/TrackedDownloadServiceFixture.cs b/src/NzbDrone.Core.Test/Download/TrackedDownloads/TrackedDownloadServiceFixture.cs index ee84ac9e7..dc3f0e52e 100644 --- a/src/NzbDrone.Core.Test/Download/TrackedDownloads/TrackedDownloadServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Download/TrackedDownloads/TrackedDownloadServiceFixture.cs @@ -3,12 +3,12 @@ using System.Linq; using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; +using NzbDrone.Core.Books.Events; using NzbDrone.Core.Download; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.History; using NzbDrone.Core.Indexers; -using NzbDrone.Core.Music; -using NzbDrone.Core.Music.Events; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; @@ -39,19 +39,19 @@ namespace NzbDrone.Core.Test.Download.TrackedDownloads { GivenDownloadHistory(); - var remoteAlbum = new RemoteAlbum + var remoteAlbum = new RemoteBook { - Artist = new Author() { Id = 5 }, - Albums = new List { new Book { Id = 4 } }, - ParsedAlbumInfo = new ParsedAlbumInfo() + Author = new Author() { Id = 5 }, + Books = new List { new Book { Id = 4 } }, + ParsedBookInfo = new ParsedBookInfo() { - AlbumTitle = "Audio Album", - ArtistName = "Audio Artist" + BookTitle = "Audio Album", + AuthorName = "Audio Artist" } }; Mocker.GetMock() - .Setup(s => s.Map(It.Is(i => i.AlbumTitle == "Audio Album" && i.ArtistName == "Audio Artist"), It.IsAny(), It.IsAny>())) + .Setup(s => s.Map(It.Is(i => i.BookTitle == "Audio Album" && i.AuthorName == "Audio Artist"), It.IsAny(), It.IsAny>())) .Returns(remoteAlbum); var client = new DownloadClientDefinition() @@ -69,10 +69,10 @@ namespace NzbDrone.Core.Test.Download.TrackedDownloads var trackedDownload = Subject.TrackDownload(client, item); trackedDownload.Should().NotBeNull(); - trackedDownload.RemoteAlbum.Should().NotBeNull(); - trackedDownload.RemoteAlbum.Artist.Should().NotBeNull(); - trackedDownload.RemoteAlbum.Artist.Id.Should().Be(5); - trackedDownload.RemoteAlbum.Albums.First().Id.Should().Be(4); + trackedDownload.RemoteBook.Should().NotBeNull(); + trackedDownload.RemoteBook.Author.Should().NotBeNull(); + trackedDownload.RemoteBook.Author.Id.Should().Be(5); + trackedDownload.RemoteBook.Books.First().Id.Should().Be(4); } [Test] @@ -80,19 +80,19 @@ namespace NzbDrone.Core.Test.Download.TrackedDownloads { GivenDownloadHistory(); - var remoteAlbum = new RemoteAlbum + var remoteAlbum = new RemoteBook { - Artist = new Author() { Id = 5 }, - Albums = new List { new Book { Id = 4 } }, - ParsedAlbumInfo = new ParsedAlbumInfo() + Author = new Author() { Id = 5 }, + Books = new List { new Book { Id = 4 } }, + ParsedBookInfo = new ParsedBookInfo() { - AlbumTitle = "Audio Album", - ArtistName = "Audio Artist" + BookTitle = "Audio Album", + AuthorName = "Audio Artist" } }; Mocker.GetMock() - .Setup(s => s.Map(It.Is(i => i.AlbumTitle == "Audio Album" && i.ArtistName == "Audio Artist"), It.IsAny(), It.IsAny>())) + .Setup(s => s.Map(It.Is(i => i.BookTitle == "Audio Album" && i.AuthorName == "Audio Artist"), It.IsAny(), It.IsAny>())) .Returns(remoteAlbum); var client = new DownloadClientDefinition() @@ -113,16 +113,16 @@ namespace NzbDrone.Core.Test.Download.TrackedDownloads // simulate deletion - album no longer maps Mocker.GetMock() - .Setup(s => s.Map(It.Is(i => i.AlbumTitle == "Audio Album" && i.ArtistName == "Audio Artist"), It.IsAny(), It.IsAny>())) - .Returns(default(RemoteAlbum)); + .Setup(s => s.Map(It.Is(i => i.BookTitle == "Audio Album" && i.AuthorName == "Audio Artist"), It.IsAny(), It.IsAny>())) + .Returns(default(RemoteBook)); // handle deletion event - Subject.Handle(new AlbumDeletedEvent(remoteAlbum.Albums.First(), false, false)); + Subject.Handle(new BookDeletedEvent(remoteAlbum.Books.First(), false, false)); // verify download has null remote album var trackedDownloads = Subject.GetTrackedDownloads(); trackedDownloads.Should().HaveCount(1); - trackedDownloads.First().RemoteAlbum.Should().BeNull(); + trackedDownloads.First().RemoteBook.Should().BeNull(); } } } diff --git a/src/NzbDrone.Core.Test/HealthCheck/Checks/DeleteBadMediaCovers.cs b/src/NzbDrone.Core.Test/HealthCheck/Checks/DeleteBadMediaCovers.cs index 050544d47..3f0b233c2 100644 --- a/src/NzbDrone.Core.Test/HealthCheck/Checks/DeleteBadMediaCovers.cs +++ b/src/NzbDrone.Core.Test/HealthCheck/Checks/DeleteBadMediaCovers.cs @@ -6,11 +6,11 @@ using FizzWare.NBuilder; using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; using NzbDrone.Core.Extras.Metadata; using NzbDrone.Core.Extras.Metadata.Files; using NzbDrone.Core.Housekeeping.Housekeepers; -using NzbDrone.Core.Music; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; @@ -33,8 +33,8 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks _metadata = Builder.CreateListOfSize(1) .Build().ToList(); - Mocker.GetMock() - .Setup(c => c.GetAllArtists()) + Mocker.GetMock() + .Setup(c => c.GetAllAuthors()) .Returns(_artist); Mocker.GetMock() @@ -73,7 +73,7 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks Subject.Clean(); Mocker.GetMock().VerifySet(c => c.CleanupMetadataImages = true, Times.Never()); - Mocker.GetMock().Verify(c => c.GetAllArtists(), Times.Never()); + Mocker.GetMock().Verify(c => c.GetAllAuthors(), Times.Never()); AssertImageWasNotRemoved(); } diff --git a/src/NzbDrone.Core.Test/HealthCheck/Checks/RemotePathMappingCheckFixture.cs b/src/NzbDrone.Core.Test/HealthCheck/Checks/RemotePathMappingCheckFixture.cs index 368c39792..e28dce7c2 100644 --- a/src/NzbDrone.Core.Test/HealthCheck/Checks/RemotePathMappingCheckFixture.cs +++ b/src/NzbDrone.Core.Test/HealthCheck/Checks/RemotePathMappingCheckFixture.cs @@ -166,7 +166,7 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks public void should_return_ok_on_track_imported_event() { GivenFolderExists(_downloadRootPath); - var importEvent = new TrackImportedEvent(new LocalTrack(), new BookFile(), new List(), true, new DownloadClientItem()); + var importEvent = new TrackImportedEvent(new LocalBook(), new BookFile(), new List(), true, new DownloadClientItem()); Subject.Check(importEvent).ShouldBeOk(); } @@ -174,7 +174,7 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks [Test] public void should_return_permissions_error_on_track_import_failed_event_if_file_exists() { - var localTrack = new LocalTrack + var localTrack = new LocalBook { Path = Path.Combine(_downloadItemPath, "file.mp3") }; diff --git a/src/NzbDrone.Core.Test/HealthCheck/Checks/RootFolderCheckFixture.cs b/src/NzbDrone.Core.Test/HealthCheck/Checks/RootFolderCheckFixture.cs index 37da55683..e900b2475 100644 --- a/src/NzbDrone.Core.Test/HealthCheck/Checks/RootFolderCheckFixture.cs +++ b/src/NzbDrone.Core.Test/HealthCheck/Checks/RootFolderCheckFixture.cs @@ -4,9 +4,9 @@ using FizzWare.NBuilder; using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; +using NzbDrone.Core.Books; using NzbDrone.Core.HealthCheck.Checks; using NzbDrone.Core.ImportLists; -using NzbDrone.Core.Music; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.HealthCheck.Checks @@ -24,8 +24,8 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks .Build() .ToList(); - Mocker.GetMock() - .Setup(s => s.GetAllArtists()) + Mocker.GetMock() + .Setup(s => s.GetAllAuthors()) .Returns(artist); Mocker.GetMock() @@ -44,8 +44,8 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks [Test] public void should_not_return_error_when_no_artist() { - Mocker.GetMock() - .Setup(s => s.GetAllArtists()) + Mocker.GetMock() + .Setup(s => s.GetAllAuthors()) .Returns(new List()); Mocker.GetMock() diff --git a/src/NzbDrone.Core.Test/HistoryTests/HistoryServiceFixture.cs b/src/NzbDrone.Core.Test/HistoryTests/HistoryServiceFixture.cs index 6c63200c1..a2c7708f0 100644 --- a/src/NzbDrone.Core.Test/HistoryTests/HistoryServiceFixture.cs +++ b/src/NzbDrone.Core.Test/HistoryTests/HistoryServiceFixture.cs @@ -4,11 +4,11 @@ using System.Linq; using FizzWare.NBuilder; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Download; using NzbDrone.Core.History; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Events; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Qualities; using NzbDrone.Core.Qualities; @@ -44,13 +44,13 @@ namespace NzbDrone.Core.Test.HistoryTests var artist = Builder.CreateNew().Build(); var trackFile = Builder.CreateNew() .With(f => f.SceneName = null) - .With(f => f.Artist = artist) + .With(f => f.Author = artist) .Build(); - var localTrack = new LocalTrack + var localTrack = new LocalBook { - Artist = artist, - Album = new Book(), + Author = artist, + Book = new Book(), Path = @"C:\Test\Unsorted\Artist.01.Hymn.mp3" }; diff --git a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupDownloadClientUnavailablePendingReleasesFixture.cs b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupDownloadClientUnavailablePendingReleasesFixture.cs index cda91729d..20be1ae2f 100644 --- a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupDownloadClientUnavailablePendingReleasesFixture.cs +++ b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupDownloadClientUnavailablePendingReleasesFixture.cs @@ -18,7 +18,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers var pendingRelease = Builder.CreateNew() .With(h => h.Reason = PendingReleaseReason.DownloadClientUnavailable) .With(h => h.Added = DateTime.UtcNow.AddDays(-21)) - .With(h => h.ParsedAlbumInfo = new ParsedAlbumInfo()) + .With(h => h.ParsedBookInfo = new ParsedBookInfo()) .With(h => h.Release = new ReleaseInfo()) .BuildNew(); @@ -33,7 +33,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers var pendingRelease = Builder.CreateNew() .With(h => h.Reason = PendingReleaseReason.Fallback) .With(h => h.Added = DateTime.UtcNow.AddDays(-21)) - .With(h => h.ParsedAlbumInfo = new ParsedAlbumInfo()) + .With(h => h.ParsedBookInfo = new ParsedBookInfo()) .With(h => h.Release = new ReleaseInfo()) .BuildNew(); @@ -48,7 +48,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers var pendingRelease = Builder.CreateNew() .With(h => h.Reason = PendingReleaseReason.Delay) .With(h => h.Added = DateTime.UtcNow.AddDays(-21)) - .With(h => h.ParsedAlbumInfo = new ParsedAlbumInfo()) + .With(h => h.ParsedBookInfo = new ParsedBookInfo()) .With(h => h.Release = new ReleaseInfo()) .BuildNew(); diff --git a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupDuplicateMetadataFilesFixture.cs b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupDuplicateMetadataFilesFixture.cs index 335d33500..2ce3bf8e6 100644 --- a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupDuplicateMetadataFilesFixture.cs +++ b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupDuplicateMetadataFilesFixture.cs @@ -128,7 +128,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers var files = Builder.CreateListOfSize(2) .All() .With(m => m.Type = MetadataType.TrackMetadata) - .With(m => m.TrackFileId = 1) + .With(m => m.BookFileId = 1) .BuildListOfNew(); Db.InsertMany(files); @@ -156,7 +156,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers var files = Builder.CreateListOfSize(2) .All() .With(m => m.Type = MetadataType.TrackMetadata) - .With(m => m.TrackFileId = 1) + .With(m => m.BookFileId = 1) .With(m => m.Consumer = "XbmcMetadata") .BuildListOfNew(); diff --git a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedBlacklistFixture.cs b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedBlacklistFixture.cs index 1c6d252cf..59ede4a92 100644 --- a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedBlacklistFixture.cs +++ b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedBlacklistFixture.cs @@ -3,8 +3,8 @@ using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.Blacklisting; +using NzbDrone.Core.Books; using NzbDrone.Core.Housekeeping.Housekeepers; -using NzbDrone.Core.Music; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; diff --git a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedTrackFilesFixture.cs b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedBookFilesFixture.cs similarity index 85% rename from src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedTrackFilesFixture.cs rename to src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedBookFilesFixture.cs index 7c9a7bcc9..02e3938ee 100644 --- a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedTrackFilesFixture.cs +++ b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedBookFilesFixture.cs @@ -2,16 +2,16 @@ using System.Linq; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Housekeeping.Housekeepers; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.Housekeeping.Housekeepers { [TestFixture] - public class CleanupOrphanedTrackFilesFixture : DbTest + public class CleanupOrphanedBookFilesFixture : DbTest { [Test] public void should_unlink_orphaned_track_files() diff --git a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedAlbumsFixture.cs b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedBooksFixture.cs similarity index 91% rename from src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedAlbumsFixture.cs rename to src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedBooksFixture.cs index 512195148..ebef27b36 100644 --- a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedAlbumsFixture.cs +++ b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedBooksFixture.cs @@ -1,14 +1,14 @@ using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Housekeeping.Housekeepers; -using NzbDrone.Core.Music; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.Housekeeping.Housekeepers { [TestFixture] - public class CleanupOrphanedAlbumsFixture : DbTest + public class CleanupOrphanedBooksFixture : DbTest { [Test] public void should_delete_orphaned_albums() diff --git a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedHistoryItemsFixture.cs b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedHistoryItemsFixture.cs index 9149d17b6..95070eddf 100644 --- a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedHistoryItemsFixture.cs +++ b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedHistoryItemsFixture.cs @@ -1,8 +1,8 @@ using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Housekeeping.Housekeepers; -using NzbDrone.Core.Music; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; diff --git a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedMetadataFilesFixture.cs b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedMetadataFilesFixture.cs index 60f07caab..d47959895 100644 --- a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedMetadataFilesFixture.cs +++ b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedMetadataFilesFixture.cs @@ -1,11 +1,11 @@ using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Extras.Metadata; using NzbDrone.Core.Extras.Metadata.Files; using NzbDrone.Core.Housekeeping.Housekeepers; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; @@ -18,7 +18,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers public void should_delete_metadata_files_that_dont_have_a_coresponding_artist() { var metadataFile = Builder.CreateNew() - .With(m => m.TrackFileId = null) + .With(m => m.BookFileId = null) .BuildNew(); Db.Insert(metadataFile); @@ -36,7 +36,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers var metadataFile = Builder.CreateNew() .With(m => m.AuthorId = artist.Id) - .With(m => m.TrackFileId = null) + .With(m => m.BookFileId = null) .BuildNew(); Db.Insert(metadataFile); @@ -55,7 +55,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers var metadataFile = Builder.CreateNew() .With(m => m.AuthorId = artist.Id) .With(m => m.BookId = null) - .With(m => m.TrackFileId = null) + .With(m => m.BookFileId = null) .BuildNew(); Db.Insert(metadataFile); @@ -79,7 +79,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers var metadataFile = Builder.CreateNew() .With(m => m.AuthorId = artist.Id) .With(m => m.BookId = album.Id) - .With(m => m.TrackFileId = null) + .With(m => m.BookFileId = null) .BuildNew(); Db.Insert(metadataFile); @@ -102,7 +102,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers var metadataFile = Builder.CreateNew() .With(m => m.AuthorId = artist.Id) .With(m => m.BookId = album.Id) - .With(m => m.TrackFileId = 10) + .With(m => m.BookFileId = 10) .BuildNew(); Db.Insert(metadataFile); @@ -130,7 +130,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers var metadataFile = Builder.CreateNew() .With(m => m.AuthorId = artist.Id) .With(m => m.BookId = album.Id) - .With(m => m.TrackFileId = trackFile.Id) + .With(m => m.BookFileId = trackFile.Id) .BuildNew(); Db.Insert(metadataFile); @@ -150,7 +150,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers .With(m => m.AuthorId = artist.Id) .With(m => m.Type = MetadataType.AlbumMetadata) .With(m => m.BookId = 0) - .With(m => m.TrackFileId = null) + .With(m => m.BookFileId = null) .BuildNew(); Db.Insert(metadataFile); @@ -170,7 +170,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers .With(m => m.AuthorId = artist.Id) .With(m => m.Type = MetadataType.AlbumImage) .With(m => m.BookId = 0) - .With(m => m.TrackFileId = null) + .With(m => m.BookFileId = null) .BuildNew(); Db.Insert(metadataFile); @@ -189,7 +189,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers var metadataFile = Builder.CreateNew() .With(m => m.AuthorId = artist.Id) .With(m => m.Type = MetadataType.TrackMetadata) - .With(m => m.TrackFileId = 0) + .With(m => m.BookFileId = 0) .BuildNew(); Db.Insert(metadataFile); diff --git a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedPendingReleasesFixture.cs b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedPendingReleasesFixture.cs index bbfcb489a..1840cda46 100644 --- a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedPendingReleasesFixture.cs +++ b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedPendingReleasesFixture.cs @@ -1,9 +1,9 @@ using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Download.Pending; using NzbDrone.Core.Housekeeping.Housekeepers; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; @@ -16,7 +16,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers public void should_delete_orphaned_pending_items() { var pendingRelease = Builder.CreateNew() - .With(h => h.ParsedAlbumInfo = new ParsedAlbumInfo()) + .With(h => h.ParsedBookInfo = new ParsedBookInfo()) .With(h => h.Release = new ReleaseInfo()) .BuildNew(); @@ -34,7 +34,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers var pendingRelease = Builder.CreateNew() .With(h => h.AuthorId = artist.Id) - .With(h => h.ParsedAlbumInfo = new ParsedAlbumInfo()) + .With(h => h.ParsedBookInfo = new ParsedBookInfo()) .With(h => h.Release = new ReleaseInfo()) .BuildNew(); diff --git a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/UpdateCleanTitleForArtistFixture.cs b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/UpdateCleanTitleForAuthorFixture.cs similarity index 81% rename from src/NzbDrone.Core.Test/Housekeeping/Housekeepers/UpdateCleanTitleForArtistFixture.cs rename to src/NzbDrone.Core.Test/Housekeeping/Housekeepers/UpdateCleanTitleForAuthorFixture.cs index f67a7b18a..d1393dbda 100644 --- a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/UpdateCleanTitleForArtistFixture.cs +++ b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/UpdateCleanTitleForAuthorFixture.cs @@ -1,14 +1,14 @@ using FizzWare.NBuilder; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Housekeeping.Housekeepers; -using NzbDrone.Core.Music; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.Housekeeping.Housekeepers { [TestFixture] - public class UpdateCleanTitleForArtistFixture : CoreTest + public class UpdateCleanTitleForAuthorFixture : CoreTest { [Test] public void should_update_clean_title() @@ -18,13 +18,13 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers .With(s => s.CleanName = "unclean") .Build(); - Mocker.GetMock() + Mocker.GetMock() .Setup(s => s.All()) .Returns(new[] { artist }); Subject.Clean(); - Mocker.GetMock() + Mocker.GetMock() .Verify(v => v.Update(It.Is(s => s.CleanName == "fullname")), Times.Once()); } @@ -36,13 +36,13 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers .With(s => s.CleanName = "fullname") .Build(); - Mocker.GetMock() + Mocker.GetMock() .Setup(s => s.All()) .Returns(new[] { artist }); Subject.Clean(); - Mocker.GetMock() + Mocker.GetMock() .Verify(v => v.Update(It.Is(s => s.CleanName == "fullname")), Times.Never()); } } diff --git a/src/NzbDrone.Core.Test/ImportListTests/ImportListSyncServiceFixture.cs b/src/NzbDrone.Core.Test/ImportListTests/ImportListSyncServiceFixture.cs index 1449ddd60..2db8a98e1 100644 --- a/src/NzbDrone.Core.Test/ImportListTests/ImportListSyncServiceFixture.cs +++ b/src/NzbDrone.Core.Test/ImportListTests/ImportListSyncServiceFixture.cs @@ -3,10 +3,10 @@ using System.Linq; using FizzWare.NBuilder; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.ImportLists; using NzbDrone.Core.ImportLists.Exclusions; using NzbDrone.Core.MetadataSource; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; @@ -21,7 +21,7 @@ namespace NzbDrone.Core.Test.ImportListTests { var importListItem1 = new ImportListItemInfo { - Artist = "Linkin Park" + Author = "Linkin Park" }; _importListReports = new List { importListItem1 }; @@ -59,18 +59,18 @@ namespace NzbDrone.Core.Test.ImportListTests .Setup(v => v.All()) .Returns(new List()); - Mocker.GetMock() - .Setup(v => v.AddAlbums(It.IsAny>(), false)) + Mocker.GetMock() + .Setup(v => v.AddBooks(It.IsAny>(), false)) .Returns, bool>((x, y) => x); - Mocker.GetMock() - .Setup(v => v.AddArtists(It.IsAny>(), false)) + Mocker.GetMock() + .Setup(v => v.AddAuthors(It.IsAny>(), false)) .Returns, bool>((x, y) => x); } private void WithAlbum() { - _importListReports.First().Album = "Meteora"; + _importListReports.First().Book = "Meteora"; } private void WithAuthorId() @@ -85,14 +85,14 @@ namespace NzbDrone.Core.Test.ImportListTests private void WithExistingArtist() { - Mocker.GetMock() + Mocker.GetMock() .Setup(v => v.FindById(_importListReports.First().ArtistMusicBrainzId)) .Returns(new Author { ForeignAuthorId = _importListReports.First().ArtistMusicBrainzId }); } private void WithExistingAlbum() { - Mocker.GetMock() + Mocker.GetMock() .Setup(v => v.FindById(_importListReports.First().AlbumMusicBrainzId)) .Returns(new Book { ForeignBookId = _importListReports.First().AlbumMusicBrainzId }); } @@ -193,8 +193,8 @@ namespace NzbDrone.Core.Test.ImportListTests Subject.Execute(new ImportListSyncCommand()); - Mocker.GetMock() - .Verify(v => v.AddArtists(It.Is>(t => t.Count == 0), false)); + Mocker.GetMock() + .Verify(v => v.AddAuthors(It.Is>(t => t.Count == 0), false)); } [Test] @@ -205,8 +205,8 @@ namespace NzbDrone.Core.Test.ImportListTests Subject.Execute(new ImportListSyncCommand()); - Mocker.GetMock() - .Verify(v => v.AddArtists(It.Is>(t => t.Count == 0), false)); + Mocker.GetMock() + .Verify(v => v.AddAuthors(It.Is>(t => t.Count == 0), false)); } [Test] @@ -217,8 +217,8 @@ namespace NzbDrone.Core.Test.ImportListTests Subject.Execute(new ImportListSyncCommand()); - Mocker.GetMock() - .Verify(v => v.AddAlbums(It.Is>(t => t.Count == 1), false)); + Mocker.GetMock() + .Verify(v => v.AddBooks(It.Is>(t => t.Count == 1), false)); } [TestCase(ImportListMonitorType.None, false)] @@ -231,8 +231,8 @@ namespace NzbDrone.Core.Test.ImportListTests Subject.Execute(new ImportListSyncCommand()); - Mocker.GetMock() - .Verify(v => v.AddArtists(It.Is>(t => t.Count == 1 && t.First().Monitored == expectedArtistMonitored), false)); + Mocker.GetMock() + .Verify(v => v.AddAuthors(It.Is>(t => t.Count == 1 && t.First().Monitored == expectedArtistMonitored), false)); } [TestCase(ImportListMonitorType.None, false)] @@ -245,8 +245,8 @@ namespace NzbDrone.Core.Test.ImportListTests Subject.Execute(new ImportListSyncCommand()); - Mocker.GetMock() - .Verify(v => v.AddAlbums(It.Is>(t => t.Count == 1 && t.First().Monitored == expectedAlbumMonitored), false)); + Mocker.GetMock() + .Verify(v => v.AddBooks(It.Is>(t => t.Count == 1 && t.First().Monitored == expectedAlbumMonitored), false)); } [Test] @@ -257,8 +257,8 @@ namespace NzbDrone.Core.Test.ImportListTests Subject.Execute(new ImportListSyncCommand()); - Mocker.GetMock() - .Verify(v => v.AddArtists(It.Is>(t => t.Count == 0), false)); + Mocker.GetMock() + .Verify(v => v.AddAuthors(It.Is>(t => t.Count == 0), false)); } [Test] @@ -269,8 +269,8 @@ namespace NzbDrone.Core.Test.ImportListTests Subject.Execute(new ImportListSyncCommand()); - Mocker.GetMock() - .Verify(v => v.AddAlbums(It.Is>(t => t.Count == 0), false)); + Mocker.GetMock() + .Verify(v => v.AddBooks(It.Is>(t => t.Count == 0), false)); } [Test] @@ -282,8 +282,8 @@ namespace NzbDrone.Core.Test.ImportListTests Subject.Execute(new ImportListSyncCommand()); - Mocker.GetMock() - .Verify(v => v.AddAlbums(It.Is>(t => t.Count == 0), false)); + Mocker.GetMock() + .Verify(v => v.AddBooks(It.Is>(t => t.Count == 0), false)); } } } diff --git a/src/NzbDrone.Core.Test/IndexerSearchTests/ArtistSearchServiceFixture.cs b/src/NzbDrone.Core.Test/IndexerSearchTests/ArtistSearchServiceFixture.cs index c9ad90daa..74d72a9b2 100644 --- a/src/NzbDrone.Core.Test/IndexerSearchTests/ArtistSearchServiceFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerSearchTests/ArtistSearchServiceFixture.cs @@ -2,17 +2,17 @@ using System.Collections.Generic; using System.Linq; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Messaging.Commands; -using NzbDrone.Core.Music; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.IndexerSearchTests { [TestFixture] - public class ArtistSearchServiceFixture : CoreTest + public class ArtistSearchServiceFixture : CoreTest { private Author _artist; @@ -21,8 +21,8 @@ namespace NzbDrone.Core.Test.IndexerSearchTests { _artist = new Author(); - Mocker.GetMock() - .Setup(s => s.GetArtist(It.IsAny())) + Mocker.GetMock() + .Setup(s => s.GetAuthor(It.IsAny())) .Returns(_artist); Mocker.GetMock() @@ -43,7 +43,7 @@ namespace NzbDrone.Core.Test.IndexerSearchTests new Book { Monitored = true } }; - Subject.Execute(new ArtistSearchCommand { AuthorId = _artist.Id, Trigger = CommandTrigger.Manual }); + Subject.Execute(new AuthorSearchCommand { AuthorId = _artist.Id, Trigger = CommandTrigger.Manual }); Mocker.GetMock() .Verify(v => v.ArtistSearch(_artist.Id, false, true, false), diff --git a/src/NzbDrone.Core.Test/IndexerSearchTests/SearchDefinitionFixture.cs b/src/NzbDrone.Core.Test/IndexerSearchTests/SearchDefinitionFixture.cs index e429cc08e..4d86947fe 100644 --- a/src/NzbDrone.Core.Test/IndexerSearchTests/SearchDefinitionFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerSearchTests/SearchDefinitionFixture.cs @@ -1,18 +1,18 @@ using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Music; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.IndexerSearchTests { - public class AlbumSearchDefinitionFixture : CoreTest + public class AlbumSearchDefinitionFixture : CoreTest { [TestCase("Mötley Crüe", "Motley+Crue")] [TestCase("방탄소년단", "방탄소년단")] public void should_replace_some_special_characters_artist(string artist, string expected) { - Subject.Artist = new Author { Name = artist }; + Subject.Author = new Author { Name = artist }; Subject.ArtistQuery.Should().Be(expected); } @@ -24,14 +24,14 @@ namespace NzbDrone.Core.Test.IndexerSearchTests [TestCase("Section.80", "Section+80")] public void should_replace_some_special_characters(string album, string expected) { - Subject.AlbumTitle = album; + Subject.BookTitle = album; Subject.AlbumQuery.Should().Be(expected); } [TestCase("+", "+")] public void should_not_replace_some_special_characters_if_result_empty_string(string album, string expected) { - Subject.AlbumTitle = album; + Subject.BookTitle = album; Subject.AlbumQuery.Should().Be(expected); } } diff --git a/src/NzbDrone.Core.Test/IndexerTests/IntegrationTests/IndexerIntegrationTests.cs b/src/NzbDrone.Core.Test/IndexerTests/IntegrationTests/IndexerIntegrationTests.cs index a8cf68024..037746696 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/IntegrationTests/IndexerIntegrationTests.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/IntegrationTests/IndexerIntegrationTests.cs @@ -14,14 +14,14 @@ namespace NzbDrone.Core.Test.IndexerTests.IntegrationTests [IntegrationTest] public class IndexerIntegrationTests : CoreTest { - private AlbumSearchCriteria _albumSearchCriteria; + private BookSearchCriteria _albumSearchCriteria; [SetUp] public void SetUp() { UseRealHttp(); - _albumSearchCriteria = new AlbumSearchCriteria() + _albumSearchCriteria = new BookSearchCriteria() { }; } diff --git a/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabRequestGeneratorFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabRequestGeneratorFixture.cs index d13a6972e..b27df93ab 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabRequestGeneratorFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabRequestGeneratorFixture.cs @@ -10,7 +10,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests { public class NewznabRequestGeneratorFixture : CoreTest { - private AlbumSearchCriteria _singleAlbumSearchCriteria; + private BookSearchCriteria _singleAlbumSearchCriteria; private NewznabCapabilities _capabilities; [SetUp] @@ -23,10 +23,10 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests ApiKey = "abcd", }; - _singleAlbumSearchCriteria = new AlbumSearchCriteria + _singleAlbumSearchCriteria = new BookSearchCriteria { - Artist = new Music.Author { Name = "Alien Ant Farm" }, - AlbumTitle = "TruANT" + Author = new Books.Author { Name = "Alien Ant Farm" }, + BookTitle = "TruANT" }; _capabilities = new NewznabCapabilities(); @@ -51,15 +51,15 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests [Test] public void should_search_by_artist_and_album_if_supported() { - _capabilities.SupportedAudioSearchParameters = new[] { "q", "artist", "album" }; + _capabilities.SupportedAudioSearchParameters = new[] { "q", "author", "book" }; var results = Subject.GetSearchRequests(_singleAlbumSearchCriteria); results.GetTier(0).Should().HaveCount(1); var page = results.GetAllTiers().First().First(); - page.Url.Query.Should().Contain("artist=Alien%20Ant%20Farm"); - page.Url.Query.Should().Contain("album=TruANT"); + page.Url.Query.Should().Contain("author=Alien%20Ant%20Farm"); + page.Url.Query.Should().Contain("book=TruANT"); } } } diff --git a/src/NzbDrone.Core.Test/IndexerTests/SeedConfigProviderFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/SeedConfigProviderFixture.cs index 53a054868..b17b79ae7 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/SeedConfigProviderFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/SeedConfigProviderFixture.cs @@ -20,7 +20,7 @@ namespace NzbDrone.Core.Test.IndexerTests .Setup(v => v.Get(It.IsAny())) .Throws(new ModelNotFoundException(typeof(IndexerDefinition), 0)); - var result = Subject.GetSeedConfiguration(new RemoteAlbum + var result = Subject.GetSeedConfiguration(new RemoteBook { Release = new ReleaseInfo { @@ -45,14 +45,14 @@ namespace NzbDrone.Core.Test.IndexerTests Settings = settings }); - var result = Subject.GetSeedConfiguration(new RemoteAlbum + var result = Subject.GetSeedConfiguration(new RemoteBook { Release = new ReleaseInfo() { DownloadProtocol = DownloadProtocol.Torrent, IndexerId = 1 }, - ParsedAlbumInfo = new ParsedAlbumInfo + ParsedBookInfo = new ParsedBookInfo { Discography = true } diff --git a/src/NzbDrone.Core.Test/MediaCoverTests/MediaCoverServiceFixture.cs b/src/NzbDrone.Core.Test/MediaCoverTests/MediaCoverServiceFixture.cs index a4f7da7be..b1e2a8ad6 100644 --- a/src/NzbDrone.Core.Test/MediaCoverTests/MediaCoverServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaCoverTests/MediaCoverServiceFixture.cs @@ -8,9 +8,9 @@ using NUnit.Framework; using NzbDrone.Common.Disk; using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Http; +using NzbDrone.Core.Books; +using NzbDrone.Core.Books.Events; using NzbDrone.Core.MediaCover; -using NzbDrone.Core.Music; -using NzbDrone.Core.Music.Events; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.MediaCoverTests @@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests Mocker.GetMock().Setup(c => c.FileExists(It.IsAny())) .Returns(true); - Subject.ConvertToLocalUrls(12, MediaCoverEntity.Artist, covers); + Subject.ConvertToLocalUrls(12, MediaCoverEntity.Author, covers); covers.Single().Url.Should().Be("/MediaCover/12/banner" + extension + "?lastWrite=1234"); } @@ -84,7 +84,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests Mocker.GetMock().Setup(c => c.FileExists(It.IsAny())) .Returns(true); - Subject.ConvertToLocalUrls(12, MediaCoverEntity.Artist, covers); + Subject.ConvertToLocalUrls(12, MediaCoverEntity.Author, covers); covers.Single().Extension.Should().Be(extension); } @@ -108,7 +108,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests Mocker.GetMock().Setup(c => c.FileExists(It.IsAny())) .Returns(true); - Subject.ConvertToLocalUrls(6, MediaCoverEntity.Album, covers); + Subject.ConvertToLocalUrls(6, MediaCoverEntity.Book, covers); covers.Single().Url.Should().Be("/MediaCover/Albums/6/disc" + extension + "?lastWrite=1234"); } @@ -126,7 +126,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests } }; - Subject.ConvertToLocalUrls(12, MediaCoverEntity.Artist, covers); + Subject.ConvertToLocalUrls(12, MediaCoverEntity.Author, covers); covers.Single().Url.Should().Be("/MediaCover/12/banner" + extension); } @@ -138,15 +138,15 @@ namespace NzbDrone.Core.Test.MediaCoverTests .Setup(v => v.AlreadyExists(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(false); - Mocker.GetMock() - .Setup(v => v.GetAlbumsByArtist(It.IsAny())) + Mocker.GetMock() + .Setup(v => v.GetBooksByAuthor(It.IsAny())) .Returns(new List { _album }); Mocker.GetMock() .Setup(v => v.FileExists(It.IsAny())) .Returns(true); - Subject.HandleAsync(new ArtistRefreshCompleteEvent(_artist)); + Subject.HandleAsync(new AuthorRefreshCompleteEvent(_artist)); Mocker.GetMock() .Verify(v => v.Resize(It.IsAny(), It.IsAny(), It.IsAny()), Times.Exactly(2)); @@ -159,15 +159,15 @@ namespace NzbDrone.Core.Test.MediaCoverTests .Setup(v => v.AlreadyExists(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(true); - Mocker.GetMock() - .Setup(v => v.GetAlbumsByArtist(It.IsAny())) + Mocker.GetMock() + .Setup(v => v.GetBooksByAuthor(It.IsAny())) .Returns(new List { _album }); Mocker.GetMock() .Setup(v => v.FileExists(It.IsAny())) .Returns(false); - Subject.HandleAsync(new ArtistRefreshCompleteEvent(_artist)); + Subject.HandleAsync(new AuthorRefreshCompleteEvent(_artist)); Mocker.GetMock() .Verify(v => v.Resize(It.IsAny(), It.IsAny(), It.IsAny()), Times.Exactly(2)); @@ -184,15 +184,15 @@ namespace NzbDrone.Core.Test.MediaCoverTests .Setup(v => v.FileExists(It.IsAny())) .Returns(true); - Mocker.GetMock() - .Setup(v => v.GetAlbumsByArtist(It.IsAny())) + Mocker.GetMock() + .Setup(v => v.GetBooksByAuthor(It.IsAny())) .Returns(new List { _album }); Mocker.GetMock() .Setup(v => v.GetFileSize(It.IsAny())) .Returns(1000); - Subject.HandleAsync(new ArtistRefreshCompleteEvent(_artist)); + Subject.HandleAsync(new AuthorRefreshCompleteEvent(_artist)); Mocker.GetMock() .Verify(v => v.Resize(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); @@ -209,15 +209,15 @@ namespace NzbDrone.Core.Test.MediaCoverTests .Setup(v => v.FileExists(It.IsAny())) .Returns(true); - Mocker.GetMock() - .Setup(v => v.GetAlbumsByArtist(It.IsAny())) + Mocker.GetMock() + .Setup(v => v.GetBooksByAuthor(It.IsAny())) .Returns(new List { _album }); Mocker.GetMock() .Setup(v => v.GetFileSize(It.IsAny())) .Returns(0); - Subject.HandleAsync(new ArtistRefreshCompleteEvent(_artist)); + Subject.HandleAsync(new AuthorRefreshCompleteEvent(_artist)); Mocker.GetMock() .Verify(v => v.Resize(It.IsAny(), It.IsAny(), It.IsAny()), Times.Exactly(2)); @@ -234,15 +234,15 @@ namespace NzbDrone.Core.Test.MediaCoverTests .Setup(v => v.FileExists(It.IsAny())) .Returns(false); - Mocker.GetMock() - .Setup(v => v.GetAlbumsByArtist(It.IsAny())) + Mocker.GetMock() + .Setup(v => v.GetBooksByAuthor(It.IsAny())) .Returns(new List { _album }); Mocker.GetMock() .Setup(v => v.Resize(It.IsAny(), It.IsAny(), It.IsAny())) .Throws(); - Subject.HandleAsync(new ArtistRefreshCompleteEvent(_artist)); + Subject.HandleAsync(new AuthorRefreshCompleteEvent(_artist)); Mocker.GetMock() .Verify(v => v.Resize(It.IsAny(), It.IsAny(), It.IsAny()), Times.Exactly(2)); diff --git a/src/NzbDrone.Core.Test/MediaFiles/AudioTagServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/AudioTagServiceFixture.cs index af65be391..12c382c81 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/AudioTagServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/AudioTagServiceFixture.cs @@ -8,9 +8,9 @@ using FluentAssertions; using NUnit.Framework; using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; @@ -316,8 +316,8 @@ namespace NzbDrone.Core.Test.MediaFiles.AudioTagServiceFixture .Build(); var file = Builder.CreateNew() - .With(x => x.Album = album) - .With(x => x.Artist = artist) + .With(x => x.Book = album) + .With(x => x.Author = artist) .Build(); return file; diff --git a/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs index 44036d1eb..1aee7c976 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs @@ -9,10 +9,10 @@ using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.MediaFiles.TrackImport; -using NzbDrone.Core.Music; +using NzbDrone.Core.MediaFiles.BookImport; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; using NzbDrone.Core.RootFolders; @@ -43,16 +43,16 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests .Setup(s => s.GetBestRootFolder(It.IsAny())) .Returns(new RootFolder { Path = _rootFolder }); - Mocker.GetMock() - .Setup(s => s.GetArtists(It.IsAny>())) + Mocker.GetMock() + .Setup(s => s.GetAuthors(It.IsAny>())) .Returns(new List()); Mocker.GetMock() .Setup(v => v.GetImportDecisions(It.IsAny>(), It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(new List>()); + .Returns(new List>()); Mocker.GetMock() - .Setup(v => v.GetFilesByArtist(It.IsAny())) + .Setup(v => v.GetFilesByAuthor(It.IsAny())) .Returns(new List()); Mocker.GetMock() @@ -370,14 +370,14 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests Mocker.GetMock() .Setup(x => x.GetImportDecisions(It.IsAny>(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns((List fileList, IdentificationOverrides idOverrides, ImportDecisionMakerInfo idInfo, ImportDecisionMakerConfig idConfig) => - fileList.Select(x => new LocalTrack + fileList.Select(x => new LocalBook { - Artist = _artist, + Author = _artist, Path = x.FullName, Modified = x.LastWriteTimeUtc, FileTrackInfo = new ParsedTrackInfo() }) - .Select(x => new ImportDecision(x, new Rejection("Reject"))) + .Select(x => new ImportDecision(x, new Rejection("Reject"))) .ToList()); } @@ -501,7 +501,7 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests FileSystem.AddFile(files[0], new MockFileData("".PadRight(100)) { LastWriteTime = new DateTime(2019, 2, 1) }); - var localTrack = Builder.CreateNew() + var localTrack = Builder.CreateNew() .With(x => x.Path = files[0]) .With(x => x.Modified = new DateTime(2019, 2, 1)) .With(x => x.Size = 100) @@ -514,7 +514,7 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests Mocker.GetMock() .Setup(x => x.GetImportDecisions(It.IsAny>(), It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(new List> { new ImportDecision(localTrack, new Rejection("Reject")) }); + .Returns(new List> { new ImportDecision(localTrack, new Rejection("Reject")) }); Subject.Scan(new List { _artist.Path }); diff --git a/src/NzbDrone.Core.Test/MediaFiles/DownloadedAlbumsCommandServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/DownloadedAlbumsCommandServiceFixture.cs index 21046f9eb..a8cd6c6b7 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/DownloadedAlbumsCommandServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/DownloadedAlbumsCommandServiceFixture.cs @@ -5,12 +5,12 @@ using System.IO.Abstractions.TestingHelpers; using FizzWare.NBuilder; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Download; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.MediaFiles; +using NzbDrone.Core.MediaFiles.BookImport; using NzbDrone.Core.MediaFiles.Commands; -using NzbDrone.Core.MediaFiles.TrackImport; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; @@ -18,7 +18,7 @@ using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MediaFiles { [TestFixture] - public class DownloadedAlbumsCommandServiceFixture : FileSystemTest + public class DownloadedAlbumsCommandServiceFixture : FileSystemTest { private string _downloadFolder = "c:\\drop_other\\Show.S01E01\\".AsOsAgnostic(); private string _downloadFile = "c:\\drop_other\\Show.S01E01.mkv".AsOsAgnostic(); @@ -28,11 +28,11 @@ namespace NzbDrone.Core.Test.MediaFiles [SetUp] public void Setup() { - Mocker.GetMock() + Mocker.GetMock() .Setup(v => v.ProcessRootFolder(It.IsAny())) .Returns(new List()); - Mocker.GetMock() + Mocker.GetMock() .Setup(v => v.ProcessPath(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(new List()); @@ -41,14 +41,14 @@ namespace NzbDrone.Core.Test.MediaFiles .With(v => v.Status = DownloadItemStatus.Downloading) .Build(); - var remoteAlbum = Builder.CreateNew() - .With(v => v.Artist = new Author()) + var remoteAlbum = Builder.CreateNew() + .With(v => v.Author = new Author()) .Build(); _trackedDownload = new TrackedDownload { DownloadItem = downloadItem, - RemoteAlbum = remoteAlbum, + RemoteBook = remoteAlbum, State = TrackedDownloadState.Downloading }; } @@ -73,9 +73,9 @@ namespace NzbDrone.Core.Test.MediaFiles [Test] public void should_skip_import_if_dronefactory_doesnt_exist() { - Assert.Throws(() => Subject.Execute(new DownloadedAlbumsScanCommand())); + Assert.Throws(() => Subject.Execute(new DownloadedBooksScanCommand())); - Mocker.GetMock().Verify(c => c.ProcessRootFolder(It.IsAny()), Times.Never()); + Mocker.GetMock().Verify(c => c.ProcessRootFolder(It.IsAny()), Times.Never()); } [Test] @@ -83,9 +83,9 @@ namespace NzbDrone.Core.Test.MediaFiles { GivenExistingFolder(_downloadFolder); - Subject.Execute(new DownloadedAlbumsScanCommand() { Path = _downloadFolder }); + Subject.Execute(new DownloadedBooksScanCommand() { Path = _downloadFolder }); - Mocker.GetMock().Verify(c => c.ProcessPath(It.IsAny(), ImportMode.Auto, null, null), Times.Once()); + Mocker.GetMock().Verify(c => c.ProcessPath(It.IsAny(), ImportMode.Auto, null, null), Times.Once()); } [Test] @@ -93,9 +93,9 @@ namespace NzbDrone.Core.Test.MediaFiles { GivenExistingFile(_downloadFile); - Subject.Execute(new DownloadedAlbumsScanCommand() { Path = _downloadFile }); + Subject.Execute(new DownloadedBooksScanCommand() { Path = _downloadFile }); - Mocker.GetMock().Verify(c => c.ProcessPath(It.IsAny(), ImportMode.Auto, null, null), Times.Once()); + Mocker.GetMock().Verify(c => c.ProcessPath(It.IsAny(), ImportMode.Auto, null, null), Times.Once()); } [Test] @@ -104,9 +104,9 @@ namespace NzbDrone.Core.Test.MediaFiles GivenExistingFolder(_downloadFolder); GivenValidQueueItem(); - Subject.Execute(new DownloadedAlbumsScanCommand() { Path = _downloadFolder, DownloadClientId = "sab1" }); + Subject.Execute(new DownloadedBooksScanCommand() { Path = _downloadFolder, DownloadClientId = "sab1" }); - Mocker.GetMock().Verify(c => c.ProcessPath(_downloadFolder, ImportMode.Auto, _trackedDownload.RemoteAlbum.Artist, _trackedDownload.DownloadItem), Times.Once()); + Mocker.GetMock().Verify(c => c.ProcessPath(_downloadFolder, ImportMode.Auto, _trackedDownload.RemoteBook.Author, _trackedDownload.DownloadItem), Times.Once()); } [Test] @@ -114,9 +114,9 @@ namespace NzbDrone.Core.Test.MediaFiles { GivenExistingFolder(_downloadFolder); - Subject.Execute(new DownloadedAlbumsScanCommand() { Path = _downloadFolder, DownloadClientId = "sab1" }); + Subject.Execute(new DownloadedBooksScanCommand() { Path = _downloadFolder, DownloadClientId = "sab1" }); - Mocker.GetMock().Verify(c => c.ProcessPath(_downloadFolder, ImportMode.Auto, null, null), Times.Once()); + Mocker.GetMock().Verify(c => c.ProcessPath(_downloadFolder, ImportMode.Auto, null, null), Times.Once()); ExceptionVerification.ExpectedWarns(1); } @@ -124,9 +124,9 @@ namespace NzbDrone.Core.Test.MediaFiles [Test] public void should_warn_if_neither_folder_or_file_exists() { - Subject.Execute(new DownloadedAlbumsScanCommand() { Path = _downloadFolder }); + Subject.Execute(new DownloadedBooksScanCommand() { Path = _downloadFolder }); - Mocker.GetMock().Verify(c => c.ProcessPath(It.IsAny(), ImportMode.Auto, null, null), Times.Never()); + Mocker.GetMock().Verify(c => c.ProcessPath(It.IsAny(), ImportMode.Auto, null, null), Times.Never()); ExceptionVerification.ExpectedWarns(1); } @@ -136,9 +136,9 @@ namespace NzbDrone.Core.Test.MediaFiles { GivenExistingFile(_downloadFile); - Subject.Execute(new DownloadedAlbumsScanCommand() { Path = _downloadFile, ImportMode = ImportMode.Copy }); + Subject.Execute(new DownloadedBooksScanCommand() { Path = _downloadFile, ImportMode = ImportMode.Copy }); - Mocker.GetMock().Verify(c => c.ProcessPath(It.IsAny(), ImportMode.Copy, null, null), Times.Once()); + Mocker.GetMock().Verify(c => c.ProcessPath(It.IsAny(), ImportMode.Copy, null, null), Times.Once()); } } } diff --git a/src/NzbDrone.Core.Test/MediaFiles/DownloadedTracksImportServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/DownloadedTracksImportServiceFixture.cs index b06834749..86ccd2176 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/DownloadedTracksImportServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/DownloadedTracksImportServiceFixture.cs @@ -8,11 +8,11 @@ using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; +using NzbDrone.Core.Books; using NzbDrone.Core.Download; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.MediaFiles.TrackImport; -using NzbDrone.Core.Music; +using NzbDrone.Core.MediaFiles.BookImport; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; @@ -21,7 +21,7 @@ using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MediaFiles { [TestFixture] - public class DownloadedTracksImportServiceFixture : FileSystemTest + public class DownloadedTracksImportServiceFixture : FileSystemTest { private string _droneFactory = "c:\\drop\\".AsOsAgnostic(); private string[] _subFolders = new[] { "c:\\drop\\foldername".AsOsAgnostic() }; @@ -34,14 +34,14 @@ namespace NzbDrone.Core.Test.MediaFiles { GivenAudioFiles(_audioFiles, 10); - Mocker.GetMock().Setup(c => c.GetAudioFiles(It.IsAny(), It.IsAny())) + Mocker.GetMock().Setup(c => c.GetBookFiles(It.IsAny(), It.IsAny())) .Returns(_audioFiles.Select(x => DiskProvider.GetFileInfo(x)).ToArray()); Mocker.GetMock().Setup(c => c.FilterFiles(It.IsAny(), It.IsAny>())) .Returns>((b, s) => s.ToList()); - Mocker.GetMock() - .Setup(s => s.Import(It.IsAny>>(), true, null, ImportMode.Auto)) + Mocker.GetMock() + .Setup(s => s.Import(It.IsAny>>(), true, null, ImportMode.Auto)) .Returns(new List()); var downloadItem = Builder.CreateNew() @@ -49,14 +49,14 @@ namespace NzbDrone.Core.Test.MediaFiles .With(v => v.Status = DownloadItemStatus.Downloading) .Build(); - var remoteAlbum = Builder.CreateNew() - .With(v => v.Artist = new Author()) + var remoteAlbum = Builder.CreateNew() + .With(v => v.Author = new Author()) .Build(); _trackedDownload = new TrackedDownload { DownloadItem = downloadItem, - RemoteAlbum = remoteAlbum, + RemoteBook = remoteAlbum, State = TrackedDownloadState.Downloading }; } @@ -78,24 +78,24 @@ namespace NzbDrone.Core.Test.MediaFiles private void GivenSuccessfulImport() { - var localTrack = new LocalTrack(); + var localTrack = new LocalBook(); - var imported = new List>(); - imported.Add(new ImportDecision(localTrack)); + var imported = new List>(); + imported.Add(new ImportDecision(localTrack)); Mocker.GetMock() .Setup(v => v.GetImportDecisions(It.IsAny>(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(imported); - Mocker.GetMock() - .Setup(s => s.Import(It.IsAny>>(), It.IsAny(), It.IsAny(), It.IsAny())) + Mocker.GetMock() + .Setup(s => s.Import(It.IsAny>>(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(imported.Select(i => new ImportResult(i)).ToList()) .Callback(() => WasImportedResponse()); } private void WasImportedResponse() { - Mocker.GetMock().Setup(c => c.GetAudioFiles(It.IsAny(), It.IsAny())) + Mocker.GetMock().Setup(c => c.GetBookFiles(It.IsAny(), It.IsAny())) .Returns(new IFileInfo[0]); } @@ -141,18 +141,18 @@ namespace NzbDrone.Core.Test.MediaFiles { GivenValidArtist(); - Mocker.GetMock() - .Setup(s => s.ArtistPathExists(It.IsAny())) + Mocker.GetMock() + .Setup(s => s.AuthorPathExists(It.IsAny())) .Returns(true); Mocker.GetMock() - .Setup(c => c.GetAudioFiles(It.IsAny(), It.IsAny())) + .Setup(c => c.GetBookFiles(It.IsAny(), It.IsAny())) .Returns(new IFileInfo[0]); Subject.ProcessRootFolder(DiskProvider.GetDirectoryInfo(_droneFactory)); Mocker.GetMock() - .Verify(v => v.GetAudioFiles(It.IsAny(), true), Times.Never()); + .Verify(v => v.GetBookFiles(It.IsAny(), true), Times.Never()); ExceptionVerification.ExpectedWarns(1); } @@ -160,8 +160,8 @@ namespace NzbDrone.Core.Test.MediaFiles [Test] public void should_not_delete_folder_if_no_files_were_imported() { - Mocker.GetMock() - .Setup(s => s.Import(It.IsAny>>(), false, null, ImportMode.Auto)) + Mocker.GetMock() + .Setup(s => s.Import(It.IsAny>>(), false, null, ImportMode.Auto)) .Returns(new List()); Subject.ProcessRootFolder(DiskProvider.GetDirectoryInfo(_droneFactory)); @@ -175,17 +175,17 @@ namespace NzbDrone.Core.Test.MediaFiles { GivenValidArtist(); - var localTrack = new LocalTrack(); + var localTrack = new LocalBook(); - var imported = new List>(); - imported.Add(new ImportDecision(localTrack)); + var imported = new List>(); + imported.Add(new ImportDecision(localTrack)); Mocker.GetMock() .Setup(v => v.GetImportDecisions(It.IsAny>(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(imported); - Mocker.GetMock() - .Setup(s => s.Import(It.IsAny>>(), true, null, ImportMode.Auto)) + Mocker.GetMock() + .Setup(s => s.Import(It.IsAny>>(), true, null, ImportMode.Auto)) .Returns(imported.Select(i => new ImportResult(i)).ToList()); Subject.ProcessRootFolder(DiskProvider.GetDirectoryInfo(_droneFactory)); @@ -232,17 +232,17 @@ namespace NzbDrone.Core.Test.MediaFiles { GivenValidArtist(); - var localTrack = new LocalTrack(); + var localTrack = new LocalBook(); - var imported = new List>(); - imported.Add(new ImportDecision(localTrack)); + var imported = new List>(); + imported.Add(new ImportDecision(localTrack)); Mocker.GetMock() .Setup(v => v.GetImportDecisions(It.IsAny>(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(imported); - Mocker.GetMock() - .Setup(s => s.Import(It.IsAny>>(), true, null, ImportMode.Auto)) + Mocker.GetMock() + .Setup(s => s.Import(It.IsAny>>(), true, null, ImportMode.Auto)) .Returns(imported.Select(i => new ImportResult(i)).ToList()); GivenAudioFiles(new[] { _audioFiles.First().Replace(".ext", ".rar") }, 15.Megabytes()); @@ -272,17 +272,17 @@ namespace NzbDrone.Core.Test.MediaFiles { GivenValidArtist(); - var localTrack = new LocalTrack(); + var localTrack = new LocalBook(); - var imported = new List>(); - imported.Add(new ImportDecision(localTrack)); + var imported = new List>(); + imported.Add(new ImportDecision(localTrack)); Mocker.GetMock() .Setup(v => v.GetImportDecisions(It.IsAny>(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(imported); - Mocker.GetMock() - .Setup(s => s.Import(It.IsAny>>(), true, null, ImportMode.Auto)) + Mocker.GetMock() + .Setup(s => s.Import(It.IsAny>>(), true, null, ImportMode.Auto)) .Returns(new List()); Subject.ProcessRootFolder(DiskProvider.GetDirectoryInfo(_droneFactory)); @@ -302,7 +302,7 @@ namespace NzbDrone.Core.Test.MediaFiles _trackedDownload.DownloadItem.CanMoveFiles = false; - Subject.ProcessPath(_droneFactory, ImportMode.Auto, _trackedDownload.RemoteAlbum.Artist, _trackedDownload.DownloadItem); + Subject.ProcessPath(_droneFactory, ImportMode.Auto, _trackedDownload.RemoteBook.Author, _trackedDownload.DownloadItem); DiskProvider.FolderExists(_subFolders[0]).Should().BeTrue(); } @@ -316,7 +316,7 @@ namespace NzbDrone.Core.Test.MediaFiles _trackedDownload.DownloadItem.CanMoveFiles = false; - Subject.ProcessPath(_droneFactory, ImportMode.Move, _trackedDownload.RemoteAlbum.Artist, _trackedDownload.DownloadItem); + Subject.ProcessPath(_droneFactory, ImportMode.Move, _trackedDownload.RemoteBook.Author, _trackedDownload.DownloadItem); DiskProvider.FolderExists(_subFolders[0]).Should().BeFalse(); } @@ -330,20 +330,20 @@ namespace NzbDrone.Core.Test.MediaFiles _trackedDownload.DownloadItem.CanMoveFiles = true; - Subject.ProcessPath(_droneFactory, ImportMode.Copy, _trackedDownload.RemoteAlbum.Artist, _trackedDownload.DownloadItem); + Subject.ProcessPath(_droneFactory, ImportMode.Copy, _trackedDownload.RemoteBook.Author, _trackedDownload.DownloadItem); DiskProvider.FolderExists(_subFolders[0]).Should().BeTrue(); } private void VerifyNoImport() { - Mocker.GetMock().Verify(c => c.Import(It.IsAny>>(), true, null, ImportMode.Auto), + Mocker.GetMock().Verify(c => c.Import(It.IsAny>>(), true, null, ImportMode.Auto), Times.Never()); } private void VerifyImport() { - Mocker.GetMock().Verify(c => c.Import(It.IsAny>>(), true, null, ImportMode.Auto), + Mocker.GetMock().Verify(c => c.Import(It.IsAny>>(), true, null, ImportMode.Auto), Times.Once()); } } diff --git a/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedTracksFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedTracksFixture.cs index 0638ebe62..1da292901 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedTracksFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedTracksFixture.cs @@ -5,13 +5,13 @@ using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.MediaFiles; +using NzbDrone.Core.MediaFiles.BookImport; using NzbDrone.Core.MediaFiles.Events; -using NzbDrone.Core.MediaFiles.TrackImport; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Qualities; using NzbDrone.Core.Qualities; @@ -21,18 +21,18 @@ using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MediaFiles { [TestFixture] - public class ImportApprovedTracksFixture : CoreTest + public class ImportApprovedTracksFixture : CoreTest { - private List> _rejectedDecisions; - private List> _approvedDecisions; + private List> _rejectedDecisions; + private List> _approvedDecisions; private DownloadClientItem _downloadClientItem; [SetUp] public void Setup() { - _rejectedDecisions = new List>(); - _approvedDecisions = new List>(); + _rejectedDecisions = new List>(); + _approvedDecisions = new List>(); var artist = Builder.CreateNew() .With(e => e.QualityProfile = new QualityProfile { Items = Qualities.QualityFixture.GetDefaultQualities() }) @@ -43,15 +43,15 @@ namespace NzbDrone.Core.Test.MediaFiles .With(e => e.Author = artist) .Build(); - _rejectedDecisions.Add(new ImportDecision(new LocalTrack(), new Rejection("Rejected!"))); - _rejectedDecisions.Add(new ImportDecision(new LocalTrack(), new Rejection("Rejected!"))); - _rejectedDecisions.Add(new ImportDecision(new LocalTrack(), new Rejection("Rejected!"))); + _rejectedDecisions.Add(new ImportDecision(new LocalBook(), new Rejection("Rejected!"))); + _rejectedDecisions.Add(new ImportDecision(new LocalBook(), new Rejection("Rejected!"))); + _rejectedDecisions.Add(new ImportDecision(new LocalBook(), new Rejection("Rejected!"))); - _approvedDecisions.Add(new ImportDecision( - new LocalTrack + _approvedDecisions.Add(new ImportDecision( + new LocalBook { - Artist = artist, - Album = album, + Author = artist, + Book = album, Path = Path.Combine(artist.Path, "Alien Ant Farm - 01 - Pilot.mp3"), Quality = new QualityModel(Quality.MP3_320), FileTrackInfo = new ParsedTrackInfo @@ -61,13 +61,13 @@ namespace NzbDrone.Core.Test.MediaFiles })); Mocker.GetMock() - .Setup(s => s.UpgradeTrackFile(It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(new TrackFileMoveResult()); + .Setup(s => s.UpgradeBookFile(It.IsAny(), It.IsAny(), It.IsAny())) + .Returns(new BookFileMoveResult()); _downloadClientItem = Builder.CreateNew().Build(); Mocker.GetMock() - .Setup(s => s.GetFilesByAlbum(It.IsAny())) + .Setup(s => s.GetFilesByBook(It.IsAny())) .Returns(new List()); } @@ -88,7 +88,7 @@ namespace NzbDrone.Core.Test.MediaFiles [Test] public void should_only_import_approved() { - var all = new List>(); + var all = new List>(); all.AddRange(_rejectedDecisions); all.AddRange(_approvedDecisions); @@ -101,9 +101,9 @@ namespace NzbDrone.Core.Test.MediaFiles [Test] public void should_only_import_each_track_once() { - var all = new List>(); + var all = new List>(); all.AddRange(_approvedDecisions); - all.Add(new ImportDecision(_approvedDecisions.First().Item)); + all.Add(new ImportDecision(_approvedDecisions.First().Item)); var result = Subject.Import(all, false); @@ -113,17 +113,17 @@ namespace NzbDrone.Core.Test.MediaFiles [Test] public void should_move_new_downloads() { - Subject.Import(new List> { _approvedDecisions.First() }, true); + Subject.Import(new List> { _approvedDecisions.First() }, true); Mocker.GetMock() - .Verify(v => v.UpgradeTrackFile(It.IsAny(), _approvedDecisions.First().Item, false), + .Verify(v => v.UpgradeBookFile(It.IsAny(), _approvedDecisions.First().Item, false), Times.Once()); } [Test] public void should_publish_TrackImportedEvent_for_new_downloads() { - Subject.Import(new List> { _approvedDecisions.First() }, true); + Subject.Import(new List> { _approvedDecisions.First() }, true); Mocker.GetMock() .Verify(v => v.PublishEvent(It.IsAny()), Times.Once()); @@ -134,10 +134,10 @@ namespace NzbDrone.Core.Test.MediaFiles { var track = _approvedDecisions.First(); track.Item.ExistingFile = true; - Subject.Import(new List> { track }, false); + Subject.Import(new List> { track }, false); Mocker.GetMock() - .Verify(v => v.UpgradeTrackFile(It.IsAny(), _approvedDecisions.First().Item, false), + .Verify(v => v.UpgradeBookFile(It.IsAny(), _approvedDecisions.First().Item, false), Times.Never()); } @@ -147,17 +147,17 @@ namespace NzbDrone.Core.Test.MediaFiles var fileDecision = _approvedDecisions.First(); fileDecision.Item.Size = 1.Gigabytes(); - var sampleDecision = new ImportDecision( - new LocalTrack + var sampleDecision = new ImportDecision( + new LocalBook { - Artist = fileDecision.Item.Artist, - Album = fileDecision.Item.Album, + Author = fileDecision.Item.Author, + Book = fileDecision.Item.Book, Path = @"C:\Test\Music\Alien Ant Farm\Alien Ant Farm - 01 - Pilot.mp3".AsOsAgnostic(), Quality = new QualityModel(Quality.MP3_320), Size = 80.Megabytes() }); - var all = new List>(); + var all = new List>(); all.Add(fileDecision); all.Add(sampleDecision); @@ -171,19 +171,19 @@ namespace NzbDrone.Core.Test.MediaFiles [Test] public void should_copy_when_cannot_move_files_downloads() { - Subject.Import(new List> { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "Alien.Ant.Farm-Truant", CanMoveFiles = false }); + Subject.Import(new List> { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "Alien.Ant.Farm-Truant", CanMoveFiles = false }); Mocker.GetMock() - .Verify(v => v.UpgradeTrackFile(It.IsAny(), _approvedDecisions.First().Item, true), Times.Once()); + .Verify(v => v.UpgradeBookFile(It.IsAny(), _approvedDecisions.First().Item, true), Times.Once()); } [Test] public void should_use_override_importmode() { - Subject.Import(new List> { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "Alien.Ant.Farm-Truant", CanMoveFiles = false }, ImportMode.Move); + Subject.Import(new List> { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "Alien.Ant.Farm-Truant", CanMoveFiles = false }, ImportMode.Move); Mocker.GetMock() - .Verify(v => v.UpgradeTrackFile(It.IsAny(), _approvedDecisions.First().Item, false), Times.Once()); + .Verify(v => v.UpgradeBookFile(It.IsAny(), _approvedDecisions.First().Item, false), Times.Once()); } [Test] @@ -195,7 +195,7 @@ namespace NzbDrone.Core.Test.MediaFiles var track = _approvedDecisions.First(); track.Item.ExistingFile = true; - Subject.Import(new List> { track }, false); + Subject.Import(new List> { track }, false); Mocker.GetMock() .Verify(v => v.Delete(It.IsAny(), DeleteMediaFileReason.ManualOverride), Times.Once()); diff --git a/src/NzbDrone.Core.Test/MediaFiles/MediaFileDeletionService/DeleteTrackFileFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MediaFileDeletionService/DeleteTrackFileFixture.cs index 30d099648..306560e56 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/MediaFileDeletionService/DeleteTrackFileFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MediaFileDeletionService/DeleteTrackFileFixture.cs @@ -3,9 +3,9 @@ using FizzWare.NBuilder; using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; +using NzbDrone.Core.Books; using NzbDrone.Core.Exceptions; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; diff --git a/src/NzbDrone.Core.Test/MediaFiles/MediaFileRepositoryFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MediaFileRepositoryFixture.cs index c627b90aa..714e2dd62 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/MediaFileRepositoryFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MediaFileRepositoryFixture.cs @@ -3,8 +3,8 @@ using System.Linq; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; @@ -55,10 +55,10 @@ namespace NzbDrone.Core.Test.MediaFiles public void get_files_by_artist() { VerifyData(); - var artistFiles = Subject.GetFilesByArtist(_artist.Id); + var artistFiles = Subject.GetFilesByAuthor(_artist.Id); VerifyEagerLoaded(artistFiles); - artistFiles.Should().OnlyContain(c => c.Artist.Value.Id == _artist.Id); + artistFiles.Should().OnlyContain(c => c.Author.Value.Id == _artist.Id); } [Test] @@ -109,17 +109,17 @@ namespace NzbDrone.Core.Test.MediaFiles var file = Subject.GetFileWithPath(@"C:\Test\Path\Artist\somefile2.flac".AsOsAgnostic()); file.Should().NotBeNull(); - file.Album.IsLoaded.Should().BeTrue(); - file.Album.Value.Should().NotBeNull(); - file.Artist.IsLoaded.Should().BeTrue(); - file.Artist.Value.Should().NotBeNull(); + file.Book.IsLoaded.Should().BeTrue(); + file.Book.Value.Should().NotBeNull(); + file.Author.IsLoaded.Should().BeTrue(); + file.Author.Value.Should().NotBeNull(); } [Test] public void get_files_by_album() { VerifyData(); - var files = Subject.GetFilesByAlbum(_album.Id); + var files = Subject.GetFilesByBook(_album.Id); VerifyEagerLoaded(files); files.Should().OnlyContain(c => c.BookId == _album.Id); @@ -136,12 +136,12 @@ namespace NzbDrone.Core.Test.MediaFiles { foreach (var file in files) { - file.Album.IsLoaded.Should().BeTrue(); - file.Album.Value.Should().NotBeNull(); - file.Artist.IsLoaded.Should().BeTrue(); - file.Artist.Value.Should().NotBeNull(); - file.Artist.Value.Metadata.IsLoaded.Should().BeTrue(); - file.Artist.Value.Metadata.Value.Should().NotBeNull(); + file.Book.IsLoaded.Should().BeTrue(); + file.Book.Value.Should().NotBeNull(); + file.Author.IsLoaded.Should().BeTrue(); + file.Author.Value.Should().NotBeNull(); + file.Author.Value.Metadata.IsLoaded.Should().BeTrue(); + file.Author.Value.Metadata.Value.Should().NotBeNull(); } } @@ -149,10 +149,10 @@ namespace NzbDrone.Core.Test.MediaFiles { foreach (var file in files) { - file.Album.IsLoaded.Should().BeFalse(); - file.Album.Value.Should().BeNull(); - file.Artist.IsLoaded.Should().BeFalse(); - file.Artist.Value.Should().BeNull(); + file.Book.IsLoaded.Should().BeFalse(); + file.Book.Value.Should().BeNull(); + file.Author.IsLoaded.Should().BeFalse(); + file.Author.Value.Should().BeNull(); } } @@ -160,7 +160,7 @@ namespace NzbDrone.Core.Test.MediaFiles public void delete_files_by_album_should_work_if_join_fails() { Db.Delete(_album); - Subject.DeleteFilesByAlbum(_album.Id); + Subject.DeleteFilesByBook(_album.Id); Db.All().Where(x => x.BookId == _album.Id).Should().HaveCount(0); } diff --git a/src/NzbDrone.Core.Test/MediaFiles/MediaFileServiceTests/FilterFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MediaFileServiceTests/FilterFixture.cs index 324f20626..c3bc653e0 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/MediaFileServiceTests/FilterFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MediaFileServiceTests/FilterFixture.cs @@ -7,9 +7,9 @@ using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; @@ -213,7 +213,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests Path = "C:\\file2.avi".AsOsAgnostic(), Size = 10, Modified = _lastWrite, - Album = new LazyLoaded(null) + Book = new LazyLoaded(null) } }); @@ -239,7 +239,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests Path = "C:\\file2.avi".AsOsAgnostic(), Size = 10, Modified = _lastWrite, - Album = Builder.CreateNew().Build() + Book = Builder.CreateNew().Build() } }); diff --git a/src/NzbDrone.Core.Test/MediaFiles/MediaFileServiceTests/MediaFileServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MediaFileServiceTests/MediaFileServiceFixture.cs index 0013dc8cc..55f561da5 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/MediaFileServiceTests/MediaFileServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MediaFileServiceTests/MediaFileServiceFixture.cs @@ -3,9 +3,9 @@ using System.Linq; using FizzWare.NBuilder; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Events; -using NzbDrone.Core.Music; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.MediaFiles.TrackFileMovingServiceTests @@ -35,7 +35,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackFileMovingServiceTests { Subject.DeleteMany(_trackFiles, DeleteMediaFileReason.Manual); - VerifyEventPublished(Times.Exactly(2)); + VerifyEventPublished(Times.Exactly(2)); } [Test] @@ -43,7 +43,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackFileMovingServiceTests { Subject.Delete(_trackFiles[0], DeleteMediaFileReason.Manual); - VerifyEventPublished(Times.Once()); + VerifyEventPublished(Times.Once()); } [Test] @@ -51,7 +51,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackFileMovingServiceTests { Subject.AddMany(_trackFiles); - VerifyEventPublished(Times.Exactly(3)); + VerifyEventPublished(Times.Exactly(3)); } [Test] @@ -59,7 +59,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackFileMovingServiceTests { Subject.Add(_trackFiles[0]); - VerifyEventPublished(Times.Once()); + VerifyEventPublished(Times.Once()); } } } diff --git a/src/NzbDrone.Core.Test/MediaFiles/MediaFileTableCleanupServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MediaFileTableCleanupServiceFixture.cs index cfd5e92f2..e289f7a66 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/MediaFileTableCleanupServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MediaFileTableCleanupServiceFixture.cs @@ -4,8 +4,8 @@ using System.Linq; using FizzWare.NBuilder; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; diff --git a/src/NzbDrone.Core.Test/MediaFiles/RenameTrackFileServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/RenameTrackFileServiceFixture.cs index 988d56ed8..8e954fb75 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/RenameTrackFileServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/RenameTrackFileServiceFixture.cs @@ -3,16 +3,16 @@ using System.Linq; using FizzWare.NBuilder; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Commands; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.MediaFiles { - public class RenameTrackFileServiceFixture : CoreTest + public class RenameTrackFileServiceFixture : CoreTest { private Author _artist; private List _trackFiles; @@ -25,12 +25,12 @@ namespace NzbDrone.Core.Test.MediaFiles _trackFiles = Builder.CreateListOfSize(2) .All() - .With(e => e.Artist = _artist) + .With(e => e.Author = _artist) .Build() .ToList(); - Mocker.GetMock() - .Setup(s => s.GetArtist(_artist.Id)) + Mocker.GetMock() + .Setup(s => s.GetAuthor(_artist.Id)) .Returns(_artist); } @@ -50,8 +50,8 @@ namespace NzbDrone.Core.Test.MediaFiles private void GivenMovedFiles() { - Mocker.GetMock() - .Setup(s => s.MoveTrackFile(It.IsAny(), _artist)); + Mocker.GetMock() + .Setup(s => s.MoveBookFile(It.IsAny(), _artist)); } [Test] @@ -62,7 +62,7 @@ namespace NzbDrone.Core.Test.MediaFiles Subject.Execute(new RenameFilesCommand(_artist.Id, new List { 1 })); Mocker.GetMock() - .Verify(v => v.PublishEvent(It.IsAny()), Times.Never()); + .Verify(v => v.PublishEvent(It.IsAny()), Times.Never()); } [Test] @@ -70,14 +70,14 @@ namespace NzbDrone.Core.Test.MediaFiles { GivenTrackFiles(); - Mocker.GetMock() - .Setup(s => s.MoveTrackFile(It.IsAny(), It.IsAny())) + Mocker.GetMock() + .Setup(s => s.MoveBookFile(It.IsAny(), It.IsAny())) .Throws(new SameFilenameException("Same file name", "Filename")); Subject.Execute(new RenameFilesCommand(_artist.Id, new List { 1 })); Mocker.GetMock() - .Verify(v => v.PublishEvent(It.IsAny()), Times.Never()); + .Verify(v => v.PublishEvent(It.IsAny()), Times.Never()); } [Test] @@ -89,7 +89,7 @@ namespace NzbDrone.Core.Test.MediaFiles Subject.Execute(new RenameFilesCommand(_artist.Id, new List { 1 })); Mocker.GetMock() - .Verify(v => v.PublishEvent(It.IsAny()), Times.Once()); + .Verify(v => v.PublishEvent(It.IsAny()), Times.Once()); } [Test] diff --git a/src/NzbDrone.Core.Test/MediaFiles/TrackFileMovingServiceTests/MoveTrackFileFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/TrackFileMovingServiceTests/MoveTrackFileFixture.cs index 4d26d95e5..69d4a64a2 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/TrackFileMovingServiceTests/MoveTrackFileFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/TrackFileMovingServiceTests/MoveTrackFileFixture.cs @@ -7,10 +7,10 @@ using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; using NzbDrone.Core.Organizer; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; @@ -19,11 +19,11 @@ using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MediaFiles.TrackFileMovingServiceTests { [TestFixture] - public class MoveTrackFileFixture : CoreTest + public class MoveTrackFileFixture : CoreTest { private Author _artist; private BookFile _trackFile; - private LocalTrack _localtrack; + private LocalBook _localtrack; [SetUp] public void Setup() @@ -37,21 +37,21 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackFileMovingServiceTests .With(f => f.Path = Path.Combine(_artist.Path, @"Album\File.mp3")) .Build(); - _localtrack = Builder.CreateNew() - .With(l => l.Artist = _artist) - .With(l => l.Album = Builder.CreateNew().Build()) + _localtrack = Builder.CreateNew() + .With(l => l.Author = _artist) + .With(l => l.Book = Builder.CreateNew().Build()) .Build(); Mocker.GetMock() - .Setup(s => s.BuildTrackFileName(It.IsAny(), It.IsAny(), It.IsAny(), null, null)) + .Setup(s => s.BuildBookFileName(It.IsAny(), It.IsAny(), It.IsAny(), null, null)) .Returns("File Name"); Mocker.GetMock() - .Setup(s => s.BuildTrackFilePath(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) + .Setup(s => s.BuildBookFilePath(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(@"C:\Test\Music\Artist\Album\File Name.mp3".AsOsAgnostic()); Mocker.GetMock() - .Setup(s => s.BuildAlbumPath(It.IsAny(), It.IsAny())) + .Setup(s => s.BuildBookPath(It.IsAny(), It.IsAny())) .Returns(@"C:\Test\Music\Artist\Album".AsOsAgnostic()); var rootFolder = @"C:\Test\Music\".AsOsAgnostic(); @@ -73,7 +73,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackFileMovingServiceTests .Setup(s => s.InheritFolderPermissions(It.IsAny())) .Throws(); - Subject.MoveTrackFile(_trackFile, _localtrack); + Subject.MoveBookFile(_trackFile, _localtrack); } [Test] @@ -85,27 +85,27 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackFileMovingServiceTests .Setup(s => s.InheritFolderPermissions(It.IsAny())) .Throws(); - Subject.MoveTrackFile(_trackFile, _localtrack); + Subject.MoveBookFile(_trackFile, _localtrack); } [Test] public void should_notify_on_artist_folder_creation() { - Subject.MoveTrackFile(_trackFile, _localtrack); + Subject.MoveBookFile(_trackFile, _localtrack); Mocker.GetMock() .Verify(s => s.PublishEvent(It.Is(p => - p.ArtistFolder.IsNotNullOrWhiteSpace())), Times.Once()); + p.AuthorFolder.IsNotNullOrWhiteSpace())), Times.Once()); } [Test] public void should_notify_on_album_folder_creation() { - Subject.MoveTrackFile(_trackFile, _localtrack); + Subject.MoveBookFile(_trackFile, _localtrack); Mocker.GetMock() .Verify(s => s.PublishEvent(It.Is(p => - p.AlbumFolder.IsNotNullOrWhiteSpace())), Times.Once()); + p.BookFolder.IsNotNullOrWhiteSpace())), Times.Once()); } [Test] @@ -115,11 +115,11 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackFileMovingServiceTests .Setup(s => s.FolderExists(_artist.Path)) .Returns(true); - Subject.MoveTrackFile(_trackFile, _localtrack); + Subject.MoveBookFile(_trackFile, _localtrack); Mocker.GetMock() .Verify(s => s.PublishEvent(It.Is(p => - p.ArtistFolder.IsNotNullOrWhiteSpace())), Times.Never()); + p.AuthorFolder.IsNotNullOrWhiteSpace())), Times.Never()); } } } diff --git a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Aggregation/AggregateFilenameInfoFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Aggregation/AggregateFilenameInfoFixture.cs index 1160b474f..e908a708c 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Aggregation/AggregateFilenameInfoFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Aggregation/AggregateFilenameInfoFixture.cs @@ -5,19 +5,19 @@ using System.IO; using System.Linq; using FluentAssertions; using NUnit.Framework; -using NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators; +using NzbDrone.Core.MediaFiles.BookImport.Aggregation.Aggregators; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; -namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Aggregation.Aggregators +namespace NzbDrone.Core.Test.MediaFiles.BookImport.Aggregation.Aggregators { [TestFixture] public class AggregateFilenameInfoFixture : CoreTest { private LocalAlbumRelease GivenTracks(List files, string root) { - var tracks = files.Select(x => new LocalTrack + var tracks = files.Select(x => new LocalBook { Path = Path.Combine(root, x), FileTrackInfo = new ParsedTrackInfo @@ -28,7 +28,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Aggregation.Aggregators return new LocalAlbumRelease(tracks); } - private void VerifyData(LocalTrack track, string artist, string title, int trackNum, int disc) + private void VerifyData(LocalBook track, string artist, string title, int trackNum, int disc) { track.FileTrackInfo.ArtistTitle.Should().Be(artist); track.FileTrackInfo.Title.Should().Be(title); @@ -49,10 +49,10 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Aggregation.Aggregators Subject.Aggregate(release, true); - VerifyData(release.LocalTracks[0], "Adele", "Daydreamer", 1, 1); - VerifyData(release.LocalTracks[1], "Adele", "Best for Last", 2, 1); - VerifyData(release.LocalTracks[2], "Adele", "Chasing Pavements", 3, 1); - VerifyData(release.LocalTracks[3], "Adele", "That's It, I Quit, I'm Moving On", 3, 2); + VerifyData(release.LocalBooks[0], "Adele", "Daydreamer", 1, 1); + VerifyData(release.LocalBooks[1], "Adele", "Best for Last", 2, 1); + VerifyData(release.LocalBooks[2], "Adele", "Chasing Pavements", 3, 1); + VerifyData(release.LocalBooks[3], "Adele", "That's It, I Quit, I'm Moving On", 3, 2); } public static class TestCaseFactory @@ -159,7 +159,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Aggregation.Aggregators return outp; } - private void VerifyDataAuto(List tracks, string[] tokens, string whitespace) + private void VerifyDataAuto(List tracks, string[] tokens, string whitespace) { for (int i = 1; i <= tracks.Count; i++) { @@ -200,7 +200,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Aggregation.Aggregators Subject.Aggregate(release, true); - VerifyDataAuto(release.LocalTracks, testcase.Item1, testcase.Item3); + VerifyDataAuto(release.LocalBooks, testcase.Item1, testcase.Item3); } } } diff --git a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/DistanceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/DistanceFixture.cs index 8c0851f6d..74fe5a750 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/DistanceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/DistanceFixture.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; using FluentAssertions; using NUnit.Framework; -using NzbDrone.Core.MediaFiles.TrackImport.Identification; +using NzbDrone.Core.MediaFiles.BookImport.Identification; using NzbDrone.Test.Common; -namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification +namespace NzbDrone.Core.Test.MediaFiles.BookImport.Identification { [TestFixture] public class DistanceFixture : TestBase diff --git a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/IdentificationServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/IdentificationServiceFixture.cs index d1ff79569..eebdd110a 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/IdentificationServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/IdentificationServiceFixture.cs @@ -8,32 +8,32 @@ using Moq; using Newtonsoft.Json; using NUnit.Framework; using NzbDrone.Common.Serializer; +using NzbDrone.Core.Books; +using NzbDrone.Core.Books.Commands; using NzbDrone.Core.Configuration; using NzbDrone.Core.ImportLists.Exclusions; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.MediaFiles.TrackImport; -using NzbDrone.Core.MediaFiles.TrackImport.Aggregation; -using NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators; -using NzbDrone.Core.MediaFiles.TrackImport.Identification; +using NzbDrone.Core.MediaFiles.BookImport; +using NzbDrone.Core.MediaFiles.BookImport.Aggregation; +using NzbDrone.Core.MediaFiles.BookImport.Aggregation.Aggregators; +using NzbDrone.Core.MediaFiles.BookImport.Identification; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.MetadataSource; using NzbDrone.Core.MetadataSource.SkyHook; -using NzbDrone.Core.Music; -using NzbDrone.Core.Music.Commands; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Metadata; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; -namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification +namespace NzbDrone.Core.Test.MediaFiles.BookImport.Identification { [TestFixture] public class IdentificationServiceFixture : DbTest { - private ArtistService _artistService; - private AddArtistService _addArtistService; - private RefreshArtistService _refreshArtistService; + private AuthorService _authorService; + private AddArtistService _addAuthorService; + private RefreshAuthorService _refreshArtistService; private IdentificationService _Subject; @@ -43,18 +43,18 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification UseRealHttp(); // Resolve all the parts we need - Mocker.SetConstant(Mocker.Resolve()); - Mocker.SetConstant(Mocker.Resolve()); - Mocker.SetConstant(Mocker.Resolve()); + Mocker.SetConstant(Mocker.Resolve()); + Mocker.SetConstant(Mocker.Resolve()); + Mocker.SetConstant(Mocker.Resolve()); Mocker.SetConstant(Mocker.Resolve()); Mocker.SetConstant(Mocker.Resolve()); Mocker.GetMock().Setup(x => x.Exists(It.IsAny())).Returns(true); - _artistService = Mocker.Resolve(); - Mocker.SetConstant(_artistService); - Mocker.SetConstant(Mocker.Resolve()); - Mocker.SetConstant(Mocker.Resolve()); + _authorService = Mocker.Resolve(); + Mocker.SetConstant(_authorService); + Mocker.SetConstant(Mocker.Resolve()); + Mocker.SetConstant(Mocker.Resolve()); Mocker.SetConstant(Mocker.Resolve()); Mocker.SetConstant(Mocker.Resolve()); @@ -62,12 +62,12 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification Mocker.SetConstant(Mocker.Resolve()); Mocker.SetConstant(Mocker.Resolve()); - _addArtistService = Mocker.Resolve(); + _addAuthorService = Mocker.Resolve(); - Mocker.SetConstant(Mocker.Resolve()); - _refreshArtistService = Mocker.Resolve(); + Mocker.SetConstant(Mocker.Resolve()); + _refreshArtistService = Mocker.Resolve(); - Mocker.GetMock().Setup(x => x.Validate(It.IsAny())).Returns(new ValidationResult()); + Mocker.GetMock().Setup(x => x.Validate(It.IsAny())).Returns(new ValidationResult()); Mocker.SetConstant(Mocker.Resolve()); Mocker.SetConstant(Mocker.Resolve()); @@ -88,7 +88,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification Mocker.GetMock().Setup(x => x.Get(profile.Id)).Returns(profile); } - private List GivenArtists(List artists) + private List GivenArtists(List artists) { var outp = new List(); for (int i = 0; i < artists.Count; i++) @@ -96,7 +96,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification var meta = artists[i].MetadataProfile; meta.Id = i + 1; GivenMetadataProfile(meta); - outp.Add(GivenArtist(artists[i].Artist, meta.Id)); + outp.Add(GivenArtist(artists[i].Author, meta.Id)); } return outp; @@ -104,7 +104,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification private Author GivenArtist(string foreignAuthorId, int metadataProfileId) { - var artist = _addArtistService.AddArtist(new Author + var artist = _addAuthorService.AddAuthor(new Author { Metadata = new AuthorMetadata { @@ -114,7 +114,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification MetadataProfileId = metadataProfileId }); - var command = new RefreshArtistCommand + var command = new RefreshAuthorCommand { AuthorId = artist.Id, Trigger = CommandTrigger.Unspecified @@ -122,7 +122,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification _refreshArtistService.Execute(command); - return _artistService.FindById(foreignAuthorId); + return _authorService.FindById(foreignAuthorId); } private void GivenFingerprints(List fingerprints) @@ -131,8 +131,8 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification Mocker.GetMock().Setup(x => x.IsSetup()).Returns(true); Mocker.GetMock() - .Setup(x => x.Lookup(It.IsAny>(), It.IsAny())) - .Callback((List track, double thres) => + .Setup(x => x.Lookup(It.IsAny>(), It.IsAny())) + .Callback((List track, double thres) => { track.ForEach(x => x.AcoustIdResults = fingerprints.SingleOrDefault(f => f.Path == x.Path).AcoustIdResults); }); @@ -172,11 +172,11 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification var path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "Identification", file); var testcase = JsonConvert.DeserializeObject(File.ReadAllText(path)); - var artists = GivenArtists(testcase.LibraryArtists); - var specifiedArtist = artists.SingleOrDefault(x => x.Metadata.Value.ForeignAuthorId == testcase.Artist); - var idOverrides = new IdentificationOverrides { Artist = specifiedArtist }; + var artists = GivenArtists(testcase.LibraryAuthors); + var specifiedArtist = artists.SingleOrDefault(x => x.Metadata.Value.ForeignAuthorId == testcase.Author); + var idOverrides = new IdentificationOverrides { Author = specifiedArtist }; - var tracks = testcase.Tracks.Select(x => new LocalTrack + var tracks = testcase.Tracks.Select(x => new LocalBook { Path = x.Path.AsOsAgnostic(), FileTrackInfo = x.FileTrackInfo diff --git a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/MunkresFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/MunkresFixture.cs index 2229a05f2..30fb2cde8 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/MunkresFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/MunkresFixture.cs @@ -1,9 +1,9 @@ using FluentAssertions; using NUnit.Framework; -using NzbDrone.Core.MediaFiles.TrackImport.Identification; +using NzbDrone.Core.MediaFiles.BookImport.Identification; using NzbDrone.Test.Common; -namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification +namespace NzbDrone.Core.Test.MediaFiles.BookImport.Identification { [TestFixture] public class MunkresFixture : TestBase diff --git a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/TrackGroupingServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/TrackGroupingServiceFixture.cs index a83c935e0..202e7720d 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/TrackGroupingServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/TrackGroupingServiceFixture.cs @@ -7,12 +7,12 @@ using FizzWare.NBuilder; using FizzWare.NBuilder.PropertyNaming; using FluentAssertions; using NUnit.Framework; -using NzbDrone.Core.MediaFiles.TrackImport.Identification; +using NzbDrone.Core.MediaFiles.BookImport.Identification; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; -namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification +namespace NzbDrone.Core.Test.MediaFiles.BookImport.Identification { // we need to use random strings to test the va (so we don't just get artist1, artist2 etc which are too similar) // but the standard random value namer would give paths that are too long on windows @@ -66,7 +66,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification [TestFixture] public class TrackGroupingServiceFixture : CoreTest { - private List GivenTracks(string root, string artist, string album, int count) + private List GivenTracks(string root, string artist, string album, int count) { var fileInfos = Builder .CreateListOfSize(count) @@ -77,7 +77,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification .With(f => f.ReleaseMBId = null) .Build(); - var tracks = fileInfos.Select(x => Builder + var tracks = fileInfos.Select(x => Builder .CreateNew() .With(y => y.FileTrackInfo = x) .With(y => y.Path = Path.Combine(root, x.Title)) @@ -86,13 +86,13 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification return tracks; } - private List GivenTracksWithNoTags(string root, int count) + private List GivenTracksWithNoTags(string root, int count) { - var outp = new List(); + var outp = new List(); for (int i = 0; i < count; i++) { - var track = Builder + var track = Builder .CreateNew() .With(y => y.FileTrackInfo = new ParsedTrackInfo()) .With(y => y.Path = Path.Combine(root, $"{i}.mp3")) @@ -104,7 +104,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification } [Repeat(100)] - private List GivenVaTracks(string root, string album, int count) + private List GivenVaTracks(string root, string album, int count) { var settings = new BuilderSettings(); settings.SetPropertyNamerFor(new RandomValueNamerShortStrings(settings)); @@ -119,7 +119,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification .With(f => f.ReleaseMBId = null) .Build(); - var tracks = fileInfos.Select(x => Builder + var tracks = fileInfos.Select(x => Builder .CreateNew() .With(y => y.FileTrackInfo = x) .With(y => y.Path = Path.Combine(@"C:\music\incoming".AsOsAgnostic(), x.Title)) @@ -199,7 +199,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification TrackGroupingService.LooksLikeSingleRelease(tracks).Should().Be(true); output.Count.Should().Be(1); - output[0].LocalTracks.Count.Should().Be(count); + output[0].LocalBooks.Count.Should().Be(count); } [TestCase("cd")] @@ -215,7 +215,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification var output = Subject.GroupTracks(tracks); output.Count.Should().Be(1); - output[0].LocalTracks.Count.Should().Be(15); + output[0].LocalBooks.Count.Should().Be(15); } [Test] @@ -229,8 +229,8 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification var output = Subject.GroupTracks(tracks); output.Count.Should().Be(2); - output[0].LocalTracks.Count.Should().Be(10); - output[1].LocalTracks.Count.Should().Be(5); + output[0].LocalBooks.Count.Should().Be(10); + output[1].LocalBooks.Count.Should().Be(5); } [Test] @@ -244,7 +244,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification var output = Subject.GroupTracks(tracks); output.Count.Should().Be(1); - output[0].LocalTracks.Count.Should().Be(15); + output[0].LocalBooks.Count.Should().Be(15); } [Test] @@ -258,8 +258,8 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification var output = Subject.GroupTracks(tracks); output.Count.Should().Be(2); - output[0].LocalTracks.Count.Should().Be(1); - output[1].LocalTracks.Count.Should().Be(1); + output[0].LocalBooks.Count.Should().Be(1); + output[1].LocalBooks.Count.Should().Be(1); } [Test] @@ -273,14 +273,14 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification var output = Subject.GroupTracks(tracks); output.Count.Should().Be(2); - output[0].LocalTracks.Count.Should().Be(10); - output[1].LocalTracks.Count.Should().Be(5); + output[0].LocalBooks.Count.Should().Be(10); + output[1].LocalBooks.Count.Should().Be(5); } [Test] public void should_separate_many_albums_in_same_directory() { - var tracks = new List(); + var tracks = new List(); for (int i = 0; i < 100; i++) { tracks.AddRange(GivenTracks($"C:\\music".AsOsAgnostic(), "artist" + i, "album" + i, 10)); @@ -291,7 +291,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification var output = Subject.GroupTracks(tracks); output.Count.Should().Be(100); - output.Select(x => x.LocalTracks.Count).Distinct().Should().BeEquivalentTo(new List { 10 }); + output.Select(x => x.LocalBooks.Count).Distinct().Should().BeEquivalentTo(new List { 10 }); } [Test] @@ -305,8 +305,8 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification var output = Subject.GroupTracks(tracks); output.Count.Should().Be(2); - output[0].LocalTracks.Count.Should().Be(10); - output[1].LocalTracks.Count.Should().Be(5); + output[0].LocalBooks.Count.Should().Be(10); + output[1].LocalBooks.Count.Should().Be(5); } [Test] @@ -320,7 +320,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification var output = Subject.GroupTracks(tracks); output.Count.Should().Be(1); - output[0].LocalTracks.Count.Should().Be(10); + output[0].LocalBooks.Count.Should().Be(10); } [Test] @@ -335,8 +335,8 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification var output = Subject.GroupTracks(tracks); output.Count.Should().Be(2); - output[0].LocalTracks.Count.Should().Be(10); - output[1].LocalTracks.Count.Should().Be(5); + output[0].LocalBooks.Count.Should().Be(10); + output[1].LocalBooks.Count.Should().Be(5); } [Test] @@ -349,7 +349,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification var output = Subject.GroupTracks(tracks); output.Count.Should().Be(1); - output[0].LocalTracks.Count.Should().Be(10); + output[0].LocalBooks.Count.Should().Be(10); } [Test] @@ -363,7 +363,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification var output = Subject.GroupTracks(tracks); output.Count.Should().Be(1); - output[0].LocalTracks.Count.Should().Be(12); + output[0].LocalBooks.Count.Should().Be(12); } [Test] @@ -380,12 +380,12 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification foreach (var group in output) { TestLogger.Debug($"*** group {group} ***"); - TestLogger.Debug(string.Join("\n", group.LocalTracks.Select(x => x.Path))); + TestLogger.Debug(string.Join("\n", group.LocalBooks.Select(x => x.Path))); } output.Count.Should().Be(2); - output[0].LocalTracks.Count.Should().Be(10); - output[1].LocalTracks.Count.Should().Be(10); + output[0].LocalBooks.Count.Should().Be(10); + output[1].LocalBooks.Count.Should().Be(10); } } } diff --git a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/ImportDecisionMakerFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/ImportDecisionMakerFixture.cs index 9c27350cc..3f25059e1 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/ImportDecisionMakerFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/ImportDecisionMakerFixture.cs @@ -6,26 +6,26 @@ using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.MediaFiles.TrackImport; -using NzbDrone.Core.MediaFiles.TrackImport.Aggregation; -using NzbDrone.Core.MediaFiles.TrackImport.Identification; -using NzbDrone.Core.Music; +using NzbDrone.Core.MediaFiles.BookImport; +using NzbDrone.Core.MediaFiles.BookImport.Aggregation; +using NzbDrone.Core.MediaFiles.BookImport.Identification; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Qualities; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; -namespace NzbDrone.Core.Test.MediaFiles.TrackImport +namespace NzbDrone.Core.Test.MediaFiles.BookImport { [TestFixture] public class ImportDecisionMakerFixture : FileSystemTest { private List _fileInfos; - private LocalTrack _localTrack; + private LocalBook _localTrack; private Author _artist; private Book _album; private QualityModel _quality; @@ -41,13 +41,13 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport private Mock> _albumfail2; private Mock> _albumfail3; - private Mock> _pass1; - private Mock> _pass2; - private Mock> _pass3; + private Mock> _pass1; + private Mock> _pass2; + private Mock> _pass3; - private Mock> _fail1; - private Mock> _fail2; - private Mock> _fail3; + private Mock> _fail1; + private Mock> _fail2; + private Mock> _fail3; [SetUp] public void Setup() @@ -60,13 +60,13 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport _albumfail2 = new Mock>(); _albumfail3 = new Mock>(); - _pass1 = new Mock>(); - _pass2 = new Mock>(); - _pass3 = new Mock>(); + _pass1 = new Mock>(); + _pass2 = new Mock>(); + _pass3 = new Mock>(); - _fail1 = new Mock>(); - _fail2 = new Mock>(); - _fail3 = new Mock>(); + _fail1 = new Mock>(); + _fail2 = new Mock>(); + _fail3 = new Mock>(); _albumpass1.Setup(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny())).Returns(Decision.Accept()); _albumpass2.Setup(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny())).Returns(Decision.Accept()); @@ -76,13 +76,13 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport _albumfail2.Setup(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny())).Returns(Decision.Reject("_albumfail2")); _albumfail3.Setup(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny())).Returns(Decision.Reject("_albumfail3")); - _pass1.Setup(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny())).Returns(Decision.Accept()); - _pass2.Setup(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny())).Returns(Decision.Accept()); - _pass3.Setup(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny())).Returns(Decision.Accept()); + _pass1.Setup(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny())).Returns(Decision.Accept()); + _pass2.Setup(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny())).Returns(Decision.Accept()); + _pass3.Setup(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny())).Returns(Decision.Accept()); - _fail1.Setup(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny())).Returns(Decision.Reject("_fail1")); - _fail2.Setup(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny())).Returns(Decision.Reject("_fail2")); - _fail3.Setup(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny())).Returns(Decision.Reject("_fail3")); + _fail1.Setup(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny())).Returns(Decision.Reject("_fail1")); + _fail2.Setup(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny())).Returns(Decision.Reject("_fail2")); + _fail3.Setup(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny())).Returns(Decision.Reject("_fail3")); _artist = Builder.CreateNew() .With(e => e.QualityProfileId = 1) @@ -95,17 +95,17 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport _quality = new QualityModel(Quality.MP3_320); - _localTrack = new LocalTrack + _localTrack = new LocalBook { - Artist = _artist, + Author = _artist, Quality = _quality, - Album = new Book(), + Book = new Book(), Path = @"C:\Test\Unsorted\The.Office.S03E115.DVDRip.XviD-OSiTV.avi".AsOsAgnostic() }; _idOverrides = new IdentificationOverrides { - Artist = _artist + Author = _artist }; _idConfig = new ImportDecisionMakerConfig(); @@ -113,8 +113,8 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport GivenAudioFiles(new List { @"C:\Test\Unsorted\The.Office.S03E115.DVDRip.XviD-OSiTV.avi".AsOsAgnostic() }); Mocker.GetMock() - .Setup(s => s.Identify(It.IsAny>(), It.IsAny(), It.IsAny())) - .Returns((List tracks, IdentificationOverrides idOverrides, ImportDecisionMakerConfig config) => + .Setup(s => s.Identify(It.IsAny>(), It.IsAny(), It.IsAny())) + .Returns((List tracks, IdentificationOverrides idOverrides, ImportDecisionMakerConfig config) => { var ret = new LocalAlbumRelease(tracks); ret.Book = _album; @@ -146,10 +146,10 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport private void GivenAugmentationSuccess() { Mocker.GetMock() - .Setup(s => s.Augment(It.IsAny(), It.IsAny())) - .Callback((localTrack, otherFiles) => + .Setup(s => s.Augment(It.IsAny(), It.IsAny())) + .Callback((localTrack, otherFiles) => { - localTrack.Album = _localTrack.Album; + localTrack.Book = _localTrack.Book; }); } @@ -183,12 +183,12 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport Subject.GetImportDecisions(_fileInfos, null, itemInfo, _idConfig); - _fail1.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Once()); - _fail2.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Once()); - _fail3.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Once()); - _pass1.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Once()); - _pass2.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Once()); - _pass3.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Once()); + _fail1.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Once()); + _fail2.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Once()); + _fail3.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Once()); + _pass1.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Once()); + _pass2.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Once()); + _pass3.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Once()); } [Test] @@ -203,12 +203,12 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport Subject.GetImportDecisions(_fileInfos, null, itemInfo, _idConfig); - _fail1.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Never()); - _fail2.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Never()); - _fail3.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Never()); - _pass1.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Never()); - _pass2.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Never()); - _pass3.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Never()); + _fail1.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Never()); + _fail2.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Never()); + _fail3.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Never()); + _pass1.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Never()); + _pass2.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Never()); + _pass3.Verify(c => c.IsSatisfiedBy(It.IsAny(), It.IsAny()), Times.Never()); } [Test] @@ -283,7 +283,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport GivenSpecifications(_pass1); Mocker.GetMock() - .Setup(c => c.Augment(It.IsAny(), It.IsAny())) + .Setup(c => c.Augment(It.IsAny(), It.IsAny())) .Throws(); GivenAudioFiles(new[] @@ -296,7 +296,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport var decisions = Subject.GetImportDecisions(_fileInfos, _idOverrides, null, _idConfig); Mocker.GetMock() - .Verify(c => c.Augment(It.IsAny(), It.IsAny()), Times.Exactly(_fileInfos.Count)); + .Verify(c => c.Augment(It.IsAny(), It.IsAny()), Times.Exactly(_fileInfos.Count)); ExceptionVerification.ExpectedErrors(3); } @@ -314,8 +314,8 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport }); Mocker.GetMock() - .Setup(s => s.Identify(It.IsAny>(), It.IsAny(), It.IsAny())) - .Returns((List tracks, IdentificationOverrides idOverrides, ImportDecisionMakerConfig config) => + .Setup(s => s.Identify(It.IsAny>(), It.IsAny(), It.IsAny())) + .Returns((List tracks, IdentificationOverrides idOverrides, ImportDecisionMakerConfig config) => { return new List { new LocalAlbumRelease(tracks) }; }); @@ -323,7 +323,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport var decisions = Subject.GetImportDecisions(_fileInfos, _idOverrides, null, _idConfig); Mocker.GetMock() - .Verify(c => c.Augment(It.IsAny(), It.IsAny()), Times.Exactly(_fileInfos.Count)); + .Verify(c => c.Augment(It.IsAny(), It.IsAny()), Times.Exactly(_fileInfos.Count)); decisions.Should().HaveCount(3); decisions.First().Rejections.Should().NotBeEmpty(); @@ -344,7 +344,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport var decisions = Subject.GetImportDecisions(_fileInfos, _idOverrides, null, _idConfig); Mocker.GetMock() - .Verify(c => c.Augment(It.IsAny(), It.IsAny()), Times.Exactly(_fileInfos.Count)); + .Verify(c => c.Augment(It.IsAny(), It.IsAny()), Times.Exactly(_fileInfos.Count)); decisions.Should().HaveCount(3); decisions.First().Rejections.Should().NotBeEmpty(); @@ -354,7 +354,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport public void should_return_a_decision_when_exception_is_caught() { Mocker.GetMock() - .Setup(c => c.Augment(It.IsAny(), It.IsAny())) + .Setup(c => c.Augment(It.IsAny(), It.IsAny())) .Throws(); GivenAudioFiles(new[] diff --git a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Specifications/FreeSpaceSpecificationFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Specifications/FreeSpaceSpecificationFixture.cs index 823bf3448..c66ef3e97 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Specifications/FreeSpaceSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Specifications/FreeSpaceSpecificationFixture.cs @@ -4,20 +4,20 @@ using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; -using NzbDrone.Core.MediaFiles.TrackImport.Specifications; -using NzbDrone.Core.Music; +using NzbDrone.Core.MediaFiles.BookImport.Specifications; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; -namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications +namespace NzbDrone.Core.Test.MediaFiles.BookImport.Specifications { [TestFixture] public class FreeSpaceSpecificationFixture : CoreTest { private Author _artist; - private LocalTrack _localTrack; + private LocalBook _localTrack; private string _rootFolder; [SetUp] @@ -29,11 +29,11 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications .With(s => s.Path = Path.Combine(_rootFolder, "Alice in Chains")) .Build(); - _localTrack = new LocalTrack + _localTrack = new LocalBook { Path = @"C:\Test\Unsorted\Alice in Chains\Alice in Chains - track1.mp3".AsOsAgnostic(), - Album = new Book(), - Artist = _artist + Book = new Book(), + Author = _artist }; } diff --git a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Specifications/NotUnpackingSpecificationFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Specifications/NotUnpackingSpecificationFixture.cs index bcdde075b..722eba60c 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Specifications/NotUnpackingSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Specifications/NotUnpackingSpecificationFixture.cs @@ -4,19 +4,19 @@ using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; -using NzbDrone.Core.MediaFiles.TrackImport.Specifications; -using NzbDrone.Core.Music; +using NzbDrone.Core.MediaFiles.BookImport.Specifications; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; -namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications +namespace NzbDrone.Core.Test.MediaFiles.BookImport.Specifications { [TestFixture] public class NotUnpackingSpecificationFixture : CoreTest { - private LocalTrack _localTrack; + private LocalBook _localTrack; [SetUp] public void Setup() @@ -25,11 +25,11 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications .SetupGet(s => s.DownloadClientWorkingFolders) .Returns("_UNPACK_|_FAILED_"); - _localTrack = new LocalTrack + _localTrack = new LocalBook { Path = @"C:\Test\Unsorted Music\Kid.Rock\Kid.Rock.Cowboy.mp3".AsOsAgnostic(), Size = 100, - Artist = Builder.CreateNew().Build() + Author = Builder.CreateNew().Build() }; } diff --git a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Specifications/SameFileSpecificationFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Specifications/SameFileSpecificationFixture.cs index 9d3b3dfcf..ffa01c460 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Specifications/SameFileSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Specifications/SameFileSpecificationFixture.cs @@ -2,24 +2,24 @@ using System.Collections.Generic; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.MediaFiles.TrackImport.Specifications; -using NzbDrone.Core.Music; +using NzbDrone.Core.MediaFiles.BookImport.Specifications; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; -namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications +namespace NzbDrone.Core.Test.MediaFiles.BookImport.Specifications { [TestFixture] public class SameFileSpecificationFixture : CoreTest { - private LocalTrack _localTrack; + private LocalBook _localTrack; [SetUp] public void Setup() { - _localTrack = Builder.CreateNew() + _localTrack = Builder.CreateNew() .With(l => l.Size = 150.Megabytes()) .Build(); } @@ -27,7 +27,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications [Test] public void should_be_accepted_if_no_existing_file() { - _localTrack.Album = Builder.CreateNew() + _localTrack.Book = Builder.CreateNew() .Build(); Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeTrue(); @@ -61,7 +61,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications [Test] public void should_be_accepted_if_file_size_is_different() { - _localTrack.Album = Builder.CreateNew() + _localTrack.Book = Builder.CreateNew() .With(e => e.BookFiles = new LazyLoaded>( new List { @@ -78,7 +78,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications [Test] public void should_be_reject_if_file_size_is_the_same() { - _localTrack.Album = Builder.CreateNew() + _localTrack.Book = Builder.CreateNew() .With(e => e.BookFiles = new LazyLoaded>( new List { diff --git a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Specifications/UpgradeSpecificationFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Specifications/UpgradeSpecificationFixture.cs index 315f029af..9dab94b32 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Specifications/UpgradeSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Specifications/UpgradeSpecificationFixture.cs @@ -2,17 +2,17 @@ using System.Linq; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; using NzbDrone.Core.Datastore; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.MediaFiles.TrackImport.Specifications; -using NzbDrone.Core.Music; +using NzbDrone.Core.MediaFiles.BookImport.Specifications; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Qualities; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications +namespace NzbDrone.Core.Test.MediaFiles.BookImport.Specifications { [TestFixture] public class UpgradeSpecificationFixture : CoreTest diff --git a/src/NzbDrone.Core.Test/MediaFiles/UpgradeMediaFileServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/UpgradeMediaFileServiceFixture.cs index 397d3d028..6bbaee6a2 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/UpgradeMediaFileServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/UpgradeMediaFileServiceFixture.cs @@ -5,9 +5,9 @@ using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.RootFolders; using NzbDrone.Core.Test.Framework; @@ -18,14 +18,14 @@ namespace NzbDrone.Core.Test.MediaFiles public class UpgradeMediaFileServiceFixture : CoreTest { private BookFile _trackFile; - private LocalTrack _localTrack; + private LocalBook _localTrack; private string _rootPath = @"C:\Test\Music\Artist".AsOsAgnostic(); [SetUp] public void Setup() { - _localTrack = new LocalTrack(); - _localTrack.Artist = new Author + _localTrack = new LocalBook(); + _localTrack.Author = new Author { Path = _rootPath }; @@ -53,7 +53,7 @@ namespace NzbDrone.Core.Test.MediaFiles private void GivenSingleTrackWithSingleTrackFile() { - _localTrack.Album = Builder.CreateNew() + _localTrack.Book = Builder.CreateNew() .With(e => e.BookFiles = new LazyLoaded>( new List { @@ -71,7 +71,7 @@ namespace NzbDrone.Core.Test.MediaFiles { GivenSingleTrackWithSingleTrackFile(); - Subject.UpgradeTrackFile(_trackFile, _localTrack); + Subject.UpgradeBookFile(_trackFile, _localTrack); Mocker.GetMock().Verify(v => v.DeleteFile(It.IsAny(), It.IsAny()), Times.Once()); } @@ -81,7 +81,7 @@ namespace NzbDrone.Core.Test.MediaFiles { GivenSingleTrackWithSingleTrackFile(); - Subject.UpgradeTrackFile(_trackFile, _localTrack); + Subject.UpgradeBookFile(_trackFile, _localTrack); Mocker.GetMock().Verify(v => v.Delete(It.IsAny(), DeleteMediaFileReason.Upgrade), Times.Once()); } @@ -95,7 +95,7 @@ namespace NzbDrone.Core.Test.MediaFiles .Setup(c => c.FileExists(It.IsAny())) .Returns(false); - Subject.UpgradeTrackFile(_trackFile, _localTrack); + Subject.UpgradeBookFile(_trackFile, _localTrack); // Mocker.GetMock().Verify(v => v.Delete(_localTrack.Album.BookFiles.Value, DeleteMediaFileReason.Upgrade), Times.Once()); } @@ -109,7 +109,7 @@ namespace NzbDrone.Core.Test.MediaFiles .Setup(c => c.FileExists(It.IsAny())) .Returns(false); - Subject.UpgradeTrackFile(_trackFile, _localTrack); + Subject.UpgradeBookFile(_trackFile, _localTrack); Mocker.GetMock().Verify(v => v.DeleteFile(It.IsAny(), It.IsAny()), Times.Never()); } @@ -119,18 +119,18 @@ namespace NzbDrone.Core.Test.MediaFiles { GivenSingleTrackWithSingleTrackFile(); - Subject.UpgradeTrackFile(_trackFile, _localTrack).OldFiles.Count.Should().Be(1); + Subject.UpgradeBookFile(_trackFile, _localTrack).OldFiles.Count.Should().Be(1); } [Test] [Ignore("Pending readarr fix")] public void should_import_if_existing_file_doesnt_exist_in_db() { - _localTrack.Album = Builder.CreateNew() + _localTrack.Book = Builder.CreateNew() .With(e => e.BookFiles = new LazyLoaded>()) .Build(); - Subject.UpgradeTrackFile(_trackFile, _localTrack); + Subject.UpgradeBookFile(_trackFile, _localTrack); // Mocker.GetMock().Verify(v => v.Delete(_localTrack.Album.BookFiles.Value, It.IsAny()), Times.Never()); } diff --git a/src/NzbDrone.Core.Test/Messaging/Commands/CommandEqualityComparerFixture.cs b/src/NzbDrone.Core.Test/Messaging/Commands/CommandEqualityComparerFixture.cs index fbe7e8357..7c1986bad 100644 --- a/src/NzbDrone.Core.Test/Messaging/Commands/CommandEqualityComparerFixture.cs +++ b/src/NzbDrone.Core.Test/Messaging/Commands/CommandEqualityComparerFixture.cs @@ -8,8 +8,8 @@ using NUnit.Framework; using NzbDrone.Common.Extensions; using NzbDrone.Core.Indexers; using NzbDrone.Core.IndexerSearch; +using NzbDrone.Core.MediaFiles.BookImport.Manual; using NzbDrone.Core.MediaFiles.Commands; -using NzbDrone.Core.MediaFiles.TrackImport.Manual; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Update.Commands; using NzbDrone.Test.Common; @@ -27,8 +27,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands [Test] public void should_return_true_when_there_are_no_properties() { - var command1 = new DownloadedAlbumsScanCommand(); - var command2 = new DownloadedAlbumsScanCommand(); + var command1 = new DownloadedBooksScanCommand(); + var command2 = new DownloadedBooksScanCommand(); CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeTrue(); } @@ -36,8 +36,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands [Test] public void should_return_true_when_single_property_matches() { - var command1 = new AlbumSearchCommand { BookIds = new List { 1 } }; - var command2 = new AlbumSearchCommand { BookIds = new List { 1 } }; + var command1 = new BookSearchCommand { BookIds = new List { 1 } }; + var command2 = new BookSearchCommand { BookIds = new List { 1 } }; CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeTrue(); } @@ -45,8 +45,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands [Test] public void should_return_false_when_single_property_doesnt_match() { - var command1 = new AlbumSearchCommand { BookIds = new List { 1 } }; - var command2 = new AlbumSearchCommand { BookIds = new List { 2 } }; + var command1 = new BookSearchCommand { BookIds = new List { 1 } }; + var command2 = new BookSearchCommand { BookIds = new List { 2 } }; CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse(); } @@ -54,8 +54,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands [Test] public void should_return_false_when_only_one_has_properties() { - var command1 = new ArtistSearchCommand(); - var command2 = new ArtistSearchCommand { AuthorId = 2 }; + var command1 = new AuthorSearchCommand(); + var command2 = new AuthorSearchCommand { AuthorId = 2 }; CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse(); } @@ -63,8 +63,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands [Test] public void should_return_false_when_only_one_has_null_property() { - var command1 = new AlbumSearchCommand(null); - var command2 = new AlbumSearchCommand(new List()); + var command1 = new BookSearchCommand(null); + var command2 = new BookSearchCommand(new List()); CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse(); } @@ -78,8 +78,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands [Test] public void should_return_false_when_commands_list_are_different_lengths() { - var command1 = new AlbumSearchCommand { BookIds = new List { 1 } }; - var command2 = new AlbumSearchCommand { BookIds = new List { 1, 2 } }; + var command1 = new BookSearchCommand { BookIds = new List { 1 } }; + var command2 = new BookSearchCommand { BookIds = new List { 1, 2 } }; CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse(); } @@ -87,8 +87,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands [Test] public void should_return_false_when_commands_list_dont_match() { - var command1 = new AlbumSearchCommand { BookIds = new List { 1 } }; - var command2 = new AlbumSearchCommand { BookIds = new List { 2 } }; + var command1 = new BookSearchCommand { BookIds = new List { 1 } }; + var command2 = new BookSearchCommand { BookIds = new List { 2 } }; CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse(); } diff --git a/src/NzbDrone.Core.Test/Messaging/Commands/CommandQueueFixture.cs b/src/NzbDrone.Core.Test/Messaging/Commands/CommandQueueFixture.cs index e7598a914..de095c129 100644 --- a/src/NzbDrone.Core.Test/Messaging/Commands/CommandQueueFixture.cs +++ b/src/NzbDrone.Core.Test/Messaging/Commands/CommandQueueFixture.cs @@ -1,10 +1,10 @@ using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books.Commands; using NzbDrone.Core.Download; using NzbDrone.Core.ImportLists; using NzbDrone.Core.Messaging.Commands; -using NzbDrone.Core.Music.Commands; using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Update.Commands; @@ -131,7 +131,7 @@ namespace NzbDrone.Core.Test.Messaging.Commands var newCommandModel = Builder .CreateNew() .With(c => c.Name = "RefreshArtist") - .With(c => c.Body = new RefreshArtistCommand()) + .With(c => c.Body = new RefreshAuthorCommand()) .Build(); Subject.Add(newCommandModel); @@ -168,7 +168,7 @@ namespace NzbDrone.Core.Test.Messaging.Commands var newCommandModel = Builder .CreateNew() .With(c => c.Name = "RefreshArtist") - .With(c => c.Body = new RefreshArtistCommand()) + .With(c => c.Body = new RefreshAuthorCommand()) .Build(); Subject.Add(newCommandModel); diff --git a/src/NzbDrone.Core.Test/MetadataSource/SearchArtistComparerFixture.cs b/src/NzbDrone.Core.Test/MetadataSource/SearchArtistComparerFixture.cs index 6c697c70b..44d2c053f 100644 --- a/src/NzbDrone.Core.Test/MetadataSource/SearchArtistComparerFixture.cs +++ b/src/NzbDrone.Core.Test/MetadataSource/SearchArtistComparerFixture.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Linq; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.MetadataSource; -using NzbDrone.Core.Music; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.MetadataSource @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.MetadataSource WithSeries("Talking Dead"); WithSeries("The Walking Dead"); - _artist.Sort(new SearchArtistComparer("the walking dead")); + _artist.Sort(new SearchAuthorComparer("the walking dead")); _artist.First().Name.Should().Be("The Walking Dead"); } @@ -41,7 +41,7 @@ namespace NzbDrone.Core.Test.MetadataSource WithSeries("Talking Dead"); WithSeries("The Walking Dead"); - _artist.Sort(new SearchArtistComparer("walking dead")); + _artist.Sort(new SearchAuthorComparer("walking dead")); _artist.First().Name.Should().Be("The Walking Dead"); } @@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.MetadataSource WithSeries("The Blacklist"); WithSeries("Blacklist"); - _artist.Sort(new SearchArtistComparer("blacklist")); + _artist.Sort(new SearchAuthorComparer("blacklist")); _artist.First().Name.Should().Be("Blacklist"); } @@ -63,7 +63,7 @@ namespace NzbDrone.Core.Test.MetadataSource WithSeries("Blacklist"); WithSeries("The Blacklist"); - _artist.Sort(new SearchArtistComparer("the blacklist")); + _artist.Sort(new SearchAuthorComparer("the blacklist")); _artist.First().Name.Should().Be("The Blacklist"); } diff --git a/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxyFixture.cs b/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxyFixture.cs index ea4d4a2dd..f9c43e952 100644 --- a/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxyFixture.cs +++ b/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxyFixture.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Exceptions; using NzbDrone.Core.MetadataSource.SkyHook; -using NzbDrone.Core.Music; using NzbDrone.Core.Profiles.Metadata; using NzbDrone.Core.Test.Framework; @@ -56,20 +56,20 @@ namespace NzbDrone.Core.Test.MetadataSource.SkyHook [Test] public void getting_details_of_invalid_artist() { - Assert.Throws(() => Subject.GetAuthorInfo("66c66aaa-6e2f-4930-8610-912e24c63ed1")); + Assert.Throws(() => Subject.GetAuthorInfo("66c66aaa-6e2f-4930-8610-912e24c63ed1")); } [Test] public void getting_details_of_invalid_album() { - Assert.Throws(() => Subject.GetBookInfo("66c66aaa-6e2f-4930-8610-912e24c63ed1")); + Assert.Throws(() => Subject.GetBookInfo("66c66aaa-6e2f-4930-8610-912e24c63ed1")); } private void ValidateAuthor(Author author) { author.Should().NotBeNull(); author.Name.Should().NotBeNullOrWhiteSpace(); - author.CleanName.Should().Be(Parser.Parser.CleanArtistName(author.Name)); + author.CleanName.Should().Be(Parser.Parser.CleanAuthorName(author.Name)); author.SortName.Should().Be(Parser.Parser.NormalizeTitle(author.Name)); author.Metadata.Value.TitleSlug.Should().NotBeNullOrWhiteSpace(); author.Metadata.Value.Overview.Should().NotBeNullOrWhiteSpace(); diff --git a/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxySearchFixture.cs b/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxySearchFixture.cs index 720f479f9..10263ebbc 100644 --- a/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxySearchFixture.cs +++ b/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxySearchFixture.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.MetadataSource.SkyHook; -using NzbDrone.Core.Music; using NzbDrone.Core.Profiles.Metadata; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; diff --git a/src/NzbDrone.Core.Test/MusicTests/AddAlbumFixture.cs b/src/NzbDrone.Core.Test/MusicTests/AddAlbumFixture.cs index 87629b9fc..bda0bd0a3 100644 --- a/src/NzbDrone.Core.Test/MusicTests/AddAlbumFixture.cs +++ b/src/NzbDrone.Core.Test/MusicTests/AddAlbumFixture.cs @@ -5,9 +5,9 @@ using FluentAssertions; using FluentValidation; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Exceptions; using NzbDrone.Core.MetadataSource; -using NzbDrone.Core.Music; using NzbDrone.Core.Organizer; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; @@ -15,7 +15,7 @@ using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MusicTests { [TestFixture] - public class AddAlbumFixture : CoreTest + public class AddAlbumFixture : CoreTest { private Author _fakeArtist; private Book _fakeAlbum; @@ -42,15 +42,15 @@ namespace NzbDrone.Core.Test.MusicTests _fakeAlbum, new List { _fakeArtist.Metadata.Value })); - Mocker.GetMock() - .Setup(s => s.AddArtist(It.IsAny(), It.IsAny())) + Mocker.GetMock() + .Setup(s => s.AddAuthor(It.IsAny(), It.IsAny())) .Returns(_fakeArtist); } private void GivenValidPath() { Mocker.GetMock() - .Setup(s => s.GetArtistFolder(It.IsAny(), null)) + .Setup(s => s.GetAuthorFolder(It.IsAny(), null)) .Returns((c, n) => c.Name); } @@ -74,7 +74,7 @@ namespace NzbDrone.Core.Test.MusicTests GivenValidAlbum(newAlbum.ForeignBookId); GivenValidPath(); - var album = Subject.AddAlbum(newAlbum); + var album = Subject.AddBook(newAlbum); album.Title.Should().Be(_fakeAlbum.Title); } @@ -86,9 +86,9 @@ namespace NzbDrone.Core.Test.MusicTests Mocker.GetMock() .Setup(s => s.GetBookInfo(newAlbum.ForeignBookId)) - .Throws(new AlbumNotFoundException(newAlbum.ForeignBookId)); + .Throws(new BookNotFoundException(newAlbum.ForeignBookId)); - Assert.Throws(() => Subject.AddAlbum(newAlbum)); + Assert.Throws(() => Subject.AddBook(newAlbum)); ExceptionVerification.ExpectedErrors(1); } diff --git a/src/NzbDrone.Core.Test/MusicTests/AddArtistFixture.cs b/src/NzbDrone.Core.Test/MusicTests/AddArtistFixture.cs index 1a8f60977..72b06199f 100644 --- a/src/NzbDrone.Core.Test/MusicTests/AddArtistFixture.cs +++ b/src/NzbDrone.Core.Test/MusicTests/AddArtistFixture.cs @@ -6,9 +6,9 @@ using FluentValidation; using FluentValidation.Results; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Exceptions; using NzbDrone.Core.MetadataSource; -using NzbDrone.Core.Music; using NzbDrone.Core.Organizer; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; @@ -40,10 +40,10 @@ namespace NzbDrone.Core.Test.MusicTests private void GivenValidPath() { Mocker.GetMock() - .Setup(s => s.GetArtistFolder(It.IsAny(), null)) + .Setup(s => s.GetAuthorFolder(It.IsAny(), null)) .Returns((c, n) => c.Name); - Mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Validate(It.IsAny())) .Returns(new ValidationResult()); } @@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.MusicTests GivenValidArtist(newArtist.ForeignAuthorId); GivenValidPath(); - var artist = Subject.AddArtist(newArtist); + var artist = Subject.AddAuthor(newArtist); artist.Name.Should().Be(_fakeArtist.Name); } @@ -77,7 +77,7 @@ namespace NzbDrone.Core.Test.MusicTests GivenValidArtist(newArtist.ForeignAuthorId); GivenValidPath(); - var artist = Subject.AddArtist(newArtist); + var artist = Subject.AddAuthor(newArtist); artist.Path.Should().Be(Path.Combine(newArtist.RootFolderPath, _fakeArtist.Name)); } @@ -93,14 +93,14 @@ namespace NzbDrone.Core.Test.MusicTests GivenValidArtist(newArtist.ForeignAuthorId); - Mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Validate(It.IsAny())) .Returns(new ValidationResult(new List { new ValidationFailure("Path", "Test validation failure") })); - Assert.Throws(() => Subject.AddArtist(newArtist)); + Assert.Throws(() => Subject.AddAuthor(newArtist)); } [Test] @@ -114,16 +114,16 @@ namespace NzbDrone.Core.Test.MusicTests Mocker.GetMock() .Setup(s => s.GetAuthorInfo(newArtist.ForeignAuthorId)) - .Throws(new ArtistNotFoundException(newArtist.ForeignAuthorId)); + .Throws(new AuthorNotFoundException(newArtist.ForeignAuthorId)); - Mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Validate(It.IsAny())) .Returns(new ValidationResult(new List { new ValidationFailure("Path", "Test validation failure") })); - Assert.Throws(() => Subject.AddArtist(newArtist)); + Assert.Throws(() => Subject.AddAuthor(newArtist)); ExceptionVerification.ExpectedErrors(1); } @@ -142,11 +142,11 @@ namespace NzbDrone.Core.Test.MusicTests GivenValidArtist(newArtist.ForeignAuthorId); GivenValidPath(); - Mocker.GetMock() - .Setup(x => x.ArtistPathExists(newArtist.Path)) + Mocker.GetMock() + .Setup(x => x.AuthorPathExists(newArtist.Path)) .Returns(true); - var artist = Subject.AddArtist(newArtist); + var artist = Subject.AddAuthor(newArtist); artist.Path.Should().Be(newArtist.Path + " (Disambiguation)"); } @@ -164,23 +164,23 @@ namespace NzbDrone.Core.Test.MusicTests GivenValidArtist(newArtist.ForeignAuthorId); GivenValidPath(); - Mocker.GetMock() - .Setup(x => x.ArtistPathExists(newArtist.Path)) + Mocker.GetMock() + .Setup(x => x.AuthorPathExists(newArtist.Path)) .Returns(true); - Mocker.GetMock() - .Setup(x => x.ArtistPathExists(newArtist.Path + " (Disambiguation)")) + Mocker.GetMock() + .Setup(x => x.AuthorPathExists(newArtist.Path + " (Disambiguation)")) .Returns(true); - Mocker.GetMock() - .Setup(x => x.ArtistPathExists(newArtist.Path + " (Disambiguation) (1)")) + Mocker.GetMock() + .Setup(x => x.AuthorPathExists(newArtist.Path + " (Disambiguation) (1)")) .Returns(true); - Mocker.GetMock() - .Setup(x => x.ArtistPathExists(newArtist.Path + " (Disambiguation) (2)")) + Mocker.GetMock() + .Setup(x => x.AuthorPathExists(newArtist.Path + " (Disambiguation) (2)")) .Returns(true); - var artist = Subject.AddArtist(newArtist); + var artist = Subject.AddAuthor(newArtist); artist.Path.Should().Be(newArtist.Path + " (Disambiguation) (3)"); } @@ -198,19 +198,19 @@ namespace NzbDrone.Core.Test.MusicTests GivenValidArtist(newArtist.ForeignAuthorId); GivenValidPath(); - Mocker.GetMock() - .Setup(x => x.ArtistPathExists(newArtist.Path)) + Mocker.GetMock() + .Setup(x => x.AuthorPathExists(newArtist.Path)) .Returns(true); - Mocker.GetMock() - .Setup(x => x.ArtistPathExists(newArtist.Path + " (1)")) + Mocker.GetMock() + .Setup(x => x.AuthorPathExists(newArtist.Path + " (1)")) .Returns(true); - Mocker.GetMock() - .Setup(x => x.ArtistPathExists(newArtist.Path + " (2)")) + Mocker.GetMock() + .Setup(x => x.AuthorPathExists(newArtist.Path + " (2)")) .Returns(true); - var artist = Subject.AddArtist(newArtist); + var artist = Subject.AddAuthor(newArtist); artist.Path.Should().Be(newArtist.Path + " (3)"); } } diff --git a/src/NzbDrone.Core.Test/MusicTests/AlbumMonitoredServiceTests/AlbumMonitoredServiceFixture.cs b/src/NzbDrone.Core.Test/MusicTests/AlbumMonitoredServiceTests/AlbumMonitoredServiceFixture.cs index 44438e2a4..33264851b 100644 --- a/src/NzbDrone.Core.Test/MusicTests/AlbumMonitoredServiceTests/AlbumMonitoredServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MusicTests/AlbumMonitoredServiceTests/AlbumMonitoredServiceFixture.cs @@ -5,13 +5,13 @@ using FizzWare.NBuilder; using Moq; using NUnit.Framework; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.MusicTests.AlbumMonitoredServiceTests { [TestFixture] - public class SetAlbumMontitoredFixture : CoreTest + public class SetAlbumMontitoredFixture : CoreTest { private Author _artist; private List _albums; @@ -39,24 +39,24 @@ namespace NzbDrone.Core.Test.MusicTests.AlbumMonitoredServiceTests .Build() .ToList(); - Mocker.GetMock() - .Setup(s => s.GetAlbumsByArtist(It.IsAny())) + Mocker.GetMock() + .Setup(s => s.GetBooksByAuthor(It.IsAny())) .Returns(_albums); - Mocker.GetMock() - .Setup(s => s.GetArtistAlbumsWithFiles(It.IsAny())) + Mocker.GetMock() + .Setup(s => s.GetAuthorBooksWithFiles(It.IsAny())) .Returns(new List()); } [Test] public void should_be_able_to_monitor_artist_without_changing_albums() { - Subject.SetAlbumMonitoredStatus(_artist, null); + Subject.SetBookMonitoredStatus(_artist, null); - Mocker.GetMock() - .Verify(v => v.UpdateArtist(It.IsAny()), Times.Once()); + Mocker.GetMock() + .Verify(v => v.UpdateAuthor(It.IsAny()), Times.Once()); - Mocker.GetMock() + Mocker.GetMock() .Verify(v => v.UpdateMany(It.IsAny>()), Times.Never()); } @@ -65,10 +65,10 @@ namespace NzbDrone.Core.Test.MusicTests.AlbumMonitoredServiceTests { var albumsToMonitor = new List { _albums.First().ForeignBookId }; - Subject.SetAlbumMonitoredStatus(_artist, new MonitoringOptions { Monitored = true, AlbumsToMonitor = albumsToMonitor }); + Subject.SetBookMonitoredStatus(_artist, new MonitoringOptions { Monitored = true, BooksToMonitor = albumsToMonitor }); - Mocker.GetMock() - .Verify(v => v.UpdateArtist(It.IsAny()), Times.Once()); + Mocker.GetMock() + .Verify(v => v.UpdateAuthor(It.IsAny()), Times.Once()); VerifyMonitored(e => e.ForeignBookId == _albums.First().ForeignBookId); VerifyNotMonitored(e => e.ForeignBookId != _albums.First().ForeignBookId); @@ -77,9 +77,9 @@ namespace NzbDrone.Core.Test.MusicTests.AlbumMonitoredServiceTests [Test] public void should_be_able_to_monitor_all_albums() { - Subject.SetAlbumMonitoredStatus(_artist, new MonitoringOptions { Monitor = MonitorTypes.All }); + Subject.SetBookMonitoredStatus(_artist, new MonitoringOptions { Monitor = MonitorTypes.All }); - Mocker.GetMock() + Mocker.GetMock() .Verify(v => v.UpdateMany(It.Is>(l => l.All(e => e.Monitored)))); } @@ -91,7 +91,7 @@ namespace NzbDrone.Core.Test.MusicTests.AlbumMonitoredServiceTests Monitor = MonitorTypes.Future }; - Subject.SetAlbumMonitoredStatus(_artist, monitoringOptions); + Subject.SetBookMonitoredStatus(_artist, monitoringOptions); VerifyMonitored(e => e.ReleaseDate.HasValue && e.ReleaseDate.Value.After(DateTime.UtcNow)); VerifyMonitored(e => !e.ReleaseDate.HasValue); @@ -100,13 +100,13 @@ namespace NzbDrone.Core.Test.MusicTests.AlbumMonitoredServiceTests private void VerifyMonitored(Func predicate) { - Mocker.GetMock() + Mocker.GetMock() .Verify(v => v.UpdateMany(It.Is>(l => l.Where(predicate).All(e => e.Monitored)))); } private void VerifyNotMonitored(Func predicate) { - Mocker.GetMock() + Mocker.GetMock() .Verify(v => v.UpdateMany(It.Is>(l => l.Where(predicate).All(e => !e.Monitored)))); } } diff --git a/src/NzbDrone.Core.Test/MusicTests/AlbumRepositoryTests/AlbumRepositoryFixture.cs b/src/NzbDrone.Core.Test/MusicTests/AlbumRepositoryTests/AlbumRepositoryFixture.cs index c47bd068d..f30aef238 100644 --- a/src/NzbDrone.Core.Test/MusicTests/AlbumRepositoryTests/AlbumRepositoryFixture.cs +++ b/src/NzbDrone.Core.Test/MusicTests/AlbumRepositoryTests/AlbumRepositoryFixture.cs @@ -4,19 +4,19 @@ using System.Linq; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.MusicTests.AlbumRepositoryTests { [TestFixture] - public class AlbumRepositoryFixture : DbTest + public class AlbumRepositoryFixture : DbTest { private Author _artist; private Book _album; private Book _albumSpecial; private List _albums; - private AlbumRepository _albumRepo; + private BookRepository _albumRepo; [SetUp] public void Setup() @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.MusicTests.AlbumRepositoryTests AuthorMetadataId = 1 }; - _albumRepo = Mocker.Resolve(); + _albumRepo = Mocker.Resolve(); _album = new Book { @@ -144,7 +144,7 @@ namespace NzbDrone.Core.Test.MusicTests.AlbumRepositoryTests { GivenMultipleAlbums(); - var result = _albumRepo.GetNextAlbums(new[] { _artist.AuthorMetadataId }); + var result = _albumRepo.GetNextBooks(new[] { _artist.AuthorMetadataId }); result.Should().BeEquivalentTo(_albums.Take(1)); } @@ -153,7 +153,7 @@ namespace NzbDrone.Core.Test.MusicTests.AlbumRepositoryTests { GivenMultipleAlbums(); - var result = _albumRepo.GetLastAlbums(new[] { _artist.AuthorMetadataId }); + var result = _albumRepo.GetLastBooks(new[] { _artist.AuthorMetadataId }); result.Should().BeEquivalentTo(_albums.Skip(2).Take(1)); } } diff --git a/src/NzbDrone.Core.Test/MusicTests/AlbumServiceFixture.cs b/src/NzbDrone.Core.Test/MusicTests/AlbumServiceFixture.cs index b4110059a..3bf08b866 100644 --- a/src/NzbDrone.Core.Test/MusicTests/AlbumServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MusicTests/AlbumServiceFixture.cs @@ -2,13 +2,13 @@ using System.Collections.Generic; using FluentAssertions; using Moq; using NUnit.Framework; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.MusicTests.AlbumRepositoryTests { [TestFixture] - public class AlbumServiceFixture : CoreTest + public class AlbumServiceFixture : CoreTest { private List _albums; @@ -28,8 +28,8 @@ namespace NzbDrone.Core.Test.MusicTests.AlbumRepositoryTests CleanTitle = "", }); - Mocker.GetMock() - .Setup(s => s.GetAlbumsByArtistMetadataId(It.IsAny())) + Mocker.GetMock() + .Setup(s => s.GetBooksByAuthorMetadataId(It.IsAny())) .Returns(_albums); } diff --git a/src/NzbDrone.Core.Test/MusicTests/ArtistMetadataRepositoryTests/ArtistMetadataRepositoryFixture.cs b/src/NzbDrone.Core.Test/MusicTests/ArtistMetadataRepositoryTests/ArtistMetadataRepositoryFixture.cs index c562f0069..c71dccc6c 100644 --- a/src/NzbDrone.Core.Test/MusicTests/ArtistMetadataRepositoryTests/ArtistMetadataRepositoryFixture.cs +++ b/src/NzbDrone.Core.Test/MusicTests/ArtistMetadataRepositoryTests/ArtistMetadataRepositoryFixture.cs @@ -4,22 +4,22 @@ using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.MusicTests.ArtistRepositoryTests { [TestFixture] - public class ArtistMetadataRepositoryFixture : DbTest + public class ArtistMetadataRepositoryFixture : DbTest { - private ArtistMetadataRepository _artistMetadataRepo; + private AuthorMetadataRepository _artistMetadataRepo; private List _metadataList; [SetUp] public void Setup() { - _artistMetadataRepo = Mocker.Resolve(); + _artistMetadataRepo = Mocker.Resolve(); _metadataList = Builder.CreateListOfSize(10).All().With(x => x.Id = 0).BuildList(); } diff --git a/src/NzbDrone.Core.Test/MusicTests/ArtistRepositoryTests/ArtistRepositoryFixture.cs b/src/NzbDrone.Core.Test/MusicTests/ArtistRepositoryTests/ArtistRepositoryFixture.cs index b9f71bcec..68df854b5 100644 --- a/src/NzbDrone.Core.Test/MusicTests/ArtistRepositoryTests/ArtistRepositoryFixture.cs +++ b/src/NzbDrone.Core.Test/MusicTests/ArtistRepositoryTests/ArtistRepositoryFixture.cs @@ -5,7 +5,7 @@ using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Profiles.Metadata; using NzbDrone.Core.Profiles.Qualities; using NzbDrone.Core.Qualities; @@ -15,16 +15,16 @@ namespace NzbDrone.Core.Test.MusicTests.ArtistRepositoryTests { [TestFixture] - public class ArtistRepositoryFixture : DbTest + public class ArtistRepositoryFixture : DbTest { - private ArtistRepository _artistRepo; - private ArtistMetadataRepository _artistMetadataRepo; + private AuthorRepository _artistRepo; + private AuthorMetadataRepository _artistMetadataRepo; [SetUp] public void Setup() { - _artistRepo = Mocker.Resolve(); - _artistMetadataRepo = Mocker.Resolve(); + _artistRepo = Mocker.Resolve(); + _artistMetadataRepo = Mocker.Resolve(); } private void AddArtist(string name, string foreignId, List oldIds = null) @@ -43,7 +43,7 @@ namespace NzbDrone.Core.Test.MusicTests.ArtistRepositoryTests var artist = Builder.CreateNew() .With(a => a.Id = 0) .With(a => a.Metadata = metadata) - .With(a => a.CleanName = Parser.Parser.CleanArtistName(name)) + .With(a => a.CleanName = Parser.Parser.CleanAuthorName(name)) .With(a => a.ForeignAuthorId = foreignId) .BuildNew(); @@ -92,7 +92,7 @@ namespace NzbDrone.Core.Test.MusicTests.ArtistRepositoryTests public void should_find_artist_in_db_by_name(string name) { GivenArtists(); - var artist = _artistRepo.FindByName(Parser.Parser.CleanArtistName(name)); + var artist = _artistRepo.FindByName(Parser.Parser.CleanAuthorName(name)); artist.Should().NotBeNull(); artist.Name.Should().Be(name); @@ -119,7 +119,7 @@ namespace NzbDrone.Core.Test.MusicTests.ArtistRepositoryTests _artistRepo.All().Should().HaveCount(4); - var artist = _artistRepo.FindByName(Parser.Parser.CleanArtistName(name)); + var artist = _artistRepo.FindByName(Parser.Parser.CleanAuthorName(name)); artist.Should().BeNull(); } @@ -135,7 +135,7 @@ namespace NzbDrone.Core.Test.MusicTests.ArtistRepositoryTests var artist1 = Builder.CreateNew() .With(a => a.Id = 0) .With(a => a.Metadata = metadata) - .With(a => a.CleanName = Parser.Parser.CleanArtistName(name)) + .With(a => a.CleanName = Parser.Parser.CleanAuthorName(name)) .BuildNew(); var artist2 = artist1.JsonClone(); diff --git a/src/NzbDrone.Core.Test/MusicTests/ArtistServiceTests/FindByNameInexactFixture.cs b/src/NzbDrone.Core.Test/MusicTests/ArtistServiceTests/FindByNameInexactFixture.cs index 072d38394..fca328d64 100644 --- a/src/NzbDrone.Core.Test/MusicTests/ArtistServiceTests/FindByNameInexactFixture.cs +++ b/src/NzbDrone.Core.Test/MusicTests/ArtistServiceTests/FindByNameInexactFixture.cs @@ -2,14 +2,14 @@ using System.Collections.Generic; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.MusicTests.ArtistServiceTests { [TestFixture] - public class FindByNameInexactFixture : CoreTest + public class FindByNameInexactFixture : CoreTest { private List _artists; @@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.MusicTests.ArtistServiceTests { return Builder.CreateNew() .With(a => a.Name = name) - .With(a => a.CleanName = Parser.Parser.CleanArtistName(name)) + .With(a => a.CleanName = Parser.Parser.CleanAuthorName(name)) .With(a => a.ForeignAuthorId = name) .BuildNew(); } @@ -29,7 +29,7 @@ namespace NzbDrone.Core.Test.MusicTests.ArtistServiceTests _artists.Add(CreateArtist("The Black Eyed Peas")); _artists.Add(CreateArtist("The Black Keys")); - Mocker.GetMock() + Mocker.GetMock() .Setup(s => s.All()) .Returns(_artists); } @@ -53,7 +53,7 @@ namespace NzbDrone.Core.Test.MusicTests.ArtistServiceTests _artists.Add(CreateArtist("Black Keys")); _artists.Add(CreateArtist("The Black Eyed Peas")); - Mocker.GetMock() + Mocker.GetMock() .Setup(s => s.All()) .Returns(_artists); diff --git a/src/NzbDrone.Core.Test/MusicTests/ArtistServiceTests/UpdateMultipleArtistFixture.cs b/src/NzbDrone.Core.Test/MusicTests/ArtistServiceTests/UpdateMultipleArtistFixture.cs index c3c4da498..985f520cc 100644 --- a/src/NzbDrone.Core.Test/MusicTests/ArtistServiceTests/UpdateMultipleArtistFixture.cs +++ b/src/NzbDrone.Core.Test/MusicTests/ArtistServiceTests/UpdateMultipleArtistFixture.cs @@ -5,7 +5,7 @@ using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Organizer; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; @@ -13,7 +13,7 @@ using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MusicTests.ArtistServiceTests { [TestFixture] - public class UpdateMultipleArtistFixture : CoreTest + public class UpdateMultipleArtistFixture : CoreTest { private List _artists; @@ -32,32 +32,32 @@ namespace NzbDrone.Core.Test.MusicTests.ArtistServiceTests [Test] public void should_call_repo_updateMany() { - Subject.UpdateArtists(_artists, false); + Subject.UpdateAuthors(_artists, false); - Mocker.GetMock().Verify(v => v.UpdateMany(_artists), Times.Once()); + Mocker.GetMock().Verify(v => v.UpdateMany(_artists), Times.Once()); } [Test] public void should_update_path_when_rootFolderPath_is_supplied() { Mocker.GetMock() - .Setup(s => s.GetArtistFolder(It.IsAny(), null)) + .Setup(s => s.GetAuthorFolder(It.IsAny(), null)) .Returns((c, n) => c.Name); var newRoot = @"C:\Test\Music2".AsOsAgnostic(); _artists.ForEach(s => s.RootFolderPath = newRoot); - Mocker.GetMock() + Mocker.GetMock() .Setup(s => s.BuildPath(It.IsAny(), false)) .Returns((s, u) => Path.Combine(s.RootFolderPath, s.Name)); - Subject.UpdateArtists(_artists, false).ForEach(s => s.Path.Should().StartWith(newRoot)); + Subject.UpdateAuthors(_artists, false).ForEach(s => s.Path.Should().StartWith(newRoot)); } [Test] public void should_not_update_path_when_rootFolderPath_is_empty() { - Subject.UpdateArtists(_artists, false).ForEach(s => + Subject.UpdateAuthors(_artists, false).ForEach(s => { var expectedPath = _artists.Single(ser => ser.Id == s.Id).Path; s.Path.Should().Be(expectedPath); @@ -74,13 +74,13 @@ namespace NzbDrone.Core.Test.MusicTests.ArtistServiceTests .ToList(); Mocker.GetMock() - .Setup(s => s.GetArtistFolder(It.IsAny(), null)) + .Setup(s => s.GetAuthorFolder(It.IsAny(), null)) .Returns((c, n) => c.Name); var newRoot = @"C:\Test\Music2".AsOsAgnostic(); artist.ForEach(s => s.RootFolderPath = newRoot); - Subject.UpdateArtists(artist, false); + Subject.UpdateAuthors(artist, false); } } } diff --git a/src/NzbDrone.Core.Test/MusicTests/EntityFixture.cs b/src/NzbDrone.Core.Test/MusicTests/EntityFixture.cs index bdc02a4af..2183ff4a2 100644 --- a/src/NzbDrone.Core.Test/MusicTests/EntityFixture.cs +++ b/src/NzbDrone.Core.Test/MusicTests/EntityFixture.cs @@ -6,8 +6,8 @@ using Equ; using FluentAssertions; using NUnit.Framework; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; -using NzbDrone.Core.Music; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MusicTests diff --git a/src/NzbDrone.Core.Test/MusicTests/MoveArtistServiceFixture.cs b/src/NzbDrone.Core.Test/MusicTests/MoveArtistServiceFixture.cs index fdcd0c3c6..adfe1eea8 100644 --- a/src/NzbDrone.Core.Test/MusicTests/MoveArtistServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MusicTests/MoveArtistServiceFixture.cs @@ -5,8 +5,8 @@ using FizzWare.NBuilder; using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; -using NzbDrone.Core.Music; -using NzbDrone.Core.Music.Commands; +using NzbDrone.Core.Books; +using NzbDrone.Core.Books.Commands; using NzbDrone.Core.Organizer; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; @@ -14,11 +14,11 @@ using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MusicTests { [TestFixture] - public class MoveArtistServiceFixture : CoreTest + public class MoveArtistServiceFixture : CoreTest { private Author _artist; - private MoveArtistCommand _command; - private BulkMoveArtistCommand _bulkCommand; + private MoveAuthorCommand _command; + private BulkMoveAuthorCommand _bulkCommand; [SetUp] public void Setup() @@ -27,18 +27,18 @@ namespace NzbDrone.Core.Test.MusicTests .CreateNew() .Build(); - _command = new MoveArtistCommand + _command = new MoveAuthorCommand { AuthorId = 1, SourcePath = @"C:\Test\Music\Artist".AsOsAgnostic(), DestinationPath = @"C:\Test\Music2\Artist".AsOsAgnostic() }; - _bulkCommand = new BulkMoveArtistCommand + _bulkCommand = new BulkMoveAuthorCommand { - Artist = new List + Author = new List { - new BulkMoveArtist + new BulkMoveAuthor { AuthorId = 1, SourcePath = @"C:\Test\Music\Artist".AsOsAgnostic() @@ -47,8 +47,8 @@ namespace NzbDrone.Core.Test.MusicTests DestinationRootFolder = @"C:\Test\Music2".AsOsAgnostic() }; - Mocker.GetMock() - .Setup(s => s.GetArtist(It.IsAny())) + Mocker.GetMock() + .Setup(s => s.GetAuthor(It.IsAny())) .Returns(_artist); Mocker.GetMock() @@ -82,8 +82,8 @@ namespace NzbDrone.Core.Test.MusicTests ExceptionVerification.ExpectedErrors(1); - Mocker.GetMock() - .Verify(v => v.UpdateArtist(It.IsAny()), Times.Once()); + Mocker.GetMock() + .Verify(v => v.UpdateAuthor(It.IsAny()), Times.Once()); } [Test] @@ -100,7 +100,7 @@ namespace NzbDrone.Core.Test.MusicTests Times.Once()); Mocker.GetMock() - .Verify(v => v.GetArtistFolder(It.IsAny(), null), Times.Never()); + .Verify(v => v.GetAuthorFolder(It.IsAny(), null), Times.Never()); } [Test] @@ -110,14 +110,14 @@ namespace NzbDrone.Core.Test.MusicTests var expectedPath = Path.Combine(_bulkCommand.DestinationRootFolder, artistFolder); Mocker.GetMock() - .Setup(s => s.GetArtistFolder(It.IsAny(), null)) + .Setup(s => s.GetAuthorFolder(It.IsAny(), null)) .Returns(artistFolder); Subject.Execute(_bulkCommand); Mocker.GetMock() .Verify( - v => v.TransferFolder(_bulkCommand.Artist.First().SourcePath, + v => v.TransferFolder(_bulkCommand.Author.First().SourcePath, expectedPath, TransferMode.Move, It.IsAny()), @@ -141,7 +141,7 @@ namespace NzbDrone.Core.Test.MusicTests It.IsAny()), Times.Never()); Mocker.GetMock() - .Verify(v => v.GetArtistFolder(It.IsAny(), null), Times.Never()); + .Verify(v => v.GetAuthorFolder(It.IsAny(), null), Times.Never()); } } } diff --git a/src/NzbDrone.Core.Test/MusicTests/RefreshAlbumServiceFixture.cs b/src/NzbDrone.Core.Test/MusicTests/RefreshAlbumServiceFixture.cs index cbe2b07f0..251009287 100644 --- a/src/NzbDrone.Core.Test/MusicTests/RefreshAlbumServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MusicTests/RefreshAlbumServiceFixture.cs @@ -5,18 +5,18 @@ using FizzWare.NBuilder; using Moq; using NUnit.Framework; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.Exceptions; using NzbDrone.Core.History; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MetadataSource; -using NzbDrone.Core.Music; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MusicTests { [TestFixture] - public class RefreshAlbumServiceFixture : CoreTest + public class RefreshAlbumServiceFixture : CoreTest { private Author _artist; private List _albums; @@ -36,28 +36,28 @@ namespace NzbDrone.Core.Test.MusicTests .With(s => s.Books = _albums) .Build(); - Mocker.GetMock() - .Setup(s => s.GetArtist(_artist.Id)) + Mocker.GetMock() + .Setup(s => s.GetAuthor(_artist.Id)) .Returns(_artist); - Mocker.GetMock() + Mocker.GetMock() .Setup(s => s.UpsertMany(It.IsAny>())) .Returns(true); Mocker.GetMock() .Setup(s => s.GetBookInfo(It.IsAny())) - .Callback(() => { throw new AlbumNotFoundException(album1.ForeignBookId); }); + .Callback(() => { throw new BookNotFoundException(album1.ForeignBookId); }); - Mocker.GetMock() + Mocker.GetMock() .Setup(s => s.ShouldRefresh(It.IsAny())) .Returns(true); Mocker.GetMock() - .Setup(x => x.GetFilesByAlbum(It.IsAny())) + .Setup(x => x.GetFilesByBook(It.IsAny())) .Returns(new List()); Mocker.GetMock() - .Setup(x => x.GetByAlbum(It.IsAny(), It.IsAny())) + .Setup(x => x.GetByBook(It.IsAny(), It.IsAny())) .Returns(new List()); } @@ -68,9 +68,9 @@ namespace NzbDrone.Core.Test.MusicTests newAlbumInfo.AuthorMetadata = _albums.First().AuthorMetadata.Value.JsonClone(); newAlbumInfo.ForeignBookId = _albums.First().ForeignBookId + 1; - Subject.RefreshAlbumInfo(_albums, new List { newAlbumInfo }, null, false, false, null); + Subject.RefreshBookInfo(_albums, new List { newAlbumInfo }, null, false, false, null); - Mocker.GetMock() + Mocker.GetMock() .Verify(v => v.UpdateMany(It.Is>(s => s.First().ForeignBookId == newAlbumInfo.ForeignBookId))); } @@ -84,7 +84,7 @@ namespace NzbDrone.Core.Test.MusicTests clash.AuthorMetadata = existing.AuthorMetadata.Value.JsonClone(); clash.ForeignBookId += 1; - Mocker.GetMock() + Mocker.GetMock() .Setup(x => x.FindById(clash.ForeignBookId)) .Returns(clash); @@ -92,14 +92,14 @@ namespace NzbDrone.Core.Test.MusicTests newAlbumInfo.AuthorMetadata = existing.AuthorMetadata.Value.JsonClone(); newAlbumInfo.ForeignBookId = _albums.First().ForeignBookId + 1; - Subject.RefreshAlbumInfo(_albums, new List { newAlbumInfo }, null, false, false, null); + Subject.RefreshBookInfo(_albums, new List { newAlbumInfo }, null, false, false, null); // check old album is deleted - Mocker.GetMock() + Mocker.GetMock() .Verify(v => v.DeleteMany(It.Is>(x => x.First().ForeignBookId == existing.ForeignBookId))); // check that clash gets updated - Mocker.GetMock() + Mocker.GetMock() .Verify(v => v.UpdateMany(It.Is>(s => s.First().ForeignBookId == newAlbumInfo.ForeignBookId))); ExceptionVerification.ExpectedWarns(1); diff --git a/src/NzbDrone.Core.Test/MusicTests/RefreshArtistServiceFixture.cs b/src/NzbDrone.Core.Test/MusicTests/RefreshArtistServiceFixture.cs index f08d89726..33d59c3bc 100644 --- a/src/NzbDrone.Core.Test/MusicTests/RefreshArtistServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MusicTests/RefreshArtistServiceFixture.cs @@ -3,14 +3,14 @@ using FizzWare.NBuilder; using Moq; using NUnit.Framework; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; +using NzbDrone.Core.Books.Commands; +using NzbDrone.Core.Books.Events; using NzbDrone.Core.Exceptions; using NzbDrone.Core.History; using NzbDrone.Core.ImportLists.Exclusions; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MetadataSource; -using NzbDrone.Core.Music; -using NzbDrone.Core.Music.Commands; -using NzbDrone.Core.Music.Events; using NzbDrone.Core.Profiles.Metadata; using NzbDrone.Core.RootFolders; using NzbDrone.Core.Test.Framework; @@ -19,7 +19,7 @@ using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MusicTests { [TestFixture] - public class RefreshArtistServiceFixture : CoreTest + public class RefreshArtistServiceFixture : CoreTest { private Author _artist; private Book _album1; @@ -51,11 +51,11 @@ namespace NzbDrone.Core.Test.MusicTests .With(a => a.Series = series) .Build(); - Mocker.GetMock(MockBehavior.Strict) - .Setup(s => s.GetArtists(new List { _artist.Id })) + Mocker.GetMock(MockBehavior.Strict) + .Setup(s => s.GetAuthors(new List { _artist.Id })) .Returns(new List { _artist }); - Mocker.GetMock(MockBehavior.Strict) + Mocker.GetMock(MockBehavior.Strict) .Setup(s => s.InsertMany(It.IsAny>())); Mocker.GetMock() @@ -64,14 +64,14 @@ namespace NzbDrone.Core.Test.MusicTests Mocker.GetMock() .Setup(s => s.GetAuthorInfo(It.IsAny())) - .Callback(() => { throw new ArtistNotFoundException(_artist.ForeignAuthorId); }); + .Callback(() => { throw new AuthorNotFoundException(_artist.ForeignAuthorId); }); Mocker.GetMock() - .Setup(x => x.GetFilesByArtist(It.IsAny())) + .Setup(x => x.GetFilesByAuthor(It.IsAny())) .Returns(new List()); Mocker.GetMock() - .Setup(x => x.GetByArtist(It.IsAny(), It.IsAny())) + .Setup(x => x.GetByAuthor(It.IsAny(), It.IsAny())) .Returns(new List()); Mocker.GetMock() @@ -93,21 +93,21 @@ namespace NzbDrone.Core.Test.MusicTests private void GivenArtistFiles() { Mocker.GetMock() - .Setup(x => x.GetFilesByArtist(It.IsAny())) + .Setup(x => x.GetFilesByAuthor(It.IsAny())) .Returns(Builder.CreateListOfSize(1).BuildList()); } private void GivenAlbumsForRefresh(List albums) { - Mocker.GetMock(MockBehavior.Strict) - .Setup(s => s.GetAlbumsForRefresh(It.IsAny(), It.IsAny>())) + Mocker.GetMock(MockBehavior.Strict) + .Setup(s => s.GetBooksForRefresh(It.IsAny(), It.IsAny>())) .Returns(albums); } private void AllowArtistUpdate() { - Mocker.GetMock(MockBehavior.Strict) - .Setup(x => x.UpdateArtist(It.IsAny())) + Mocker.GetMock(MockBehavior.Strict) + .Setup(x => x.UpdateAuthor(It.IsAny())) .Returns((Author a) => a); } @@ -122,10 +122,10 @@ namespace NzbDrone.Core.Test.MusicTests GivenAlbumsForRefresh(_albums); AllowArtistUpdate(); - Subject.Execute(new RefreshArtistCommand(_artist.Id)); + Subject.Execute(new RefreshAuthorCommand(_artist.Id)); - VerifyEventNotPublished(); - VerifyEventPublished(); + VerifyEventNotPublished(); + VerifyEventPublished(); } [Test] @@ -143,25 +143,25 @@ namespace NzbDrone.Core.Test.MusicTests GivenAlbumsForRefresh(new List()); AllowArtistUpdate(); - Subject.Execute(new RefreshArtistCommand(_artist.Id)); + Subject.Execute(new RefreshAuthorCommand(_artist.Id)); - VerifyEventPublished(); - VerifyEventPublished(); + VerifyEventPublished(); + VerifyEventPublished(); } [Test] public void should_log_error_and_delete_if_musicbrainz_id_not_found_and_artist_has_no_files() { - Mocker.GetMock() - .Setup(x => x.DeleteArtist(It.IsAny(), It.IsAny(), It.IsAny())); + Mocker.GetMock() + .Setup(x => x.DeleteAuthor(It.IsAny(), It.IsAny(), It.IsAny())); - Subject.Execute(new RefreshArtistCommand(_artist.Id)); + Subject.Execute(new RefreshAuthorCommand(_artist.Id)); - Mocker.GetMock() - .Verify(v => v.UpdateArtist(It.IsAny()), Times.Never()); + Mocker.GetMock() + .Verify(v => v.UpdateAuthor(It.IsAny()), Times.Never()); - Mocker.GetMock() - .Verify(v => v.DeleteArtist(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once()); + Mocker.GetMock() + .Verify(v => v.DeleteAuthor(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once()); ExceptionVerification.ExpectedErrors(1); ExceptionVerification.ExpectedWarns(1); @@ -173,13 +173,13 @@ namespace NzbDrone.Core.Test.MusicTests GivenArtistFiles(); GivenAlbumsForRefresh(new List()); - Subject.Execute(new RefreshArtistCommand(_artist.Id)); + Subject.Execute(new RefreshAuthorCommand(_artist.Id)); - Mocker.GetMock() - .Verify(v => v.UpdateArtist(It.IsAny()), Times.Never()); + Mocker.GetMock() + .Verify(v => v.UpdateAuthor(It.IsAny()), Times.Never()); - Mocker.GetMock() - .Verify(v => v.DeleteArtist(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); + Mocker.GetMock() + .Verify(v => v.DeleteAuthor(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); ExceptionVerification.ExpectedErrors(2); } @@ -197,31 +197,31 @@ namespace NzbDrone.Core.Test.MusicTests var seq = new MockSequence(); - Mocker.GetMock(MockBehavior.Strict) + Mocker.GetMock(MockBehavior.Strict) .Setup(x => x.FindById(newArtistInfo.ForeignAuthorId)) .Returns(default(Author)); // Make sure that the artist is updated before we refresh the albums - Mocker.GetMock(MockBehavior.Strict) + Mocker.GetMock(MockBehavior.Strict) .InSequence(seq) - .Setup(x => x.UpdateArtist(It.IsAny())) + .Setup(x => x.UpdateAuthor(It.IsAny())) .Returns((Author a) => a); - Mocker.GetMock(MockBehavior.Strict) + Mocker.GetMock(MockBehavior.Strict) .InSequence(seq) - .Setup(x => x.GetAlbumsForRefresh(It.IsAny(), It.IsAny>())) + .Setup(x => x.GetBooksForRefresh(It.IsAny(), It.IsAny>())) .Returns(new List()); // Update called twice for a move/merge - Mocker.GetMock(MockBehavior.Strict) + Mocker.GetMock(MockBehavior.Strict) .InSequence(seq) - .Setup(x => x.UpdateArtist(It.IsAny())) + .Setup(x => x.UpdateAuthor(It.IsAny())) .Returns((Author a) => a); - Subject.Execute(new RefreshArtistCommand(_artist.Id)); + Subject.Execute(new RefreshAuthorCommand(_artist.Id)); - Mocker.GetMock() - .Verify(v => v.UpdateArtist(It.Is(s => s.AuthorMetadataId == 100 && s.ForeignAuthorId == newArtistInfo.ForeignAuthorId)), + Mocker.GetMock() + .Verify(v => v.UpdateAuthor(It.Is(s => s.AuthorMetadataId == 100 && s.ForeignAuthorId == newArtistInfo.ForeignAuthorId)), Times.Exactly(2)); } @@ -236,7 +236,7 @@ namespace NzbDrone.Core.Test.MusicTests clash.Metadata.Value.Id = 101; clash.Metadata.Value.ForeignAuthorId = clash.Metadata.Value.ForeignAuthorId + 1; - Mocker.GetMock(MockBehavior.Strict) + Mocker.GetMock(MockBehavior.Strict) .Setup(x => x.FindById(clash.Metadata.Value.ForeignAuthorId)) .Returns(clash); @@ -249,46 +249,46 @@ namespace NzbDrone.Core.Test.MusicTests var seq = new MockSequence(); // Make sure that the artist is updated before we refresh the albums - Mocker.GetMock(MockBehavior.Strict) + Mocker.GetMock(MockBehavior.Strict) .InSequence(seq) - .Setup(x => x.GetAlbumsByArtist(existing.Id)) + .Setup(x => x.GetBooksByAuthor(existing.Id)) .Returns(_albums); - Mocker.GetMock(MockBehavior.Strict) + Mocker.GetMock(MockBehavior.Strict) .InSequence(seq) .Setup(x => x.UpdateMany(It.IsAny>())); - Mocker.GetMock(MockBehavior.Strict) + Mocker.GetMock(MockBehavior.Strict) .InSequence(seq) - .Setup(x => x.DeleteArtist(existing.Id, It.IsAny(), false)); + .Setup(x => x.DeleteAuthor(existing.Id, It.IsAny(), false)); - Mocker.GetMock(MockBehavior.Strict) + Mocker.GetMock(MockBehavior.Strict) .InSequence(seq) - .Setup(x => x.UpdateArtist(It.Is(a => a.Id == clash.Id))) + .Setup(x => x.UpdateAuthor(It.Is(a => a.Id == clash.Id))) .Returns((Author a) => a); - Mocker.GetMock(MockBehavior.Strict) + Mocker.GetMock(MockBehavior.Strict) .InSequence(seq) - .Setup(x => x.GetAlbumsForRefresh(clash.AuthorMetadataId, It.IsAny>())) + .Setup(x => x.GetBooksForRefresh(clash.AuthorMetadataId, It.IsAny>())) .Returns(_albums); // Update called twice for a move/merge - Mocker.GetMock(MockBehavior.Strict) + Mocker.GetMock(MockBehavior.Strict) .InSequence(seq) - .Setup(x => x.UpdateArtist(It.IsAny())) + .Setup(x => x.UpdateAuthor(It.IsAny())) .Returns((Author a) => a); - Subject.Execute(new RefreshArtistCommand(_artist.Id)); + Subject.Execute(new RefreshAuthorCommand(_artist.Id)); // the retained artist gets updated - Mocker.GetMock() - .Verify(v => v.UpdateArtist(It.Is(s => s.Id == clash.Id)), Times.Exactly(2)); + Mocker.GetMock() + .Verify(v => v.UpdateAuthor(It.Is(s => s.Id == clash.Id)), Times.Exactly(2)); // the old one gets removed - Mocker.GetMock() - .Verify(v => v.DeleteArtist(existing.Id, false, false)); + Mocker.GetMock() + .Verify(v => v.DeleteAuthor(existing.Id, false, false)); - Mocker.GetMock() + Mocker.GetMock() .Verify(v => v.UpdateMany(It.Is>(x => x.Count == _albums.Count))); ExceptionVerification.ExpectedWarns(1); diff --git a/src/NzbDrone.Core.Test/MusicTests/ShouldRefreshAlbumFixture.cs b/src/NzbDrone.Core.Test/MusicTests/ShouldRefreshAlbumFixture.cs index dde9dd1f6..0e11fb218 100644 --- a/src/NzbDrone.Core.Test/MusicTests/ShouldRefreshAlbumFixture.cs +++ b/src/NzbDrone.Core.Test/MusicTests/ShouldRefreshAlbumFixture.cs @@ -2,13 +2,13 @@ using System; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MusicTests { [TestFixture] - public class ShouldRefreshAlbumFixture : TestBase + public class ShouldRefreshAlbumFixture : TestBase { private Book _album; diff --git a/src/NzbDrone.Core.Test/MusicTests/ShouldRefreshArtistFixture.cs b/src/NzbDrone.Core.Test/MusicTests/ShouldRefreshArtistFixture.cs index d83b967b8..7f9352206 100644 --- a/src/NzbDrone.Core.Test/MusicTests/ShouldRefreshArtistFixture.cs +++ b/src/NzbDrone.Core.Test/MusicTests/ShouldRefreshArtistFixture.cs @@ -3,13 +3,13 @@ using System.Linq; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MusicTests { [TestFixture] - public class ShouldRefreshArtistFixture : TestBase + public class ShouldRefreshArtistFixture : TestBase { private Author _artist; @@ -17,11 +17,11 @@ namespace NzbDrone.Core.Test.MusicTests public void Setup() { _artist = Builder.CreateNew() - .With(v => v.Metadata.Value.Status == ArtistStatusType.Continuing) + .With(v => v.Metadata.Value.Status == AuthorStatusType.Continuing) .Build(); - Mocker.GetMock() - .Setup(s => s.GetAlbumsByArtist(_artist.Id)) + Mocker.GetMock() + .Setup(s => s.GetBooksByAuthor(_artist.Id)) .Returns(Builder.CreateListOfSize(2) .All() .With(e => e.ReleaseDate = DateTime.Today.AddDays(-100)) @@ -31,7 +31,7 @@ namespace NzbDrone.Core.Test.MusicTests private void GivenArtistIsEnded() { - _artist.Metadata.Value.Status = ArtistStatusType.Ended; + _artist.Metadata.Value.Status = AuthorStatusType.Ended; } private void GivenArtistLastRefreshedMonthsAgo() @@ -56,8 +56,8 @@ namespace NzbDrone.Core.Test.MusicTests private void GivenRecentlyAired() { - Mocker.GetMock() - .Setup(s => s.GetAlbumsByArtist(_artist.Id)) + Mocker.GetMock() + .Setup(s => s.GetBooksByAuthor(_artist.Id)) .Returns(Builder.CreateListOfSize(2) .TheFirst(1) .With(e => e.ReleaseDate = DateTime.Today.AddDays(-7)) diff --git a/src/NzbDrone.Core.Test/NotificationTests/NotificationBaseFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/NotificationBaseFixture.cs index 7a207c1cc..bb7bba1a8 100644 --- a/src/NzbDrone.Core.Test/NotificationTests/NotificationBaseFixture.cs +++ b/src/NzbDrone.Core.Test/NotificationTests/NotificationBaseFixture.cs @@ -2,7 +2,7 @@ using System; using FluentAssertions; using FluentValidation.Results; using NUnit.Framework; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Notifications; using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.Validation; @@ -31,7 +31,7 @@ namespace NzbDrone.Core.Test.NotificationTests throw new NotImplementedException(); } - public override void OnReleaseImport(AlbumDownloadMessage message) + public override void OnReleaseImport(BookDownloadMessage message) { TestLogger.Info("OnDownload was called"); } @@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.NotificationTests TestLogger.Info("OnGrab was called"); } - public override void OnReleaseImport(AlbumDownloadMessage message) + public override void OnReleaseImport(BookDownloadMessage message) { TestLogger.Info("OnAlbumDownload was called"); } @@ -72,12 +72,12 @@ namespace NzbDrone.Core.Test.NotificationTests TestLogger.Info("OnDownloadFailure was called"); } - public override void OnImportFailure(AlbumDownloadMessage message) + public override void OnImportFailure(BookDownloadMessage message) { TestLogger.Info("OnImportFailure was called"); } - public override void OnTrackRetag(TrackRetagMessage message) + public override void OnTrackRetag(BookRetagMessage message) { TestLogger.Info("OnTrackRetag was called"); } diff --git a/src/NzbDrone.Core.Test/NotificationTests/SynologyIndexerFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/SynologyIndexerFixture.cs index 3db6af3c2..86fc1c506 100644 --- a/src/NzbDrone.Core.Test/NotificationTests/SynologyIndexerFixture.cs +++ b/src/NzbDrone.Core.Test/NotificationTests/SynologyIndexerFixture.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.IO; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Notifications; using NzbDrone.Core.Notifications.Synology; using NzbDrone.Core.Test.Framework; @@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.NotificationTests public class SynologyIndexerFixture : CoreTest { private Author _artist; - private AlbumDownloadMessage _upgrade; + private BookDownloadMessage _upgrade; private string _rootPath = @"C:\Test\".AsOsAgnostic(); [SetUp] @@ -26,11 +26,11 @@ namespace NzbDrone.Core.Test.NotificationTests Path = _rootPath, }; - _upgrade = new AlbumDownloadMessage() + _upgrade = new BookDownloadMessage() { - Artist = _artist, + Author = _artist, - TrackFiles = new List + BookFiles = new List { new BookFile { diff --git a/src/NzbDrone.Core.Test/OrganizerTests/BuildFilePathFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/BuildFilePathFixture.cs index ee9ef9cc0..6dd126d96 100644 --- a/src/NzbDrone.Core.Test/OrganizerTests/BuildFilePathFixture.cs +++ b/src/NzbDrone.Core.Test/OrganizerTests/BuildFilePathFixture.cs @@ -1,7 +1,7 @@ using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Organizer; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; @@ -38,7 +38,7 @@ namespace NzbDrone.Core.Test.OrganizerTests .With(s => s.Title = "Fake: Book") .Build(); - Subject.BuildTrackFilePath(fakeArtist, fakeAlbum, filename, ".mobi").Should().Be(expectedPath.AsOsAgnostic()); + Subject.BuildBookFilePath(fakeArtist, fakeAlbum, filename, ".mobi").Should().Be(expectedPath.AsOsAgnostic()); } } } diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/CleanTitleFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/CleanTitleFixture.cs index d64b23164..31398bdc3 100644 --- a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/CleanTitleFixture.cs +++ b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/CleanTitleFixture.cs @@ -3,8 +3,8 @@ using System.Linq; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Organizer; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; @@ -35,7 +35,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests _trackFile = new BookFile { Quality = new QualityModel(Quality.MP3_320), ReleaseGroup = "ReadarrTest" }; _namingConfig = NamingConfig.Default; - _namingConfig.RenameTracks = true; + _namingConfig.RenameBooks = true; Mocker.GetMock() .Setup(c => c.GetConfig()).Returns(_namingConfig); @@ -66,9 +66,9 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_get_expected_title_back(string name, string expected) { _artist.Name = name; - _namingConfig.StandardTrackFormat = "{Artist CleanName}"; + _namingConfig.StandardBookFormat = "{Author CleanName}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be(expected); } } diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/FileNameBuilderFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/FileNameBuilderFixture.cs index cb3b6433a..09d20006d 100644 --- a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/FileNameBuilderFixture.cs +++ b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/FileNameBuilderFixture.cs @@ -4,8 +4,8 @@ using System.Linq; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Organizer; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; @@ -41,7 +41,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests .Build(); _namingConfig = NamingConfig.Default; - _namingConfig.RenameTracks = true; + _namingConfig.RenameBooks = true; Mocker.GetMock() .Setup(c => c.GetConfig()).Returns(_namingConfig); @@ -76,267 +76,267 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests [Test] public void should_replace_Artist_space_Name() { - _namingConfig.StandardTrackFormat = "{Artist Name}"; + _namingConfig.StandardBookFormat = "{Author Name}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("Linkin Park"); } [Test] public void should_replace_Artist_underscore_Name() { - _namingConfig.StandardTrackFormat = "{Artist_Name}"; + _namingConfig.StandardBookFormat = "{Author_Name}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("Linkin_Park"); } [Test] public void should_replace_Artist_dot_Name() { - _namingConfig.StandardTrackFormat = "{Artist.Name}"; + _namingConfig.StandardBookFormat = "{Author.Name}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("Linkin.Park"); } [Test] public void should_replace_Artist_dash_Name() { - _namingConfig.StandardTrackFormat = "{Artist-Name}"; + _namingConfig.StandardBookFormat = "{Author-Name}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("Linkin-Park"); } [Test] public void should_replace_ARTIST_NAME_with_all_caps() { - _namingConfig.StandardTrackFormat = "{ARTIST NAME}"; + _namingConfig.StandardBookFormat = "{AUTHOR NAME}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("LINKIN PARK"); } [Test] public void should_replace_ARTIST_NAME_with_random_casing_should_keep_original_casing() { - _namingConfig.StandardTrackFormat = "{aRtIST-nAmE}"; + _namingConfig.StandardBookFormat = "{aUtHoR-nAmE}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be(_artist.Name.Replace(' ', '-')); } [Test] public void should_replace_artist_name_with_all_lower_case() { - _namingConfig.StandardTrackFormat = "{artist name}"; + _namingConfig.StandardBookFormat = "{author name}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("linkin park"); } [Test] public void should_cleanup_Artist_Name() { - _namingConfig.StandardTrackFormat = "{Artist.CleanName}"; + _namingConfig.StandardBookFormat = "{Author.CleanName}"; _artist.Name = "Linkin Park (1997)"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("Linkin.Park.1997"); } [Test] public void should_replace_Artist_Disambiguation() { - _namingConfig.StandardTrackFormat = "{Artist Disambiguation}"; + _namingConfig.StandardBookFormat = "{Author Disambiguation}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("US Rock Band"); } [Test] public void should_replace_Album_space_Title() { - _namingConfig.StandardTrackFormat = "{Album Title}"; + _namingConfig.StandardBookFormat = "{Book Title}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("Hybrid Theory"); } [Test] public void should_replace_Album_Disambiguation() { - _namingConfig.StandardTrackFormat = "{Album Disambiguation}"; + _namingConfig.StandardBookFormat = "{Book Disambiguation}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("The Best Album"); } [Test] public void should_replace_Album_underscore_Title() { - _namingConfig.StandardTrackFormat = "{Album_Title}"; + _namingConfig.StandardBookFormat = "{Book_Title}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("Hybrid_Theory"); } [Test] public void should_replace_Album_dot_Title() { - _namingConfig.StandardTrackFormat = "{Album.Title}"; + _namingConfig.StandardBookFormat = "{Book.Title}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("Hybrid.Theory"); } [Test] public void should_replace_Album_dash_Title() { - _namingConfig.StandardTrackFormat = "{Album-Title}"; + _namingConfig.StandardBookFormat = "{Book-Title}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("Hybrid-Theory"); } [Test] public void should_replace_ALBUM_TITLE_with_all_caps() { - _namingConfig.StandardTrackFormat = "{ALBUM TITLE}"; + _namingConfig.StandardBookFormat = "{BOOK TITLE}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("HYBRID THEORY"); } [Test] public void should_replace_ALBUM_TITLE_with_random_casing_should_keep_original_casing() { - _namingConfig.StandardTrackFormat = "{aLbUM-tItLE}"; + _namingConfig.StandardBookFormat = "{bOoK-tItLE}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be(_album.Title.Replace(' ', '-')); } [Test] public void should_replace_album_title_with_all_lower_case() { - _namingConfig.StandardTrackFormat = "{album title}"; + _namingConfig.StandardBookFormat = "{book title}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("hybrid theory"); } [Test] public void should_cleanup_Album_Title() { - _namingConfig.StandardTrackFormat = "{Artist.CleanName}"; + _namingConfig.StandardBookFormat = "{Author.CleanName}"; _artist.Name = "Hybrid Theory (2000)"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("Hybrid.Theory.2000"); } [Test] public void should_replace_quality_title() { - _namingConfig.StandardTrackFormat = "{Quality Title}"; + _namingConfig.StandardBookFormat = "{Quality Title}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("MP3-320"); } [Test] public void should_replace_media_info_audio_codec() { - _namingConfig.StandardTrackFormat = "{MediaInfo AudioCodec}"; + _namingConfig.StandardBookFormat = "{MediaInfo AudioCodec}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("FLAC"); } [Test] public void should_replace_media_info_audio_bitrate() { - _namingConfig.StandardTrackFormat = "{MediaInfo AudioBitRate}"; + _namingConfig.StandardBookFormat = "{MediaInfo AudioBitRate}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("320 kbps"); } [Test] public void should_replace_media_info_audio_channels() { - _namingConfig.StandardTrackFormat = "{MediaInfo AudioChannels}"; + _namingConfig.StandardBookFormat = "{MediaInfo AudioChannels}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("2.0"); } [Test] public void should_replace_media_info_bits_per_sample() { - _namingConfig.StandardTrackFormat = "{MediaInfo AudioBitsPerSample}"; + _namingConfig.StandardBookFormat = "{MediaInfo AudioBitsPerSample}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("16bit"); } [Test] public void should_replace_media_info_sample_rate() { - _namingConfig.StandardTrackFormat = "{MediaInfo AudioSampleRate}"; + _namingConfig.StandardBookFormat = "{MediaInfo AudioSampleRate}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("44.1kHz"); } [Test] public void should_replace_all_contents_in_pattern() { - _namingConfig.StandardTrackFormat = "{Artist Name} - {Album Title} - [{Quality Title}]"; + _namingConfig.StandardBookFormat = "{Author Name} - {Book Title} - [{Quality Title}]"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("Linkin Park - Hybrid Theory - [MP3-320]"); } [Test] public void use_file_name_when_sceneName_is_null() { - _namingConfig.RenameTracks = false; + _namingConfig.RenameBooks = false; _trackFile.Path = "Linkin Park - 06 - Test"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be(Path.GetFileNameWithoutExtension(_trackFile.Path)); } [Test] public void use_file_name_when_sceneName_is_not_null() { - _namingConfig.RenameTracks = false; + _namingConfig.RenameBooks = false; _trackFile.Path = "Linkin Park - 06 - Test"; _trackFile.SceneName = "SceneName"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be(Path.GetFileNameWithoutExtension(_trackFile.Path)); } [Test] public void use_path_when_sceneName_and_relative_path_are_null() { - _namingConfig.RenameTracks = false; + _namingConfig.RenameBooks = false; _trackFile.Path = @"C:\Test\Unsorted\Artist - 01 - Test"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be(Path.GetFileNameWithoutExtension(_trackFile.Path)); } [Test] public void should_should_replace_release_group() { - _namingConfig.StandardTrackFormat = "{Release Group}"; + _namingConfig.StandardBookFormat = "{Release Group}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be(_trackFile.ReleaseGroup); } @@ -344,48 +344,48 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_be_able_to_use_original_title() { _artist.Name = "Linkin Park"; - _namingConfig.StandardTrackFormat = "{Artist Name} - {Original Title}"; + _namingConfig.StandardBookFormat = "{Author Name} - {Original Title}"; _trackFile.SceneName = "Linkin.Park.Meteora.320-LOL"; _trackFile.Path = "30 Rock - 01 - Test"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("Linkin Park - Linkin.Park.Meteora.320-LOL"); } [Test] public void should_replace_double_period_with_single_period() { - _namingConfig.StandardTrackFormat = "{Artist.Name}.{Album.Title}"; + _namingConfig.StandardBookFormat = "{Author.Name}.{Book.Title}"; - Subject.BuildTrackFileName(new Author { Name = "In The Woods." }, new Book { Title = "30 Rock" }, _trackFile) + Subject.BuildBookFileName(new Author { Name = "In The Woods." }, new Book { Title = "30 Rock" }, _trackFile) .Should().Be("In.The.Woods.30.Rock"); } [Test] public void should_replace_triple_period_with_single_period() { - _namingConfig.StandardTrackFormat = "{Artist.Name}.{Album.Title}"; + _namingConfig.StandardBookFormat = "{Author.Name}.{Book.Title}"; - Subject.BuildTrackFileName(new Author { Name = "In The Woods..." }, new Book { Title = "30 Rock" }, _trackFile) + Subject.BuildBookFileName(new Author { Name = "In The Woods..." }, new Book { Title = "30 Rock" }, _trackFile) .Should().Be("In.The.Woods.30.Rock"); } [Test] public void should_include_affixes_if_value_not_empty() { - _namingConfig.StandardTrackFormat = "{Artist.Name}{_Album.Title_}{Quality.Title}"; + _namingConfig.StandardBookFormat = "{Author.Name}{_Book.Title_}{Quality.Title}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("Linkin.Park_Hybrid.Theory_MP3-320"); } [Test] public void should_not_include_affixes_if_value_empty() { - _namingConfig.StandardTrackFormat = "{Artist.Name}{_Album.Title_}"; + _namingConfig.StandardBookFormat = "{Author.Name}{_Book.Title_}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("Linkin.Park_Hybrid.Theory"); } @@ -393,22 +393,22 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_remove_duplicate_non_word_characters() { _artist.Name = "Venture Bros."; - _namingConfig.StandardTrackFormat = "{Artist.Name}.{Album.Title}"; + _namingConfig.StandardBookFormat = "{Author.Name}.{Book.Title}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("Venture.Bros.Hybrid.Theory"); } [Test] public void should_use_existing_filename_when_scene_name_is_not_available() { - _namingConfig.RenameTracks = true; - _namingConfig.StandardTrackFormat = "{Original Title}"; + _namingConfig.RenameBooks = true; + _namingConfig.StandardBookFormat = "{Original Title}"; _trackFile.SceneName = null; _trackFile.Path = "existing.file.mkv"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be(Path.GetFileNameWithoutExtension(_trackFile.Path)); } @@ -416,39 +416,39 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_be_able_to_use_only_original_title() { _artist.Name = "30 Rock"; - _namingConfig.StandardTrackFormat = "{Original Title}"; + _namingConfig.StandardBookFormat = "{Original Title}"; _trackFile.SceneName = "30.Rock.S01E01.xvid-LOL"; _trackFile.Path = "30 Rock - S01E01 - Test"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("30.Rock.S01E01.xvid-LOL"); } [Test] public void should_not_include_quality_proper_when_release_is_not_a_proper() { - _namingConfig.StandardTrackFormat = "{Quality Title} {Quality Proper}"; + _namingConfig.StandardBookFormat = "{Quality Title} {Quality Proper}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("MP3-320"); } [Test] public void should_not_wrap_proper_in_square_brackets_when_not_a_proper() { - _namingConfig.StandardTrackFormat = "{Artist Name} - {Album Title} [{Quality Title}] {[Quality Proper]}"; + _namingConfig.StandardBookFormat = "{Author Name} - {Book Title} [{Quality Title}] {[Quality Proper]}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("Linkin Park - Hybrid Theory [MP3-320]"); } [Test] public void should_replace_quality_full_with_quality_title_only_when_not_a_proper() { - _namingConfig.StandardTrackFormat = "{Artist Name} - {Album Title} [{Quality Full}]"; + _namingConfig.StandardBookFormat = "{Author Name} - {Book Title} [{Quality Full}]"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("Linkin Park - Hybrid Theory [MP3-320]"); } @@ -458,9 +458,9 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests [TestCase('_')] public void should_trim_extra_separators_from_end_when_quality_proper_is_not_included(char separator) { - _namingConfig.StandardTrackFormat = string.Format("{{Quality{0}Title}}{0}{{Quality{0}Proper}}", separator); + _namingConfig.StandardBookFormat = string.Format("{{Quality{0}Title}}{0}{{Quality{0}Proper}}", separator); - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("MP3-320"); } @@ -470,9 +470,9 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests [TestCase('_')] public void should_trim_extra_separators_from_middle_when_quality_proper_is_not_included(char separator) { - _namingConfig.StandardTrackFormat = string.Format("{{Quality{0}Title}}{0}{{Quality{0}Proper}}{0}{{Album{0}Title}}", separator); + _namingConfig.StandardBookFormat = string.Format("{{Quality{0}Title}}{0}{{Quality{0}Proper}}{0}{{Book{0}Title}}", separator); - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be(string.Format("MP3-320{0}Hybrid{0}Theory", separator)); } @@ -480,12 +480,12 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_be_able_to_use_original_filename() { _artist.Name = "30 Rock"; - _namingConfig.StandardTrackFormat = "{Artist Name} - {Original Filename}"; + _namingConfig.StandardBookFormat = "{Author Name} - {Original Filename}"; _trackFile.SceneName = "30.Rock.S01E01.xvid-LOL"; _trackFile.Path = "30 Rock - S01E01 - Test"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("30 Rock - 30 Rock - S01E01 - Test"); } @@ -493,12 +493,12 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_be_able_to_use_original_filename_only() { _artist.Name = "30 Rock"; - _namingConfig.StandardTrackFormat = "{Original Filename}"; + _namingConfig.StandardBookFormat = "{Original Filename}"; _trackFile.SceneName = "30.Rock.S01E01.xvid-LOL"; _trackFile.Path = "30 Rock - S01E01 - Test"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("30 Rock - S01E01 - Test"); } @@ -506,21 +506,21 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_use_Readarr_as_release_group_when_not_available() { _trackFile.ReleaseGroup = null; - _namingConfig.StandardTrackFormat = "{Release Group}"; + _namingConfig.StandardBookFormat = "{Release Group}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be("Readarr"); } - [TestCase("{Album Title}{-Release Group}", "Hybrid Theory")] - [TestCase("{Album Title}{ Release Group}", "Hybrid Theory")] - [TestCase("{Album Title}{ [Release Group]}", "Hybrid Theory")] + [TestCase("{Book Title}{-Release Group}", "Hybrid Theory")] + [TestCase("{Book Title}{ Release Group}", "Hybrid Theory")] + [TestCase("{Book Title}{ [Release Group]}", "Hybrid Theory")] public void should_not_use_Readarr_as_release_group_if_pattern_has_separator(string pattern, string expectedFileName) { _trackFile.ReleaseGroup = null; - _namingConfig.StandardTrackFormat = pattern; + _namingConfig.StandardBookFormat = pattern; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be(expectedFileName); } @@ -530,9 +530,9 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_use_existing_casing_for_release_group(string releaseGroup) { _trackFile.ReleaseGroup = releaseGroup; - _namingConfig.StandardTrackFormat = "{Release Group}"; + _namingConfig.StandardBookFormat = "{Release Group}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be(releaseGroup); } } diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/TitleTheFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/TitleTheFixture.cs index 71b4675c4..0bb4506f9 100644 --- a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/TitleTheFixture.cs +++ b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/TitleTheFixture.cs @@ -3,8 +3,8 @@ using System.Linq; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Organizer; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; @@ -35,7 +35,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests _trackFile = new BookFile { Quality = new QualityModel(Quality.MP3_320), ReleaseGroup = "ReadarrTest" }; _namingConfig = NamingConfig.Default; - _namingConfig.RenameTracks = true; + _namingConfig.RenameBooks = true; Mocker.GetMock() .Setup(c => c.GetConfig()).Returns(_namingConfig); @@ -60,9 +60,9 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_get_expected_title_back(string name, string expected) { _artist.Name = name; - _namingConfig.StandardTrackFormat = "{Artist NameThe}"; + _namingConfig.StandardBookFormat = "{Author NameThe}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be(expected); } @@ -73,9 +73,9 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_not_change_title(string name) { _artist.Name = name; - _namingConfig.StandardTrackFormat = "{Artist NameThe}"; + _namingConfig.StandardBookFormat = "{Author NameThe}"; - Subject.BuildTrackFileName(_artist, _album, _trackFile) + Subject.BuildBookFileName(_artist, _album, _trackFile) .Should().Be(name); } } diff --git a/src/NzbDrone.Core.Test/OrganizerTests/GetArtistFolderFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/GetArtistFolderFixture.cs deleted file mode 100644 index 933159126..000000000 --- a/src/NzbDrone.Core.Test/OrganizerTests/GetArtistFolderFixture.cs +++ /dev/null @@ -1,39 +0,0 @@ -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Music; -using NzbDrone.Core.Organizer; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.OrganizerTests -{ - [TestFixture] - - public class GetArtistFolderFixture : CoreTest - { - private NamingConfig _namingConfig; - - [SetUp] - public void Setup() - { - _namingConfig = NamingConfig.Default; - - Mocker.GetMock() - .Setup(c => c.GetConfig()).Returns(_namingConfig); - } - - [TestCase("Avenged Sevenfold", "{Artist Name}", "Avenged Sevenfold")] - [TestCase("Avenged Sevenfold", "{Artist.Name}", "Avenged.Sevenfold")] - [TestCase("AC/DC", "{Artist Name}", "AC+DC")] - [TestCase("In the Woods...", "{Artist.Name}", "In.the.Woods")] - [TestCase("3OH!3", "{Artist.Name}", "3OH!3")] - [TestCase("Avenged Sevenfold", ".{Artist.Name}.", "Avenged.Sevenfold")] - public void should_use_artistFolderFormat_to_build_folder_name(string artistName, string format, string expected) - { - _namingConfig.ArtistFolderFormat = format; - - var artist = new Author { Name = artistName }; - - Subject.GetArtistFolder(artist).Should().Be(expected); - } - } -} diff --git a/src/NzbDrone.Core.Test/OrganizerTests/GetAuthorFolderFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/GetAuthorFolderFixture.cs new file mode 100644 index 000000000..25ded8661 --- /dev/null +++ b/src/NzbDrone.Core.Test/OrganizerTests/GetAuthorFolderFixture.cs @@ -0,0 +1,39 @@ +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.Books; +using NzbDrone.Core.Organizer; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.OrganizerTests +{ + [TestFixture] + + public class GetAuthorFolderFixture : CoreTest + { + private NamingConfig _namingConfig; + + [SetUp] + public void Setup() + { + _namingConfig = NamingConfig.Default; + + Mocker.GetMock() + .Setup(c => c.GetConfig()).Returns(_namingConfig); + } + + [TestCase("Avenged Sevenfold", "{Author Name}", "Avenged Sevenfold")] + [TestCase("Avenged Sevenfold", "{Author.Name}", "Avenged.Sevenfold")] + [TestCase("AC/DC", "{Author Name}", "AC+DC")] + [TestCase("In the Woods...", "{Author.Name}", "In.the.Woods")] + [TestCase("3OH!3", "{Author.Name}", "3OH!3")] + [TestCase("Avenged Sevenfold", ".{Author.Name}.", "Avenged.Sevenfold")] + public void should_use_authorFolderFormat_to_build_folder_name(string authorName, string format, string expected) + { + _namingConfig.AuthorFolderFormat = format; + + var author = new Author { Name = authorName }; + + Subject.GetAuthorFolder(author).Should().Be(expected); + } + } +} diff --git a/src/NzbDrone.Core.Test/ParserTests/ArtistTitleInfoFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ArtistTitleInfoFixture.cs index 54623599c..cb34c06cb 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ArtistTitleInfoFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ArtistTitleInfoFixture.cs @@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.ParserTests { const string title = "Alien Ant Farm - TruAnt [Flac]"; - var result = Parser.Parser.ParseAlbumTitle(title).ArtistTitleInfo; + var result = Parser.Parser.ParseBookTitle(title).AuthorTitleInfo; result.Year.Should().Be(0); } @@ -25,7 +25,7 @@ namespace NzbDrone.Core.Test.ParserTests { const string title = "Alien Ant Farm - TruAnt [Flac]"; - var result = Parser.Parser.ParseAlbumTitle(title).ArtistTitleInfo; + var result = Parser.Parser.ParseBookTitle(title).AuthorTitleInfo; result.Title.Should().Be(result.TitleWithoutYear); } @@ -36,7 +36,7 @@ namespace NzbDrone.Core.Test.ParserTests { const string title = "Alien Ant Farm - TruAnt [Flac]"; - var result = Parser.Parser.ParseAlbumTitle(title).ArtistTitleInfo; + var result = Parser.Parser.ParseBookTitle(title).AuthorTitleInfo; result.Year.Should().Be(2004); } @@ -47,7 +47,7 @@ namespace NzbDrone.Core.Test.ParserTests { const string title = "Alien Ant Farm - TruAnt [Flac]"; - var result = Parser.Parser.ParseAlbumTitle(title).ArtistTitleInfo; + var result = Parser.Parser.ParseBookTitle(title).AuthorTitleInfo; result.Title.Should().Be("House 2004"); } @@ -58,7 +58,7 @@ namespace NzbDrone.Core.Test.ParserTests { const string title = "Alien Ant Farm - TruAnt [Flac]"; - var result = Parser.Parser.ParseAlbumTitle(title).ArtistTitleInfo; + var result = Parser.Parser.ParseBookTitle(title).AuthorTitleInfo; result.TitleWithoutYear.Should().Be("House"); } diff --git a/src/NzbDrone.Core.Test/ParserTests/CrapParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/CrapParserFixture.cs index e5674bcdb..afb42e4f0 100644 --- a/src/NzbDrone.Core.Test/ParserTests/CrapParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/CrapParserFixture.cs @@ -32,7 +32,7 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("QZC4HDl7ncmzyUj9amucWe1ddKU1oFMZDd8r0dEDUsTd")] public void should_not_parse_crap(string title) { - Parser.Parser.ParseAlbumTitle(title).Should().BeNull(); + Parser.Parser.ParseBookTitle(title).Should().BeNull(); ExceptionVerification.IgnoreWarns(); } @@ -51,7 +51,7 @@ namespace NzbDrone.Core.Test.ParserTests hash = BitConverter.ToString(hashData).Replace("-", ""); - if (Parser.Parser.ParseAlbumTitle(hash) == null) + if (Parser.Parser.ParseBookTitle(hash) == null) { success++; } @@ -79,7 +79,7 @@ namespace NzbDrone.Core.Test.ParserTests hash.Append(charset[hashAlgo.Next() % charset.Length]); } - if (Parser.Parser.ParseAlbumTitle(hash.ToString()) == null) + if (Parser.Parser.ParseBookTitle(hash.ToString()) == null) { success++; } @@ -91,7 +91,7 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("thebiggestloser1618finale")] public void should_not_parse_file_name_without_proper_spacing(string fileName) { - Parser.Parser.ParseAlbumTitle(fileName).Should().BeNull(); + Parser.Parser.ParseBookTitle(fileName).Should().BeNull(); } } } diff --git a/src/NzbDrone.Core.Test/ParserTests/FingerprintingServiceFixture.cs b/src/NzbDrone.Core.Test/ParserTests/FingerprintingServiceFixture.cs index eafe6837b..fa8ebead3 100644 --- a/src/NzbDrone.Core.Test/ParserTests/FingerprintingServiceFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/FingerprintingServiceFixture.cs @@ -102,8 +102,8 @@ FINGERPRINT=AQAHJlMURlEURcgP6cwRD43Y4Ptw9FowncWPWkf6GB9-JYdP9OgJHw8u4Apw4SsOHMdx public void should_lookup_file(string file) { var path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "Media", file); - var localTrack = new LocalTrack { Path = path }; - Subject.Lookup(new List { localTrack }, 0.5); + var localTrack = new LocalBook { Path = path }; + Subject.Lookup(new List { localTrack }, 0.5); localTrack.AcoustIdResults.Should().NotBeNull(); localTrack.AcoustIdResults.Should().Contain("30f3f33e-8d0c-4e69-8539-cbd701d18f28"); } @@ -115,7 +115,7 @@ FINGERPRINT=AQAHJlMURlEURcgP6cwRD43Y4Ptw9FowncWPWkf6GB9-JYdP9OgJHw8u4Apw4SsOHMdx { "nin.mp3", "nin.flac" - }.Select(x => new LocalTrack { Path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "Media", x) }).ToList(); + }.Select(x => new LocalBook { Path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "Media", x) }).ToList(); Subject.Lookup(files, 0.5); files[0].AcoustIdResults.Should().Contain("30f3f33e-8d0c-4e69-8539-cbd701d18f28"); @@ -130,7 +130,7 @@ FINGERPRINT=AQAHJlMURlEURcgP6cwRD43Y4Ptw9FowncWPWkf6GB9-JYdP9OgJHw8u4Apw4SsOHMdx "nin.mp3", "missing.mp3", "nin.flac" - }.Select(x => new LocalTrack { Path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "Media", x) }).ToList(); + }.Select(x => new LocalBook { Path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "Media", x) }).ToList(); var idpairs = files.Select(x => Tuple.Create(x, Subject.GetFingerprint(x.Path))).ToList(); @@ -148,9 +148,9 @@ FINGERPRINT=AQAHJlMURlEURcgP6cwRD43Y4Ptw9FowncWPWkf6GB9-JYdP9OgJHw8u4Apw4SsOHMdx { "missing1.mp3", "missing2.mp3" - }.Select(x => new LocalTrack { Path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "Media", x) }).ToList(); + }.Select(x => new LocalBook { Path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "Media", x) }).ToList(); - var idpairs = files.Select(x => Tuple.Create(x, null)).ToList(); + var idpairs = files.Select(x => Tuple.Create(x, null)).ToList(); Subject.Lookup(idpairs, 0.5); @@ -162,28 +162,28 @@ FINGERPRINT=AQAHJlMURlEURcgP6cwRD43Y4Ptw9FowncWPWkf6GB9-JYdP9OgJHw8u4Apw4SsOHMdx public void should_not_fail_if_duration_reported_as_zero() { var path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "Media", "missing.mp3"); - var localTrack = new LocalTrack { Path = path }; + var localTrack = new LocalBook { Path = path }; var acoustId = new AcoustId { Duration = 0, Fingerprint = "fingerprint" }; - Subject.Lookup(new List> { Tuple.Create(localTrack, acoustId) }, 0.5); + Subject.Lookup(new List> { Tuple.Create(localTrack, acoustId) }, 0.5); } [Test] public void should_not_throw_if_fingerprint_invalid() { var path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "Media", "missing.mp3"); - var localTrack = new LocalTrack { Path = path }; + var localTrack = new LocalBook { Path = path }; var acoustId = new AcoustId { Duration = 1, Fingerprint = "fingerprint" }; - var files = new List> { Tuple.Create(localTrack, acoustId) }; + var files = new List> { Tuple.Create(localTrack, acoustId) }; Subject.Lookup(files, 0.5); files[0].Item1.AcoustIdResults.Should().BeNull(); } @@ -195,11 +195,11 @@ FINGERPRINT=AQAHJlMURlEURcgP6cwRD43Y4Ptw9FowncWPWkf6GB9-JYdP9OgJHw8u4Apw4SsOHMdx { "nin.mp3", "nin.flac" - }.Select(x => new LocalTrack { Path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "Media", x) }).ToList(); + }.Select(x => new LocalBook { Path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "Media", x) }).ToList(); var idpairs = files.Select(x => Tuple.Create(x, Subject.GetFingerprint(x.Path))).ToList(); - idpairs.Add(Tuple.Create(new LocalTrack(), new AcoustId { Duration = 1, Fingerprint = "fingerprint" })); + idpairs.Add(Tuple.Create(new LocalBook(), new AcoustId { Duration = 1, Fingerprint = "fingerprint" })); Subject.Lookup(idpairs, 0.5); @@ -215,8 +215,8 @@ FINGERPRINT=AQAHJlMURlEURcgP6cwRD43Y4Ptw9FowncWPWkf6GB9-JYdP9OgJHw8u4Apw4SsOHMdx .Callback(req => throw new UnexpectedHtmlContentException(new HttpResponse(req, req.Headers, "html content", HttpStatusCode.Accepted))); var path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "Media", "nin.mp3"); - var localTrack = new LocalTrack { Path = path }; - Subject.Lookup(new List { localTrack }, 0.5); + var localTrack = new LocalBook { Path = path }; + Subject.Lookup(new List { localTrack }, 0.5); localTrack.AcoustIdResults.Should().BeNull(); ExceptionVerification.ExpectedWarns(4); @@ -229,8 +229,8 @@ FINGERPRINT=AQAHJlMURlEURcgP6cwRD43Y4Ptw9FowncWPWkf6GB9-JYdP9OgJHw8u4Apw4SsOHMdx .Throws(new System.Net.WebException("The operation has timed out.")); var path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "Media", "nin.mp3"); - var localTrack = new LocalTrack { Path = path }; - Subject.Lookup(new List { localTrack }, 0.5); + var localTrack = new LocalBook { Path = path }; + Subject.Lookup(new List { localTrack }, 0.5); localTrack.AcoustIdResults.Should().BeNull(); ExceptionVerification.ExpectedWarns(1); @@ -247,8 +247,8 @@ FINGERPRINT=AQAHJlMURlEURcgP6cwRD43Y4Ptw9FowncWPWkf6GB9-JYdP9OgJHw8u4Apw4SsOHMdx .Returns(new HttpResponse(new HttpResponse(new HttpRequest("dummy"), new HttpHeader(), response, HttpStatusCode.OK))); var path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "Media", "nin.mp3"); - var localTrack = new LocalTrack { Path = path }; - Subject.Lookup(new List { localTrack }, 0.5); + var localTrack = new LocalBook { Path = path }; + Subject.Lookup(new List { localTrack }, 0.5); localTrack.AcoustIdResults.Should().NotBeNull(); localTrack.AcoustIdResults.Should().Contain("30f3f33e-8d0c-4e69-8539-cbd701d18f28"); @@ -265,9 +265,9 @@ FINGERPRINT=AQAHJlMURlEURcgP6cwRD43Y4Ptw9FowncWPWkf6GB9-JYdP9OgJHw8u4Apw4SsOHMdx .Returns(new HttpResponse(new HttpResponse(new HttpRequest("dummy"), new HttpHeader(), error, HttpStatusCode.ServiceUnavailable))); var path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "Media", "nin.mp3"); - var localTrack = new LocalTrack { Path = path }; + var localTrack = new LocalBook { Path = path }; - Subject.Lookup(new List { localTrack }, 0.5); + Subject.Lookup(new List { localTrack }, 0.5); localTrack.AcoustIdResults.Should().BeNull(); Mocker.GetMock() diff --git a/src/NzbDrone.Core.Test/ParserTests/MusicParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/MusicParserFixture.cs index 82a9473db..16996e080 100644 --- a/src/NzbDrone.Core.Test/ParserTests/MusicParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/MusicParserFixture.cs @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.ParserTests // TODO: Rewrite this test to something that makes sense. public void should_parse_artist_names(string title) { - Parser.Parser.ParseMusicTitle(title).ArtistTitle.Should().Be(title); + Parser.Parser.ParseTitle(title).ArtistTitle.Should().Be(title); ExceptionVerification.IgnoreWarns(); } } diff --git a/src/NzbDrone.Core.Test/ParserTests/NormalizeTitleFixture.cs b/src/NzbDrone.Core.Test/ParserTests/NormalizeTitleFixture.cs index f2af9134e..826b66c98 100644 --- a/src/NzbDrone.Core.Test/ParserTests/NormalizeTitleFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/NormalizeTitleFixture.cs @@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("Law_and_Order_SVU", "lawordersvu")] public void should_normalize_artist_title(string parsedArtistName, string artistName) { - var result = parsedArtistName.CleanArtistName(); + var result = parsedArtistName.CleanAuthorName(); result.Should().Be(artistName); } @@ -26,7 +26,7 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("24", "24")] public void should_remove_special_characters_and_casing(string dirty, string clean) { - var result = dirty.CleanArtistName(); + var result = dirty.CleanAuthorName(); result.Should().Be(clean); } @@ -50,7 +50,7 @@ namespace NzbDrone.Core.Test.ParserTests foreach (var s in dirtyFormat) { var dirty = string.Format(s, word); - dirty.CleanArtistName().Should().Be("wordword"); + dirty.CleanAuthorName().Should().Be("wordword"); } } @@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test.ParserTests foreach (var s in dirtyFormat) { var dirty = string.Format(s, "a"); - dirty.CleanArtistName().Should().Be("wordword"); + dirty.CleanAuthorName().Should().Be("wordword"); } } @@ -92,7 +92,7 @@ namespace NzbDrone.Core.Test.ParserTests foreach (var s in dirtyFormat) { var dirty = string.Format(s, word); - dirty.CleanArtistName().Should().Be("word" + word.ToLower() + "word"); + dirty.CleanAuthorName().Should().Be("word" + word.ToLower() + "word"); } } @@ -101,7 +101,7 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("The.Daily.Show", "thedailyshow")] public void should_not_remove_from_the_beginning_of_the_title(string parsedArtistName, string artistName) { - var result = parsedArtistName.CleanArtistName(); + var result = parsedArtistName.CleanAuthorName(); result.Should().Be(artistName); } @@ -123,14 +123,14 @@ namespace NzbDrone.Core.Test.ParserTests foreach (var s in dirtyFormat) { var dirty = string.Format(s, word); - dirty.CleanArtistName().Should().Be(word + "wordword"); + dirty.CleanAuthorName().Should().Be(word + "wordword"); } } [Test] public void should_not_clean_trailing_a() { - "Tokyo Ghoul A".CleanArtistName().Should().Be("tokyoghoula"); + "Tokyo Ghoul A".CleanAuthorName().Should().Be("tokyoghoula"); } [TestCase("3%", "3percent")] @@ -138,7 +138,7 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("Big Jay Oakerson's What's Your F@%king Deal?!", "bigjayoakersonswhatsyourfkingdeal")] public void should_replace_percent_sign_with_percent_following_numbers(string input, string expected) { - input.CleanArtistName().Should().Be(expected); + input.CleanAuthorName().Should().Be(expected); } } } diff --git a/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs index 2a317c860..2d4567475 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Parser; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; @@ -37,8 +37,8 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("Bad Format", "badformat")] public void should_parse_artist_name(string postTitle, string title) { - var result = Parser.Parser.ParseArtistName(postTitle).CleanArtistName(); - result.Should().Be(title.CleanArtistName()); + var result = Parser.Parser.ParseArtistName(postTitle).CleanAuthorName(); + result.Should().Be(title.CleanAuthorName()); } [Test] @@ -46,7 +46,7 @@ namespace NzbDrone.Core.Test.ParserTests { const string title = "Carniv\u00E0le"; - title.CleanArtistName().Should().Be("carnivale"); + title.CleanAuthorName().Should().Be("carnivale"); } [TestCase("Songs of Experience (Deluxe Edition)", "Songs of Experience")] @@ -80,13 +80,13 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("Discovery TV - Gold Rush : 02 Road From Hell [S04].mp4")] public void should_clean_up_invalid_path_characters(string postTitle) { - Parser.Parser.ParseAlbumTitle(postTitle); + Parser.Parser.ParseBookTitle(postTitle); } [TestCase("[scnzbefnet][509103] Jay-Z - 4:44 (Deluxe Edition) (2017) 320", "Jay-Z")] public void should_remove_request_info_from_title(string postTitle, string title) { - Parser.Parser.ParseAlbumTitle(postTitle).ArtistName.Should().Be(title); + Parser.Parser.ParseBookTitle(postTitle).AuthorName.Should().Be(title); } [TestCase("02 Unchained.flac")] // This isn't valid on any regex we have. We must always have an artist @@ -94,8 +94,8 @@ namespace NzbDrone.Core.Test.ParserTests [Ignore("Ignore Test until track parsing rework")] public void should_parse_quality_from_extension(string title) { - Parser.Parser.ParseAlbumTitle(title).Quality.Quality.Should().NotBe(Quality.Unknown); - Parser.Parser.ParseAlbumTitle(title).Quality.QualityDetectionSource.Should().Be(QualityDetectionSource.Extension); + Parser.Parser.ParseBookTitle(title).Quality.Quality.Should().NotBe(Quality.Unknown); + Parser.Parser.ParseBookTitle(title).Quality.QualityDetectionSource.Should().Be(QualityDetectionSource.Extension); } [TestCase("VA - The Best 101 Love Ballads (2017) MP3 [192 kbps]", "VA", "The Best 101 Love Ballads")] @@ -177,9 +177,9 @@ namespace NzbDrone.Core.Test.ParserTests // [TestCase("Metallica - ...And Justice for All (1988) [FLAC Lossless]", "Metallica", "...And Justice for All")] public void should_parse_artist_name_and_album_title(string postTitle, string name, string title, bool discography = false) { - var parseResult = Parser.Parser.ParseAlbumTitle(postTitle); - parseResult.ArtistName.Should().Be(name); - parseResult.AlbumTitle.Should().Be(title); + var parseResult = Parser.Parser.ParseBookTitle(postTitle); + parseResult.AuthorName.Should().Be(name); + parseResult.BookTitle.Should().Be(title); parseResult.Discography.Should().Be(discography); } @@ -193,8 +193,8 @@ namespace NzbDrone.Core.Test.ParserTests { GivenSearchCriteria("Black Sabbath", "Black Sabbath"); var parseResult = Parser.Parser.ParseAlbumTitleWithSearchCriteria(releaseTitle, _artist, _albums); - parseResult.ArtistName.ToLowerInvariant().Should().Be("black sabbath"); - parseResult.AlbumTitle.ToLowerInvariant().Should().Be("black sabbath"); + parseResult.AuthorName.ToLowerInvariant().Should().Be("black sabbath"); + parseResult.BookTitle.ToLowerInvariant().Should().Be("black sabbath"); } [TestCase("Captain-Discography_1998_-_2001-CD-FLAC-2007-UTP", 1998, 2001)] @@ -204,7 +204,7 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("Caetano Veloso Discografia Completa MP3 @256", 0, 0)] public void should_parse_year_or_year_range_from_discography(string releaseTitle, int startyear, int endyear) { - var parseResult = Parser.Parser.ParseAlbumTitle(releaseTitle); + var parseResult = Parser.Parser.ParseBookTitle(releaseTitle); parseResult.Discography.Should().BeTrue(); parseResult.DiscographyStart.Should().Be(startyear); parseResult.DiscographyEnd.Should().Be(endyear); @@ -229,7 +229,7 @@ namespace NzbDrone.Core.Test.ParserTests { GivenSearchCriteria(artist, album); var parseResult = Parser.Parser.ParseAlbumTitleWithSearchCriteria(releaseTitle, _artist, _albums); - parseResult.AlbumTitle.Should().Be(album); + parseResult.BookTitle.Should().Be(album); } [TestCase("???", "Album", "??? Album FLAC")] @@ -240,7 +240,7 @@ namespace NzbDrone.Core.Test.ParserTests { GivenSearchCriteria(artist, album); var parseResult = Parser.Parser.ParseAlbumTitleWithSearchCriteria(releaseTitle, _artist, _albums); - parseResult.ArtistName.Should().Be(artist); + parseResult.AuthorName.Should().Be(artist); } [TestCase("Michael Bubl\u00E9", "Michael Bubl\u00E9", @"Michael Buble Michael Buble CD FLAC 2003 PERFECT")] @@ -248,8 +248,8 @@ namespace NzbDrone.Core.Test.ParserTests { GivenSearchCriteria(artist, album); var parseResult = Parser.Parser.ParseAlbumTitleWithSearchCriteria(releaseTitle, _artist, _albums); - parseResult.ArtistName.Should().Be("Michael Buble"); - parseResult.AlbumTitle.Should().Be("Michael Buble"); + parseResult.AuthorName.Should().Be("Michael Buble"); + parseResult.BookTitle.Should().Be("Michael Buble"); } [Test] @@ -262,8 +262,8 @@ namespace NzbDrone.Core.Test.ParserTests GivenSearchCriteria("Michael Bubl\u00E9", "To Be Loved"); var parseResult = Parser.Parser.ParseAlbumTitleWithSearchCriteria( "Michael Buble Christmas (Deluxe Special Edition) CD FLAC 2012 UNDERTONE iNT", _artist, _albums); - parseResult.ArtistName.Should().Be("Michael Buble"); - parseResult.AlbumTitle.Should().Be("Christmas"); + parseResult.AuthorName.Should().Be("Michael Buble"); + parseResult.BookTitle.Should().Be("Christmas"); } } } diff --git a/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetAlbumsFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetAlbumsFixture.cs index 3d2de1244..109d4d629 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetAlbumsFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetAlbumsFixture.cs @@ -4,8 +4,8 @@ using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; @@ -20,20 +20,20 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests { var artist = Builder.CreateNew().Build(); var albums = Builder.CreateListOfSize(2).All().With(x => x.Title = "IdenticalTitle").Build().ToList(); - var criteria = new AlbumSearchCriteria + var criteria = new BookSearchCriteria { - Artist = artist, - Albums = albums + Author = artist, + Books = albums }; - var parsed = new ParsedAlbumInfo + var parsed = new ParsedBookInfo { - AlbumTitle = "IdenticalTitle" + BookTitle = "IdenticalTitle" }; Subject.GetAlbums(parsed, artist, criteria).Should().BeEquivalentTo(new List()); - Mocker.GetMock() + Mocker.GetMock() .Verify(s => s.FindByTitle(artist.AuthorMetadataId, "IdenticalTitle"), Times.Once()); } } diff --git a/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetArtistFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetArtistFixture.cs index 784d510e6..75794f770 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetArtistFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetArtistFixture.cs @@ -1,6 +1,6 @@ using Moq; using NUnit.Framework; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Parser; using NzbDrone.Core.Test.Framework; @@ -16,7 +16,7 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests Subject.GetArtist(title); - Mocker.GetMock() + Mocker.GetMock() .Verify(s => s.FindByName(title), Times.Once()); } @@ -27,8 +27,8 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests Subject.GetArtist(title); - Mocker.GetMock() - .Verify(s => s.FindByName(Parser.Parser.ParseAlbumTitle(title).ArtistName), Times.Once()); + Mocker.GetMock() + .Verify(s => s.FindByName(Parser.Parser.ParseBookTitle(title).AuthorName), Times.Once()); } } } diff --git a/src/NzbDrone.Core.Test/Profiles/Metadata/MetadataProfileRepositoryFixture.cs b/src/NzbDrone.Core.Test/Profiles/Metadata/MetadataProfileRepositoryFixture.cs index db24a0a15..0647b1c4e 100644 --- a/src/NzbDrone.Core.Test/Profiles/Metadata/MetadataProfileRepositoryFixture.cs +++ b/src/NzbDrone.Core.Test/Profiles/Metadata/MetadataProfileRepositoryFixture.cs @@ -1,7 +1,7 @@ using System.Linq; using FluentAssertions; using NUnit.Framework; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Profiles.Metadata; using NzbDrone.Core.Test.Framework; diff --git a/src/NzbDrone.Core.Test/Profiles/Metadata/MetadataProfileServiceFixture.cs b/src/NzbDrone.Core.Test/Profiles/Metadata/MetadataProfileServiceFixture.cs index 4daefc516..2784dedae 100644 --- a/src/NzbDrone.Core.Test/Profiles/Metadata/MetadataProfileServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Profiles/Metadata/MetadataProfileServiceFixture.cs @@ -4,9 +4,9 @@ using System.Linq; using FizzWare.NBuilder; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.ImportLists; using NzbDrone.Core.Lifecycle; -using NzbDrone.Core.Music; using NzbDrone.Core.Profiles.Metadata; using NzbDrone.Core.RootFolders; using NzbDrone.Core.Test.Framework; @@ -120,7 +120,7 @@ namespace NzbDrone.Core.Test.Profiles.Metadata .With(f => f.DefaultMetadataProfileId = 1) .BuildList(); - Mocker.GetMock().Setup(c => c.GetAllArtists()).Returns(artistList); + Mocker.GetMock().Setup(c => c.GetAllAuthors()).Returns(artistList); Mocker.GetMock().Setup(c => c.All()).Returns(importLists); Mocker.GetMock().Setup(c => c.All()).Returns(rootFolders); Mocker.GetMock().Setup(c => c.Get(profile.Id)).Returns(profile); @@ -152,7 +152,7 @@ namespace NzbDrone.Core.Test.Profiles.Metadata .With(f => f.DefaultMetadataProfileId = 1) .BuildList(); - Mocker.GetMock().Setup(c => c.GetAllArtists()).Returns(artistList); + Mocker.GetMock().Setup(c => c.GetAllAuthors()).Returns(artistList); Mocker.GetMock().Setup(c => c.All()).Returns(importLists); Mocker.GetMock().Setup(c => c.All()).Returns(rootFolders); Mocker.GetMock().Setup(c => c.Get(profile.Id)).Returns(profile); @@ -184,7 +184,7 @@ namespace NzbDrone.Core.Test.Profiles.Metadata .With(f => f.DefaultMetadataProfileId = profile.Id) .BuildList(); - Mocker.GetMock().Setup(c => c.GetAllArtists()).Returns(artistList); + Mocker.GetMock().Setup(c => c.GetAllAuthors()).Returns(artistList); Mocker.GetMock().Setup(c => c.All()).Returns(importLists); Mocker.GetMock().Setup(c => c.All()).Returns(rootFolders); Mocker.GetMock().Setup(c => c.Get(profile.Id)).Returns(profile); @@ -216,7 +216,7 @@ namespace NzbDrone.Core.Test.Profiles.Metadata .With(f => f.DefaultMetadataProfileId = 2) .BuildList(); - Mocker.GetMock().Setup(c => c.GetAllArtists()).Returns(artistList); + Mocker.GetMock().Setup(c => c.GetAllAuthors()).Returns(artistList); Mocker.GetMock().Setup(c => c.All()).Returns(importLists); Mocker.GetMock().Setup(c => c.All()).Returns(rootFolders); Mocker.GetMock().Setup(c => c.Get(profile.Id)).Returns(profile); diff --git a/src/NzbDrone.Core.Test/Profiles/ProfileServiceFixture.cs b/src/NzbDrone.Core.Test/Profiles/ProfileServiceFixture.cs index 3e756e3ff..135ee494d 100644 --- a/src/NzbDrone.Core.Test/Profiles/ProfileServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Profiles/ProfileServiceFixture.cs @@ -2,9 +2,9 @@ using System.Linq; using FizzWare.NBuilder; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.ImportLists; using NzbDrone.Core.Lifecycle; -using NzbDrone.Core.Music; using NzbDrone.Core.Profiles.Qualities; using NzbDrone.Core.RootFolders; using NzbDrone.Core.Test.Framework; @@ -62,7 +62,7 @@ namespace NzbDrone.Core.Test.Profiles .With(f => f.DefaultQualityProfileId = 1) .BuildList(); - Mocker.GetMock().Setup(c => c.GetAllArtists()).Returns(artistList); + Mocker.GetMock().Setup(c => c.GetAllAuthors()).Returns(artistList); Mocker.GetMock().Setup(c => c.All()).Returns(importLists); Mocker.GetMock().Setup(c => c.All()).Returns(rootFolders); Mocker.GetMock().Setup(c => c.Get(profile.Id)).Returns(profile); @@ -94,7 +94,7 @@ namespace NzbDrone.Core.Test.Profiles .With(f => f.DefaultQualityProfileId = 1) .BuildList(); - Mocker.GetMock().Setup(c => c.GetAllArtists()).Returns(artistList); + Mocker.GetMock().Setup(c => c.GetAllAuthors()).Returns(artistList); Mocker.GetMock().Setup(c => c.All()).Returns(importLists); Mocker.GetMock().Setup(c => c.All()).Returns(rootFolders); Mocker.GetMock().Setup(c => c.Get(profile.Id)).Returns(profile); @@ -126,7 +126,7 @@ namespace NzbDrone.Core.Test.Profiles .With(f => f.DefaultQualityProfileId = profile.Id) .BuildList(); - Mocker.GetMock().Setup(c => c.GetAllArtists()).Returns(artistList); + Mocker.GetMock().Setup(c => c.GetAllAuthors()).Returns(artistList); Mocker.GetMock().Setup(c => c.All()).Returns(importLists); Mocker.GetMock().Setup(c => c.All()).Returns(rootFolders); Mocker.GetMock().Setup(c => c.Get(profile.Id)).Returns(profile); @@ -154,7 +154,7 @@ namespace NzbDrone.Core.Test.Profiles .With(f => f.DefaultQualityProfileId = 2) .BuildList(); - Mocker.GetMock().Setup(c => c.GetAllArtists()).Returns(artistList); + Mocker.GetMock().Setup(c => c.GetAllAuthors()).Returns(artistList); Mocker.GetMock().Setup(c => c.All()).Returns(importLists); Mocker.GetMock().Setup(c => c.All()).Returns(rootFolders); diff --git a/src/NzbDrone.Core.Test/Profiles/Releases/PreferredWordService/CalculateFixture.cs b/src/NzbDrone.Core.Test/Profiles/Releases/PreferredWordService/CalculateFixture.cs index 6586f5fd5..29a99af2f 100644 --- a/src/NzbDrone.Core.Test/Profiles/Releases/PreferredWordService/CalculateFixture.cs +++ b/src/NzbDrone.Core.Test/Profiles/Releases/PreferredWordService/CalculateFixture.cs @@ -4,7 +4,7 @@ using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Profiles.Releases; using NzbDrone.Core.Test.Framework; diff --git a/src/NzbDrone.Core.Test/Profiles/Releases/PreferredWordService/GetMatchingPreferredWordsFixture.cs b/src/NzbDrone.Core.Test/Profiles/Releases/PreferredWordService/GetMatchingPreferredWordsFixture.cs index d78f3ac94..0f1cdc172 100644 --- a/src/NzbDrone.Core.Test/Profiles/Releases/PreferredWordService/GetMatchingPreferredWordsFixture.cs +++ b/src/NzbDrone.Core.Test/Profiles/Releases/PreferredWordService/GetMatchingPreferredWordsFixture.cs @@ -4,7 +4,7 @@ using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Profiles.Releases; using NzbDrone.Core.Test.Framework; diff --git a/src/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetAudioFilesFixture.cs b/src/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetAudioFilesFixture.cs index 6a18545f5..e4682b411 100644 --- a/src/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetAudioFilesFixture.cs +++ b/src/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetAudioFilesFixture.cs @@ -58,7 +58,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests [Test] public void should_check_all_directories() { - Subject.GetAudioFiles(_path); + Subject.GetBookFiles(_path); Mocker.GetMock().Verify(s => s.GetFileInfos(_path, SearchOption.AllDirectories), Times.Once()); Mocker.GetMock().Verify(s => s.GetFileInfos(_path, SearchOption.TopDirectoryOnly), Times.Never()); @@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests [Test] public void should_check_all_directories_when_allDirectories_is_true() { - Subject.GetAudioFiles(_path, true); + Subject.GetBookFiles(_path, true); Mocker.GetMock().Verify(s => s.GetFileInfos(_path, SearchOption.AllDirectories), Times.Once()); Mocker.GetMock().Verify(s => s.GetFileInfos(_path, SearchOption.TopDirectoryOnly), Times.Never()); @@ -76,7 +76,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests [Test] public void should_check_top_level_directory_only_when_allDirectories_is_false() { - Subject.GetAudioFiles(_path, false); + Subject.GetBookFiles(_path, false); Mocker.GetMock().Verify(s => s.GetFileInfos(_path, SearchOption.AllDirectories), Times.Never()); Mocker.GetMock().Verify(s => s.GetFileInfos(_path, SearchOption.TopDirectoryOnly), Times.Once()); @@ -87,7 +87,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests { GivenFiles(GetFiles(_path)); - Subject.GetAudioFiles(_path).Should().HaveCount(3); + Subject.GetBookFiles(_path).Should().HaveCount(3); } [TestCase("Extras")] diff --git a/src/NzbDrone.Core.Test/QueueTests/QueueServiceFixture.cs b/src/NzbDrone.Core.Test/QueueTests/QueueServiceFixture.cs index 4f7ae4df0..dbb7e51ff 100644 --- a/src/NzbDrone.Core.Test/QueueTests/QueueServiceFixture.cs +++ b/src/NzbDrone.Core.Test/QueueTests/QueueServiceFixture.cs @@ -5,9 +5,9 @@ using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.Books; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.History; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Queue; using NzbDrone.Core.Test.Framework; @@ -34,16 +34,16 @@ namespace NzbDrone.Core.Test.QueueTests .With(e => e.AuthorId = artist.Id) .Build(); - var remoteAlbum = Builder.CreateNew() - .With(r => r.Artist = artist) - .With(r => r.Albums = new List(albums)) - .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo()) + var remoteAlbum = Builder.CreateNew() + .With(r => r.Author = artist) + .With(r => r.Books = new List(albums)) + .With(r => r.ParsedBookInfo = new ParsedBookInfo()) .Build(); _trackedDownloads = Builder.CreateListOfSize(1) .All() .With(v => v.DownloadItem = downloadItem) - .With(v => v.RemoteAlbum = remoteAlbum) + .With(v => v.RemoteBook = remoteAlbum) .Build() .ToList(); diff --git a/src/NzbDrone.Core.Test/RootFolderTests/RootFolderServiceFixture.cs b/src/NzbDrone.Core.Test/RootFolderTests/RootFolderServiceFixture.cs index 375bd4a6c..5d6b71d74 100644 --- a/src/NzbDrone.Core.Test/RootFolderTests/RootFolderServiceFixture.cs +++ b/src/NzbDrone.Core.Test/RootFolderTests/RootFolderServiceFixture.cs @@ -7,7 +7,7 @@ using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.RootFolders; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; diff --git a/src/NzbDrone.Core.Test/ValidationTests/SystemFolderValidatorFixture.cs b/src/NzbDrone.Core.Test/ValidationTests/SystemFolderValidatorFixture.cs index 168cae893..71d39a36b 100644 --- a/src/NzbDrone.Core.Test/ValidationTests/SystemFolderValidatorFixture.cs +++ b/src/NzbDrone.Core.Test/ValidationTests/SystemFolderValidatorFixture.cs @@ -4,7 +4,7 @@ using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; using NzbDrone.Common.EnvironmentInfo; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Validation.Paths; using NzbDrone.Test.Common; diff --git a/src/NzbDrone.Core/ArtistStats/AlbumStatistics.cs b/src/NzbDrone.Core/ArtistStats/AlbumStatistics.cs deleted file mode 100644 index 3c81e1297..000000000 --- a/src/NzbDrone.Core/ArtistStats/AlbumStatistics.cs +++ /dev/null @@ -1,15 +0,0 @@ -using NzbDrone.Core.Datastore; - -namespace NzbDrone.Core.ArtistStats -{ - public class AlbumStatistics : ResultSet - { - public int AuthorId { get; set; } - public int BookId { get; set; } - public int TrackFileCount { get; set; } - public int TrackCount { get; set; } - public int AvailableTrackCount { get; set; } - public int TotalTrackCount { get; set; } - public long SizeOnDisk { get; set; } - } -} diff --git a/src/NzbDrone.Core/ArtistStats/ArtistStatistics.cs b/src/NzbDrone.Core/ArtistStats/ArtistStatistics.cs deleted file mode 100644 index 71a5394f9..000000000 --- a/src/NzbDrone.Core/ArtistStats/ArtistStatistics.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections.Generic; -using NzbDrone.Core.Datastore; - -namespace NzbDrone.Core.ArtistStats -{ - public class ArtistStatistics : ResultSet - { - public int AuthorId { get; set; } - public int AlbumCount { get; set; } - public int TrackFileCount { get; set; } - public int TrackCount { get; set; } - public int TotalTrackCount { get; set; } - public long SizeOnDisk { get; set; } - public List AlbumStatistics { get; set; } - } -} diff --git a/src/NzbDrone.Core/ArtistStats/ArtistStatisticsService.cs b/src/NzbDrone.Core/ArtistStats/ArtistStatisticsService.cs deleted file mode 100644 index ebfe6e60d..000000000 --- a/src/NzbDrone.Core/ArtistStats/ArtistStatisticsService.cs +++ /dev/null @@ -1,120 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using NzbDrone.Common.Cache; -using NzbDrone.Core.MediaFiles.Events; -using NzbDrone.Core.Messaging; -using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music.Events; - -namespace NzbDrone.Core.ArtistStats -{ - public interface IArtistStatisticsService - { - List ArtistStatistics(); - ArtistStatistics ArtistStatistics(int authorId); - } - - public class ArtistStatisticsService : IArtistStatisticsService, - IHandle, - IHandle, - IHandle, - IHandle, - IHandle, - IHandle, - IHandle - { - private readonly IArtistStatisticsRepository _artistStatisticsRepository; - private readonly ICached> _cache; - - public ArtistStatisticsService(IArtistStatisticsRepository artistStatisticsRepository, - ICacheManager cacheManager) - { - _artistStatisticsRepository = artistStatisticsRepository; - _cache = cacheManager.GetCache>(GetType()); - } - - public List ArtistStatistics() - { - var albumStatistics = _cache.Get("AllArtists", () => _artistStatisticsRepository.ArtistStatistics()); - - return albumStatistics.GroupBy(s => s.AuthorId).Select(s => MapArtistStatistics(s.ToList())).ToList(); - } - - public ArtistStatistics ArtistStatistics(int authorId) - { - var stats = _cache.Get(authorId.ToString(), () => _artistStatisticsRepository.ArtistStatistics(authorId)); - - if (stats == null || stats.Count == 0) - { - return new ArtistStatistics(); - } - - return MapArtistStatistics(stats); - } - - private ArtistStatistics MapArtistStatistics(List albumStatistics) - { - var artistStatistics = new ArtistStatistics - { - AlbumStatistics = albumStatistics, - AlbumCount = albumStatistics.Count, - AuthorId = albumStatistics.First().AuthorId, - TrackFileCount = albumStatistics.Sum(s => s.TrackFileCount), - TrackCount = albumStatistics.Sum(s => s.TrackCount), - TotalTrackCount = albumStatistics.Sum(s => s.TotalTrackCount), - SizeOnDisk = albumStatistics.Sum(s => s.SizeOnDisk) - }; - - return artistStatistics; - } - - [EventHandleOrder(EventHandleOrder.First)] - public void Handle(ArtistUpdatedEvent message) - { - _cache.Remove("AllArtists"); - _cache.Remove(message.Artist.Id.ToString()); - } - - [EventHandleOrder(EventHandleOrder.First)] - public void Handle(ArtistDeletedEvent message) - { - _cache.Remove("AllArtists"); - _cache.Remove(message.Artist.Id.ToString()); - } - - [EventHandleOrder(EventHandleOrder.First)] - public void Handle(AlbumAddedEvent message) - { - _cache.Remove("AllArtists"); - _cache.Remove(message.Album.AuthorId.ToString()); - } - - [EventHandleOrder(EventHandleOrder.First)] - public void Handle(AlbumDeletedEvent message) - { - _cache.Remove("AllArtists"); - _cache.Remove(message.Album.AuthorId.ToString()); - } - - [EventHandleOrder(EventHandleOrder.First)] - public void Handle(AlbumImportedEvent message) - { - _cache.Remove("AllArtists"); - _cache.Remove(message.Artist.Id.ToString()); - } - - [EventHandleOrder(EventHandleOrder.First)] - public void Handle(AlbumEditedEvent message) - { - _cache.Remove("AllArtists"); - _cache.Remove(message.Album.AuthorId.ToString()); - } - - [EventHandleOrder(EventHandleOrder.First)] - public void Handle(TrackFileDeletedEvent message) - { - _cache.Remove("AllArtists"); - _cache.Remove(message.TrackFile.Artist.Value.Id.ToString()); - } - } -} diff --git a/src/NzbDrone.Core/AuthorStats/AuthorStatistics.cs b/src/NzbDrone.Core/AuthorStats/AuthorStatistics.cs new file mode 100644 index 000000000..027e0a2ee --- /dev/null +++ b/src/NzbDrone.Core/AuthorStats/AuthorStatistics.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using NzbDrone.Core.Datastore; + +namespace NzbDrone.Core.AuthorStats +{ + public class AuthorStatistics : ResultSet + { + public int AuthorId { get; set; } + public int BookCount { get; set; } + public int BookFileCount { get; set; } + public long SizeOnDisk { get; set; } + public List BookStatistics { get; set; } + } +} diff --git a/src/NzbDrone.Core/ArtistStats/ArtistStatisticsRepository.cs b/src/NzbDrone.Core/AuthorStats/AuthorStatisticsRepository.cs similarity index 62% rename from src/NzbDrone.Core/ArtistStats/ArtistStatisticsRepository.cs rename to src/NzbDrone.Core/AuthorStats/AuthorStatisticsRepository.cs index e5590da56..1fec6a273 100644 --- a/src/NzbDrone.Core/ArtistStats/ArtistStatisticsRepository.cs +++ b/src/NzbDrone.Core/AuthorStats/AuthorStatisticsRepository.cs @@ -2,49 +2,49 @@ using System; using System.Collections.Generic; using System.Linq; using Dapper; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; -namespace NzbDrone.Core.ArtistStats +namespace NzbDrone.Core.AuthorStats { - public interface IArtistStatisticsRepository + public interface IAuthorStatisticsRepository { - List ArtistStatistics(); - List ArtistStatistics(int authorId); + List AuthorStatistics(); + List AuthorStatistics(int authorId); } - public class ArtistStatisticsRepository : IArtistStatisticsRepository + public class AuthorStatisticsRepository : IAuthorStatisticsRepository { private const string _selectTemplate = "SELECT /**select**/ FROM Books /**join**/ /**innerjoin**/ /**leftjoin**/ /**where**/ /**groupby**/ /**having**/ /**orderby**/"; private readonly IMainDatabase _database; - public ArtistStatisticsRepository(IMainDatabase database) + public AuthorStatisticsRepository(IMainDatabase database) { _database = database; } - public List ArtistStatistics() + public List AuthorStatistics() { var time = DateTime.UtcNow; return Query(Builder().Where(x => x.ReleaseDate < time)); } - public List ArtistStatistics(int authorId) + public List AuthorStatistics(int authorId) { var time = DateTime.UtcNow; return Query(Builder().Where(x => x.ReleaseDate < time) .Where(x => x.Id == authorId)); } - private List Query(SqlBuilder builder) + private List Query(SqlBuilder builder) { var sql = builder.AddTemplate(_selectTemplate).LogQuery(); using (var conn = _database.OpenConnection()) { - return conn.Query(sql.RawSql, sql.Parameters).ToList(); + return conn.Query(sql.RawSql, sql.Parameters).ToList(); } } @@ -52,11 +52,11 @@ namespace NzbDrone.Core.ArtistStats .Select(@"Authors.Id AS AuthorId, Books.Id AS BookId, SUM(COALESCE(BookFiles.Size, 0)) AS SizeOnDisk, - COUNT(Books.Id) AS TotalTrackCount, - SUM(CASE WHEN BookFiles.Id IS NULL THEN 0 ELSE 1 END) AS AvailableTrackCount, - SUM(CASE WHEN Books.Monitored = 1 OR BookFiles.Id IS NOT NULL THEN 1 ELSE 0 END) AS TrackCount, - SUM(CASE WHEN BookFiles.Id IS NULL THEN 0 ELSE 1 END) AS TrackFileCount") - .Join((album, artist) => album.AuthorMetadataId == artist.AuthorMetadataId) + COUNT(Books.Id) AS TotalBookCount, + SUM(CASE WHEN BookFiles.Id IS NULL THEN 0 ELSE 1 END) AS AvailableBookCount, + SUM(CASE WHEN Books.Monitored = 1 OR BookFiles.Id IS NOT NULL THEN 1 ELSE 0 END) AS BookCount, + SUM(CASE WHEN BookFiles.Id IS NULL THEN 0 ELSE 1 END) AS BookFileCount") + .Join((book, author) => book.AuthorMetadataId == author.AuthorMetadataId) .LeftJoin((t, f) => t.Id == f.BookId) .GroupBy(x => x.Id) .GroupBy(x => x.Id); diff --git a/src/NzbDrone.Core/AuthorStats/AuthorStatisticsService.cs b/src/NzbDrone.Core/AuthorStats/AuthorStatisticsService.cs new file mode 100644 index 000000000..77d4bb947 --- /dev/null +++ b/src/NzbDrone.Core/AuthorStats/AuthorStatisticsService.cs @@ -0,0 +1,118 @@ +using System.Collections.Generic; +using System.Linq; +using NzbDrone.Common.Cache; +using NzbDrone.Core.Books.Events; +using NzbDrone.Core.MediaFiles.Events; +using NzbDrone.Core.Messaging; +using NzbDrone.Core.Messaging.Events; + +namespace NzbDrone.Core.AuthorStats +{ + public interface IAuthorStatisticsService + { + List AuthorStatistics(); + AuthorStatistics AuthorStatistics(int authorId); + } + + public class AuthorStatisticsService : IAuthorStatisticsService, + IHandle, + IHandle, + IHandle, + IHandle, + IHandle, + IHandle, + IHandle + { + private readonly IAuthorStatisticsRepository _authorStatisticsRepository; + private readonly ICached> _cache; + + public AuthorStatisticsService(IAuthorStatisticsRepository authorStatisticsRepository, + ICacheManager cacheManager) + { + _authorStatisticsRepository = authorStatisticsRepository; + _cache = cacheManager.GetCache>(GetType()); + } + + public List AuthorStatistics() + { + var bookStatistics = _cache.Get("AllAuthors", () => _authorStatisticsRepository.AuthorStatistics()); + + return bookStatistics.GroupBy(s => s.AuthorId).Select(s => MapArtistStatistics(s.ToList())).ToList(); + } + + public AuthorStatistics AuthorStatistics(int authorId) + { + var stats = _cache.Get(authorId.ToString(), () => _authorStatisticsRepository.AuthorStatistics(authorId)); + + if (stats == null || stats.Count == 0) + { + return new AuthorStatistics(); + } + + return MapArtistStatistics(stats); + } + + private AuthorStatistics MapArtistStatistics(List bookStatistics) + { + var authorStatistics = new AuthorStatistics + { + BookStatistics = bookStatistics, + BookCount = bookStatistics.Sum(s => s.BookCount), + AuthorId = bookStatistics.First().AuthorId, + BookFileCount = bookStatistics.Sum(s => s.BookFileCount), + SizeOnDisk = bookStatistics.Sum(s => s.SizeOnDisk) + }; + + return authorStatistics; + } + + [EventHandleOrder(EventHandleOrder.First)] + public void Handle(AuthorUpdatedEvent message) + { + _cache.Remove("AllAuthors"); + _cache.Remove(message.Author.Id.ToString()); + } + + [EventHandleOrder(EventHandleOrder.First)] + public void Handle(AuthorDeletedEvent message) + { + _cache.Remove("AllAuthors"); + _cache.Remove(message.Author.Id.ToString()); + } + + [EventHandleOrder(EventHandleOrder.First)] + public void Handle(BookAddedEvent message) + { + _cache.Remove("AllAuthors"); + _cache.Remove(message.Book.AuthorId.ToString()); + } + + [EventHandleOrder(EventHandleOrder.First)] + public void Handle(BookDeletedEvent message) + { + _cache.Remove("AllAuthors"); + _cache.Remove(message.Book.AuthorId.ToString()); + } + + [EventHandleOrder(EventHandleOrder.First)] + public void Handle(BookImportedEvent message) + { + _cache.Remove("AllAuthors"); + _cache.Remove(message.Author.Id.ToString()); + } + + [EventHandleOrder(EventHandleOrder.First)] + public void Handle(BookEditedEvent message) + { + _cache.Remove("AllAuthors"); + _cache.Remove(message.Album.AuthorId.ToString()); + } + + [EventHandleOrder(EventHandleOrder.First)] + public void Handle(BookFileDeletedEvent message) + { + _cache.Remove("AllAuthors"); + _cache.Remove(message.BookFile.Author.Value.Id.ToString()); + } + } +} diff --git a/src/NzbDrone.Core/AuthorStats/BookStatistics.cs b/src/NzbDrone.Core/AuthorStats/BookStatistics.cs new file mode 100644 index 000000000..3e5f1b9a5 --- /dev/null +++ b/src/NzbDrone.Core/AuthorStats/BookStatistics.cs @@ -0,0 +1,13 @@ +using NzbDrone.Core.Datastore; + +namespace NzbDrone.Core.AuthorStats +{ + public class BookStatistics : ResultSet + { + public int AuthorId { get; set; } + public int BookId { get; set; } + public int BookFileCount { get; set; } + public int BookCount { get; set; } + public long SizeOnDisk { get; set; } + } +} diff --git a/src/NzbDrone.Core/Blacklisting/Blacklist.cs b/src/NzbDrone.Core/Blacklisting/Blacklist.cs index 1cd7a5199..ef26bf86f 100644 --- a/src/NzbDrone.Core/Blacklisting/Blacklist.cs +++ b/src/NzbDrone.Core/Blacklisting/Blacklist.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.Indexers; -using NzbDrone.Core.Music; using NzbDrone.Core.Qualities; namespace NzbDrone.Core.Blacklisting @@ -10,7 +10,7 @@ namespace NzbDrone.Core.Blacklisting public class Blacklist : ModelBase { public int AuthorId { get; set; } - public Author Artist { get; set; } + public Author Author { get; set; } public List BookIds { get; set; } public string SourceTitle { get; set; } public QualityModel Quality { get; set; } diff --git a/src/NzbDrone.Core/Blacklisting/BlacklistRepository.cs b/src/NzbDrone.Core/Blacklisting/BlacklistRepository.cs index b5e452c21..d82686169 100644 --- a/src/NzbDrone.Core/Blacklisting/BlacklistRepository.cs +++ b/src/NzbDrone.Core/Blacklisting/BlacklistRepository.cs @@ -1,8 +1,8 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Dapper; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; namespace NzbDrone.Core.Blacklisting { @@ -36,9 +36,9 @@ namespace NzbDrone.Core.Blacklisting } protected override SqlBuilder PagedBuilder() => new SqlBuilder().Join((b, m) => b.AuthorId == m.Id); - protected override IEnumerable PagedQuery(SqlBuilder builder) => _database.QueryJoined(builder, (bl, artist) => + protected override IEnumerable PagedQuery(SqlBuilder builder) => _database.QueryJoined(builder, (bl, author) => { - bl.Artist = artist; + bl.Author = author; return bl; }); } diff --git a/src/NzbDrone.Core/Blacklisting/BlacklistService.cs b/src/NzbDrone.Core/Blacklisting/BlacklistService.cs index c9a363287..9ce467b9e 100644 --- a/src/NzbDrone.Core/Blacklisting/BlacklistService.cs +++ b/src/NzbDrone.Core/Blacklisting/BlacklistService.cs @@ -2,12 +2,12 @@ using System; using System.Collections.Generic; using System.Linq; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books.Events; using NzbDrone.Core.Datastore; using NzbDrone.Core.Download; using NzbDrone.Core.Indexers; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music.Events; using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.Blacklisting @@ -23,7 +23,7 @@ namespace NzbDrone.Core.Blacklisting IExecute, IHandle, - IHandleAsync + IHandleAsync { private readonly IBlacklistRepository _blacklistRepository; @@ -155,9 +155,9 @@ namespace NzbDrone.Core.Blacklisting _blacklistRepository.Insert(blacklist); } - public void HandleAsync(ArtistDeletedEvent message) + public void HandleAsync(AuthorDeletedEvent message) { - var blacklisted = _blacklistRepository.BlacklistedByArtist(message.Artist.Id); + var blacklisted = _blacklistRepository.BlacklistedByArtist(message.Author.Id); _blacklistRepository.DeleteMany(blacklisted); } diff --git a/src/NzbDrone.Core/Books/Calibre/CalibreProxy.cs b/src/NzbDrone.Core/Books/Calibre/CalibreProxy.cs index 8688bbdcc..0de8806ed 100644 --- a/src/NzbDrone.Core/Books/Calibre/CalibreProxy.cs +++ b/src/NzbDrone.Core/Books/Calibre/CalibreProxy.cs @@ -117,13 +117,13 @@ namespace NzbDrone.Core.Books.Calibre public void SetFields(BookFile file, CalibreSettings settings) { - var book = file.Album.Value; + var book = file.Book.Value; var cover = book.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Cover); string image = null; if (cover != null) { - var imageFile = _mediaCoverService.GetCoverPath(book.Id, MediaCoverEntity.Album, cover.CoverType, cover.Extension, null); + var imageFile = _mediaCoverService.GetCoverPath(book.Id, MediaCoverEntity.Book, cover.CoverType, cover.Extension, null); if (File.Exists(imageFile)) { @@ -137,7 +137,7 @@ namespace NzbDrone.Core.Books.Calibre changes = new { title = book.Title, - authors = new[] { file.Artist.Value.Name }, + authors = new[] { file.Author.Value.Name }, cover = image, pubdate = book.ReleaseDate, comments = book.Overview, diff --git a/src/NzbDrone.Core/Books/Commands/BulkMoveArtistCommand.cs b/src/NzbDrone.Core/Books/Commands/BulkMoveAuthorCommand.cs similarity index 74% rename from src/NzbDrone.Core/Books/Commands/BulkMoveArtistCommand.cs rename to src/NzbDrone.Core/Books/Commands/BulkMoveAuthorCommand.cs index 7895a6f51..702a50a65 100644 --- a/src/NzbDrone.Core/Books/Commands/BulkMoveArtistCommand.cs +++ b/src/NzbDrone.Core/Books/Commands/BulkMoveAuthorCommand.cs @@ -2,23 +2,23 @@ using System; using System.Collections.Generic; using NzbDrone.Core.Messaging.Commands; -namespace NzbDrone.Core.Music.Commands +namespace NzbDrone.Core.Books.Commands { - public class BulkMoveArtistCommand : Command + public class BulkMoveAuthorCommand : Command { - public List Artist { get; set; } + public List Author { get; set; } public string DestinationRootFolder { get; set; } public override bool SendUpdatesToClient => true; public override bool RequiresDiskAccess => true; } - public class BulkMoveArtist : IEquatable + public class BulkMoveAuthor : IEquatable { public int AuthorId { get; set; } public string SourcePath { get; set; } - public bool Equals(BulkMoveArtist other) + public bool Equals(BulkMoveAuthor other) { if (other == null) { @@ -40,7 +40,7 @@ namespace NzbDrone.Core.Music.Commands return false; } - return AuthorId.Equals(((BulkMoveArtist)obj).AuthorId); + return AuthorId.Equals(((BulkMoveAuthor)obj).AuthorId); } public override int GetHashCode() diff --git a/src/NzbDrone.Core/Books/Commands/BulkRefreshArtistCommand.cs b/src/NzbDrone.Core/Books/Commands/BulkRefreshAuthorCommand.cs similarity index 51% rename from src/NzbDrone.Core/Books/Commands/BulkRefreshArtistCommand.cs rename to src/NzbDrone.Core/Books/Commands/BulkRefreshAuthorCommand.cs index 63d077596..2b5ed4993 100644 --- a/src/NzbDrone.Core/Books/Commands/BulkRefreshArtistCommand.cs +++ b/src/NzbDrone.Core/Books/Commands/BulkRefreshAuthorCommand.cs @@ -1,22 +1,22 @@ using System.Collections.Generic; using NzbDrone.Core.Messaging.Commands; -namespace NzbDrone.Core.Music.Commands +namespace NzbDrone.Core.Books.Commands { - public class BulkRefreshArtistCommand : Command + public class BulkRefreshAuthorCommand : Command { - public BulkRefreshArtistCommand() + public BulkRefreshAuthorCommand() { } - public BulkRefreshArtistCommand(List authorIds, bool areNewArtists = false) + public BulkRefreshAuthorCommand(List authorIds, bool areNewAuthors = false) { AuthorIds = authorIds; - AreNewArtists = areNewArtists; + AreNewAuthors = areNewAuthors; } public List AuthorIds { get; set; } - public bool AreNewArtists { get; set; } + public bool AreNewAuthors { get; set; } public override bool SendUpdatesToClient => true; diff --git a/src/NzbDrone.Core/Books/Commands/MoveArtistCommand.cs b/src/NzbDrone.Core/Books/Commands/MoveAuthorCommand.cs similarity index 78% rename from src/NzbDrone.Core/Books/Commands/MoveArtistCommand.cs rename to src/NzbDrone.Core/Books/Commands/MoveAuthorCommand.cs index 7e7dc5f8a..273b9e3a7 100644 --- a/src/NzbDrone.Core/Books/Commands/MoveArtistCommand.cs +++ b/src/NzbDrone.Core/Books/Commands/MoveAuthorCommand.cs @@ -1,8 +1,8 @@ using NzbDrone.Core.Messaging.Commands; -namespace NzbDrone.Core.Music.Commands +namespace NzbDrone.Core.Books.Commands { - public class MoveArtistCommand : Command + public class MoveAuthorCommand : Command { public int AuthorId { get; set; } public string SourcePath { get; set; } diff --git a/src/NzbDrone.Core/Books/Commands/RefreshArtistCommand.cs b/src/NzbDrone.Core/Books/Commands/RefreshAuthorCommand.cs similarity index 51% rename from src/NzbDrone.Core/Books/Commands/RefreshArtistCommand.cs rename to src/NzbDrone.Core/Books/Commands/RefreshAuthorCommand.cs index 86825d49d..8a8dba62a 100644 --- a/src/NzbDrone.Core/Books/Commands/RefreshArtistCommand.cs +++ b/src/NzbDrone.Core/Books/Commands/RefreshAuthorCommand.cs @@ -1,20 +1,20 @@ using NzbDrone.Core.Messaging.Commands; -namespace NzbDrone.Core.Music.Commands +namespace NzbDrone.Core.Books.Commands { - public class RefreshArtistCommand : Command + public class RefreshAuthorCommand : Command { public int? AuthorId { get; set; } - public bool IsNewArtist { get; set; } + public bool IsNewAuthor { get; set; } - public RefreshArtistCommand() + public RefreshAuthorCommand() { } - public RefreshArtistCommand(int? authorId, bool isNewArtist = false) + public RefreshAuthorCommand(int? authorId, bool isNewAuthor = false) { AuthorId = authorId; - IsNewArtist = isNewArtist; + IsNewAuthor = isNewAuthor; } public override bool SendUpdatesToClient => true; diff --git a/src/NzbDrone.Core/Books/Commands/RefreshAlbumCommand.cs b/src/NzbDrone.Core/Books/Commands/RefreshBookCommand.cs similarity index 63% rename from src/NzbDrone.Core/Books/Commands/RefreshAlbumCommand.cs rename to src/NzbDrone.Core/Books/Commands/RefreshBookCommand.cs index 9db176a0f..2e10adf81 100644 --- a/src/NzbDrone.Core/Books/Commands/RefreshAlbumCommand.cs +++ b/src/NzbDrone.Core/Books/Commands/RefreshBookCommand.cs @@ -1,16 +1,16 @@ using NzbDrone.Core.Messaging.Commands; -namespace NzbDrone.Core.Music.Commands +namespace NzbDrone.Core.Books.Commands { - public class RefreshAlbumCommand : Command + public class RefreshBookCommand : Command { public int? BookId { get; set; } - public RefreshAlbumCommand() + public RefreshBookCommand() { } - public RefreshAlbumCommand(int? bookId) + public RefreshBookCommand(int? bookId) { BookId = bookId; } diff --git a/src/NzbDrone.Core/Books/Events/AlbumAddedEvent.cs b/src/NzbDrone.Core/Books/Events/AlbumAddedEvent.cs deleted file mode 100644 index 50ca77b43..000000000 --- a/src/NzbDrone.Core/Books/Events/AlbumAddedEvent.cs +++ /dev/null @@ -1,16 +0,0 @@ -using NzbDrone.Common.Messaging; - -namespace NzbDrone.Core.Music.Events -{ - public class AlbumAddedEvent : IEvent - { - public Book Album { get; private set; } - public bool DoRefresh { get; private set; } - - public AlbumAddedEvent(Book album, bool doRefresh = true) - { - Album = album; - DoRefresh = doRefresh; - } - } -} diff --git a/src/NzbDrone.Core/Books/Events/AlbumUpdatedEvent.cs b/src/NzbDrone.Core/Books/Events/AlbumUpdatedEvent.cs deleted file mode 100644 index 359ac3e9d..000000000 --- a/src/NzbDrone.Core/Books/Events/AlbumUpdatedEvent.cs +++ /dev/null @@ -1,14 +0,0 @@ -using NzbDrone.Common.Messaging; - -namespace NzbDrone.Core.Music.Events -{ - public class AlbumUpdatedEvent : IEvent - { - public Book Album { get; private set; } - - public AlbumUpdatedEvent(Book album) - { - Album = album; - } - } -} diff --git a/src/NzbDrone.Core/Books/Events/ArtistAddedEvent.cs b/src/NzbDrone.Core/Books/Events/ArtistAddedEvent.cs deleted file mode 100644 index e8e419d3d..000000000 --- a/src/NzbDrone.Core/Books/Events/ArtistAddedEvent.cs +++ /dev/null @@ -1,16 +0,0 @@ -using NzbDrone.Common.Messaging; - -namespace NzbDrone.Core.Music.Events -{ - public class ArtistAddedEvent : IEvent - { - public Author Artist { get; private set; } - public bool DoRefresh { get; private set; } - - public ArtistAddedEvent(Author artist, bool doRefresh = true) - { - Artist = artist; - DoRefresh = doRefresh; - } - } -} diff --git a/src/NzbDrone.Core/Books/Events/ArtistEditedEvent.cs b/src/NzbDrone.Core/Books/Events/ArtistEditedEvent.cs deleted file mode 100644 index 317cd7222..000000000 --- a/src/NzbDrone.Core/Books/Events/ArtistEditedEvent.cs +++ /dev/null @@ -1,16 +0,0 @@ -using NzbDrone.Common.Messaging; - -namespace NzbDrone.Core.Music.Events -{ - public class ArtistEditedEvent : IEvent - { - public Author Artist { get; private set; } - public Author OldArtist { get; private set; } - - public ArtistEditedEvent(Author artist, Author oldArtist) - { - Artist = artist; - OldArtist = oldArtist; - } - } -} diff --git a/src/NzbDrone.Core/Books/Events/ArtistMovedEvent.cs b/src/NzbDrone.Core/Books/Events/ArtistMovedEvent.cs deleted file mode 100644 index 56bfa6270..000000000 --- a/src/NzbDrone.Core/Books/Events/ArtistMovedEvent.cs +++ /dev/null @@ -1,18 +0,0 @@ -using NzbDrone.Common.Messaging; - -namespace NzbDrone.Core.Music.Events -{ - public class ArtistMovedEvent : IEvent - { - public Author Artist { get; set; } - public string SourcePath { get; set; } - public string DestinationPath { get; set; } - - public ArtistMovedEvent(Author artist, string sourcePath, string destinationPath) - { - Artist = artist; - SourcePath = sourcePath; - DestinationPath = destinationPath; - } - } -} diff --git a/src/NzbDrone.Core/Books/Events/ArtistRefreshCompleteEvent.cs b/src/NzbDrone.Core/Books/Events/ArtistRefreshCompleteEvent.cs deleted file mode 100644 index 1c0680a67..000000000 --- a/src/NzbDrone.Core/Books/Events/ArtistRefreshCompleteEvent.cs +++ /dev/null @@ -1,14 +0,0 @@ -using NzbDrone.Common.Messaging; - -namespace NzbDrone.Core.Music.Events -{ - public class ArtistRefreshCompleteEvent : IEvent - { - public Author Artist { get; set; } - - public ArtistRefreshCompleteEvent(Author artist) - { - Artist = artist; - } - } -} diff --git a/src/NzbDrone.Core/Books/Events/ArtistUpdatedEvent.cs b/src/NzbDrone.Core/Books/Events/ArtistUpdatedEvent.cs deleted file mode 100644 index 62e9c50c1..000000000 --- a/src/NzbDrone.Core/Books/Events/ArtistUpdatedEvent.cs +++ /dev/null @@ -1,14 +0,0 @@ -using NzbDrone.Common.Messaging; - -namespace NzbDrone.Core.Music.Events -{ - public class ArtistUpdatedEvent : IEvent - { - public Author Artist { get; private set; } - - public ArtistUpdatedEvent(Author artist) - { - Artist = artist; - } - } -} diff --git a/src/NzbDrone.Core/Books/Events/AuthorAddedEvent.cs b/src/NzbDrone.Core/Books/Events/AuthorAddedEvent.cs new file mode 100644 index 000000000..d4982b548 --- /dev/null +++ b/src/NzbDrone.Core/Books/Events/AuthorAddedEvent.cs @@ -0,0 +1,16 @@ +using NzbDrone.Common.Messaging; + +namespace NzbDrone.Core.Books.Events +{ + public class AuthorAddedEvent : IEvent + { + public Author Author { get; private set; } + public bool DoRefresh { get; private set; } + + public AuthorAddedEvent(Author author, bool doRefresh = true) + { + Author = author; + DoRefresh = doRefresh; + } + } +} diff --git a/src/NzbDrone.Core/Books/Events/ArtistDeletedEvent.cs b/src/NzbDrone.Core/Books/Events/AuthorDeletedEvent.cs similarity index 58% rename from src/NzbDrone.Core/Books/Events/ArtistDeletedEvent.cs rename to src/NzbDrone.Core/Books/Events/AuthorDeletedEvent.cs index 7cd120fc2..fd35da1b2 100644 --- a/src/NzbDrone.Core/Books/Events/ArtistDeletedEvent.cs +++ b/src/NzbDrone.Core/Books/Events/AuthorDeletedEvent.cs @@ -1,16 +1,16 @@ using NzbDrone.Common.Messaging; -namespace NzbDrone.Core.Music.Events +namespace NzbDrone.Core.Books.Events { - public class ArtistDeletedEvent : IEvent + public class AuthorDeletedEvent : IEvent { - public Author Artist { get; private set; } + public Author Author { get; private set; } public bool DeleteFiles { get; private set; } public bool AddImportListExclusion { get; private set; } - public ArtistDeletedEvent(Author artist, bool deleteFiles, bool addImportListExclusion) + public AuthorDeletedEvent(Author author, bool deleteFiles, bool addImportListExclusion) { - Artist = artist; + Author = author; DeleteFiles = deleteFiles; AddImportListExclusion = addImportListExclusion; } diff --git a/src/NzbDrone.Core/Books/Events/AuthorEditedEvent.cs b/src/NzbDrone.Core/Books/Events/AuthorEditedEvent.cs new file mode 100644 index 000000000..bfd3f8b73 --- /dev/null +++ b/src/NzbDrone.Core/Books/Events/AuthorEditedEvent.cs @@ -0,0 +1,16 @@ +using NzbDrone.Common.Messaging; + +namespace NzbDrone.Core.Books.Events +{ + public class AuthorEditedEvent : IEvent + { + public Author Author { get; private set; } + public Author OldAuthor { get; private set; } + + public AuthorEditedEvent(Author author, Author oldAuthor) + { + Author = author; + OldAuthor = oldAuthor; + } + } +} diff --git a/src/NzbDrone.Core/Books/Events/AuthorMovedEvent.cs b/src/NzbDrone.Core/Books/Events/AuthorMovedEvent.cs new file mode 100644 index 000000000..1dbf1fbdd --- /dev/null +++ b/src/NzbDrone.Core/Books/Events/AuthorMovedEvent.cs @@ -0,0 +1,18 @@ +using NzbDrone.Common.Messaging; + +namespace NzbDrone.Core.Books.Events +{ + public class AuthorMovedEvent : IEvent + { + public Author Author { get; set; } + public string SourcePath { get; set; } + public string DestinationPath { get; set; } + + public AuthorMovedEvent(Author author, string sourcePath, string destinationPath) + { + Author = author; + SourcePath = sourcePath; + DestinationPath = destinationPath; + } + } +} diff --git a/src/NzbDrone.Core/Books/Events/AuthorRefreshCompleteEvent.cs b/src/NzbDrone.Core/Books/Events/AuthorRefreshCompleteEvent.cs new file mode 100644 index 000000000..412ab3ea5 --- /dev/null +++ b/src/NzbDrone.Core/Books/Events/AuthorRefreshCompleteEvent.cs @@ -0,0 +1,14 @@ +using NzbDrone.Common.Messaging; + +namespace NzbDrone.Core.Books.Events +{ + public class AuthorRefreshCompleteEvent : IEvent + { + public Author Author { get; set; } + + public AuthorRefreshCompleteEvent(Author author) + { + Author = author; + } + } +} diff --git a/src/NzbDrone.Core/Books/Events/AuthorUpdatedEvent.cs b/src/NzbDrone.Core/Books/Events/AuthorUpdatedEvent.cs new file mode 100644 index 000000000..867219b04 --- /dev/null +++ b/src/NzbDrone.Core/Books/Events/AuthorUpdatedEvent.cs @@ -0,0 +1,14 @@ +using NzbDrone.Common.Messaging; + +namespace NzbDrone.Core.Books.Events +{ + public class AuthorUpdatedEvent : IEvent + { + public Author Author { get; private set; } + + public AuthorUpdatedEvent(Author author) + { + Author = author; + } + } +} diff --git a/src/NzbDrone.Core/Books/Events/ArtistsImportedEvent.cs b/src/NzbDrone.Core/Books/Events/AuthorsImportedEvent.cs similarity index 66% rename from src/NzbDrone.Core/Books/Events/ArtistsImportedEvent.cs rename to src/NzbDrone.Core/Books/Events/AuthorsImportedEvent.cs index 2a7fcbaf9..7bdd96dfb 100644 --- a/src/NzbDrone.Core/Books/Events/ArtistsImportedEvent.cs +++ b/src/NzbDrone.Core/Books/Events/AuthorsImportedEvent.cs @@ -1,14 +1,14 @@ using System.Collections.Generic; using NzbDrone.Common.Messaging; -namespace NzbDrone.Core.Music.Events +namespace NzbDrone.Core.Books.Events { - public class ArtistsImportedEvent : IEvent + public class AuthorsImportedEvent : IEvent { public List AuthorIds { get; private set; } public bool DoRefresh { get; private set; } - public ArtistsImportedEvent(List authorIds, bool doRefresh = true) + public AuthorsImportedEvent(List authorIds, bool doRefresh = true) { AuthorIds = authorIds; DoRefresh = doRefresh; diff --git a/src/NzbDrone.Core/Books/Events/BookAddedEvent.cs b/src/NzbDrone.Core/Books/Events/BookAddedEvent.cs new file mode 100644 index 000000000..32d794456 --- /dev/null +++ b/src/NzbDrone.Core/Books/Events/BookAddedEvent.cs @@ -0,0 +1,16 @@ +using NzbDrone.Common.Messaging; + +namespace NzbDrone.Core.Books.Events +{ + public class BookAddedEvent : IEvent + { + public Book Book { get; private set; } + public bool DoRefresh { get; private set; } + + public BookAddedEvent(Book book, bool doRefresh = true) + { + Book = book; + DoRefresh = doRefresh; + } + } +} diff --git a/src/NzbDrone.Core/Books/Events/AlbumDeletedEvent.cs b/src/NzbDrone.Core/Books/Events/BookDeletedEvent.cs similarity index 54% rename from src/NzbDrone.Core/Books/Events/AlbumDeletedEvent.cs rename to src/NzbDrone.Core/Books/Events/BookDeletedEvent.cs index 4d7842a9a..de2d5ea76 100644 --- a/src/NzbDrone.Core/Books/Events/AlbumDeletedEvent.cs +++ b/src/NzbDrone.Core/Books/Events/BookDeletedEvent.cs @@ -1,16 +1,16 @@ using NzbDrone.Common.Messaging; -namespace NzbDrone.Core.Music.Events +namespace NzbDrone.Core.Books.Events { - public class AlbumDeletedEvent : IEvent + public class BookDeletedEvent : IEvent { - public Book Album { get; private set; } + public Book Book { get; private set; } public bool DeleteFiles { get; private set; } public bool AddImportListExclusion { get; private set; } - public AlbumDeletedEvent(Book album, bool deleteFiles, bool addImportListExclusion) + public BookDeletedEvent(Book book, bool deleteFiles, bool addImportListExclusion) { - Album = album; + Book = book; DeleteFiles = deleteFiles; AddImportListExclusion = addImportListExclusion; } diff --git a/src/NzbDrone.Core/Books/Events/AlbumEditedEvent.cs b/src/NzbDrone.Core/Books/Events/BookEditedEvent.cs similarity index 55% rename from src/NzbDrone.Core/Books/Events/AlbumEditedEvent.cs rename to src/NzbDrone.Core/Books/Events/BookEditedEvent.cs index 8ef98bb15..0b7b4b98b 100644 --- a/src/NzbDrone.Core/Books/Events/AlbumEditedEvent.cs +++ b/src/NzbDrone.Core/Books/Events/BookEditedEvent.cs @@ -1,15 +1,15 @@ using NzbDrone.Common.Messaging; -namespace NzbDrone.Core.Music.Events +namespace NzbDrone.Core.Books.Events { - public class AlbumEditedEvent : IEvent + public class BookEditedEvent : IEvent { public Book Album { get; private set; } public Book OldAlbum { get; private set; } - public AlbumEditedEvent(Book album, Book oldAlbum) + public BookEditedEvent(Book book, Book oldAlbum) { - Album = album; + Album = book; OldAlbum = oldAlbum; } } diff --git a/src/NzbDrone.Core/Books/Events/AlbumInfoRefreshedEvent.cs b/src/NzbDrone.Core/Books/Events/BookInfoRefreshedEvent.cs similarity index 55% rename from src/NzbDrone.Core/Books/Events/AlbumInfoRefreshedEvent.cs rename to src/NzbDrone.Core/Books/Events/BookInfoRefreshedEvent.cs index 4e6ea3d76..8a4a11946 100644 --- a/src/NzbDrone.Core/Books/Events/AlbumInfoRefreshedEvent.cs +++ b/src/NzbDrone.Core/Books/Events/BookInfoRefreshedEvent.cs @@ -1,18 +1,18 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Collections.ObjectModel; using NzbDrone.Common.Messaging; -namespace NzbDrone.Core.Music.Events +namespace NzbDrone.Core.Books.Events { - public class AlbumInfoRefreshedEvent : IEvent + public class BookInfoRefreshedEvent : IEvent { - public Author Artist { get; set; } + public Author Author { get; set; } public ReadOnlyCollection Added { get; private set; } public ReadOnlyCollection Updated { get; private set; } - public AlbumInfoRefreshedEvent(Author artist, IList added, IList updated) + public BookInfoRefreshedEvent(Author author, IList added, IList updated) { - Artist = artist; + Author = author; Added = new ReadOnlyCollection(added); Updated = new ReadOnlyCollection(updated); } diff --git a/src/NzbDrone.Core/Books/Events/BookUpdatedEvent.cs b/src/NzbDrone.Core/Books/Events/BookUpdatedEvent.cs new file mode 100644 index 000000000..8cc288ced --- /dev/null +++ b/src/NzbDrone.Core/Books/Events/BookUpdatedEvent.cs @@ -0,0 +1,14 @@ +using NzbDrone.Common.Messaging; + +namespace NzbDrone.Core.Books.Events +{ + public class BookUpdatedEvent : IEvent + { + public Book Book { get; private set; } + + public BookUpdatedEvent(Book book) + { + Book = book; + } + } +} diff --git a/src/NzbDrone.Core/Books/Handlers/AlbumAddedHandler.cs b/src/NzbDrone.Core/Books/Handlers/AlbumAddedHandler.cs deleted file mode 100644 index 035f56dcf..000000000 --- a/src/NzbDrone.Core/Books/Handlers/AlbumAddedHandler.cs +++ /dev/null @@ -1,25 +0,0 @@ -using NzbDrone.Core.Messaging.Commands; -using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music.Commands; -using NzbDrone.Core.Music.Events; - -namespace NzbDrone.Core.Music -{ - public class AlbumAddedHandler : IHandle - { - private readonly IManageCommandQueue _commandQueueManager; - - public AlbumAddedHandler(IManageCommandQueue commandQueueManager) - { - _commandQueueManager = commandQueueManager; - } - - public void Handle(AlbumAddedEvent message) - { - if (message.DoRefresh) - { - _commandQueueManager.Push(new RefreshArtistCommand(message.Album.Author.Value.Id)); - } - } - } -} diff --git a/src/NzbDrone.Core/Books/Handlers/ArtistAddedHandler.cs b/src/NzbDrone.Core/Books/Handlers/ArtistAddedHandler.cs deleted file mode 100644 index fc1c8a933..000000000 --- a/src/NzbDrone.Core/Books/Handlers/ArtistAddedHandler.cs +++ /dev/null @@ -1,34 +0,0 @@ -using NzbDrone.Core.Messaging.Commands; -using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music.Commands; -using NzbDrone.Core.Music.Events; - -namespace NzbDrone.Core.Music -{ - public class ArtistAddedHandler : IHandle, - IHandle - { - private readonly IManageCommandQueue _commandQueueManager; - - public ArtistAddedHandler(IManageCommandQueue commandQueueManager) - { - _commandQueueManager = commandQueueManager; - } - - public void Handle(ArtistAddedEvent message) - { - if (message.DoRefresh) - { - _commandQueueManager.Push(new RefreshArtistCommand(message.Artist.Id, true)); - } - } - - public void Handle(ArtistsImportedEvent message) - { - if (message.DoRefresh) - { - _commandQueueManager.Push(new BulkRefreshArtistCommand(message.AuthorIds, true)); - } - } - } -} diff --git a/src/NzbDrone.Core/Books/Handlers/ArtistEditedHandler.cs b/src/NzbDrone.Core/Books/Handlers/ArtistEditedHandler.cs deleted file mode 100644 index a01e2cfe8..000000000 --- a/src/NzbDrone.Core/Books/Handlers/ArtistEditedHandler.cs +++ /dev/null @@ -1,26 +0,0 @@ -using NzbDrone.Core.Messaging.Commands; -using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music.Commands; -using NzbDrone.Core.Music.Events; - -namespace NzbDrone.Core.Music -{ - public class ArtistEditedService : IHandle - { - private readonly IManageCommandQueue _commandQueueManager; - - public ArtistEditedService(IManageCommandQueue commandQueueManager) - { - _commandQueueManager = commandQueueManager; - } - - public void Handle(ArtistEditedEvent message) - { - // Refresh Artist is we change AlbumType Preferences - if (message.Artist.MetadataProfileId != message.OldArtist.MetadataProfileId) - { - _commandQueueManager.Push(new RefreshArtistCommand(message.Artist.Id, false)); - } - } - } -} diff --git a/src/NzbDrone.Core/Books/Handlers/ArtistScannedHandler.cs b/src/NzbDrone.Core/Books/Handlers/ArtistScannedHandler.cs deleted file mode 100644 index 5f514bac2..000000000 --- a/src/NzbDrone.Core/Books/Handlers/ArtistScannedHandler.cs +++ /dev/null @@ -1,60 +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.Music -{ - public class ArtistScannedHandler : IHandle, - IHandle - { - private readonly IAlbumMonitoredService _albumMonitoredService; - private readonly IArtistService _artistService; - private readonly IManageCommandQueue _commandQueueManager; - private readonly IAlbumAddedService _albumAddedService; - private readonly Logger _logger; - - public ArtistScannedHandler(IAlbumMonitoredService albumMonitoredService, - IArtistService artistService, - IManageCommandQueue commandQueueManager, - IAlbumAddedService albumAddedService, - Logger logger) - { - _albumMonitoredService = albumMonitoredService; - _artistService = artistService; - _commandQueueManager = commandQueueManager; - _albumAddedService = albumAddedService; - _logger = logger; - } - - private void HandleScanEvents(Author artist) - { - if (artist.AddOptions != null) - { - _logger.Info("[{0}] was recently added, performing post-add actions", artist.Name); - _albumMonitoredService.SetAlbumMonitoredStatus(artist, artist.AddOptions); - - if (artist.AddOptions.SearchForMissingAlbums) - { - _commandQueueManager.Push(new MissingAlbumSearchCommand(artist.Id)); - } - - artist.AddOptions = null; - _artistService.RemoveAddOptions(artist); - } - - _albumAddedService.SearchForRecentlyAdded(artist.Id); - } - - public void Handle(ArtistScannedEvent message) - { - HandleScanEvents(message.Artist); - } - - public void Handle(ArtistScanSkippedEvent message) - { - HandleScanEvents(message.Artist); - } - } -} diff --git a/src/NzbDrone.Core/Books/Handlers/AuthorAddedHandler.cs b/src/NzbDrone.Core/Books/Handlers/AuthorAddedHandler.cs new file mode 100644 index 000000000..61ef268dc --- /dev/null +++ b/src/NzbDrone.Core/Books/Handlers/AuthorAddedHandler.cs @@ -0,0 +1,34 @@ +using NzbDrone.Core.Books.Commands; +using NzbDrone.Core.Books.Events; +using NzbDrone.Core.Messaging.Commands; +using NzbDrone.Core.Messaging.Events; + +namespace NzbDrone.Core.Books +{ + public class AuthorAddedHandler : IHandle, + IHandle + { + private readonly IManageCommandQueue _commandQueueManager; + + public AuthorAddedHandler(IManageCommandQueue commandQueueManager) + { + _commandQueueManager = commandQueueManager; + } + + public void Handle(AuthorAddedEvent message) + { + if (message.DoRefresh) + { + _commandQueueManager.Push(new RefreshAuthorCommand(message.Author.Id, true)); + } + } + + public void Handle(AuthorsImportedEvent message) + { + if (message.DoRefresh) + { + _commandQueueManager.Push(new BulkRefreshAuthorCommand(message.AuthorIds, true)); + } + } + } +} diff --git a/src/NzbDrone.Core/Books/Handlers/AuthorEditedHandler.cs b/src/NzbDrone.Core/Books/Handlers/AuthorEditedHandler.cs new file mode 100644 index 000000000..2fd8660c3 --- /dev/null +++ b/src/NzbDrone.Core/Books/Handlers/AuthorEditedHandler.cs @@ -0,0 +1,26 @@ +using NzbDrone.Core.Books.Commands; +using NzbDrone.Core.Books.Events; +using NzbDrone.Core.Messaging.Commands; +using NzbDrone.Core.Messaging.Events; + +namespace NzbDrone.Core.Books +{ + public class AuthorEditedService : IHandle + { + private readonly IManageCommandQueue _commandQueueManager; + + public AuthorEditedService(IManageCommandQueue commandQueueManager) + { + _commandQueueManager = commandQueueManager; + } + + public void Handle(AuthorEditedEvent message) + { + // Refresh Author is we change AlbumType Preferences + if (message.Author.MetadataProfileId != message.OldAuthor.MetadataProfileId) + { + _commandQueueManager.Push(new RefreshAuthorCommand(message.Author.Id, false)); + } + } + } +} diff --git a/src/NzbDrone.Core/Books/Handlers/AuthorScannedHandler.cs b/src/NzbDrone.Core/Books/Handlers/AuthorScannedHandler.cs new file mode 100644 index 000000000..c441fb965 --- /dev/null +++ b/src/NzbDrone.Core/Books/Handlers/AuthorScannedHandler.cs @@ -0,0 +1,60 @@ +using NLog; +using NzbDrone.Core.IndexerSearch; +using NzbDrone.Core.MediaFiles.Events; +using NzbDrone.Core.Messaging.Commands; +using NzbDrone.Core.Messaging.Events; + +namespace NzbDrone.Core.Books +{ + public class AuthorScannedHandler : IHandle, + IHandle + { + private readonly IBookMonitoredService _bookMonitoredService; + private readonly IAuthorService _authorService; + private readonly IManageCommandQueue _commandQueueManager; + private readonly IBookAddedService _bookAddedService; + private readonly Logger _logger; + + public AuthorScannedHandler(IBookMonitoredService bookMonitoredService, + IAuthorService authorService, + IManageCommandQueue commandQueueManager, + IBookAddedService bookAddedService, + Logger logger) + { + _bookMonitoredService = bookMonitoredService; + _authorService = authorService; + _commandQueueManager = commandQueueManager; + _bookAddedService = bookAddedService; + _logger = logger; + } + + private void HandleScanEvents(Author author) + { + if (author.AddOptions != null) + { + _logger.Info("[{0}] was recently added, performing post-add actions", author.Name); + _bookMonitoredService.SetBookMonitoredStatus(author, author.AddOptions); + + if (author.AddOptions.SearchForMissingAlbums) + { + _commandQueueManager.Push(new MissingBookSearchCommand(author.Id)); + } + + author.AddOptions = null; + _authorService.RemoveAddOptions(author); + } + + _bookAddedService.SearchForRecentlyAdded(author.Id); + } + + public void Handle(AuthorScannedEvent message) + { + HandleScanEvents(message.Author); + } + + public void Handle(AuthorScanSkippedEvent message) + { + HandleScanEvents(message.Author); + } + } +} diff --git a/src/NzbDrone.Core/Books/Handlers/BookAddedHandler.cs b/src/NzbDrone.Core/Books/Handlers/BookAddedHandler.cs new file mode 100644 index 000000000..4e0de127e --- /dev/null +++ b/src/NzbDrone.Core/Books/Handlers/BookAddedHandler.cs @@ -0,0 +1,25 @@ +using NzbDrone.Core.Books.Commands; +using NzbDrone.Core.Books.Events; +using NzbDrone.Core.Messaging.Commands; +using NzbDrone.Core.Messaging.Events; + +namespace NzbDrone.Core.Books +{ + public class BookAddedHandler : IHandle + { + private readonly IManageCommandQueue _commandQueueManager; + + public BookAddedHandler(IManageCommandQueue commandQueueManager) + { + _commandQueueManager = commandQueueManager; + } + + public void Handle(BookAddedEvent message) + { + if (message.DoRefresh) + { + _commandQueueManager.Push(new RefreshAuthorCommand(message.Book.Author.Value.Id)); + } + } + } +} diff --git a/src/NzbDrone.Core/Books/Model/AddArtistOptions.cs b/src/NzbDrone.Core/Books/Model/AddArtistOptions.cs deleted file mode 100644 index 8ef3ca72c..000000000 --- a/src/NzbDrone.Core/Books/Model/AddArtistOptions.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace NzbDrone.Core.Music -{ - public class AddArtistOptions : MonitoringOptions - { - public bool SearchForMissingAlbums { get; set; } - } -} diff --git a/src/NzbDrone.Core/Books/Model/AddAuthorOptions.cs b/src/NzbDrone.Core/Books/Model/AddAuthorOptions.cs new file mode 100644 index 000000000..b16cd6aef --- /dev/null +++ b/src/NzbDrone.Core/Books/Model/AddAuthorOptions.cs @@ -0,0 +1,7 @@ +namespace NzbDrone.Core.Books +{ + public class AddAuthorOptions : MonitoringOptions + { + public bool SearchForMissingAlbums { get; set; } + } +} diff --git a/src/NzbDrone.Core/Books/Model/AddAlbumOptions.cs b/src/NzbDrone.Core/Books/Model/AddBookOptions.cs similarity index 74% rename from src/NzbDrone.Core/Books/Model/AddAlbumOptions.cs rename to src/NzbDrone.Core/Books/Model/AddBookOptions.cs index 537856c12..6b2b6f451 100644 --- a/src/NzbDrone.Core/Books/Model/AddAlbumOptions.cs +++ b/src/NzbDrone.Core/Books/Model/AddBookOptions.cs @@ -1,10 +1,10 @@ using NzbDrone.Core.Datastore; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { - public class AddAlbumOptions : IEmbeddedDocument + public class AddBookOptions : IEmbeddedDocument { - public AddAlbumOptions() + public AddBookOptions() { // default in case not set in db AddType = AlbumAddType.Automatic; diff --git a/src/NzbDrone.Core/Books/Model/ArtistStatusType.cs b/src/NzbDrone.Core/Books/Model/ArtistStatusType.cs deleted file mode 100644 index 478959016..000000000 --- a/src/NzbDrone.Core/Books/Model/ArtistStatusType.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace NzbDrone.Core.Music -{ - public enum ArtistStatusType - { - Continuing = 0, - Ended = 1 - } -} diff --git a/src/NzbDrone.Core/Books/Model/Author.cs b/src/NzbDrone.Core/Books/Model/Author.cs index 9fe08ea14..0d22382db 100644 --- a/src/NzbDrone.Core/Books/Model/Author.cs +++ b/src/NzbDrone.Core/Books/Model/Author.cs @@ -6,7 +6,7 @@ using NzbDrone.Core.Datastore; using NzbDrone.Core.Profiles.Metadata; using NzbDrone.Core.Profiles.Qualities; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { public class Author : Entity { @@ -29,7 +29,7 @@ namespace NzbDrone.Core.Music public int MetadataProfileId { get; set; } public HashSet Tags { get; set; } [MemberwiseEqualityIgnore] - public AddArtistOptions AddOptions { get; set; } + public AddAuthorOptions AddOptions { get; set; } // Dynamically loaded from DB [MemberwiseEqualityIgnore] diff --git a/src/NzbDrone.Core/Books/Model/AuthorMetadata.cs b/src/NzbDrone.Core/Books/Model/AuthorMetadata.cs index fd030700b..6176a853a 100644 --- a/src/NzbDrone.Core/Books/Model/AuthorMetadata.cs +++ b/src/NzbDrone.Core/Books/Model/AuthorMetadata.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using NzbDrone.Common.Extensions; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { public class AuthorMetadata : Entity { @@ -23,7 +23,7 @@ namespace NzbDrone.Core.Music public string Overview { get; set; } public string Disambiguation { get; set; } public string Type { get; set; } - public ArtistStatusType Status { get; set; } + public AuthorStatusType Status { get; set; } public List Images { get; set; } public List Links { get; set; } public List Genres { get; set; } diff --git a/src/NzbDrone.Core/Books/Model/AuthorStatusType.cs b/src/NzbDrone.Core/Books/Model/AuthorStatusType.cs new file mode 100644 index 000000000..db0e2b467 --- /dev/null +++ b/src/NzbDrone.Core/Books/Model/AuthorStatusType.cs @@ -0,0 +1,8 @@ +namespace NzbDrone.Core.Books +{ + public enum AuthorStatusType + { + Continuing = 0, + Ended = 1 + } +} diff --git a/src/NzbDrone.Core/Books/Model/Book.cs b/src/NzbDrone.Core/Books/Model/Book.cs index 27af2e3ac..fd2283f75 100644 --- a/src/NzbDrone.Core/Books/Model/Book.cs +++ b/src/NzbDrone.Core/Books/Model/Book.cs @@ -7,7 +7,7 @@ using NzbDrone.Common.Extensions; using NzbDrone.Core.Datastore; using NzbDrone.Core.MediaFiles; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { public class Book : Entity { @@ -19,7 +19,7 @@ namespace NzbDrone.Core.Music Genres = new List(); Ratings = new Ratings(); Author = new Author(); - AddOptions = new AddAlbumOptions(); + AddOptions = new AddBookOptions(); } // These correspond to columns in the Albums table @@ -49,7 +49,7 @@ namespace NzbDrone.Core.Music public DateTime? LastInfoSync { get; set; } public DateTime Added { get; set; } [MemberwiseEqualityIgnore] - public AddAlbumOptions AddOptions { get; set; } + public AddBookOptions AddOptions { get; set; } // These are dynamically queried from other tables [MemberwiseEqualityIgnore] diff --git a/src/NzbDrone.Core/Books/Model/Entity.cs b/src/NzbDrone.Core/Books/Model/Entity.cs index 03a93707f..6c41874c2 100644 --- a/src/NzbDrone.Core/Books/Model/Entity.cs +++ b/src/NzbDrone.Core/Books/Model/Entity.cs @@ -2,7 +2,7 @@ using System; using Equ; using NzbDrone.Core.Datastore; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { public abstract class Entity : ModelBase, IEquatable where T : Entity diff --git a/src/NzbDrone.Core/Books/Model/Links.cs b/src/NzbDrone.Core/Books/Model/Links.cs index 19df7f5fd..dbba21098 100644 --- a/src/NzbDrone.Core/Books/Model/Links.cs +++ b/src/NzbDrone.Core/Books/Model/Links.cs @@ -1,7 +1,7 @@ using Equ; using NzbDrone.Core.Datastore; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { public class Links : MemberwiseEquatable, IEmbeddedDocument { diff --git a/src/NzbDrone.Core/Books/Model/MonitoringOptions.cs b/src/NzbDrone.Core/Books/Model/MonitoringOptions.cs index 382c40a57..c97d4e4a4 100644 --- a/src/NzbDrone.Core/Books/Model/MonitoringOptions.cs +++ b/src/NzbDrone.Core/Books/Model/MonitoringOptions.cs @@ -1,17 +1,17 @@ using System.Collections.Generic; using NzbDrone.Core.Datastore; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { public class MonitoringOptions : IEmbeddedDocument { public MonitoringOptions() { - AlbumsToMonitor = new List(); + BooksToMonitor = new List(); } public MonitorTypes Monitor { get; set; } - public List AlbumsToMonitor { get; set; } + public List BooksToMonitor { get; set; } public bool Monitored { get; set; } } diff --git a/src/NzbDrone.Core/Books/Model/Ratings.cs b/src/NzbDrone.Core/Books/Model/Ratings.cs index ae3a0526a..2eb445ad8 100644 --- a/src/NzbDrone.Core/Books/Model/Ratings.cs +++ b/src/NzbDrone.Core/Books/Model/Ratings.cs @@ -1,7 +1,7 @@ using Equ; using NzbDrone.Core.Datastore; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { public class Ratings : MemberwiseEquatable, IEmbeddedDocument { diff --git a/src/NzbDrone.Core/Books/Model/Series.cs b/src/NzbDrone.Core/Books/Model/Series.cs index 900e70a44..d93230807 100644 --- a/src/NzbDrone.Core/Books/Model/Series.cs +++ b/src/NzbDrone.Core/Books/Model/Series.cs @@ -3,7 +3,7 @@ using Equ; using NzbDrone.Common.Extensions; using NzbDrone.Core.Datastore; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { public class Series : Entity { diff --git a/src/NzbDrone.Core/Books/Model/SeriesBookLink.cs b/src/NzbDrone.Core/Books/Model/SeriesBookLink.cs index fa7ce65fe..3cbdefff8 100644 --- a/src/NzbDrone.Core/Books/Model/SeriesBookLink.cs +++ b/src/NzbDrone.Core/Books/Model/SeriesBookLink.cs @@ -1,7 +1,7 @@ using Equ; using NzbDrone.Core.Datastore; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { public class SeriesBookLink : Entity { diff --git a/src/NzbDrone.Core/Books/Repositories/ArtistMetadataRepository.cs b/src/NzbDrone.Core/Books/Repositories/AuthorMetadataRepository.cs similarity index 82% rename from src/NzbDrone.Core/Books/Repositories/ArtistMetadataRepository.cs rename to src/NzbDrone.Core/Books/Repositories/AuthorMetadataRepository.cs index 419c2d5aa..15ede62d9 100644 --- a/src/NzbDrone.Core/Books/Repositories/ArtistMetadataRepository.cs +++ b/src/NzbDrone.Core/Books/Repositories/AuthorMetadataRepository.cs @@ -1,22 +1,22 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using NLog; using NzbDrone.Core.Datastore; using NzbDrone.Core.Messaging.Events; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { - public interface IArtistMetadataRepository : IBasicRepository + public interface IAuthorMetadataRepository : IBasicRepository { List FindById(List foreignIds); bool UpsertMany(List data); } - public class ArtistMetadataRepository : BasicRepository, IArtistMetadataRepository + public class AuthorMetadataRepository : BasicRepository, IAuthorMetadataRepository { private readonly Logger _logger; - public ArtistMetadataRepository(IMainDatabase database, IEventAggregator eventAggregator, Logger logger) + public AuthorMetadataRepository(IMainDatabase database, IEventAggregator eventAggregator, Logger logger) : base(database, eventAggregator) { _logger = logger; @@ -61,7 +61,7 @@ namespace NzbDrone.Core.Music UpdateMany(updateMetadataList); InsertMany(addMetadataList); - _logger.Debug($"{upToDateMetadataCount} artist metadata up to date; Updating {updateMetadataList.Count}, Adding {addMetadataList.Count} artist metadata entries."); + _logger.Debug($"{upToDateMetadataCount} author metadata up to date; Updating {updateMetadataList.Count}, Adding {addMetadataList.Count} author metadata entries."); return updateMetadataList.Count > 0 || addMetadataList.Count > 0; } diff --git a/src/NzbDrone.Core/Books/Repositories/ArtistRepository.cs b/src/NzbDrone.Core/Books/Repositories/AuthorRepository.cs similarity index 62% rename from src/NzbDrone.Core/Books/Repositories/ArtistRepository.cs rename to src/NzbDrone.Core/Books/Repositories/AuthorRepository.cs index f12c1c05d..a5acebf2e 100644 --- a/src/NzbDrone.Core/Books/Repositories/ArtistRepository.cs +++ b/src/NzbDrone.Core/Books/Repositories/AuthorRepository.cs @@ -5,20 +5,20 @@ using NzbDrone.Common.Extensions; using NzbDrone.Core.Datastore; using NzbDrone.Core.Messaging.Events; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { - public interface IArtistRepository : IBasicRepository + public interface IAuthorRepository : IBasicRepository { - bool ArtistPathExists(string path); + bool AuthorPathExists(string path); Author FindByName(string cleanName); Author FindById(string foreignAuthorId); - Author GetArtistByMetadataId(int artistMetadataId); - List GetArtistByMetadataId(IEnumerable artistMetadataId); + Author GetAuthorByMetadataId(int authorMetadataId); + List GetAuthorsByMetadataId(IEnumerable authorMetadataId); } - public class ArtistRepository : BasicRepository, IArtistRepository + public class AuthorRepository : BasicRepository, IAuthorRepository { - public ArtistRepository(IMainDatabase database, + public AuthorRepository(IMainDatabase database, IEventAggregator eventAggregator) : base(database, eventAggregator) { @@ -31,14 +31,14 @@ namespace NzbDrone.Core.Music public static IEnumerable Query(IDatabase database, SqlBuilder builder) { - return database.QueryJoined(builder, (artist, metadata) => + return database.QueryJoined(builder, (author, metadata) => { - artist.Metadata = metadata; - return artist; + author.Metadata = metadata; + return author; }); } - public bool ArtistPathExists(string path) + public bool AuthorPathExists(string path) { return Query(c => c.Path == path).Any(); } @@ -55,14 +55,14 @@ namespace NzbDrone.Core.Music return Query(s => s.CleanName == cleanName).ExclusiveOrDefault(); } - public Author GetArtistByMetadataId(int artistMetadataId) + public Author GetAuthorByMetadataId(int authorMetadataId) { - return Query(s => s.AuthorMetadataId == artistMetadataId).SingleOrDefault(); + return Query(s => s.AuthorMetadataId == authorMetadataId).SingleOrDefault(); } - public List GetArtistByMetadataId(IEnumerable artistMetadataIds) + public List GetAuthorsByMetadataId(IEnumerable authorMetadataIds) { - return Query(s => artistMetadataIds.Contains(s.AuthorMetadataId)); + return Query(s => authorMetadataIds.Contains(s.AuthorMetadataId)); } } } diff --git a/src/NzbDrone.Core/Books/Repositories/AlbumRepository.cs b/src/NzbDrone.Core/Books/Repositories/BookRepository.cs similarity index 67% rename from src/NzbDrone.Core/Books/Repositories/AlbumRepository.cs rename to src/NzbDrone.Core/Books/Repositories/BookRepository.cs index 8a2f8578a..f5d0e04ca 100644 --- a/src/NzbDrone.Core/Books/Repositories/AlbumRepository.cs +++ b/src/NzbDrone.Core/Books/Repositories/BookRepository.cs @@ -7,67 +7,67 @@ using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Qualities; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { - public interface IAlbumRepository : IBasicRepository + public interface IBookRepository : IBasicRepository { - List GetAlbums(int authorId); - List GetLastAlbums(IEnumerable artistMetadataIds); - List GetNextAlbums(IEnumerable artistMetadataIds); - List GetAlbumsByArtistMetadataId(int artistMetadataId); - List GetAlbumsForRefresh(int artistMetadataId, IEnumerable foreignIds); - List GetAlbumsByFileIds(IEnumerable fileIds); - Book FindByTitle(int artistMetadataId, string title); + List GetBooks(int authorId); + List GetLastBooks(IEnumerable authorMetadataIds); + List GetNextBooks(IEnumerable authorMetadataIds); + List GetBooksByAuthorMetadataId(int authorMetadataId); + List GetBooksForRefresh(int authorMetadataId, IEnumerable foreignIds); + List GetBooksByFileIds(IEnumerable fileIds); + Book FindByTitle(int authorMetadataId, string title); Book FindById(string foreignBookId); Book FindBySlug(string titleSlug); - PagingSpec AlbumsWithoutFiles(PagingSpec pagingSpec); - PagingSpec AlbumsWhereCutoffUnmet(PagingSpec pagingSpec, List qualitiesBelowCutoff); - List AlbumsBetweenDates(DateTime startDate, DateTime endDate, bool includeUnmonitored); - List ArtistAlbumsBetweenDates(Author artist, DateTime startDate, DateTime endDate, bool includeUnmonitored); - void SetMonitoredFlat(Book album, bool monitored); + PagingSpec BooksWithoutFiles(PagingSpec pagingSpec); + PagingSpec BooksWhereCutoffUnmet(PagingSpec pagingSpec, List qualitiesBelowCutoff); + List BooksBetweenDates(DateTime startDate, DateTime endDate, bool includeUnmonitored); + List AuthorBooksBetweenDates(Author author, DateTime startDate, DateTime endDate, bool includeUnmonitored); + void SetMonitoredFlat(Book book, bool monitored); void SetMonitored(IEnumerable ids, bool monitored); - List GetArtistAlbumsWithFiles(Author artist); + List GetArtistAlbumsWithFiles(Author author); } - public class AlbumRepository : BasicRepository, IAlbumRepository + public class BookRepository : BasicRepository, IBookRepository { - public AlbumRepository(IMainDatabase database, IEventAggregator eventAggregator) + public BookRepository(IMainDatabase database, IEventAggregator eventAggregator) : base(database, eventAggregator) { } - public List GetAlbums(int authorId) + public List GetBooks(int authorId) { return Query(Builder().Join((l, r) => l.AuthorMetadataId == r.AuthorMetadataId).Where(a => a.Id == authorId)); } - public List GetLastAlbums(IEnumerable artistMetadataIds) + public List GetLastBooks(IEnumerable authorMetadataIds) { var now = DateTime.UtcNow; - return Query(Builder().Where(x => artistMetadataIds.Contains(x.AuthorMetadataId) && x.ReleaseDate < now) + return Query(Builder().Where(x => authorMetadataIds.Contains(x.AuthorMetadataId) && x.ReleaseDate < now) .GroupBy(x => x.AuthorMetadataId) .Having("Books.ReleaseDate = MAX(Books.ReleaseDate)")); } - public List GetNextAlbums(IEnumerable artistMetadataIds) + public List GetNextBooks(IEnumerable authorMetadataIds) { var now = DateTime.UtcNow; - return Query(Builder().Where(x => artistMetadataIds.Contains(x.AuthorMetadataId) && x.ReleaseDate > now) + return Query(Builder().Where(x => authorMetadataIds.Contains(x.AuthorMetadataId) && x.ReleaseDate > now) .GroupBy(x => x.AuthorMetadataId) .Having("Books.ReleaseDate = MIN(Books.ReleaseDate)")); } - public List GetAlbumsByArtistMetadataId(int artistMetadataId) + public List GetBooksByAuthorMetadataId(int authorMetadataId) { - return Query(s => s.AuthorMetadataId == artistMetadataId); + return Query(s => s.AuthorMetadataId == authorMetadataId); } - public List GetAlbumsForRefresh(int artistMetadataId, IEnumerable foreignIds) + public List GetBooksForRefresh(int authorMetadataId, IEnumerable foreignIds) { - return Query(a => a.AuthorMetadataId == artistMetadataId || foreignIds.Contains(a.ForeignBookId)); + return Query(a => a.AuthorMetadataId == authorMetadataId || foreignIds.Contains(a.ForeignBookId)); } - public List GetAlbumsByFileIds(IEnumerable fileIds) + public List GetBooksByFileIds(IEnumerable fileIds) { return Query(new SqlBuilder() .Join((l, r) => l.Id == r.BookId) @@ -95,7 +95,7 @@ namespace NzbDrone.Core.Music .Where(a => a.ReleaseDate <= currentTime); #pragma warning restore CS0472 - public PagingSpec AlbumsWithoutFiles(PagingSpec pagingSpec) + public PagingSpec BooksWithoutFiles(PagingSpec pagingSpec) { var currentTime = DateTime.UtcNow; @@ -125,7 +125,7 @@ namespace NzbDrone.Core.Music return string.Format("({0})", string.Join(" OR ", clauses)); } - public PagingSpec AlbumsWhereCutoffUnmet(PagingSpec pagingSpec, List qualitiesBelowCutoff) + public PagingSpec BooksWhereCutoffUnmet(PagingSpec pagingSpec, List qualitiesBelowCutoff) { pagingSpec.Records = GetPagedRecords(AlbumsWhereCutoffUnmetBuilder(qualitiesBelowCutoff), pagingSpec, PagedQuery); @@ -135,7 +135,7 @@ namespace NzbDrone.Core.Music return pagingSpec; } - public List AlbumsBetweenDates(DateTime startDate, DateTime endDate, bool includeUnmonitored) + public List BooksBetweenDates(DateTime startDate, DateTime endDate, bool includeUnmonitored) { var builder = Builder().Where(rg => rg.ReleaseDate >= startDate && rg.ReleaseDate <= endDate); @@ -149,11 +149,11 @@ namespace NzbDrone.Core.Music return Query(builder); } - public List ArtistAlbumsBetweenDates(Author artist, DateTime startDate, DateTime endDate, bool includeUnmonitored) + public List AuthorBooksBetweenDates(Author author, DateTime startDate, DateTime endDate, bool includeUnmonitored) { var builder = Builder().Where(rg => rg.ReleaseDate >= startDate && rg.ReleaseDate <= endDate && - rg.AuthorMetadataId == artist.AuthorMetadataId); + rg.AuthorMetadataId == author.AuthorMetadataId); if (!includeUnmonitored) { @@ -165,10 +165,10 @@ namespace NzbDrone.Core.Music return Query(builder); } - public void SetMonitoredFlat(Book album, bool monitored) + public void SetMonitoredFlat(Book book, bool monitored) { - album.Monitored = monitored; - SetFields(album, p => p.Monitored); + book.Monitored = monitored; + SetFields(book, p => p.Monitored); } public void SetMonitored(IEnumerable ids, bool monitored) @@ -177,24 +177,24 @@ namespace NzbDrone.Core.Music SetFields(albums, p => p.Monitored); } - public Book FindByTitle(int artistMetadataId, string title) + public Book FindByTitle(int authorMetadataId, string title) { - var cleanTitle = Parser.Parser.CleanArtistName(title); + var cleanTitle = Parser.Parser.CleanAuthorName(title); if (string.IsNullOrEmpty(cleanTitle)) { cleanTitle = title; } - return Query(s => (s.CleanTitle == cleanTitle || s.Title == title) && s.AuthorMetadataId == artistMetadataId) + return Query(s => (s.CleanTitle == cleanTitle || s.Title == title) && s.AuthorMetadataId == authorMetadataId) .ExclusiveOrDefault(); } - public List GetArtistAlbumsWithFiles(Author artist) + public List GetArtistAlbumsWithFiles(Author author) { return Query(Builder() .Join((t, f) => t.Id == f.BookId) - .Where(x => x.AuthorMetadataId == artist.AuthorMetadataId)); + .Where(x => x.AuthorMetadataId == author.AuthorMetadataId)); } } } diff --git a/src/NzbDrone.Core/Books/Repositories/SeriesBookLinkRepository.cs b/src/NzbDrone.Core/Books/Repositories/SeriesBookLinkRepository.cs index 4e93804c2..142278c0b 100644 --- a/src/NzbDrone.Core/Books/Repositories/SeriesBookLinkRepository.cs +++ b/src/NzbDrone.Core/Books/Repositories/SeriesBookLinkRepository.cs @@ -2,7 +2,7 @@ using NzbDrone.Core.Datastore; using NzbDrone.Core.Messaging.Events; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { public interface ISeriesBookLinkRepository : IBasicRepository { diff --git a/src/NzbDrone.Core/Books/Repositories/SeriesRepository.cs b/src/NzbDrone.Core/Books/Repositories/SeriesRepository.cs index 891d323e8..0a89d47f0 100644 --- a/src/NzbDrone.Core/Books/Repositories/SeriesRepository.cs +++ b/src/NzbDrone.Core/Books/Repositories/SeriesRepository.cs @@ -3,7 +3,7 @@ using System.Linq; using NzbDrone.Core.Datastore; using NzbDrone.Core.Messaging.Events; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { public interface ISeriesRepository : IBasicRepository { diff --git a/src/NzbDrone.Core/Books/Services/AddAlbumService.cs b/src/NzbDrone.Core/Books/Services/AddAlbumService.cs deleted file mode 100644 index effe499c6..000000000 --- a/src/NzbDrone.Core/Books/Services/AddAlbumService.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using FluentValidation; -using FluentValidation.Results; -using NLog; -using NzbDrone.Core.Exceptions; -using NzbDrone.Core.ImportLists.Exclusions; -using NzbDrone.Core.MetadataSource; - -namespace NzbDrone.Core.Music -{ - public interface IAddAlbumService - { - Book AddAlbum(Book album, bool doRefresh = true); - List AddAlbums(List albums, bool doRefresh = true); - } - - public class AddAlbumService : IAddAlbumService - { - private readonly IArtistService _artistService; - private readonly IAddArtistService _addArtistService; - private readonly IAlbumService _albumService; - private readonly IProvideBookInfo _albumInfo; - private readonly IImportListExclusionService _importListExclusionService; - private readonly Logger _logger; - - public AddAlbumService(IArtistService artistService, - IAddArtistService addArtistService, - IAlbumService albumService, - IProvideBookInfo albumInfo, - IImportListExclusionService importListExclusionService, - Logger logger) - { - _artistService = artistService; - _addArtistService = addArtistService; - _albumService = albumService; - _albumInfo = albumInfo; - _importListExclusionService = importListExclusionService; - _logger = logger; - } - - public Book AddAlbum(Book album, bool doRefresh = true) - { - _logger.Debug($"Adding album {album}"); - - album = AddSkyhookData(album); - - // Remove any import list exclusions preventing addition - _importListExclusionService.Delete(album.ForeignBookId); - _importListExclusionService.Delete(album.AuthorMetadata.Value.ForeignAuthorId); - - // Note it's a manual addition so it's not deleted on next refresh - album.AddOptions.AddType = AlbumAddType.Manual; - - // Add the artist if necessary - var dbArtist = _artistService.FindById(album.AuthorMetadata.Value.ForeignAuthorId); - if (dbArtist == null) - { - var artist = album.Author.Value; - - artist.Metadata.Value.ForeignAuthorId = album.AuthorMetadata.Value.ForeignAuthorId; - - dbArtist = _addArtistService.AddArtist(artist, false); - } - - album.Author = dbArtist; - album.AuthorMetadataId = dbArtist.AuthorMetadataId; - _albumService.AddAlbum(album, doRefresh); - - return album; - } - - public List AddAlbums(List albums, bool doRefresh = true) - { - var added = DateTime.UtcNow; - var addedAlbums = new List(); - - foreach (var a in albums) - { - a.Added = added; - try - { - addedAlbums.Add(AddAlbum(a, doRefresh)); - } - catch (Exception ex) - { - // Could be a bad id from an import list - _logger.Error(ex, "Failed to import id: {0} - {1}", a.ForeignBookId, a.Title); - } - } - - return addedAlbums; - } - - private Book AddSkyhookData(Book newAlbum) - { - Tuple> tuple = null; - try - { - tuple = _albumInfo.GetBookInfo(newAlbum.ForeignBookId); - } - catch (AlbumNotFoundException) - { - _logger.Error("Album with MusicBrainz Id {0} was not found, it may have been removed from Musicbrainz.", newAlbum.ForeignBookId); - - throw new ValidationException(new List - { - new ValidationFailure("MusicbrainzId", "An album with this ID was not found", newAlbum.ForeignBookId) - }); - } - - newAlbum.UseMetadataFrom(tuple.Item2); - newAlbum.Added = DateTime.UtcNow; - - var metadata = tuple.Item3.Single(x => x.ForeignAuthorId == tuple.Item1); - newAlbum.AuthorMetadata = metadata; - - return newAlbum; - } - } -} diff --git a/src/NzbDrone.Core/Books/Services/AddAuthorService.cs b/src/NzbDrone.Core/Books/Services/AddAuthorService.cs index 996b78609..4a0b6df87 100644 --- a/src/NzbDrone.Core/Books/Services/AddAuthorService.cs +++ b/src/NzbDrone.Core/Books/Services/AddAuthorService.cs @@ -12,70 +12,70 @@ using NzbDrone.Core.MetadataSource; using NzbDrone.Core.Organizer; using NzbDrone.Core.Parser; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { - public interface IAddArtistService + public interface IAddAuthorService { - Author AddArtist(Author newArtist, bool doRefresh = true); - List AddArtists(List newArtists, bool doRefresh = true); + Author AddAuthor(Author newAuthor, bool doRefresh = true); + List AddAuthors(List newAuthors, bool doRefresh = true); } - public class AddArtistService : IAddArtistService + public class AddArtistService : IAddAuthorService { - private readonly IArtistService _artistService; - private readonly IArtistMetadataService _artistMetadataService; - private readonly IProvideAuthorInfo _artistInfo; + private readonly IAuthorService _authorService; + private readonly IAuthorMetadataService _authorMetadataService; + private readonly IProvideAuthorInfo _authorInfo; private readonly IBuildFileNames _fileNameBuilder; - private readonly IAddArtistValidator _addArtistValidator; + private readonly IAddAuthorValidator _addAuthorValidator; private readonly Logger _logger; - public AddArtistService(IArtistService artistService, - IArtistMetadataService artistMetadataService, - IProvideAuthorInfo artistInfo, + public AddArtistService(IAuthorService authorService, + IAuthorMetadataService authorMetadataService, + IProvideAuthorInfo authorInfo, IBuildFileNames fileNameBuilder, - IAddArtistValidator addArtistValidator, + IAddAuthorValidator addAuthorValidator, Logger logger) { - _artistService = artistService; - _artistMetadataService = artistMetadataService; - _artistInfo = artistInfo; + _authorService = authorService; + _authorMetadataService = authorMetadataService; + _authorInfo = authorInfo; _fileNameBuilder = fileNameBuilder; - _addArtistValidator = addArtistValidator; + _addAuthorValidator = addAuthorValidator; _logger = logger; } - public Author AddArtist(Author newArtist, bool doRefresh = true) + public Author AddAuthor(Author newAuthor, bool doRefresh = true) { - Ensure.That(newArtist, () => newArtist).IsNotNull(); + Ensure.That(newAuthor, () => newAuthor).IsNotNull(); - newArtist = AddSkyhookData(newArtist); - newArtist = SetPropertiesAndValidate(newArtist); + newAuthor = AddSkyhookData(newAuthor); + newAuthor = SetPropertiesAndValidate(newAuthor); - _logger.Info("Adding Artist {0} Path: [{1}]", newArtist, newArtist.Path); + _logger.Info("Adding Author {0} Path: [{1}]", newAuthor, newAuthor.Path); // add metadata - _artistMetadataService.Upsert(newArtist.Metadata.Value); - newArtist.AuthorMetadataId = newArtist.Metadata.Value.Id; + _authorMetadataService.Upsert(newAuthor.Metadata.Value); + newAuthor.AuthorMetadataId = newAuthor.Metadata.Value.Id; - // add the artist itself - _artistService.AddArtist(newArtist, doRefresh); + // add the author itself + _authorService.AddAuthor(newAuthor, doRefresh); - return newArtist; + return newAuthor; } - public List AddArtists(List newArtists, bool doRefresh = true) + public List AddAuthors(List newAuthors, bool doRefresh = true) { var added = DateTime.UtcNow; - var artistsToAdd = new List(); + var authorsToAdd = new List(); - foreach (var s in newArtists) + foreach (var s in newAuthors) { try { - var artist = AddSkyhookData(s); - artist = SetPropertiesAndValidate(artist); - artist.Added = added; - artistsToAdd.Add(artist); + var author = AddSkyhookData(s); + author = SetPropertiesAndValidate(author); + author.Added = added; + authorsToAdd.Add(author); } catch (Exception ex) { @@ -85,53 +85,53 @@ namespace NzbDrone.Core.Music } // add metadata - _artistMetadataService.UpsertMany(artistsToAdd.Select(x => x.Metadata.Value).ToList()); - artistsToAdd.ForEach(x => x.AuthorMetadataId = x.Metadata.Value.Id); + _authorMetadataService.UpsertMany(authorsToAdd.Select(x => x.Metadata.Value).ToList()); + authorsToAdd.ForEach(x => x.AuthorMetadataId = x.Metadata.Value.Id); - return _artistService.AddArtists(artistsToAdd, doRefresh); + return _authorService.AddAuthors(authorsToAdd, doRefresh); } - private Author AddSkyhookData(Author newArtist) + private Author AddSkyhookData(Author newAuthor) { - Author artist; + Author author; try { - artist = _artistInfo.GetAuthorInfo(newArtist.Metadata.Value.ForeignAuthorId); + author = _authorInfo.GetAuthorInfo(newAuthor.Metadata.Value.ForeignAuthorId); } - catch (ArtistNotFoundException) + catch (AuthorNotFoundException) { - _logger.Error("ReadarrId {0} was not found, it may have been removed from Musicbrainz.", newArtist.Metadata.Value.ForeignAuthorId); + _logger.Error("ReadarrId {0} was not found, it may have been removed from Goodreads.", newAuthor.Metadata.Value.ForeignAuthorId); throw new ValidationException(new List { - new ValidationFailure("MusicbrainzId", "An artist with this ID was not found", newArtist.Metadata.Value.ForeignAuthorId) + new ValidationFailure("MusicbrainzId", "An author with this ID was not found", newAuthor.Metadata.Value.ForeignAuthorId) }); } - artist.ApplyChanges(newArtist); + author.ApplyChanges(newAuthor); - return artist; + return author; } - private Author SetPropertiesAndValidate(Author newArtist) + private Author SetPropertiesAndValidate(Author newAuthor) { - var path = newArtist.Path; + var path = newAuthor.Path; if (string.IsNullOrWhiteSpace(path)) { - var folderName = _fileNameBuilder.GetArtistFolder(newArtist); - path = Path.Combine(newArtist.RootFolderPath, folderName); + var folderName = _fileNameBuilder.GetAuthorFolder(newAuthor); + path = Path.Combine(newAuthor.RootFolderPath, folderName); } - // Disambiguate artist path if it exists already - if (_artistService.ArtistPathExists(path)) + // Disambiguate author path if it exists already + if (_authorService.AuthorPathExists(path)) { - if (newArtist.Metadata.Value.Disambiguation.IsNotNullOrWhiteSpace()) + if (newAuthor.Metadata.Value.Disambiguation.IsNotNullOrWhiteSpace()) { - path += $" ({newArtist.Metadata.Value.Disambiguation})"; + path += $" ({newAuthor.Metadata.Value.Disambiguation})"; } - if (_artistService.ArtistPathExists(path)) + if (_authorService.AuthorPathExists(path)) { var basepath = path; int i = 0; @@ -140,28 +140,28 @@ namespace NzbDrone.Core.Music i++; path = basepath + $" ({i})"; } - while (_artistService.ArtistPathExists(path)); + while (_authorService.AuthorPathExists(path)); } } - newArtist.Path = path; - newArtist.CleanName = newArtist.Metadata.Value.Name.CleanArtistName(); - newArtist.SortName = Parser.Parser.NormalizeTitle(newArtist.Metadata.Value.Name).ToLower(); - newArtist.Added = DateTime.UtcNow; + newAuthor.Path = path; + newAuthor.CleanName = newAuthor.Metadata.Value.Name.CleanAuthorName(); + newAuthor.SortName = Parser.Parser.NormalizeTitle(newAuthor.Metadata.Value.Name).ToLower(); + newAuthor.Added = DateTime.UtcNow; - if (newArtist.AddOptions != null && newArtist.AddOptions.Monitor == MonitorTypes.None) + if (newAuthor.AddOptions != null && newAuthor.AddOptions.Monitor == MonitorTypes.None) { - newArtist.Monitored = false; + newAuthor.Monitored = false; } - var validationResult = _addArtistValidator.Validate(newArtist); + var validationResult = _addAuthorValidator.Validate(newAuthor); if (!validationResult.IsValid) { throw new ValidationException(validationResult.Errors); } - return newArtist; + return newAuthor; } } } diff --git a/src/NzbDrone.Core/Books/Services/AddBookService.cs b/src/NzbDrone.Core/Books/Services/AddBookService.cs new file mode 100644 index 000000000..35ee14110 --- /dev/null +++ b/src/NzbDrone.Core/Books/Services/AddBookService.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using FluentValidation; +using FluentValidation.Results; +using NLog; +using NzbDrone.Core.Exceptions; +using NzbDrone.Core.ImportLists.Exclusions; +using NzbDrone.Core.MetadataSource; + +namespace NzbDrone.Core.Books +{ + public interface IAddBookService + { + Book AddBook(Book book, bool doRefresh = true); + List AddBooks(List books, bool doRefresh = true); + } + + public class AddBookService : IAddBookService + { + private readonly IAuthorService _authorService; + private readonly IAddAuthorService _addAuthorService; + private readonly IBookService _bookService; + private readonly IProvideBookInfo _bookInfo; + private readonly IImportListExclusionService _importListExclusionService; + private readonly Logger _logger; + + public AddBookService(IAuthorService authorService, + IAddAuthorService addAuthorService, + IBookService bookService, + IProvideBookInfo bookInfo, + IImportListExclusionService importListExclusionService, + Logger logger) + { + _authorService = authorService; + _addAuthorService = addAuthorService; + _bookService = bookService; + _bookInfo = bookInfo; + _importListExclusionService = importListExclusionService; + _logger = logger; + } + + public Book AddBook(Book book, bool doRefresh = true) + { + _logger.Debug($"Adding book {book}"); + + book = AddSkyhookData(book); + + // Remove any import list exclusions preventing addition + _importListExclusionService.Delete(book.ForeignBookId); + _importListExclusionService.Delete(book.AuthorMetadata.Value.ForeignAuthorId); + + // Note it's a manual addition so it's not deleted on next refresh + book.AddOptions.AddType = AlbumAddType.Manual; + + // Add the author if necessary + var dbAuthor = _authorService.FindById(book.AuthorMetadata.Value.ForeignAuthorId); + if (dbAuthor == null) + { + var author = book.Author.Value; + + author.Metadata.Value.ForeignAuthorId = book.AuthorMetadata.Value.ForeignAuthorId; + + dbAuthor = _addAuthorService.AddAuthor(author, false); + } + + book.Author = dbAuthor; + book.AuthorMetadataId = dbAuthor.AuthorMetadataId; + _bookService.AddBook(book, doRefresh); + + return book; + } + + public List AddBooks(List books, bool doRefresh = true) + { + var added = DateTime.UtcNow; + var addedBooks = new List(); + + foreach (var a in books) + { + a.Added = added; + try + { + addedBooks.Add(AddBook(a, doRefresh)); + } + catch (Exception ex) + { + // Could be a bad id from an import list + _logger.Error(ex, "Failed to import id: {0} - {1}", a.ForeignBookId, a.Title); + } + } + + return addedBooks; + } + + private Book AddSkyhookData(Book newBook) + { + Tuple> tuple = null; + try + { + tuple = _bookInfo.GetBookInfo(newBook.ForeignBookId); + } + catch (BookNotFoundException) + { + _logger.Error("Book with Foreign Id {0} was not found, it may have been removed from Goodreads.", newBook.ForeignBookId); + + throw new ValidationException(new List + { + new ValidationFailure("GoodreadsId", "A book with this ID was not found", newBook.ForeignBookId) + }); + } + + newBook.UseMetadataFrom(tuple.Item2); + newBook.Added = DateTime.UtcNow; + + var metadata = tuple.Item3.Single(x => x.ForeignAuthorId == tuple.Item1); + newBook.AuthorMetadata = metadata; + + return newBook; + } + } +} diff --git a/src/NzbDrone.Core/Books/Services/AlbumMonitoredService.cs b/src/NzbDrone.Core/Books/Services/AlbumMonitoredService.cs deleted file mode 100644 index 84fd75330..000000000 --- a/src/NzbDrone.Core/Books/Services/AlbumMonitoredService.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using NLog; - -namespace NzbDrone.Core.Music -{ - public interface IAlbumMonitoredService - { - void SetAlbumMonitoredStatus(Author artist, MonitoringOptions monitoringOptions); - } - - public class AlbumMonitoredService : IAlbumMonitoredService - { - private readonly IArtistService _artistService; - private readonly IAlbumService _albumService; - private readonly Logger _logger; - - public AlbumMonitoredService(IArtistService artistService, IAlbumService albumService, Logger logger) - { - _artistService = artistService; - _albumService = albumService; - _logger = logger; - } - - public void SetAlbumMonitoredStatus(Author artist, MonitoringOptions monitoringOptions) - { - if (monitoringOptions != null) - { - _logger.Debug("[{0}] Setting album monitored status.", artist.Name); - - var albums = _albumService.GetAlbumsByArtist(artist.Id); - - var albumsWithFiles = _albumService.GetArtistAlbumsWithFiles(artist); - - var albumsWithoutFiles = albums.Where(c => !albumsWithFiles.Select(e => e.Id).Contains(c.Id) && c.ReleaseDate <= DateTime.UtcNow).ToList(); - - var monitoredAlbums = monitoringOptions.AlbumsToMonitor; - - // If specific albums are passed use those instead of the monitoring options. - if (monitoredAlbums.Any()) - { - ToggleAlbumsMonitoredState( - albums.Where(s => monitoredAlbums.Any(t => t == s.ForeignBookId)), true); - ToggleAlbumsMonitoredState( - albums.Where(s => monitoredAlbums.Any(t => t != s.ForeignBookId)), false); - } - else - { - switch (monitoringOptions.Monitor) - { - case MonitorTypes.All: - ToggleAlbumsMonitoredState(albums, true); - break; - case MonitorTypes.Future: - _logger.Debug("Unmonitoring Albums with Files"); - ToggleAlbumsMonitoredState(albums.Where(e => albumsWithFiles.Select(c => c.Id).Contains(e.Id)), false); - _logger.Debug("Unmonitoring Albums without Files"); - ToggleAlbumsMonitoredState(albums.Where(e => albumsWithoutFiles.Select(c => c.Id).Contains(e.Id)), false); - break; - case MonitorTypes.None: - ToggleAlbumsMonitoredState(albums, false); - break; - case MonitorTypes.Missing: - _logger.Debug("Unmonitoring Albums with Files"); - ToggleAlbumsMonitoredState(albums.Where(e => albumsWithFiles.Select(c => c.Id).Contains(e.Id)), false); - _logger.Debug("Monitoring Albums without Files"); - ToggleAlbumsMonitoredState(albums.Where(e => albumsWithoutFiles.Select(c => c.Id).Contains(e.Id)), true); - break; - case MonitorTypes.Existing: - _logger.Debug("Monitoring Albums with Files"); - ToggleAlbumsMonitoredState(albums.Where(e => albumsWithFiles.Select(c => c.Id).Contains(e.Id)), true); - _logger.Debug("Unmonitoring Albums without Files"); - ToggleAlbumsMonitoredState(albums.Where(e => albumsWithoutFiles.Select(c => c.Id).Contains(e.Id)), false); - break; - case MonitorTypes.Latest: - ToggleAlbumsMonitoredState(albums, false); - ToggleAlbumsMonitoredState(albums.OrderByDescending(e => e.ReleaseDate).Take(1), true); - break; - case MonitorTypes.First: - ToggleAlbumsMonitoredState(albums, false); - ToggleAlbumsMonitoredState(albums.OrderBy(e => e.ReleaseDate).Take(1), true); - break; - default: - throw new ArgumentOutOfRangeException(); - } - } - - _albumService.UpdateMany(albums); - } - - _artistService.UpdateArtist(artist); - } - - private void ToggleAlbumsMonitoredState(IEnumerable albums, bool monitored) - { - foreach (var album in albums) - { - album.Monitored = monitored; - } - } - } -} diff --git a/src/NzbDrone.Core/Books/Services/AlbumService.cs b/src/NzbDrone.Core/Books/Services/AlbumService.cs deleted file mode 100644 index 6a16cf300..000000000 --- a/src/NzbDrone.Core/Books/Services/AlbumService.cs +++ /dev/null @@ -1,292 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using NLog; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Datastore; -using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music.Events; -using NzbDrone.Core.Parser; - -namespace NzbDrone.Core.Music -{ - public interface IAlbumService - { - Book GetAlbum(int bookId); - List GetAlbums(IEnumerable bookIds); - List GetAlbumsByArtist(int authorId); - List GetNextAlbumsByArtistMetadataId(IEnumerable artistMetadataIds); - List GetLastAlbumsByArtistMetadataId(IEnumerable artistMetadataIds); - List GetAlbumsByArtistMetadataId(int artistMetadataId); - List GetAlbumsForRefresh(int artistMetadataId, IEnumerable foreignIds); - List GetAlbumsByFileIds(IEnumerable fileIds); - Book AddAlbum(Book newAlbum, bool doRefresh = true); - Book FindById(string foreignId); - Book FindBySlug(string titleSlug); - Book FindByTitle(int artistMetadataId, string title); - Book FindByTitleInexact(int artistMetadataId, string title); - List GetCandidates(int artistMetadataId, string title); - void DeleteAlbum(int bookId, bool deleteFiles, bool addImportListExclusion = false); - List GetAllAlbums(); - Book UpdateAlbum(Book album); - void SetAlbumMonitored(int bookId, bool monitored); - void SetMonitored(IEnumerable ids, bool monitored); - PagingSpec AlbumsWithoutFiles(PagingSpec pagingSpec); - List AlbumsBetweenDates(DateTime start, DateTime end, bool includeUnmonitored); - List ArtistAlbumsBetweenDates(Author artist, DateTime start, DateTime end, bool includeUnmonitored); - void InsertMany(List albums); - void UpdateMany(List albums); - void DeleteMany(List albums); - void SetAddOptions(IEnumerable albums); - List GetArtistAlbumsWithFiles(Author artist); - } - - public class AlbumService : IAlbumService, - IHandle - { - private readonly IAlbumRepository _albumRepository; - private readonly IEventAggregator _eventAggregator; - private readonly Logger _logger; - - public AlbumService(IAlbumRepository albumRepository, - IEventAggregator eventAggregator, - Logger logger) - { - _albumRepository = albumRepository; - _eventAggregator = eventAggregator; - _logger = logger; - } - - public Book AddAlbum(Book newAlbum, bool doRefresh = true) - { - _albumRepository.Insert(newAlbum); - - _eventAggregator.PublishEvent(new AlbumAddedEvent(GetAlbum(newAlbum.Id), doRefresh)); - - return newAlbum; - } - - public void DeleteAlbum(int bookId, bool deleteFiles, bool addImportListExclusion = false) - { - var album = _albumRepository.Get(bookId); - album.Author.LazyLoad(); - _albumRepository.Delete(bookId); - _eventAggregator.PublishEvent(new AlbumDeletedEvent(album, deleteFiles, addImportListExclusion)); - } - - public Book FindById(string foreignId) - { - return _albumRepository.FindById(foreignId); - } - - public Book FindBySlug(string titleSlug) - { - return _albumRepository.FindBySlug(titleSlug); - } - - public Book FindByTitle(int artistMetadataId, string title) - { - return _albumRepository.FindByTitle(artistMetadataId, title); - } - - private List, string>> AlbumScoringFunctions(string title, string cleanTitle) - { - Func, string, Tuple, string>> tc = Tuple.Create; - var scoringFunctions = new List, string>> - { - tc((a, t) => a.CleanTitle.FuzzyMatch(t), cleanTitle), - tc((a, t) => a.Title.FuzzyMatch(t), title), - tc((a, t) => a.CleanTitle.FuzzyMatch(t), title.RemoveBracketsAndContents().CleanArtistName()), - tc((a, t) => a.CleanTitle.FuzzyMatch(t), title.RemoveAfterDash().CleanArtistName()), - tc((a, t) => a.CleanTitle.FuzzyMatch(t), title.RemoveBracketsAndContents().RemoveAfterDash().CleanArtistName()), - tc((a, t) => t.FuzzyContains(a.CleanTitle), cleanTitle), - tc((a, t) => t.FuzzyContains(a.Title), title) - }; - - return scoringFunctions; - } - - public Book FindByTitleInexact(int artistMetadataId, string title) - { - var albums = GetAlbumsByArtistMetadataId(artistMetadataId); - - foreach (var func in AlbumScoringFunctions(title, title.CleanArtistName())) - { - var results = FindByStringInexact(albums, func.Item1, func.Item2); - if (results.Count == 1) - { - return results[0]; - } - } - - return null; - } - - public List GetCandidates(int artistMetadataId, string title) - { - var albums = GetAlbumsByArtistMetadataId(artistMetadataId); - var output = new List(); - - foreach (var func in AlbumScoringFunctions(title, title.CleanArtistName())) - { - output.AddRange(FindByStringInexact(albums, func.Item1, func.Item2)); - } - - return output.DistinctBy(x => x.Id).ToList(); - } - - private List FindByStringInexact(List albums, Func scoreFunction, string title) - { - const double fuzzThreshold = 0.7; - const double fuzzGap = 0.4; - - var sortedAlbums = albums.Select(s => new - { - MatchProb = scoreFunction(s, title), - Album = s - }) - .ToList() - .OrderByDescending(s => s.MatchProb) - .ToList(); - - return sortedAlbums.TakeWhile((x, i) => i == 0 || sortedAlbums[i - 1].MatchProb - x.MatchProb < fuzzGap) - .TakeWhile((x, i) => x.MatchProb > fuzzThreshold || (i > 0 && sortedAlbums[i - 1].MatchProb > fuzzThreshold)) - .Select(x => x.Album) - .ToList(); - } - - public List GetAllAlbums() - { - return _albumRepository.All().ToList(); - } - - public Book GetAlbum(int bookId) - { - return _albumRepository.Get(bookId); - } - - public List GetAlbums(IEnumerable bookIds) - { - return _albumRepository.Get(bookIds).ToList(); - } - - public List GetAlbumsByArtist(int authorId) - { - return _albumRepository.GetAlbums(authorId).ToList(); - } - - public List GetNextAlbumsByArtistMetadataId(IEnumerable artistMetadataIds) - { - return _albumRepository.GetNextAlbums(artistMetadataIds).ToList(); - } - - public List GetLastAlbumsByArtistMetadataId(IEnumerable artistMetadataIds) - { - return _albumRepository.GetLastAlbums(artistMetadataIds).ToList(); - } - - public List GetAlbumsByArtistMetadataId(int artistMetadataId) - { - return _albumRepository.GetAlbumsByArtistMetadataId(artistMetadataId).ToList(); - } - - public List GetAlbumsForRefresh(int artistMetadataId, IEnumerable foreignIds) - { - return _albumRepository.GetAlbumsForRefresh(artistMetadataId, foreignIds); - } - - public List GetAlbumsByFileIds(IEnumerable fileIds) - { - return _albumRepository.GetAlbumsByFileIds(fileIds); - } - - public void SetAddOptions(IEnumerable albums) - { - _albumRepository.SetFields(albums.ToList(), s => s.AddOptions); - } - - public PagingSpec AlbumsWithoutFiles(PagingSpec pagingSpec) - { - var albumResult = _albumRepository.AlbumsWithoutFiles(pagingSpec); - - return albumResult; - } - - public List AlbumsBetweenDates(DateTime start, DateTime end, bool includeUnmonitored) - { - var albums = _albumRepository.AlbumsBetweenDates(start.ToUniversalTime(), end.ToUniversalTime(), includeUnmonitored); - - return albums; - } - - public List ArtistAlbumsBetweenDates(Author artist, DateTime start, DateTime end, bool includeUnmonitored) - { - var albums = _albumRepository.ArtistAlbumsBetweenDates(artist, start.ToUniversalTime(), end.ToUniversalTime(), includeUnmonitored); - - return albums; - } - - public List GetArtistAlbumsWithFiles(Author artist) - { - return _albumRepository.GetArtistAlbumsWithFiles(artist); - } - - public void InsertMany(List albums) - { - _albumRepository.InsertMany(albums); - } - - public void UpdateMany(List albums) - { - _albumRepository.UpdateMany(albums); - } - - public void DeleteMany(List albums) - { - _albumRepository.DeleteMany(albums); - - foreach (var album in albums) - { - _eventAggregator.PublishEvent(new AlbumDeletedEvent(album, false, false)); - } - } - - public Book UpdateAlbum(Book album) - { - var storedAlbum = GetAlbum(album.Id); - var updatedAlbum = _albumRepository.Update(album); - - _eventAggregator.PublishEvent(new AlbumEditedEvent(updatedAlbum, storedAlbum)); - - return updatedAlbum; - } - - public void SetAlbumMonitored(int bookId, bool monitored) - { - var album = _albumRepository.Get(bookId); - _albumRepository.SetMonitoredFlat(album, monitored); - - // publish album edited event so artist stats update - _eventAggregator.PublishEvent(new AlbumEditedEvent(album, album)); - - _logger.Debug("Monitored flag for Album:{0} was set to {1}", bookId, monitored); - } - - public void SetMonitored(IEnumerable ids, bool monitored) - { - _albumRepository.SetMonitored(ids, monitored); - - // publish album edited event so artist stats update - foreach (var album in _albumRepository.Get(ids)) - { - _eventAggregator.PublishEvent(new AlbumEditedEvent(album, album)); - } - } - - public void Handle(ArtistDeletedEvent message) - { - var albums = GetAlbumsByArtistMetadataId(message.Artist.AuthorMetadataId); - DeleteMany(albums); - } - } -} diff --git a/src/NzbDrone.Core/Books/Services/ArtistMetadataService.cs b/src/NzbDrone.Core/Books/Services/ArtistMetadataService.cs deleted file mode 100644 index 6b02f908c..000000000 --- a/src/NzbDrone.Core/Books/Services/ArtistMetadataService.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Collections.Generic; - -namespace NzbDrone.Core.Music -{ - public interface IArtistMetadataService - { - bool Upsert(AuthorMetadata artist); - bool UpsertMany(List artists); - } - - public class ArtistMetadataService : IArtistMetadataService - { - private readonly IArtistMetadataRepository _artistMetadataRepository; - - public ArtistMetadataService(IArtistMetadataRepository artistMetadataRepository) - { - _artistMetadataRepository = artistMetadataRepository; - } - - public bool Upsert(AuthorMetadata artist) - { - return _artistMetadataRepository.UpsertMany(new List { artist }); - } - - public bool UpsertMany(List artists) - { - return _artistMetadataRepository.UpsertMany(artists); - } - } -} diff --git a/src/NzbDrone.Core/Books/Services/AuthorMetadataService.cs b/src/NzbDrone.Core/Books/Services/AuthorMetadataService.cs new file mode 100644 index 000000000..966a841be --- /dev/null +++ b/src/NzbDrone.Core/Books/Services/AuthorMetadataService.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; + +namespace NzbDrone.Core.Books +{ + public interface IAuthorMetadataService + { + bool Upsert(AuthorMetadata author); + bool UpsertMany(List authors); + } + + public class AuthorMetadataService : IAuthorMetadataService + { + private readonly IAuthorMetadataRepository _authorMetadataRepository; + + public AuthorMetadataService(IAuthorMetadataRepository authorMetadataRepository) + { + _authorMetadataRepository = authorMetadataRepository; + } + + public bool Upsert(AuthorMetadata author) + { + return _authorMetadataRepository.UpsertMany(new List { author }); + } + + public bool UpsertMany(List authors) + { + return _authorMetadataRepository.UpsertMany(authors); + } + } +} diff --git a/src/NzbDrone.Core/Books/Services/ArtistService.cs b/src/NzbDrone.Core/Books/Services/AuthorService.cs similarity index 50% rename from src/NzbDrone.Core/Books/Services/ArtistService.cs rename to src/NzbDrone.Core/Books/Services/AuthorService.cs index d29663539..1509351bf 100644 --- a/src/NzbDrone.Core/Books/Services/ArtistService.cs +++ b/src/NzbDrone.Core/Books/Services/AuthorService.cs @@ -4,108 +4,108 @@ using System.Linq; using NLog; using NzbDrone.Common.Cache; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books.Events; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music.Events; using NzbDrone.Core.Parser; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { - public interface IArtistService + public interface IAuthorService { - Author GetArtist(int authorId); - Author GetArtistByMetadataId(int artistMetadataId); - List GetArtists(IEnumerable authorIds); - Author AddArtist(Author newArtist, bool doRefresh); - List AddArtists(List newArtists, bool doRefresh); + Author GetAuthor(int authorId); + Author GetAuthorByMetadataId(int authorMetadataId); + List GetAuthors(IEnumerable authorIds); + Author AddAuthor(Author newAuthor, bool doRefresh); + List AddAuthors(List newAuthors, bool doRefresh); Author FindById(string foreignAuthorId); Author FindByName(string title); Author FindByNameInexact(string title); List GetCandidates(string title); List GetReportCandidates(string reportTitle); - void DeleteArtist(int authorId, bool deleteFiles, bool addImportListExclusion = false); - List GetAllArtists(); + void DeleteAuthor(int authorId, bool deleteFiles, bool addImportListExclusion = false); + List GetAllAuthors(); List AllForTag(int tagId); - Author UpdateArtist(Author artist); - List UpdateArtists(List artist, bool useExistingRelativeFolder); - bool ArtistPathExists(string folder); - void RemoveAddOptions(Author artist); + Author UpdateAuthor(Author author); + List UpdateAuthors(List authors, bool useExistingRelativeFolder); + bool AuthorPathExists(string folder); + void RemoveAddOptions(Author author); } - public class ArtistService : IArtistService + public class AuthorService : IAuthorService { - private readonly IArtistRepository _artistRepository; + private readonly IAuthorRepository _authorRepository; private readonly IEventAggregator _eventAggregator; - private readonly IBuildArtistPaths _artistPathBuilder; + private readonly IBuildAuthorPaths _authorPathBuilder; private readonly Logger _logger; private readonly ICached> _cache; - public ArtistService(IArtistRepository artistRepository, + public AuthorService(IAuthorRepository authorRepository, IEventAggregator eventAggregator, - IBuildArtistPaths artistPathBuilder, + IBuildAuthorPaths authorPathBuilder, ICacheManager cacheManager, Logger logger) { - _artistRepository = artistRepository; + _authorRepository = authorRepository; _eventAggregator = eventAggregator; - _artistPathBuilder = artistPathBuilder; + _authorPathBuilder = authorPathBuilder; _cache = cacheManager.GetCache>(GetType()); _logger = logger; } - public Author AddArtist(Author newArtist, bool doRefresh) + public Author AddAuthor(Author newAuthor, bool doRefresh) { _cache.Clear(); - _artistRepository.Insert(newArtist); - _eventAggregator.PublishEvent(new ArtistAddedEvent(GetArtist(newArtist.Id), doRefresh)); + _authorRepository.Insert(newAuthor); + _eventAggregator.PublishEvent(new AuthorAddedEvent(GetAuthor(newAuthor.Id), doRefresh)); - return newArtist; + return newAuthor; } - public List AddArtists(List newArtists, bool doRefresh) + public List AddAuthors(List newAuthors, bool doRefresh) { _cache.Clear(); - _artistRepository.InsertMany(newArtists); - _eventAggregator.PublishEvent(new ArtistsImportedEvent(newArtists.Select(s => s.Id).ToList(), doRefresh)); + _authorRepository.InsertMany(newAuthors); + _eventAggregator.PublishEvent(new AuthorsImportedEvent(newAuthors.Select(s => s.Id).ToList(), doRefresh)); - return newArtists; + return newAuthors; } - public bool ArtistPathExists(string folder) + public bool AuthorPathExists(string folder) { - return _artistRepository.ArtistPathExists(folder); + return _authorRepository.AuthorPathExists(folder); } - public void DeleteArtist(int authorId, bool deleteFiles, bool addImportListExclusion = false) + public void DeleteAuthor(int authorId, bool deleteFiles, bool addImportListExclusion = false) { _cache.Clear(); - var artist = _artistRepository.Get(authorId); - _artistRepository.Delete(authorId); - _eventAggregator.PublishEvent(new ArtistDeletedEvent(artist, deleteFiles, addImportListExclusion)); + var author = _authorRepository.Get(authorId); + _authorRepository.Delete(authorId); + _eventAggregator.PublishEvent(new AuthorDeletedEvent(author, deleteFiles, addImportListExclusion)); } public Author FindById(string foreignAuthorId) { - return _artistRepository.FindById(foreignAuthorId); + return _authorRepository.FindById(foreignAuthorId); } public Author FindByName(string title) { - return _artistRepository.FindByName(title.CleanArtistName()); + return _authorRepository.FindByName(title.CleanAuthorName()); } - public List, string>> ArtistScoringFunctions(string title, string cleanTitle) + public List, string>> AuthorScoringFunctions(string title, string cleanTitle) { Func, string, Tuple, string>> tc = Tuple.Create; var scoringFunctions = new List, string>> { tc((a, t) => a.CleanName.FuzzyMatch(t), cleanTitle), tc((a, t) => a.Name.FuzzyMatch(t), title), - tc((a, t) => a.Metadata.Value.Aliases.Concat(new List { a.Name }).Max(x => x.CleanArtistName().FuzzyMatch(t)), cleanTitle), + tc((a, t) => a.Metadata.Value.Aliases.Concat(new List { a.Name }).Max(x => x.CleanAuthorName().FuzzyMatch(t)), cleanTitle), }; if (title.StartsWith("The ", StringComparison.CurrentCultureIgnoreCase)) { - scoringFunctions.Add(tc((a, t) => a.CleanName.FuzzyMatch(t), title.Substring(4).CleanArtistName())); + scoringFunctions.Add(tc((a, t) => a.CleanName.FuzzyMatch(t), title.Substring(4).CleanAuthorName())); } else { @@ -117,11 +117,11 @@ namespace NzbDrone.Core.Music public Author FindByNameInexact(string title) { - var artists = GetAllArtists(); + var authors = GetAllAuthors(); - foreach (var func in ArtistScoringFunctions(title, title.CleanArtistName())) + foreach (var func in AuthorScoringFunctions(title, title.CleanAuthorName())) { - var results = FindByStringInexact(artists, func.Item1, func.Item2); + var results = FindByStringInexact(authors, func.Item1, func.Item2); if (results.Count == 1) { return results[0]; @@ -133,18 +133,18 @@ namespace NzbDrone.Core.Music public List GetCandidates(string title) { - var artists = GetAllArtists(); + var authors = GetAllAuthors(); var output = new List(); - foreach (var func in ArtistScoringFunctions(title, title.CleanArtistName())) + foreach (var func in AuthorScoringFunctions(title, title.CleanAuthorName())) { - output.AddRange(FindByStringInexact(artists, func.Item1, func.Item2)); + output.AddRange(FindByStringInexact(authors, func.Item1, func.Item2)); } return output.DistinctBy(x => x.Id).ToList(); } - public List, string>> ReportArtistScoringFunctions(string reportTitle, string cleanReportTitle) + public List, string>> ReportAuthorScoringFunctions(string reportTitle, string cleanReportTitle) { Func, string, Tuple, string>> tc = Tuple.Create; var scoringFunctions = new List, string>> @@ -158,90 +158,90 @@ namespace NzbDrone.Core.Music public List GetReportCandidates(string reportTitle) { - var artists = GetAllArtists(); + var authors = GetAllAuthors(); var output = new List(); - foreach (var func in ArtistScoringFunctions(reportTitle, reportTitle.CleanArtistName())) + foreach (var func in AuthorScoringFunctions(reportTitle, reportTitle.CleanAuthorName())) { - output.AddRange(FindByStringInexact(artists, func.Item1, func.Item2)); + output.AddRange(FindByStringInexact(authors, func.Item1, func.Item2)); } return output.DistinctBy(x => x.Id).ToList(); } - private List FindByStringInexact(List artists, Func scoreFunction, string title) + private List FindByStringInexact(List authors, Func scoreFunction, string title) { const double fuzzThreshold = 0.8; const double fuzzGap = 0.2; - var sortedArtists = artists.Select(s => new + var sortedAuthors = authors.Select(s => new { MatchProb = scoreFunction(s, title), - Artist = s + Author = s }) .ToList() .OrderByDescending(s => s.MatchProb) .ToList(); - return sortedArtists.TakeWhile((x, i) => i == 0 || sortedArtists[i - 1].MatchProb - x.MatchProb < fuzzGap) - .TakeWhile((x, i) => x.MatchProb > fuzzThreshold || (i > 0 && sortedArtists[i - 1].MatchProb > fuzzThreshold)) - .Select(x => x.Artist) + return sortedAuthors.TakeWhile((x, i) => i == 0 || sortedAuthors[i - 1].MatchProb - x.MatchProb < fuzzGap) + .TakeWhile((x, i) => x.MatchProb > fuzzThreshold || (i > 0 && sortedAuthors[i - 1].MatchProb > fuzzThreshold)) + .Select(x => x.Author) .ToList(); } - public List GetAllArtists() + public List GetAllAuthors() { - return _cache.Get("GetAllArtists", () => _artistRepository.All().ToList(), TimeSpan.FromSeconds(30)); + return _cache.Get("GetAllAuthors", () => _authorRepository.All().ToList(), TimeSpan.FromSeconds(30)); } public List AllForTag(int tagId) { - return GetAllArtists().Where(s => s.Tags.Contains(tagId)) + return GetAllAuthors().Where(s => s.Tags.Contains(tagId)) .ToList(); } - public Author GetArtist(int authorId) + public Author GetAuthor(int authorId) { - return _artistRepository.Get(authorId); + return _authorRepository.Get(authorId); } - public Author GetArtistByMetadataId(int artistMetadataId) + public Author GetAuthorByMetadataId(int authorMetadataId) { - return _artistRepository.GetArtistByMetadataId(artistMetadataId); + return _authorRepository.GetAuthorByMetadataId(authorMetadataId); } - public List GetArtists(IEnumerable authorIds) + public List GetAuthors(IEnumerable authorIds) { - return _artistRepository.Get(authorIds).ToList(); + return _authorRepository.Get(authorIds).ToList(); } - public void RemoveAddOptions(Author artist) + public void RemoveAddOptions(Author author) { - _artistRepository.SetFields(artist, s => s.AddOptions); + _authorRepository.SetFields(author, s => s.AddOptions); } - public Author UpdateArtist(Author artist) + public Author UpdateAuthor(Author author) { _cache.Clear(); - var storedArtist = GetArtist(artist.Id); - var updatedArtist = _artistRepository.Update(artist); - _eventAggregator.PublishEvent(new ArtistEditedEvent(updatedArtist, storedArtist)); + var storedAuthor = GetAuthor(author.Id); + var updatedAuthor = _authorRepository.Update(author); + _eventAggregator.PublishEvent(new AuthorEditedEvent(updatedAuthor, storedAuthor)); - return updatedArtist; + return updatedAuthor; } - public List UpdateArtists(List artist, bool useExistingRelativeFolder) + public List UpdateAuthors(List author, bool useExistingRelativeFolder) { _cache.Clear(); - _logger.Debug("Updating {0} artist", artist.Count); + _logger.Debug("Updating {0} author", author.Count); - foreach (var s in artist) + foreach (var s in author) { _logger.Trace("Updating: {0}", s.Name); if (!s.RootFolderPath.IsNullOrWhiteSpace()) { - s.Path = _artistPathBuilder.BuildPath(s, useExistingRelativeFolder); + s.Path = _authorPathBuilder.BuildPath(s, useExistingRelativeFolder); _logger.Trace("Changing path for {0} to {1}", s.Name, s.Path); } @@ -251,10 +251,10 @@ namespace NzbDrone.Core.Music } } - _artistRepository.UpdateMany(artist); - _logger.Debug("{0} artists updated", artist.Count); + _authorRepository.UpdateMany(author); + _logger.Debug("{0} authors updated", author.Count); - return artist; + return author; } } } diff --git a/src/NzbDrone.Core/Books/Services/AlbumAddedService.cs b/src/NzbDrone.Core/Books/Services/BookAddedService.cs similarity index 50% rename from src/NzbDrone.Core/Books/Services/AlbumAddedService.cs rename to src/NzbDrone.Core/Books/Services/BookAddedService.cs index 6841b8355..79a5082b4 100644 --- a/src/NzbDrone.Core/Books/Services/AlbumAddedService.cs +++ b/src/NzbDrone.Core/Books/Services/BookAddedService.cs @@ -4,81 +4,81 @@ using System.Linq; using NLog; using NzbDrone.Common.Cache; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books.Events; using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music.Events; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { - public interface IAlbumAddedService + public interface IBookAddedService { void SearchForRecentlyAdded(int authorId); } - public class AlbumAddedService : IHandle, IAlbumAddedService + public class BookAddedService : IHandle, IBookAddedService { private readonly IManageCommandQueue _commandQueueManager; - private readonly IAlbumService _albumService; + private readonly IBookService _bookService; private readonly Logger _logger; - private readonly ICached> _addedAlbumsCache; + private readonly ICached> _addedBooksCache; - public AlbumAddedService(ICacheManager cacheManager, + public BookAddedService(ICacheManager cacheManager, IManageCommandQueue commandQueueManager, - IAlbumService albumService, + IBookService bookService, Logger logger) { _commandQueueManager = commandQueueManager; - _albumService = albumService; + _bookService = bookService; _logger = logger; - _addedAlbumsCache = cacheManager.GetCache>(GetType()); + _addedBooksCache = cacheManager.GetCache>(GetType()); } public void SearchForRecentlyAdded(int authorId) { - var allAlbums = _albumService.GetAlbumsByArtist(authorId); - var toSearch = allAlbums.Where(x => x.AddOptions.SearchForNewAlbum).ToList(); + var allBooks = _bookService.GetBooksByAuthor(authorId); + var toSearch = allBooks.Where(x => x.AddOptions.SearchForNewAlbum).ToList(); if (toSearch.Any()) { toSearch.ForEach(x => x.AddOptions.SearchForNewAlbum = false); - _albumService.SetAddOptions(toSearch); + _bookService.SetAddOptions(toSearch); } - var recentlyAddedIds = _addedAlbumsCache.Find(authorId.ToString()); + var recentlyAddedIds = _addedBooksCache.Find(authorId.ToString()); if (recentlyAddedIds != null) { - toSearch.AddRange(allAlbums.Where(x => recentlyAddedIds.Contains(x.Id))); + toSearch.AddRange(allBooks.Where(x => recentlyAddedIds.Contains(x.Id))); } if (toSearch.Any()) { - _commandQueueManager.Push(new AlbumSearchCommand(toSearch.Select(e => e.Id).ToList())); + _commandQueueManager.Push(new BookSearchCommand(toSearch.Select(e => e.Id).ToList())); } - _addedAlbumsCache.Remove(authorId.ToString()); + _addedBooksCache.Remove(authorId.ToString()); } - public void Handle(AlbumInfoRefreshedEvent message) + public void Handle(BookInfoRefreshedEvent message) { - if (message.Artist.AddOptions == null) + if (message.Author.AddOptions == null) { - if (!message.Artist.Monitored) + if (!message.Author.Monitored) { - _logger.Debug("Artist is not monitored"); + _logger.Debug("Author is not monitored"); return; } if (message.Added.Empty()) { - _logger.Debug("No new albums, skipping search"); + _logger.Debug("No new books, skipping search"); return; } if (message.Added.None(a => a.ReleaseDate.HasValue)) { - _logger.Debug("No new albums have an release date"); + _logger.Debug("No new books have an release date"); return; } @@ -86,11 +86,11 @@ namespace NzbDrone.Core.Music if (previouslyReleased.Empty()) { - _logger.Debug("Newly added albums all release in the future"); + _logger.Debug("Newly added books all release in the future"); return; } - _addedAlbumsCache.Set(message.Artist.Id.ToString(), previouslyReleased.Select(e => e.Id).ToList()); + _addedBooksCache.Set(message.Author.Id.ToString(), previouslyReleased.Select(e => e.Id).ToList()); } } } diff --git a/src/NzbDrone.Core/Books/Services/AlbumCutoffService.cs b/src/NzbDrone.Core/Books/Services/BookCutoffService.cs similarity index 61% rename from src/NzbDrone.Core/Books/Services/AlbumCutoffService.cs rename to src/NzbDrone.Core/Books/Services/BookCutoffService.cs index 31d877cf1..f61323cbd 100644 --- a/src/NzbDrone.Core/Books/Services/AlbumCutoffService.cs +++ b/src/NzbDrone.Core/Books/Services/BookCutoffService.cs @@ -4,25 +4,25 @@ using NzbDrone.Core.Datastore; using NzbDrone.Core.Profiles.Qualities; using NzbDrone.Core.Qualities; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { - public interface IAlbumCutoffService + public interface IBookCutoffService { - PagingSpec AlbumsWhereCutoffUnmet(PagingSpec pagingSpec); + PagingSpec BooksWhereCutoffUnmet(PagingSpec pagingSpec); } - public class AlbumCutoffService : IAlbumCutoffService + public class BookCutoffService : IBookCutoffService { - private readonly IAlbumRepository _albumRepository; + private readonly IBookRepository _bookRepository; private readonly IProfileService _profileService; - public AlbumCutoffService(IAlbumRepository albumRepository, IProfileService profileService) + public BookCutoffService(IBookRepository bookRepository, IProfileService profileService) { - _albumRepository = albumRepository; + _bookRepository = bookRepository; _profileService = profileService; } - public PagingSpec AlbumsWhereCutoffUnmet(PagingSpec pagingSpec) + public PagingSpec BooksWhereCutoffUnmet(PagingSpec pagingSpec) { var qualitiesBelowCutoff = new List(); var profiles = _profileService.All(); @@ -39,7 +39,7 @@ namespace NzbDrone.Core.Music } } - return _albumRepository.AlbumsWhereCutoffUnmet(pagingSpec, qualitiesBelowCutoff); + return _bookRepository.BooksWhereCutoffUnmet(pagingSpec, qualitiesBelowCutoff); } } } diff --git a/src/NzbDrone.Core/Books/Services/BookMonitoredService.cs b/src/NzbDrone.Core/Books/Services/BookMonitoredService.cs new file mode 100644 index 000000000..30d793d44 --- /dev/null +++ b/src/NzbDrone.Core/Books/Services/BookMonitoredService.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using NLog; + +namespace NzbDrone.Core.Books +{ + public interface IBookMonitoredService + { + void SetBookMonitoredStatus(Author author, MonitoringOptions monitoringOptions); + } + + public class BookMonitoredService : IBookMonitoredService + { + private readonly IAuthorService _authorService; + private readonly IBookService _bookService; + private readonly Logger _logger; + + public BookMonitoredService(IAuthorService authorService, IBookService bookService, Logger logger) + { + _authorService = authorService; + _bookService = bookService; + _logger = logger; + } + + public void SetBookMonitoredStatus(Author author, MonitoringOptions monitoringOptions) + { + if (monitoringOptions != null) + { + _logger.Debug("[{0}] Setting book monitored status.", author.Name); + + var books = _bookService.GetBooksByAuthor(author.Id); + + var booksWithFiles = _bookService.GetAuthorBooksWithFiles(author); + + var booksWithoutFiles = books.Where(c => !booksWithFiles.Select(e => e.Id).Contains(c.Id) && c.ReleaseDate <= DateTime.UtcNow).ToList(); + + var monitoredBooks = monitoringOptions.BooksToMonitor; + + // If specific books are passed use those instead of the monitoring options. + if (monitoredBooks.Any()) + { + ToggleBooksMonitoredState( + books.Where(s => monitoredBooks.Any(t => t == s.ForeignBookId)), true); + ToggleBooksMonitoredState( + books.Where(s => monitoredBooks.Any(t => t != s.ForeignBookId)), false); + } + else + { + switch (monitoringOptions.Monitor) + { + case MonitorTypes.All: + ToggleBooksMonitoredState(books, true); + break; + case MonitorTypes.Future: + _logger.Debug("Unmonitoring Books with Files"); + ToggleBooksMonitoredState(books.Where(e => booksWithFiles.Select(c => c.Id).Contains(e.Id)), false); + _logger.Debug("Unmonitoring Books without Files"); + ToggleBooksMonitoredState(books.Where(e => booksWithoutFiles.Select(c => c.Id).Contains(e.Id)), false); + break; + case MonitorTypes.None: + ToggleBooksMonitoredState(books, false); + break; + case MonitorTypes.Missing: + _logger.Debug("Unmonitoring Books with Files"); + ToggleBooksMonitoredState(books.Where(e => booksWithFiles.Select(c => c.Id).Contains(e.Id)), false); + _logger.Debug("Monitoring Books without Files"); + ToggleBooksMonitoredState(books.Where(e => booksWithoutFiles.Select(c => c.Id).Contains(e.Id)), true); + break; + case MonitorTypes.Existing: + _logger.Debug("Monitoring Books with Files"); + ToggleBooksMonitoredState(books.Where(e => booksWithFiles.Select(c => c.Id).Contains(e.Id)), true); + _logger.Debug("Unmonitoring Books without Files"); + ToggleBooksMonitoredState(books.Where(e => booksWithoutFiles.Select(c => c.Id).Contains(e.Id)), false); + break; + case MonitorTypes.Latest: + ToggleBooksMonitoredState(books, false); + ToggleBooksMonitoredState(books.OrderByDescending(e => e.ReleaseDate).Take(1), true); + break; + case MonitorTypes.First: + ToggleBooksMonitoredState(books, false); + ToggleBooksMonitoredState(books.OrderBy(e => e.ReleaseDate).Take(1), true); + break; + default: + throw new ArgumentOutOfRangeException(); + } + } + + _bookService.UpdateMany(books); + } + + _authorService.UpdateAuthor(author); + } + + private void ToggleBooksMonitoredState(IEnumerable books, bool monitored) + { + foreach (var book in books) + { + book.Monitored = monitored; + } + } + } +} diff --git a/src/NzbDrone.Core/Books/Services/BookService.cs b/src/NzbDrone.Core/Books/Services/BookService.cs new file mode 100644 index 000000000..2bb58cb24 --- /dev/null +++ b/src/NzbDrone.Core/Books/Services/BookService.cs @@ -0,0 +1,292 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using NLog; +using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books.Events; +using NzbDrone.Core.Datastore; +using NzbDrone.Core.Messaging.Events; +using NzbDrone.Core.Parser; + +namespace NzbDrone.Core.Books +{ + public interface IBookService + { + Book GetBook(int bookId); + List GetBooks(IEnumerable bookIds); + List GetBooksByAuthor(int authorId); + List GetNextBooksByAuthorMetadataId(IEnumerable authorMetadataIds); + List GetLastBooksByAuthorMetadataId(IEnumerable authorMetadataIds); + List GetBooksByAuthorMetadataId(int authorMetadataId); + List GetBooksForRefresh(int authorMetadataId, IEnumerable foreignIds); + List GetBooksByFileIds(IEnumerable fileIds); + Book AddBook(Book newAlbum, bool doRefresh = true); + Book FindById(string foreignId); + Book FindBySlug(string titleSlug); + Book FindByTitle(int authorMetadataId, string title); + Book FindByTitleInexact(int authorMetadataId, string title); + List GetCandidates(int authorMetadataId, string title); + void DeleteBook(int bookId, bool deleteFiles, bool addImportListExclusion = false); + List GetAllBooks(); + Book UpdateBook(Book book); + void SetBookMonitored(int bookId, bool monitored); + void SetMonitored(IEnumerable ids, bool monitored); + PagingSpec BooksWithoutFiles(PagingSpec pagingSpec); + List BooksBetweenDates(DateTime start, DateTime end, bool includeUnmonitored); + List AuthorBooksBetweenDates(Author author, DateTime start, DateTime end, bool includeUnmonitored); + void InsertMany(List books); + void UpdateMany(List books); + void DeleteMany(List books); + void SetAddOptions(IEnumerable books); + List GetAuthorBooksWithFiles(Author author); + } + + public class BookService : IBookService, + IHandle + { + private readonly IBookRepository _bookRepository; + private readonly IEventAggregator _eventAggregator; + private readonly Logger _logger; + + public BookService(IBookRepository bookRepository, + IEventAggregator eventAggregator, + Logger logger) + { + _bookRepository = bookRepository; + _eventAggregator = eventAggregator; + _logger = logger; + } + + public Book AddBook(Book newBook, bool doRefresh = true) + { + _bookRepository.Insert(newBook); + + _eventAggregator.PublishEvent(new BookAddedEvent(GetBook(newBook.Id), doRefresh)); + + return newBook; + } + + public void DeleteBook(int bookId, bool deleteFiles, bool addImportListExclusion = false) + { + var book = _bookRepository.Get(bookId); + book.Author.LazyLoad(); + _bookRepository.Delete(bookId); + _eventAggregator.PublishEvent(new BookDeletedEvent(book, deleteFiles, addImportListExclusion)); + } + + public Book FindById(string foreignId) + { + return _bookRepository.FindById(foreignId); + } + + public Book FindBySlug(string titleSlug) + { + return _bookRepository.FindBySlug(titleSlug); + } + + public Book FindByTitle(int authorMetadataId, string title) + { + return _bookRepository.FindByTitle(authorMetadataId, title); + } + + private List, string>> BookScoringFunctions(string title, string cleanTitle) + { + Func, string, Tuple, string>> tc = Tuple.Create; + var scoringFunctions = new List, string>> + { + tc((a, t) => a.CleanTitle.FuzzyMatch(t), cleanTitle), + tc((a, t) => a.Title.FuzzyMatch(t), title), + tc((a, t) => a.CleanTitle.FuzzyMatch(t), title.RemoveBracketsAndContents().CleanAuthorName()), + tc((a, t) => a.CleanTitle.FuzzyMatch(t), title.RemoveAfterDash().CleanAuthorName()), + tc((a, t) => a.CleanTitle.FuzzyMatch(t), title.RemoveBracketsAndContents().RemoveAfterDash().CleanAuthorName()), + tc((a, t) => t.FuzzyContains(a.CleanTitle), cleanTitle), + tc((a, t) => t.FuzzyContains(a.Title), title) + }; + + return scoringFunctions; + } + + public Book FindByTitleInexact(int authorMetadataId, string title) + { + var books = GetBooksByAuthorMetadataId(authorMetadataId); + + foreach (var func in BookScoringFunctions(title, title.CleanAuthorName())) + { + var results = FindByStringInexact(books, func.Item1, func.Item2); + if (results.Count == 1) + { + return results[0]; + } + } + + return null; + } + + public List GetCandidates(int authorMetadataId, string title) + { + var books = GetBooksByAuthorMetadataId(authorMetadataId); + var output = new List(); + + foreach (var func in BookScoringFunctions(title, title.CleanAuthorName())) + { + output.AddRange(FindByStringInexact(books, func.Item1, func.Item2)); + } + + return output.DistinctBy(x => x.Id).ToList(); + } + + private List FindByStringInexact(List books, Func scoreFunction, string title) + { + const double fuzzThreshold = 0.7; + const double fuzzGap = 0.4; + + var sortedBooks = books.Select(s => new + { + MatchProb = scoreFunction(s, title), + Album = s + }) + .ToList() + .OrderByDescending(s => s.MatchProb) + .ToList(); + + return sortedBooks.TakeWhile((x, i) => i == 0 || sortedBooks[i - 1].MatchProb - x.MatchProb < fuzzGap) + .TakeWhile((x, i) => x.MatchProb > fuzzThreshold || (i > 0 && sortedBooks[i - 1].MatchProb > fuzzThreshold)) + .Select(x => x.Album) + .ToList(); + } + + public List GetAllBooks() + { + return _bookRepository.All().ToList(); + } + + public Book GetBook(int bookId) + { + return _bookRepository.Get(bookId); + } + + public List GetBooks(IEnumerable bookIds) + { + return _bookRepository.Get(bookIds).ToList(); + } + + public List GetBooksByAuthor(int authorId) + { + return _bookRepository.GetBooks(authorId).ToList(); + } + + public List GetNextBooksByAuthorMetadataId(IEnumerable authorMetadataIds) + { + return _bookRepository.GetNextBooks(authorMetadataIds).ToList(); + } + + public List GetLastBooksByAuthorMetadataId(IEnumerable authorMetadataIds) + { + return _bookRepository.GetLastBooks(authorMetadataIds).ToList(); + } + + public List GetBooksByAuthorMetadataId(int authorMetadataId) + { + return _bookRepository.GetBooksByAuthorMetadataId(authorMetadataId).ToList(); + } + + public List GetBooksForRefresh(int authorMetadataId, IEnumerable foreignIds) + { + return _bookRepository.GetBooksForRefresh(authorMetadataId, foreignIds); + } + + public List GetBooksByFileIds(IEnumerable fileIds) + { + return _bookRepository.GetBooksByFileIds(fileIds); + } + + public void SetAddOptions(IEnumerable books) + { + _bookRepository.SetFields(books.ToList(), s => s.AddOptions); + } + + public PagingSpec BooksWithoutFiles(PagingSpec pagingSpec) + { + var bookResult = _bookRepository.BooksWithoutFiles(pagingSpec); + + return bookResult; + } + + public List BooksBetweenDates(DateTime start, DateTime end, bool includeUnmonitored) + { + var books = _bookRepository.BooksBetweenDates(start.ToUniversalTime(), end.ToUniversalTime(), includeUnmonitored); + + return books; + } + + public List AuthorBooksBetweenDates(Author author, DateTime start, DateTime end, bool includeUnmonitored) + { + var books = _bookRepository.AuthorBooksBetweenDates(author, start.ToUniversalTime(), end.ToUniversalTime(), includeUnmonitored); + + return books; + } + + public List GetAuthorBooksWithFiles(Author author) + { + return _bookRepository.GetArtistAlbumsWithFiles(author); + } + + public void InsertMany(List books) + { + _bookRepository.InsertMany(books); + } + + public void UpdateMany(List books) + { + _bookRepository.UpdateMany(books); + } + + public void DeleteMany(List books) + { + _bookRepository.DeleteMany(books); + + foreach (var book in books) + { + _eventAggregator.PublishEvent(new BookDeletedEvent(book, false, false)); + } + } + + public Book UpdateBook(Book book) + { + var storedBook = GetBook(book.Id); + var updatedBook = _bookRepository.Update(book); + + _eventAggregator.PublishEvent(new BookEditedEvent(updatedBook, storedBook)); + + return updatedBook; + } + + public void SetBookMonitored(int bookId, bool monitored) + { + var book = _bookRepository.Get(bookId); + _bookRepository.SetMonitoredFlat(book, monitored); + + // publish book edited event so author stats update + _eventAggregator.PublishEvent(new BookEditedEvent(book, book)); + + _logger.Debug("Monitored flag for Book:{0} was set to {1}", bookId, monitored); + } + + public void SetMonitored(IEnumerable ids, bool monitored) + { + _bookRepository.SetMonitored(ids, monitored); + + // publish book edited event so author stats update + foreach (var book in _bookRepository.Get(ids)) + { + _eventAggregator.PublishEvent(new BookEditedEvent(book, book)); + } + } + + public void Handle(AuthorDeletedEvent message) + { + var books = GetBooksByAuthorMetadataId(message.Author.AuthorMetadataId); + DeleteMany(books); + } + } +} diff --git a/src/NzbDrone.Core/Books/Services/MoveArtistService.cs b/src/NzbDrone.Core/Books/Services/MoveAuthorService.cs similarity index 59% rename from src/NzbDrone.Core/Books/Services/MoveArtistService.cs rename to src/NzbDrone.Core/Books/Services/MoveAuthorService.cs index da9613ffc..5bef3065f 100644 --- a/src/NzbDrone.Core/Books/Services/MoveArtistService.cs +++ b/src/NzbDrone.Core/Books/Services/MoveAuthorService.cs @@ -2,18 +2,18 @@ using System.IO; using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.Instrumentation.Extensions; +using NzbDrone.Core.Books.Commands; +using NzbDrone.Core.Books.Events; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music.Commands; -using NzbDrone.Core.Music.Events; using NzbDrone.Core.Organizer; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { - public class MoveArtistService : IExecute, IExecute + public class MoveAuthorService : IExecute, IExecute { - private readonly IArtistService _artistService; + private readonly IAuthorService _authorService; private readonly IBuildFileNames _filenameBuilder; private readonly IDiskProvider _diskProvider; private readonly IRootFolderWatchingService _rootFolderWatchingService; @@ -21,7 +21,7 @@ namespace NzbDrone.Core.Music private readonly IEventAggregator _eventAggregator; private readonly Logger _logger; - public MoveArtistService(IArtistService artistService, + public MoveAuthorService(IAuthorService authorService, IBuildFileNames filenameBuilder, IDiskProvider diskProvider, IRootFolderWatchingService rootFolderWatchingService, @@ -29,7 +29,7 @@ namespace NzbDrone.Core.Music IEventAggregator eventAggregator, Logger logger) { - _artistService = artistService; + _authorService = authorService; _filenameBuilder = filenameBuilder; _diskProvider = diskProvider; _rootFolderWatchingService = rootFolderWatchingService; @@ -38,21 +38,21 @@ namespace NzbDrone.Core.Music _logger = logger; } - private void MoveSingleArtist(Author artist, string sourcePath, string destinationPath, int? index = null, int? total = null) + private void MoveSingleArtist(Author author, string sourcePath, string destinationPath, int? index = null, int? total = null) { if (!_diskProvider.FolderExists(sourcePath)) { - _logger.Debug("Folder '{0}' for '{1}' does not exist, not moving.", sourcePath, artist.Name); + _logger.Debug("Folder '{0}' for '{1}' does not exist, not moving.", sourcePath, author.Name); return; } if (index != null && total != null) { - _logger.ProgressInfo("Moving {0} from '{1}' to '{2}' ({3}/{4})", artist.Name, sourcePath, destinationPath, index + 1, total); + _logger.ProgressInfo("Moving {0} from '{1}' to '{2}' ({3}/{4})", author.Name, sourcePath, destinationPath, index + 1, total); } else { - _logger.ProgressInfo("Moving {0} from '{1}' to '{2}'", artist.Name, sourcePath, destinationPath); + _logger.ProgressInfo("Moving {0} from '{1}' to '{2}'", author.Name, sourcePath, destinationPath); } try @@ -61,49 +61,49 @@ namespace NzbDrone.Core.Music _diskTransferService.TransferFolder(sourcePath, destinationPath, TransferMode.Move); - _logger.ProgressInfo("{0} moved successfully to {1}", artist.Name, artist.Path); + _logger.ProgressInfo("{0} moved successfully to {1}", author.Name, author.Path); - _eventAggregator.PublishEvent(new ArtistMovedEvent(artist, sourcePath, destinationPath)); + _eventAggregator.PublishEvent(new AuthorMovedEvent(author, sourcePath, destinationPath)); } catch (IOException ex) { - _logger.Error(ex, "Unable to move artist from '{0}' to '{1}'. Try moving files manually", sourcePath, destinationPath); + _logger.Error(ex, "Unable to move author from '{0}' to '{1}'. Try moving files manually", sourcePath, destinationPath); - RevertPath(artist.Id, sourcePath); + RevertPath(author.Id, sourcePath); } } private void RevertPath(int authorId, string path) { - var artist = _artistService.GetArtist(authorId); + var author = _authorService.GetAuthor(authorId); - artist.Path = path; - _artistService.UpdateArtist(artist); + author.Path = path; + _authorService.UpdateAuthor(author); } - public void Execute(MoveArtistCommand message) + public void Execute(MoveAuthorCommand message) { - var artist = _artistService.GetArtist(message.AuthorId); - MoveSingleArtist(artist, message.SourcePath, message.DestinationPath); + var author = _authorService.GetAuthor(message.AuthorId); + MoveSingleArtist(author, message.SourcePath, message.DestinationPath); } - public void Execute(BulkMoveArtistCommand message) + public void Execute(BulkMoveAuthorCommand message) { - var artistToMove = message.Artist; + var authorToMove = message.Author; var destinationRootFolder = message.DestinationRootFolder; - _logger.ProgressInfo("Moving {0} artist to '{1}'", artistToMove.Count, destinationRootFolder); + _logger.ProgressInfo("Moving {0} author to '{1}'", authorToMove.Count, destinationRootFolder); - for (var index = 0; index < artistToMove.Count; index++) + for (var index = 0; index < authorToMove.Count; index++) { - var s = artistToMove[index]; - var artist = _artistService.GetArtist(s.AuthorId); - var destinationPath = Path.Combine(destinationRootFolder, _filenameBuilder.GetArtistFolder(artist)); + var s = authorToMove[index]; + var author = _authorService.GetAuthor(s.AuthorId); + var destinationPath = Path.Combine(destinationRootFolder, _filenameBuilder.GetAuthorFolder(author)); - MoveSingleArtist(artist, s.SourcePath, destinationPath, index, artistToMove.Count); + MoveSingleArtist(author, s.SourcePath, destinationPath, index, authorToMove.Count); } - _logger.ProgressInfo("Finished moving {0} artist to '{1}'", artistToMove.Count, destinationRootFolder); + _logger.ProgressInfo("Finished moving {0} author to '{1}'", authorToMove.Count, destinationRootFolder); } } } diff --git a/src/NzbDrone.Core/Books/Services/RefreshAuthorService.cs b/src/NzbDrone.Core/Books/Services/RefreshAuthorService.cs index b32d0a9c4..637697b2f 100644 --- a/src/NzbDrone.Core/Books/Services/RefreshAuthorService.cs +++ b/src/NzbDrone.Core/Books/Services/RefreshAuthorService.cs @@ -5,6 +5,8 @@ using System.Linq; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Common.Instrumentation.Extensions; +using NzbDrone.Core.Books.Commands; +using NzbDrone.Core.Books.Events; using NzbDrone.Core.Configuration; using NzbDrone.Core.Exceptions; using NzbDrone.Core.History; @@ -14,63 +16,61 @@ using NzbDrone.Core.MediaFiles.Commands; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.MetadataSource; -using NzbDrone.Core.Music.Commands; -using NzbDrone.Core.Music.Events; using NzbDrone.Core.Profiles.Metadata; using NzbDrone.Core.RootFolders; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { - public class RefreshArtistService : RefreshEntityServiceBase, - IExecute, - IExecute + public class RefreshAuthorService : RefreshEntityServiceBase, + IExecute, + IExecute { - private readonly IProvideAuthorInfo _artistInfo; - private readonly IArtistService _artistService; - private readonly IAlbumService _albumService; + private readonly IProvideAuthorInfo _authorInfo; + private readonly IAuthorService _authorService; + private readonly IBookService _bookService; private readonly IMetadataProfileService _metadataProfileService; - private readonly IRefreshAlbumService _refreshAlbumService; + private readonly IRefreshBookService _refreshBookService; private readonly IRefreshSeriesService _refreshSeriesService; private readonly IEventAggregator _eventAggregator; private readonly IManageCommandQueue _commandQueueManager; private readonly IMediaFileService _mediaFileService; private readonly IHistoryService _historyService; private readonly IRootFolderService _rootFolderService; - private readonly ICheckIfArtistShouldBeRefreshed _checkIfArtistShouldBeRefreshed; + private readonly ICheckIfAuthorShouldBeRefreshed _checkIfAuthorShouldBeRefreshed; private readonly IConfigService _configService; private readonly IImportListExclusionService _importListExclusionService; private readonly Logger _logger; - public RefreshArtistService(IProvideAuthorInfo artistInfo, - IArtistService artistService, - IArtistMetadataService artistMetadataService, - IAlbumService albumService, + public RefreshAuthorService(IProvideAuthorInfo authorInfo, + IAuthorService authorService, + IAuthorMetadataService authorMetadataService, + IBookService bookService, IMetadataProfileService metadataProfileService, - IRefreshAlbumService refreshAlbumService, + IRefreshBookService refreshBookService, IRefreshSeriesService refreshSeriesService, IEventAggregator eventAggregator, IManageCommandQueue commandQueueManager, IMediaFileService mediaFileService, IHistoryService historyService, IRootFolderService rootFolderService, - ICheckIfArtistShouldBeRefreshed checkIfArtistShouldBeRefreshed, + ICheckIfAuthorShouldBeRefreshed checkIfAuthorShouldBeRefreshed, IConfigService configService, IImportListExclusionService importListExclusionService, Logger logger) - : base(logger, artistMetadataService) + : base(logger, authorMetadataService) { - _artistInfo = artistInfo; - _artistService = artistService; - _albumService = albumService; + _authorInfo = authorInfo; + _authorService = authorService; + _bookService = bookService; _metadataProfileService = metadataProfileService; - _refreshAlbumService = refreshAlbumService; + _refreshBookService = refreshBookService; _refreshSeriesService = refreshSeriesService; _eventAggregator = eventAggregator; _commandQueueManager = commandQueueManager; _mediaFileService = mediaFileService; _historyService = historyService; _rootFolderService = rootFolderService; - _checkIfArtistShouldBeRefreshed = checkIfArtistShouldBeRefreshed; + _checkIfAuthorShouldBeRefreshed = checkIfAuthorShouldBeRefreshed; _configService = configService; _importListExclusionService = importListExclusionService; _logger = logger; @@ -80,11 +80,11 @@ namespace NzbDrone.Core.Music { try { - return _artistInfo.GetAuthorInfo(foreignId); + return _authorInfo.GetAuthorInfo(foreignId); } - catch (ArtistNotFoundException) + catch (AuthorNotFoundException) { - _logger.Error($"Could not find artist with id {foreignId}"); + _logger.Error($"Could not find author with id {foreignId}"); } return null; @@ -105,7 +105,7 @@ namespace NzbDrone.Core.Music protected override bool ShouldDelete(Author local) { - return !_mediaFileService.GetFilesByArtist(local.Id).Any(); + return !_mediaFileService.GetFilesByAuthor(local.Id).Any(); } protected override void LogProgress(Author local) @@ -140,7 +140,7 @@ namespace NzbDrone.Core.Music } catch (Exception e) { - _logger.Warn(e, "Couldn't update artist path for " + local.Path); + _logger.Warn(e, "Couldn't update author path for " + local.Path); } return result; @@ -166,13 +166,13 @@ namespace NzbDrone.Core.Music // Do the standard update UpdateEntity(local, remote); - // We know we need to update tags as artist id has changed + // We know we need to update tags as author id has changed return UpdateResult.UpdateTags; } protected override UpdateResult MergeEntity(Author local, Author target, Author remote) { - _logger.Warn($"Artist {local} was replaced with {remote} because the original was a duplicate."); + _logger.Warn($"Author {local} was replaced with {remote} because the original was a duplicate."); // Update list exclusion if one exists var importExclusionLocal = _importListExclusionService.FindByForeignId(local.Metadata.Value.ForeignAuthorId); @@ -187,34 +187,34 @@ namespace NzbDrone.Core.Music } } - // move any albums over to the new artist and remove the local artist - var albums = _albumService.GetAlbumsByArtist(local.Id); - albums.ForEach(x => x.AuthorMetadataId = target.AuthorMetadataId); - _albumService.UpdateMany(albums); - _artistService.DeleteArtist(local.Id, false); + // move any books over to the new author and remove the local author + var books = _bookService.GetBooksByAuthor(local.Id); + books.ForEach(x => x.AuthorMetadataId = target.AuthorMetadataId); + _bookService.UpdateMany(books); + _authorService.DeleteAuthor(local.Id, false); // Update history entries to new id - var items = _historyService.GetByArtist(local.Id, null); + var items = _historyService.GetByAuthor(local.Id, null); items.ForEach(x => x.AuthorId = target.Id); _historyService.UpdateMany(items); - // We know we need to update tags as artist id has changed + // We know we need to update tags as author id has changed return UpdateResult.UpdateTags; } protected override Author GetEntityByForeignId(Author local) { - return _artistService.FindById(local.ForeignAuthorId); + return _authorService.FindById(local.ForeignAuthorId); } protected override void SaveEntity(Author local) { - _artistService.UpdateArtist(local); + _authorService.UpdateAuthor(local); } protected override void DeleteEntity(Author local, bool deleteFiles) { - _artistService.DeleteArtist(local.Id, true); + _authorService.DeleteAuthor(local.Id, true); } protected override List GetRemoteChildren(Author local, Author remote) @@ -229,7 +229,7 @@ namespace NzbDrone.Core.Music protected override List GetLocalChildren(Author entity, List remoteChildren) { - return _albumService.GetAlbumsForRefresh(entity.AuthorMetadataId, + return _bookService.GetBooksForRefresh(entity.AuthorMetadataId, remoteChildren.Select(x => x.ForeignBookId)); } @@ -261,17 +261,17 @@ namespace NzbDrone.Core.Music protected override void AddChildren(List children) { - _albumService.InsertMany(children); + _bookService.InsertMany(children); } protected override bool RefreshChildren(SortedChildren localChildren, List remoteChildren, Author remoteData, bool forceChildRefresh, bool forceUpdateFileTags, DateTime? lastUpdate) { - return _refreshAlbumService.RefreshAlbumInfo(localChildren.All, remoteChildren, remoteData, forceChildRefresh, forceUpdateFileTags, lastUpdate); + return _refreshBookService.RefreshBookInfo(localChildren.All, remoteChildren, remoteData, forceChildRefresh, forceUpdateFileTags, lastUpdate); } protected override void PublishEntityUpdatedEvent(Author entity) { - _eventAggregator.PublishEvent(new ArtistUpdatedEvent(entity)); + _eventAggregator.PublishEvent(new AuthorUpdatedEvent(entity)); } protected override void PublishRefreshCompleteEvent(Author entity) @@ -279,12 +279,12 @@ namespace NzbDrone.Core.Music // little hack - trigger the series update here _refreshSeriesService.RefreshSeriesInfo(entity.AuthorMetadataId, entity.Series, entity, false, false, null); - _eventAggregator.PublishEvent(new ArtistRefreshCompleteEvent(entity)); + _eventAggregator.PublishEvent(new AuthorRefreshCompleteEvent(entity)); } protected override void PublishChildrenUpdatedEvent(Author entity, List newChildren, List updateChildren) { - _eventAggregator.PublishEvent(new AlbumInfoRefreshedEvent(entity, newChildren, updateChildren)); + _eventAggregator.PublishEvent(new BookInfoRefreshedEvent(entity, newChildren, updateChildren)); } private void Rescan(List authorIds, bool isNew, CommandTrigger trigger, bool infoUpdated) @@ -294,7 +294,7 @@ namespace NzbDrone.Core.Music if (isNew) { - _logger.Trace("Forcing rescan. Reason: New artist added"); + _logger.Trace("Forcing rescan. Reason: New author added"); shouldRescan = true; } else if (rescanAfterRefresh == RescanAfterRefreshType.Never) @@ -316,7 +316,7 @@ namespace NzbDrone.Core.Music if (shouldRescan) { // some metadata has updated so rescan unmatched - // (but don't add new artists to reduce repeated searches against api) + // (but don't add new authors to reduce repeated searches against api) var folders = _rootFolderService.All().Select(x => x.Path).ToList(); _commandQueueManager.Push(new RescanFoldersCommand(folders, FilterFilesType.Matched, false, authorIds)); @@ -326,33 +326,33 @@ namespace NzbDrone.Core.Music private void RefreshSelectedArtists(List authorIds, bool isNew, CommandTrigger trigger) { var updated = false; - var artists = _artistService.GetArtists(authorIds); + var authors = _authorService.GetAuthors(authorIds); - foreach (var artist in artists) + foreach (var author in authors) { try { - var data = GetSkyhookData(artist.ForeignAuthorId); - updated |= RefreshEntityInfo(artist, null, data, true, false, null); + var data = GetSkyhookData(author.ForeignAuthorId); + updated |= RefreshEntityInfo(author, null, data, true, false, null); } catch (Exception e) { - _logger.Error(e, "Couldn't refresh info for {0}", artist); + _logger.Error(e, "Couldn't refresh info for {0}", author); } } Rescan(authorIds, isNew, trigger, updated); } - public void Execute(BulkRefreshArtistCommand message) + public void Execute(BulkRefreshAuthorCommand message) { - RefreshSelectedArtists(message.AuthorIds, message.AreNewArtists, message.Trigger); + RefreshSelectedArtists(message.AuthorIds, message.AreNewAuthors, message.Trigger); } - public void Execute(RefreshArtistCommand message) + public void Execute(RefreshAuthorCommand message) { var trigger = message.Trigger; - var isNew = message.IsNewArtist; + var isNew = message.IsNewAuthor; if (message.AuthorId.HasValue) { @@ -361,37 +361,37 @@ namespace NzbDrone.Core.Music else { var updated = false; - var artists = _artistService.GetAllArtists().OrderBy(c => c.Name).ToList(); - var authorIds = artists.Select(x => x.Id).ToList(); + var authors = _authorService.GetAllAuthors().OrderBy(c => c.Name).ToList(); + var authorIds = authors.Select(x => x.Id).ToList(); - var updatedMusicbrainzArtists = new HashSet(); + var updatedGoodreadsAuthors = new HashSet(); if (message.LastExecutionTime.HasValue && message.LastExecutionTime.Value.AddDays(14) > DateTime.UtcNow) { - updatedMusicbrainzArtists = _artistInfo.GetChangedArtists(message.LastStartTime.Value); + updatedGoodreadsAuthors = _authorInfo.GetChangedArtists(message.LastStartTime.Value); } - foreach (var artist in artists) + foreach (var author in authors) { var manualTrigger = message.Trigger == CommandTrigger.Manual; - if ((updatedMusicbrainzArtists == null && _checkIfArtistShouldBeRefreshed.ShouldRefresh(artist)) || - (updatedMusicbrainzArtists != null && updatedMusicbrainzArtists.Contains(artist.ForeignAuthorId)) || + if ((updatedGoodreadsAuthors == null && _checkIfAuthorShouldBeRefreshed.ShouldRefresh(author)) || + (updatedGoodreadsAuthors != null && updatedGoodreadsAuthors.Contains(author.ForeignAuthorId)) || manualTrigger) { try { - var data = GetSkyhookData(artist.ForeignAuthorId); - updated |= RefreshEntityInfo(artist, null, data, manualTrigger, false, message.LastStartTime); + var data = GetSkyhookData(author.ForeignAuthorId); + updated |= RefreshEntityInfo(author, null, data, manualTrigger, false, message.LastStartTime); } catch (Exception e) { - _logger.Error(e, "Couldn't refresh info for {0}", artist); + _logger.Error(e, "Couldn't refresh info for {0}", author); } } else { - _logger.Info("Skipping refresh of artist: {0}", artist.Name); + _logger.Info("Skipping refresh of author: {0}", author.Name); } } diff --git a/src/NzbDrone.Core/Books/Services/RefreshBookService.cs b/src/NzbDrone.Core/Books/Services/RefreshBookService.cs index d2a5abd4e..eb1874012 100644 --- a/src/NzbDrone.Core/Books/Services/RefreshBookService.cs +++ b/src/NzbDrone.Core/Books/Services/RefreshBookService.cs @@ -3,55 +3,55 @@ using System.Collections.Generic; using System.Linq; using NLog; using NzbDrone.Common.Instrumentation.Extensions; +using NzbDrone.Core.Books.Events; using NzbDrone.Core.History; using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.MetadataSource; -using NzbDrone.Core.Music.Events; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { - public interface IRefreshAlbumService + public interface IRefreshBookService { - bool RefreshAlbumInfo(Book album, List remoteAlbums, Author remoteData, bool forceUpdateFileTags); - bool RefreshAlbumInfo(List albums, List remoteAlbums, Author remoteData, bool forceAlbumRefresh, bool forceUpdateFileTags, DateTime? lastUpdate); + bool RefreshBookInfo(Book book, List remoteBooks, Author remoteData, bool forceUpdateFileTags); + bool RefreshBookInfo(List books, List remoteBooks, Author remoteData, bool forceBookRefresh, bool forceUpdateFileTags, DateTime? lastUpdate); } - public class RefreshAlbumService : RefreshEntityServiceBase, IRefreshAlbumService + public class RefreshBookService : RefreshEntityServiceBase, IRefreshBookService { - private readonly IAlbumService _albumService; - private readonly IArtistService _artistService; - private readonly IAddArtistService _addArtistService; - private readonly IProvideBookInfo _albumInfo; + private readonly IBookService _bookService; + private readonly IAuthorService _authorService; + private readonly IAddAuthorService _addAuthorService; + private readonly IProvideBookInfo _bookInfo; private readonly IMediaFileService _mediaFileService; private readonly IHistoryService _historyService; private readonly IEventAggregator _eventAggregator; - private readonly ICheckIfAlbumShouldBeRefreshed _checkIfAlbumShouldBeRefreshed; + private readonly ICheckIfBookShouldBeRefreshed _checkIfBookShouldBeRefreshed; private readonly IMapCoversToLocal _mediaCoverService; private readonly Logger _logger; - public RefreshAlbumService(IAlbumService albumService, - IArtistService artistService, - IAddArtistService addArtistService, - IArtistMetadataService artistMetadataService, - IProvideBookInfo albumInfo, + public RefreshBookService(IBookService bookService, + IAuthorService authorService, + IAddAuthorService addAuthorService, + IAuthorMetadataService authorMetadataService, + IProvideBookInfo bookInfo, IMediaFileService mediaFileService, IHistoryService historyService, IEventAggregator eventAggregator, - ICheckIfAlbumShouldBeRefreshed checkIfAlbumShouldBeRefreshed, + ICheckIfBookShouldBeRefreshed checkIfBookShouldBeRefreshed, IMapCoversToLocal mediaCoverService, Logger logger) - : base(logger, artistMetadataService) + : base(logger, authorMetadataService) { - _albumService = albumService; - _artistService = artistService; - _addArtistService = addArtistService; - _albumInfo = albumInfo; + _bookService = bookService; + _authorService = authorService; + _addAuthorService = addAuthorService; + _bookInfo = bookInfo; _mediaFileService = mediaFileService; _historyService = historyService; _eventAggregator = eventAggregator; - _checkIfAlbumShouldBeRefreshed = checkIfAlbumShouldBeRefreshed; + _checkIfBookShouldBeRefreshed = checkIfBookShouldBeRefreshed; _mediaCoverService = mediaCoverService; _logger = logger; } @@ -83,29 +83,29 @@ namespace NzbDrone.Core.Music protected override void EnsureNewParent(Book local, Book remote) { - // Make sure the appropriate artist exists (it could be that an album changes parent) - // The artistMetadata entry will be in the db but make sure a corresponding artist is too - // so that the album doesn't just disappear. + // Make sure the appropriate author exists (it could be that an book changes parent) + // The authorMetadata entry will be in the db but make sure a corresponding author is too + // so that the book doesn't just disappear. // TODO filter by metadata id before hitting database - _logger.Trace($"Ensuring parent artist exists [{remote.AuthorMetadata.Value.ForeignAuthorId}]"); + _logger.Trace($"Ensuring parent author exists [{remote.AuthorMetadata.Value.ForeignAuthorId}]"); - var newArtist = _artistService.FindById(remote.AuthorMetadata.Value.ForeignAuthorId); + var newAuthor = _authorService.FindById(remote.AuthorMetadata.Value.ForeignAuthorId); - if (newArtist == null) + if (newAuthor == null) { - var oldArtist = local.Author.Value; + var oldAuthor = local.Author.Value; var addArtist = new Author { Metadata = remote.AuthorMetadata.Value, - MetadataProfileId = oldArtist.MetadataProfileId, - QualityProfileId = oldArtist.QualityProfileId, - RootFolderPath = oldArtist.RootFolderPath, - Monitored = oldArtist.Monitored, - Tags = oldArtist.Tags + MetadataProfileId = oldAuthor.MetadataProfileId, + QualityProfileId = oldAuthor.QualityProfileId, + RootFolderPath = oldAuthor.RootFolderPath, + Monitored = oldAuthor.Monitored, + Tags = oldAuthor.Tags }; - _logger.Debug($"Adding missing parent artist {addArtist}"); - _addArtistService.AddArtist(addArtist); + _logger.Debug($"Adding missing parent author {addArtist}"); + _addAuthorService.AddAuthor(addArtist); } } @@ -113,7 +113,7 @@ namespace NzbDrone.Core.Music { // not manually added and has no files return local.AddOptions.AddType != AlbumAddType.Manual && - !_mediaFileService.GetFilesByAlbum(local.Id).Any(); + !_mediaFileService.GetFilesByBook(local.Id).Any(); } protected override void LogProgress(Book local) @@ -163,38 +163,38 @@ namespace NzbDrone.Core.Music protected override UpdateResult MergeEntity(Book local, Book target, Book remote) { - _logger.Warn($"Album {local} was merged with {remote} because the original was a duplicate."); + _logger.Warn($"Book {local} was merged with {remote} because the original was a duplicate."); - // Update album ids for trackfiles - var files = _mediaFileService.GetFilesByAlbum(local.Id); + // Update book ids for trackfiles + var files = _mediaFileService.GetFilesByBook(local.Id); files.ForEach(x => x.BookId = target.Id); _mediaFileService.Update(files); - // Update album ids for history - var items = _historyService.GetByAlbum(local.Id, null); + // Update book ids for history + var items = _historyService.GetByBook(local.Id, null); items.ForEach(x => x.BookId = target.Id); _historyService.UpdateMany(items); - // Finally delete the old album - _albumService.DeleteMany(new List { local }); + // Finally delete the old book + _bookService.DeleteMany(new List { local }); return UpdateResult.UpdateTags; } protected override Book GetEntityByForeignId(Book local) { - return _albumService.FindById(local.ForeignBookId); + return _bookService.FindById(local.ForeignBookId); } protected override void SaveEntity(Book local) { - // Use UpdateMany to avoid firing the album edited event - _albumService.UpdateMany(new List { local }); + // Use UpdateMany to avoid firing the book edited event + _bookService.UpdateMany(new List { local }); } protected override void DeleteEntity(Book local, bool deleteFiles) { - _albumService.DeleteAlbum(local.Id, true); + _bookService.DeleteBook(local.Id, true); } protected override List GetRemoteChildren(Book local, Book remote) @@ -232,40 +232,40 @@ namespace NzbDrone.Core.Music protected override void PublishEntityUpdatedEvent(Book entity) { // Fetch fresh from DB so all lazy loads are available - _eventAggregator.PublishEvent(new AlbumUpdatedEvent(_albumService.GetAlbum(entity.Id))); + _eventAggregator.PublishEvent(new BookUpdatedEvent(_bookService.GetBook(entity.Id))); } - public bool RefreshAlbumInfo(List albums, List remoteAlbums, Author remoteData, bool forceAlbumRefresh, bool forceUpdateFileTags, DateTime? lastUpdate) + public bool RefreshBookInfo(List books, List remoteBooks, Author remoteData, bool forceAlbumRefresh, bool forceUpdateFileTags, DateTime? lastUpdate) { var updated = false; - HashSet updatedMusicbrainzAlbums = null; + HashSet updatedGoodreadsBooks = null; if (lastUpdate.HasValue && lastUpdate.Value.AddDays(14) > DateTime.UtcNow) { - updatedMusicbrainzAlbums = _albumInfo.GetChangedAlbums(lastUpdate.Value); + updatedGoodreadsBooks = _bookInfo.GetChangedBooks(lastUpdate.Value); } - foreach (var album in albums) + foreach (var book in books) { if (forceAlbumRefresh || - (updatedMusicbrainzAlbums == null && _checkIfAlbumShouldBeRefreshed.ShouldRefresh(album)) || - (updatedMusicbrainzAlbums != null && updatedMusicbrainzAlbums.Contains(album.ForeignBookId))) + (updatedGoodreadsBooks == null && _checkIfBookShouldBeRefreshed.ShouldRefresh(book)) || + (updatedGoodreadsBooks != null && updatedGoodreadsBooks.Contains(book.ForeignBookId))) { - updated |= RefreshAlbumInfo(album, remoteAlbums, remoteData, forceUpdateFileTags); + updated |= RefreshBookInfo(book, remoteBooks, remoteData, forceUpdateFileTags); } else { - _logger.Debug("Skipping refresh of album: {0}", album.Title); + _logger.Debug("Skipping refresh of book: {0}", book.Title); } } return updated; } - public bool RefreshAlbumInfo(Book album, List remoteAlbums, Author remoteData, bool forceUpdateFileTags) + public bool RefreshBookInfo(Book book, List remoteBooks, Author remoteData, bool forceUpdateFileTags) { - return RefreshEntityInfo(album, remoteAlbums, remoteData, true, forceUpdateFileTags, null); + return RefreshEntityInfo(book, remoteBooks, remoteData, true, forceUpdateFileTags, null); } } } diff --git a/src/NzbDrone.Core/Books/Services/RefreshEntityServiceBase.cs b/src/NzbDrone.Core/Books/Services/RefreshEntityServiceBase.cs index 4aaae5911..9bcd1a555 100644 --- a/src/NzbDrone.Core/Books/Services/RefreshEntityServiceBase.cs +++ b/src/NzbDrone.Core/Books/Services/RefreshEntityServiceBase.cs @@ -4,18 +4,18 @@ using System.Linq; using NLog; using NzbDrone.Common.Extensions; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { public abstract class RefreshEntityServiceBase { private readonly Logger _logger; - private readonly IArtistMetadataService _artistMetadataService; + private readonly IAuthorMetadataService _authorMetadataService; protected RefreshEntityServiceBase(Logger logger, - IArtistMetadataService artistMetadataService) + IAuthorMetadataService authorMetadataService) { _logger = logger; - _artistMetadataService = artistMetadataService; + _authorMetadataService = authorMetadataService; } public enum UpdateResult @@ -209,7 +209,7 @@ namespace NzbDrone.Core.Music public UpdateResult UpdateArtistMetadata(List data) { var remoteMetadata = data.DistinctBy(x => x.ForeignAuthorId).ToList(); - var updated = _artistMetadataService.UpsertMany(remoteMetadata); + var updated = _authorMetadataService.UpsertMany(remoteMetadata); return updated ? UpdateResult.UpdateTags : UpdateResult.None; } diff --git a/src/NzbDrone.Core/Books/Services/RefreshSeriesBookLinkService.cs b/src/NzbDrone.Core/Books/Services/RefreshSeriesBookLinkService.cs index 8c7ab5710..db8248d61 100644 --- a/src/NzbDrone.Core/Books/Services/RefreshSeriesBookLinkService.cs +++ b/src/NzbDrone.Core/Books/Services/RefreshSeriesBookLinkService.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using NLog; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { public interface IRefreshSeriesBookLinkService { diff --git a/src/NzbDrone.Core/Books/Services/RefreshSeriesService.cs b/src/NzbDrone.Core/Books/Services/RefreshSeriesService.cs index 343fa2c74..d1150c071 100644 --- a/src/NzbDrone.Core/Books/Services/RefreshSeriesService.cs +++ b/src/NzbDrone.Core/Books/Services/RefreshSeriesService.cs @@ -5,7 +5,7 @@ using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Common.Serializer; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { public interface IRefreshSeriesService { @@ -14,19 +14,19 @@ namespace NzbDrone.Core.Music public class RefreshSeriesService : RefreshEntityServiceBase, IRefreshSeriesService { - private readonly IAlbumService _bookService; + private readonly IBookService _bookService; private readonly ISeriesService _seriesService; private readonly ISeriesBookLinkService _linkService; private readonly IRefreshSeriesBookLinkService _refreshLinkService; private readonly Logger _logger; - public RefreshSeriesService(IAlbumService bookService, + public RefreshSeriesService(IBookService bookService, ISeriesService seriesService, ISeriesBookLinkService linkService, IRefreshSeriesBookLinkService refreshLinkService, - IArtistMetadataService artistMetadataService, + IAuthorMetadataService authorMetadataService, Logger logger) - : base(logger, artistMetadataService) + : base(logger, authorMetadataService) { _bookService = bookService; _seriesService = seriesService; @@ -67,7 +67,7 @@ namespace NzbDrone.Core.Music protected override void SaveEntity(Series local) { - // Use UpdateMany to avoid firing the album edited event + // Use UpdateMany to avoid firing the book edited event _seriesService.UpdateMany(new List { local }); } @@ -128,7 +128,7 @@ namespace NzbDrone.Core.Music var existingBySeries = _seriesService.FindById(remoteSeries.Select(x => x.ForeignSeriesId)); var existing = existingByAuthor.Concat(existingBySeries).GroupBy(x => x.ForeignSeriesId).Select(x => x.First()).ToList(); - var books = _bookService.GetAlbumsByArtistMetadataId(authorMetadataId); + var books = _bookService.GetBooksByAuthorMetadataId(authorMetadataId); var bookDict = books.ToDictionary(x => x.ForeignWorkId); var links = new List(); diff --git a/src/NzbDrone.Core/Books/Services/SeriesBookLinkService.cs b/src/NzbDrone.Core/Books/Services/SeriesBookLinkService.cs index bf08a51d2..c0f0585c9 100644 --- a/src/NzbDrone.Core/Books/Services/SeriesBookLinkService.cs +++ b/src/NzbDrone.Core/Books/Services/SeriesBookLinkService.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { public interface ISeriesBookLinkService { diff --git a/src/NzbDrone.Core/Books/Services/SeriesService.cs b/src/NzbDrone.Core/Books/Services/SeriesService.cs index 018112240..4176bd1c4 100644 --- a/src/NzbDrone.Core/Books/Services/SeriesService.cs +++ b/src/NzbDrone.Core/Books/Services/SeriesService.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { public interface ISeriesService { diff --git a/src/NzbDrone.Core/Books/Utilities/AddArtistValidator.cs b/src/NzbDrone.Core/Books/Utilities/AddAuthorValidator.cs similarity index 63% rename from src/NzbDrone.Core/Books/Utilities/AddArtistValidator.cs rename to src/NzbDrone.Core/Books/Utilities/AddAuthorValidator.cs index 11aab0893..3a87e073a 100644 --- a/src/NzbDrone.Core/Books/Utilities/AddArtistValidator.cs +++ b/src/NzbDrone.Core/Books/Utilities/AddAuthorValidator.cs @@ -3,26 +3,26 @@ using FluentValidation.Results; using NzbDrone.Core.Validation; using NzbDrone.Core.Validation.Paths; -namespace NzbDrone.Core.Music +namespace NzbDrone.Core.Books { - public interface IAddArtistValidator + public interface IAddAuthorValidator { ValidationResult Validate(Author instance); } - public class AddArtistValidator : AbstractValidator, IAddArtistValidator + public class AddAuthorValidator : AbstractValidator, IAddAuthorValidator { - public AddArtistValidator(RootFolderValidator rootFolderValidator, - ArtistPathValidator artistPathValidator, - ArtistAncestorValidator artistAncestorValidator, + public AddAuthorValidator(RootFolderValidator rootFolderValidator, + AuthorPathValidator authorPathValidator, + AuthorAncestorValidator authorAncestorValidator, QualityProfileExistsValidator qualityProfileExistsValidator, MetadataProfileExistsValidator metadataProfileExistsValidator) { RuleFor(c => c.Path).Cascade(CascadeMode.StopOnFirstFailure) .IsValidPath() .SetValidator(rootFolderValidator) - .SetValidator(artistPathValidator) - .SetValidator(artistAncestorValidator); + .SetValidator(authorPathValidator) + .SetValidator(authorAncestorValidator); RuleFor(c => c.QualityProfileId).SetValidator(qualityProfileExistsValidator); diff --git a/src/NzbDrone.Core/Books/Utilities/ArtistPathBuilder.cs b/src/NzbDrone.Core/Books/Utilities/ArtistPathBuilder.cs deleted file mode 100644 index f0667bca7..000000000 --- a/src/NzbDrone.Core/Books/Utilities/ArtistPathBuilder.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.IO; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Organizer; -using NzbDrone.Core.RootFolders; - -namespace NzbDrone.Core.Music -{ - public interface IBuildArtistPaths - { - string BuildPath(Author artist, bool useExistingRelativeFolder); - } - - public class ArtistPathBuilder : IBuildArtistPaths - { - private readonly IBuildFileNames _fileNameBuilder; - private readonly IRootFolderService _rootFolderService; - - public ArtistPathBuilder(IBuildFileNames fileNameBuilder, IRootFolderService rootFolderService) - { - _fileNameBuilder = fileNameBuilder; - _rootFolderService = rootFolderService; - } - - public string BuildPath(Author artist, bool useExistingRelativeFolder) - { - if (artist.RootFolderPath.IsNullOrWhiteSpace()) - { - throw new ArgumentException("Root folder was not provided", nameof(artist)); - } - - if (useExistingRelativeFolder && artist.Path.IsNotNullOrWhiteSpace()) - { - var relativePath = GetExistingRelativePath(artist); - return Path.Combine(artist.RootFolderPath, relativePath); - } - - return Path.Combine(artist.RootFolderPath, _fileNameBuilder.GetArtistFolder(artist)); - } - - private string GetExistingRelativePath(Author artist) - { - var rootFolderPath = _rootFolderService.GetBestRootFolderPath(artist.Path); - - return rootFolderPath.GetRelativePath(artist.Path); - } - } -} diff --git a/src/NzbDrone.Core/Books/Utilities/AuthorPathBuilder.cs b/src/NzbDrone.Core/Books/Utilities/AuthorPathBuilder.cs new file mode 100644 index 000000000..f8562c110 --- /dev/null +++ b/src/NzbDrone.Core/Books/Utilities/AuthorPathBuilder.cs @@ -0,0 +1,48 @@ +using System; +using System.IO; +using NzbDrone.Common.Extensions; +using NzbDrone.Core.Organizer; +using NzbDrone.Core.RootFolders; + +namespace NzbDrone.Core.Books +{ + public interface IBuildAuthorPaths + { + string BuildPath(Author author, bool useExistingRelativeFolder); + } + + public class AuthorPathBuilder : IBuildAuthorPaths + { + private readonly IBuildFileNames _fileNameBuilder; + private readonly IRootFolderService _rootFolderService; + + public AuthorPathBuilder(IBuildFileNames fileNameBuilder, IRootFolderService rootFolderService) + { + _fileNameBuilder = fileNameBuilder; + _rootFolderService = rootFolderService; + } + + public string BuildPath(Author author, bool useExistingRelativeFolder) + { + if (author.RootFolderPath.IsNullOrWhiteSpace()) + { + throw new ArgumentException("Root folder was not provided", nameof(author)); + } + + if (useExistingRelativeFolder && author.Path.IsNotNullOrWhiteSpace()) + { + var relativePath = GetExistingRelativePath(author); + return Path.Combine(author.RootFolderPath, relativePath); + } + + return Path.Combine(author.RootFolderPath, _fileNameBuilder.GetAuthorFolder(author)); + } + + private string GetExistingRelativePath(Author author) + { + var rootFolderPath = _rootFolderService.GetBestRootFolderPath(author.Path); + + return rootFolderPath.GetRelativePath(author.Path); + } + } +} diff --git a/src/NzbDrone.Core/Books/Utilities/ShouldRefreshAlbum.cs b/src/NzbDrone.Core/Books/Utilities/ShouldRefreshAlbum.cs deleted file mode 100644 index 6c56b2690..000000000 --- a/src/NzbDrone.Core/Books/Utilities/ShouldRefreshAlbum.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using NLog; - -namespace NzbDrone.Core.Music -{ - public interface ICheckIfAlbumShouldBeRefreshed - { - bool ShouldRefresh(Book album); - } - - public class ShouldRefreshAlbum : ICheckIfAlbumShouldBeRefreshed - { - private readonly Logger _logger; - - public ShouldRefreshAlbum(Logger logger) - { - _logger = logger; - } - - public bool ShouldRefresh(Book album) - { - if (album.LastInfoSync < DateTime.UtcNow.AddDays(-60)) - { - _logger.Trace("Album {0} last updated more than 60 days ago, should refresh.", album.Title); - return true; - } - - if (album.LastInfoSync >= DateTime.UtcNow.AddHours(-12)) - { - _logger.Trace("Album {0} last updated less than 12 hours ago, should not be refreshed.", album.Title); - return false; - } - - if (album.ReleaseDate > DateTime.UtcNow.AddDays(-30)) - { - _logger.Trace("album {0} released less than 30 days ago, should refresh.", album.Title); - return true; - } - - _logger.Trace("Album {0} released long ago and recently refreshed, should not be refreshed.", album.Title); - return false; - } - } -} diff --git a/src/NzbDrone.Core/Books/Utilities/ShouldRefreshArtist.cs b/src/NzbDrone.Core/Books/Utilities/ShouldRefreshArtist.cs deleted file mode 100644 index 0ddd01be7..000000000 --- a/src/NzbDrone.Core/Books/Utilities/ShouldRefreshArtist.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Linq; -using NLog; - -namespace NzbDrone.Core.Music -{ - public interface ICheckIfArtistShouldBeRefreshed - { - bool ShouldRefresh(Author artist); - } - - public class ShouldRefreshArtist : ICheckIfArtistShouldBeRefreshed - { - private readonly IAlbumService _albumService; - private readonly Logger _logger; - - public ShouldRefreshArtist(IAlbumService albumService, Logger logger) - { - _albumService = albumService; - _logger = logger; - } - - public bool ShouldRefresh(Author artist) - { - if (artist.LastInfoSync < DateTime.UtcNow.AddDays(-30)) - { - _logger.Trace("Artist {0} last updated more than 30 days ago, should refresh.", artist.Name); - return true; - } - - if (artist.LastInfoSync >= DateTime.UtcNow.AddHours(-12)) - { - _logger.Trace("Artist {0} last updated less than 12 hours ago, should not be refreshed.", artist.Name); - return false; - } - - if (artist.Metadata.Value.Status == ArtistStatusType.Continuing && artist.LastInfoSync < DateTime.UtcNow.AddDays(-2)) - { - _logger.Trace("Artist {0} is continuing and has not been refreshed in 2 days, should refresh.", artist.Name); - return true; - } - - var lastAlbum = _albumService.GetAlbumsByArtist(artist.Id).OrderByDescending(e => e.ReleaseDate).FirstOrDefault(); - - if (lastAlbum != null && lastAlbum.ReleaseDate > DateTime.UtcNow.AddDays(-30)) - { - _logger.Trace("Last album in {0} aired less than 30 days ago, should refresh.", artist.Name); - return true; - } - - _logger.Trace("Artist {0} ended long ago, should not be refreshed.", artist.Name); - return false; - } - } -} diff --git a/src/NzbDrone.Core/Books/Utilities/ShouldRefreshAuthor.cs b/src/NzbDrone.Core/Books/Utilities/ShouldRefreshAuthor.cs new file mode 100644 index 000000000..523cccf3a --- /dev/null +++ b/src/NzbDrone.Core/Books/Utilities/ShouldRefreshAuthor.cs @@ -0,0 +1,55 @@ +using System; +using System.Linq; +using NLog; + +namespace NzbDrone.Core.Books +{ + public interface ICheckIfAuthorShouldBeRefreshed + { + bool ShouldRefresh(Author author); + } + + public class ShouldRefreshAuthor : ICheckIfAuthorShouldBeRefreshed + { + private readonly IBookService _bookService; + private readonly Logger _logger; + + public ShouldRefreshAuthor(IBookService bookService, Logger logger) + { + _bookService = bookService; + _logger = logger; + } + + public bool ShouldRefresh(Author author) + { + if (author.LastInfoSync < DateTime.UtcNow.AddDays(-30)) + { + _logger.Trace("Author {0} last updated more than 30 days ago, should refresh.", author.Name); + return true; + } + + if (author.LastInfoSync >= DateTime.UtcNow.AddHours(-12)) + { + _logger.Trace("Author {0} last updated less than 12 hours ago, should not be refreshed.", author.Name); + return false; + } + + if (author.Metadata.Value.Status == AuthorStatusType.Continuing && author.LastInfoSync < DateTime.UtcNow.AddDays(-2)) + { + _logger.Trace("Author {0} is continuing and has not been refreshed in 2 days, should refresh.", author.Name); + return true; + } + + var lastAlbum = _bookService.GetBooksByAuthor(author.Id).OrderByDescending(e => e.ReleaseDate).FirstOrDefault(); + + if (lastAlbum != null && lastAlbum.ReleaseDate > DateTime.UtcNow.AddDays(-30)) + { + _logger.Trace("Last book in {0} released less than 30 days ago, should refresh.", author.Name); + return true; + } + + _logger.Trace("Author {0} ended long ago, should not be refreshed.", author.Name); + return false; + } + } +} diff --git a/src/NzbDrone.Core/Books/Utilities/ShouldRefreshBook.cs b/src/NzbDrone.Core/Books/Utilities/ShouldRefreshBook.cs new file mode 100644 index 000000000..9d3ae1c04 --- /dev/null +++ b/src/NzbDrone.Core/Books/Utilities/ShouldRefreshBook.cs @@ -0,0 +1,44 @@ +using System; +using NLog; + +namespace NzbDrone.Core.Books +{ + public interface ICheckIfBookShouldBeRefreshed + { + bool ShouldRefresh(Book book); + } + + public class ShouldRefreshBook : ICheckIfBookShouldBeRefreshed + { + private readonly Logger _logger; + + public ShouldRefreshBook(Logger logger) + { + _logger = logger; + } + + public bool ShouldRefresh(Book book) + { + if (book.LastInfoSync < DateTime.UtcNow.AddDays(-60)) + { + _logger.Trace("Book {0} last updated more than 60 days ago, should refresh.", book.Title); + return true; + } + + if (book.LastInfoSync >= DateTime.UtcNow.AddHours(-12)) + { + _logger.Trace("Book {0} last updated less than 12 hours ago, should not be refreshed.", book.Title); + return false; + } + + if (book.ReleaseDate > DateTime.UtcNow.AddDays(-30)) + { + _logger.Trace("Book {0} released less than 30 days ago, should refresh.", book.Title); + return true; + } + + _logger.Trace("Book {0} released long ago and recently refreshed, should not be refreshed.", book.Title); + return false; + } + } +} diff --git a/src/NzbDrone.Core/Datastore/Migration/001_initial_setup.cs b/src/NzbDrone.Core/Datastore/Migration/001_initial_setup.cs index 15a15b95f..dbe313993 100644 --- a/src/NzbDrone.Core/Datastore/Migration/001_initial_setup.cs +++ b/src/NzbDrone.Core/Datastore/Migration/001_initial_setup.cs @@ -168,11 +168,9 @@ namespace NzbDrone.Core.Datastore.Migration Create.TableForModel("NamingConfig") .WithColumn("ReplaceIllegalCharacters").AsBoolean().WithDefaultValue(true) - .WithColumn("ArtistFolderFormat").AsString().Nullable() - .WithColumn("RenameTracks").AsBoolean().Nullable() - .WithColumn("StandardTrackFormat").AsString().Nullable() - .WithColumn("AlbumFolderFormat").AsString().Nullable() - .WithColumn("MultiDiscTrackFormat").AsString().Nullable(); + .WithColumn("AuthorFolderFormat").AsString().Nullable() + .WithColumn("RenameBooks").AsBoolean().Nullable() + .WithColumn("StandardBookFormat").AsString().Nullable(); Create.TableForModel("Blacklist") .WithColumn("SourceTitle").AsString() @@ -201,7 +199,7 @@ namespace NzbDrone.Core.Datastore.Migration .WithColumn("RelativePath").AsString().NotNullable() .WithColumn("LastUpdated").AsDateTime().NotNullable() .WithColumn("BookId").AsInt32().Nullable() - .WithColumn("TrackFileId").AsInt32().Nullable() + .WithColumn("BookFileId").AsInt32().Nullable() .WithColumn("Hash").AsString().Nullable() .WithColumn("Added").AsDateTime().Nullable() .WithColumn("Extension").AsString().NotNullable(); @@ -219,7 +217,7 @@ namespace NzbDrone.Core.Datastore.Migration .WithColumn("Added").AsDateTime() .WithColumn("Release").AsString() .WithColumn("AuthorId").AsInt32().WithDefaultValue(0) - .WithColumn("ParsedAlbumInfo").AsString().WithDefaultValue("") + .WithColumn("ParsedBookInfo").AsString().WithDefaultValue("") .WithColumn("Reason").AsInt32().WithDefaultValue(0); Create.TableForModel("RemotePathMappings") @@ -274,7 +272,7 @@ namespace NzbDrone.Core.Datastore.Migration Create.TableForModel("ExtraFiles") .WithColumn("AuthorId").AsInt32().NotNullable() .WithColumn("BookId").AsInt32().NotNullable() - .WithColumn("TrackFileId").AsInt32().NotNullable() + .WithColumn("BookFileId").AsInt32().NotNullable() .WithColumn("RelativePath").AsString().NotNullable() .WithColumn("Extension").AsString().NotNullable() .WithColumn("Added").AsDateTime().NotNullable() diff --git a/src/NzbDrone.Core/Datastore/TableMapping.cs b/src/NzbDrone.Core/Datastore/TableMapping.cs index 945ad3c1f..b7ac35b9d 100644 --- a/src/NzbDrone.Core/Datastore/TableMapping.cs +++ b/src/NzbDrone.Core/Datastore/TableMapping.cs @@ -5,6 +5,7 @@ using Dapper; using NzbDrone.Common.Reflection; using NzbDrone.Core.Authentication; using NzbDrone.Core.Blacklisting; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; using NzbDrone.Core.CustomFilters; using NzbDrone.Core.Datastore.Converters; @@ -20,7 +21,6 @@ using NzbDrone.Core.Instrumentation; using NzbDrone.Core.Jobs; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Messaging.Commands; -using NzbDrone.Core.Music; using NzbDrone.Core.Notifications; using NzbDrone.Core.Organizer; using NzbDrone.Core.Parser.Model; @@ -127,16 +127,16 @@ namespace NzbDrone.Core.Datastore .Where(b => b.Id == book.Id)).ToList(), b => b.Id > 0) .LazyLoad(a => a.Author, - (db, album) => ArtistRepository.Query(db, + (db, book) => AuthorRepository.Query(db, new SqlBuilder() .Join((a, m) => a.AuthorMetadataId == m.Id) - .Where(a => a.AuthorMetadataId == album.AuthorMetadataId)).SingleOrDefault(), + .Where(a => a.AuthorMetadataId == book.AuthorMetadataId)).SingleOrDefault(), a => a.AuthorMetadataId > 0); Mapper.Entity("BookFiles").RegisterModel() - .HasOne(f => f.Album, f => f.BookId) - .LazyLoad(x => x.Artist, - (db, f) => ArtistRepository.Query(db, + .HasOne(f => f.Book, f => f.BookId) + .LazyLoad(x => x.Author, + (db, f) => AuthorRepository.Query(db, new SqlBuilder() .Join((a, m) => a.AuthorMetadataId == m.Id) .Join((l, r) => l.AuthorMetadataId == r.AuthorMetadataId) @@ -158,7 +158,7 @@ namespace NzbDrone.Core.Datastore Mapper.Entity("ExtraFiles").RegisterModel(); Mapper.Entity("PendingReleases").RegisterModel() - .Ignore(e => e.RemoteAlbum); + .Ignore(e => e.RemoteBook); Mapper.Entity("RemotePathMappings").RegisterModel(); Mapper.Entity("Tags").RegisterModel(); @@ -193,7 +193,7 @@ namespace NzbDrone.Core.Datastore SqlMapper.AddTypeHandler(new EmbeddedDocumentConverter>>()); SqlMapper.AddTypeHandler(new EmbeddedDocumentConverter>()); SqlMapper.AddTypeHandler(new EmbeddedDocumentConverter>()); - SqlMapper.AddTypeHandler(new EmbeddedDocumentConverter()); + SqlMapper.AddTypeHandler(new EmbeddedDocumentConverter()); SqlMapper.AddTypeHandler(new EmbeddedDocumentConverter()); SqlMapper.AddTypeHandler(new EmbeddedDocumentConverter()); SqlMapper.AddTypeHandler(new EmbeddedDocumentConverter>()); diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecision.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecision.cs index 021648540..a22d8e37d 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecision.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecision.cs @@ -6,7 +6,7 @@ namespace NzbDrone.Core.DecisionEngine { public class DownloadDecision { - public RemoteAlbum RemoteAlbum { get; private set; } + public RemoteBook RemoteBook { get; private set; } public IEnumerable Rejections { get; private set; } public bool Approved => !Rejections.Any(); @@ -27,9 +27,9 @@ namespace NzbDrone.Core.DecisionEngine } } - public DownloadDecision(RemoteAlbum album, params Rejection[] rejections) + public DownloadDecision(RemoteBook book, params Rejection[] rejections) { - RemoteAlbum = album; + RemoteBook = book; Rejections = rejections.ToList(); } @@ -37,10 +37,10 @@ namespace NzbDrone.Core.DecisionEngine { if (Approved) { - return "[OK] " + RemoteAlbum; + return "[OK] " + RemoteBook; } - return "[Rejected " + Rejections.Count() + "]" + RemoteAlbum; + return "[Rejected " + Rejections.Count() + "]" + RemoteBook; } } } diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionComparer.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionComparer.cs index 6b674f65f..fc4faa90b 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionComparer.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionComparer.cs @@ -63,25 +63,25 @@ namespace NzbDrone.Core.DecisionEngine { if (_configService.DownloadPropersAndRepacks == ProperDownloadTypes.DoNotPrefer) { - return CompareAll(CompareBy(x.RemoteAlbum, y.RemoteAlbum, remoteAlbum => remoteAlbum.Artist.QualityProfile.Value.GetIndex(remoteAlbum.ParsedAlbumInfo.Quality.Quality)), - CompareBy(x.RemoteAlbum, y.RemoteAlbum, remoteAlbum => remoteAlbum.ParsedAlbumInfo.Quality.Revision.Real)); + return CompareAll(CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum => remoteAlbum.Author.QualityProfile.Value.GetIndex(remoteAlbum.ParsedBookInfo.Quality.Quality)), + CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum => remoteAlbum.ParsedBookInfo.Quality.Revision.Real)); } - return CompareAll(CompareBy(x.RemoteAlbum, y.RemoteAlbum, remoteAlbum => remoteAlbum.Artist.QualityProfile.Value.GetIndex(remoteAlbum.ParsedAlbumInfo.Quality.Quality)), - CompareBy(x.RemoteAlbum, y.RemoteAlbum, remoteAlbum => remoteAlbum.ParsedAlbumInfo.Quality.Revision.Real), - CompareBy(x.RemoteAlbum, y.RemoteAlbum, remoteAlbum => remoteAlbum.ParsedAlbumInfo.Quality.Revision.Version)); + return CompareAll(CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum => remoteAlbum.Author.QualityProfile.Value.GetIndex(remoteAlbum.ParsedBookInfo.Quality.Quality)), + CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum => remoteAlbum.ParsedBookInfo.Quality.Revision.Real), + CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum => remoteAlbum.ParsedBookInfo.Quality.Revision.Version)); } private int ComparePreferredWordScore(DownloadDecision x, DownloadDecision y) { - return CompareBy(x.RemoteAlbum, y.RemoteAlbum, remoteAlbum => remoteAlbum.PreferredWordScore); + return CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum => remoteAlbum.PreferredWordScore); } private int CompareProtocol(DownloadDecision x, DownloadDecision y) { - var result = CompareBy(x.RemoteAlbum, y.RemoteAlbum, remoteAlbum => + var result = CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum => { - var delayProfile = _delayProfileService.BestForTags(remoteAlbum.Artist.Tags); + var delayProfile = _delayProfileService.BestForTags(remoteAlbum.Author.Tags); var downloadProtocol = remoteAlbum.Release.DownloadProtocol; return downloadProtocol == delayProfile.PreferredProtocol; }); @@ -91,36 +91,36 @@ namespace NzbDrone.Core.DecisionEngine private int CompareAlbumCount(DownloadDecision x, DownloadDecision y) { - var discographyCompare = CompareBy(x.RemoteAlbum, - y.RemoteAlbum, - remoteAlbum => remoteAlbum.ParsedAlbumInfo.Discography); + var discographyCompare = CompareBy(x.RemoteBook, + y.RemoteBook, + remoteAlbum => remoteAlbum.ParsedBookInfo.Discography); if (discographyCompare != 0) { return discographyCompare; } - return CompareByReverse(x.RemoteAlbum, y.RemoteAlbum, remoteAlbum => remoteAlbum.Albums.Count); + return CompareByReverse(x.RemoteBook, y.RemoteBook, remoteAlbum => remoteAlbum.Books.Count); } private int ComparePeersIfTorrent(DownloadDecision x, DownloadDecision y) { // Different protocols should get caught when checking the preferred protocol, // since we're dealing with the same series in our comparisions - if (x.RemoteAlbum.Release.DownloadProtocol != DownloadProtocol.Torrent || - y.RemoteAlbum.Release.DownloadProtocol != DownloadProtocol.Torrent) + if (x.RemoteBook.Release.DownloadProtocol != DownloadProtocol.Torrent || + y.RemoteBook.Release.DownloadProtocol != DownloadProtocol.Torrent) { return 0; } return CompareAll( - CompareBy(x.RemoteAlbum, y.RemoteAlbum, remoteAlbum => + CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum => { var seeders = TorrentInfo.GetSeeders(remoteAlbum.Release); return seeders.HasValue && seeders.Value > 0 ? Math.Round(Math.Log10(seeders.Value)) : 0; }), - CompareBy(x.RemoteAlbum, y.RemoteAlbum, remoteAlbum => + CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum => { var peers = TorrentInfo.GetPeers(remoteAlbum.Release); @@ -130,13 +130,13 @@ namespace NzbDrone.Core.DecisionEngine private int CompareAgeIfUsenet(DownloadDecision x, DownloadDecision y) { - if (x.RemoteAlbum.Release.DownloadProtocol != DownloadProtocol.Usenet || - y.RemoteAlbum.Release.DownloadProtocol != DownloadProtocol.Usenet) + if (x.RemoteBook.Release.DownloadProtocol != DownloadProtocol.Usenet || + y.RemoteBook.Release.DownloadProtocol != DownloadProtocol.Usenet) { return 0; } - return CompareBy(x.RemoteAlbum, y.RemoteAlbum, remoteAlbum => + return CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum => { var ageHours = remoteAlbum.Release.AgeHours; var age = remoteAlbum.Release.Age; @@ -163,7 +163,7 @@ namespace NzbDrone.Core.DecisionEngine private int CompareSize(DownloadDecision x, DownloadDecision y) { // TODO: Is smaller better? Smaller for usenet could mean no par2 files. - return CompareBy(x.RemoteAlbum, y.RemoteAlbum, remoteAlbum => remoteAlbum.Release.Size.Round(200.Megabytes())); + return CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum => remoteAlbum.Release.Size.Round(200.Megabytes())); } } } diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs index 2917ed153..b6b758a27 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs @@ -68,69 +68,69 @@ namespace NzbDrone.Core.DecisionEngine try { - var parsedAlbumInfo = Parser.Parser.ParseAlbumTitle(report.Title); + var parsedBookInfo = Parser.Parser.ParseBookTitle(report.Title); - if (parsedAlbumInfo == null) + if (parsedBookInfo == null) { if (searchCriteria != null) { - parsedAlbumInfo = Parser.Parser.ParseAlbumTitleWithSearchCriteria(report.Title, - searchCriteria.Artist, - searchCriteria.Albums); + parsedBookInfo = Parser.Parser.ParseAlbumTitleWithSearchCriteria(report.Title, + searchCriteria.Author, + searchCriteria.Books); } else { // try parsing fuzzy - parsedAlbumInfo = _parsingService.ParseAlbumTitleFuzzy(report.Title); + parsedBookInfo = _parsingService.ParseAlbumTitleFuzzy(report.Title); } } - if (parsedAlbumInfo != null) + if (parsedBookInfo != null) { - if (!parsedAlbumInfo.ArtistName.IsNullOrWhiteSpace()) + if (!parsedBookInfo.AuthorName.IsNullOrWhiteSpace()) { - var remoteAlbum = _parsingService.Map(parsedAlbumInfo, searchCriteria); + var remoteBook = _parsingService.Map(parsedBookInfo, searchCriteria); // try parsing again using the search criteria, in case it parsed but parsed incorrectly - if ((remoteAlbum.Artist == null || remoteAlbum.Albums.Empty()) && searchCriteria != null) + if ((remoteBook.Author == null || remoteBook.Books.Empty()) && searchCriteria != null) { - _logger.Debug("Artist/Album null for {0}, reparsing with search criteria", report.Title); + _logger.Debug("Author/Book null for {0}, reparsing with search criteria", report.Title); var parsedAlbumInfoWithCriteria = Parser.Parser.ParseAlbumTitleWithSearchCriteria(report.Title, - searchCriteria.Artist, - searchCriteria.Albums); + searchCriteria.Author, + searchCriteria.Books); - if (parsedAlbumInfoWithCriteria != null && parsedAlbumInfoWithCriteria.ArtistName.IsNotNullOrWhiteSpace()) + if (parsedAlbumInfoWithCriteria != null && parsedAlbumInfoWithCriteria.AuthorName.IsNotNullOrWhiteSpace()) { - remoteAlbum = _parsingService.Map(parsedAlbumInfoWithCriteria, searchCriteria); + remoteBook = _parsingService.Map(parsedAlbumInfoWithCriteria, searchCriteria); } } - remoteAlbum.Release = report; + remoteBook.Release = report; - if (remoteAlbum.Artist == null) + if (remoteBook.Author == null) { - decision = new DownloadDecision(remoteAlbum, new Rejection("Unknown Artist")); + decision = new DownloadDecision(remoteBook, new Rejection("Unknown Author")); - // shove in the searched artist in case of forced download in interactive search + // shove in the searched author in case of forced download in interactive search if (searchCriteria != null) { - remoteAlbum.Artist = searchCriteria.Artist; - remoteAlbum.Albums = searchCriteria.Albums; + remoteBook.Author = searchCriteria.Author; + remoteBook.Books = searchCriteria.Books; } } - else if (remoteAlbum.Albums.Empty()) + else if (remoteBook.Books.Empty()) { - decision = new DownloadDecision(remoteAlbum, new Rejection("Unable to parse albums from release name")); + decision = new DownloadDecision(remoteBook, new Rejection("Unable to parse books from release name")); if (searchCriteria != null) { - remoteAlbum.Albums = searchCriteria.Albums; + remoteBook.Books = searchCriteria.Books; } } else { - _aggregationService.Augment(remoteAlbum); - remoteAlbum.DownloadAllowed = remoteAlbum.Albums.Any(); - decision = GetDecisionForReport(remoteAlbum, searchCriteria); + _aggregationService.Augment(remoteBook); + remoteBook.DownloadAllowed = remoteBook.Books.Any(); + decision = GetDecisionForReport(remoteBook, searchCriteria); } } } @@ -139,8 +139,8 @@ namespace NzbDrone.Core.DecisionEngine { _logger.Error(e, "Couldn't process release."); - var remoteAlbum = new RemoteAlbum { Release = report }; - decision = new DownloadDecision(remoteAlbum, new Rejection("Unexpected error processing release")); + var remoteBook = new RemoteBook { Release = report }; + decision = new DownloadDecision(remoteBook, new Rejection("Unexpected error processing release")); } reportNumber++; @@ -161,13 +161,13 @@ namespace NzbDrone.Core.DecisionEngine } } - private DownloadDecision GetDecisionForReport(RemoteAlbum remoteAlbum, SearchCriteriaBase searchCriteria = null) + private DownloadDecision GetDecisionForReport(RemoteBook remoteBook, SearchCriteriaBase searchCriteria = null) { var reasons = new Rejection[0]; foreach (var specifications in _specifications.GroupBy(v => v.Priority).OrderBy(v => v.Key)) { - reasons = specifications.Select(c => EvaluateSpec(c, remoteAlbum, searchCriteria)) + reasons = specifications.Select(c => EvaluateSpec(c, remoteBook, searchCriteria)) .Where(c => c != null) .ToArray(); @@ -177,14 +177,14 @@ namespace NzbDrone.Core.DecisionEngine } } - return new DownloadDecision(remoteAlbum, reasons.ToArray()); + return new DownloadDecision(remoteBook, reasons.ToArray()); } - private Rejection EvaluateSpec(IDecisionEngineSpecification spec, RemoteAlbum remoteAlbum, SearchCriteriaBase searchCriteriaBase = null) + private Rejection EvaluateSpec(IDecisionEngineSpecification spec, RemoteBook remoteBook, SearchCriteriaBase searchCriteriaBase = null) { try { - var result = spec.IsSatisfiedBy(remoteAlbum, searchCriteriaBase); + var result = spec.IsSatisfiedBy(remoteBook, searchCriteriaBase); if (!result.Accepted) { @@ -197,9 +197,9 @@ namespace NzbDrone.Core.DecisionEngine } catch (Exception e) { - e.Data.Add("report", remoteAlbum.Release.ToJson()); - e.Data.Add("parsed", remoteAlbum.ParsedAlbumInfo.ToJson()); - _logger.Error(e, "Couldn't evaluate decision on {0}", remoteAlbum.Release.Title); + e.Data.Add("report", remoteBook.Release.ToJson()); + e.Data.Add("parsed", remoteBook.ParsedBookInfo.ToJson()); + _logger.Error(e, "Couldn't evaluate decision on {0}", remoteBook.Release.Title); return new Rejection($"{spec.GetType().Name}: {e.Message}"); } diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionPriorizationService.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionPriorizationService.cs index 616c5ba45..afe7a1765 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionPriorizationService.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionPriorizationService.cs @@ -23,13 +23,13 @@ namespace NzbDrone.Core.DecisionEngine public List PrioritizeDecisions(List decisions) { - return decisions.Where(c => c.RemoteAlbum.DownloadAllowed) - .GroupBy(c => c.RemoteAlbum.Artist.Id, (authorId, downloadDecisions) => + return decisions.Where(c => c.RemoteBook.DownloadAllowed) + .GroupBy(c => c.RemoteBook.Author.Id, (authorId, downloadDecisions) => { return downloadDecisions.OrderByDescending(decision => decision, new DownloadDecisionComparer(_configService, _delayProfileService)); }) .SelectMany(c => c) - .Union(decisions.Where(c => !c.RemoteAlbum.DownloadAllowed)) + .Union(decisions.Where(c => !c.RemoteBook.DownloadAllowed)) .ToList(); } } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/AcceptableSizeSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/AcceptableSizeSpecification.cs index cf9266d1e..7a2fd330a 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/AcceptableSizeSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/AcceptableSizeSpecification.cs @@ -21,7 +21,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public SpecificationPriority Priority => SpecificationPriority.Default; public RejectionType Type => RejectionType.Permanent; - public Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { _logger.Debug("size restriction not implemented"); return Decision.Accept(); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/AlreadyImportedSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/AlreadyImportedSpecification.cs index 027f599e6..c80fddb4d 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/AlreadyImportedSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/AlreadyImportedSpecification.cs @@ -31,7 +31,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public SpecificationPriority Priority => SpecificationPriority.Database; public RejectionType Type => RejectionType.Permanent; - public Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { var cdhEnabled = _configService.EnableCompletedDownloadHandling; @@ -42,17 +42,17 @@ namespace NzbDrone.Core.DecisionEngine.Specifications } _logger.Debug("Performing already imported check on report"); - foreach (var album in subject.Albums) + foreach (var book in subject.Books) { - var trackFiles = _mediaFileService.GetFilesByAlbum(album.Id); + var bookFiles = _mediaFileService.GetFilesByBook(book.Id); - if (trackFiles.Count() == 0) + if (bookFiles.Count() == 0) { - _logger.Debug("Skipping already imported check for album without files"); + _logger.Debug("Skipping already imported check for book without files"); continue; } - var historyForAlbum = _historyService.GetByAlbum(album.Id, null); + var historyForAlbum = _historyService.GetByBook(book.Id, null); var lastGrabbed = historyForAlbum.FirstOrDefault(h => h.EventType == HistoryEventType.Grabbed); if (lastGrabbed == null) diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/BlacklistSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/BlacklistSpecification.cs index 0f471dad9..bab5bbd3a 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/BlacklistSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/BlacklistSpecification.cs @@ -19,9 +19,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public SpecificationPriority Priority => SpecificationPriority.Database; public RejectionType Type => RejectionType.Permanent; - public Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { - if (_blacklistService.Blacklisted(subject.Artist.Id, subject.Release)) + if (_blacklistService.Blacklisted(subject.Author.Id, subject.Release)) { _logger.Debug("{0} is blacklisted, rejecting.", subject.Release.Title); return Decision.Reject("Release is blacklisted"); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/BlockedIndexerSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/BlockedIndexerSpecification.cs index 3ec06fe7e..c40ab39b6 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/BlockedIndexerSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/BlockedIndexerSpecification.cs @@ -27,7 +27,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public SpecificationPriority Priority => SpecificationPriority.Database; public RejectionType Type => RejectionType.Temporary; - public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { var status = _blockedIndexerCache.Find(subject.Release.IndexerId.ToString()); if (status != null) diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/CutoffSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/CutoffSpecification.cs index 46f4d88ca..af7bd7ed2 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/CutoffSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/CutoffSpecification.cs @@ -27,21 +27,21 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public SpecificationPriority Priority => SpecificationPriority.Default; public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { - var qualityProfile = subject.Artist.QualityProfile.Value; + var qualityProfile = subject.Author.QualityProfile.Value; - foreach (var file in subject.Albums.SelectMany(b => b.BookFiles.Value)) + foreach (var file in subject.Books.SelectMany(b => b.BookFiles.Value)) { - // Get a distinct list of all current track qualities for a given album + // Get a distinct list of all current track qualities for a given book var currentQualities = new List { file.Quality }; _logger.Debug("Comparing file quality with report. Existing files contain {0}", currentQualities.ConcatToString()); if (!_upgradableSpecification.CutoffNotMet(qualityProfile, currentQualities, - _preferredWordServiceCalculator.Calculate(subject.Artist, file.GetSceneOrFileName()), - subject.ParsedAlbumInfo.Quality, + _preferredWordServiceCalculator.Calculate(subject.Author, file.GetSceneOrFileName()), + subject.ParsedBookInfo.Quality, subject.PreferredWordScore)) { _logger.Debug("Cutoff already met by existing files, rejecting."); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/DiscographySpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/DiscographySpecification.cs index 98ff0d304..48d82a27e 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/DiscographySpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/DiscographySpecification.cs @@ -19,13 +19,13 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public SpecificationPriority Priority => SpecificationPriority.Default; public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { - if (subject.ParsedAlbumInfo.Discography) + if (subject.ParsedBookInfo.Discography) { _logger.Debug("Checking if all albums in discography release have released. {0}", subject.Release.Title); - if (subject.Albums.Any(e => !e.ReleaseDate.HasValue || e.ReleaseDate.Value.After(DateTime.UtcNow))) + if (subject.Books.Any(e => !e.ReleaseDate.HasValue || e.ReleaseDate.Value.After(DateTime.UtcNow))) { _logger.Debug("Discography release {0} rejected. All albums haven't released yet.", subject.Release.Title); return Decision.Reject("Discography release rejected. All albums haven't released yet."); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/EarlyReleaseSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/EarlyReleaseSpecification.cs index 4a3fbdef4..13984bc28 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/EarlyReleaseSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/EarlyReleaseSpecification.cs @@ -21,7 +21,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public SpecificationPriority Priority => SpecificationPriority.Default; public RejectionType Type => RejectionType.Permanent; - public Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { var releaseInfo = subject.Release; @@ -43,12 +43,12 @@ namespace NzbDrone.Core.DecisionEngine.Specifications var indexerSettings = indexer.Settings as IIndexerSettings; - if (subject.Albums.Count != 1 || indexerSettings?.EarlyReleaseLimit == null) + if (subject.Books.Count != 1 || indexerSettings?.EarlyReleaseLimit == null) { return Decision.Accept(); } - var releaseDate = subject.Albums.First().ReleaseDate; + var releaseDate = subject.Books.First().ReleaseDate; if (releaseDate == null) { diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/IDecisionEngineSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/IDecisionEngineSpecification.cs index a9eec669f..fbcdb5c26 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/IDecisionEngineSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/IDecisionEngineSpecification.cs @@ -9,6 +9,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications SpecificationPriority Priority { get; } - Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria); + Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria); } } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/MaximumSizeSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/MaximumSizeSpecification.cs index 04f12ece0..1e1af447b 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/MaximumSizeSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/MaximumSizeSpecification.cs @@ -20,7 +20,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public SpecificationPriority Priority => SpecificationPriority.Default; public RejectionType Type => RejectionType.Permanent; - public Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { var size = subject.Release.Size; var maximumSize = _configService.MaximumSize.Megabytes(); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/MinimumAgeSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/MinimumAgeSpecification.cs index 3e322881d..ec6a050eb 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/MinimumAgeSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/MinimumAgeSpecification.cs @@ -20,7 +20,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public SpecificationPriority Priority => SpecificationPriority.Default; public RejectionType Type => RejectionType.Temporary; - public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { if (subject.Release.DownloadProtocol != Indexers.DownloadProtocol.Usenet) { diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/NotSampleSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/NotSampleSpecification.cs index 6f7b454b4..7695d2c12 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/NotSampleSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/NotSampleSpecification.cs @@ -16,7 +16,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications _logger = logger; } - public Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { if (subject.Release.Title.ToLower().Contains("sample") && subject.Release.Size < 20.Megabytes()) { diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/ProtocolSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/ProtocolSpecification.cs index dae103196..f36a7f5dd 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/ProtocolSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/ProtocolSpecification.cs @@ -21,20 +21,20 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public SpecificationPriority Priority => SpecificationPriority.Default; public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { - var delayProfile = _delayProfileService.BestForTags(subject.Artist.Tags); + var delayProfile = _delayProfileService.BestForTags(subject.Author.Tags); if (subject.Release.DownloadProtocol == DownloadProtocol.Usenet && !delayProfile.EnableUsenet) { - _logger.Debug("[{0}] Usenet is not enabled for this artist", subject.Release.Title); - return Decision.Reject("Usenet is not enabled for this artist"); + _logger.Debug("[{0}] Usenet is not enabled for this author", subject.Release.Title); + return Decision.Reject("Usenet is not enabled for this author"); } if (subject.Release.DownloadProtocol == DownloadProtocol.Torrent && !delayProfile.EnableTorrent) { - _logger.Debug("[{0}] Torrent is not enabled for this artist", subject.Release.Title); - return Decision.Reject("Torrent is not enabled for this artist"); + _logger.Debug("[{0}] Torrent is not enabled for this author", subject.Release.Title); + return Decision.Reject("Torrent is not enabled for this author"); } return Decision.Accept(); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/QualityAllowedByProfileSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/QualityAllowedByProfileSpecification.cs index db5eebaec..eca323331 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/QualityAllowedByProfileSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/QualityAllowedByProfileSpecification.cs @@ -16,18 +16,18 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public SpecificationPriority Priority => SpecificationPriority.Default; public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { - _logger.Debug("Checking if report meets quality requirements. {0}", subject.ParsedAlbumInfo.Quality); + _logger.Debug("Checking if report meets quality requirements. {0}", subject.ParsedBookInfo.Quality); - var profile = subject.Artist.QualityProfile.Value; - var qualityIndex = profile.GetIndex(subject.ParsedAlbumInfo.Quality.Quality); + var profile = subject.Author.QualityProfile.Value; + var qualityIndex = profile.GetIndex(subject.ParsedBookInfo.Quality.Quality); var qualityOrGroup = profile.Items[qualityIndex.Index]; if (!qualityOrGroup.Allowed) { - _logger.Debug("Quality {0} rejected by Artist's quality profile", subject.ParsedAlbumInfo.Quality); - return Decision.Reject("{0} is not wanted in profile", subject.ParsedAlbumInfo.Quality.Quality); + _logger.Debug("Quality {0} rejected by Author's quality profile", subject.ParsedBookInfo.Quality); + return Decision.Reject("{0} is not wanted in profile", subject.ParsedBookInfo.Quality.Quality); } return Decision.Accept(); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/QueueSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/QueueSpecification.cs index e512faffb..5f8f7a6ce 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/QueueSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/QueueSpecification.cs @@ -31,18 +31,18 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public SpecificationPriority Priority => SpecificationPriority.Default; public RejectionType Type => RejectionType.Permanent; - public Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { var queue = _queueService.GetQueue(); - var matchingAlbum = queue.Where(q => q.RemoteAlbum?.Artist != null && - q.RemoteAlbum.Artist.Id == subject.Artist.Id && - q.RemoteAlbum.Albums.Select(e => e.Id).Intersect(subject.Albums.Select(e => e.Id)).Any()) + var matchingAlbum = queue.Where(q => q.RemoteBook?.Author != null && + q.RemoteBook.Author.Id == subject.Author.Id && + q.RemoteBook.Books.Select(e => e.Id).Intersect(subject.Books.Select(e => e.Id)).Any()) .ToList(); foreach (var queueItem in matchingAlbum) { - var remoteAlbum = queueItem.RemoteAlbum; - var qualityProfile = subject.Artist.QualityProfile.Value; + var remoteAlbum = queueItem.RemoteBook; + var qualityProfile = subject.Author.QualityProfile.Value; // To avoid a race make sure it's not FailedPending (failed awaiting removal/search). // Failed items (already searching for a replacement) won't be part of the queue since @@ -52,35 +52,35 @@ namespace NzbDrone.Core.DecisionEngine.Specifications continue; } - _logger.Debug("Checking if existing release in queue meets cutoff. Queued quality is: {0}", remoteAlbum.ParsedAlbumInfo.Quality); + _logger.Debug("Checking if existing release in queue meets cutoff. Queued quality is: {0}", remoteAlbum.ParsedBookInfo.Quality); - var queuedItemPreferredWordScore = _preferredWordServiceCalculator.Calculate(subject.Artist, queueItem.Title); + var queuedItemPreferredWordScore = _preferredWordServiceCalculator.Calculate(subject.Author, queueItem.Title); if (!_upgradableSpecification.CutoffNotMet(qualityProfile, - new List { remoteAlbum.ParsedAlbumInfo.Quality }, + new List { remoteAlbum.ParsedBookInfo.Quality }, queuedItemPreferredWordScore, - subject.ParsedAlbumInfo.Quality, + subject.ParsedBookInfo.Quality, subject.PreferredWordScore)) { - return Decision.Reject("Release in queue already meets cutoff: {0}", remoteAlbum.ParsedAlbumInfo.Quality); + return Decision.Reject("Release in queue already meets cutoff: {0}", remoteAlbum.ParsedBookInfo.Quality); } - _logger.Debug("Checking if release is higher quality than queued release. Queued: {0}", remoteAlbum.ParsedAlbumInfo.Quality); + _logger.Debug("Checking if release is higher quality than queued release. Queued: {0}", remoteAlbum.ParsedBookInfo.Quality); if (!_upgradableSpecification.IsUpgradable(qualityProfile, - new List { remoteAlbum.ParsedAlbumInfo.Quality }, + new List { remoteAlbum.ParsedBookInfo.Quality }, queuedItemPreferredWordScore, - subject.ParsedAlbumInfo.Quality, + subject.ParsedBookInfo.Quality, subject.PreferredWordScore)) { - return Decision.Reject("Release in queue is of equal or higher preference: {0}", remoteAlbum.ParsedAlbumInfo.Quality); + return Decision.Reject("Release in queue is of equal or higher preference: {0}", remoteAlbum.ParsedBookInfo.Quality); } - _logger.Debug("Checking if profiles allow upgrading. Queued: {0}", remoteAlbum.ParsedAlbumInfo.Quality); + _logger.Debug("Checking if profiles allow upgrading. Queued: {0}", remoteAlbum.ParsedBookInfo.Quality); if (!_upgradableSpecification.IsUpgradeAllowed(qualityProfile, - new List { remoteAlbum.ParsedAlbumInfo.Quality }, - subject.ParsedAlbumInfo.Quality)) + new List { remoteAlbum.ParsedBookInfo.Quality }, + subject.ParsedBookInfo.Quality)) { return Decision.Reject("Another release is queued and the Quality profile does not allow upgrades"); } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RawDiskSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RawDiskSpecification.cs index 41a337336..cd6855e51 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RawDiskSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RawDiskSpecification.cs @@ -20,7 +20,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public SpecificationPriority Priority => SpecificationPriority.Default; public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { if (subject.Release == null || subject.Release.Container.IsNullOrWhiteSpace()) { diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/ReleaseRestrictionsSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/ReleaseRestrictionsSpecification.cs index 025d9bcad..dfd0bbc21 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/ReleaseRestrictionsSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/ReleaseRestrictionsSpecification.cs @@ -25,12 +25,12 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public SpecificationPriority Priority => SpecificationPriority.Default; public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { _logger.Debug("Checking if release meets restrictions: {0}", subject); var title = subject.Release.Title; - var restrictions = _releaseProfileService.AllForTags(subject.Artist.Tags); + var restrictions = _releaseProfileService.AllForTags(subject.Author.Tags); var required = restrictions.Where(r => r.Required.IsNotNullOrWhiteSpace()); var ignored = restrictions.Where(r => r.Ignored.IsNotNullOrWhiteSpace()); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RepackSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RepackSpecification.cs index 86198d776..8cce208d8 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RepackSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RepackSpecification.cs @@ -23,21 +23,21 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public SpecificationPriority Priority => SpecificationPriority.Database; public RejectionType Type => RejectionType.Permanent; - public Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { - if (!subject.ParsedAlbumInfo.Quality.Revision.IsRepack) + if (!subject.ParsedBookInfo.Quality.Revision.IsRepack) { return Decision.Accept(); } - foreach (var album in subject.Albums) + foreach (var book in subject.Books) { - var releaseGroup = subject.ParsedAlbumInfo.ReleaseGroup; - var trackFiles = _mediaFileService.GetFilesByAlbum(album.Id); + var releaseGroup = subject.ParsedBookInfo.ReleaseGroup; + var bookFiles = _mediaFileService.GetFilesByBook(book.Id); - foreach (var file in trackFiles) + foreach (var file in bookFiles) { - if (_upgradableSpecification.IsRevisionUpgrade(file.Quality, subject.ParsedAlbumInfo.Quality)) + if (_upgradableSpecification.IsRevisionUpgrade(file.Quality, subject.ParsedBookInfo.Quality)) { var fileReleaseGroup = file.ReleaseGroup; diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RetentionSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RetentionSpecification.cs index c3deb05fd..94c7f5200 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RetentionSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RetentionSpecification.cs @@ -19,7 +19,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public SpecificationPriority Priority => SpecificationPriority.Default; public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { if (subject.Release.DownloadProtocol != Indexers.DownloadProtocol.Usenet) { diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DelaySpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DelaySpecification.cs index 8e12e3d24..c1e965383 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DelaySpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DelaySpecification.cs @@ -37,7 +37,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync public SpecificationPriority Priority => SpecificationPriority.Database; public RejectionType Type => RejectionType.Temporary; - public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { if (searchCriteria != null && searchCriteria.UserInvokedSearch) { @@ -45,8 +45,8 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync return Decision.Accept(); } - var qualityProfile = subject.Artist.QualityProfile.Value; - var delayProfile = _delayProfileService.BestForTags(subject.Artist.Tags); + var qualityProfile = subject.Author.QualityProfile.Value; + var delayProfile = _delayProfileService.BestForTags(subject.Author.Tags); var delay = delayProfile.GetProtocolDelay(subject.Release.DownloadProtocol); var isPreferredProtocol = subject.Release.DownloadProtocol == delayProfile.PreferredProtocol; @@ -60,18 +60,18 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync if (isPreferredProtocol) { - foreach (var album in subject.Albums) + foreach (var book in subject.Books) { - var trackFiles = _mediaFileService.GetFilesByAlbum(album.Id); + var bookFiles = _mediaFileService.GetFilesByBook(book.Id); - if (trackFiles.Any()) + if (bookFiles.Any()) { - var currentQualities = trackFiles.Select(c => c.Quality).Distinct().ToList(); + var currentQualities = bookFiles.Select(c => c.Quality).Distinct().ToList(); var upgradable = _upgradableSpecification.IsUpgradable(qualityProfile, currentQualities, - _preferredWordServiceCalculator.Calculate(subject.Artist, trackFiles[0].GetSceneOrFileName()), - subject.ParsedAlbumInfo.Quality, + _preferredWordServiceCalculator.Calculate(subject.Author, bookFiles[0].GetSceneOrFileName()), + subject.ParsedBookInfo.Quality, subject.PreferredWordScore); if (upgradable) { @@ -84,7 +84,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync // If quality meets or exceeds the best allowed quality in the profile accept it immediately var bestQualityInProfile = qualityProfile.LastAllowedQuality(); - var isBestInProfile = qualityComparer.Compare(subject.ParsedAlbumInfo.Quality.Quality, bestQualityInProfile) >= 0; + var isBestInProfile = qualityComparer.Compare(subject.ParsedBookInfo.Quality.Quality, bestQualityInProfile) >= 0; if (isBestInProfile && isPreferredProtocol) { @@ -92,9 +92,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync return Decision.Accept(); } - var bookIds = subject.Albums.Select(e => e.Id); + var bookIds = subject.Books.Select(e => e.Id); - var oldest = _pendingReleaseService.OldestPendingRelease(subject.Artist.Id, bookIds.ToArray()); + var oldest = _pendingReleaseService.OldestPendingRelease(subject.Author.Id, bookIds.ToArray()); if (oldest != null && oldest.Release.AgeMinutes > delay) { diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DeletedTrackFileSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DeletedBookFileSpecification.cs similarity index 57% rename from src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DeletedTrackFileSpecification.cs rename to src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DeletedBookFileSpecification.cs index 6faf03b44..9827ea12e 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DeletedTrackFileSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DeletedBookFileSpecification.cs @@ -2,36 +2,36 @@ using System.Linq; using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync { - public class DeletedTrackFileSpecification : IDecisionEngineSpecification + public class DeletedBookFileSpecification : IDecisionEngineSpecification { private readonly IDiskProvider _diskProvider; private readonly IConfigService _configService; - private readonly IMediaFileService _albumService; + private readonly IMediaFileService _bookService; private readonly Logger _logger; - public DeletedTrackFileSpecification(IDiskProvider diskProvider, + public DeletedBookFileSpecification(IDiskProvider diskProvider, IConfigService configService, - IMediaFileService albumService, + IMediaFileService bookService, Logger logger) { _diskProvider = diskProvider; _configService = configService; - _albumService = albumService; + _bookService = bookService; _logger = logger; } public SpecificationPriority Priority => SpecificationPriority.Disk; public RejectionType Type => RejectionType.Temporary; - public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { if (!_configService.AutoUnmonitorPreviouslyDownloadedTracks) { @@ -40,33 +40,33 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync if (searchCriteria != null) { - _logger.Debug("Skipping deleted trackfile check during search"); + _logger.Debug("Skipping deleted bookfile check during search"); return Decision.Accept(); } - var missingTrackFiles = subject.Albums - .SelectMany(v => _albumService.GetFilesByAlbum(v.Id)) + var missingTrackFiles = subject.Books + .SelectMany(v => _bookService.GetFilesByBook(v.Id)) .DistinctBy(v => v.Id) - .Where(v => IsTrackFileMissing(subject.Artist, v)) + .Where(v => IsTrackFileMissing(subject.Author, v)) .ToArray(); if (missingTrackFiles.Any()) { foreach (var missingTrackFile in missingTrackFiles) { - _logger.Trace("Track file {0} is missing from disk.", missingTrackFile.Path); + _logger.Trace("Book file {0} is missing from disk.", missingTrackFile.Path); } - _logger.Debug("Files for this album exist in the database but not on disk, will be unmonitored on next diskscan. skipping."); - return Decision.Reject("Artist is not monitored"); + _logger.Debug("Files for this book exist in the database but not on disk, will be unmonitored on next diskscan. skipping."); + return Decision.Reject("Author is not monitored"); } return Decision.Accept(); } - private bool IsTrackFileMissing(Author artist, BookFile trackFile) + private bool IsTrackFileMissing(Author author, BookFile bookFile) { - return !_diskProvider.FileExists(trackFile.Path); + return !_diskProvider.FileExists(bookFile.Path); } } } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/HistorySpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/HistorySpecification.cs index 65cac72f3..042899a9b 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/HistorySpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/HistorySpecification.cs @@ -35,7 +35,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync public SpecificationPriority Priority => SpecificationPriority.Database; public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { if (searchCriteria != null) { @@ -46,10 +46,10 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync var cdhEnabled = _configService.EnableCompletedDownloadHandling; _logger.Debug("Performing history status check on report"); - foreach (var album in subject.Albums) + foreach (var book in subject.Books) { - _logger.Debug("Checking current status of album [{0}] in history", album.Id); - var mostRecent = _historyService.MostRecentForAlbum(album.Id); + _logger.Debug("Checking current status of book [{0}] in history", book.Id); + var mostRecent = _historyService.MostRecentForBook(book.Id); if (mostRecent != null && mostRecent.EventType == HistoryEventType.Grabbed) { @@ -60,22 +60,22 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync continue; } - // The artist will be the same as the one in history since it's the same album. - // Instead of fetching the artist from the DB reuse the known artist. - var preferredWordScore = _preferredWordServiceCalculator.Calculate(subject.Artist, mostRecent.SourceTitle); + // The author will be the same as the one in history since it's the same book. + // Instead of fetching the author from the DB reuse the known author. + var preferredWordScore = _preferredWordServiceCalculator.Calculate(subject.Author, mostRecent.SourceTitle); var cutoffUnmet = _upgradableSpecification.CutoffNotMet( - subject.Artist.QualityProfile, + subject.Author.QualityProfile, new List { mostRecent.Quality }, preferredWordScore, - subject.ParsedAlbumInfo.Quality, + subject.ParsedBookInfo.Quality, subject.PreferredWordScore); var upgradeable = _upgradableSpecification.IsUpgradable( - subject.Artist.QualityProfile, + subject.Author.QualityProfile, new List { mostRecent.Quality }, preferredWordScore, - subject.ParsedAlbumInfo.Quality, + subject.ParsedBookInfo.Quality, subject.PreferredWordScore); if (!cutoffUnmet) diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredAlbumSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredAlbumSpecification.cs index e0f26ab11..4caf91b37 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredAlbumSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredAlbumSpecification.cs @@ -17,42 +17,42 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync public SpecificationPriority Priority => SpecificationPriority.Default; public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { if (searchCriteria != null) { - if (!searchCriteria.MonitoredEpisodesOnly) + if (!searchCriteria.MonitoredBooksOnly) { _logger.Debug("Skipping monitored check during search"); return Decision.Accept(); } } - if (!subject.Artist.Monitored) + if (!subject.Author.Monitored) { - _logger.Debug("{0} is present in the DB but not tracked. Rejecting.", subject.Artist); - return Decision.Reject("Artist is not monitored"); + _logger.Debug("{0} is present in the DB but not tracked. Rejecting.", subject.Author); + return Decision.Reject("Author is not monitored"); } - var monitoredCount = subject.Albums.Count(album => album.Monitored); - if (monitoredCount == subject.Albums.Count) + var monitoredCount = subject.Books.Count(book => book.Monitored); + if (monitoredCount == subject.Books.Count) { return Decision.Accept(); } - if (subject.Albums.Count == 1) + if (subject.Books.Count == 1) { - _logger.Debug("Album is not monitored. Rejecting", monitoredCount, subject.Albums.Count); + _logger.Debug("Album is not monitored. Rejecting", monitoredCount, subject.Books.Count); return Decision.Reject("Album is not monitored"); } if (monitoredCount == 0) { - _logger.Debug("No albums in the release are monitored. Rejecting", monitoredCount, subject.Albums.Count); + _logger.Debug("No albums in the release are monitored. Rejecting", monitoredCount, subject.Books.Count); } else { - _logger.Debug("Only {0}/{1} albums in the release are monitored. Rejecting", monitoredCount, subject.Albums.Count); + _logger.Debug("Only {0}/{1} albums in the release are monitored. Rejecting", monitoredCount, subject.Books.Count); } return Decision.Reject("Album is not monitored"); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/ProperSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/ProperSpecification.cs index 03b63e3d2..ae3809bf9 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/ProperSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/ProperSpecification.cs @@ -26,7 +26,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync public SpecificationPriority Priority => SpecificationPriority.Default; public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { if (searchCriteria != null) { @@ -41,13 +41,13 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync return Decision.Accept(); } - foreach (var album in subject.Albums) + foreach (var book in subject.Books) { - var trackFiles = _mediaFileService.GetFilesByAlbum(album.Id); + var bookFiles = _mediaFileService.GetFilesByBook(book.Id); - foreach (var file in trackFiles) + foreach (var file in bookFiles) { - if (_qualityUpgradableSpecification.IsRevisionUpgrade(file.Quality, subject.ParsedAlbumInfo.Quality)) + if (_qualityUpgradableSpecification.IsRevisionUpgrade(file.Quality, subject.ParsedBookInfo.Quality)) { if (downloadPropersAndRepacks == ProperDownloadTypes.DoNotUpgrade) { diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/AlbumRequestedSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/AlbumRequestedSpecification.cs index 79c4a82b2..b19ca8440 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/AlbumRequestedSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/AlbumRequestedSpecification.cs @@ -17,19 +17,19 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search public SpecificationPriority Priority => SpecificationPriority.Default; public RejectionType Type => RejectionType.Permanent; - public Decision IsSatisfiedBy(RemoteAlbum remoteAlbum, SearchCriteriaBase searchCriteria) + public Decision IsSatisfiedBy(RemoteBook remoteAlbum, SearchCriteriaBase searchCriteria) { if (searchCriteria == null) { return Decision.Accept(); } - var criteriaAlbum = searchCriteria.Albums.Select(v => v.Id).ToList(); - var remoteAlbums = remoteAlbum.Albums.Select(v => v.Id).ToList(); + var criteriaAlbum = searchCriteria.Books.Select(v => v.Id).ToList(); + var remoteAlbums = remoteAlbum.Books.Select(v => v.Id).ToList(); if (!criteriaAlbum.Intersect(remoteAlbums).Any()) { - _logger.Debug("Release rejected since the album wasn't requested: {0}", remoteAlbum.ParsedAlbumInfo); + _logger.Debug("Release rejected since the book wasn't requested: {0}", remoteAlbum.ParsedBookInfo); return Decision.Reject("Album wasn't requested"); } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/ArtistSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/AuthorSpecification.cs similarity index 54% rename from src/NzbDrone.Core/DecisionEngine/Specifications/Search/ArtistSpecification.cs rename to src/NzbDrone.Core/DecisionEngine/Specifications/Search/AuthorSpecification.cs index 7eb972b80..c7d661c83 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/ArtistSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/AuthorSpecification.cs @@ -4,11 +4,11 @@ using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.DecisionEngine.Specifications.Search { - public class ArtistSpecification : IDecisionEngineSpecification + public class AuthorSpecification : IDecisionEngineSpecification { private readonly Logger _logger; - public ArtistSpecification(Logger logger) + public AuthorSpecification(Logger logger) { _logger = logger; } @@ -16,19 +16,19 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search public SpecificationPriority Priority => SpecificationPriority.Default; public RejectionType Type => RejectionType.Permanent; - public Decision IsSatisfiedBy(RemoteAlbum remoteAlbum, SearchCriteriaBase searchCriteria) + public Decision IsSatisfiedBy(RemoteBook remoteAlbum, SearchCriteriaBase searchCriteria) { if (searchCriteria == null) { return Decision.Accept(); } - _logger.Debug("Checking if artist matches searched artist"); + _logger.Debug("Checking if author matches searched author"); - if (remoteAlbum.Artist.Id != searchCriteria.Artist.Id) + if (remoteAlbum.Author.Id != searchCriteria.Author.Id) { - _logger.Debug("Artist {0} does not match {1}", remoteAlbum.Artist, searchCriteria.Artist); - return Decision.Reject("Wrong artist"); + _logger.Debug("Author {0} does not match {1}", remoteAlbum.Author, searchCriteria.Author); + return Decision.Reject("Wrong author"); } return Decision.Accept(); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleAlbumSearchMatchSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleAlbumSearchMatchSpecification.cs deleted file mode 100644 index 58543dcf1..000000000 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleAlbumSearchMatchSpecification.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Linq; -using NLog; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.DecisionEngine.Specifications.Search -{ - public class SingleAlbumSearchMatchSpecification : IDecisionEngineSpecification - { - private readonly Logger _logger; - - public SingleAlbumSearchMatchSpecification(Logger logger) - { - _logger = logger; - } - - public SpecificationPriority Priority => SpecificationPriority.Default; - public RejectionType Type => RejectionType.Permanent; - - public virtual Decision IsSatisfiedBy(RemoteAlbum remoteAlbum, SearchCriteriaBase searchCriteria) - { - if (searchCriteria == null) - { - return Decision.Accept(); - } - - var singleAlbumSpec = searchCriteria as AlbumSearchCriteria; - if (singleAlbumSpec == null) - { - return Decision.Accept(); - } - - if (Parser.Parser.CleanArtistName(singleAlbumSpec.AlbumTitle) != Parser.Parser.CleanArtistName(remoteAlbum.ParsedAlbumInfo.AlbumTitle)) - { - _logger.Debug("Album does not match searched album title, skipping."); - return Decision.Reject("Wrong album"); - } - - if (!remoteAlbum.ParsedAlbumInfo.AlbumTitle.Any()) - { - _logger.Debug("Full discography result during single album search, skipping."); - return Decision.Reject("Full artist pack"); - } - - return Decision.Accept(); - } - } -} diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleBookSearchMatchSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleBookSearchMatchSpecification.cs new file mode 100644 index 000000000..09ae0217f --- /dev/null +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleBookSearchMatchSpecification.cs @@ -0,0 +1,48 @@ +using System.Linq; +using NLog; +using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Parser.Model; + +namespace NzbDrone.Core.DecisionEngine.Specifications.Search +{ + public class SingleBookSearchMatchSpecification : IDecisionEngineSpecification + { + private readonly Logger _logger; + + public SingleBookSearchMatchSpecification(Logger logger) + { + _logger = logger; + } + + public SpecificationPriority Priority => SpecificationPriority.Default; + public RejectionType Type => RejectionType.Permanent; + + public virtual Decision IsSatisfiedBy(RemoteBook remoteBook, SearchCriteriaBase searchCriteria) + { + if (searchCriteria == null) + { + return Decision.Accept(); + } + + var singleBookSpec = searchCriteria as BookSearchCriteria; + if (singleBookSpec == null) + { + return Decision.Accept(); + } + + if (Parser.Parser.CleanAuthorName(singleBookSpec.BookTitle) != Parser.Parser.CleanAuthorName(remoteBook.ParsedBookInfo.BookTitle)) + { + _logger.Debug("Book does not match searched book title, skipping."); + return Decision.Reject("Wrong book"); + } + + if (!remoteBook.ParsedBookInfo.BookTitle.Any()) + { + _logger.Debug("Full discography result during single book search, skipping."); + return Decision.Reject("Full author pack"); + } + + return Decision.Accept(); + } + } +} diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/TorrentSeedingSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/TorrentSeedingSpecification.cs index c98ae9f5a..de157c92c 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/TorrentSeedingSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/TorrentSeedingSpecification.cs @@ -20,7 +20,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public SpecificationPriority Priority => SpecificationPriority.Default; public RejectionType Type => RejectionType.Permanent; - public Decision IsSatisfiedBy(RemoteAlbum remoteAlbum, SearchCriteriaBase searchCriteria) + public Decision IsSatisfiedBy(RemoteBook remoteAlbum, SearchCriteriaBase searchCriteria) { var torrentInfo = remoteAlbum.Release as TorrentInfo; diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradeAllowedSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradeAllowedSpecification.cs index 944cf6f84..42ce9c70c 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradeAllowedSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradeAllowedSpecification.cs @@ -23,11 +23,11 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public SpecificationPriority Priority => SpecificationPriority.Default; public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { - var qualityProfile = subject.Artist.QualityProfile.Value; + var qualityProfile = subject.Author.QualityProfile.Value; - foreach (var file in subject.Albums.SelectMany(b => b.BookFiles.Value)) + foreach (var file in subject.Books.SelectMany(b => b.BookFiles.Value)) { if (file == null) { @@ -35,14 +35,14 @@ namespace NzbDrone.Core.DecisionEngine.Specifications continue; } - // Get a distinct list of all current track qualities for a given album + // Get a distinct list of all current track qualities for a given book var currentQualities = new List { file.Quality }; _logger.Debug("Comparing file quality with report. Existing files contain {0}", currentQualities.ConcatToString()); if (!_upgradableSpecification.IsUpgradeAllowed(qualityProfile, currentQualities, - subject.ParsedAlbumInfo.Quality)) + subject.ParsedBookInfo.Quality)) { _logger.Debug("Upgrading is not allowed by the quality profile"); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradeDiskSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradeDiskSpecification.cs index ba15adff5..578826fce 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradeDiskSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradeDiskSpecification.cs @@ -26,9 +26,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public SpecificationPriority Priority => SpecificationPriority.Default; public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { - foreach (var file in subject.Albums.SelectMany(c => c.BookFiles.Value)) + foreach (var file in subject.Books.SelectMany(c => c.BookFiles.Value)) { if (file == null) { @@ -38,10 +38,10 @@ namespace NzbDrone.Core.DecisionEngine.Specifications _logger.Debug("Comparing file quality and language with report. Existing file is {0}", file.Quality); - if (!_upgradableSpecification.IsUpgradable(subject.Artist.QualityProfile, + if (!_upgradableSpecification.IsUpgradable(subject.Author.QualityProfile, new List { file.Quality }, - _preferredWordServiceCalculator.Calculate(subject.Artist, file.GetSceneOrFileName()), - subject.ParsedAlbumInfo.Quality, + _preferredWordServiceCalculator.Calculate(subject.Author, file.GetSceneOrFileName()), + subject.ParsedBookInfo.Quality, subject.PreferredWordScore)) { return Decision.Reject("Existing file on disk is of equal or higher preference: {0}", file.Quality); diff --git a/src/NzbDrone.Core/Download/Aggregation/Aggregators/AggregatePreferredWordScore.cs b/src/NzbDrone.Core/Download/Aggregation/Aggregators/AggregatePreferredWordScore.cs index cf41c32bc..9f93b78b0 100644 --- a/src/NzbDrone.Core/Download/Aggregation/Aggregators/AggregatePreferredWordScore.cs +++ b/src/NzbDrone.Core/Download/Aggregation/Aggregators/AggregatePreferredWordScore.cs @@ -12,9 +12,9 @@ namespace NzbDrone.Core.Download.Aggregation.Aggregators _preferredWordServiceCalculator = preferredWordServiceCalculator; } - public RemoteAlbum Aggregate(RemoteAlbum remoteAlbum) + public RemoteBook Aggregate(RemoteBook remoteAlbum) { - remoteAlbum.PreferredWordScore = _preferredWordServiceCalculator.Calculate(remoteAlbum.Artist, remoteAlbum.Release.Title); + remoteAlbum.PreferredWordScore = _preferredWordServiceCalculator.Calculate(remoteAlbum.Author, remoteAlbum.Release.Title); return remoteAlbum; } diff --git a/src/NzbDrone.Core/Download/Aggregation/Aggregators/IAggregateRemoteAlbum.cs b/src/NzbDrone.Core/Download/Aggregation/Aggregators/IAggregateRemoteAlbum.cs index c88c95686..1d4cce43e 100644 --- a/src/NzbDrone.Core/Download/Aggregation/Aggregators/IAggregateRemoteAlbum.cs +++ b/src/NzbDrone.Core/Download/Aggregation/Aggregators/IAggregateRemoteAlbum.cs @@ -4,6 +4,6 @@ namespace NzbDrone.Core.Download.Aggregation.Aggregators { public interface IAggregateRemoteAlbum { - RemoteAlbum Aggregate(RemoteAlbum remoteAlbum); + RemoteBook Aggregate(RemoteBook remoteAlbum); } } diff --git a/src/NzbDrone.Core/Download/Aggregation/RemoteAlbumAggregationService.cs b/src/NzbDrone.Core/Download/Aggregation/RemoteAlbumAggregationService.cs index 46352c300..e9860eb29 100644 --- a/src/NzbDrone.Core/Download/Aggregation/RemoteAlbumAggregationService.cs +++ b/src/NzbDrone.Core/Download/Aggregation/RemoteAlbumAggregationService.cs @@ -8,7 +8,7 @@ namespace NzbDrone.Core.Download.Aggregation { public interface IRemoteAlbumAggregationService { - RemoteAlbum Augment(RemoteAlbum remoteAlbum); + RemoteBook Augment(RemoteBook remoteAlbum); } public class RemoteAlbumAggregationService : IRemoteAlbumAggregationService @@ -23,7 +23,7 @@ namespace NzbDrone.Core.Download.Aggregation _logger = logger; } - public RemoteAlbum Augment(RemoteAlbum remoteAlbum) + public RemoteBook Augment(RemoteBook remoteAlbum) { foreach (var augmenter in _augmenters) { diff --git a/src/NzbDrone.Core/Download/AlbumGrabbedEvent.cs b/src/NzbDrone.Core/Download/AlbumGrabbedEvent.cs index 7876edec3..4dca3b527 100644 --- a/src/NzbDrone.Core/Download/AlbumGrabbedEvent.cs +++ b/src/NzbDrone.Core/Download/AlbumGrabbedEvent.cs @@ -3,15 +3,15 @@ using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.Download { - public class AlbumGrabbedEvent : IEvent + public class BookGrabbedEvent : IEvent { - public RemoteAlbum Album { get; private set; } + public RemoteBook Book { get; private set; } public string DownloadClient { get; set; } public string DownloadId { get; set; } - public AlbumGrabbedEvent(RemoteAlbum album) + public BookGrabbedEvent(RemoteBook book) { - Album = album; + Book = book; } } } diff --git a/src/NzbDrone.Core/Download/Clients/Blackhole/ScanWatchFolder.cs b/src/NzbDrone.Core/Download/Clients/Blackhole/ScanWatchFolder.cs index 9dec12b09..df04053fe 100644 --- a/src/NzbDrone.Core/Download/Clients/Blackhole/ScanWatchFolder.cs +++ b/src/NzbDrone.Core/Download/Clients/Blackhole/ScanWatchFolder.cs @@ -86,7 +86,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole yield return newWatchItem; } - foreach (var audioFile in _diskScanService.FilterFiles(watchFolder, _diskScanService.GetAudioFiles(watchFolder, false))) + foreach (var audioFile in _diskScanService.FilterFiles(watchFolder, _diskScanService.GetBookFiles(watchFolder, false))) { var title = FileNameBuilder.CleanFileName(audioFile.Name); diff --git a/src/NzbDrone.Core/Download/Clients/Blackhole/TorrentBlackhole.cs b/src/NzbDrone.Core/Download/Clients/Blackhole/TorrentBlackhole.cs index 5ecbd35ff..0b8740ff7 100644 --- a/src/NzbDrone.Core/Download/Clients/Blackhole/TorrentBlackhole.cs +++ b/src/NzbDrone.Core/Download/Clients/Blackhole/TorrentBlackhole.cs @@ -37,7 +37,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole ScanGracePeriod = TimeSpan.FromSeconds(30); } - protected override string AddFromMagnetLink(RemoteAlbum remoteAlbum, string hash, string magnetLink) + protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash, string magnetLink) { if (!Settings.SaveMagnetFiles) { @@ -61,7 +61,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole return null; } - protected override string AddFromTorrentFile(RemoteAlbum remoteAlbum, string hash, string filename, byte[] fileContent) + protected override string AddFromTorrentFile(RemoteBook remoteAlbum, string hash, string filename, byte[] fileContent) { var title = remoteAlbum.Release.Title; diff --git a/src/NzbDrone.Core/Download/Clients/Blackhole/UsenetBlackhole.cs b/src/NzbDrone.Core/Download/Clients/Blackhole/UsenetBlackhole.cs index 61458cc0b..f0e5b24e0 100644 --- a/src/NzbDrone.Core/Download/Clients/Blackhole/UsenetBlackhole.cs +++ b/src/NzbDrone.Core/Download/Clients/Blackhole/UsenetBlackhole.cs @@ -33,7 +33,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole ScanGracePeriod = TimeSpan.FromSeconds(30); } - protected override string AddFromNzbFile(RemoteAlbum remoteAlbum, string filename, byte[] fileContent) + protected override string AddFromNzbFile(RemoteBook remoteAlbum, string filename, byte[] fileContent) { var title = remoteAlbum.Release.Title; diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs index dd6ff2196..411fa950e 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs @@ -50,7 +50,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge } } - protected override string AddFromMagnetLink(RemoteAlbum remoteAlbum, string hash, string magnetLink) + protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash, string magnetLink) { var actualHash = _proxy.AddTorrentFromMagnet(magnetLink, Settings); @@ -77,7 +77,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge return actualHash.ToUpper(); } - protected override string AddFromTorrentFile(RemoteAlbum remoteAlbum, string hash, string filename, byte[] fileContent) + protected override string AddFromTorrentFile(RemoteBook remoteAlbum, string hash, string filename, byte[] fileContent) { var actualHash = _proxy.AddTorrentFromFile(filename, fileContent, Settings); diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs index 835a82795..b663469cc 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs @@ -154,7 +154,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation return finalPath; } - protected override string AddFromMagnetLink(RemoteAlbum remoteAlbum, string hash, string magnetLink) + protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash, string magnetLink) { var hashedSerialNumber = _serialNumberProvider.GetSerialNumber(Settings); @@ -173,7 +173,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation throw new DownloadClientException("Failed to add magnet task to Download Station"); } - protected override string AddFromTorrentFile(RemoteAlbum remoteAlbum, string hash, string filename, byte[] fileContent) + protected override string AddFromTorrentFile(RemoteBook remoteAlbum, string hash, string filename, byte[] fileContent) { var hashedSerialNumber = _serialNumberProvider.GetSerialNumber(Settings); diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs index 58bb4e4e2..e3c078de6 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs @@ -167,7 +167,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation _logger.Debug("{0} removed correctly", downloadId); } - protected override string AddFromNzbFile(RemoteAlbum remoteAlbum, string filename, byte[] fileContent) + protected override string AddFromNzbFile(RemoteBook remoteAlbum, string filename, byte[] fileContent) { var hashedSerialNumber = _serialNumberProvider.GetSerialNumber(Settings); diff --git a/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs b/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs index b6b09a59c..d2f400c08 100644 --- a/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs +++ b/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs @@ -137,14 +137,14 @@ namespace NzbDrone.Core.Download.Clients.Hadouken failures.AddIfNotNull(TestGetTorrents()); } - protected override string AddFromMagnetLink(RemoteAlbum remoteAlbum, string hash, string magnetLink) + protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash, string magnetLink) { _proxy.AddTorrentUri(Settings, magnetLink); return hash.ToUpper(); } - protected override string AddFromTorrentFile(RemoteAlbum remoteAlbum, string hash, string filename, byte[] fileContent) + protected override string AddFromTorrentFile(RemoteBook remoteAlbum, string hash, string filename, byte[] fileContent) { return _proxy.AddTorrentFile(Settings, fileContent).ToUpper(); } diff --git a/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs b/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs index 8b3ae01be..a4171a1ad 100644 --- a/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs +++ b/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex _proxy = proxy; } - protected override string AddFromNzbFile(RemoteAlbum remoteAlbum, string filename, byte[] fileContent) + protected override string AddFromNzbFile(RemoteBook remoteAlbum, string filename, byte[] fileContent) { var priority = remoteAlbum.IsRecentAlbum() ? Settings.RecentTvPriority : Settings.OlderTvPriority; diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs index f49b74552..997edd341 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs @@ -34,7 +34,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget _proxy = proxy; } - protected override string AddFromNzbFile(RemoteAlbum remoteAlbum, string filename, byte[] fileContent) + protected override string AddFromNzbFile(RemoteBook remoteAlbum, string filename, byte[] fileContent) { var category = Settings.MusicCategory; var priority = remoteAlbum.IsRecentAlbum() ? Settings.RecentTvPriority : Settings.OlderTvPriority; diff --git a/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs b/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs index f8eb62cc1..e722dddc0 100644 --- a/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs +++ b/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs @@ -32,12 +32,12 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic public override DownloadProtocol Protocol => DownloadProtocol.Usenet; - public override string Download(RemoteAlbum remoteAlbum) + public override string Download(RemoteBook remoteAlbum) { var url = remoteAlbum.Release.DownloadUrl; var title = remoteAlbum.Release.Title; - if (remoteAlbum.ParsedAlbumInfo.Discography) + if (remoteAlbum.ParsedBookInfo.Discography) { throw new NotSupportedException("Discography releases are not supported with Pneumatic."); } diff --git a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs index 84706ac76..f500469f9 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs @@ -62,7 +62,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent } } - protected override string AddFromMagnetLink(RemoteAlbum remoteAlbum, string hash, string magnetLink) + protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash, string magnetLink) { if (!Proxy.GetConfig(Settings).DhtEnabled && !magnetLink.Contains("&tr=")) { @@ -89,7 +89,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent return hash; } - protected override string AddFromTorrentFile(RemoteAlbum remoteAlbum, string hash, string filename, byte[] fileContent) + protected override string AddFromTorrentFile(RemoteBook remoteAlbum, string hash, string filename, byte[] fileContent) { Proxy.AddTorrentFromFile(filename, fileContent, Settings); diff --git a/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs b/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs index a832ab0eb..b798e34aa 100644 --- a/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs +++ b/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs @@ -34,7 +34,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd // patch can be a number (releases) or 'x' (git) private static readonly Regex VersionRegex = new Regex(@"(?\d+)\.(?\d+)\.(?\d+|x)", RegexOptions.Compiled); - protected override string AddFromNzbFile(RemoteAlbum remoteAlbum, string filename, byte[] fileContent) + protected override string AddFromNzbFile(RemoteBook remoteAlbum, string filename, byte[] fileContent) { var category = Settings.MusicCategory; var priority = remoteAlbum.IsRecentAlbum() ? Settings.RecentTvPriority : Settings.OlderTvPriority; diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs index 0a27e2819..45f73cb59 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs @@ -179,7 +179,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission }; } - protected override string AddFromMagnetLink(RemoteAlbum remoteAlbum, string hash, string magnetLink) + protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash, string magnetLink) { _proxy.AddTorrentFromUrl(magnetLink, GetDownloadDirectory(), Settings); _proxy.SetTorrentSeedingConfiguration(hash, remoteAlbum.SeedConfiguration, Settings); @@ -195,7 +195,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission return hash; } - protected override string AddFromTorrentFile(RemoteAlbum remoteAlbum, string hash, string filename, byte[] fileContent) + protected override string AddFromTorrentFile(RemoteBook remoteAlbum, string hash, string filename, byte[] fileContent) { _proxy.AddTorrentFromData(fileContent, GetDownloadDirectory(), Settings); _proxy.SetTorrentSeedingConfiguration(hash, remoteAlbum.SeedConfiguration, Settings); diff --git a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs index a1e1c5f95..5da8aee94 100644 --- a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs @@ -57,7 +57,7 @@ namespace NzbDrone.Core.Download.Clients.RTorrent } } - protected override string AddFromMagnetLink(RemoteAlbum remoteAlbum, string hash, string magnetLink) + protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash, string magnetLink) { var priority = (RTorrentPriority)(remoteAlbum.IsRecentAlbum() ? Settings.RecentTvPriority : Settings.OlderTvPriority); @@ -77,7 +77,7 @@ namespace NzbDrone.Core.Download.Clients.RTorrent return hash; } - protected override string AddFromTorrentFile(RemoteAlbum remoteAlbum, string hash, string filename, byte[] fileContent) + protected override string AddFromTorrentFile(RemoteBook remoteAlbum, string hash, string filename, byte[] fileContent) { var priority = (RTorrentPriority)(remoteAlbum.IsRecentAlbum() ? Settings.RecentTvPriority : Settings.OlderTvPriority); diff --git a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs index 8c72ac9c1..41ec5fd71 100644 --- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs @@ -52,7 +52,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent } } - protected override string AddFromMagnetLink(RemoteAlbum remoteAlbum, string hash, string magnetLink) + protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash, string magnetLink) { _proxy.AddTorrentFromUrl(magnetLink, Settings); _proxy.SetTorrentSeedingConfiguration(hash, remoteAlbum.SeedConfiguration, Settings); @@ -75,7 +75,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent return hash; } - protected override string AddFromTorrentFile(RemoteAlbum remoteAlbum, string hash, string filename, byte[] fileContent) + protected override string AddFromTorrentFile(RemoteBook remoteAlbum, string hash, string filename, byte[] fileContent) { _proxy.AddTorrentFromFile(filename, fileContent, Settings); _proxy.SetTorrentSeedingConfiguration(hash, remoteAlbum.SeedConfiguration, Settings); diff --git a/src/NzbDrone.Core/Download/CompletedDownloadService.cs b/src/NzbDrone.Core/Download/CompletedDownloadService.cs index c244ec066..1fe1b361e 100644 --- a/src/NzbDrone.Core/Download/CompletedDownloadService.cs +++ b/src/NzbDrone.Core/Download/CompletedDownloadService.cs @@ -4,13 +4,13 @@ using System.IO; using System.Linq; using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.History; using NzbDrone.Core.MediaFiles; +using NzbDrone.Core.MediaFiles.BookImport; using NzbDrone.Core.MediaFiles.Events; -using NzbDrone.Core.MediaFiles.TrackImport; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; namespace NzbDrone.Core.Download { @@ -24,27 +24,27 @@ namespace NzbDrone.Core.Download { private readonly IEventAggregator _eventAggregator; private readonly IHistoryService _historyService; - private readonly IDownloadedTracksImportService _downloadedTracksImportService; - private readonly IArtistService _artistService; + private readonly IDownloadedBooksImportService _downloadedTracksImportService; + private readonly IAuthorService _authorService; private readonly ITrackedDownloadAlreadyImported _trackedDownloadAlreadyImported; public CompletedDownloadService(IEventAggregator eventAggregator, IHistoryService historyService, - IDownloadedTracksImportService downloadedTracksImportService, - IArtistService artistService, + IDownloadedBooksImportService downloadedTracksImportService, + IAuthorService authorService, ITrackedDownloadAlreadyImported trackedDownloadAlreadyImported) { _eventAggregator = eventAggregator; _historyService = historyService; _downloadedTracksImportService = downloadedTracksImportService; - _artistService = artistService; + _authorService = authorService; _trackedDownloadAlreadyImported = trackedDownloadAlreadyImported; } public void Check(TrackedDownload trackedDownload) { if (trackedDownload.DownloadItem.Status != DownloadItemStatus.Completed || - trackedDownload.RemoteAlbum == null) + trackedDownload.RemoteBook == null) { return; } @@ -78,18 +78,18 @@ namespace NzbDrone.Core.Download return; } - var artist = trackedDownload.RemoteAlbum.Artist; + var author = trackedDownload.RemoteBook.Author; - if (artist == null) + if (author == null) { if (historyItem != null) { - artist = _artistService.GetArtist(historyItem.AuthorId); + author = _authorService.GetAuthor(historyItem.AuthorId); } - if (artist == null) + if (author == null) { - trackedDownload.Warn("Artist name mismatch, automatic import is not possible."); + trackedDownload.Warn("Author name mismatch, automatic import is not possible."); return; } } @@ -102,13 +102,13 @@ namespace NzbDrone.Core.Download trackedDownload.State = TrackedDownloadState.Importing; var outputPath = trackedDownload.DownloadItem.OutputPath.FullPath; - var importResults = _downloadedTracksImportService.ProcessPath(outputPath, ImportMode.Auto, trackedDownload.RemoteAlbum.Artist, trackedDownload.DownloadItem); + var importResults = _downloadedTracksImportService.ProcessPath(outputPath, ImportMode.Auto, trackedDownload.RemoteBook.Author, trackedDownload.DownloadItem); if (importResults.Empty()) { trackedDownload.State = TrackedDownloadState.ImportFailed; trackedDownload.Warn("No files found are eligible for import in {0}", outputPath); - _eventAggregator.PublishEvent(new AlbumImportIncompleteEvent(trackedDownload)); + _eventAggregator.PublishEvent(new BookImportIncompleteEvent(trackedDownload)); return; } @@ -128,7 +128,7 @@ namespace NzbDrone.Core.Download .ToArray(); trackedDownload.Warn(statusMessages); - _eventAggregator.PublishEvent(new AlbumImportIncompleteEvent(trackedDownload)); + _eventAggregator.PublishEvent(new BookImportIncompleteEvent(trackedDownload)); return; } } @@ -136,8 +136,8 @@ namespace NzbDrone.Core.Download public bool VerifyImport(TrackedDownload trackedDownload, List importResults) { var allItemsImported = importResults.Where(c => c.Result == ImportResultType.Imported) - .Select(c => c.ImportDecision.Item.Album) - .Count() >= Math.Max(1, trackedDownload.RemoteAlbum.Albums.Count); + .Select(c => c.ImportDecision.Item.Book) + .Count() >= Math.Max(1, trackedDownload.RemoteBook.Books.Count); if (allItemsImported) { diff --git a/src/NzbDrone.Core/Download/DownloadClientBase.cs b/src/NzbDrone.Core/Download/DownloadClientBase.cs index 9e1ca80c6..6ec983e39 100644 --- a/src/NzbDrone.Core/Download/DownloadClientBase.cs +++ b/src/NzbDrone.Core/Download/DownloadClientBase.cs @@ -60,7 +60,7 @@ namespace NzbDrone.Core.Download get; } - public abstract string Download(RemoteAlbum remoteAlbum); + public abstract string Download(RemoteBook remoteAlbum); public abstract IEnumerable GetItems(); public abstract void RemoveItem(string downloadId, bool deleteData); public abstract DownloadClientInfo GetStatus(); diff --git a/src/NzbDrone.Core/Download/DownloadService.cs b/src/NzbDrone.Core/Download/DownloadService.cs index f1348cf2e..ab8d6de2c 100644 --- a/src/NzbDrone.Core/Download/DownloadService.cs +++ b/src/NzbDrone.Core/Download/DownloadService.cs @@ -15,7 +15,7 @@ namespace NzbDrone.Core.Download { public interface IDownloadService { - void DownloadReport(RemoteAlbum remoteAlbum); + void DownloadReport(RemoteBook remoteAlbum); } public class DownloadService : IDownloadService @@ -45,10 +45,10 @@ namespace NzbDrone.Core.Download _logger = logger; } - public void DownloadReport(RemoteAlbum remoteAlbum) + public void DownloadReport(RemoteBook remoteAlbum) { - Ensure.That(remoteAlbum.Artist, () => remoteAlbum.Artist).IsNotNull(); - Ensure.That(remoteAlbum.Albums, () => remoteAlbum.Albums).HasItems(); + Ensure.That(remoteAlbum.Author, () => remoteAlbum.Author).IsNotNull(); + Ensure.That(remoteAlbum.Books, () => remoteAlbum.Books).HasItems(); var downloadTitle = remoteAlbum.Release.Title; var downloadClient = _downloadClientProvider.GetDownloadClient(remoteAlbum.Release.DownloadProtocol); @@ -95,7 +95,7 @@ namespace NzbDrone.Core.Download throw; } - var albumGrabbedEvent = new AlbumGrabbedEvent(remoteAlbum); + var albumGrabbedEvent = new BookGrabbedEvent(remoteAlbum); albumGrabbedEvent.DownloadClient = downloadClient.Name; if (!string.IsNullOrWhiteSpace(downloadClientId)) diff --git a/src/NzbDrone.Core/Download/IDownloadClient.cs b/src/NzbDrone.Core/Download/IDownloadClient.cs index 99b9c0faa..afee811bc 100644 --- a/src/NzbDrone.Core/Download/IDownloadClient.cs +++ b/src/NzbDrone.Core/Download/IDownloadClient.cs @@ -9,7 +9,7 @@ namespace NzbDrone.Core.Download { DownloadProtocol Protocol { get; } - string Download(RemoteAlbum remoteAlbum); + string Download(RemoteBook remoteAlbum); IEnumerable GetItems(); void RemoveItem(string downloadId, bool deleteData); DownloadClientInfo GetStatus(); diff --git a/src/NzbDrone.Core/Download/IgnoredDownloadService.cs b/src/NzbDrone.Core/Download/IgnoredDownloadService.cs index cd2828bf3..0479c6e19 100644 --- a/src/NzbDrone.Core/Download/IgnoredDownloadService.cs +++ b/src/NzbDrone.Core/Download/IgnoredDownloadService.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Core.Download.TrackedDownloads; @@ -25,20 +25,20 @@ namespace NzbDrone.Core.Download public bool IgnoreDownload(TrackedDownload trackedDownload) { - var artist = trackedDownload.RemoteAlbum.Artist; - var albums = trackedDownload.RemoteAlbum.Albums; + var author = trackedDownload.RemoteBook.Author; + var books = trackedDownload.RemoteBook.Books; - if (artist == null || albums.Empty()) + if (author == null || books.Empty()) { - _logger.Warn("Unable to ignore download for unknown artist/album"); + _logger.Warn("Unable to ignore download for unknown author/book"); return false; } var downloadIgnoredEvent = new DownloadIgnoredEvent { - AuthorId = artist.Id, - BookIds = albums.Select(e => e.Id).ToList(), - Quality = trackedDownload.RemoteAlbum.ParsedAlbumInfo.Quality, + AuthorId = author.Id, + BookIds = books.Select(e => e.Id).ToList(), + Quality = trackedDownload.RemoteBook.ParsedBookInfo.Quality, SourceTitle = trackedDownload.DownloadItem.Title, DownloadClient = trackedDownload.DownloadItem.DownloadClient, DownloadId = trackedDownload.DownloadItem.DownloadId, diff --git a/src/NzbDrone.Core/Download/Pending/PendingRelease.cs b/src/NzbDrone.Core/Download/Pending/PendingRelease.cs index d1062f911..b382d411c 100644 --- a/src/NzbDrone.Core/Download/Pending/PendingRelease.cs +++ b/src/NzbDrone.Core/Download/Pending/PendingRelease.cs @@ -9,11 +9,11 @@ namespace NzbDrone.Core.Download.Pending public int AuthorId { get; set; } public string Title { get; set; } public DateTime Added { get; set; } - public ParsedAlbumInfo ParsedAlbumInfo { get; set; } + public ParsedBookInfo ParsedBookInfo { get; set; } public ReleaseInfo Release { get; set; } public PendingReleaseReason Reason { get; set; } //Not persisted - public RemoteAlbum RemoteAlbum { get; set; } + public RemoteBook RemoteBook { get; set; } } } diff --git a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs index eb7f2370d..60fa59008 100644 --- a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs +++ b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs @@ -4,13 +4,13 @@ using System.Linq; using NLog; using NzbDrone.Common.Crypto; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; +using NzbDrone.Core.Books.Events; using NzbDrone.Core.Configuration; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Indexers; using NzbDrone.Core.Jobs; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; -using NzbDrone.Core.Music.Events; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Delay; @@ -23,21 +23,21 @@ namespace NzbDrone.Core.Download.Pending void Add(DownloadDecision decision, PendingReleaseReason reason); void AddMany(List> decisions); List GetPending(); - List GetPendingRemoteAlbums(int authorId); + List GetPendingRemoteBooks(int authorId); List GetPendingQueue(); Queue.Queue FindPendingQueueItem(int queueId); void RemovePendingQueueItems(int queueId); - RemoteAlbum OldestPendingRelease(int authorId, int[] bookIds); + RemoteBook OldestPendingRelease(int authorId, int[] bookIds); } public class PendingReleaseService : IPendingReleaseService, - IHandle, - IHandle, + IHandle, + IHandle, IHandle { private readonly IIndexerStatusService _indexerStatusService; private readonly IPendingReleaseRepository _repository; - private readonly IArtistService _artistService; + private readonly IAuthorService _authorService; private readonly IParsingService _parsingService; private readonly IDelayProfileService _delayProfileService; private readonly ITaskManager _taskManager; @@ -47,7 +47,7 @@ namespace NzbDrone.Core.Download.Pending public PendingReleaseService(IIndexerStatusService indexerStatusService, IPendingReleaseRepository repository, - IArtistService artistService, + IAuthorService authorService, IParsingService parsingService, IDelayProfileService delayProfileService, ITaskManager taskManager, @@ -57,7 +57,7 @@ namespace NzbDrone.Core.Download.Pending { _indexerStatusService = indexerStatusService; _repository = repository; - _artistService = artistService; + _authorService = authorService; _parsingService = parsingService; _delayProfileService = delayProfileService; _taskManager = taskManager; @@ -73,25 +73,25 @@ namespace NzbDrone.Core.Download.Pending public void AddMany(List> decisions) { - foreach (var artistDecisions in decisions.GroupBy(v => v.Item1.RemoteAlbum.Artist.Id)) + foreach (var authorDecisions in decisions.GroupBy(v => v.Item1.RemoteBook.Author.Id)) { - var artist = artistDecisions.First().Item1.RemoteAlbum.Artist; - var alreadyPending = _repository.AllByAuthorId(artist.Id); + var author = authorDecisions.First().Item1.RemoteBook.Author; + var alreadyPending = _repository.AllByAuthorId(author.Id); - alreadyPending = IncludeRemoteAlbums(alreadyPending, artistDecisions.ToDictionaryIgnoreDuplicates(v => v.Item1.RemoteAlbum.Release.Title, v => v.Item1.RemoteAlbum)); - var alreadyPendingByAlbum = CreateAlbumLookup(alreadyPending); + alreadyPending = IncludeRemoteBooks(alreadyPending, authorDecisions.ToDictionaryIgnoreDuplicates(v => v.Item1.RemoteBook.Release.Title, v => v.Item1.RemoteBook)); + var alreadyPendingByAlbum = CreateBookLookup(alreadyPending); - foreach (var pair in artistDecisions) + foreach (var pair in authorDecisions) { var decision = pair.Item1; var reason = pair.Item2; - var bookIds = decision.RemoteAlbum.Albums.Select(e => e.Id); + var bookIds = decision.RemoteBook.Books.Select(e => e.Id); var existingReports = bookIds.SelectMany(v => alreadyPendingByAlbum[v] ?? Enumerable.Empty()) .Distinct().ToList(); - var matchingReports = existingReports.Where(MatchingReleasePredicate(decision.RemoteAlbum.Release)).ToList(); + var matchingReports = existingReports.Where(MatchingReleasePredicate(decision.RemoteBook.Release)).ToList(); if (matchingReports.Any()) { @@ -99,39 +99,39 @@ namespace NzbDrone.Core.Download.Pending if (matchingReport.Reason != reason) { - _logger.Debug("The release {0} is already pending with reason {1}, changing to {2}", decision.RemoteAlbum, matchingReport.Reason, reason); + _logger.Debug("The release {0} is already pending with reason {1}, changing to {2}", decision.RemoteBook, matchingReport.Reason, reason); matchingReport.Reason = reason; _repository.Update(matchingReport); } else { - _logger.Debug("The release {0} is already pending with reason {1}, not adding again", decision.RemoteAlbum, reason); + _logger.Debug("The release {0} is already pending with reason {1}, not adding again", decision.RemoteBook, reason); } if (matchingReports.Count() > 1) { - _logger.Debug("The release {0} had {1} duplicate pending, removing duplicates.", decision.RemoteAlbum, matchingReports.Count() - 1); + _logger.Debug("The release {0} had {1} duplicate pending, removing duplicates.", decision.RemoteBook, matchingReports.Count() - 1); foreach (var duplicate in matchingReports.Skip(1)) { _repository.Delete(duplicate.Id); alreadyPending.Remove(duplicate); - alreadyPendingByAlbum = CreateAlbumLookup(alreadyPending); + alreadyPendingByAlbum = CreateBookLookup(alreadyPending); } } continue; } - _logger.Debug("Adding release {0} to pending releases with reason {1}", decision.RemoteAlbum, reason); + _logger.Debug("Adding release {0} to pending releases with reason {1}", decision.RemoteBook, reason); Insert(decision, reason); } } } - private ILookup CreateAlbumLookup(IEnumerable alreadyPending) + private ILookup CreateBookLookup(IEnumerable alreadyPending) { - return alreadyPending.SelectMany(v => v.RemoteAlbum.Albums + return alreadyPending.SelectMany(v => v.RemoteBook.Books .Select(d => new { Album = d, PendingRelease = v })) .ToLookup(v => v.Album.Id, v => v.PendingRelease); } @@ -155,9 +155,9 @@ namespace NzbDrone.Core.Download.Pending return releases.Where(release => !blockedIndexers.Contains(release.IndexerId)).ToList(); } - public List GetPendingRemoteAlbums(int authorId) + public List GetPendingRemoteBooks(int authorId) { - return IncludeRemoteAlbums(_repository.AllByAuthorId(authorId)).Select(v => v.RemoteAlbum).ToList(); + return IncludeRemoteBooks(_repository.AllByAuthorId(authorId)).Select(v => v.RemoteBook).ToList(); } public List GetPendingQueue() @@ -166,12 +166,12 @@ namespace NzbDrone.Core.Download.Pending var nextRssSync = new Lazy(() => _taskManager.GetNextExecution(typeof(RssSyncCommand))); - var pendingReleases = IncludeRemoteAlbums(_repository.WithoutFallback()); + var pendingReleases = IncludeRemoteBooks(_repository.WithoutFallback()); foreach (var pendingRelease in pendingReleases) { - foreach (var album in pendingRelease.RemoteAlbum.Albums) + foreach (var book in pendingRelease.RemoteBook.Books) { - var ect = pendingRelease.Release.PublishDate.AddMinutes(GetDelay(pendingRelease.RemoteAlbum)); + var ect = pendingRelease.Release.PublishDate.AddMinutes(GetDelay(pendingRelease.RemoteBook)); if (ect < nextRssSync.Value) { @@ -191,32 +191,32 @@ namespace NzbDrone.Core.Download.Pending var queue = new Queue.Queue { - Id = GetQueueId(pendingRelease, album), - Artist = pendingRelease.RemoteAlbum.Artist, - Album = album, - Quality = pendingRelease.RemoteAlbum.ParsedAlbumInfo.Quality, + Id = GetQueueId(pendingRelease, book), + Author = pendingRelease.RemoteBook.Author, + Book = book, + Quality = pendingRelease.RemoteBook.ParsedBookInfo.Quality, Title = pendingRelease.Title, - Size = pendingRelease.RemoteAlbum.Release.Size, - Sizeleft = pendingRelease.RemoteAlbum.Release.Size, - RemoteAlbum = pendingRelease.RemoteAlbum, + Size = pendingRelease.RemoteBook.Release.Size, + Sizeleft = pendingRelease.RemoteBook.Release.Size, + RemoteBook = pendingRelease.RemoteBook, Timeleft = timeleft, EstimatedCompletionTime = ect, Status = pendingRelease.Reason.ToString(), - Protocol = pendingRelease.RemoteAlbum.Release.DownloadProtocol, - Indexer = pendingRelease.RemoteAlbum.Release.Indexer + Protocol = pendingRelease.RemoteBook.Release.DownloadProtocol, + Indexer = pendingRelease.RemoteBook.Release.Indexer }; queued.Add(queue); } } - //Return best quality release for each album - var deduped = queued.GroupBy(q => q.Album.Id).Select(g => + //Return best quality release for each book + var deduped = queued.GroupBy(q => q.Book.Id).Select(g => { - var artist = g.First().Artist; + var author = g.First().Author; - return g.OrderByDescending(e => e.Quality, new QualityModelComparer(artist.QualityProfile)) - .ThenBy(q => PrioritizeDownloadProtocol(q.Artist, q.Protocol)) + return g.OrderByDescending(e => e.Quality, new QualityModelComparer(author.QualityProfile)) + .ThenBy(q => PrioritizeDownloadProtocol(q.Author, q.Protocol)) .First(); }); @@ -231,83 +231,83 @@ namespace NzbDrone.Core.Download.Pending public void RemovePendingQueueItems(int queueId) { var targetItem = FindPendingRelease(queueId); - var artistReleases = _repository.AllByAuthorId(targetItem.AuthorId); + var authorReleases = _repository.AllByAuthorId(targetItem.AuthorId); - var releasesToRemove = artistReleases.Where( - c => c.ParsedAlbumInfo.AlbumTitle == targetItem.ParsedAlbumInfo.AlbumTitle); + var releasesToRemove = authorReleases.Where( + c => c.ParsedBookInfo.BookTitle == targetItem.ParsedBookInfo.BookTitle); _repository.DeleteMany(releasesToRemove.Select(c => c.Id)); } - public RemoteAlbum OldestPendingRelease(int authorId, int[] bookIds) + public RemoteBook OldestPendingRelease(int authorId, int[] bookIds) { - var artistReleases = GetPendingReleases(authorId); + var authorReleases = GetPendingReleases(authorId); - return artistReleases.Select(r => r.RemoteAlbum) - .Where(r => r.Albums.Select(e => e.Id).Intersect(bookIds).Any()) + return authorReleases.Select(r => r.RemoteBook) + .Where(r => r.Books.Select(e => e.Id).Intersect(bookIds).Any()) .OrderByDescending(p => p.Release.AgeHours) .FirstOrDefault(); } private List GetPendingReleases() { - return IncludeRemoteAlbums(_repository.All().ToList()); + return IncludeRemoteBooks(_repository.All().ToList()); } private List GetPendingReleases(int authorId) { - return IncludeRemoteAlbums(_repository.AllByAuthorId(authorId).ToList()); + return IncludeRemoteBooks(_repository.AllByAuthorId(authorId).ToList()); } - private List IncludeRemoteAlbums(List releases, Dictionary knownRemoteAlbums = null) + private List IncludeRemoteBooks(List releases, Dictionary knownRemoteBooks = null) { var result = new List(); - var artistMap = new Dictionary(); + var authorMap = new Dictionary(); - if (knownRemoteAlbums != null) + if (knownRemoteBooks != null) { - foreach (var artist in knownRemoteAlbums.Values.Select(v => v.Artist)) + foreach (var author in knownRemoteBooks.Values.Select(v => v.Author)) { - if (!artistMap.ContainsKey(artist.Id)) + if (!authorMap.ContainsKey(author.Id)) { - artistMap[artist.Id] = artist; + authorMap[author.Id] = author; } } } - foreach (var artist in _artistService.GetArtists(releases.Select(v => v.AuthorId).Distinct().Where(v => !artistMap.ContainsKey(v)))) + foreach (var author in _authorService.GetAuthors(releases.Select(v => v.AuthorId).Distinct().Where(v => !authorMap.ContainsKey(v)))) { - artistMap[artist.Id] = artist; + authorMap[author.Id] = author; } foreach (var release in releases) { - var artist = artistMap.GetValueOrDefault(release.AuthorId); + var author = authorMap.GetValueOrDefault(release.AuthorId); - // Just in case the artist was removed, but wasn't cleaned up yet (housekeeper will clean it up) - if (artist == null) + // Just in case the author was removed, but wasn't cleaned up yet (housekeeper will clean it up) + if (author == null) { return null; } - List albums; + List books; - RemoteAlbum knownRemoteAlbum; - if (knownRemoteAlbums != null && knownRemoteAlbums.TryGetValue(release.Release.Title, out knownRemoteAlbum)) + RemoteBook knownRemoteBook; + if (knownRemoteBooks != null && knownRemoteBooks.TryGetValue(release.Release.Title, out knownRemoteBook)) { - albums = knownRemoteAlbum.Albums; + books = knownRemoteBook.Books; } else { - albums = _parsingService.GetAlbums(release.ParsedAlbumInfo, artist); + books = _parsingService.GetAlbums(release.ParsedBookInfo, author); } - release.RemoteAlbum = new RemoteAlbum + release.RemoteBook = new RemoteBook { - Artist = artist, - Albums = albums, - ParsedAlbumInfo = release.ParsedAlbumInfo, + Author = author, + Books = books, + ParsedBookInfo = release.ParsedBookInfo, Release = release.Release }; @@ -321,10 +321,10 @@ namespace NzbDrone.Core.Download.Pending { _repository.Insert(new PendingRelease { - AuthorId = decision.RemoteAlbum.Artist.Id, - ParsedAlbumInfo = decision.RemoteAlbum.ParsedAlbumInfo, - Release = decision.RemoteAlbum.Release, - Title = decision.RemoteAlbum.Release.Title, + AuthorId = decision.RemoteBook.Author.Id, + ParsedBookInfo = decision.RemoteBook.ParsedBookInfo, + Release = decision.RemoteBook.Release, + Title = decision.RemoteBook.Release.Title, Added = DateTime.UtcNow, Reason = reason }); @@ -345,21 +345,21 @@ namespace NzbDrone.Core.Download.Pending p.Release.Indexer == release.Indexer; } - private int GetDelay(RemoteAlbum remoteAlbum) + private int GetDelay(RemoteBook remoteAlbum) { - var delayProfile = _delayProfileService.AllForTags(remoteAlbum.Artist.Tags).OrderBy(d => d.Order).First(); + var delayProfile = _delayProfileService.AllForTags(remoteAlbum.Author.Tags).OrderBy(d => d.Order).First(); var delay = delayProfile.GetProtocolDelay(remoteAlbum.Release.DownloadProtocol); var minimumAge = _configService.MinimumAge; return new[] { delay, minimumAge }.Max(); } - private void RemoveGrabbed(RemoteAlbum remoteAlbum) + private void RemoveGrabbed(RemoteBook remoteBook) { - var pendingReleases = GetPendingReleases(remoteAlbum.Artist.Id); - var bookIds = remoteAlbum.Albums.Select(e => e.Id); + var pendingReleases = GetPendingReleases(remoteBook.Author.Id); + var bookIds = remoteBook.Books.Select(e => e.Id); - var existingReports = pendingReleases.Where(r => r.RemoteAlbum.Albums.Select(e => e.Id) + var existingReports = pendingReleases.Where(r => r.RemoteBook.Books.Select(e => e.Id) .Intersect(bookIds) .Any()) .ToList(); @@ -369,12 +369,12 @@ namespace NzbDrone.Core.Download.Pending return; } - var profile = remoteAlbum.Artist.QualityProfile.Value; + var profile = remoteBook.Author.QualityProfile.Value; foreach (var existingReport in existingReports) { - var compare = new QualityModelComparer(profile).Compare(remoteAlbum.ParsedAlbumInfo.Quality, - existingReport.RemoteAlbum.ParsedAlbumInfo.Quality); + var compare = new QualityModelComparer(profile).Compare(remoteBook.ParsedBookInfo.Quality, + existingReport.RemoteBook.ParsedBookInfo.Quality); //Only remove lower/equal quality pending releases //It is safer to retry these releases on the next round than remove it and try to re-add it (if its still in the feed) @@ -393,7 +393,7 @@ namespace NzbDrone.Core.Download.Pending foreach (var rejectedRelease in rejected) { - var matching = pending.Where(MatchingReleasePredicate(rejectedRelease.RemoteAlbum.Release)); + var matching = pending.Where(MatchingReleasePredicate(rejectedRelease.RemoteBook.Release)); foreach (var pendingRelease in matching) { @@ -405,17 +405,17 @@ namespace NzbDrone.Core.Download.Pending private PendingRelease FindPendingRelease(int queueId) { - return GetPendingReleases().First(p => p.RemoteAlbum.Albums.Any(e => queueId == GetQueueId(p, e))); + return GetPendingReleases().First(p => p.RemoteBook.Books.Any(e => queueId == GetQueueId(p, e))); } - private int GetQueueId(PendingRelease pendingRelease, Book album) + private int GetQueueId(PendingRelease pendingRelease, Book book) { - return HashConverter.GetHashInt31(string.Format("pending-{0}-album{1}", pendingRelease.Id, album.Id)); + return HashConverter.GetHashInt31(string.Format("pending-{0}-book{1}", pendingRelease.Id, book.Id)); } - private int PrioritizeDownloadProtocol(Author artist, DownloadProtocol downloadProtocol) + private int PrioritizeDownloadProtocol(Author author, DownloadProtocol downloadProtocol) { - var delayProfile = _delayProfileService.BestForTags(artist.Tags); + var delayProfile = _delayProfileService.BestForTags(author.Tags); if (downloadProtocol == delayProfile.PreferredProtocol) { @@ -425,14 +425,14 @@ namespace NzbDrone.Core.Download.Pending return 1; } - public void Handle(ArtistDeletedEvent message) + public void Handle(AuthorDeletedEvent message) { - _repository.DeleteByAuthorId(message.Artist.Id); + _repository.DeleteByAuthorId(message.Author.Id); } - public void Handle(AlbumGrabbedEvent message) + public void Handle(BookGrabbedEvent message) { - RemoveGrabbed(message.Album); + RemoveGrabbed(message.Book); } public void Handle(RssSyncCompleteEvent message) diff --git a/src/NzbDrone.Core/Download/ProcessDownloadDecisions.cs b/src/NzbDrone.Core/Download/ProcessDownloadDecisions.cs index e64f6ffeb..b1322fe66 100644 --- a/src/NzbDrone.Core/Download/ProcessDownloadDecisions.cs +++ b/src/NzbDrone.Core/Download/ProcessDownloadDecisions.cs @@ -50,8 +50,8 @@ namespace NzbDrone.Core.Download foreach (var report in prioritizedDecisions) { - var remoteAlbum = report.RemoteAlbum; - var downloadProtocol = report.RemoteAlbum.Release.DownloadProtocol; + var remoteAlbum = report.RemoteBook; + var downloadProtocol = report.RemoteBook.Release.DownloadProtocol; //Skip if already grabbed if (IsAlbumProcessed(grabbed, report)) @@ -116,14 +116,14 @@ namespace NzbDrone.Core.Download internal List GetQualifiedReports(IEnumerable decisions) { //Process both approved and temporarily rejected - return decisions.Where(c => (c.Approved || c.TemporarilyRejected) && c.RemoteAlbum.Albums.Any()).ToList(); + return decisions.Where(c => (c.Approved || c.TemporarilyRejected) && c.RemoteBook.Books.Any()).ToList(); } private bool IsAlbumProcessed(List decisions, DownloadDecision report) { - var bookIds = report.RemoteAlbum.Albums.Select(e => e.Id).ToList(); + var bookIds = report.RemoteBook.Books.Select(e => e.Id).ToList(); - return decisions.SelectMany(r => r.RemoteAlbum.Albums) + return decisions.SelectMany(r => r.RemoteBook.Books) .Select(e => e.Id) .ToList() .Intersect(bookIds) diff --git a/src/NzbDrone.Core/Download/RedownloadFailedDownloadService.cs b/src/NzbDrone.Core/Download/RedownloadFailedDownloadService.cs index 017601a3f..1e8dbdf14 100644 --- a/src/NzbDrone.Core/Download/RedownloadFailedDownloadService.cs +++ b/src/NzbDrone.Core/Download/RedownloadFailedDownloadService.cs @@ -1,27 +1,27 @@ using NLog; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Messaging; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; namespace NzbDrone.Core.Download { public class RedownloadFailedDownloadService : IHandle { private readonly IConfigService _configService; - private readonly IAlbumService _albumService; + private readonly IBookService _bookService; private readonly IManageCommandQueue _commandQueueManager; private readonly Logger _logger; public RedownloadFailedDownloadService(IConfigService configService, - IAlbumService albumService, + IBookService bookService, IManageCommandQueue commandQueueManager, Logger logger) { _configService = configService; - _albumService = albumService; + _bookService = bookService; _commandQueueManager = commandQueueManager; _logger = logger; } @@ -37,26 +37,26 @@ namespace NzbDrone.Core.Download if (!_configService.AutoRedownloadFailed) { - _logger.Debug("Auto redownloading failed albums is disabled"); + _logger.Debug("Auto redownloading failed books is disabled"); return; } if (message.BookIds.Count == 1) { - _logger.Debug("Failed download only contains one album, searching again"); + _logger.Debug("Failed download only contains one book, searching again"); - _commandQueueManager.Push(new AlbumSearchCommand(message.BookIds)); + _commandQueueManager.Push(new BookSearchCommand(message.BookIds)); return; } - var albumsInArtist = _albumService.GetAlbumsByArtist(message.AuthorId); + var albumsInArtist = _bookService.GetBooksByAuthor(message.AuthorId); if (message.BookIds.Count == albumsInArtist.Count) { - _logger.Debug("Failed download was entire artist, searching again"); + _logger.Debug("Failed download was entire author, searching again"); - _commandQueueManager.Push(new ArtistSearchCommand + _commandQueueManager.Push(new AuthorSearchCommand { AuthorId = message.AuthorId }); @@ -64,9 +64,9 @@ namespace NzbDrone.Core.Download return; } - _logger.Debug("Failed download contains multiple albums, searching again"); + _logger.Debug("Failed download contains multiple books, searching again"); - _commandQueueManager.Push(new AlbumSearchCommand(message.BookIds)); + _commandQueueManager.Push(new BookSearchCommand(message.BookIds)); } } } diff --git a/src/NzbDrone.Core/Download/TorrentClientBase.cs b/src/NzbDrone.Core/Download/TorrentClientBase.cs index cb8aa1430..9f9d5c5d1 100644 --- a/src/NzbDrone.Core/Download/TorrentClientBase.cs +++ b/src/NzbDrone.Core/Download/TorrentClientBase.cs @@ -38,10 +38,10 @@ namespace NzbDrone.Core.Download public virtual bool PreferTorrentFile => false; - protected abstract string AddFromMagnetLink(RemoteAlbum remoteAlbum, string hash, string magnetLink); - protected abstract string AddFromTorrentFile(RemoteAlbum remoteAlbum, string hash, string filename, byte[] fileContent); + protected abstract string AddFromMagnetLink(RemoteBook remoteAlbum, string hash, string magnetLink); + protected abstract string AddFromTorrentFile(RemoteBook remoteAlbum, string hash, string filename, byte[] fileContent); - public override string Download(RemoteAlbum remoteAlbum) + public override string Download(RemoteBook remoteAlbum) { var torrentInfo = remoteAlbum.Release as TorrentInfo; @@ -121,7 +121,7 @@ namespace NzbDrone.Core.Download return null; } - private string DownloadFromWebUrl(RemoteAlbum remoteAlbum, string torrentUrl) + private string DownloadFromWebUrl(RemoteBook remoteAlbum, string torrentUrl) { byte[] torrentFile = null; @@ -162,7 +162,7 @@ namespace NzbDrone.Core.Download { if (ex.Response.StatusCode == HttpStatusCode.NotFound) { - _logger.Error(ex, "Downloading torrent file for album '{0}' failed since it no longer exists ({1})", remoteAlbum.Release.Title, torrentUrl); + _logger.Error(ex, "Downloading torrent file for book '{0}' failed since it no longer exists ({1})", remoteAlbum.Release.Title, torrentUrl); throw new ReleaseUnavailableException(remoteAlbum.Release, "Downloading torrent failed", ex); } @@ -199,7 +199,7 @@ namespace NzbDrone.Core.Download return actualHash; } - private string DownloadFromMagnetUrl(RemoteAlbum remoteAlbum, string magnetUrl) + private string DownloadFromMagnetUrl(RemoteBook remoteAlbum, string magnetUrl) { string hash = null; string actualHash = null; diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs b/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs index 2fb243335..b0c577d1b 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs @@ -12,7 +12,7 @@ using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Download.TrackedDownloads { public class DownloadMonitoringService : IExecute, - IHandle, + IHandle, IHandle, IHandle, IHandle @@ -159,7 +159,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads Refresh(); } - public void Handle(AlbumGrabbedEvent message) + public void Handle(BookGrabbedEvent message) { _refreshDebounce.Execute(); } diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs index 46c46d529..50670d5cd 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs @@ -9,7 +9,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads public DownloadClientItem DownloadItem { get; set; } public TrackedDownloadState State { get; set; } public TrackedDownloadStatus Status { get; private set; } - public RemoteAlbum RemoteAlbum { get; set; } + public RemoteBook RemoteBook { get; set; } public TrackedDownloadStatusMessage[] StatusMessages { get; private set; } public DownloadProtocol Protocol { get; set; } public string Indexer { get; set; } diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadAlreadyImported.cs b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadAlreadyImported.cs index 22217d8c1..0bdc7a3d1 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadAlreadyImported.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadAlreadyImported.cs @@ -19,14 +19,14 @@ namespace NzbDrone.Core.Download.TrackedDownloads return false; } - if (trackedDownload.RemoteAlbum == null || trackedDownload.RemoteAlbum.Albums == null) + if (trackedDownload.RemoteBook == null || trackedDownload.RemoteBook.Books == null) { return true; } - var allAlbumsImportedInHistory = trackedDownload.RemoteAlbum.Albums.All(album => + var allAlbumsImportedInHistory = trackedDownload.RemoteBook.Books.All(book => { - var lastHistoryItem = historyItems.FirstOrDefault(h => h.BookId == album.Id); + var lastHistoryItem = historyItems.FirstOrDefault(h => h.BookId == book.Id); if (lastHistoryItem == null) { diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs index bff07fd21..9bf8883f9 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs @@ -5,15 +5,15 @@ using NLog; using NzbDrone.Common.Cache; using NzbDrone.Common.Extensions; using NzbDrone.Common.Serializer; +using NzbDrone.Core.Books; +using NzbDrone.Core.Books.Events; using NzbDrone.Core.History; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; -using NzbDrone.Core.Music.Events; using NzbDrone.Core.Parser; namespace NzbDrone.Core.Download.TrackedDownloads { - public interface ITrackedDownloadService : IHandle + public interface ITrackedDownloadService : IHandle { TrackedDownload Find(string downloadId); void StopTracking(string downloadId); @@ -54,16 +54,16 @@ namespace NzbDrone.Core.Download.TrackedDownloads public void UpdateAlbumCache(int bookId) { - var updateCacheItems = _cache.Values.Where(x => x.RemoteAlbum != null && x.RemoteAlbum.Albums.Any(a => a.Id == bookId)).ToList(); + var updateCacheItems = _cache.Values.Where(x => x.RemoteBook != null && x.RemoteBook.Books.Any(a => a.Id == bookId)).ToList(); foreach (var item in updateCacheItems) { - var parsedAlbumInfo = Parser.Parser.ParseAlbumTitle(item.DownloadItem.Title); - item.RemoteAlbum = null; + var parsedAlbumInfo = Parser.Parser.ParseBookTitle(item.DownloadItem.Title); + item.RemoteBook = null; if (parsedAlbumInfo != null) { - item.RemoteAlbum = _parsingService.Map(parsedAlbumInfo); + item.RemoteBook = _parsingService.Map(parsedAlbumInfo); } } @@ -116,14 +116,14 @@ namespace NzbDrone.Core.Download.TrackedDownloads try { - var parsedAlbumInfo = Parser.Parser.ParseAlbumTitle(trackedDownload.DownloadItem.Title); + var parsedBookInfo = Parser.Parser.ParseBookTitle(trackedDownload.DownloadItem.Title); var historyItems = _historyService.FindByDownloadId(downloadItem.DownloadId) .OrderByDescending(h => h.Date) .ToList(); - if (parsedAlbumInfo != null) + if (parsedBookInfo != null) { - trackedDownload.RemoteAlbum = _parsingService.Map(parsedAlbumInfo); + trackedDownload.RemoteBook = _parsingService.Map(parsedBookInfo); } if (historyItems.Any()) @@ -144,7 +144,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads trackedDownload.State = state; } - if (firstHistoryItem.EventType == HistoryEventType.AlbumImportIncomplete) + if (firstHistoryItem.EventType == HistoryEventType.BookImportIncomplete) { var messages = Json.Deserialize>(firstHistoryItem?.Data["statusMessages"]).ToArray(); trackedDownload.Warn(messages); @@ -153,35 +153,35 @@ namespace NzbDrone.Core.Download.TrackedDownloads var grabbedEvent = historyItems.FirstOrDefault(v => v.EventType == HistoryEventType.Grabbed); trackedDownload.Indexer = grabbedEvent?.Data["indexer"]; - if (parsedAlbumInfo == null || - trackedDownload.RemoteAlbum == null || - trackedDownload.RemoteAlbum.Artist == null || - trackedDownload.RemoteAlbum.Albums.Empty()) + if (parsedBookInfo == null || + trackedDownload.RemoteBook == null || + trackedDownload.RemoteBook.Author == null || + trackedDownload.RemoteBook.Books.Empty()) { // Try parsing the original source title and if that fails, try parsing it as a special // TODO: Pass the TVDB ID and TVRage IDs in as well so we have a better chance for finding the item - var historyArtist = firstHistoryItem.Artist; - var historyAlbums = new List { firstHistoryItem.Album }; + var historyAuthor = firstHistoryItem.Author; + var historyBooks = new List { firstHistoryItem.Book }; - parsedAlbumInfo = Parser.Parser.ParseAlbumTitle(firstHistoryItem.SourceTitle); + parsedBookInfo = Parser.Parser.ParseBookTitle(firstHistoryItem.SourceTitle); - if (parsedAlbumInfo != null) + if (parsedBookInfo != null) { - trackedDownload.RemoteAlbum = _parsingService.Map(parsedAlbumInfo, + trackedDownload.RemoteBook = _parsingService.Map(parsedBookInfo, firstHistoryItem.AuthorId, historyItems.Where(v => v.EventType == HistoryEventType.Grabbed).Select(h => h.BookId) .Distinct()); } else { - parsedAlbumInfo = + parsedBookInfo = Parser.Parser.ParseAlbumTitleWithSearchCriteria(firstHistoryItem.SourceTitle, - historyArtist, - historyAlbums); + historyAuthor, + historyBooks); - if (parsedAlbumInfo != null) + if (parsedBookInfo != null) { - trackedDownload.RemoteAlbum = _parsingService.Map(parsedAlbumInfo, + trackedDownload.RemoteBook = _parsingService.Map(parsedBookInfo, firstHistoryItem.AuthorId, historyItems.Where(v => v.EventType == HistoryEventType.Grabbed).Select(h => h.BookId) .Distinct()); @@ -190,16 +190,16 @@ namespace NzbDrone.Core.Download.TrackedDownloads } } - // Track it so it can be displayed in the queue even though we can't determine which artist it is for - if (trackedDownload.RemoteAlbum == null) + // Track it so it can be displayed in the queue even though we can't determine which author it is for + if (trackedDownload.RemoteBook == null) { - _logger.Trace("No Album found for download '{0}'", trackedDownload.DownloadItem.Title); - trackedDownload.Warn("No Album found for download '{0}'", trackedDownload.DownloadItem.Title); + _logger.Trace("No Book found for download '{0}'", trackedDownload.DownloadItem.Title); + trackedDownload.Warn("No Book found for download '{0}'", trackedDownload.DownloadItem.Title); } } catch (Exception e) { - _logger.Debug(e, "Failed to find album for " + downloadItem.Title); + _logger.Debug(e, "Failed to find book for " + downloadItem.Title); return null; } @@ -231,13 +231,13 @@ namespace NzbDrone.Core.Download.TrackedDownloads existingItem.CanBeRemoved != downloadItem.CanBeRemoved || existingItem.CanMoveFiles != downloadItem.CanMoveFiles) { - _logger.Debug("Tracking '{0}:{1}': ClientState={2}{3} ReadarrStage={4} Album='{5}' OutputPath={6}.", + _logger.Debug("Tracking '{0}:{1}': ClientState={2}{3} ReadarrStage={4} Book='{5}' OutputPath={6}.", downloadItem.DownloadClient, downloadItem.Title, downloadItem.Status, downloadItem.CanBeRemoved ? "" : downloadItem.CanMoveFiles ? " (busy)" : " (readonly)", trackedDownload.State, - trackedDownload.RemoteAlbum?.ParsedAlbumInfo, + trackedDownload.RemoteBook?.ParsedBookInfo, downloadItem.OutputPath); } } @@ -246,7 +246,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads { switch (history.EventType) { - case HistoryEventType.AlbumImportIncomplete: + case HistoryEventType.BookImportIncomplete: return TrackedDownloadState.ImportFailed; case HistoryEventType.DownloadImported: return TrackedDownloadState.Imported; @@ -265,9 +265,9 @@ namespace NzbDrone.Core.Download.TrackedDownloads return TrackedDownloadState.Downloading; } - public void Handle(AlbumDeletedEvent message) + public void Handle(BookDeletedEvent message) { - UpdateAlbumCache(message.Album.Id); + UpdateAlbumCache(message.Book.Id); } } } diff --git a/src/NzbDrone.Core/Download/UsenetClientBase.cs b/src/NzbDrone.Core/Download/UsenetClientBase.cs index 381f837b5..75a32a3af 100644 --- a/src/NzbDrone.Core/Download/UsenetClientBase.cs +++ b/src/NzbDrone.Core/Download/UsenetClientBase.cs @@ -33,9 +33,9 @@ namespace NzbDrone.Core.Download public override DownloadProtocol Protocol => DownloadProtocol.Usenet; - protected abstract string AddFromNzbFile(RemoteAlbum remoteAlbum, string filename, byte[] fileContent); + protected abstract string AddFromNzbFile(RemoteBook remoteAlbum, string filename, byte[] fileContent); - public override string Download(RemoteAlbum remoteAlbum) + public override string Download(RemoteBook remoteAlbum) { var url = remoteAlbum.Release.DownloadUrl; var filename = FileNameBuilder.CleanFileName(remoteAlbum.Release.Title) + ".nzb"; @@ -60,7 +60,7 @@ namespace NzbDrone.Core.Download { if (ex.Response.StatusCode == HttpStatusCode.NotFound) { - _logger.Error(ex, "Downloading nzb file for album '{0}' failed since it no longer exists ({1})", remoteAlbum.Release.Title, url); + _logger.Error(ex, "Downloading nzb file for book '{0}' failed since it no longer exists ({1})", remoteAlbum.Release.Title, url); throw new ReleaseUnavailableException(remoteAlbum.Release, "Downloading torrent failed", ex); } diff --git a/src/NzbDrone.Core/Exceptions/AlbumNotFoundException.cs b/src/NzbDrone.Core/Exceptions/AlbumNotFoundException.cs deleted file mode 100644 index a580acded..000000000 --- a/src/NzbDrone.Core/Exceptions/AlbumNotFoundException.cs +++ /dev/null @@ -1,27 +0,0 @@ -using NzbDrone.Common.Exceptions; - -namespace NzbDrone.Core.Exceptions -{ - public class AlbumNotFoundException : NzbDroneException - { - public string MusicBrainzId { get; set; } - - public AlbumNotFoundException(string musicbrainzId) - : base(string.Format("Album with id {0} was not found, it may have been removed from metadata server.", musicbrainzId)) - { - MusicBrainzId = musicbrainzId; - } - - public AlbumNotFoundException(string musicbrainzId, string message, params object[] args) - : base(message, args) - { - MusicBrainzId = musicbrainzId; - } - - public AlbumNotFoundException(string musicbrainzId, string message) - : base(message) - { - MusicBrainzId = musicbrainzId; - } - } -} diff --git a/src/NzbDrone.Core/Exceptions/ArtistNotFoundException.cs b/src/NzbDrone.Core/Exceptions/AuthorNotFoundException.cs similarity index 61% rename from src/NzbDrone.Core/Exceptions/ArtistNotFoundException.cs rename to src/NzbDrone.Core/Exceptions/AuthorNotFoundException.cs index 0f8af670a..4a1593ae6 100644 --- a/src/NzbDrone.Core/Exceptions/ArtistNotFoundException.cs +++ b/src/NzbDrone.Core/Exceptions/AuthorNotFoundException.cs @@ -2,23 +2,23 @@ using NzbDrone.Common.Exceptions; namespace NzbDrone.Core.Exceptions { - public class ArtistNotFoundException : NzbDroneException + public class AuthorNotFoundException : NzbDroneException { public string MusicBrainzId { get; set; } - public ArtistNotFoundException(string musicbrainzId) - : base(string.Format("Artist with id {0} was not found, it may have been removed from the metadata server.", musicbrainzId)) + public AuthorNotFoundException(string musicbrainzId) + : base(string.Format("Author with id {0} was not found, it may have been removed from the metadata server.", musicbrainzId)) { MusicBrainzId = musicbrainzId; } - public ArtistNotFoundException(string musicbrainzId, string message, params object[] args) + public AuthorNotFoundException(string musicbrainzId, string message, params object[] args) : base(message, args) { MusicBrainzId = musicbrainzId; } - public ArtistNotFoundException(string musicbrainzId, string message) + public AuthorNotFoundException(string musicbrainzId, string message) : base(message) { MusicBrainzId = musicbrainzId; diff --git a/src/NzbDrone.Core/Exceptions/BookNotFoundException.cs b/src/NzbDrone.Core/Exceptions/BookNotFoundException.cs new file mode 100644 index 000000000..7e48b04df --- /dev/null +++ b/src/NzbDrone.Core/Exceptions/BookNotFoundException.cs @@ -0,0 +1,27 @@ +using NzbDrone.Common.Exceptions; + +namespace NzbDrone.Core.Exceptions +{ + public class BookNotFoundException : NzbDroneException + { + public string MusicBrainzId { get; set; } + + public BookNotFoundException(string musicbrainzId) + : base(string.Format("Book with id {0} was not found, it may have been removed from metadata server.", musicbrainzId)) + { + MusicBrainzId = musicbrainzId; + } + + public BookNotFoundException(string musicbrainzId, string message, params object[] args) + : base(message, args) + { + MusicBrainzId = musicbrainzId; + } + + public BookNotFoundException(string musicbrainzId, string message) + : base(message) + { + MusicBrainzId = musicbrainzId; + } + } +} diff --git a/src/NzbDrone.Core/Extras/ExistingExtraFileService.cs b/src/NzbDrone.Core/Extras/ExistingExtraFileService.cs index 14dfb622a..8602bb4f6 100644 --- a/src/NzbDrone.Core/Extras/ExistingExtraFileService.cs +++ b/src/NzbDrone.Core/Extras/ExistingExtraFileService.cs @@ -10,7 +10,7 @@ using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Extras { - public class ExistingExtraFileService : IHandle + public class ExistingExtraFileService : IHandle { private readonly IDiskProvider _diskProvider; private readonly IDiskScanService _diskScanService; @@ -28,29 +28,29 @@ namespace NzbDrone.Core.Extras _logger = logger; } - public void Handle(ArtistScannedEvent message) + public void Handle(AuthorScannedEvent message) { - var artist = message.Artist; + var author = message.Author; var extraFiles = new List(); - if (!_diskProvider.FolderExists(artist.Path)) + if (!_diskProvider.FolderExists(author.Path)) { return; } - _logger.Debug("Looking for existing extra files in {0}", artist.Path); + _logger.Debug("Looking for existing extra files in {0}", author.Path); - var filesOnDisk = _diskScanService.GetNonAudioFiles(artist.Path); - var possibleExtraFiles = _diskScanService.FilterFiles(artist.Path, filesOnDisk); + var filesOnDisk = _diskScanService.GetNonBookFiles(author.Path); + var possibleExtraFiles = _diskScanService.FilterFiles(author.Path, filesOnDisk); var filteredFiles = possibleExtraFiles; var importedFiles = new List(); foreach (var existingExtraFileImporter in _existingExtraFileImporters) { - var imported = existingExtraFileImporter.ProcessFiles(artist, filteredFiles, importedFiles); + var imported = existingExtraFileImporter.ProcessFiles(author, filteredFiles, importedFiles); - importedFiles.AddRange(imported.Select(f => Path.Combine(artist.Path, f.RelativePath))); + importedFiles.AddRange(imported.Select(f => Path.Combine(author.Path, f.RelativePath))); } _logger.Info("Found {0} extra files", extraFiles.Count); diff --git a/src/NzbDrone.Core/Extras/ExtraService.cs b/src/NzbDrone.Core/Extras/ExtraService.cs index f16fa7abb..b2c293743 100644 --- a/src/NzbDrone.Core/Extras/ExtraService.cs +++ b/src/NzbDrone.Core/Extras/ExtraService.cs @@ -4,6 +4,7 @@ using System.IO; using System.Linq; using NLog; using NzbDrone.Common.Disk; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; using NzbDrone.Core.Datastore; using NzbDrone.Core.Extras.Files; @@ -11,58 +12,57 @@ using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.Extras { public interface IExtraService { - void ImportTrack(LocalTrack localTrack, BookFile trackFile, bool isReadOnly); + void ImportTrack(LocalBook localBook, BookFile bookFile, bool isReadOnly); } public class ExtraService : IExtraService, IHandle, IHandle, - IHandle + IHandle { private readonly IMediaFileService _mediaFileService; - private readonly IAlbumService _albumService; + private readonly IBookService _bookService; private readonly IDiskProvider _diskProvider; private readonly IConfigService _configService; private readonly List _extraFileManagers; private readonly Logger _logger; public ExtraService(IMediaFileService mediaFileService, - IAlbumService albumService, + IBookService bookService, IDiskProvider diskProvider, IConfigService configService, List extraFileManagers, Logger logger) { _mediaFileService = mediaFileService; - _albumService = albumService; + _bookService = bookService; _diskProvider = diskProvider; _configService = configService; _extraFileManagers = extraFileManagers.OrderBy(e => e.Order).ToList(); _logger = logger; } - public void ImportTrack(LocalTrack localTrack, BookFile trackFile, bool isReadOnly) + public void ImportTrack(LocalBook localBook, BookFile bookFile, bool isReadOnly) { - ImportExtraFiles(localTrack, trackFile, isReadOnly); + ImportExtraFiles(localBook, bookFile, isReadOnly); - CreateAfterImport(localTrack.Artist, trackFile); + CreateAfterImport(localBook.Author, bookFile); } - public void ImportExtraFiles(LocalTrack localTrack, BookFile trackFile, bool isReadOnly) + public void ImportExtraFiles(LocalBook localBook, BookFile bookFile, bool isReadOnly) { if (!_configService.ImportExtraFiles) { return; } - var sourcePath = localTrack.Path; + var sourcePath = localBook.Path; var sourceFolder = _diskProvider.GetParentFolder(sourcePath); var sourceFileName = Path.GetFileNameWithoutExtension(sourcePath); var files = _diskProvider.GetFiles(sourceFolder, SearchOption.TopDirectoryOnly); @@ -105,7 +105,7 @@ namespace NzbDrone.Core.Extras foreach (var extraFileManager in _extraFileManagers) { var extension = Path.GetExtension(matchingFilename); - var extraFile = extraFileManager.Import(localTrack.Artist, trackFile, matchingFilename, extension, isReadOnly); + var extraFile = extraFileManager.Import(localBook.Author, bookFile, matchingFilename, extension, isReadOnly); if (extraFile != null) { @@ -120,51 +120,51 @@ namespace NzbDrone.Core.Extras } } - private void CreateAfterImport(Author artist, BookFile trackFile) + private void CreateAfterImport(Author author, BookFile bookFile) { foreach (var extraFileManager in _extraFileManagers) { - extraFileManager.CreateAfterTrackImport(artist, trackFile); + extraFileManager.CreateAfterTrackImport(author, bookFile); } } public void Handle(MediaCoversUpdatedEvent message) { - var artist = message.Artist; + var author = message.Author; - var trackFiles = GetTrackFiles(artist.Id); + var bookFiles = GetBookFiles(author.Id); foreach (var extraFileManager in _extraFileManagers) { - extraFileManager.CreateAfterArtistScan(artist, trackFiles); + extraFileManager.CreateAfterAuthorScan(author, bookFiles); } } public void Handle(TrackFolderCreatedEvent message) { - var artist = message.Artist; - var album = _albumService.GetAlbum(message.TrackFile.BookId); + var author = message.Author; + var book = _bookService.GetBook(message.BookFile.BookId); foreach (var extraFileManager in _extraFileManagers) { - extraFileManager.CreateAfterTrackImport(artist, album, message.ArtistFolder, message.AlbumFolder); + extraFileManager.CreateAfterBookImport(author, book, message.AuthorFolder, message.BookFolder); } } - public void Handle(ArtistRenamedEvent message) + public void Handle(AuthorRenamedEvent message) { - var artist = message.Artist; - var trackFiles = GetTrackFiles(artist.Id); + var author = message.Author; + var bookFiles = GetBookFiles(author.Id); foreach (var extraFileManager in _extraFileManagers) { - extraFileManager.MoveFilesAfterRename(artist, trackFiles); + extraFileManager.MoveFilesAfterRename(author, bookFiles); } } - private List GetTrackFiles(int authorId) + private List GetBookFiles(int authorId) { - return _mediaFileService.GetFilesByArtist(authorId); + return _mediaFileService.GetFilesByAuthor(authorId); } } } diff --git a/src/NzbDrone.Core/Extras/Files/ExtraFile.cs b/src/NzbDrone.Core/Extras/Files/ExtraFile.cs index f3737e572..e5748fe63 100644 --- a/src/NzbDrone.Core/Extras/Files/ExtraFile.cs +++ b/src/NzbDrone.Core/Extras/Files/ExtraFile.cs @@ -6,7 +6,7 @@ namespace NzbDrone.Core.Extras.Files public abstract class ExtraFile : ModelBase { public int AuthorId { get; set; } - public int? TrackFileId { get; set; } + public int? BookFileId { get; set; } public int? BookId { get; set; } public string RelativePath { get; set; } public DateTime Added { get; set; } diff --git a/src/NzbDrone.Core/Extras/Files/ExtraFileManager.cs b/src/NzbDrone.Core/Extras/Files/ExtraFileManager.cs index 7da4509ca..31980f474 100644 --- a/src/NzbDrone.Core/Extras/Files/ExtraFileManager.cs +++ b/src/NzbDrone.Core/Extras/Files/ExtraFileManager.cs @@ -5,20 +5,20 @@ using System.Text; using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; namespace NzbDrone.Core.Extras.Files { public interface IManageExtraFiles { int Order { get; } - IEnumerable CreateAfterArtistScan(Author artist, List trackFiles); - IEnumerable CreateAfterTrackImport(Author artist, BookFile trackFile); - IEnumerable CreateAfterTrackImport(Author artist, Book album, string artistFolder, string albumFolder); - IEnumerable MoveFilesAfterRename(Author artist, List trackFiles); - ExtraFile Import(Author artist, BookFile trackFile, string path, string extension, bool readOnly); + IEnumerable CreateAfterAuthorScan(Author author, List bookFiles); + IEnumerable CreateAfterTrackImport(Author author, BookFile bookFile); + IEnumerable CreateAfterBookImport(Author author, Book book, string authorFolder, string bookFolder); + IEnumerable MoveFilesAfterRename(Author author, List bookFiles); + ExtraFile Import(Author author, BookFile bookFile, string path, string extension, bool readOnly); } public abstract class ExtraFileManager : IManageExtraFiles @@ -41,16 +41,16 @@ namespace NzbDrone.Core.Extras.Files } public abstract int Order { get; } - public abstract IEnumerable CreateAfterArtistScan(Author artist, List trackFiles); - public abstract IEnumerable CreateAfterTrackImport(Author artist, BookFile trackFile); - public abstract IEnumerable CreateAfterTrackImport(Author artist, Book album, string artistFolder, string albumFolder); - public abstract IEnumerable MoveFilesAfterRename(Author artist, List trackFiles); - public abstract ExtraFile Import(Author artist, BookFile trackFile, string path, string extension, bool readOnly); + public abstract IEnumerable CreateAfterAuthorScan(Author author, List bookFiles); + public abstract IEnumerable CreateAfterTrackImport(Author author, BookFile bookFile); + public abstract IEnumerable CreateAfterBookImport(Author author, Book book, string authorFolder, string albumFolder); + public abstract IEnumerable MoveFilesAfterRename(Author author, List bookFiles); + public abstract ExtraFile Import(Author author, BookFile bookFile, string path, string extension, bool readOnly); - protected TExtraFile ImportFile(Author artist, BookFile trackFile, string path, bool readOnly, string extension, string fileNameSuffix = null) + protected TExtraFile ImportFile(Author author, BookFile bookFile, string path, bool readOnly, string extension, string fileNameSuffix = null) { - var newFolder = Path.GetDirectoryName(trackFile.Path); - var filenameBuilder = new StringBuilder(Path.GetFileNameWithoutExtension(trackFile.Path)); + var newFolder = Path.GetDirectoryName(bookFile.Path); + var filenameBuilder = new StringBuilder(Path.GetFileNameWithoutExtension(bookFile.Path)); if (fileNameSuffix.IsNotNullOrWhiteSpace()) { @@ -71,18 +71,18 @@ namespace NzbDrone.Core.Extras.Files return new TExtraFile { - AuthorId = artist.Id, - BookId = trackFile.BookId, - TrackFileId = trackFile.Id, - RelativePath = artist.Path.GetRelativePath(newFileName), + AuthorId = author.Id, + BookId = bookFile.BookId, + BookFileId = bookFile.Id, + RelativePath = author.Path.GetRelativePath(newFileName), Extension = extension }; } - protected TExtraFile MoveFile(Author artist, BookFile trackFile, TExtraFile extraFile, string fileNameSuffix = null) + protected TExtraFile MoveFile(Author author, BookFile bookFile, TExtraFile extraFile, string fileNameSuffix = null) { - var newFolder = Path.GetDirectoryName(trackFile.Path); - var filenameBuilder = new StringBuilder(Path.GetFileNameWithoutExtension(trackFile.Path)); + var newFolder = Path.GetDirectoryName(bookFile.Path); + var filenameBuilder = new StringBuilder(Path.GetFileNameWithoutExtension(bookFile.Path)); if (fileNameSuffix.IsNotNullOrWhiteSpace()) { @@ -91,7 +91,7 @@ namespace NzbDrone.Core.Extras.Files filenameBuilder.Append(extraFile.Extension); - var existingFileName = Path.Combine(artist.Path, extraFile.RelativePath); + var existingFileName = Path.Combine(author.Path, extraFile.RelativePath); var newFileName = Path.Combine(newFolder, filenameBuilder.ToString()); if (newFileName.PathNotEquals(existingFileName)) @@ -99,7 +99,7 @@ namespace NzbDrone.Core.Extras.Files try { _diskProvider.MoveFile(existingFileName, newFileName); - extraFile.RelativePath = artist.Path.GetRelativePath(newFileName); + extraFile.RelativePath = author.Path.GetRelativePath(newFileName); return extraFile; } diff --git a/src/NzbDrone.Core/Extras/Files/ExtraFileRepository.cs b/src/NzbDrone.Core/Extras/Files/ExtraFileRepository.cs index 2c0eeeb69..185ae2a20 100644 --- a/src/NzbDrone.Core/Extras/Files/ExtraFileRepository.cs +++ b/src/NzbDrone.Core/Extras/Files/ExtraFileRepository.cs @@ -8,12 +8,12 @@ namespace NzbDrone.Core.Extras.Files public interface IExtraFileRepository : IBasicRepository where TExtraFile : ExtraFile, new() { - void DeleteForArtist(int authorId); - void DeleteForAlbum(int authorId, int bookId); - void DeleteForTrackFile(int trackFileId); - List GetFilesByArtist(int authorId); - List GetFilesByAlbum(int authorId, int bookId); - List GetFilesByTrackFile(int trackFileId); + void DeleteForAuthor(int authorId); + void DeleteForBook(int authorId, int bookId); + void DeleteForBookFile(int bookFileId); + List GetFilesByAuthor(int authorId); + List GetFilesByBook(int authorId, int bookId); + List GetFilesByBookFile(int bookFileId); TExtraFile FindByPath(string path); } @@ -25,34 +25,34 @@ namespace NzbDrone.Core.Extras.Files { } - public void DeleteForArtist(int authorId) + public void DeleteForAuthor(int authorId) { Delete(c => c.AuthorId == authorId); } - public void DeleteForAlbum(int authorId, int bookId) + public void DeleteForBook(int authorId, int bookId) { Delete(c => c.AuthorId == authorId && c.BookId == bookId); } - public void DeleteForTrackFile(int trackFileId) + public void DeleteForBookFile(int bookFileId) { - Delete(c => c.TrackFileId == trackFileId); + Delete(c => c.BookFileId == bookFileId); } - public List GetFilesByArtist(int authorId) + public List GetFilesByAuthor(int authorId) { return Query(c => c.AuthorId == authorId); } - public List GetFilesByAlbum(int authorId, int bookId) + public List GetFilesByBook(int authorId, int bookId) { return Query(c => c.AuthorId == authorId && c.BookId == bookId); } - public List GetFilesByTrackFile(int trackFileId) + public List GetFilesByBookFile(int bookFileId) { - return Query(c => c.TrackFileId == trackFileId); + return Query(c => c.BookFileId == bookFileId); } public TExtraFile FindByPath(string path) diff --git a/src/NzbDrone.Core/Extras/Files/ExtraFileService.cs b/src/NzbDrone.Core/Extras/Files/ExtraFileService.cs index aaecf56aa..aedf65945 100644 --- a/src/NzbDrone.Core/Extras/Files/ExtraFileService.cs +++ b/src/NzbDrone.Core/Extras/Files/ExtraFileService.cs @@ -5,11 +5,11 @@ using System.Linq; using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; +using NzbDrone.Core.Books.Events; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; -using NzbDrone.Core.Music.Events; namespace NzbDrone.Core.Extras.Files { @@ -26,24 +26,24 @@ namespace NzbDrone.Core.Extras.Files } public abstract class ExtraFileService : IExtraFileService, - IHandleAsync, - IHandle + IHandleAsync, + IHandle where TExtraFile : ExtraFile, new() { private readonly IExtraFileRepository _repository; - private readonly IArtistService _artistService; + private readonly IAuthorService _authorService; private readonly IDiskProvider _diskProvider; private readonly IRecycleBinProvider _recycleBinProvider; private readonly Logger _logger; public ExtraFileService(IExtraFileRepository repository, - IArtistService artistService, + IAuthorService authorService, IDiskProvider diskProvider, IRecycleBinProvider recycleBinProvider, Logger logger) { _repository = repository; - _artistService = artistService; + _authorService = authorService; _diskProvider = diskProvider; _recycleBinProvider = recycleBinProvider; _logger = logger; @@ -51,12 +51,12 @@ namespace NzbDrone.Core.Extras.Files public List GetFilesByArtist(int authorId) { - return _repository.GetFilesByArtist(authorId); + return _repository.GetFilesByAuthor(authorId); } public List GetFilesByTrackFile(int trackFileId) { - return _repository.GetFilesByTrackFile(trackFileId); + return _repository.GetFilesByBookFile(trackFileId); } public TExtraFile FindByPath(string path) @@ -95,15 +95,15 @@ namespace NzbDrone.Core.Extras.Files _repository.DeleteMany(ids); } - public void HandleAsync(ArtistDeletedEvent message) + public void HandleAsync(AuthorDeletedEvent message) { - _logger.Debug("Deleting Extra from database for artist: {0}", message.Artist); - _repository.DeleteForArtist(message.Artist.Id); + _logger.Debug("Deleting Extra from database for author: {0}", message.Author); + _repository.DeleteForAuthor(message.Author.Id); } - public void Handle(TrackFileDeletedEvent message) + public void Handle(BookFileDeletedEvent message) { - var trackFile = message.TrackFile; + var bookFile = message.BookFile; if (message.Reason == DeleteMediaFileReason.NoLinkedEpisodes) { @@ -111,23 +111,23 @@ namespace NzbDrone.Core.Extras.Files } else { - var artist = trackFile.Artist.Value; + var author = bookFile.Author.Value; - foreach (var extra in _repository.GetFilesByTrackFile(trackFile.Id)) + foreach (var extra in _repository.GetFilesByBookFile(bookFile.Id)) { - var path = Path.Combine(artist.Path, extra.RelativePath); + var path = Path.Combine(author.Path, extra.RelativePath); if (_diskProvider.FileExists(path)) { // Send to the recycling bin so they can be recovered if necessary - var subfolder = _diskProvider.GetParentFolder(artist.Path).GetRelativePath(_diskProvider.GetParentFolder(path)); + var subfolder = _diskProvider.GetParentFolder(author.Path).GetRelativePath(_diskProvider.GetParentFolder(path)); _recycleBinProvider.DeleteFile(path, subfolder); } } } - _logger.Debug("Deleting Extra from database for track file: {0}", trackFile); - _repository.DeleteForTrackFile(trackFile.Id); + _logger.Debug("Deleting Extra from database for track file: {0}", bookFile); + _repository.DeleteForBookFile(bookFile.Id); } } } diff --git a/src/NzbDrone.Core/Extras/IImportExistingExtraFiles.cs b/src/NzbDrone.Core/Extras/IImportExistingExtraFiles.cs index 458b0282e..3a0630841 100644 --- a/src/NzbDrone.Core/Extras/IImportExistingExtraFiles.cs +++ b/src/NzbDrone.Core/Extras/IImportExistingExtraFiles.cs @@ -1,12 +1,12 @@ using System.Collections.Generic; +using NzbDrone.Core.Books; using NzbDrone.Core.Extras.Files; -using NzbDrone.Core.Music; namespace NzbDrone.Core.Extras { public interface IImportExistingExtraFiles { int Order { get; } - IEnumerable ProcessFiles(Author artist, List filesOnDisk, List importedFiles); + IEnumerable ProcessFiles(Author author, List filesOnDisk, List importedFiles); } } diff --git a/src/NzbDrone.Core/Extras/ImportExistingExtraFilesBase.cs b/src/NzbDrone.Core/Extras/ImportExistingExtraFilesBase.cs index a6801fe7a..0c8f3688e 100644 --- a/src/NzbDrone.Core/Extras/ImportExistingExtraFilesBase.cs +++ b/src/NzbDrone.Core/Extras/ImportExistingExtraFilesBase.cs @@ -3,8 +3,8 @@ using System.IO; using System.Linq; using NzbDrone.Common; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.Extras.Files; -using NzbDrone.Core.Music; namespace NzbDrone.Core.Extras { @@ -19,21 +19,21 @@ namespace NzbDrone.Core.Extras } public abstract int Order { get; } - public abstract IEnumerable ProcessFiles(Author artist, List filesOnDisk, List importedFiles); + public abstract IEnumerable ProcessFiles(Author author, List filesOnDisk, List importedFiles); - public virtual ImportExistingExtraFileFilterResult FilterAndClean(Author artist, List filesOnDisk, List importedFiles) + public virtual ImportExistingExtraFileFilterResult FilterAndClean(Author author, List filesOnDisk, List importedFiles) { - var artistFiles = _extraFileService.GetFilesByArtist(artist.Id); + var authorFiles = _extraFileService.GetFilesByArtist(author.Id); - Clean(artist, filesOnDisk, importedFiles, artistFiles); + Clean(author, filesOnDisk, importedFiles, authorFiles); - return Filter(artist, filesOnDisk, importedFiles, artistFiles); + return Filter(author, filesOnDisk, importedFiles, authorFiles); } - private ImportExistingExtraFileFilterResult Filter(Author artist, List filesOnDisk, List importedFiles, List artistFiles) + private ImportExistingExtraFileFilterResult Filter(Author author, List filesOnDisk, List importedFiles, List authorFiles) { - var previouslyImported = artistFiles.IntersectBy(s => Path.Combine(artist.Path, s.RelativePath), filesOnDisk, f => f, PathEqualityComparer.Instance).ToList(); - var filteredFiles = filesOnDisk.Except(previouslyImported.Select(f => Path.Combine(artist.Path, f.RelativePath)).ToList(), PathEqualityComparer.Instance) + var previouslyImported = authorFiles.IntersectBy(s => Path.Combine(author.Path, s.RelativePath), filesOnDisk, f => f, PathEqualityComparer.Instance).ToList(); + var filteredFiles = filesOnDisk.Except(previouslyImported.Select(f => Path.Combine(author.Path, f.RelativePath)).ToList(), PathEqualityComparer.Instance) .Except(importedFiles, PathEqualityComparer.Instance) .ToList(); @@ -42,12 +42,12 @@ namespace NzbDrone.Core.Extras return new ImportExistingExtraFileFilterResult(previouslyImported, filteredFiles); } - private void Clean(Author artist, List filesOnDisk, List importedFiles, List artistFiles) + private void Clean(Author author, List filesOnDisk, List importedFiles, List authorFiles) { - var alreadyImportedFileIds = artistFiles.IntersectBy(f => Path.Combine(artist.Path, f.RelativePath), importedFiles, i => i, PathEqualityComparer.Instance) + var alreadyImportedFileIds = authorFiles.IntersectBy(f => Path.Combine(author.Path, f.RelativePath), importedFiles, i => i, PathEqualityComparer.Instance) .Select(f => f.Id); - var deletedFiles = artistFiles.ExceptBy(f => Path.Combine(artist.Path, f.RelativePath), filesOnDisk, i => i, PathEqualityComparer.Instance) + var deletedFiles = authorFiles.ExceptBy(f => Path.Combine(author.Path, f.RelativePath), filesOnDisk, i => i, PathEqualityComparer.Instance) .Select(f => f.Id); _extraFileService.DeleteMany(alreadyImportedFileIds); diff --git a/src/NzbDrone.Core/Extras/Metadata/ExistingMetadataImporter.cs b/src/NzbDrone.Core/Extras/Metadata/ExistingMetadataImporter.cs index 4ec3e0581..3f0005053 100644 --- a/src/NzbDrone.Core/Extras/Metadata/ExistingMetadataImporter.cs +++ b/src/NzbDrone.Core/Extras/Metadata/ExistingMetadataImporter.cs @@ -3,10 +3,10 @@ using System.IO; using System.Linq; using NLog; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.Extras.Files; using NzbDrone.Core.Extras.Metadata.Files; -using NzbDrone.Core.MediaFiles.TrackImport.Aggregation; -using NzbDrone.Core.Music; +using NzbDrone.Core.MediaFiles.BookImport.Aggregation; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; @@ -36,18 +36,18 @@ namespace NzbDrone.Core.Extras.Metadata public override int Order => 0; - public override IEnumerable ProcessFiles(Author artist, List filesOnDisk, List importedFiles) + public override IEnumerable ProcessFiles(Author author, List filesOnDisk, List importedFiles) { - _logger.Debug("Looking for existing metadata in {0}", artist.Path); + _logger.Debug("Looking for existing metadata in {0}", author.Path); var metadataFiles = new List(); - var filterResult = FilterAndClean(artist, filesOnDisk, importedFiles); + var filterResult = FilterAndClean(author, filesOnDisk, importedFiles); foreach (var possibleMetadataFile in filterResult.FilesOnDisk) { foreach (var consumer in _consumers) { - var metadata = consumer.FindMetadataFile(artist, possibleMetadataFile); + var metadata = consumer.FindMetadataFile(author, possibleMetadataFile); if (metadata == null) { @@ -56,7 +56,7 @@ namespace NzbDrone.Core.Extras.Metadata if (metadata.Type == MetadataType.AlbumImage || metadata.Type == MetadataType.AlbumMetadata) { - var localAlbum = _parsingService.GetLocalAlbum(possibleMetadataFile, artist); + var localAlbum = _parsingService.GetLocalAlbum(possibleMetadataFile, author); if (localAlbum == null) { @@ -69,10 +69,10 @@ namespace NzbDrone.Core.Extras.Metadata if (metadata.Type == MetadataType.TrackMetadata) { - var localTrack = new LocalTrack + var localTrack = new LocalBook { FileTrackInfo = Parser.Parser.ParseMusicPath(possibleMetadataFile), - Artist = artist, + Author = author, Path = possibleMetadataFile }; @@ -86,7 +86,7 @@ namespace NzbDrone.Core.Extras.Metadata continue; } - if (localTrack.Album == null) + if (localTrack.Book == null) { _logger.Debug("Cannot find related book for: {0}", possibleMetadataFile); continue; diff --git a/src/NzbDrone.Core/Extras/Metadata/Files/CleanMetadataFileService.cs b/src/NzbDrone.Core/Extras/Metadata/Files/CleanMetadataFileService.cs index 865ed1b89..496d2ceeb 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Files/CleanMetadataFileService.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Files/CleanMetadataFileService.cs @@ -1,13 +1,13 @@ using System.IO; using NLog; using NzbDrone.Common.Disk; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; namespace NzbDrone.Core.Extras.Metadata.Files { public interface ICleanMetadataService { - void Clean(Author artist); + void Clean(Author author); } public class CleanExtraFileService : ICleanMetadataService @@ -25,15 +25,15 @@ namespace NzbDrone.Core.Extras.Metadata.Files _logger = logger; } - public void Clean(Author artist) + public void Clean(Author author) { - _logger.Debug("Cleaning missing metadata files for artist: {0}", artist.Name); + _logger.Debug("Cleaning missing metadata files for author: {0}", author.Name); - var metadataFiles = _metadataFileService.GetFilesByArtist(artist.Id); + var metadataFiles = _metadataFileService.GetFilesByArtist(author.Id); foreach (var metadataFile in metadataFiles) { - if (!_diskProvider.FileExists(Path.Combine(artist.Path, metadataFile.RelativePath))) + if (!_diskProvider.FileExists(Path.Combine(author.Path, metadataFile.RelativePath))) { _logger.Debug("Deleting metadata file from database: {0}", metadataFile.RelativePath); _metadataFileService.Delete(metadataFile.Id); diff --git a/src/NzbDrone.Core/Extras/Metadata/Files/MetadataFileService.cs b/src/NzbDrone.Core/Extras/Metadata/Files/MetadataFileService.cs index 7789cfe44..689268d34 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Files/MetadataFileService.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Files/MetadataFileService.cs @@ -1,8 +1,8 @@ using NLog; using NzbDrone.Common.Disk; +using NzbDrone.Core.Books; using NzbDrone.Core.Extras.Files; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; namespace NzbDrone.Core.Extras.Metadata.Files { @@ -12,8 +12,8 @@ namespace NzbDrone.Core.Extras.Metadata.Files public class MetadataFileService : ExtraFileService, IMetadataFileService { - public MetadataFileService(IExtraFileRepository repository, IArtistService artistService, IDiskProvider diskProvider, IRecycleBinProvider recycleBinProvider, Logger logger) - : base(repository, artistService, diskProvider, recycleBinProvider, logger) + public MetadataFileService(IExtraFileRepository repository, IAuthorService authorService, IDiskProvider diskProvider, IRecycleBinProvider recycleBinProvider, Logger logger) + : base(repository, authorService, diskProvider, recycleBinProvider, logger) { } } diff --git a/src/NzbDrone.Core/Extras/Metadata/IMetadata.cs b/src/NzbDrone.Core/Extras/Metadata/IMetadata.cs index 309dd2898..93d074d3d 100644 --- a/src/NzbDrone.Core/Extras/Metadata/IMetadata.cs +++ b/src/NzbDrone.Core/Extras/Metadata/IMetadata.cs @@ -1,21 +1,21 @@ using System.Collections.Generic; +using NzbDrone.Core.Books; using NzbDrone.Core.Extras.Metadata.Files; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.ThingiProvider; namespace NzbDrone.Core.Extras.Metadata { public interface IMetadata : IProvider { - string GetFilenameAfterMove(Author artist, BookFile trackFile, MetadataFile metadataFile); - string GetFilenameAfterMove(Author artist, string albumPath, MetadataFile metadataFile); - MetadataFile FindMetadataFile(Author artist, string path); - MetadataFileResult ArtistMetadata(Author artist); - MetadataFileResult AlbumMetadata(Author artist, Book album, string albumPath); - MetadataFileResult TrackMetadata(Author artist, BookFile trackFile); - List ArtistImages(Author artist); - List AlbumImages(Author artist, Book album, string albumPath); - List TrackImages(Author artist, BookFile trackFile); + string GetFilenameAfterMove(Author author, BookFile bookFile, MetadataFile metadataFile); + string GetFilenameAfterMove(Author author, string albumPath, MetadataFile metadataFile); + MetadataFile FindMetadataFile(Author author, string path); + MetadataFileResult ArtistMetadata(Author author); + MetadataFileResult AlbumMetadata(Author author, Book book, string albumPath); + MetadataFileResult TrackMetadata(Author author, BookFile bookFile); + List ArtistImages(Author author); + List AlbumImages(Author author, Book book, string albumPath); + List TrackImages(Author author, BookFile bookFile); } } diff --git a/src/NzbDrone.Core/Extras/Metadata/MetadataBase.cs b/src/NzbDrone.Core/Extras/Metadata/MetadataBase.cs index efa994eed..4d84c9125 100644 --- a/src/NzbDrone.Core/Extras/Metadata/MetadataBase.cs +++ b/src/NzbDrone.Core/Extras/Metadata/MetadataBase.cs @@ -2,9 +2,9 @@ using System; using System.Collections.Generic; using System.IO; using FluentValidation.Results; +using NzbDrone.Core.Books; using NzbDrone.Core.Extras.Metadata.Files; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.ThingiProvider; namespace NzbDrone.Core.Extras.Metadata @@ -27,31 +27,31 @@ namespace NzbDrone.Core.Extras.Metadata return new ValidationResult(); } - public virtual string GetFilenameAfterMove(Author artist, BookFile trackFile, MetadataFile metadataFile) + public virtual string GetFilenameAfterMove(Author author, BookFile bookFile, MetadataFile metadataFile) { - var existingFilename = Path.Combine(artist.Path, metadataFile.RelativePath); + var existingFilename = Path.Combine(author.Path, metadataFile.RelativePath); var extension = Path.GetExtension(existingFilename).TrimStart('.'); - var newFileName = Path.ChangeExtension(trackFile.Path, extension); + var newFileName = Path.ChangeExtension(bookFile.Path, extension); return newFileName; } - public virtual string GetFilenameAfterMove(Author artist, string albumPath, MetadataFile metadataFile) + public virtual string GetFilenameAfterMove(Author author, string albumPath, MetadataFile metadataFile) { var existingFilename = Path.GetFileName(metadataFile.RelativePath); - var newFileName = Path.Combine(artist.Path, albumPath, existingFilename); + var newFileName = Path.Combine(author.Path, albumPath, existingFilename); return newFileName; } - public abstract MetadataFile FindMetadataFile(Author artist, string path); + public abstract MetadataFile FindMetadataFile(Author author, string path); - public abstract MetadataFileResult ArtistMetadata(Author artist); - public abstract MetadataFileResult AlbumMetadata(Author artist, Book album, string albumPath); - public abstract MetadataFileResult TrackMetadata(Author artist, BookFile trackFile); - public abstract List ArtistImages(Author artist); - public abstract List AlbumImages(Author artist, Book album, string albumPath); - public abstract List TrackImages(Author artist, BookFile trackFile); + public abstract MetadataFileResult ArtistMetadata(Author author); + public abstract MetadataFileResult AlbumMetadata(Author author, Book book, string albumPath); + public abstract MetadataFileResult TrackMetadata(Author author, BookFile bookFile); + public abstract List ArtistImages(Author author); + public abstract List AlbumImages(Author author, Book book, string albumPath); + public abstract List TrackImages(Author author, BookFile bookFile); public virtual object RequestAction(string action, IDictionary query) { diff --git a/src/NzbDrone.Core/Extras/Metadata/MetadataService.cs b/src/NzbDrone.Core/Extras/Metadata/MetadataService.cs index b51f293b8..e7bcfb590 100644 --- a/src/NzbDrone.Core/Extras/Metadata/MetadataService.cs +++ b/src/NzbDrone.Core/Extras/Metadata/MetadataService.cs @@ -7,12 +7,12 @@ using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; using NzbDrone.Core.Extras.Files; using NzbDrone.Core.Extras.Metadata.Files; using NzbDrone.Core.Extras.Others; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; namespace NzbDrone.Core.Extras.Metadata { @@ -27,7 +27,7 @@ namespace NzbDrone.Core.Extras.Metadata private readonly IHttpClient _httpClient; private readonly IMediaFileAttributeService _mediaFileAttributeService; private readonly IMetadataFileService _metadataFileService; - private readonly IAlbumService _albumService; + private readonly IBookService _bookService; private readonly Logger _logger; public MetadataService(IConfigService configService, @@ -40,7 +40,7 @@ namespace NzbDrone.Core.Extras.Metadata IHttpClient httpClient, IMediaFileAttributeService mediaFileAttributeService, IMetadataFileService metadataFileService, - IAlbumService albumService, + IBookService bookService, Logger logger) : base(configService, diskProvider, diskTransferService, logger) { @@ -53,20 +53,20 @@ namespace NzbDrone.Core.Extras.Metadata _httpClient = httpClient; _mediaFileAttributeService = mediaFileAttributeService; _metadataFileService = metadataFileService; - _albumService = albumService; + _bookService = bookService; _logger = logger; } public override int Order => 0; - public override IEnumerable CreateAfterArtistScan(Author artist, List trackFiles) + public override IEnumerable CreateAfterAuthorScan(Author author, List bookFiles) { - var metadataFiles = _metadataFileService.GetFilesByArtist(artist.Id); - _cleanMetadataService.Clean(artist); + var metadataFiles = _metadataFileService.GetFilesByArtist(author.Id); + _cleanMetadataService.Clean(author); - if (!_diskProvider.FolderExists(artist.Path)) + if (!_diskProvider.FolderExists(author.Path)) { - _logger.Info("Artist folder does not exist, skipping metadata creation"); + _logger.Info("Author folder does not exist, skipping metadata creation"); return Enumerable.Empty(); } @@ -76,21 +76,21 @@ namespace NzbDrone.Core.Extras.Metadata { var consumerFiles = GetMetadataFilesForConsumer(consumer, metadataFiles); - files.AddIfNotNull(ProcessArtistMetadata(consumer, artist, consumerFiles)); - files.AddRange(ProcessArtistImages(consumer, artist, consumerFiles)); + files.AddIfNotNull(ProcessArtistMetadata(consumer, author, consumerFiles)); + files.AddRange(ProcessArtistImages(consumer, author, consumerFiles)); - var albumGroups = trackFiles.GroupBy(s => Path.GetDirectoryName(s.Path)).ToList(); + var albumGroups = bookFiles.GroupBy(s => Path.GetDirectoryName(s.Path)).ToList(); foreach (var group in albumGroups) { - var album = _albumService.GetAlbum(group.First().BookId); + var book = _bookService.GetBook(group.First().BookId); var albumFolder = group.Key; - files.AddIfNotNull(ProcessAlbumMetadata(consumer, artist, album, albumFolder, consumerFiles)); - files.AddRange(ProcessAlbumImages(consumer, artist, album, albumFolder, consumerFiles)); + files.AddIfNotNull(ProcessAlbumMetadata(consumer, author, book, albumFolder, consumerFiles)); + files.AddRange(ProcessAlbumImages(consumer, author, book, albumFolder, consumerFiles)); - foreach (var trackFile in group) + foreach (var bookFile in group) { - files.AddIfNotNull(ProcessTrackMetadata(consumer, artist, trackFile, consumerFiles)); + files.AddIfNotNull(ProcessTrackMetadata(consumer, author, bookFile, consumerFiles)); } } } @@ -100,13 +100,13 @@ namespace NzbDrone.Core.Extras.Metadata return files; } - public override IEnumerable CreateAfterTrackImport(Author artist, BookFile trackFile) + public override IEnumerable CreateAfterTrackImport(Author author, BookFile bookFile) { var files = new List(); foreach (var consumer in _metadataFactory.Enabled()) { - files.AddIfNotNull(ProcessTrackMetadata(consumer, artist, trackFile, new List())); + files.AddIfNotNull(ProcessTrackMetadata(consumer, author, bookFile, new List())); } _metadataFileService.Upsert(files); @@ -114,9 +114,9 @@ namespace NzbDrone.Core.Extras.Metadata return files; } - public override IEnumerable CreateAfterTrackImport(Author artist, Book album, string artistFolder, string albumFolder) + public override IEnumerable CreateAfterBookImport(Author author, Book book, string artistFolder, string albumFolder) { - var metadataFiles = _metadataFileService.GetFilesByArtist(artist.Id); + var metadataFiles = _metadataFileService.GetFilesByArtist(author.Id); if (artistFolder.IsNullOrWhiteSpace() && albumFolder.IsNullOrWhiteSpace()) { @@ -131,8 +131,8 @@ namespace NzbDrone.Core.Extras.Metadata if (artistFolder.IsNotNullOrWhiteSpace()) { - files.AddIfNotNull(ProcessArtistMetadata(consumer, artist, consumerFiles)); - files.AddRange(ProcessArtistImages(consumer, artist, consumerFiles)); + files.AddIfNotNull(ProcessArtistMetadata(consumer, author, consumerFiles)); + files.AddRange(ProcessArtistImages(consumer, author, consumerFiles)); } } @@ -141,11 +141,11 @@ namespace NzbDrone.Core.Extras.Metadata return files; } - public override IEnumerable MoveFilesAfterRename(Author artist, List trackFiles) + public override IEnumerable MoveFilesAfterRename(Author author, List bookFiles) { - var metadataFiles = _metadataFileService.GetFilesByArtist(artist.Id); + var metadataFiles = _metadataFileService.GetFilesByArtist(author.Id); var movedFiles = new List(); - var distinctTrackFilePaths = trackFiles.DistinctBy(s => Path.GetDirectoryName(s.Path)).ToList(); + var distinctTrackFilePaths = bookFiles.DistinctBy(s => Path.GetDirectoryName(s.Path)).ToList(); // TODO: Move EpisodeImage and EpisodeMetadata metadata files, instead of relying on consumers to do it // (Xbmc's EpisodeImage is more than just the extension) @@ -160,15 +160,15 @@ namespace NzbDrone.Core.Extras.Metadata foreach (var metadataFile in metadataFilesForConsumer) { - var newFileName = consumer.GetFilenameAfterMove(artist, Path.GetDirectoryName(filePath.Path), metadataFile); - var existingFileName = Path.Combine(artist.Path, metadataFile.RelativePath); + var newFileName = consumer.GetFilenameAfterMove(author, Path.GetDirectoryName(filePath.Path), metadataFile); + var existingFileName = Path.Combine(author.Path, metadataFile.RelativePath); if (newFileName.PathNotEquals(existingFileName)) { try { _diskProvider.MoveFile(existingFileName, newFileName); - metadataFile.RelativePath = artist.Path.GetRelativePath(newFileName); + metadataFile.RelativePath = author.Path.GetRelativePath(newFileName); movedFiles.Add(metadataFile); } catch (Exception ex) @@ -179,21 +179,21 @@ namespace NzbDrone.Core.Extras.Metadata } } - foreach (var trackFile in trackFiles) + foreach (var bookFile in bookFiles) { - var metadataFilesForConsumer = GetMetadataFilesForConsumer(consumer, metadataFiles).Where(m => m.TrackFileId == trackFile.Id).ToList(); + var metadataFilesForConsumer = GetMetadataFilesForConsumer(consumer, metadataFiles).Where(m => m.BookFileId == bookFile.Id).ToList(); foreach (var metadataFile in metadataFilesForConsumer) { - var newFileName = consumer.GetFilenameAfterMove(artist, trackFile, metadataFile); - var existingFileName = Path.Combine(artist.Path, metadataFile.RelativePath); + var newFileName = consumer.GetFilenameAfterMove(author, bookFile, metadataFile); + var existingFileName = Path.Combine(author.Path, metadataFile.RelativePath); if (newFileName.PathNotEquals(existingFileName)) { try { _diskProvider.MoveFile(existingFileName, newFileName); - metadataFile.RelativePath = artist.Path.GetRelativePath(newFileName); + metadataFile.RelativePath = author.Path.GetRelativePath(newFileName); movedFiles.Add(metadataFile); } catch (Exception ex) @@ -210,7 +210,7 @@ namespace NzbDrone.Core.Extras.Metadata return movedFiles; } - public override ExtraFile Import(Author artist, BookFile trackFile, string path, string extension, bool readOnly) + public override ExtraFile Import(Author author, BookFile bookFile, string path, string extension, bool readOnly) { return null; } @@ -220,9 +220,9 @@ namespace NzbDrone.Core.Extras.Metadata return artistMetadata.Where(c => c.Consumer == consumer.GetType().Name).ToList(); } - private MetadataFile ProcessArtistMetadata(IMetadata consumer, Author artist, List existingMetadataFiles) + private MetadataFile ProcessArtistMetadata(IMetadata consumer, Author author, List existingMetadataFiles) { - var artistMetadata = consumer.ArtistMetadata(artist); + var artistMetadata = consumer.ArtistMetadata(author); if (artistMetadata == null) { @@ -231,10 +231,10 @@ namespace NzbDrone.Core.Extras.Metadata var hash = artistMetadata.Contents.SHA256Hash(); - var metadata = GetMetadataFile(artist, existingMetadataFiles, e => e.Type == MetadataType.ArtistMetadata) ?? + var metadata = GetMetadataFile(author, existingMetadataFiles, e => e.Type == MetadataType.ArtistMetadata) ?? new MetadataFile { - AuthorId = artist.Id, + AuthorId = author.Id, Consumer = consumer.GetType().Name, Type = MetadataType.ArtistMetadata }; @@ -251,11 +251,11 @@ namespace NzbDrone.Core.Extras.Metadata return null; } - var fullPath = Path.Combine(artist.Path, artistMetadata.RelativePath); + var fullPath = Path.Combine(author.Path, artistMetadata.RelativePath); - _otherExtraFileRenamer.RenameOtherExtraFile(artist, fullPath); + _otherExtraFileRenamer.RenameOtherExtraFile(author, fullPath); - _logger.Debug("Writing Artist Metadata to: {0}", fullPath); + _logger.Debug("Writing Author Metadata to: {0}", fullPath); SaveMetadataFile(fullPath, artistMetadata.Contents); metadata.Hash = hash; @@ -265,9 +265,9 @@ namespace NzbDrone.Core.Extras.Metadata return metadata; } - private MetadataFile ProcessAlbumMetadata(IMetadata consumer, Author artist, Book album, string albumPath, List existingMetadataFiles) + private MetadataFile ProcessAlbumMetadata(IMetadata consumer, Author author, Book book, string albumPath, List existingMetadataFiles) { - var albumMetadata = consumer.AlbumMetadata(artist, album, albumPath); + var albumMetadata = consumer.AlbumMetadata(author, book, albumPath); if (albumMetadata == null) { @@ -276,11 +276,11 @@ namespace NzbDrone.Core.Extras.Metadata var hash = albumMetadata.Contents.SHA256Hash(); - var metadata = GetMetadataFile(artist, existingMetadataFiles, e => e.Type == MetadataType.AlbumMetadata && e.BookId == album.Id) ?? + var metadata = GetMetadataFile(author, existingMetadataFiles, e => e.Type == MetadataType.AlbumMetadata && e.BookId == book.Id) ?? new MetadataFile { - AuthorId = artist.Id, - BookId = album.Id, + AuthorId = author.Id, + BookId = book.Id, Consumer = consumer.GetType().Name, Type = MetadataType.AlbumMetadata }; @@ -297,9 +297,9 @@ namespace NzbDrone.Core.Extras.Metadata return null; } - var fullPath = Path.Combine(artist.Path, albumMetadata.RelativePath); + var fullPath = Path.Combine(author.Path, albumMetadata.RelativePath); - _otherExtraFileRenamer.RenameOtherExtraFile(artist, fullPath); + _otherExtraFileRenamer.RenameOtherExtraFile(author, fullPath); _logger.Debug("Writing Album Metadata to: {0}", fullPath); SaveMetadataFile(fullPath, albumMetadata.Contents); @@ -311,25 +311,25 @@ namespace NzbDrone.Core.Extras.Metadata return metadata; } - private MetadataFile ProcessTrackMetadata(IMetadata consumer, Author artist, BookFile trackFile, List existingMetadataFiles) + private MetadataFile ProcessTrackMetadata(IMetadata consumer, Author author, BookFile bookFile, List existingMetadataFiles) { - var trackMetadata = consumer.TrackMetadata(artist, trackFile); + var trackMetadata = consumer.TrackMetadata(author, bookFile); if (trackMetadata == null) { return null; } - var fullPath = Path.Combine(artist.Path, trackMetadata.RelativePath); + var fullPath = Path.Combine(author.Path, trackMetadata.RelativePath); - _otherExtraFileRenamer.RenameOtherExtraFile(artist, fullPath); + _otherExtraFileRenamer.RenameOtherExtraFile(author, fullPath); - var existingMetadata = GetMetadataFile(artist, existingMetadataFiles, c => c.Type == MetadataType.TrackMetadata && - c.TrackFileId == trackFile.Id); + var existingMetadata = GetMetadataFile(author, existingMetadataFiles, c => c.Type == MetadataType.TrackMetadata && + c.BookFileId == bookFile.Id); if (existingMetadata != null) { - var existingFullPath = Path.Combine(artist.Path, existingMetadata.RelativePath); + var existingFullPath = Path.Combine(author.Path, existingMetadata.RelativePath); if (fullPath.PathNotEquals(existingFullPath)) { _diskTransferService.TransferFile(existingFullPath, fullPath, TransferMode.Move); @@ -342,9 +342,9 @@ namespace NzbDrone.Core.Extras.Metadata var metadata = existingMetadata ?? new MetadataFile { - AuthorId = artist.Id, - BookId = trackFile.BookId, - TrackFileId = trackFile.Id, + AuthorId = author.Id, + BookId = bookFile.BookId, + BookFileId = bookFile.Id, Consumer = consumer.GetType().Name, Type = MetadataType.TrackMetadata, RelativePath = trackMetadata.RelativePath, @@ -364,34 +364,34 @@ namespace NzbDrone.Core.Extras.Metadata return metadata; } - private List ProcessArtistImages(IMetadata consumer, Author artist, List existingMetadataFiles) + private List ProcessArtistImages(IMetadata consumer, Author author, List existingMetadataFiles) { var result = new List(); - foreach (var image in consumer.ArtistImages(artist)) + foreach (var image in consumer.ArtistImages(author)) { - var fullPath = Path.Combine(artist.Path, image.RelativePath); + var fullPath = Path.Combine(author.Path, image.RelativePath); if (_diskProvider.FileExists(fullPath)) { - _logger.Debug("Artist image already exists: {0}", fullPath); + _logger.Debug("Author image already exists: {0}", fullPath); continue; } - _otherExtraFileRenamer.RenameOtherExtraFile(artist, fullPath); + _otherExtraFileRenamer.RenameOtherExtraFile(author, fullPath); - var metadata = GetMetadataFile(artist, existingMetadataFiles, c => c.Type == MetadataType.ArtistImage && + var metadata = GetMetadataFile(author, existingMetadataFiles, c => c.Type == MetadataType.ArtistImage && c.RelativePath == image.RelativePath) ?? new MetadataFile { - AuthorId = artist.Id, + AuthorId = author.Id, Consumer = consumer.GetType().Name, Type = MetadataType.ArtistImage, RelativePath = image.RelativePath, Extension = Path.GetExtension(fullPath) }; - DownloadImage(artist, image); + DownloadImage(author, image); result.Add(metadata); } @@ -399,13 +399,13 @@ namespace NzbDrone.Core.Extras.Metadata return result; } - private List ProcessAlbumImages(IMetadata consumer, Author artist, Book album, string albumFolder, List existingMetadataFiles) + private List ProcessAlbumImages(IMetadata consumer, Author author, Book book, string albumFolder, List existingMetadataFiles) { var result = new List(); - foreach (var image in consumer.AlbumImages(artist, album, albumFolder)) + foreach (var image in consumer.AlbumImages(author, book, albumFolder)) { - var fullPath = Path.Combine(artist.Path, image.RelativePath); + var fullPath = Path.Combine(author.Path, image.RelativePath); if (_diskProvider.FileExists(fullPath)) { @@ -413,22 +413,22 @@ namespace NzbDrone.Core.Extras.Metadata continue; } - _otherExtraFileRenamer.RenameOtherExtraFile(artist, fullPath); + _otherExtraFileRenamer.RenameOtherExtraFile(author, fullPath); - var metadata = GetMetadataFile(artist, existingMetadataFiles, c => c.Type == MetadataType.AlbumImage && - c.BookId == album.Id && + var metadata = GetMetadataFile(author, existingMetadataFiles, c => c.Type == MetadataType.AlbumImage && + c.BookId == book.Id && c.RelativePath == image.RelativePath) ?? new MetadataFile { - AuthorId = artist.Id, - BookId = album.Id, + AuthorId = author.Id, + BookId = book.Id, Consumer = consumer.GetType().Name, Type = MetadataType.AlbumImage, RelativePath = image.RelativePath, Extension = Path.GetExtension(fullPath) }; - DownloadImage(artist, image); + DownloadImage(author, image); result.Add(metadata); } @@ -436,9 +436,9 @@ namespace NzbDrone.Core.Extras.Metadata return result; } - private void DownloadImage(Author artist, ImageFileResult image) + private void DownloadImage(Author author, ImageFileResult image) { - var fullPath = Path.Combine(artist.Path, image.RelativePath); + var fullPath = Path.Combine(author.Path, image.RelativePath); try { @@ -455,11 +455,11 @@ namespace NzbDrone.Core.Extras.Metadata } catch (WebException ex) { - _logger.Warn(ex, "Couldn't download image {0} for {1}. {2}", image.Url, artist, ex.Message); + _logger.Warn(ex, "Couldn't download image {0} for {1}. {2}", image.Url, author, ex.Message); } catch (Exception ex) { - _logger.Error(ex, "Couldn't download image {0} for {1}", image.Url, artist); + _logger.Error(ex, "Couldn't download image {0} for {1}", image.Url, author); } } @@ -469,7 +469,7 @@ namespace NzbDrone.Core.Extras.Metadata _mediaFileAttributeService.SetFilePermissions(path); } - private MetadataFile GetMetadataFile(Author artist, List existingMetadataFiles, Func predicate) + private MetadataFile GetMetadataFile(Author author, List existingMetadataFiles, Func predicate) { var matchingMetadataFiles = existingMetadataFiles.Where(predicate).ToList(); @@ -481,11 +481,11 @@ namespace NzbDrone.Core.Extras.Metadata //Remove duplicate metadata files from DB and disk foreach (var file in matchingMetadataFiles.Skip(1)) { - var path = Path.Combine(artist.Path, file.RelativePath); + var path = Path.Combine(author.Path, file.RelativePath); _logger.Debug("Removing duplicate Metadata file: {0}", path); - var subfolder = _diskProvider.GetParentFolder(artist.Path).GetRelativePath(_diskProvider.GetParentFolder(path)); + var subfolder = _diskProvider.GetParentFolder(author.Path).GetRelativePath(_diskProvider.GetParentFolder(path)); _recycleBinProvider.DeleteFile(path, subfolder); _metadataFileService.Delete(file.Id); } diff --git a/src/NzbDrone.Core/Extras/Others/ExistingOtherExtraImporter.cs b/src/NzbDrone.Core/Extras/Others/ExistingOtherExtraImporter.cs index 7c5ea6fc1..5dd56dc19 100644 --- a/src/NzbDrone.Core/Extras/Others/ExistingOtherExtraImporter.cs +++ b/src/NzbDrone.Core/Extras/Others/ExistingOtherExtraImporter.cs @@ -3,9 +3,9 @@ using System.IO; using System.Linq; using NLog; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.Extras.Files; -using NzbDrone.Core.MediaFiles.TrackImport.Aggregation; -using NzbDrone.Core.Music; +using NzbDrone.Core.MediaFiles.BookImport.Aggregation; using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.Extras.Others @@ -28,12 +28,12 @@ namespace NzbDrone.Core.Extras.Others public override int Order => 2; - public override IEnumerable ProcessFiles(Author artist, List filesOnDisk, List importedFiles) + public override IEnumerable ProcessFiles(Author author, List filesOnDisk, List importedFiles) { - _logger.Debug("Looking for existing extra files in {0}", artist.Path); + _logger.Debug("Looking for existing extra files in {0}", author.Path); var extraFiles = new List(); - var filterResult = FilterAndClean(artist, filesOnDisk, importedFiles); + var filterResult = FilterAndClean(author, filesOnDisk, importedFiles); foreach (var possibleExtraFile in filterResult.FilesOnDisk) { @@ -45,10 +45,10 @@ namespace NzbDrone.Core.Extras.Others continue; } - var localTrack = new LocalTrack + var localTrack = new LocalBook { FileTrackInfo = Parser.Parser.ParseMusicPath(possibleExtraFile), - Artist = artist, + Author = author, Path = possibleExtraFile }; @@ -62,7 +62,7 @@ namespace NzbDrone.Core.Extras.Others continue; } - if (localTrack.Album == null) + if (localTrack.Book == null) { _logger.Debug("Cannot find related book for: {0}", possibleExtraFile); continue; @@ -70,9 +70,9 @@ namespace NzbDrone.Core.Extras.Others var extraFile = new OtherExtraFile { - AuthorId = artist.Id, - BookId = localTrack.Album.Id, - RelativePath = artist.Path.GetRelativePath(possibleExtraFile), + AuthorId = author.Id, + BookId = localTrack.Book.Id, + RelativePath = author.Path.GetRelativePath(possibleExtraFile), Extension = extension }; diff --git a/src/NzbDrone.Core/Extras/Others/OtherExtraFileRenamer.cs b/src/NzbDrone.Core/Extras/Others/OtherExtraFileRenamer.cs index 26548cae4..8f4bec1e6 100644 --- a/src/NzbDrone.Core/Extras/Others/OtherExtraFileRenamer.cs +++ b/src/NzbDrone.Core/Extras/Others/OtherExtraFileRenamer.cs @@ -2,14 +2,14 @@ using System.IO; using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; namespace NzbDrone.Core.Extras.Others { public interface IOtherExtraFileRenamer { - void RenameOtherExtraFile(Author artist, string path); + void RenameOtherExtraFile(Author author, string path); } public class OtherExtraFileRenamer : IOtherExtraFileRenamer @@ -17,11 +17,11 @@ namespace NzbDrone.Core.Extras.Others private readonly Logger _logger; private readonly IDiskProvider _diskProvider; private readonly IRecycleBinProvider _recycleBinProvider; - private readonly IArtistService _artistService; + private readonly IAuthorService _authorService; private readonly IOtherExtraFileService _otherExtraFileService; public OtherExtraFileRenamer(IOtherExtraFileService otherExtraFileService, - IArtistService artistService, + IAuthorService authorService, IRecycleBinProvider recycleBinProvider, IDiskProvider diskProvider, Logger logger) @@ -29,18 +29,18 @@ namespace NzbDrone.Core.Extras.Others _logger = logger; _diskProvider = diskProvider; _recycleBinProvider = recycleBinProvider; - _artistService = artistService; + _authorService = authorService; _otherExtraFileService = otherExtraFileService; } - public void RenameOtherExtraFile(Author artist, string path) + public void RenameOtherExtraFile(Author author, string path) { if (!_diskProvider.FileExists(path)) { return; } - var relativePath = artist.Path.GetRelativePath(path); + var relativePath = author.Path.GetRelativePath(path); var otherExtraFile = _otherExtraFileService.FindByPath(relativePath); if (otherExtraFile != null) @@ -48,7 +48,7 @@ namespace NzbDrone.Core.Extras.Others var newPath = path + "-orig"; // Recycle an existing -orig file. - RemoveOtherExtraFile(artist, newPath); + RemoveOtherExtraFile(author, newPath); // Rename the file to .*-orig _diskProvider.MoveFile(path, newPath); @@ -58,14 +58,14 @@ namespace NzbDrone.Core.Extras.Others } } - private void RemoveOtherExtraFile(Author artist, string path) + private void RemoveOtherExtraFile(Author author, string path) { if (!_diskProvider.FileExists(path)) { return; } - var relativePath = artist.Path.GetRelativePath(path); + var relativePath = author.Path.GetRelativePath(path); var otherExtraFile = _otherExtraFileService.FindByPath(relativePath); if (otherExtraFile != null) diff --git a/src/NzbDrone.Core/Extras/Others/OtherExtraFileService.cs b/src/NzbDrone.Core/Extras/Others/OtherExtraFileService.cs index 063d75f86..e187157fe 100644 --- a/src/NzbDrone.Core/Extras/Others/OtherExtraFileService.cs +++ b/src/NzbDrone.Core/Extras/Others/OtherExtraFileService.cs @@ -1,8 +1,8 @@ using NLog; using NzbDrone.Common.Disk; +using NzbDrone.Core.Books; using NzbDrone.Core.Extras.Files; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; namespace NzbDrone.Core.Extras.Others { @@ -12,8 +12,8 @@ namespace NzbDrone.Core.Extras.Others public class OtherExtraFileService : ExtraFileService, IOtherExtraFileService { - public OtherExtraFileService(IExtraFileRepository repository, IArtistService artistService, IDiskProvider diskProvider, IRecycleBinProvider recycleBinProvider, Logger logger) - : base(repository, artistService, diskProvider, recycleBinProvider, logger) + public OtherExtraFileService(IExtraFileRepository repository, IAuthorService authorService, IDiskProvider diskProvider, IRecycleBinProvider recycleBinProvider, Logger logger) + : base(repository, authorService, diskProvider, recycleBinProvider, logger) { } } diff --git a/src/NzbDrone.Core/Extras/Others/OtherExtraService.cs b/src/NzbDrone.Core/Extras/Others/OtherExtraService.cs index 63e4b3be7..b93c74348 100644 --- a/src/NzbDrone.Core/Extras/Others/OtherExtraService.cs +++ b/src/NzbDrone.Core/Extras/Others/OtherExtraService.cs @@ -3,10 +3,10 @@ using System.Linq; using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; using NzbDrone.Core.Extras.Files; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; namespace NzbDrone.Core.Extras.Others { @@ -26,33 +26,33 @@ namespace NzbDrone.Core.Extras.Others public override int Order => 2; - public override IEnumerable CreateAfterArtistScan(Author artist, List trackFiles) + public override IEnumerable CreateAfterAuthorScan(Author author, List bookFiles) { return Enumerable.Empty(); } - public override IEnumerable CreateAfterTrackImport(Author artist, BookFile trackFile) + public override IEnumerable CreateAfterTrackImport(Author author, BookFile bookFile) { return Enumerable.Empty(); } - public override IEnumerable CreateAfterTrackImport(Author artist, Book album, string artistFolder, string albumFolder) + public override IEnumerable CreateAfterBookImport(Author author, Book book, string artistFolder, string albumFolder) { return Enumerable.Empty(); } - public override IEnumerable MoveFilesAfterRename(Author artist, List trackFiles) + public override IEnumerable MoveFilesAfterRename(Author author, List bookFiles) { - var extraFiles = _otherExtraFileService.GetFilesByArtist(artist.Id); + var extraFiles = _otherExtraFileService.GetFilesByArtist(author.Id); var movedFiles = new List(); - foreach (var trackFile in trackFiles) + foreach (var bookFile in bookFiles) { - var extraFilesForTrackFile = extraFiles.Where(m => m.TrackFileId == trackFile.Id).ToList(); + var extraFilesForTrackFile = extraFiles.Where(m => m.BookFileId == bookFile.Id).ToList(); foreach (var extraFile in extraFilesForTrackFile) { - movedFiles.AddIfNotNull(MoveFile(artist, trackFile, extraFile)); + movedFiles.AddIfNotNull(MoveFile(author, bookFile, extraFile)); } } @@ -61,9 +61,9 @@ namespace NzbDrone.Core.Extras.Others return movedFiles; } - public override ExtraFile Import(Author artist, BookFile trackFile, string path, string extension, bool readOnly) + public override ExtraFile Import(Author author, BookFile bookFile, string path, string extension, bool readOnly) { - var extraFile = ImportFile(artist, trackFile, path, readOnly, extension, null); + var extraFile = ImportFile(author, bookFile, path, readOnly, extension, null); _otherExtraFileService.Upsert(extraFile); diff --git a/src/NzbDrone.Core/HealthCheck/Checks/MountCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/MountCheck.cs index 91129d1c8..5c642825a 100644 --- a/src/NzbDrone.Core/HealthCheck/Checks/MountCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/Checks/MountCheck.cs @@ -1,33 +1,33 @@ using System.Linq; using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; namespace NzbDrone.Core.HealthCheck.Checks { public class MountCheck : HealthCheckBase { private readonly IDiskProvider _diskProvider; - private readonly IArtistService _artistService; + private readonly IAuthorService _authorService; - public MountCheck(IDiskProvider diskProvider, IArtistService artistService) + public MountCheck(IDiskProvider diskProvider, IAuthorService authorService) { _diskProvider = diskProvider; - _artistService = artistService; + _authorService = authorService; } public override HealthCheck Check() { // Not best for optimization but due to possible symlinks and junctions, we get mounts based on series path so internals can handle mount resolution. - var mounts = _artistService.GetAllArtists() - .Select(artist => _diskProvider.GetMount(artist.Path)) + var mounts = _authorService.GetAllAuthors() + .Select(author => _diskProvider.GetMount(author.Path)) .Where(m => m != null && m.MountOptions != null && m.MountOptions.IsReadOnly) .DistinctBy(m => m.RootDirectory) .ToList(); if (mounts.Any()) { - return new HealthCheck(GetType(), HealthCheckResult.Error, "Mount containing a artist path is mounted read-only: " + string.Join(",", mounts.Select(m => m.Name)), "#artist-mount-ro"); + return new HealthCheck(GetType(), HealthCheckResult.Error, "Mount containing a author path is mounted read-only: " + string.Join(",", mounts.Select(m => m.Name)), "#author-mount-ro"); } return new HealthCheck(GetType()); diff --git a/src/NzbDrone.Core/HealthCheck/Checks/RemotePathMappingCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/RemotePathMappingCheck.cs index c702999c8..08c723d14 100644 --- a/src/NzbDrone.Core/HealthCheck/Checks/RemotePathMappingCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/Checks/RemotePathMappingCheck.cs @@ -106,9 +106,9 @@ namespace NzbDrone.Core.HealthCheck.Checks var failureMessage = (TrackImportFailedEvent)message; // if we can see the file exists but the import failed then likely a permissions issue - if (failureMessage.TrackInfo != null) + if (failureMessage.BookInfo != null) { - var trackPath = failureMessage.TrackInfo.Path; + var trackPath = failureMessage.BookInfo.Path; if (_diskProvider.FileExists(trackPath)) { return new HealthCheck(GetType(), HealthCheckResult.Error, $"Readarr can see but not access downloaded track {trackPath}. Likely permissions error.", "#permissions-error"); diff --git a/src/NzbDrone.Core/HealthCheck/Checks/RootFolderCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/RootFolderCheck.cs index ecdaf5e24..c74655174 100644 --- a/src/NzbDrone.Core/HealthCheck/Checks/RootFolderCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/Checks/RootFolderCheck.cs @@ -1,32 +1,32 @@ using System.Linq; using NzbDrone.Common.Disk; +using NzbDrone.Core.Books; +using NzbDrone.Core.Books.Events; using NzbDrone.Core.ImportLists; using NzbDrone.Core.MediaFiles.Events; -using NzbDrone.Core.Music; -using NzbDrone.Core.Music.Events; namespace NzbDrone.Core.HealthCheck.Checks { - [CheckOn(typeof(ArtistDeletedEvent))] - [CheckOn(typeof(ArtistMovedEvent))] + [CheckOn(typeof(AuthorDeletedEvent))] + [CheckOn(typeof(AuthorMovedEvent))] [CheckOn(typeof(TrackImportedEvent), CheckOnCondition.FailedOnly)] [CheckOn(typeof(TrackImportFailedEvent), CheckOnCondition.SuccessfulOnly)] public class RootFolderCheck : HealthCheckBase { - private readonly IArtistService _artistService; + private readonly IAuthorService _authorService; private readonly IImportListFactory _importListFactory; private readonly IDiskProvider _diskProvider; - public RootFolderCheck(IArtistService artistService, IImportListFactory importListFactory, IDiskProvider diskProvider) + public RootFolderCheck(IAuthorService authorService, IImportListFactory importListFactory, IDiskProvider diskProvider) { - _artistService = artistService; + _authorService = authorService; _importListFactory = importListFactory; _diskProvider = diskProvider; } public override HealthCheck Check() { - var missingRootFolders = _artistService.GetAllArtists() + var missingRootFolders = _authorService.GetAllAuthors() .Select(s => _diskProvider.GetParentFolder(s.Path)) .Distinct() .Where(s => !_diskProvider.FolderExists(s)) diff --git a/src/NzbDrone.Core/History/History.cs b/src/NzbDrone.Core/History/History.cs index 18aa78a60..bebed95f0 100644 --- a/src/NzbDrone.Core/History/History.cs +++ b/src/NzbDrone.Core/History/History.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; -using NzbDrone.Core.Music; using NzbDrone.Core.Qualities; namespace NzbDrone.Core.History @@ -20,8 +20,8 @@ namespace NzbDrone.Core.History public string SourceTitle { get; set; } public QualityModel Quality { get; set; } public DateTime Date { get; set; } - public Book Album { get; set; } - public Author Artist { get; set; } + public Book Book { get; set; } + public Author Author { get; set; } public HistoryEventType EventType { get; set; } public Dictionary Data { get; set; } @@ -37,7 +37,7 @@ namespace NzbDrone.Core.History DownloadFailed = 4, TrackFileDeleted = 5, TrackFileRenamed = 6, - AlbumImportIncomplete = 7, + BookImportIncomplete = 7, DownloadImported = 8, TrackFileRetagged = 9, DownloadIgnored = 10 diff --git a/src/NzbDrone.Core/History/HistoryRepository.cs b/src/NzbDrone.Core/History/HistoryRepository.cs index d674bc251..c7d5b0ab5 100644 --- a/src/NzbDrone.Core/History/HistoryRepository.cs +++ b/src/NzbDrone.Core/History/HistoryRepository.cs @@ -1,22 +1,22 @@ using System; using System.Collections.Generic; using System.Linq; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; using NzbDrone.Core.Qualities; namespace NzbDrone.Core.History { public interface IHistoryRepository : IBasicRepository { - History MostRecentForAlbum(int bookId); + History MostRecentForBook(int bookId); History MostRecentForDownloadId(string downloadId); List FindByDownloadId(string downloadId); - List GetByArtist(int authorId, HistoryEventType? eventType); - List GetByAlbum(int bookId, HistoryEventType? eventType); + List GetByAuthor(int authorId, HistoryEventType? eventType); + List GetByBook(int bookId, HistoryEventType? eventType); List FindDownloadHistory(int idAuthorId, QualityModel quality); - void DeleteForArtist(int authorId); + void DeleteForAuthor(int authorId); List Since(DateTime date, HistoryEventType? eventType); } @@ -27,7 +27,7 @@ namespace NzbDrone.Core.History { } - public History MostRecentForAlbum(int bookId) + public History MostRecentForBook(int bookId) { return Query(h => h.BookId == bookId) .OrderByDescending(h => h.Date) @@ -48,15 +48,15 @@ namespace NzbDrone.Core.History .Join((h, a) => h.AuthorId == a.Id) .Join((h, a) => h.BookId == a.Id) .Where(h => h.DownloadId == downloadId), - (history, artist, album) => + (history, author, book) => { - history.Artist = artist; - history.Album = album; + history.Author = author; + history.Book = book; return history; }).ToList(); } - public List GetByArtist(int authorId, HistoryEventType? eventType) + public List GetByAuthor(int authorId, HistoryEventType? eventType) { var builder = Builder().Where(h => h.AuthorId == authorId); @@ -68,7 +68,7 @@ namespace NzbDrone.Core.History return Query(builder).OrderByDescending(h => h.Date).ToList(); } - public List GetByAlbum(int bookId, HistoryEventType? eventType) + public List GetByBook(int bookId, HistoryEventType? eventType) { var builder = Builder() .Join((h, a) => h.BookId == a.Id) @@ -81,9 +81,9 @@ namespace NzbDrone.Core.History return _database.QueryJoined( builder, - (history, album) => + (history, book) => { - history.Album = album; + history.Book = book; return history; }).OrderByDescending(h => h.Date).ToList(); } @@ -97,7 +97,7 @@ namespace NzbDrone.Core.History allowed.Contains(h.EventType)); } - public void DeleteForArtist(int authorId) + public void DeleteForAuthor(int authorId) { Delete(c => c.AuthorId == authorId); } @@ -107,10 +107,10 @@ namespace NzbDrone.Core.History .Join((h, a) => h.BookId == a.Id); protected override IEnumerable PagedQuery(SqlBuilder builder) => - _database.QueryJoined(builder, (history, artist, album) => + _database.QueryJoined(builder, (history, author, book) => { - history.Artist = artist; - history.Album = album; + history.Author = author; + history.Book = book; return history; }); diff --git a/src/NzbDrone.Core/History/HistoryService.cs b/src/NzbDrone.Core/History/HistoryService.cs index 6dcea9e92..a4ad30f94 100644 --- a/src/NzbDrone.Core/History/HistoryService.cs +++ b/src/NzbDrone.Core/History/HistoryService.cs @@ -5,12 +5,12 @@ using System.Linq; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Common.Serializer; +using NzbDrone.Core.Books.Events; using NzbDrone.Core.Datastore; using NzbDrone.Core.Download; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music.Events; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; @@ -19,11 +19,11 @@ namespace NzbDrone.Core.History public interface IHistoryService { PagingSpec Paged(PagingSpec pagingSpec); - History MostRecentForAlbum(int bookId); + History MostRecentForBook(int bookId); History MostRecentForDownloadId(string downloadId); History Get(int historyId); - List GetByArtist(int authorId, HistoryEventType? eventType); - List GetByAlbum(int bookId, HistoryEventType? eventType); + List GetByAuthor(int authorId, HistoryEventType? eventType); + List GetByBook(int bookId, HistoryEventType? eventType); List Find(string downloadId, HistoryEventType eventType); List FindByDownloadId(string downloadId); List Since(DateTime date, HistoryEventType? eventType); @@ -31,15 +31,15 @@ namespace NzbDrone.Core.History } public class HistoryService : IHistoryService, - IHandle, - IHandle, + IHandle, + IHandle, IHandle, IHandle, IHandle, - IHandle, - IHandle, - IHandle, - IHandle, + IHandle, + IHandle, + IHandle, + IHandle, IHandle { private readonly IHistoryRepository _historyRepository; @@ -56,9 +56,9 @@ namespace NzbDrone.Core.History return _historyRepository.GetPaged(pagingSpec); } - public History MostRecentForAlbum(int bookId) + public History MostRecentForBook(int bookId) { - return _historyRepository.MostRecentForAlbum(bookId); + return _historyRepository.MostRecentForBook(bookId); } public History MostRecentForDownloadId(string downloadId) @@ -71,14 +71,14 @@ namespace NzbDrone.Core.History return _historyRepository.Get(historyId); } - public List GetByArtist(int authorId, HistoryEventType? eventType) + public List GetByAuthor(int authorId, HistoryEventType? eventType) { - return _historyRepository.GetByArtist(authorId, eventType); + return _historyRepository.GetByAuthor(authorId, eventType); } - public List GetByAlbum(int bookId, HistoryEventType? eventType) + public List GetByBook(int bookId, HistoryEventType? eventType) { - return _historyRepository.GetByAlbum(bookId, eventType); + return _historyRepository.GetByBook(bookId, eventType); } public List Find(string downloadId, HistoryEventType eventType) @@ -93,11 +93,11 @@ namespace NzbDrone.Core.History private string FindDownloadId(TrackImportedEvent trackedDownload) { - _logger.Debug("Trying to find downloadId for {0} from history", trackedDownload.ImportedTrack.Path); + _logger.Debug("Trying to find downloadId for {0} from history", trackedDownload.ImportedBook.Path); - var bookIds = new List { trackedDownload.TrackInfo.Album.Id }; + var bookIds = new List { trackedDownload.BookInfo.Book.Id }; - var allHistory = _historyRepository.FindDownloadHistory(trackedDownload.TrackInfo.Artist.Id, trackedDownload.ImportedTrack.Quality); + var allHistory = _historyRepository.FindDownloadHistory(trackedDownload.BookInfo.Author.Id, trackedDownload.ImportedBook.Quality); //Find download related items for these episdoes var albumsHistory = allHistory.Where(h => bookIds.Contains(h.BookId)).ToList(); @@ -112,7 +112,7 @@ namespace NzbDrone.Core.History if (stillDownloading.Any()) { - var matchingHistory = stillDownloading.Where(c => c.BookId == trackedDownload.TrackInfo.Album.Id).ToList(); + var matchingHistory = stillDownloading.Where(c => c.BookId == trackedDownload.BookInfo.Book.Id).ToList(); if (matchingHistory.Count != 1) { @@ -134,41 +134,41 @@ namespace NzbDrone.Core.History return downloadId; } - public void Handle(AlbumGrabbedEvent message) + public void Handle(BookGrabbedEvent message) { - foreach (var album in message.Album.Albums) + foreach (var book in message.Book.Books) { var history = new History { EventType = HistoryEventType.Grabbed, Date = DateTime.UtcNow, - Quality = message.Album.ParsedAlbumInfo.Quality, - SourceTitle = message.Album.Release.Title, - AuthorId = album.AuthorId, - BookId = album.Id, + Quality = message.Book.ParsedBookInfo.Quality, + SourceTitle = message.Book.Release.Title, + AuthorId = book.AuthorId, + BookId = book.Id, DownloadId = message.DownloadId }; - history.Data.Add("Indexer", message.Album.Release.Indexer); - history.Data.Add("NzbInfoUrl", message.Album.Release.InfoUrl); - history.Data.Add("ReleaseGroup", message.Album.ParsedAlbumInfo.ReleaseGroup); - history.Data.Add("Age", message.Album.Release.Age.ToString()); - history.Data.Add("AgeHours", message.Album.Release.AgeHours.ToString()); - history.Data.Add("AgeMinutes", message.Album.Release.AgeMinutes.ToString()); - history.Data.Add("PublishedDate", message.Album.Release.PublishDate.ToString("s") + "Z"); + history.Data.Add("Indexer", message.Book.Release.Indexer); + history.Data.Add("NzbInfoUrl", message.Book.Release.InfoUrl); + history.Data.Add("ReleaseGroup", message.Book.ParsedBookInfo.ReleaseGroup); + history.Data.Add("Age", message.Book.Release.Age.ToString()); + history.Data.Add("AgeHours", message.Book.Release.AgeHours.ToString()); + history.Data.Add("AgeMinutes", message.Book.Release.AgeMinutes.ToString()); + history.Data.Add("PublishedDate", message.Book.Release.PublishDate.ToString("s") + "Z"); history.Data.Add("DownloadClient", message.DownloadClient); - history.Data.Add("Size", message.Album.Release.Size.ToString()); - history.Data.Add("DownloadUrl", message.Album.Release.DownloadUrl); - history.Data.Add("Guid", message.Album.Release.Guid); - history.Data.Add("Protocol", ((int)message.Album.Release.DownloadProtocol).ToString()); - history.Data.Add("DownloadForced", (!message.Album.DownloadAllowed).ToString()); + history.Data.Add("Size", message.Book.Release.Size.ToString()); + history.Data.Add("DownloadUrl", message.Book.Release.DownloadUrl); + history.Data.Add("Guid", message.Book.Release.Guid); + history.Data.Add("Protocol", ((int)message.Book.Release.DownloadProtocol).ToString()); + history.Data.Add("DownloadForced", (!message.Book.DownloadAllowed).ToString()); - if (!message.Album.ParsedAlbumInfo.ReleaseHash.IsNullOrWhiteSpace()) + if (!message.Book.ParsedBookInfo.ReleaseHash.IsNullOrWhiteSpace()) { - history.Data.Add("ReleaseHash", message.Album.ParsedAlbumInfo.ReleaseHash); + history.Data.Add("ReleaseHash", message.Book.ParsedBookInfo.ReleaseHash); } - var torrentRelease = message.Album.Release as TorrentInfo; + var torrentRelease = message.Book.Release as TorrentInfo; if (torrentRelease != null) { @@ -179,18 +179,18 @@ namespace NzbDrone.Core.History } } - public void Handle(AlbumImportIncompleteEvent message) + public void Handle(BookImportIncompleteEvent message) { - foreach (var album in message.TrackedDownload.RemoteAlbum.Albums) + foreach (var book in message.TrackedDownload.RemoteBook.Books) { var history = new History { - EventType = HistoryEventType.AlbumImportIncomplete, + EventType = HistoryEventType.BookImportIncomplete, Date = DateTime.UtcNow, - Quality = message.TrackedDownload.RemoteAlbum.ParsedAlbumInfo?.Quality ?? new QualityModel(), + Quality = message.TrackedDownload.RemoteBook.ParsedBookInfo?.Quality ?? new QualityModel(), SourceTitle = message.TrackedDownload.DownloadItem.Title, - AuthorId = album.AuthorId, - BookId = album.Id, + AuthorId = book.AuthorId, + BookId = book.Id, DownloadId = message.TrackedDownload.DownloadItem.DownloadId }; @@ -217,17 +217,17 @@ namespace NzbDrone.Core.History { EventType = HistoryEventType.TrackFileImported, Date = DateTime.UtcNow, - Quality = message.TrackInfo.Quality, - SourceTitle = message.ImportedTrack.SceneName ?? Path.GetFileNameWithoutExtension(message.TrackInfo.Path), - AuthorId = message.TrackInfo.Artist.Id, - BookId = message.TrackInfo.Album.Id, + Quality = message.BookInfo.Quality, + SourceTitle = message.ImportedBook.SceneName ?? Path.GetFileNameWithoutExtension(message.BookInfo.Path), + AuthorId = message.BookInfo.Author.Id, + BookId = message.BookInfo.Book.Id, DownloadId = downloadId }; //Won't have a value since we publish this event before saving to DB. //history.Data.Add("FileId", message.ImportedEpisode.Id.ToString()); - history.Data.Add("DroppedPath", message.TrackInfo.Path); - history.Data.Add("ImportedPath", message.ImportedTrack.Path); + history.Data.Add("DroppedPath", message.BookInfo.Path); + history.Data.Add("ImportedPath", message.ImportedBook.Path); history.Data.Add("DownloadClient", message.DownloadClient); _historyRepository.Insert(history); @@ -257,16 +257,16 @@ namespace NzbDrone.Core.History public void Handle(DownloadCompletedEvent message) { - foreach (var album in message.TrackedDownload.RemoteAlbum.Albums) + foreach (var book in message.TrackedDownload.RemoteBook.Books) { var history = new History { EventType = HistoryEventType.DownloadImported, Date = DateTime.UtcNow, - Quality = message.TrackedDownload.RemoteAlbum.ParsedAlbumInfo?.Quality ?? new QualityModel(), + Quality = message.TrackedDownload.RemoteBook.ParsedBookInfo?.Quality ?? new QualityModel(), SourceTitle = message.TrackedDownload.DownloadItem.Title, - AuthorId = album.AuthorId, - BookId = album.Id, + AuthorId = book.AuthorId, + BookId = book.Id, DownloadId = message.TrackedDownload.DownloadItem.DownloadId }; @@ -274,16 +274,16 @@ namespace NzbDrone.Core.History } } - public void Handle(TrackFileDeletedEvent message) + public void Handle(BookFileDeletedEvent message) { if (message.Reason == DeleteMediaFileReason.NoLinkedEpisodes) { - _logger.Debug("Removing track file from DB as part of cleanup routine, not creating history event."); + _logger.Debug("Removing book file from DB as part of cleanup routine, not creating history event."); return; } else if (message.Reason == DeleteMediaFileReason.ManualOverride) { - _logger.Debug("Removing track file from DB as part of manual override of existing file, not creating history event."); + _logger.Debug("Removing book file from DB as part of manual override of existing file, not creating history event."); return; } @@ -291,10 +291,10 @@ namespace NzbDrone.Core.History { EventType = HistoryEventType.TrackFileDeleted, Date = DateTime.UtcNow, - Quality = message.TrackFile.Quality, - SourceTitle = message.TrackFile.Path, - AuthorId = message.TrackFile.Artist.Value.Id, - BookId = message.TrackFile.BookId + Quality = message.BookFile.Quality, + SourceTitle = message.BookFile.Path, + AuthorId = message.BookFile.Author.Value.Id, + BookId = message.BookFile.BookId }; history.Data.Add("Reason", message.Reason.ToString()); @@ -302,19 +302,19 @@ namespace NzbDrone.Core.History _historyRepository.Insert(history); } - public void Handle(TrackFileRenamedEvent message) + public void Handle(BookFileRenamedEvent message) { var sourcePath = message.OriginalPath; - var path = message.TrackFile.Path; + var path = message.BookFile.Path; var history = new History { EventType = HistoryEventType.TrackFileRenamed, Date = DateTime.UtcNow, - Quality = message.TrackFile.Quality, + Quality = message.BookFile.Quality, SourceTitle = message.OriginalPath, - AuthorId = message.TrackFile.Artist.Value.Id, - BookId = message.TrackFile.BookId + AuthorId = message.BookFile.Author.Value.Id, + BookId = message.BookFile.BookId }; history.Data.Add("SourcePath", sourcePath); @@ -323,18 +323,18 @@ namespace NzbDrone.Core.History _historyRepository.Insert(history); } - public void Handle(TrackFileRetaggedEvent message) + public void Handle(BookFileRetaggedEvent message) { - var path = message.TrackFile.Path; + var path = message.BookFile.Path; var history = new History { EventType = HistoryEventType.TrackFileRetagged, Date = DateTime.UtcNow, - Quality = message.TrackFile.Quality, + Quality = message.BookFile.Quality, SourceTitle = path, - AuthorId = message.TrackFile.Artist.Value.Id, - BookId = message.TrackFile.BookId + AuthorId = message.BookFile.Author.Value.Id, + BookId = message.BookFile.BookId }; history.Data.Add("TagsScrubbed", message.Scrubbed.ToString()); @@ -348,9 +348,9 @@ namespace NzbDrone.Core.History _historyRepository.Insert(history); } - public void Handle(ArtistDeletedEvent message) + public void Handle(AuthorDeletedEvent message) { - _historyRepository.DeleteForArtist(message.Artist.Id); + _historyRepository.DeleteForAuthor(message.Author.Id); } public void Handle(DownloadIgnoredEvent message) diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupDuplicateMetadataFiles.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupDuplicateMetadataFiles.cs index f69d856ba..e436e4f93 100644 --- a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupDuplicateMetadataFiles.cs +++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupDuplicateMetadataFiles.cs @@ -56,8 +56,8 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers WHERE Id IN ( SELECT Id FROM MetadataFiles WHERE Type = 2 - GROUP BY TrackFileId, Consumer - HAVING COUNT(TrackFileId) > 1 + GROUP BY BookFileId, Consumer + HAVING COUNT(BookFileId) > 1 )"); } } @@ -70,8 +70,8 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers WHERE Id IN ( SELECT Id FROM MetadataFiles WHERE Type = 5 - GROUP BY TrackFileId, Consumer - HAVING COUNT(TrackFileId) > 1 + GROUP BY BookFileId, Consumer + HAVING COUNT(BookFileId) > 1 )"); } } diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedArtistMetadata.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedAuthorMetadata.cs similarity index 100% rename from src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedArtistMetadata.cs rename to src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedAuthorMetadata.cs diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedTrackFiles.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedBookFiles.cs similarity index 100% rename from src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedTrackFiles.cs rename to src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedBookFiles.cs diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedAlbums.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedBooks.cs similarity index 100% rename from src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedAlbums.cs rename to src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedBooks.cs diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedMetadataFiles.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedMetadataFiles.cs index 750aa7dcb..f33003c05 100644 --- a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedMetadataFiles.cs +++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedMetadataFiles.cs @@ -56,8 +56,8 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers WHERE Id IN ( SELECT MetadataFiles.Id FROM MetadataFiles LEFT OUTER JOIN BookFiles - ON MetadataFiles.TrackFileId = BookFiles.Id - WHERE MetadataFiles.TrackFileId > 0 + ON MetadataFiles.BookFileId = BookFiles.Id + WHERE MetadataFiles.BookFileId > 0 AND BookFiles.Id IS NULL)"); } } @@ -82,7 +82,7 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers WHERE Id IN ( SELECT Id FROM MetadataFiles WHERE Type IN (2, 5) - AND TrackFileId = 0)"); + AND BookFileId = 0)"); } } } diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/DeleteBadMediaCovers.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/DeleteBadMediaCovers.cs index becadec0e..2f20417f6 100644 --- a/src/NzbDrone.Core/Housekeeping/Housekeepers/DeleteBadMediaCovers.cs +++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/DeleteBadMediaCovers.cs @@ -4,28 +4,28 @@ using System.IO; using System.Linq; using NLog; using NzbDrone.Common.Disk; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; using NzbDrone.Core.Extras.Metadata.Files; -using NzbDrone.Core.Music; namespace NzbDrone.Core.Housekeeping.Housekeepers { public class DeleteBadMediaCovers : IHousekeepingTask { private readonly IMetadataFileService _metaFileService; - private readonly IArtistService _artistService; + private readonly IAuthorService _authorService; private readonly IDiskProvider _diskProvider; private readonly IConfigService _configService; private readonly Logger _logger; public DeleteBadMediaCovers(IMetadataFileService metaFileService, - IArtistService artistService, + IAuthorService authorService, IDiskProvider diskProvider, IConfigService configService, Logger logger) { _metaFileService = metaFileService; - _artistService = artistService; + _authorService = authorService; _diskProvider = diskProvider; _configService = configService; _logger = logger; @@ -38,19 +38,19 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers return; } - var artists = _artistService.GetAllArtists(); + var artists = _authorService.GetAllAuthors(); var imageExtensions = new List { ".jpg", ".png", ".gif" }; - foreach (var artist in artists) + foreach (var author in artists) { - var images = _metaFileService.GetFilesByArtist(artist.Id) + var images = _metaFileService.GetFilesByArtist(author.Id) .Where(c => c.LastUpdated > new DateTime(2014, 12, 27) && imageExtensions.Any(x => c.RelativePath.EndsWith(x, StringComparison.InvariantCultureIgnoreCase))); foreach (var image in images) { try { - var path = Path.Combine(artist.Path, image.RelativePath); + var path = Path.Combine(author.Path, image.RelativePath); if (!IsValid(path)) { _logger.Debug("Deleting invalid image file " + path); diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForArtist.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForArtist.cs deleted file mode 100644 index f8649e5d6..000000000 --- a/src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForArtist.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Linq; -using NzbDrone.Core.Music; -using NzbDrone.Core.Parser; - -namespace NzbDrone.Core.Housekeeping.Housekeepers -{ - public class UpdateCleanTitleForArtist : IHousekeepingTask - { - private readonly IArtistRepository _artistRepository; - - public UpdateCleanTitleForArtist(IArtistRepository artistRepository) - { - _artistRepository = artistRepository; - } - - public void Clean() - { - var artists = _artistRepository.All().ToList(); - - artists.ForEach(s => - { - var cleanName = s.Name.CleanArtistName(); - if (s.CleanName != cleanName) - { - s.CleanName = cleanName; - _artistRepository.Update(s); - } - }); - } - } -} diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForAuthor.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForAuthor.cs new file mode 100644 index 000000000..9923d1605 --- /dev/null +++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForAuthor.cs @@ -0,0 +1,31 @@ +using System.Linq; +using NzbDrone.Core.Books; +using NzbDrone.Core.Parser; + +namespace NzbDrone.Core.Housekeeping.Housekeepers +{ + public class UpdateCleanTitleForAuthor : IHousekeepingTask + { + private readonly IAuthorRepository _authorRepository; + + public UpdateCleanTitleForAuthor(IAuthorRepository authorRepository) + { + _authorRepository = authorRepository; + } + + public void Clean() + { + var authors = _authorRepository.All().ToList(); + + authors.ForEach(s => + { + var cleanName = s.Name.CleanAuthorName(); + if (s.CleanName != cleanName) + { + s.CleanName = cleanName; + _authorRepository.Update(s); + } + }); + } + } +} diff --git a/src/NzbDrone.Core/ImportLists/Exclusions/ImportListExclusionService.cs b/src/NzbDrone.Core/ImportLists/Exclusions/ImportListExclusionService.cs index 3bdf2544f..c5c46527d 100644 --- a/src/NzbDrone.Core/ImportLists/Exclusions/ImportListExclusionService.cs +++ b/src/NzbDrone.Core/ImportLists/Exclusions/ImportListExclusionService.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; +using NzbDrone.Core.Books.Events; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music.Events; namespace NzbDrone.Core.ImportLists.Exclusions { @@ -18,8 +18,8 @@ namespace NzbDrone.Core.ImportLists.Exclusions } public class ImportListExclusionService : IImportListExclusionService, - IHandleAsync, - IHandleAsync + IHandleAsync, + IHandleAsync { private readonly IImportListExclusionRepository _repo; @@ -72,14 +72,14 @@ namespace NzbDrone.Core.ImportLists.Exclusions return _repo.All().ToList(); } - public void HandleAsync(ArtistDeletedEvent message) + public void HandleAsync(AuthorDeletedEvent message) { if (!message.AddImportListExclusion) { return; } - var existingExclusion = _repo.FindByForeignId(message.Artist.ForeignAuthorId); + var existingExclusion = _repo.FindByForeignId(message.Author.ForeignAuthorId); if (existingExclusion != null) { @@ -88,21 +88,21 @@ namespace NzbDrone.Core.ImportLists.Exclusions var importExclusion = new ImportListExclusion { - ForeignId = message.Artist.ForeignAuthorId, - Name = message.Artist.Name + ForeignId = message.Author.ForeignAuthorId, + Name = message.Author.Name }; _repo.Insert(importExclusion); } - public void HandleAsync(AlbumDeletedEvent message) + public void HandleAsync(BookDeletedEvent message) { if (!message.AddImportListExclusion) { return; } - var existingExclusion = _repo.FindByForeignId(message.Album.ForeignBookId); + var existingExclusion = _repo.FindByForeignId(message.Book.ForeignBookId); if (existingExclusion != null) { @@ -111,8 +111,8 @@ namespace NzbDrone.Core.ImportLists.Exclusions var importExclusion = new ImportListExclusion { - ForeignId = message.Album.ForeignBookId, - Name = $"{message.Album.AuthorMetadata.Value.Name} - {message.Album.Title}" + ForeignId = message.Book.ForeignBookId, + Name = $"{message.Book.AuthorMetadata.Value.Name} - {message.Book.Title}" }; _repo.Insert(importExclusion); diff --git a/src/NzbDrone.Core/ImportLists/FetchAndParseImportListService.cs b/src/NzbDrone.Core/ImportLists/FetchAndParseImportListService.cs index 9a7678313..009f099f1 100644 --- a/src/NzbDrone.Core/ImportLists/FetchAndParseImportListService.cs +++ b/src/NzbDrone.Core/ImportLists/FetchAndParseImportListService.cs @@ -71,7 +71,7 @@ namespace NzbDrone.Core.ImportLists Task.WaitAll(taskList.ToArray()); - result = result.DistinctBy(r => new { r.Artist, r.Album }).ToList(); + result = result.DistinctBy(r => new { r.Author, r.Book }).ToList(); _logger.Debug("Found {0} reports", result.Count); @@ -118,7 +118,7 @@ namespace NzbDrone.Core.ImportLists Task.WaitAll(taskList.ToArray()); - result = result.DistinctBy(r => new { r.Artist, r.Album }).ToList(); + result = result.DistinctBy(r => new { r.Author, r.Book }).ToList(); return result; } diff --git a/src/NzbDrone.Core/ImportLists/Goodreads/GoodreadsBookshelf.cs b/src/NzbDrone.Core/ImportLists/Goodreads/GoodreadsBookshelf.cs index 576f1b8b8..ea576fd3f 100644 --- a/src/NzbDrone.Core/ImportLists/Goodreads/GoodreadsBookshelf.cs +++ b/src/NzbDrone.Core/ImportLists/Goodreads/GoodreadsBookshelf.cs @@ -49,8 +49,8 @@ namespace NzbDrone.Core.ImportLists.Goodreads return reviews.Select(x => new ImportListItemInfo { - Artist = x.Book.Authors.First().Name.CleanSpaces(), - Album = x.Book.TitleWithoutSeries.CleanSpaces(), + Author = x.Book.Authors.First().Name.CleanSpaces(), + Book = x.Book.TitleWithoutSeries.CleanSpaces(), AlbumMusicBrainzId = x.Book.Uri.Replace("kca://book/", string.Empty) }).ToList(); } diff --git a/src/NzbDrone.Core/ImportLists/Goodreads/GoodreadsOwnedBooks.cs b/src/NzbDrone.Core/ImportLists/Goodreads/GoodreadsOwnedBooks.cs index 54c9002e1..5f38d9387 100644 --- a/src/NzbDrone.Core/ImportLists/Goodreads/GoodreadsOwnedBooks.cs +++ b/src/NzbDrone.Core/ImportLists/Goodreads/GoodreadsOwnedBooks.cs @@ -48,9 +48,9 @@ namespace NzbDrone.Core.ImportLists.Goodreads var result = reviews.Select(x => new ImportListItemInfo { - Artist = x.Book.Authors.First().Name.CleanSpaces(), + Author = x.Book.Authors.First().Name.CleanSpaces(), ArtistMusicBrainzId = x.Book.Authors.First().Id.ToString(), - Album = x.Book.TitleWithoutSeries.CleanSpaces(), + Book = x.Book.TitleWithoutSeries.CleanSpaces(), AlbumMusicBrainzId = x.Book.Id.ToString() }).ToList(); diff --git a/src/NzbDrone.Core/ImportLists/HttpImportListBase.cs b/src/NzbDrone.Core/ImportLists/HttpImportListBase.cs index 8907726e2..192f5562e 100644 --- a/src/NzbDrone.Core/ImportLists/HttpImportListBase.cs +++ b/src/NzbDrone.Core/ImportLists/HttpImportListBase.cs @@ -166,7 +166,7 @@ namespace NzbDrone.Core.ImportLists protected virtual bool IsValidRelease(ImportListItemInfo release) { - if (release.Album.IsNullOrWhiteSpace() && release.Artist.IsNullOrWhiteSpace()) + if (release.Book.IsNullOrWhiteSpace() && release.Author.IsNullOrWhiteSpace()) { return false; } diff --git a/src/NzbDrone.Core/ImportLists/ImportListBase.cs b/src/NzbDrone.Core/ImportLists/ImportListBase.cs index d92a6d66e..25b999f58 100644 --- a/src/NzbDrone.Core/ImportLists/ImportListBase.cs +++ b/src/NzbDrone.Core/ImportLists/ImportListBase.cs @@ -64,7 +64,7 @@ namespace NzbDrone.Core.ImportLists protected virtual IList CleanupListItems(IEnumerable releases) { - var result = releases.DistinctBy(r => new { r.Artist, r.Album }).ToList(); + var result = releases.DistinctBy(r => new { r.Author, r.Book }).ToList(); result.ForEach(c => { diff --git a/src/NzbDrone.Core/ImportLists/ImportListSyncCompleteEvent.cs b/src/NzbDrone.Core/ImportLists/ImportListSyncCompleteEvent.cs index e84d61d43..f41a435ad 100644 --- a/src/NzbDrone.Core/ImportLists/ImportListSyncCompleteEvent.cs +++ b/src/NzbDrone.Core/ImportLists/ImportListSyncCompleteEvent.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using NzbDrone.Common.Messaging; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; namespace NzbDrone.Core.ImportLists { diff --git a/src/NzbDrone.Core/ImportLists/ImportListSyncService.cs b/src/NzbDrone.Core/ImportLists/ImportListSyncService.cs index 5b8ef4aca..ced1dee09 100644 --- a/src/NzbDrone.Core/ImportLists/ImportListSyncService.cs +++ b/src/NzbDrone.Core/ImportLists/ImportListSyncService.cs @@ -3,12 +3,12 @@ using System.Linq; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Common.Instrumentation.Extensions; +using NzbDrone.Core.Books; +using NzbDrone.Core.Books.Commands; using NzbDrone.Core.ImportLists.Exclusions; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.MetadataSource; -using NzbDrone.Core.Music; -using NzbDrone.Core.Music.Commands; using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.ImportLists @@ -18,12 +18,12 @@ namespace NzbDrone.Core.ImportLists private readonly IImportListFactory _importListFactory; private readonly IImportListExclusionService _importListExclusionService; private readonly IFetchAndParseImportList _listFetcherAndParser; - private readonly ISearchForNewBook _albumSearchService; - private readonly ISearchForNewAuthor _artistSearchService; - private readonly IArtistService _artistService; - private readonly IAlbumService _albumService; - private readonly IAddArtistService _addArtistService; - private readonly IAddAlbumService _addAlbumService; + private readonly ISearchForNewBook _bookSearchService; + private readonly ISearchForNewAuthor _authorSearchService; + private readonly IAuthorService _authorService; + private readonly IBookService _bookService; + private readonly IAddAuthorService _addAuthorService; + private readonly IAddBookService _addBookService; private readonly IEventAggregator _eventAggregator; private readonly IManageCommandQueue _commandQueueManager; private readonly Logger _logger; @@ -31,12 +31,12 @@ namespace NzbDrone.Core.ImportLists public ImportListSyncService(IImportListFactory importListFactory, IImportListExclusionService importListExclusionService, IFetchAndParseImportList listFetcherAndParser, - ISearchForNewBook albumSearchService, - ISearchForNewAuthor artistSearchService, - IArtistService artistService, - IAlbumService albumService, - IAddArtistService addArtistService, - IAddAlbumService addAlbumService, + ISearchForNewBook bookSearchService, + ISearchForNewAuthor authorSearchService, + IAuthorService authorService, + IBookService bookService, + IAddAuthorService addAuthorService, + IAddBookService addBookService, IEventAggregator eventAggregator, IManageCommandQueue commandQueueManager, Logger logger) @@ -44,12 +44,12 @@ namespace NzbDrone.Core.ImportLists _importListFactory = importListFactory; _importListExclusionService = importListExclusionService; _listFetcherAndParser = listFetcherAndParser; - _albumSearchService = albumSearchService; - _artistSearchService = artistSearchService; - _artistService = artistService; - _albumService = albumService; - _addArtistService = addArtistService; - _addAlbumService = addAlbumService; + _bookSearchService = bookSearchService; + _authorSearchService = authorSearchService; + _authorService = authorService; + _bookService = bookService; + _addAuthorService = addAuthorService; + _addBookService = addBookService; _eventAggregator = eventAggregator; _commandQueueManager = commandQueueManager; _logger = logger; @@ -97,7 +97,7 @@ namespace NzbDrone.Core.ImportLists var importList = _importListFactory.Get(report.ImportListId); - if (report.Album.IsNotNullOrWhiteSpace() || report.AlbumMusicBrainzId.IsNotNullOrWhiteSpace()) + if (report.Book.IsNotNullOrWhiteSpace() || report.AlbumMusicBrainzId.IsNotNullOrWhiteSpace()) { if (report.AlbumMusicBrainzId.IsNullOrWhiteSpace() || report.ArtistMusicBrainzId.IsNullOrWhiteSpace()) { @@ -106,7 +106,7 @@ namespace NzbDrone.Core.ImportLists ProcessAlbumReport(importList, report, listExclusions, albumsToAdd); } - else if (report.Artist.IsNotNullOrWhiteSpace() || report.ArtistMusicBrainzId.IsNotNullOrWhiteSpace()) + else if (report.Author.IsNotNullOrWhiteSpace() || report.ArtistMusicBrainzId.IsNotNullOrWhiteSpace()) { if (report.ArtistMusicBrainzId.IsNullOrWhiteSpace()) { @@ -117,17 +117,17 @@ namespace NzbDrone.Core.ImportLists } } - var addedArtists = _addArtistService.AddArtists(artistsToAdd, false); - var addedAlbums = _addAlbumService.AddAlbums(albumsToAdd, false); + var addedArtists = _addAuthorService.AddAuthors(artistsToAdd, false); + var addedAlbums = _addBookService.AddBooks(albumsToAdd, false); - var message = string.Format($"Import List Sync Completed. Items found: {reports.Count}, Artists added: {artistsToAdd.Count}, Albums added: {albumsToAdd.Count}"); + var message = string.Format($"Import List Sync Completed. Items found: {reports.Count}, Authors added: {artistsToAdd.Count}, Books added: {albumsToAdd.Count}"); _logger.ProgressInfo(message); var toRefresh = addedArtists.Select(x => x.Id).Concat(addedAlbums.Select(x => x.Author.Value.Id)).Distinct().ToList(); if (toRefresh.Any()) { - _commandQueueManager.Push(new BulkRefreshArtistCommand(toRefresh, true)); + _commandQueueManager.Push(new BulkRefreshAuthorCommand(toRefresh, true)); } return processed; @@ -139,14 +139,14 @@ namespace NzbDrone.Core.ImportLists if (report.AlbumMusicBrainzId.IsNotNullOrWhiteSpace() && int.TryParse(report.AlbumMusicBrainzId, out var goodreadsId)) { - mappedAlbum = _albumSearchService.SearchByGoodreadsId(goodreadsId).FirstOrDefault(x => x.GoodreadsId == goodreadsId); + mappedAlbum = _bookSearchService.SearchByGoodreadsId(goodreadsId).FirstOrDefault(x => x.GoodreadsId == goodreadsId); } else { - mappedAlbum = _albumSearchService.SearchForNewBook(report.Album, report.Artist).FirstOrDefault(); + mappedAlbum = _bookSearchService.SearchForNewBook(report.Book, report.Author).FirstOrDefault(); } - // Break if we are looking for an album and cant find it. This will avoid us from adding the artist and possibly getting it wrong. + // Break if we are looking for an book and cant find it. This will avoid us from adding the author and possibly getting it wrong. if (mappedAlbum == null) { _logger.Trace($"Nothing found for {report.AlbumMusicBrainzId}"); @@ -157,8 +157,8 @@ namespace NzbDrone.Core.ImportLists _logger.Trace($"Mapped {report.AlbumMusicBrainzId} to {mappedAlbum}"); report.AlbumMusicBrainzId = mappedAlbum.ForeignBookId; - report.Album = mappedAlbum.Title; - report.Artist = mappedAlbum.AuthorMetadata?.Value?.Name; + report.Book = mappedAlbum.Title; + report.Author = mappedAlbum.AuthorMetadata?.Value?.Name; report.ArtistMusicBrainzId = mappedAlbum.AuthorMetadata?.Value?.ForeignAuthorId; } @@ -169,30 +169,30 @@ namespace NzbDrone.Core.ImportLists return; } - // Check to see if album in DB - var existingAlbum = _albumService.FindById(report.AlbumMusicBrainzId); + // Check to see if book in DB + var existingAlbum = _bookService.FindById(report.AlbumMusicBrainzId); if (existingAlbum != null) { - _logger.Debug("{0} [{1}] Rejected, Album Exists in DB", report.AlbumMusicBrainzId, report.Album); + _logger.Debug("{0} [{1}] Rejected, Book Exists in DB", report.AlbumMusicBrainzId, report.Book); return; } - // Check to see if album excluded + // Check to see if book excluded var excludedAlbum = listExclusions.SingleOrDefault(s => s.ForeignId == report.AlbumMusicBrainzId); if (excludedAlbum != null) { - _logger.Debug("{0} [{1}] Rejected due to list exlcusion", report.AlbumMusicBrainzId, report.Album); + _logger.Debug("{0} [{1}] Rejected due to list exlcusion", report.AlbumMusicBrainzId, report.Book); return; } - // Check to see if artist excluded + // Check to see if author excluded var excludedArtist = listExclusions.SingleOrDefault(s => s.ForeignId == report.ArtistMusicBrainzId); if (excludedArtist != null) { - _logger.Debug("{0} [{1}] Rejected due to list exlcusion for parent artist", report.AlbumMusicBrainzId, report.Album); + _logger.Debug("{0} [{1}] Rejected due to list exlcusion for parent author", report.AlbumMusicBrainzId, report.Book); return; } @@ -212,7 +212,7 @@ namespace NzbDrone.Core.ImportLists QualityProfileId = importList.ProfileId, MetadataProfileId = importList.MetadataProfileId, Tags = importList.Tags, - AddOptions = new AddArtistOptions + AddOptions = new AddAuthorOptions { SearchForMissingAlbums = monitored, Monitored = monitored, @@ -223,7 +223,7 @@ namespace NzbDrone.Core.ImportLists if (importList.ShouldMonitor == ImportListMonitorType.SpecificAlbum) { - toAdd.Author.Value.AddOptions.AlbumsToMonitor.Add(toAdd.ForeignBookId); + toAdd.Author.Value.AddOptions.BooksToMonitor.Add(toAdd.ForeignBookId); } albumsToAdd.Add(toAdd); @@ -232,10 +232,10 @@ namespace NzbDrone.Core.ImportLists private void MapArtistReport(ImportListItemInfo report) { - var mappedArtist = _artistSearchService.SearchForNewAuthor(report.Artist) + var mappedArtist = _authorSearchService.SearchForNewAuthor(report.Author) .FirstOrDefault(); report.ArtistMusicBrainzId = mappedArtist?.Metadata.Value?.ForeignAuthorId; - report.Artist = mappedArtist?.Metadata.Value?.Name; + report.Author = mappedArtist?.Metadata.Value?.Name; } private void ProcessArtistReport(ImportListDefinition importList, ImportListItemInfo report, List listExclusions, List artistsToAdd) @@ -245,25 +245,25 @@ namespace NzbDrone.Core.ImportLists return; } - // Check to see if artist in DB - var existingArtist = _artistService.FindById(report.ArtistMusicBrainzId); + // Check to see if author in DB + var existingArtist = _authorService.FindById(report.ArtistMusicBrainzId); if (existingArtist != null) { - _logger.Debug("{0} [{1}] Rejected, Artist Exists in DB", report.ArtistMusicBrainzId, report.Artist); + _logger.Debug("{0} [{1}] Rejected, Author Exists in DB", report.ArtistMusicBrainzId, report.Author); return; } - // Check to see if artist excluded + // Check to see if author excluded var excludedArtist = listExclusions.Where(s => s.ForeignId == report.ArtistMusicBrainzId).SingleOrDefault(); if (excludedArtist != null) { - _logger.Debug("{0} [{1}] Rejected due to list exlcusion", report.ArtistMusicBrainzId, report.Artist); + _logger.Debug("{0} [{1}] Rejected due to list exlcusion", report.ArtistMusicBrainzId, report.Author); return; } - // Append Artist if not already in DB or already on add list + // Append Author if not already in DB or already on add list if (artistsToAdd.All(s => s.Metadata.Value.ForeignAuthorId != report.ArtistMusicBrainzId)) { var monitored = importList.ShouldMonitor != ImportListMonitorType.None; @@ -273,14 +273,14 @@ namespace NzbDrone.Core.ImportLists Metadata = new AuthorMetadata { ForeignAuthorId = report.ArtistMusicBrainzId, - Name = report.Artist + Name = report.Author }, Monitored = monitored, RootFolderPath = importList.RootFolderPath, QualityProfileId = importList.ProfileId, MetadataProfileId = importList.MetadataProfileId, Tags = importList.Tags, - AddOptions = new AddArtistOptions + AddOptions = new AddAuthorOptions { SearchForMissingAlbums = monitored, Monitored = monitored, diff --git a/src/NzbDrone.Core/ImportLists/LazyLibrarian/LazyLibrarianImportParser.cs b/src/NzbDrone.Core/ImportLists/LazyLibrarian/LazyLibrarianImportParser.cs index 06dd86477..9b18580a8 100644 --- a/src/NzbDrone.Core/ImportLists/LazyLibrarian/LazyLibrarianImportParser.cs +++ b/src/NzbDrone.Core/ImportLists/LazyLibrarian/LazyLibrarianImportParser.cs @@ -34,8 +34,8 @@ namespace NzbDrone.Core.ImportLists.LazyLibrarianImport { items.AddIfNotNull(new ImportListItemInfo { - Artist = item.AuthorName, - Album = item.BookName, + Author = item.AuthorName, + Book = item.BookName, AlbumMusicBrainzId = item.BookId }); } diff --git a/src/NzbDrone.Core/IndexerSearch/ArtistSearchCommand.cs b/src/NzbDrone.Core/IndexerSearch/AuthorSearchCommand.cs similarity index 80% rename from src/NzbDrone.Core/IndexerSearch/ArtistSearchCommand.cs rename to src/NzbDrone.Core/IndexerSearch/AuthorSearchCommand.cs index d5c3bd9ce..1896e1ba3 100644 --- a/src/NzbDrone.Core/IndexerSearch/ArtistSearchCommand.cs +++ b/src/NzbDrone.Core/IndexerSearch/AuthorSearchCommand.cs @@ -2,7 +2,7 @@ namespace NzbDrone.Core.IndexerSearch { - public class ArtistSearchCommand : Command + public class AuthorSearchCommand : Command { public int AuthorId { get; set; } diff --git a/src/NzbDrone.Core/IndexerSearch/ArtistSearchService.cs b/src/NzbDrone.Core/IndexerSearch/AuthorSearchService.cs similarity index 78% rename from src/NzbDrone.Core/IndexerSearch/ArtistSearchService.cs rename to src/NzbDrone.Core/IndexerSearch/AuthorSearchService.cs index e80b1cfce..7893a7a26 100644 --- a/src/NzbDrone.Core/IndexerSearch/ArtistSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/AuthorSearchService.cs @@ -5,13 +5,13 @@ using NzbDrone.Core.Messaging.Commands; namespace NzbDrone.Core.IndexerSearch { - public class ArtistSearchService : IExecute + public class AuthorSearchService : IExecute { private readonly ISearchForNzb _nzbSearchService; private readonly IProcessDownloadDecisions _processDownloadDecisions; private readonly Logger _logger; - public ArtistSearchService(ISearchForNzb nzbSearchService, + public AuthorSearchService(ISearchForNzb nzbSearchService, IProcessDownloadDecisions processDownloadDecisions, Logger logger) { @@ -20,12 +20,12 @@ namespace NzbDrone.Core.IndexerSearch _logger = logger; } - public void Execute(ArtistSearchCommand message) + public void Execute(AuthorSearchCommand message) { var decisions = _nzbSearchService.ArtistSearch(message.AuthorId, false, message.Trigger == CommandTrigger.Manual, false); var processed = _processDownloadDecisions.ProcessDecisions(decisions); - _logger.ProgressInfo("Artist search completed. {0} reports downloaded.", processed.Grabbed.Count); + _logger.ProgressInfo("Author search completed. {0} reports downloaded.", processed.Grabbed.Count); } } } diff --git a/src/NzbDrone.Core/IndexerSearch/AlbumSearchCommand.cs b/src/NzbDrone.Core/IndexerSearch/BookSearchCommand.cs similarity index 69% rename from src/NzbDrone.Core/IndexerSearch/AlbumSearchCommand.cs rename to src/NzbDrone.Core/IndexerSearch/BookSearchCommand.cs index c0a4c873e..c12d0ef1a 100644 --- a/src/NzbDrone.Core/IndexerSearch/AlbumSearchCommand.cs +++ b/src/NzbDrone.Core/IndexerSearch/BookSearchCommand.cs @@ -3,17 +3,17 @@ using NzbDrone.Core.Messaging.Commands; namespace NzbDrone.Core.IndexerSearch { - public class AlbumSearchCommand : Command + public class BookSearchCommand : Command { public List BookIds { get; set; } public override bool SendUpdatesToClient => true; - public AlbumSearchCommand() + public BookSearchCommand() { } - public AlbumSearchCommand(List bookIds) + public BookSearchCommand(List bookIds) { BookIds = bookIds; } diff --git a/src/NzbDrone.Core/IndexerSearch/AlbumSearchService.cs b/src/NzbDrone.Core/IndexerSearch/BookSearchService.cs similarity index 61% rename from src/NzbDrone.Core/IndexerSearch/AlbumSearchService.cs rename to src/NzbDrone.Core/IndexerSearch/BookSearchService.cs index cca7fb8b1..4bad2da65 100644 --- a/src/NzbDrone.Core/IndexerSearch/AlbumSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/BookSearchService.cs @@ -4,59 +4,59 @@ using System.Linq; using System.Linq.Expressions; using NLog; using NzbDrone.Common.Instrumentation.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Messaging.Commands; -using NzbDrone.Core.Music; using NzbDrone.Core.Queue; namespace NzbDrone.Core.IndexerSearch { - internal class AlbumSearchService : IExecute, - IExecute, - IExecute + internal class BookSearchService : IExecute, + IExecute, + IExecute { private readonly ISearchForNzb _nzbSearchService; - private readonly IAlbumService _albumService; - private readonly IAlbumCutoffService _albumCutoffService; + private readonly IBookService _bookService; + private readonly IBookCutoffService _bookCutoffService; private readonly IQueueService _queueService; private readonly IProcessDownloadDecisions _processDownloadDecisions; private readonly Logger _logger; - public AlbumSearchService(ISearchForNzb nzbSearchService, - IAlbumService albumService, - IAlbumCutoffService albumCutoffService, + public BookSearchService(ISearchForNzb nzbSearchService, + IBookService bookService, + IBookCutoffService albumCutoffService, IQueueService queueService, IProcessDownloadDecisions processDownloadDecisions, Logger logger) { _nzbSearchService = nzbSearchService; - _albumService = albumService; - _albumCutoffService = albumCutoffService; + _bookService = bookService; + _bookCutoffService = albumCutoffService; _queueService = queueService; _processDownloadDecisions = processDownloadDecisions; _logger = logger; } - private void SearchForMissingAlbums(List albums, bool userInvokedSearch) + private void SearchForMissingBooks(List books, bool userInvokedSearch) { - _logger.ProgressInfo("Performing missing search for {0} albums", albums.Count); + _logger.ProgressInfo("Performing missing search for {0} books", books.Count); var downloadedCount = 0; - foreach (var album in albums) + foreach (var book in books) { List decisions; - decisions = _nzbSearchService.AlbumSearch(album.Id, false, userInvokedSearch, false); + decisions = _nzbSearchService.AlbumSearch(book.Id, false, userInvokedSearch, false); var processed = _processDownloadDecisions.ProcessDecisions(decisions); downloadedCount += processed.Grabbed.Count; } - _logger.ProgressInfo("Completed missing search for {0} albums. {1} reports downloaded.", albums.Count, downloadedCount); + _logger.ProgressInfo("Completed missing search for {0} books. {1} reports downloaded.", books.Count, downloadedCount); } - public void Execute(AlbumSearchCommand message) + public void Execute(BookSearchCommand message) { foreach (var bookId in message.BookIds) { @@ -64,11 +64,11 @@ namespace NzbDrone.Core.IndexerSearch _nzbSearchService.AlbumSearch(bookId, false, message.Trigger == CommandTrigger.Manual, false); var processed = _processDownloadDecisions.ProcessDecisions(decisions); - _logger.ProgressInfo("Album search completed. {0} reports downloaded.", processed.Grabbed.Count); + _logger.ProgressInfo("Book search completed. {0} reports downloaded.", processed.Grabbed.Count); } } - public void Execute(MissingAlbumSearchCommand message) + public void Execute(MissingBookSearchCommand message) { List albums; @@ -86,7 +86,7 @@ namespace NzbDrone.Core.IndexerSearch pagingSpec.FilterExpressions.Add(v => v.Monitored == true && v.Author.Value.Monitored == true); - albums = _albumService.AlbumsWithoutFiles(pagingSpec).Records.Where(e => e.AuthorId.Equals(authorId)).ToList(); + albums = _bookService.BooksWithoutFiles(pagingSpec).Records.Where(e => e.AuthorId.Equals(authorId)).ToList(); } else { @@ -100,16 +100,16 @@ namespace NzbDrone.Core.IndexerSearch pagingSpec.FilterExpressions.Add(v => v.Monitored == true && v.Author.Value.Monitored == true); - albums = _albumService.AlbumsWithoutFiles(pagingSpec).Records.ToList(); + albums = _bookService.BooksWithoutFiles(pagingSpec).Records.ToList(); } - var queue = _queueService.GetQueue().Where(q => q.Album != null).Select(q => q.Album.Id); + var queue = _queueService.GetQueue().Where(q => q.Book != null).Select(q => q.Book.Id); var missing = albums.Where(e => !queue.Contains(e.Id)).ToList(); - SearchForMissingAlbums(missing, message.Trigger == CommandTrigger.Manual); + SearchForMissingBooks(missing, message.Trigger == CommandTrigger.Manual); } - public void Execute(CutoffUnmetAlbumSearchCommand message) + public void Execute(CutoffUnmetBookSearchCommand message) { Expression> filterExpression; @@ -127,12 +127,12 @@ namespace NzbDrone.Core.IndexerSearch pagingSpec.FilterExpressions.Add(filterExpression); - var albums = _albumCutoffService.AlbumsWhereCutoffUnmet(pagingSpec).Records.ToList(); + var books = _bookCutoffService.BooksWhereCutoffUnmet(pagingSpec).Records.ToList(); - var queue = _queueService.GetQueue().Where(q => q.Album != null).Select(q => q.Album.Id); - var missing = albums.Where(e => !queue.Contains(e.Id)).ToList(); + var queue = _queueService.GetQueue().Where(q => q.Book != null).Select(q => q.Book.Id); + var missing = books.Where(e => !queue.Contains(e.Id)).ToList(); - SearchForMissingAlbums(missing, message.Trigger == CommandTrigger.Manual); + SearchForMissingBooks(missing, message.Trigger == CommandTrigger.Manual); } } } diff --git a/src/NzbDrone.Core/IndexerSearch/CutoffUnmetAlbumSearchCommand.cs b/src/NzbDrone.Core/IndexerSearch/CutoffUnmetBookSearchCommand.cs similarity index 62% rename from src/NzbDrone.Core/IndexerSearch/CutoffUnmetAlbumSearchCommand.cs rename to src/NzbDrone.Core/IndexerSearch/CutoffUnmetBookSearchCommand.cs index a74ead1f0..ca983ce35 100644 --- a/src/NzbDrone.Core/IndexerSearch/CutoffUnmetAlbumSearchCommand.cs +++ b/src/NzbDrone.Core/IndexerSearch/CutoffUnmetBookSearchCommand.cs @@ -2,17 +2,17 @@ using NzbDrone.Core.Messaging.Commands; namespace NzbDrone.Core.IndexerSearch { - public class CutoffUnmetAlbumSearchCommand : Command + public class CutoffUnmetBookSearchCommand : Command { public int? AuthorId { get; set; } public override bool SendUpdatesToClient => true; - public CutoffUnmetAlbumSearchCommand() + public CutoffUnmetBookSearchCommand() { } - public CutoffUnmetAlbumSearchCommand(int authorId) + public CutoffUnmetBookSearchCommand(int authorId) { AuthorId = authorId; } diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/AlbumSearchCriteria.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/AlbumSearchCriteria.cs deleted file mode 100644 index 3c46443f7..000000000 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/AlbumSearchCriteria.cs +++ /dev/null @@ -1,18 +0,0 @@ -using NzbDrone.Common.Extensions; - -namespace NzbDrone.Core.IndexerSearch.Definitions -{ - public class AlbumSearchCriteria : SearchCriteriaBase - { - public string AlbumTitle { get; set; } - public int AlbumYear { get; set; } - public string Disambiguation { get; set; } - - public string AlbumQuery => GetQueryTitle($"{AlbumTitle}{(Disambiguation.IsNullOrWhiteSpace() ? string.Empty : $"+{Disambiguation}")}"); - - public override string ToString() - { - return $"[{Artist.Name} - {AlbumTitle}{(Disambiguation.IsNullOrWhiteSpace() ? string.Empty : $" ({Disambiguation})")} ({AlbumYear})]"; - } - } -} diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/ArtistSearchCriteria.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/AuthorSearchCriteria.cs similarity index 57% rename from src/NzbDrone.Core/IndexerSearch/Definitions/ArtistSearchCriteria.cs rename to src/NzbDrone.Core/IndexerSearch/Definitions/AuthorSearchCriteria.cs index 4fa786200..8819c8caa 100644 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/ArtistSearchCriteria.cs +++ b/src/NzbDrone.Core/IndexerSearch/Definitions/AuthorSearchCriteria.cs @@ -1,10 +1,10 @@ namespace NzbDrone.Core.IndexerSearch.Definitions { - public class ArtistSearchCriteria : SearchCriteriaBase + public class AuthorSearchCriteria : SearchCriteriaBase { public override string ToString() { - return $"[{Artist.Name}]"; + return $"[{Author.Name}]"; } } } diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/BookSearchCriteria.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/BookSearchCriteria.cs new file mode 100644 index 000000000..8f433946c --- /dev/null +++ b/src/NzbDrone.Core/IndexerSearch/Definitions/BookSearchCriteria.cs @@ -0,0 +1,18 @@ +using NzbDrone.Common.Extensions; + +namespace NzbDrone.Core.IndexerSearch.Definitions +{ + public class BookSearchCriteria : SearchCriteriaBase + { + public string BookTitle { get; set; } + public int BookYear { get; set; } + public string Disambiguation { get; set; } + + public string AlbumQuery => GetQueryTitle($"{BookTitle}{(Disambiguation.IsNullOrWhiteSpace() ? string.Empty : $"+{Disambiguation}")}"); + + public override string ToString() + { + return $"[{Author.Name} - {BookTitle}{(Disambiguation.IsNullOrWhiteSpace() ? string.Empty : $" ({Disambiguation})")} ({BookYear})]"; + } + } +} diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs index 44c53fdb5..2ff64df2e 100644 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs +++ b/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text.RegularExpressions; using NzbDrone.Common.EnsureThat; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; namespace NzbDrone.Core.IndexerSearch.Definitions { @@ -12,20 +12,21 @@ 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); - public virtual bool MonitoredEpisodesOnly { get; set; } + public virtual bool MonitoredBooksOnly { get; set; } public virtual bool UserInvokedSearch { get; set; } public virtual bool InteractiveSearch { get; set; } - public Author Artist { get; set; } - public List Albums { get; set; } + public Author Author { get; set; } + public List Books { get; set; } - public string ArtistQuery => GetQueryTitle(Artist.Name); + public string ArtistQuery => GetQueryTitle(Author.Name); public static string GetQueryTitle(string title) { Ensure.That(title, () => title).IsNotNullOrWhiteSpace(); // Most VA albums are listed as VA, not Various Artists + // TODO: Needed in Readarr?? if (title == "Various Artists") { title = "VA"; diff --git a/src/NzbDrone.Core/IndexerSearch/MissingAlbumSearchCommand.cs b/src/NzbDrone.Core/IndexerSearch/MissingBookSearchCommand.cs similarity index 64% rename from src/NzbDrone.Core/IndexerSearch/MissingAlbumSearchCommand.cs rename to src/NzbDrone.Core/IndexerSearch/MissingBookSearchCommand.cs index 86d8f76fd..666fce447 100644 --- a/src/NzbDrone.Core/IndexerSearch/MissingAlbumSearchCommand.cs +++ b/src/NzbDrone.Core/IndexerSearch/MissingBookSearchCommand.cs @@ -2,17 +2,17 @@ using NzbDrone.Core.Messaging.Commands; namespace NzbDrone.Core.IndexerSearch { - public class MissingAlbumSearchCommand : Command + public class MissingBookSearchCommand : Command { public int? AuthorId { get; set; } public override bool SendUpdatesToClient => true; - public MissingAlbumSearchCommand() + public MissingBookSearchCommand() { } - public MissingAlbumSearchCommand(int authorId) + public MissingBookSearchCommand(int authorId) { AuthorId = authorId; } diff --git a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs index 8c3cb77ea..4b13f9359 100644 --- a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs @@ -6,10 +6,10 @@ using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Common.Instrumentation.Extensions; using NzbDrone.Common.TPL; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Indexers; using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.IndexerSearch @@ -23,86 +23,86 @@ namespace NzbDrone.Core.IndexerSearch public class NzbSearchService : ISearchForNzb { private readonly IIndexerFactory _indexerFactory; - private readonly IAlbumService _albumService; - private readonly IArtistService _artistService; + private readonly IBookService _bookService; + private readonly IAuthorService _authorService; private readonly IMakeDownloadDecision _makeDownloadDecision; private readonly Logger _logger; public NzbSearchService(IIndexerFactory indexerFactory, - IAlbumService albumService, - IArtistService artistService, + IBookService bookService, + IAuthorService authorService, IMakeDownloadDecision makeDownloadDecision, Logger logger) { _indexerFactory = indexerFactory; - _albumService = albumService; - _artistService = artistService; + _bookService = bookService; + _authorService = authorService; _makeDownloadDecision = makeDownloadDecision; _logger = logger; } public List AlbumSearch(int bookId, bool missingOnly, bool userInvokedSearch, bool interactiveSearch) { - var album = _albumService.GetAlbum(bookId); - return AlbumSearch(album, missingOnly, userInvokedSearch, interactiveSearch); + var book = _bookService.GetBook(bookId); + return AlbumSearch(book, missingOnly, userInvokedSearch, interactiveSearch); } public List ArtistSearch(int authorId, bool missingOnly, bool userInvokedSearch, bool interactiveSearch) { - var artist = _artistService.GetArtist(authorId); - return ArtistSearch(artist, missingOnly, userInvokedSearch, interactiveSearch); + var author = _authorService.GetAuthor(authorId); + return ArtistSearch(author, missingOnly, userInvokedSearch, interactiveSearch); } - public List ArtistSearch(Author artist, bool missingOnly, bool userInvokedSearch, bool interactiveSearch) + public List ArtistSearch(Author author, bool missingOnly, bool userInvokedSearch, bool interactiveSearch) { - var searchSpec = Get(artist, userInvokedSearch, interactiveSearch); - var albums = _albumService.GetAlbumsByArtist(artist.Id); + var searchSpec = Get(author, userInvokedSearch, interactiveSearch); + var albums = _bookService.GetBooksByAuthor(author.Id); albums = albums.Where(a => a.Monitored).ToList(); - searchSpec.Albums = albums; + searchSpec.Books = albums; return Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec); } - public List AlbumSearch(Book album, bool missingOnly, bool userInvokedSearch, bool interactiveSearch) + public List AlbumSearch(Book book, bool missingOnly, bool userInvokedSearch, bool interactiveSearch) { - var artist = _artistService.GetArtist(album.AuthorId); + var author = _authorService.GetAuthor(book.AuthorId); - var searchSpec = Get(artist, new List { album }, userInvokedSearch, interactiveSearch); + var searchSpec = Get(author, new List { book }, userInvokedSearch, interactiveSearch); - searchSpec.AlbumTitle = album.Title; - if (album.ReleaseDate.HasValue) + searchSpec.BookTitle = book.Title; + if (book.ReleaseDate.HasValue) { - searchSpec.AlbumYear = album.ReleaseDate.Value.Year; + searchSpec.BookYear = book.ReleaseDate.Value.Year; } - if (album.Disambiguation.IsNotNullOrWhiteSpace()) + if (book.Disambiguation.IsNotNullOrWhiteSpace()) { - searchSpec.Disambiguation = album.Disambiguation; + searchSpec.Disambiguation = book.Disambiguation; } return Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec); } - private TSpec Get(Author artist, List albums, bool userInvokedSearch, bool interactiveSearch) + private TSpec Get(Author author, List albums, bool userInvokedSearch, bool interactiveSearch) where TSpec : SearchCriteriaBase, new() { var spec = new TSpec(); - spec.Albums = albums; - spec.Artist = artist; + spec.Books = albums; + spec.Author = author; spec.UserInvokedSearch = userInvokedSearch; spec.InteractiveSearch = interactiveSearch; return spec; } - private static TSpec Get(Author artist, bool userInvokedSearch, bool interactiveSearch) + private static TSpec Get(Author author, bool userInvokedSearch, bool interactiveSearch) where TSpec : SearchCriteriaBase, new() { var spec = new TSpec(); - spec.Artist = artist; + spec.Author = author; spec.UserInvokedSearch = userInvokedSearch; spec.InteractiveSearch = interactiveSearch; diff --git a/src/NzbDrone.Core/Indexers/Gazelle/GazelleParser.cs b/src/NzbDrone.Core/Indexers/Gazelle/GazelleParser.cs index df3cdbf9d..160f42925 100644 --- a/src/NzbDrone.Core/Indexers/Gazelle/GazelleParser.cs +++ b/src/NzbDrone.Core/Indexers/Gazelle/GazelleParser.cs @@ -54,17 +54,17 @@ namespace NzbDrone.Core.Indexers.Gazelle foreach (var torrent in result.Torrents) { var id = torrent.TorrentId; - var artist = WebUtility.HtmlDecode(result.Artist); - var album = WebUtility.HtmlDecode(result.GroupName); + var author = WebUtility.HtmlDecode(result.Artist); + var book = WebUtility.HtmlDecode(result.GroupName); torrentInfos.Add(new GazelleInfo() { Guid = string.Format("Gazelle-{0}", id), - Artist = artist, + Author = author, // Splice Title from info to avoid calling API again for every torrent. Title = WebUtility.HtmlDecode(result.Artist + " - " + result.GroupName + " (" + result.GroupYear + ") [" + torrent.Format + " " + torrent.Encoding + "]"), - Album = album, + Book = book, Container = torrent.Encoding, Codec = torrent.Format, Size = long.Parse(torrent.Size), diff --git a/src/NzbDrone.Core/Indexers/Gazelle/GazelleRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Gazelle/GazelleRequestGenerator.cs index 0f15e1484..ef01d1bb6 100644 --- a/src/NzbDrone.Core/Indexers/Gazelle/GazelleRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Gazelle/GazelleRequestGenerator.cs @@ -26,14 +26,14 @@ namespace NzbDrone.Core.Indexers.Gazelle return pageableRequests; } - public IndexerPageableRequestChain GetSearchRequests(AlbumSearchCriteria searchCriteria) + public IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria) { var pageableRequests = new IndexerPageableRequestChain(); pageableRequests.Add(GetRequest(string.Format("&artistname={0}&groupname={1}", searchCriteria.ArtistQuery, searchCriteria.AlbumQuery))); return pageableRequests; } - public IndexerPageableRequestChain GetSearchRequests(ArtistSearchCriteria searchCriteria) + public IndexerPageableRequestChain GetSearchRequests(AuthorSearchCriteria searchCriteria) { var pageableRequests = new IndexerPageableRequestChain(); pageableRequests.Add(GetRequest(string.Format("&artistname={0}", searchCriteria.ArtistQuery))); diff --git a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs index d7d04acbb..13dbd98e0 100644 --- a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs +++ b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs @@ -48,7 +48,7 @@ namespace NzbDrone.Core.Indexers return FetchReleases(g => g.GetRecentRequests(), true); } - public override IList Fetch(AlbumSearchCriteria searchCriteria) + public override IList Fetch(BookSearchCriteria searchCriteria) { if (!SupportsSearch) { @@ -58,7 +58,7 @@ namespace NzbDrone.Core.Indexers return FetchReleases(g => g.GetSearchRequests(searchCriteria)); } - public override IList Fetch(ArtistSearchCriteria searchCriteria) + public override IList Fetch(AuthorSearchCriteria searchCriteria) { if (!SupportsSearch) { diff --git a/src/NzbDrone.Core/Indexers/IIndexer.cs b/src/NzbDrone.Core/Indexers/IIndexer.cs index 8e6847b8e..ecd5f1531 100644 --- a/src/NzbDrone.Core/Indexers/IIndexer.cs +++ b/src/NzbDrone.Core/Indexers/IIndexer.cs @@ -12,7 +12,7 @@ namespace NzbDrone.Core.Indexers DownloadProtocol Protocol { get; } IList FetchRecent(); - IList Fetch(AlbumSearchCriteria searchCriteria); - IList Fetch(ArtistSearchCriteria searchCriteria); + IList Fetch(BookSearchCriteria searchCriteria); + IList Fetch(AuthorSearchCriteria searchCriteria); } } diff --git a/src/NzbDrone.Core/Indexers/IIndexerRequestGenerator.cs b/src/NzbDrone.Core/Indexers/IIndexerRequestGenerator.cs index 776feee5b..cbd066ed3 100644 --- a/src/NzbDrone.Core/Indexers/IIndexerRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/IIndexerRequestGenerator.cs @@ -5,7 +5,7 @@ namespace NzbDrone.Core.Indexers public interface IIndexerRequestGenerator { IndexerPageableRequestChain GetRecentRequests(); - IndexerPageableRequestChain GetSearchRequests(AlbumSearchCriteria searchCriteria); - IndexerPageableRequestChain GetSearchRequests(ArtistSearchCriteria searchCriteria); + IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria); + IndexerPageableRequestChain GetSearchRequests(AuthorSearchCriteria searchCriteria); } } diff --git a/src/NzbDrone.Core/Indexers/IPTorrents/IPTorrentsRequestGenerator.cs b/src/NzbDrone.Core/Indexers/IPTorrents/IPTorrentsRequestGenerator.cs index e18b46808..bb5e66e11 100644 --- a/src/NzbDrone.Core/Indexers/IPTorrents/IPTorrentsRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/IPTorrents/IPTorrentsRequestGenerator.cs @@ -17,12 +17,12 @@ namespace NzbDrone.Core.Indexers.IPTorrents return pageableRequests; } - public virtual IndexerPageableRequestChain GetSearchRequests(AlbumSearchCriteria searchCriteria) + public virtual IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria) { throw new System.NotImplementedException(); } - public virtual IndexerPageableRequestChain GetSearchRequests(ArtistSearchCriteria searchCriteria) + public virtual IndexerPageableRequestChain GetSearchRequests(AuthorSearchCriteria searchCriteria) { throw new System.NotImplementedException(); } diff --git a/src/NzbDrone.Core/Indexers/IndexerBase.cs b/src/NzbDrone.Core/Indexers/IndexerBase.cs index feb5f5c27..6f0ddbf8a 100644 --- a/src/NzbDrone.Core/Indexers/IndexerBase.cs +++ b/src/NzbDrone.Core/Indexers/IndexerBase.cs @@ -67,8 +67,8 @@ namespace NzbDrone.Core.Indexers public abstract IList FetchRecent(); - public abstract IList Fetch(AlbumSearchCriteria searchCriteria); - public abstract IList Fetch(ArtistSearchCriteria searchCriteria); + public abstract IList Fetch(BookSearchCriteria searchCriteria); + public abstract IList Fetch(AuthorSearchCriteria searchCriteria); protected virtual IList CleanupReleases(IEnumerable releases) { diff --git a/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs b/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs index c24c01782..98538139c 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs @@ -112,7 +112,7 @@ namespace NzbDrone.Core.Indexers.Newznab } if (capabilities.SupportedAudioSearchParameters != null && - new[] { "artist", "album" }.All(v => capabilities.SupportedAudioSearchParameters.Contains(v))) + new[] { "author", "book" }.All(v => capabilities.SupportedAudioSearchParameters.Contains(v))) { return null; } diff --git a/src/NzbDrone.Core/Indexers/Newznab/NewznabCapabilities.cs b/src/NzbDrone.Core/Indexers/Newznab/NewznabCapabilities.cs index 035915704..408f6c103 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/NewznabCapabilities.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/NewznabCapabilities.cs @@ -18,7 +18,7 @@ namespace NzbDrone.Core.Indexers.Newznab MaxPageSize = 100; SupportedSearchParameters = new[] { "q" }; SupportedTvSearchParameters = new[] { "q", "rid", "season", "ep" }; // This should remain 'rid' for older newznab installs. - SupportedAudioSearchParameters = new[] { "q", "artist", "album" }; + SupportedAudioSearchParameters = new[] { "q", "author", "book" }; SupportsAggregateIdSearch = false; Categories = new List(); } diff --git a/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs index f7f167b34..a59bac945 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs @@ -40,8 +40,8 @@ namespace NzbDrone.Core.Indexers.Newznab return capabilities.SupportedAudioSearchParameters != null && capabilities.SupportedAudioSearchParameters.Contains("q") && - capabilities.SupportedAudioSearchParameters.Contains("artist") && - capabilities.SupportedAudioSearchParameters.Contains("album"); + capabilities.SupportedAudioSearchParameters.Contains("author") && + capabilities.SupportedAudioSearchParameters.Contains("book"); } } @@ -63,7 +63,7 @@ namespace NzbDrone.Core.Indexers.Newznab return pageableRequests; } - public virtual IndexerPageableRequestChain GetSearchRequests(AlbumSearchCriteria searchCriteria) + public virtual IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria) { var pageableRequests = new IndexerPageableRequestChain(); @@ -71,7 +71,7 @@ namespace NzbDrone.Core.Indexers.Newznab { AddAudioPageableRequests(pageableRequests, searchCriteria, - NewsnabifyTitle($"&artist={searchCriteria.ArtistQuery}&album={searchCriteria.AlbumQuery}")); + NewsnabifyTitle($"&author={searchCriteria.ArtistQuery}&book={searchCriteria.AlbumQuery}")); } if (SupportsSearch) @@ -87,7 +87,7 @@ namespace NzbDrone.Core.Indexers.Newznab return pageableRequests; } - public virtual IndexerPageableRequestChain GetSearchRequests(ArtistSearchCriteria searchCriteria) + public virtual IndexerPageableRequestChain GetSearchRequests(AuthorSearchCriteria searchCriteria) { var pageableRequests = new IndexerPageableRequestChain(); @@ -95,7 +95,7 @@ namespace NzbDrone.Core.Indexers.Newznab { AddAudioPageableRequests(pageableRequests, searchCriteria, - NewsnabifyTitle($"&artist={searchCriteria.ArtistQuery}")); + NewsnabifyTitle($"&author={searchCriteria.ArtistQuery}")); } if (SupportsSearch) diff --git a/src/NzbDrone.Core/Indexers/Newznab/NewznabRssParser.cs b/src/NzbDrone.Core/Indexers/Newznab/NewznabRssParser.cs index 0a1f15f65..1af275e01 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/NewznabRssParser.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/NewznabRssParser.cs @@ -72,8 +72,8 @@ namespace NzbDrone.Core.Indexers.Newznab { releaseInfo = base.ProcessItem(item, releaseInfo); - releaseInfo.Artist = GetArtist(item); - releaseInfo.Album = GetAlbum(item); + releaseInfo.Author = GetArtist(item); + releaseInfo.Book = GetAlbum(item); return releaseInfo; } @@ -116,7 +116,7 @@ namespace NzbDrone.Core.Indexers.Newznab protected virtual string GetArtist(XElement item) { - var artistString = TryGetNewznabAttribute(item, "artist"); + var artistString = TryGetNewznabAttribute(item, "author"); if (!artistString.IsNullOrWhiteSpace()) { @@ -128,7 +128,7 @@ namespace NzbDrone.Core.Indexers.Newznab protected virtual string GetAlbum(XElement item) { - var albumString = TryGetNewznabAttribute(item, "album"); + var albumString = TryGetNewznabAttribute(item, "book"); if (!albumString.IsNullOrWhiteSpace()) { diff --git a/src/NzbDrone.Core/Indexers/Nyaa/NyaaRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Nyaa/NyaaRequestGenerator.cs index 8157e5fc0..2fdfaec25 100644 --- a/src/NzbDrone.Core/Indexers/Nyaa/NyaaRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Nyaa/NyaaRequestGenerator.cs @@ -26,12 +26,12 @@ namespace NzbDrone.Core.Indexers.Nyaa return pageableRequests; } - public virtual IndexerPageableRequestChain GetSearchRequests(AlbumSearchCriteria searchCriteria) + public virtual IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria) { throw new System.NotImplementedException(); } - public virtual IndexerPageableRequestChain GetSearchRequests(ArtistSearchCriteria searchCriteria) + public virtual IndexerPageableRequestChain GetSearchRequests(AuthorSearchCriteria searchCriteria) { throw new System.NotImplementedException(); } diff --git a/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs index 80e73e276..c62d6d5a7 100644 --- a/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs @@ -25,7 +25,7 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs return pageableRequests; } - public virtual IndexerPageableRequestChain GetSearchRequests(AlbumSearchCriteria searchCriteria) + public virtual IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria) { var pageableRequests = new IndexerPageableRequestChain(); @@ -36,7 +36,7 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs return pageableRequests; } - public virtual IndexerPageableRequestChain GetSearchRequests(ArtistSearchCriteria searchCriteria) + public virtual IndexerPageableRequestChain GetSearchRequests(AuthorSearchCriteria searchCriteria) { var pageableRequests = new IndexerPageableRequestChain(); diff --git a/src/NzbDrone.Core/Indexers/Rarbg/RarbgRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Rarbg/RarbgRequestGenerator.cs index a1fae523c..72114cc81 100644 --- a/src/NzbDrone.Core/Indexers/Rarbg/RarbgRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Rarbg/RarbgRequestGenerator.cs @@ -26,7 +26,7 @@ namespace NzbDrone.Core.Indexers.Rarbg return pageableRequests; } - public virtual IndexerPageableRequestChain GetSearchRequests(AlbumSearchCriteria searchCriteria) + public virtual IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria) { var pageableRequests = new IndexerPageableRequestChain(); @@ -35,7 +35,7 @@ namespace NzbDrone.Core.Indexers.Rarbg return pageableRequests; } - public virtual IndexerPageableRequestChain GetSearchRequests(ArtistSearchCriteria searchCriteria) + public virtual IndexerPageableRequestChain GetSearchRequests(AuthorSearchCriteria searchCriteria) { var pageableRequests = new IndexerPageableRequestChain(); diff --git a/src/NzbDrone.Core/Indexers/Rarbg/RarbgResponse.cs b/src/NzbDrone.Core/Indexers/Rarbg/RarbgResponse.cs index d07100a6c..399d3322c 100644 --- a/src/NzbDrone.Core/Indexers/Rarbg/RarbgResponse.cs +++ b/src/NzbDrone.Core/Indexers/Rarbg/RarbgResponse.cs @@ -27,7 +27,7 @@ namespace NzbDrone.Core.Indexers.Rarbg public class RarbgTorrentInfo { // For Future if RARBG decides to return metadata - public string artist { get; set; } - public string album { get; set; } + public string author { get; set; } + public string book { get; set; } } } diff --git a/src/NzbDrone.Core/Indexers/RssIndexerRequestGenerator.cs b/src/NzbDrone.Core/Indexers/RssIndexerRequestGenerator.cs index 9c8608875..2b7316a0e 100644 --- a/src/NzbDrone.Core/Indexers/RssIndexerRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/RssIndexerRequestGenerator.cs @@ -21,12 +21,12 @@ namespace NzbDrone.Core.Indexers return pageableRequests; } - public virtual IndexerPageableRequestChain GetSearchRequests(AlbumSearchCriteria searchCriteria) + public virtual IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria) { throw new System.NotImplementedException(); } - public virtual IndexerPageableRequestChain GetSearchRequests(ArtistSearchCriteria searchCriteria) + public virtual IndexerPageableRequestChain GetSearchRequests(AuthorSearchCriteria searchCriteria) { throw new System.NotImplementedException(); } diff --git a/src/NzbDrone.Core/Indexers/SeedConfigProvider.cs b/src/NzbDrone.Core/Indexers/SeedConfigProvider.cs index f41d65ea6..2d866606b 100644 --- a/src/NzbDrone.Core/Indexers/SeedConfigProvider.cs +++ b/src/NzbDrone.Core/Indexers/SeedConfigProvider.cs @@ -7,7 +7,7 @@ namespace NzbDrone.Core.Indexers { public interface ISeedConfigProvider { - TorrentSeedConfiguration GetSeedConfiguration(RemoteAlbum release); + TorrentSeedConfiguration GetSeedConfiguration(RemoteBook release); } public class SeedConfigProvider : ISeedConfigProvider @@ -19,7 +19,7 @@ namespace NzbDrone.Core.Indexers _indexerFactory = indexerFactory; } - public TorrentSeedConfiguration GetSeedConfiguration(RemoteAlbum remoteAlbum) + public TorrentSeedConfiguration GetSeedConfiguration(RemoteBook remoteAlbum) { if (remoteAlbum.Release.DownloadProtocol != DownloadProtocol.Torrent) { @@ -43,7 +43,7 @@ namespace NzbDrone.Core.Indexers Ratio = torrentIndexerSettings.SeedCriteria.SeedRatio }; - var seedTime = remoteAlbum.ParsedAlbumInfo.Discography ? torrentIndexerSettings.SeedCriteria.DiscographySeedTime : torrentIndexerSettings.SeedCriteria.SeedTime; + var seedTime = remoteAlbum.ParsedBookInfo.Discography ? torrentIndexerSettings.SeedCriteria.DiscographySeedTime : torrentIndexerSettings.SeedCriteria.SeedTime; if (seedTime.HasValue) { seedConfig.SeedTime = TimeSpan.FromMinutes(seedTime.Value); diff --git a/src/NzbDrone.Core/Indexers/TorrentRss/TorrentRssIndexerRequestGenerator.cs b/src/NzbDrone.Core/Indexers/TorrentRss/TorrentRssIndexerRequestGenerator.cs index 956f60a25..33c6a4461 100644 --- a/src/NzbDrone.Core/Indexers/TorrentRss/TorrentRssIndexerRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/TorrentRss/TorrentRssIndexerRequestGenerator.cs @@ -18,12 +18,12 @@ namespace NzbDrone.Core.Indexers.TorrentRss return pageableRequests; } - public virtual IndexerPageableRequestChain GetSearchRequests(AlbumSearchCriteria searchCriteria) + public virtual IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria) { throw new System.NotImplementedException(); } - public virtual IndexerPageableRequestChain GetSearchRequests(ArtistSearchCriteria searchCriteria) + public virtual IndexerPageableRequestChain GetSearchRequests(AuthorSearchCriteria searchCriteria) { throw new System.NotImplementedException(); } diff --git a/src/NzbDrone.Core/Indexers/Torrentleech/TorrentleechRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Torrentleech/TorrentleechRequestGenerator.cs index a110a9cdf..29bef9c34 100644 --- a/src/NzbDrone.Core/Indexers/Torrentleech/TorrentleechRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Torrentleech/TorrentleechRequestGenerator.cs @@ -17,12 +17,12 @@ namespace NzbDrone.Core.Indexers.Torrentleech return pageableRequests; } - public virtual IndexerPageableRequestChain GetSearchRequests(AlbumSearchCriteria searchCriteria) + public virtual IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria) { throw new System.NotImplementedException(); } - public virtual IndexerPageableRequestChain GetSearchRequests(ArtistSearchCriteria searchCriteria) + public virtual IndexerPageableRequestChain GetSearchRequests(AuthorSearchCriteria searchCriteria) { throw new System.NotImplementedException(); } diff --git a/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs b/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs index 27132cd85..0ad7b3fc7 100644 --- a/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs +++ b/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs @@ -92,7 +92,7 @@ namespace NzbDrone.Core.Indexers.Torznab } if (capabilities.SupportedAudioSearchParameters != null && - new[] { "artist", "album" }.All(v => capabilities.SupportedAudioSearchParameters.Contains(v))) + new[] { "author", "book" }.All(v => capabilities.SupportedAudioSearchParameters.Contains(v))) { return null; } diff --git a/src/NzbDrone.Core/Jobs/TaskManager.cs b/src/NzbDrone.Core/Jobs/TaskManager.cs index 9687293a2..03eb419d8 100644 --- a/src/NzbDrone.Core/Jobs/TaskManager.cs +++ b/src/NzbDrone.Core/Jobs/TaskManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using NLog; using NzbDrone.Core.Backup; +using NzbDrone.Core.Books.Commands; using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration.Events; using NzbDrone.Core.Download; @@ -14,7 +15,6 @@ using NzbDrone.Core.Lifecycle; using NzbDrone.Core.MediaFiles.Commands; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music.Commands; using NzbDrone.Core.Update.Commands; namespace NzbDrone.Core.Jobs @@ -65,7 +65,7 @@ namespace NzbDrone.Core.Jobs new ScheduledTask { Interval = 5, TypeName = typeof(MessagingCleanupCommand).FullName }, new ScheduledTask { Interval = 6 * 60, TypeName = typeof(ApplicationUpdateCommand).FullName }, new ScheduledTask { Interval = 6 * 60, TypeName = typeof(CheckHealthCommand).FullName }, - new ScheduledTask { Interval = 24 * 60, TypeName = typeof(RefreshArtistCommand).FullName }, + new ScheduledTask { Interval = 24 * 60, TypeName = typeof(RefreshAuthorCommand).FullName }, new ScheduledTask { Interval = 24 * 60, TypeName = typeof(RescanFoldersCommand).FullName }, new ScheduledTask { Interval = 24 * 60, TypeName = typeof(HousekeepingCommand).FullName }, diff --git a/src/NzbDrone.Core/MediaCover/MediaCover.cs b/src/NzbDrone.Core/MediaCover/MediaCover.cs index d991a14ec..2b2fa5ec4 100644 --- a/src/NzbDrone.Core/MediaCover/MediaCover.cs +++ b/src/NzbDrone.Core/MediaCover/MediaCover.cs @@ -20,8 +20,8 @@ namespace NzbDrone.Core.MediaCover public enum MediaCoverEntity { - Artist = 0, - Album = 1 + Author = 0, + Book = 1 } public class MediaCover : MemberwiseEquatable, IEmbeddedDocument diff --git a/src/NzbDrone.Core/MediaCover/MediaCoverService.cs b/src/NzbDrone.Core/MediaCover/MediaCoverService.cs index 1ad38670d..ac7f4bd97 100644 --- a/src/NzbDrone.Core/MediaCover/MediaCoverService.cs +++ b/src/NzbDrone.Core/MediaCover/MediaCoverService.cs @@ -9,10 +9,10 @@ using NzbDrone.Common.Disk; using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; +using NzbDrone.Core.Books; +using NzbDrone.Core.Books.Events; using NzbDrone.Core.Configuration; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; -using NzbDrone.Core.Music.Events; namespace NzbDrone.Core.MediaCover { @@ -20,20 +20,20 @@ namespace NzbDrone.Core.MediaCover { void ConvertToLocalUrls(int entityId, MediaCoverEntity coverEntity, IEnumerable covers); string GetCoverPath(int entityId, MediaCoverEntity coverEntity, MediaCoverTypes mediaCoverTypes, string extension, int? height = null); - void EnsureAlbumCovers(Book album); + void EnsureAlbumCovers(Book book); } public class MediaCoverService : - IHandleAsync, - IHandleAsync, - IHandleAsync, + IHandleAsync, + IHandleAsync, + IHandleAsync, IMapCoversToLocal { private const double HTTP_RATE_LIMIT = 0; private const string USER_AGENT = "Dalvik/2.1.0 (Linux; U; Android 10; Mi A2 Build/QKQ1.190910.002)"; private readonly IImageResizer _resizer; - private readonly IAlbumService _albumService; + private readonly IBookService _bookService; private readonly IHttpClient _httpClient; private readonly IDiskProvider _diskProvider; private readonly ICoverExistsSpecification _coverExistsSpecification; @@ -48,7 +48,7 @@ namespace NzbDrone.Core.MediaCover private static SemaphoreSlim _semaphore = new SemaphoreSlim((int)Math.Ceiling(Environment.ProcessorCount / 2.0)); public MediaCoverService(IImageResizer resizer, - IAlbumService albumService, + IBookService bookService, IHttpClient httpClient, IDiskProvider diskProvider, IAppFolderInfo appFolderInfo, @@ -58,7 +58,7 @@ namespace NzbDrone.Core.MediaCover Logger logger) { _resizer = resizer; - _albumService = albumService; + _bookService = bookService; _httpClient = httpClient; _diskProvider = diskProvider; _coverExistsSpecification = coverExistsSpecification; @@ -73,7 +73,7 @@ namespace NzbDrone.Core.MediaCover { var heightSuffix = height.HasValue ? "-" + height.ToString() : ""; - if (coverEntity == MediaCoverEntity.Album) + if (coverEntity == MediaCoverEntity.Book) { return Path.Combine(GetAlbumCoverPath(entityId), coverTypes.ToString().ToLower() + heightSuffix + extension); } @@ -89,7 +89,7 @@ namespace NzbDrone.Core.MediaCover { var filePath = GetCoverPath(entityId, coverEntity, mediaCover.CoverType, mediaCover.Extension, null); - if (coverEntity == MediaCoverEntity.Album) + if (coverEntity == MediaCoverEntity.Book) { mediaCover.Url = _configFileProvider.UrlBase + @"/MediaCover/Albums/" + entityId + "/" + mediaCover.CoverType.ToString().ToLower() + mediaCover.Extension; } @@ -116,13 +116,13 @@ namespace NzbDrone.Core.MediaCover return Path.Combine(_coverRootFolder, "Albums", bookId.ToString()); } - private void EnsureArtistCovers(Author artist) + private void EnsureArtistCovers(Author author) { var toResize = new List>(); - foreach (var cover in artist.Metadata.Value.Images) + foreach (var cover in author.Metadata.Value.Images) { - var fileName = GetCoverPath(artist.Id, MediaCoverEntity.Artist, cover.CoverType, cover.Extension); + var fileName = GetCoverPath(author.Id, MediaCoverEntity.Author, cover.CoverType, cover.Extension); var alreadyExists = false; try @@ -131,16 +131,16 @@ namespace NzbDrone.Core.MediaCover if (!alreadyExists) { - DownloadCover(artist, cover, DateTime.Now); + DownloadCover(author, cover, DateTime.Now); } } catch (WebException e) { - _logger.Warn("Couldn't download media cover for {0}. {1}", artist, e.Message); + _logger.Warn("Couldn't download media cover for {0}. {1}", author, e.Message); } catch (Exception e) { - _logger.Error(e, "Couldn't download media cover for {0}", artist); + _logger.Error(e, "Couldn't download media cover for {0}", author); } toResize.Add(Tuple.Create(cover, alreadyExists)); @@ -152,7 +152,7 @@ namespace NzbDrone.Core.MediaCover foreach (var tuple in toResize) { - EnsureResizedCovers(artist, tuple.Item1, !tuple.Item2); + EnsureResizedCovers(author, tuple.Item1, !tuple.Item2); } } finally @@ -161,11 +161,11 @@ namespace NzbDrone.Core.MediaCover } } - public void EnsureAlbumCovers(Book album) + public void EnsureAlbumCovers(Book book) { - foreach (var cover in album.Images.Where(e => e.CoverType == MediaCoverTypes.Cover)) + foreach (var cover in book.Images.Where(e => e.CoverType == MediaCoverTypes.Cover)) { - var fileName = GetCoverPath(album.Id, MediaCoverEntity.Album, cover.CoverType, cover.Extension, null); + var fileName = GetCoverPath(book.Id, MediaCoverEntity.Book, cover.CoverType, cover.Extension, null); var alreadyExists = false; try { @@ -173,25 +173,25 @@ namespace NzbDrone.Core.MediaCover if (!alreadyExists) { - DownloadAlbumCover(album, cover, DateTime.Now); + DownloadAlbumCover(book, cover, DateTime.Now); } } catch (WebException e) { - _logger.Warn("Couldn't download media cover for {0}. {1}", album, e.Message); + _logger.Warn("Couldn't download media cover for {0}. {1}", book, e.Message); } catch (Exception e) { - _logger.Error(e, "Couldn't download media cover for {0}", album); + _logger.Error(e, "Couldn't download media cover for {0}", book); } } } - private void DownloadCover(Author artist, MediaCover cover, DateTime lastModified) + private void DownloadCover(Author author, MediaCover cover, DateTime lastModified) { - var fileName = GetCoverPath(artist.Id, MediaCoverEntity.Artist, cover.CoverType, cover.Extension); + var fileName = GetCoverPath(author.Id, MediaCoverEntity.Author, cover.CoverType, cover.Extension); - _logger.Info("Downloading {0} for {1} {2}", cover.CoverType, artist, cover.Url); + _logger.Info("Downloading {0} for {1} {2}", cover.CoverType, author, cover.Url); _httpClient.DownloadFile(cover.Url, fileName, USER_AGENT); try @@ -200,15 +200,15 @@ namespace NzbDrone.Core.MediaCover } catch (Exception ex) { - _logger.Debug(ex, "Unable to set modified date for {0} image for artist {1}", cover.CoverType, artist); + _logger.Debug(ex, "Unable to set modified date for {0} image for author {1}", cover.CoverType, author); } } - private void DownloadAlbumCover(Book album, MediaCover cover, DateTime lastModified) + private void DownloadAlbumCover(Book book, MediaCover cover, DateTime lastModified) { - var fileName = GetCoverPath(album.Id, MediaCoverEntity.Album, cover.CoverType, cover.Extension, null); + var fileName = GetCoverPath(book.Id, MediaCoverEntity.Book, cover.CoverType, cover.Extension, null); - _logger.Info("Downloading {0} for {1} {2}", cover.CoverType, album, cover.Url); + _logger.Info("Downloading {0} for {1} {2}", cover.CoverType, book, cover.Url); _httpClient.DownloadFile(cover.Url, fileName, USER_AGENT); try @@ -217,22 +217,22 @@ namespace NzbDrone.Core.MediaCover } catch (Exception ex) { - _logger.Debug(ex, "Unable to set modified date for {0} image for album {1}", cover.CoverType, album); + _logger.Debug(ex, "Unable to set modified date for {0} image for book {1}", cover.CoverType, book); } } - private void EnsureResizedCovers(Author artist, MediaCover cover, bool forceResize, Book album = null) + private void EnsureResizedCovers(Author author, MediaCover cover, bool forceResize, Book book = null) { int[] heights = GetDefaultHeights(cover.CoverType); foreach (var height in heights) { - var mainFileName = GetCoverPath(artist.Id, MediaCoverEntity.Artist, cover.CoverType, cover.Extension); - var resizeFileName = GetCoverPath(artist.Id, MediaCoverEntity.Artist, cover.CoverType, cover.Extension, height); + var mainFileName = GetCoverPath(author.Id, MediaCoverEntity.Author, cover.CoverType, cover.Extension); + var resizeFileName = GetCoverPath(author.Id, MediaCoverEntity.Author, cover.CoverType, cover.Extension, height); if (forceResize || !_diskProvider.FileExists(resizeFileName) || _diskProvider.GetFileSize(resizeFileName) == 0) { - _logger.Debug("Resizing {0}-{1} for {2}", cover.CoverType, height, artist); + _logger.Debug("Resizing {0}-{1} for {2}", cover.CoverType, height, author); try { @@ -240,7 +240,7 @@ namespace NzbDrone.Core.MediaCover } catch { - _logger.Debug("Couldn't resize media cover {0}-{1} for artist {2}, using full size image instead.", cover.CoverType, height, artist); + _logger.Debug("Couldn't resize media cover {0}-{1} for author {2}, using full size image instead.", cover.CoverType, height, author); } } } @@ -269,31 +269,31 @@ namespace NzbDrone.Core.MediaCover } } - public void HandleAsync(ArtistRefreshCompleteEvent message) + public void HandleAsync(AuthorRefreshCompleteEvent message) { - EnsureArtistCovers(message.Artist); + EnsureArtistCovers(message.Author); - var albums = _albumService.GetAlbumsByArtist(message.Artist.Id); - foreach (Book album in albums) + var albums = _bookService.GetBooksByAuthor(message.Author.Id); + foreach (Book book in albums) { - EnsureAlbumCovers(album); + EnsureAlbumCovers(book); } - _eventAggregator.PublishEvent(new MediaCoversUpdatedEvent(message.Artist)); + _eventAggregator.PublishEvent(new MediaCoversUpdatedEvent(message.Author)); } - public void HandleAsync(ArtistDeletedEvent message) + public void HandleAsync(AuthorDeletedEvent message) { - var path = GetArtistCoverPath(message.Artist.Id); + var path = GetArtistCoverPath(message.Author.Id); if (_diskProvider.FolderExists(path)) { _diskProvider.DeleteFolder(path, true); } } - public void HandleAsync(AlbumDeletedEvent message) + public void HandleAsync(BookDeletedEvent message) { - var path = GetAlbumCoverPath(message.Album.Id); + var path = GetAlbumCoverPath(message.Book.Id); if (_diskProvider.FolderExists(path)) { _diskProvider.DeleteFolder(path, true); diff --git a/src/NzbDrone.Core/MediaCover/MediaCoversUpdatedEvent.cs b/src/NzbDrone.Core/MediaCover/MediaCoversUpdatedEvent.cs index 0fd9fa40a..dd0da3908 100644 --- a/src/NzbDrone.Core/MediaCover/MediaCoversUpdatedEvent.cs +++ b/src/NzbDrone.Core/MediaCover/MediaCoversUpdatedEvent.cs @@ -1,21 +1,21 @@ using NzbDrone.Common.Messaging; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; namespace NzbDrone.Core.MediaCover { public class MediaCoversUpdatedEvent : IEvent { - public Author Artist { get; set; } + public Author Author { get; set; } public Book Album { get; set; } - public MediaCoversUpdatedEvent(Author artist) + public MediaCoversUpdatedEvent(Author author) { - Artist = artist; + Author = author; } - public MediaCoversUpdatedEvent(Book album) + public MediaCoversUpdatedEvent(Book book) { - Album = album; + Album = book; } } } diff --git a/src/NzbDrone.Core/MediaFiles/AudioTag.cs b/src/NzbDrone.Core/MediaFiles/AudioTag.cs index e40843de7..aa7af32dd 100644 --- a/src/NzbDrone.Core/MediaFiles/AudioTag.cs +++ b/src/NzbDrone.Core/MediaFiles/AudioTag.cs @@ -507,23 +507,23 @@ namespace NzbDrone.Core.MediaFiles }; } - var artist = tag.AlbumArtists?.FirstOrDefault(); + var author = tag.AlbumArtists?.FirstOrDefault(); - if (artist.IsNullOrWhiteSpace()) + if (author.IsNullOrWhiteSpace()) { - artist = tag.Performers?.FirstOrDefault(); + author = tag.Performers?.FirstOrDefault(); } - var artistTitleInfo = new ArtistTitleInfo + var artistTitleInfo = new AuthorTitleInfo { - Title = artist, + Title = author, Year = (int)tag.Year }; return new ParsedTrackInfo { AlbumTitle = tag.Album, - ArtistTitle = artist, + ArtistTitle = author, DiscNumber = (int)tag.Disc, DiscCount = (int)tag.DiscCount, Year = tag.Year, diff --git a/src/NzbDrone.Core/MediaFiles/AudioTagService.cs b/src/NzbDrone.Core/MediaFiles/AudioTagService.cs index 8df9730b1..71ef14804 100644 --- a/src/NzbDrone.Core/MediaFiles/AudioTagService.cs +++ b/src/NzbDrone.Core/MediaFiles/AudioTagService.cs @@ -6,13 +6,13 @@ using NLog.Fluent; using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; using NzbDrone.Common.Instrumentation.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaFiles.Commands; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using TagLib; @@ -24,19 +24,19 @@ namespace NzbDrone.Core.MediaFiles ParsedTrackInfo ReadTags(string file); void WriteTags(BookFile trackfile, bool newDownload, bool force = false); void SyncTags(List tracks); - List GetRetagPreviewsByArtist(int authorId); - List GetRetagPreviewsByAlbum(int authorId); + List GetRetagPreviewsByArtist(int authorId); + List GetRetagPreviewsByAlbum(int authorId); } public class AudioTagService : IAudioTagService, - IExecute, + IExecute, IExecute { private readonly IConfigService _configService; private readonly IMediaFileService _mediaFileService; private readonly IDiskProvider _diskProvider; private readonly IRootFolderWatchingService _rootFolderWatchingService; - private readonly IArtistService _artistService; + private readonly IAuthorService _authorService; private readonly IMapCoversToLocal _mediaCoverService; private readonly IEventAggregator _eventAggregator; private readonly Logger _logger; @@ -45,7 +45,7 @@ namespace NzbDrone.Core.MediaFiles IMediaFileService mediaFileService, IDiskProvider diskProvider, IRootFolderWatchingService rootFolderWatchingService, - IArtistService artistService, + IAuthorService authorService, IMapCoversToLocal mediaCoverService, IEventAggregator eventAggregator, Logger logger) @@ -54,7 +54,7 @@ namespace NzbDrone.Core.MediaFiles _mediaFileService = mediaFileService; _diskProvider = diskProvider; _rootFolderWatchingService = rootFolderWatchingService; - _artistService = artistService; + _authorService = authorService; _mediaCoverService = mediaCoverService; _eventAggregator = eventAggregator; _logger = logger; @@ -145,7 +145,7 @@ namespace NzbDrone.Core.MediaFiles UpdateTrackfileSizeAndModified(trackfile, path); - _eventAggregator.PublishEvent(new TrackFileRetaggedEvent(trackfile.Artist.Value, trackfile, diff, _configService.ScrubAudioTags)); + _eventAggregator.PublishEvent(new BookFileRetaggedEvent(trackfile.Author.Value, trackfile, diff, _configService.ScrubAudioTags)); } public void SyncTags(List books) @@ -164,35 +164,35 @@ namespace NzbDrone.Core.MediaFiles foreach (var file in trackFiles) { - // populate tracks (which should also have release/album/artist set) because + // populate tracks (which should also have release/book/author set) because // not all of the updates will have been committed to the database yet - file.Album = book; + file.Book = book; WriteTags(file, false); } } } - public List GetRetagPreviewsByArtist(int authorId) + public List GetRetagPreviewsByArtist(int authorId) { - var files = _mediaFileService.GetFilesByArtist(authorId); + var files = _mediaFileService.GetFilesByAuthor(authorId); return GetPreviews(files).ToList(); } - public List GetRetagPreviewsByAlbum(int bookId) + public List GetRetagPreviewsByAlbum(int bookId) { - var files = _mediaFileService.GetFilesByAlbum(bookId); + var files = _mediaFileService.GetFilesByBook(bookId); return GetPreviews(files).ToList(); } - private IEnumerable GetPreviews(List files) + private IEnumerable GetPreviews(List files) { - foreach (var f in files.OrderBy(x => x.Album.Value.Title)) + foreach (var f in files.OrderBy(x => x.Book.Value.Title)) { var file = f; - if (f.Album.Value == null) + if (f.Book.Value == null) { _logger.Warn($"File {f} is not linked to any books"); continue; @@ -204,11 +204,11 @@ namespace NzbDrone.Core.MediaFiles if (diff.Any()) { - yield return new RetagTrackFilePreview + yield return new RetagBookFilePreview { - AuthorId = file.Artist.Value.Id, - BookId = file.Album.Value.Id, - TrackFileId = file.Id, + AuthorId = file.Author.Value.Id, + BookId = file.Book.Value.Id, + BookFileId = file.Id, Path = file.Path, Changes = diff }; @@ -218,33 +218,33 @@ namespace NzbDrone.Core.MediaFiles public void Execute(RetagFilesCommand message) { - var artist = _artistService.GetArtist(message.AuthorId); + var author = _authorService.GetAuthor(message.AuthorId); var trackFiles = _mediaFileService.Get(message.Files); - _logger.ProgressInfo("Re-tagging {0} files for {1}", trackFiles.Count, artist.Name); + _logger.ProgressInfo("Re-tagging {0} files for {1}", trackFiles.Count, author.Name); foreach (var file in trackFiles) { WriteTags(file, false, force: true); } - _logger.ProgressInfo("Selected track files re-tagged for {0}", artist.Name); + _logger.ProgressInfo("Selected track files re-tagged for {0}", author.Name); } - public void Execute(RetagArtistCommand message) + public void Execute(RetagAuthorCommand message) { _logger.Debug("Re-tagging all files for selected artists"); - var artistToRename = _artistService.GetArtists(message.AuthorIds); + var artistToRename = _authorService.GetAuthors(message.AuthorIds); - foreach (var artist in artistToRename) + foreach (var author in artistToRename) { - var trackFiles = _mediaFileService.GetFilesByArtist(artist.Id); - _logger.ProgressInfo("Re-tagging all files in artist: {0}", artist.Name); + var trackFiles = _mediaFileService.GetFilesByAuthor(author.Id); + _logger.ProgressInfo("Re-tagging all files in author: {0}", author.Name); foreach (var file in trackFiles) { WriteTags(file, false, force: true); } - _logger.ProgressInfo("All track files re-tagged for {0}", artist.Name); + _logger.ProgressInfo("All track files re-tagged for {0}", author.Name); } } } diff --git a/src/NzbDrone.Core/MediaFiles/BookFile.cs b/src/NzbDrone.Core/MediaFiles/BookFile.cs index 0382c93ce..927b2d6a2 100644 --- a/src/NzbDrone.Core/MediaFiles/BookFile.cs +++ b/src/NzbDrone.Core/MediaFiles/BookFile.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; @@ -23,8 +23,8 @@ namespace NzbDrone.Core.MediaFiles public int CalibreId { get; set; } // These are queried from the database - public LazyLoaded Artist { get; set; } - public LazyLoaded Album { get; set; } + public LazyLoaded Author { get; set; } + public LazyLoaded Book { get; set; } public override string ToString() { diff --git a/src/NzbDrone.Core/MediaFiles/TrackFileMoveResult.cs b/src/NzbDrone.Core/MediaFiles/BookFileMoveResult.cs similarity index 63% rename from src/NzbDrone.Core/MediaFiles/TrackFileMoveResult.cs rename to src/NzbDrone.Core/MediaFiles/BookFileMoveResult.cs index 9e98c059f..7d0979cef 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackFileMoveResult.cs +++ b/src/NzbDrone.Core/MediaFiles/BookFileMoveResult.cs @@ -2,14 +2,14 @@ namespace NzbDrone.Core.MediaFiles { - public class TrackFileMoveResult + public class BookFileMoveResult { - public TrackFileMoveResult() + public BookFileMoveResult() { OldFiles = new List(); } - public BookFile TrackFile { get; set; } + public BookFile BookFile { get; set; } public List OldFiles { get; set; } } } diff --git a/src/NzbDrone.Core/MediaFiles/BookFileMovingService.cs b/src/NzbDrone.Core/MediaFiles/BookFileMovingService.cs new file mode 100644 index 000000000..34e88a0d0 --- /dev/null +++ b/src/NzbDrone.Core/MediaFiles/BookFileMovingService.cs @@ -0,0 +1,213 @@ +using System; +using System.Collections.Generic; +using System.IO; +using NLog; +using NzbDrone.Common.Disk; +using NzbDrone.Common.EnsureThat; +using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; +using NzbDrone.Core.Configuration; +using NzbDrone.Core.MediaFiles.BookImport; +using NzbDrone.Core.MediaFiles.Events; +using NzbDrone.Core.Messaging.Events; +using NzbDrone.Core.Organizer; +using NzbDrone.Core.Parser.Model; + +namespace NzbDrone.Core.MediaFiles +{ + public interface IMoveBookFiles + { + BookFile MoveBookFile(BookFile bookFile, Author author); + BookFile MoveBookFile(BookFile bookFile, LocalBook localBook); + BookFile CopyBookFile(BookFile bookFile, LocalBook localBook); + } + + public class BookFileMovingService : IMoveBookFiles + { + private readonly IBookService _bookService; + private readonly IUpdateBookFileService _updateBookFileService; + private readonly IBuildFileNames _buildFileNames; + private readonly IDiskTransferService _diskTransferService; + private readonly IDiskProvider _diskProvider; + private readonly IRootFolderWatchingService _rootFolderWatchingService; + private readonly IMediaFileAttributeService _mediaFileAttributeService; + private readonly IEventAggregator _eventAggregator; + private readonly IConfigService _configService; + private readonly Logger _logger; + + public BookFileMovingService(IBookService bookService, + IUpdateBookFileService updateBookFileService, + IBuildFileNames buildFileNames, + IDiskTransferService diskTransferService, + IDiskProvider diskProvider, + IRootFolderWatchingService rootFolderWatchingService, + IMediaFileAttributeService mediaFileAttributeService, + IEventAggregator eventAggregator, + IConfigService configService, + Logger logger) + { + _bookService = bookService; + _updateBookFileService = updateBookFileService; + _buildFileNames = buildFileNames; + _diskTransferService = diskTransferService; + _diskProvider = diskProvider; + _rootFolderWatchingService = rootFolderWatchingService; + _mediaFileAttributeService = mediaFileAttributeService; + _eventAggregator = eventAggregator; + _configService = configService; + _logger = logger; + } + + public BookFile MoveBookFile(BookFile bookFile, Author author) + { + var book = _bookService.GetBook(bookFile.BookId); + var newFileName = _buildFileNames.BuildBookFileName(author, book, bookFile); + var filePath = _buildFileNames.BuildBookFilePath(author, book, newFileName, Path.GetExtension(bookFile.Path)); + + EnsureBookFolder(bookFile, author, book, filePath); + + _logger.Debug("Renaming book file: {0} to {1}", bookFile, filePath); + + return TransferFile(bookFile, author, null, filePath, TransferMode.Move); + } + + public BookFile MoveBookFile(BookFile bookFile, LocalBook localBook) + { + var newFileName = _buildFileNames.BuildBookFileName(localBook.Author, localBook.Book, bookFile); + var filePath = _buildFileNames.BuildBookFilePath(localBook.Author, localBook.Book, newFileName, Path.GetExtension(localBook.Path)); + + EnsureTrackFolder(bookFile, localBook, filePath); + + _logger.Debug("Moving book file: {0} to {1}", bookFile.Path, filePath); + + return TransferFile(bookFile, localBook.Author, null, filePath, TransferMode.Move); + } + + public BookFile CopyBookFile(BookFile bookFile, LocalBook localBook) + { + var newFileName = _buildFileNames.BuildBookFileName(localBook.Author, localBook.Book, bookFile); + var filePath = _buildFileNames.BuildBookFilePath(localBook.Author, localBook.Book, newFileName, Path.GetExtension(localBook.Path)); + + EnsureTrackFolder(bookFile, localBook, filePath); + + if (_configService.CopyUsingHardlinks) + { + _logger.Debug("Hardlinking book file: {0} to {1}", bookFile.Path, filePath); + return TransferFile(bookFile, localBook.Author, localBook.Book, filePath, TransferMode.HardLinkOrCopy); + } + + _logger.Debug("Copying book file: {0} to {1}", bookFile.Path, filePath); + return TransferFile(bookFile, localBook.Author, localBook.Book, filePath, TransferMode.Copy); + } + + private BookFile TransferFile(BookFile bookFile, Author author, Book book, string destinationFilePath, TransferMode mode) + { + Ensure.That(bookFile, () => bookFile).IsNotNull(); + Ensure.That(author, () => author).IsNotNull(); + Ensure.That(destinationFilePath, () => destinationFilePath).IsValidPath(); + + var bookFilePath = bookFile.Path; + + if (!_diskProvider.FileExists(bookFilePath)) + { + throw new FileNotFoundException("Book file path does not exist", bookFilePath); + } + + if (bookFilePath == destinationFilePath) + { + throw new SameFilenameException("File not moved, source and destination are the same", bookFilePath); + } + + _rootFolderWatchingService.ReportFileSystemChangeBeginning(bookFilePath, destinationFilePath); + _diskTransferService.TransferFile(bookFilePath, destinationFilePath, mode); + + bookFile.Path = destinationFilePath; + + _updateBookFileService.ChangeFileDateForFile(bookFile, author, book); + + try + { + _mediaFileAttributeService.SetFolderLastWriteTime(author.Path, bookFile.DateAdded); + } + catch (Exception ex) + { + _logger.Warn(ex, "Unable to set last write time"); + } + + _mediaFileAttributeService.SetFilePermissions(destinationFilePath); + + return bookFile; + } + + private void EnsureTrackFolder(BookFile bookFile, LocalBook localBook, string filePath) + { + EnsureBookFolder(bookFile, localBook.Author, localBook.Book, filePath); + } + + private void EnsureBookFolder(BookFile bookFile, Author author, Book book, string filePath) + { + var trackFolder = Path.GetDirectoryName(filePath); + var bookFolder = _buildFileNames.BuildBookPath(author, book); + var authorFolder = author.Path; + var rootFolder = new OsPath(authorFolder).Directory.FullPath; + + if (!_diskProvider.FolderExists(rootFolder)) + { + throw new RootFolderNotFoundException(string.Format("Root folder '{0}' was not found.", rootFolder)); + } + + var changed = false; + var newEvent = new TrackFolderCreatedEvent(author, bookFile); + + _rootFolderWatchingService.ReportFileSystemChangeBeginning(authorFolder, bookFolder, trackFolder); + + if (!_diskProvider.FolderExists(authorFolder)) + { + CreateFolder(authorFolder); + newEvent.AuthorFolder = authorFolder; + changed = true; + } + + if (authorFolder != bookFolder && !_diskProvider.FolderExists(bookFolder)) + { + CreateFolder(bookFolder); + newEvent.BookFolder = bookFolder; + changed = true; + } + + if (bookFolder != trackFolder && !_diskProvider.FolderExists(trackFolder)) + { + CreateFolder(trackFolder); + newEvent.TrackFolder = trackFolder; + changed = true; + } + + if (changed) + { + _eventAggregator.PublishEvent(newEvent); + } + } + + private void CreateFolder(string directoryName) + { + Ensure.That(directoryName, () => directoryName).IsNotNullOrWhiteSpace(); + + var parentFolder = new OsPath(directoryName).Directory.FullPath; + if (!_diskProvider.FolderExists(parentFolder)) + { + CreateFolder(parentFolder); + } + + try + { + _diskProvider.CreateFolder(directoryName); + } + catch (IOException ex) + { + _logger.Error(ex, "Unable to create directory: {0}", directoryName); + } + + _mediaFileAttributeService.SetFolderPermissions(directoryName); + } + } +} diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/AggregationFailedException.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/AggregationFailedException.cs similarity index 92% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/AggregationFailedException.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/AggregationFailedException.cs index 6d31c819e..4a47cbc32 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/AggregationFailedException.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/AggregationFailedException.cs @@ -1,7 +1,7 @@ using System; using NzbDrone.Common.Exceptions; -namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation +namespace NzbDrone.Core.MediaFiles.BookImport.Aggregation { public class AugmentingFailedException : NzbDroneException { diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/AggregationService.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/AggregationService.cs similarity index 81% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/AggregationService.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/AggregationService.cs index 2021b7fcb..860261779 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/AggregationService.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/AggregationService.cs @@ -3,25 +3,25 @@ using System.Collections.Generic; using System.IO; using NLog; using NzbDrone.Common.Disk; -using NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators; +using NzbDrone.Core.MediaFiles.BookImport.Aggregation.Aggregators; using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation +namespace NzbDrone.Core.MediaFiles.BookImport.Aggregation { public interface IAugmentingService { - LocalTrack Augment(LocalTrack localTrack, bool otherFiles); + LocalBook Augment(LocalBook localTrack, bool otherFiles); LocalAlbumRelease Augment(LocalAlbumRelease localAlbum); } public class AugmentingService : IAugmentingService { - private readonly IEnumerable> _trackAugmenters; + private readonly IEnumerable> _trackAugmenters; private readonly IEnumerable> _albumAugmenters; private readonly IDiskProvider _diskProvider; private readonly Logger _logger; - public AugmentingService(IEnumerable> trackAugmenters, + public AugmentingService(IEnumerable> trackAugmenters, IEnumerable> albumAugmenters, IDiskProvider diskProvider, Logger logger) @@ -32,7 +32,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation _logger = logger; } - public LocalTrack Augment(LocalTrack localTrack, bool otherFiles) + public LocalBook Augment(LocalBook localTrack, bool otherFiles) { if (localTrack.DownloadClientAlbumInfo == null && localTrack.FolderTrackInfo == null && @@ -40,7 +40,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation { if (MediaFileExtensions.AllExtensions.Contains(Path.GetExtension(localTrack.Path))) { - throw new AugmentingFailedException("Unable to parse track info from path: {0}", localTrack.Path); + throw new AugmentingFailedException("Unable to parse book info from path: {0}", localTrack.Path); } } diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/Aggregators/AggregateCalibreData.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/Aggregators/AggregateCalibreData.cs similarity index 86% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/Aggregators/AggregateCalibreData.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/Aggregators/AggregateCalibreData.cs index 0d142cb5b..bcd76a479 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/Aggregators/AggregateCalibreData.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/Aggregators/AggregateCalibreData.cs @@ -6,9 +6,9 @@ using NzbDrone.Common.Serializer; using NzbDrone.Core.Books.Calibre; using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators +namespace NzbDrone.Core.MediaFiles.BookImport.Aggregation.Aggregators { - public class AggregateCalibreData : IAggregate + public class AggregateCalibreData : IAggregate { private readonly Logger _logger; private readonly ICached _bookCache; @@ -22,7 +22,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators _logger.Trace("Started calibre aug"); } - public LocalTrack Aggregate(LocalTrack localTrack, bool others) + public LocalBook Aggregate(LocalBook localTrack, bool others) { var book = _bookCache.Find(localTrack.Path); _logger.Trace($"Searching calibre data for {localTrack.Path}"); diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/Aggregators/AggregateFilenameInfo.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/Aggregators/AggregateFilenameInfo.cs similarity index 77% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/Aggregators/AggregateFilenameInfo.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/Aggregators/AggregateFilenameInfo.cs index dec828cc9..eebc79921 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/Aggregators/AggregateFilenameInfo.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/Aggregators/AggregateFilenameInfo.cs @@ -7,7 +7,7 @@ using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators +namespace NzbDrone.Core.MediaFiles.BookImport.Aggregation.Aggregators { public class AggregateFilenameInfo : IAggregate { @@ -23,24 +23,24 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators { var sep1 = $@"(?[{sep}]+)"; var sepn = @"\k"; - var artist = $@"(?[{chars}]+)"; + var author = $@"(?[{chars}]+)"; var track = $@"(?\d+)"; var title = $@"(?[{chars}]+)"; var tag = $@"(?<tag>[{chars}]+)"; return new[] { - new Regex($@"^{track}{sep1}{artist}{sepn}{title}{sepn}{tag}$", RegexOptions.IgnoreCase), - new Regex($@"^{track}{sep1}{artist}{sepn}{tag}{sepn}{title}$", RegexOptions.IgnoreCase), - new Regex($@"^{track}{sep1}{artist}{sepn}{title}$", RegexOptions.IgnoreCase), + new Regex($@"^{track}{sep1}{author}{sepn}{title}{sepn}{tag}$", RegexOptions.IgnoreCase), + new Regex($@"^{track}{sep1}{author}{sepn}{tag}{sepn}{title}$", RegexOptions.IgnoreCase), + new Regex($@"^{track}{sep1}{author}{sepn}{title}$", RegexOptions.IgnoreCase), - new Regex($@"^{artist}{sep1}{tag}{sepn}{track}{sepn}{title}$", RegexOptions.IgnoreCase), - new Regex($@"^{artist}{sep1}{track}{sepn}{title}{sepn}{tag}$", RegexOptions.IgnoreCase), - new Regex($@"^{artist}{sep1}{track}{sepn}{title}$", RegexOptions.IgnoreCase), + new Regex($@"^{author}{sep1}{tag}{sepn}{track}{sepn}{title}$", RegexOptions.IgnoreCase), + new Regex($@"^{author}{sep1}{track}{sepn}{title}{sepn}{tag}$", RegexOptions.IgnoreCase), + new Regex($@"^{author}{sep1}{track}{sepn}{title}$", RegexOptions.IgnoreCase), - new Regex($@"^{artist}{sep1}{title}{sepn}{tag}$", RegexOptions.IgnoreCase), - new Regex($@"^{artist}{sep1}{tag}{sepn}{title}$", RegexOptions.IgnoreCase), - new Regex($@"^{artist}{sep1}{title}$", RegexOptions.IgnoreCase), + new Regex($@"^{author}{sep1}{title}{sepn}{tag}$", RegexOptions.IgnoreCase), + new Regex($@"^{author}{sep1}{tag}{sepn}{title}$", RegexOptions.IgnoreCase), + new Regex($@"^{author}{sep1}{title}$", RegexOptions.IgnoreCase), new Regex($@"^{track}{sep1}{title}$", RegexOptions.IgnoreCase), new Regex($@"^{track}{sep1}{tag}{sepn}{title}$", RegexOptions.IgnoreCase), @@ -57,7 +57,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators public LocalAlbumRelease Aggregate(LocalAlbumRelease release, bool others) { - var tracks = release.LocalTracks; + var tracks = release.LocalBooks; if (tracks.Count(x => x.FileTrackInfo.Title.IsNullOrWhiteSpace()) > 0 || tracks.Count(x => x.FileTrackInfo.TrackNumbers.First() == 0) > 0 || tracks.Count(x => x.FileTrackInfo.DiscNumber == 0) > 0) @@ -79,9 +79,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators return release; } - private Dictionary<LocalTrack, Match> AllMatches(List<LocalTrack> tracks, Regex pattern) + private Dictionary<LocalBook, Match> AllMatches(List<LocalBook> tracks, Regex pattern) { - var matches = new Dictionary<LocalTrack, Match>(); + var matches = new Dictionary<LocalBook, Match>(); foreach (var track in tracks) { var filename = Path.GetFileNameWithoutExtension(track.Path).RemoveAccent(); @@ -105,7 +105,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators return matches.Select(x => x.Groups[field].Value).Distinct().Count() == 1; } - private void ApplyMatches(Dictionary<LocalTrack, Match> matches, Regex pattern) + private void ApplyMatches(Dictionary<LocalBook, Match> matches, Regex pattern) { _logger.Debug("Got filename match with regex {0}", pattern); @@ -119,44 +119,44 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators return; } - // Given both an "artist" and "title" field, assume that one is - // *actually* the artist, which must be uniform, and use the other + // Given both an "author" and "title" field, assume that one is + // *actually* the author, which must be uniform, and use the other // for the title. This, of course, won't work for VA albums. string titleField; - string artist; - if (keys.Contains("artist")) + string author; + if (keys.Contains("author")) { - if (EqualFields(matches.Values, "artist")) + if (EqualFields(matches.Values, "author")) { - artist = someMatch.Groups["artist"].Value.Trim(); + author = someMatch.Groups["author"].Value.Trim(); titleField = "title"; } else if (EqualFields(matches.Values, "title")) { - artist = someMatch.Groups["title"].Value.Trim(); - titleField = "artist"; + author = someMatch.Groups["title"].Value.Trim(); + titleField = "author"; } else { - _logger.Trace("Abort - both artist and title vary between matches"); + _logger.Trace("Abort - both author and title vary between matches"); // both vary, abort return; } - _logger.Debug("Got artist from filename: {0}", artist); + _logger.Debug("Got author from filename: {0}", author); foreach (var track in matches.Keys) { if (track.FileTrackInfo.ArtistTitle.IsNullOrWhiteSpace()) { - track.FileTrackInfo.ArtistTitle = artist; + track.FileTrackInfo.ArtistTitle = author; } } } else { - // no artist - remaining field is the title + // no author - remaining field is the title titleField = "title"; } diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/Aggregators/AggregateQuality.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/Aggregators/AggregateQuality.cs similarity index 69% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/Aggregators/AggregateQuality.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/Aggregators/AggregateQuality.cs index b926a77c8..a4495b1fa 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/Aggregators/AggregateQuality.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/Aggregators/AggregateQuality.cs @@ -1,10 +1,10 @@ using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators +namespace NzbDrone.Core.MediaFiles.BookImport.Aggregation.Aggregators { - public class AggregateQuality : IAggregate<LocalTrack> + public class AggregateQuality : IAggregate<LocalBook> { - public LocalTrack Aggregate(LocalTrack localTrack, bool otherFiles) + public LocalBook Aggregate(LocalBook localTrack, bool otherFiles) { var quality = localTrack.FileTrackInfo?.Quality; diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/Aggregators/AggregateReleaseGroup.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/Aggregators/AggregateReleaseGroup.cs similarity index 73% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/Aggregators/AggregateReleaseGroup.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/Aggregators/AggregateReleaseGroup.cs index 2bc2a80c9..630a57eea 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/Aggregators/AggregateReleaseGroup.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/Aggregators/AggregateReleaseGroup.cs @@ -1,11 +1,11 @@ using NzbDrone.Common.Extensions; using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators +namespace NzbDrone.Core.MediaFiles.BookImport.Aggregation.Aggregators { - public class AggregateReleaseGroup : IAggregate<LocalTrack> + public class AggregateReleaseGroup : IAggregate<LocalBook> { - public LocalTrack Aggregate(LocalTrack localTrack, bool otherFiles) + public LocalBook Aggregate(LocalBook localTrack, bool otherFiles) { var releaseGroup = localTrack.DownloadClientAlbumInfo?.ReleaseGroup; diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/Aggregators/IAggregateLocalTrack.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/Aggregators/IAggregateLocalTrack.cs similarity index 57% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/Aggregators/IAggregateLocalTrack.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/Aggregators/IAggregateLocalTrack.cs index c9a219b5a..dcc92477a 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/Aggregators/IAggregateLocalTrack.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/Aggregators/IAggregateLocalTrack.cs @@ -1,4 +1,4 @@ -namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators +namespace NzbDrone.Core.MediaFiles.BookImport.Aggregation.Aggregators { public interface IAggregate<T> { diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/IImportDecisionEngineSpecification.cs b/src/NzbDrone.Core/MediaFiles/BookImport/IImportDecisionEngineSpecification.cs similarity index 82% rename from src/NzbDrone.Core/MediaFiles/TrackImport/IImportDecisionEngineSpecification.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/IImportDecisionEngineSpecification.cs index 0d6a0fdb7..f55867218 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/IImportDecisionEngineSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/IImportDecisionEngineSpecification.cs @@ -1,7 +1,7 @@ using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; -namespace NzbDrone.Core.MediaFiles.TrackImport +namespace NzbDrone.Core.MediaFiles.BookImport { public interface IImportDecisionEngineSpecification<T> { diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/CandidateAlbumRelease.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/CandidateAlbumRelease.cs similarity index 81% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Identification/CandidateAlbumRelease.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Identification/CandidateAlbumRelease.cs index f05551bf8..22456163c 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/CandidateAlbumRelease.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/CandidateAlbumRelease.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; -namespace NzbDrone.Core.MediaFiles.TrackImport.Identification +namespace NzbDrone.Core.MediaFiles.BookImport.Identification { public class CandidateAlbumRelease { diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/CandidateService.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/CandidateService.cs similarity index 68% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Identification/CandidateService.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Identification/CandidateService.cs index 785032065..8776b2e2f 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/CandidateService.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/CandidateService.cs @@ -2,12 +2,12 @@ using System.Collections.Generic; using System.Linq; using NLog; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.MetadataSource; using NzbDrone.Core.MetadataSource.SkyHook; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.MediaFiles.TrackImport.Identification +namespace NzbDrone.Core.MediaFiles.BookImport.Identification { public interface ICandidateService { @@ -17,21 +17,21 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification public class CandidateService : ICandidateService { - private readonly ISearchForNewBook _albumSearchService; - private readonly IArtistService _artistService; - private readonly IAlbumService _albumService; + private readonly ISearchForNewBook _bookSearchService; + private readonly IAuthorService _authorService; + private readonly IBookService _bookService; private readonly IMediaFileService _mediaFileService; private readonly Logger _logger; - public CandidateService(ISearchForNewBook albumSearchService, - IArtistService artistService, - IAlbumService albumService, + public CandidateService(ISearchForNewBook bookSearchService, + IAuthorService authorService, + IBookService bookService, IMediaFileService mediaFileService, Logger logger) { - _albumSearchService = albumSearchService; - _artistService = artistService; - _albumService = albumService; + _bookSearchService = bookSearchService; + _authorService = authorService; + _bookService = bookService; _mediaFileService = mediaFileService; _logger = logger; } @@ -40,7 +40,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification { var watch = System.Diagnostics.Stopwatch.StartNew(); - // Generally artist, album and release are null. But if they're not then limit candidates appropriately. + // Generally author, book and release are null. But if they're not then limit candidates appropriately. // We've tried to make sure that tracks are all for a single release. List<CandidateAlbumRelease> candidateReleases; @@ -62,7 +62,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification // } if (idOverrides?.Album != null) { - // use the release from file tags if it exists and agrees with the specified album + // use the release from file tags if it exists and agrees with the specified book if (tagMbidRelease?.Id == idOverrides.Album.Id) { candidateReleases = tagCandidate; @@ -72,16 +72,16 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification candidateReleases = GetDbCandidatesByAlbum(idOverrides.Album, includeExisting); } } - else if (idOverrides?.Artist != null) + else if (idOverrides?.Author != null) { - // use the release from file tags if it exists and agrees with the specified album - if (tagMbidRelease?.AuthorMetadataId == idOverrides.Artist.AuthorMetadataId) + // use the release from file tags if it exists and agrees with the specified book + if (tagMbidRelease?.AuthorMetadataId == idOverrides.Author.AuthorMetadataId) { candidateReleases = tagCandidate; } else { - candidateReleases = GetDbCandidatesByArtist(localAlbumRelease, idOverrides.Artist, includeExisting); + candidateReleases = GetDbCandidatesByArtist(localAlbumRelease, idOverrides.Author, includeExisting); } } else @@ -97,35 +97,35 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification } watch.Stop(); - _logger.Debug($"Getting {candidateReleases.Count} candidates from tags for {localAlbumRelease.LocalTracks.Count} tracks took {watch.ElapsedMilliseconds}ms"); + _logger.Debug($"Getting {candidateReleases.Count} candidates from tags for {localAlbumRelease.LocalBooks.Count} tracks took {watch.ElapsedMilliseconds}ms"); return candidateReleases; } - private List<CandidateAlbumRelease> GetDbCandidatesByAlbum(Book album, bool includeExisting) + private List<CandidateAlbumRelease> GetDbCandidatesByAlbum(Book book, bool includeExisting) { return new List<CandidateAlbumRelease> { new CandidateAlbumRelease { - Book = album, - ExistingTracks = includeExisting ? _mediaFileService.GetFilesByAlbum(album.Id) : new List<BookFile>() + Book = book, + ExistingTracks = includeExisting ? _mediaFileService.GetFilesByBook(book.Id) : new List<BookFile>() } }; } - private List<CandidateAlbumRelease> GetDbCandidatesByArtist(LocalAlbumRelease localAlbumRelease, Author artist, bool includeExisting) + private List<CandidateAlbumRelease> GetDbCandidatesByArtist(LocalAlbumRelease localAlbumRelease, Author author, bool includeExisting) { - _logger.Trace("Getting candidates for {0}", artist); + _logger.Trace("Getting candidates for {0}", author); var candidateReleases = new List<CandidateAlbumRelease>(); - var albumTag = localAlbumRelease.LocalTracks.MostCommon(x => x.FileTrackInfo.AlbumTitle) ?? ""; + var albumTag = localAlbumRelease.LocalBooks.MostCommon(x => x.FileTrackInfo.AlbumTitle) ?? ""; if (albumTag.IsNotNullOrWhiteSpace()) { - var possibleAlbums = _albumService.GetCandidates(artist.AuthorMetadataId, albumTag); - foreach (var album in possibleAlbums) + var possibleAlbums = _bookService.GetCandidates(author.AuthorMetadataId, albumTag); + foreach (var book in possibleAlbums) { - candidateReleases.AddRange(GetDbCandidatesByAlbum(album, includeExisting)); + candidateReleases.AddRange(GetDbCandidatesByAlbum(book, includeExisting)); } } @@ -139,22 +139,22 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification var candidateReleases = new List<CandidateAlbumRelease>(); // check if it looks like VA. - if (TrackGroupingService.IsVariousArtists(localAlbumRelease.LocalTracks)) + if (TrackGroupingService.IsVariousArtists(localAlbumRelease.LocalBooks)) { - var va = _artistService.FindById(DistanceCalculator.VariousAuthorIds[0]); + var va = _authorService.FindById(DistanceCalculator.VariousAuthorIds[0]); if (va != null) { candidateReleases.AddRange(GetDbCandidatesByArtist(localAlbumRelease, va, includeExisting)); } } - var artistTag = localAlbumRelease.LocalTracks.MostCommon(x => x.FileTrackInfo.ArtistTitle) ?? ""; + var artistTag = localAlbumRelease.LocalBooks.MostCommon(x => x.FileTrackInfo.ArtistTitle) ?? ""; if (artistTag.IsNotNullOrWhiteSpace()) { - var possibleArtists = _artistService.GetCandidates(artistTag); - foreach (var artist in possibleArtists) + var possibleArtists = _authorService.GetCandidates(artistTag); + foreach (var author in possibleArtists) { - candidateReleases.AddRange(GetDbCandidatesByArtist(localAlbumRelease, artist, includeExisting)); + candidateReleases.AddRange(GetDbCandidatesByArtist(localAlbumRelease, author, includeExisting)); } } @@ -163,16 +163,16 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification public List<CandidateAlbumRelease> GetRemoteCandidates(LocalAlbumRelease localAlbumRelease) { - // Gets candidate album releases from the metadata server. + // Gets candidate book releases from the metadata server. // Will eventually need adding locally if we find a match var watch = System.Diagnostics.Stopwatch.StartNew(); List<Book> remoteAlbums = null; var candidates = new List<CandidateAlbumRelease>(); - var goodreads = localAlbumRelease.LocalTracks.Select(x => x.FileTrackInfo.GoodreadsId).Distinct().ToList(); - var isbns = localAlbumRelease.LocalTracks.Select(x => x.FileTrackInfo.Isbn).Distinct().ToList(); - var asins = localAlbumRelease.LocalTracks.Select(x => x.FileTrackInfo.Asin).Distinct().ToList(); + var goodreads = localAlbumRelease.LocalBooks.Select(x => x.FileTrackInfo.GoodreadsId).Distinct().ToList(); + var isbns = localAlbumRelease.LocalBooks.Select(x => x.FileTrackInfo.Isbn).Distinct().ToList(); + var asins = localAlbumRelease.LocalBooks.Select(x => x.FileTrackInfo.Asin).Distinct().ToList(); try { @@ -182,7 +182,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification { _logger.Trace($"Searching by goodreads id {id}"); - remoteAlbums = _albumSearchService.SearchByGoodreadsId(id); + remoteAlbums = _bookSearchService.SearchByGoodreadsId(id); } } @@ -192,7 +192,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification { _logger.Trace($"Searching by isbn {isbns[0]}"); - remoteAlbums = _albumSearchService.SearchByIsbn(isbns[0]); + remoteAlbums = _bookSearchService.SearchByIsbn(isbns[0]); } // Calibre puts junk asins into books it creates so check for sensible length @@ -203,37 +203,37 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification { _logger.Trace($"Searching by asin {asins[0]}"); - remoteAlbums = _albumSearchService.SearchByAsin(asins[0]); + remoteAlbums = _bookSearchService.SearchByAsin(asins[0]); } // if no asin/isbn or no result, fall back to text search if (remoteAlbums == null || !remoteAlbums.Any()) { - // fall back to artist / album name search + // fall back to author / book name search string artistTag; - if (TrackGroupingService.IsVariousArtists(localAlbumRelease.LocalTracks)) + if (TrackGroupingService.IsVariousArtists(localAlbumRelease.LocalBooks)) { artistTag = "Various Artists"; } else { - artistTag = localAlbumRelease.LocalTracks.MostCommon(x => x.FileTrackInfo.ArtistTitle) ?? ""; + artistTag = localAlbumRelease.LocalBooks.MostCommon(x => x.FileTrackInfo.ArtistTitle) ?? ""; } - var albumTag = localAlbumRelease.LocalTracks.MostCommon(x => x.FileTrackInfo.AlbumTitle) ?? ""; + var albumTag = localAlbumRelease.LocalBooks.MostCommon(x => x.FileTrackInfo.AlbumTitle) ?? ""; if (artistTag.IsNullOrWhiteSpace() || albumTag.IsNullOrWhiteSpace()) { return candidates; } - remoteAlbums = _albumSearchService.SearchForNewBook(albumTag, artistTag); + remoteAlbums = _bookSearchService.SearchForNewBook(albumTag, artistTag); if (!remoteAlbums.Any()) { - var albumSearch = _albumSearchService.SearchForNewBook(albumTag, null); - var artistSearch = _albumSearchService.SearchForNewBook(artistTag, null); + var albumSearch = _bookSearchService.SearchForNewBook(albumTag, null); + var artistSearch = _bookSearchService.SearchForNewBook(artistTag, null); remoteAlbums = albumSearch.Concat(artistSearch).DistinctBy(x => x.ForeignBookId).ToList(); } @@ -241,21 +241,21 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification } catch (SkyHookException e) { - _logger.Info(e, "Skipping album due to SkyHook error"); + _logger.Info(e, "Skipping book due to SkyHook error"); remoteAlbums = new List<Book>(); } - foreach (var album in remoteAlbums) + foreach (var book in remoteAlbums) { candidates.Add(new CandidateAlbumRelease { - Book = album, + Book = book, ExistingTracks = new List<BookFile>() }); } watch.Stop(); - _logger.Debug($"Getting {candidates.Count} remote candidates from tags for {localAlbumRelease.LocalTracks.Count} tracks took {watch.ElapsedMilliseconds}ms"); + _logger.Debug($"Getting {candidates.Count} remote candidates from tags for {localAlbumRelease.LocalBooks.Count} tracks took {watch.ElapsedMilliseconds}ms"); return candidates; } diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/Distance.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/Distance.cs similarity index 98% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Identification/Distance.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Identification/Distance.cs index f22f62567..9f96286fd 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/Distance.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/Distance.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using NzbDrone.Common.Extensions; -namespace NzbDrone.Core.MediaFiles.TrackImport.Identification +namespace NzbDrone.Core.MediaFiles.BookImport.Identification { public class Distance { diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/DistanceCalculator.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/DistanceCalculator.cs similarity index 95% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Identification/DistanceCalculator.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Identification/DistanceCalculator.cs index 25171f589..cb8f675e4 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/DistanceCalculator.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/DistanceCalculator.cs @@ -5,11 +5,11 @@ using System.Text.RegularExpressions; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Common.Instrumentation; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.MediaFiles.TrackImport.Identification +namespace NzbDrone.Core.MediaFiles.BookImport.Identification { public static class DistanceCalculator { @@ -27,7 +27,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification private static readonly RegexReplace StripSeriesRegex = new RegexReplace(@"\([^\)].+?\)$", string.Empty, RegexOptions.Compiled); - public static Distance BookDistance(List<LocalTrack> localTracks, Book release) + public static Distance BookDistance(List<LocalBook> localTracks, Book release) { var dist = new Distance(); diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/IdentificationService.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/IdentificationService.cs similarity index 86% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Identification/IdentificationService.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Identification/IdentificationService.cs index cb4d31daf..9c8c584c5 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/IdentificationService.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/IdentificationService.cs @@ -4,14 +4,14 @@ using System.Linq; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Common.Instrumentation.Extensions; -using NzbDrone.Core.MediaFiles.TrackImport.Aggregation; +using NzbDrone.Core.MediaFiles.BookImport.Aggregation; using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.MediaFiles.TrackImport.Identification +namespace NzbDrone.Core.MediaFiles.BookImport.Identification { public interface IIdentificationService { - List<LocalAlbumRelease> Identify(List<LocalTrack> localTracks, IdentificationOverrides idOverrides, ImportDecisionMakerConfig config); + List<LocalAlbumRelease> Identify(List<LocalBook> localTracks, IdentificationOverrides idOverrides, ImportDecisionMakerConfig config); } public class IdentificationService : IIdentificationService @@ -35,7 +35,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification _logger = logger; } - public List<LocalAlbumRelease> GetLocalAlbumReleases(List<LocalTrack> localTracks, bool singleRelease) + public List<LocalAlbumRelease> GetLocalAlbumReleases(List<LocalBook> localTracks, bool singleRelease) { var watch = System.Diagnostics.Stopwatch.StartNew(); List<LocalAlbumRelease> releases; @@ -65,10 +65,10 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification return releases; } - public List<LocalAlbumRelease> Identify(List<LocalTrack> localTracks, IdentificationOverrides idOverrides, ImportDecisionMakerConfig config) + public List<LocalAlbumRelease> Identify(List<LocalBook> localTracks, IdentificationOverrides idOverrides, ImportDecisionMakerConfig config) { // 1 group localTracks so that we think they represent a single release - // 2 get candidates given specified artist, album and release. Candidates can include extra files already on disk. + // 2 get candidates given specified author, album and release. Candidates can include extra files already on disk. // 3 find best candidate var watch = System.Diagnostics.Stopwatch.StartNew(); @@ -91,11 +91,11 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification return releases; } - private List<LocalTrack> ToLocalTrack(IEnumerable<BookFile> trackfiles, LocalAlbumRelease localRelease) + private List<LocalBook> ToLocalTrack(IEnumerable<BookFile> trackfiles, LocalAlbumRelease localRelease) { - var scanned = trackfiles.Join(localRelease.LocalTracks, t => t.Path, l => l.Path, (track, localTrack) => localTrack); + var scanned = trackfiles.Join(localRelease.LocalBooks, t => t.Path, l => l.Path, (track, localTrack) => localTrack); var toScan = trackfiles.ExceptBy(t => t.Path, scanned, s => s.Path, StringComparer.InvariantCulture); - var localTracks = scanned.Concat(toScan.Select(x => new LocalTrack + var localTracks = scanned.Concat(toScan.Select(x => new LocalBook { Path = x.Path, Size = x.Size, @@ -118,7 +118,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification var candidateReleases = _candidateService.GetDbCandidatesFromTags(localAlbumRelease, idOverrides, config.IncludeExisting); - if (candidateReleases.Count == 0 && config.AddNewArtists) + if (candidateReleases.Count == 0 && config.AddNewAuthors) { candidateReleases = _candidateService.GetRemoteCandidates(localAlbumRelease); } @@ -128,7 +128,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification return; } - _logger.Debug($"Got {candidateReleases.Count} candidates for {localAlbumRelease.LocalTracks.Count} tracks in {watch.ElapsedMilliseconds}ms"); + _logger.Debug($"Got {candidateReleases.Count} candidates for {localAlbumRelease.LocalBooks.Count} tracks in {watch.ElapsedMilliseconds}ms"); // convert all the TrackFiles that represent extra files to List<LocalTrack> var allLocalTracks = ToLocalTrack(candidateReleases @@ -146,12 +146,12 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification _logger.Debug($"IdentifyRelease done in {watch.ElapsedMilliseconds}ms"); } - private void GetBestRelease(LocalAlbumRelease localAlbumRelease, List<CandidateAlbumRelease> candidateReleases, List<LocalTrack> extraTracksOnDisk) + private void GetBestRelease(LocalAlbumRelease localAlbumRelease, List<CandidateAlbumRelease> candidateReleases, List<LocalBook> extraTracksOnDisk) { var watch = System.Diagnostics.Stopwatch.StartNew(); _logger.Debug("Matching {0} track files against {1} candidates", localAlbumRelease.TrackCount, candidateReleases.Count); - _logger.Trace("Processing files:\n{0}", string.Join("\n", localAlbumRelease.LocalTracks.Select(x => x.Path))); + _logger.Trace("Processing files:\n{0}", string.Join("\n", localAlbumRelease.LocalBooks.Select(x => x.Path))); double bestDistance = 1.0; @@ -163,7 +163,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification var extraTrackPaths = candidateRelease.ExistingTracks.Select(x => x.Path).ToList(); var extraTracks = extraTracksOnDisk.Where(x => extraTrackPaths.Contains(x.Path)).ToList(); - var allLocalTracks = localAlbumRelease.LocalTracks.Concat(extraTracks).DistinctBy(x => x.Path).ToList(); + var allLocalTracks = localAlbumRelease.LocalBooks.Concat(extraTracks).DistinctBy(x => x.Path).ToList(); var distance = DistanceCalculator.BookDistance(allLocalTracks, release); var currDistance = distance.NormalizedDistance(); diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/IdentificationTestCase.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/IdentificationTestCase.cs similarity index 74% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Identification/IdentificationTestCase.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Identification/IdentificationTestCase.cs index 0e2dabb40..1ed184f02 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/IdentificationTestCase.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/IdentificationTestCase.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Metadata; -namespace NzbDrone.Core.MediaFiles.TrackImport.Identification +namespace NzbDrone.Core.MediaFiles.BookImport.Identification { public class BasicLocalTrack { @@ -10,9 +10,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification public ParsedTrackInfo FileTrackInfo { get; set; } } - public class ArtistTestCase + public class AuthorTestCase { - public string Artist { get; set; } + public string Author { get; set; } public MetadataProfile MetadataProfile { get; set; } } @@ -25,9 +25,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification public class IdTestCase { public List<string> ExpectedMusicBrainzReleaseIds { get; set; } - public List<ArtistTestCase> LibraryArtists { get; set; } - public string Artist { get; set; } - public string Album { get; set; } + public List<AuthorTestCase> LibraryAuthors { get; set; } + public string Author { get; set; } + public string Book { get; set; } public string Release { get; set; } public bool NewDownload { get; set; } public bool SingleRelease { get; set; } diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/Munkres.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/Munkres.cs similarity index 99% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Identification/Munkres.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Identification/Munkres.cs index 02348ee10..151d0c185 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/Munkres.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/Munkres.cs @@ -32,7 +32,7 @@ using System; using System.Collections.Generic; using System.Linq; -namespace NzbDrone.Core.MediaFiles.TrackImport.Identification +namespace NzbDrone.Core.MediaFiles.BookImport.Identification { public class Munkres { diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/TrackGroupingService.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/TrackGroupingService.cs similarity index 91% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Identification/TrackGroupingService.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Identification/TrackGroupingService.cs index 7607951b6..c059c27ac 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/TrackGroupingService.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/TrackGroupingService.cs @@ -10,11 +10,11 @@ using NzbDrone.Common.Instrumentation; using NzbDrone.Common.Instrumentation.Extensions; using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.MediaFiles.TrackImport.Identification +namespace NzbDrone.Core.MediaFiles.BookImport.Identification { public interface ITrackGroupingService { - List<LocalAlbumRelease> GroupTracks(List<LocalTrack> localTracks); + List<LocalAlbumRelease> GroupTracks(List<LocalBook> localTracks); } public class TrackGroupingService : ITrackGroupingService @@ -25,7 +25,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification private static readonly string MultiDiscPatternFormat = @"^(?<root>.*%s[\W_]*)\d"; private static readonly List<string> VariousArtistTitles = new List<string> { "", "various artists", "various", "va", "unknown" }; - public List<LocalAlbumRelease> GroupTracks(List<LocalTrack> localTracks) + public List<LocalAlbumRelease> GroupTracks(List<LocalBook> localTracks) { _logger.ProgressInfo($"Grouping {localTracks.Count} tracks"); @@ -35,11 +35,11 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification var textfiles = localTracks.Where(x => MediaFileExtensions.TextExtensions.Contains(Path.GetExtension(x.Path))); foreach (var file in textfiles) { - releases.Add(new LocalAlbumRelease(new List<LocalTrack> { file })); + releases.Add(new LocalAlbumRelease(new List<LocalBook> { file })); } // first attempt, assume grouped by folder - var unprocessed = new List<LocalTrack>(); + var unprocessed = new List<LocalBook>(); foreach (var group in GroupTracksByDirectory(localTracks.Except(textfiles).ToList())) { var tracks = group.ToList(); @@ -54,7 +54,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification } // If anything didn't get grouped correctly, try grouping by Album (to pick up VA) - var unprocessed2 = new List<LocalTrack>(); + var unprocessed2 = new List<LocalBook>(); foreach (var group in unprocessed.GroupBy(x => x.FileTrackInfo.AlbumTitle)) { _logger.Debug("Falling back to grouping by album tag"); @@ -72,7 +72,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification // Finally fall back to grouping by Album/Artist pair foreach (var group in unprocessed2.GroupBy(x => new { x.FileTrackInfo.ArtistTitle, x.FileTrackInfo.AlbumTitle })) { - _logger.Debug("Falling back to grouping by album+artist tag"); + _logger.Debug("Falling back to grouping by album+author tag"); releases.Add(new LocalAlbumRelease(group.ToList())); } @@ -111,11 +111,11 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification return true; } - public static bool LooksLikeSingleRelease(List<LocalTrack> tracks) + public static bool LooksLikeSingleRelease(List<LocalBook> tracks) { // returns true if we think all the tracks belong to a single release - // artist/album tags must be the same for 75% of tracks, with no more than 25% having different values + // author/album tags must be the same for 75% of tracks, with no more than 25% having different values // (except in the case of various artists) const double albumTagThreshold = 0.25; const double artistTagThreshold = 0.25; @@ -143,7 +143,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification var artistTags = tracks.Select(x => x.FileTrackInfo.ArtistTitle); if (!HasCommonEntry(artistTags, artistTagThreshold, tagFuzz)) { - _logger.Trace("LooksLikeSingleRelease: No common artist tag"); + _logger.Trace("LooksLikeSingleRelease: No common author tag"); return false; } } @@ -151,10 +151,10 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification return true; } - public static bool IsVariousArtists(List<LocalTrack> tracks) + public static bool IsVariousArtists(List<LocalBook> tracks) { // checks whether most common title is a known VA title - // Also checks whether more than 75% of tracks have a distinct artist and that the most common artist + // Also checks whether more than 75% of tracks have a distinct author and that the most common author // is responsible for < 25% of tracks const double artistTagThreshold = 0.75; const double tagFuzz = 0.9; @@ -174,7 +174,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification return false; } - private IEnumerable<List<LocalTrack>> GroupTracksByDirectory(List<LocalTrack> tracks) + private IEnumerable<List<LocalBook>> GroupTracksByDirectory(List<LocalBook> tracks) { // we want to check for layouts like: // xx/CD1/1.mp3 @@ -193,7 +193,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification _logger.Trace("Folders:\n{0}", string.Join("\n", distinctFolders)); Regex subdirRegex = null; - var output = new List<LocalTrack>(); + var output = new List<LocalBook>(); foreach (var folder in distinctFolders) { if (subdirRegex != null) @@ -213,7 +213,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification _logger.Trace("Yielding from 1:\n{0}", string.Join("\n", output)); yield return output; - output = new List<LocalTrack>(); + output = new List<LocalBook>(); } // reset and put current folder into output @@ -245,7 +245,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification yield return output; // reset output - output = new List<LocalTrack>(); + output = new List<LocalBook>(); } } diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/ImportApprovedTracks.cs b/src/NzbDrone.Core/MediaFiles/BookImport/ImportApprovedBooks.cs similarity index 61% rename from src/NzbDrone.Core/MediaFiles/TrackImport/ImportApprovedTracks.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/ImportApprovedBooks.cs index 52d17aa1b..8cfcb3675 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/ImportApprovedTracks.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/ImportApprovedBooks.cs @@ -5,35 +5,35 @@ using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; using NzbDrone.Common.Instrumentation.Extensions; +using NzbDrone.Core.Books; +using NzbDrone.Core.Books.Commands; +using NzbDrone.Core.Books.Events; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Extras; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; -using NzbDrone.Core.Music.Commands; -using NzbDrone.Core.Music.Events; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; using NzbDrone.Core.RootFolders; -namespace NzbDrone.Core.MediaFiles.TrackImport +namespace NzbDrone.Core.MediaFiles.BookImport { - public interface IImportApprovedTracks + public interface IImportApprovedBooks { - List<ImportResult> Import(List<ImportDecision<LocalTrack>> decisions, bool replaceExisting, DownloadClientItem downloadClientItem = null, ImportMode importMode = ImportMode.Auto); + List<ImportResult> Import(List<ImportDecision<LocalBook>> decisions, bool replaceExisting, DownloadClientItem downloadClientItem = null, ImportMode importMode = ImportMode.Auto); } - public class ImportApprovedTracks : IImportApprovedTracks + public class ImportApprovedBooks : IImportApprovedBooks { - private readonly IUpgradeMediaFiles _trackFileUpgrader; + private readonly IUpgradeMediaFiles _bookFileUpgrader; private readonly IMediaFileService _mediaFileService; private readonly IAudioTagService _audioTagService; - private readonly IArtistService _artistService; - private readonly IAddArtistService _addArtistService; - private readonly IAlbumService _albumService; + private readonly IAuthorService _authorService; + private readonly IAddAuthorService _addAuthorService; + private readonly IBookService _bookService; private readonly IRootFolderService _rootFolderService; private readonly IRecycleBinProvider _recycleBinProvider; private readonly IExtraService _extraService; @@ -42,12 +42,12 @@ namespace NzbDrone.Core.MediaFiles.TrackImport private readonly IManageCommandQueue _commandQueueManager; private readonly Logger _logger; - public ImportApprovedTracks(IUpgradeMediaFiles trackFileUpgrader, + public ImportApprovedBooks(IUpgradeMediaFiles trackFileUpgrader, IMediaFileService mediaFileService, IAudioTagService audioTagService, - IArtistService artistService, - IAddArtistService addArtistService, - IAlbumService albumService, + IAuthorService authorService, + IAddAuthorService addAuthorService, + IBookService bookService, IRootFolderService rootFolderService, IRecycleBinProvider recycleBinProvider, IExtraService extraService, @@ -56,12 +56,12 @@ namespace NzbDrone.Core.MediaFiles.TrackImport IManageCommandQueue commandQueueManager, Logger logger) { - _trackFileUpgrader = trackFileUpgrader; + _bookFileUpgrader = trackFileUpgrader; _mediaFileService = mediaFileService; _audioTagService = audioTagService; - _artistService = artistService; - _addArtistService = addArtistService; - _albumService = albumService; + _authorService = authorService; + _addAuthorService = addAuthorService; + _bookService = bookService; _rootFolderService = rootFolderService; _recycleBinProvider = recycleBinProvider; _extraService = extraService; @@ -71,52 +71,52 @@ namespace NzbDrone.Core.MediaFiles.TrackImport _logger = logger; } - public List<ImportResult> Import(List<ImportDecision<LocalTrack>> decisions, bool replaceExisting, DownloadClientItem downloadClientItem = null, ImportMode importMode = ImportMode.Auto) + public List<ImportResult> Import(List<ImportDecision<LocalBook>> decisions, bool replaceExisting, DownloadClientItem downloadClientItem = null, ImportMode importMode = ImportMode.Auto) { var importResults = new List<ImportResult>(); var allImportedTrackFiles = new List<BookFile>(); var allOldTrackFiles = new List<BookFile>(); - var addedArtists = new List<Author>(); + var addedAuthors = new List<Author>(); - var albumDecisions = decisions.Where(e => e.Item.Album != null && e.Approved) - .GroupBy(e => e.Item.Album.ForeignBookId).ToList(); + var bookDecisions = decisions.Where(e => e.Item.Book != null && e.Approved) + .GroupBy(e => e.Item.Book.ForeignBookId).ToList(); int iDecision = 1; - foreach (var albumDecision in albumDecisions) + foreach (var albumDecision in bookDecisions) { - _logger.ProgressInfo($"Importing book {iDecision++}/{albumDecisions.Count} {albumDecision.First().Item.Album}"); + _logger.ProgressInfo($"Importing book {iDecision++}/{bookDecisions.Count} {albumDecision.First().Item.Book}"); var decisionList = albumDecision.ToList(); - var artist = EnsureArtistAdded(decisionList, addedArtists); + var author = EnsureAuthorAdded(decisionList, addedAuthors); - if (artist == null) + if (author == null) { - // failed to add the artist, carry on with next album + // failed to add the author, carry on with next book continue; } - var album = EnsureAlbumAdded(decisionList); + var book = EnsureBookAdded(decisionList); - if (album == null) + if (book == null) { - // failed to add the album, carry on with next one + // failed to add the book, carry on with next one continue; } if (replaceExisting) { - RemoveExistingTrackFiles(artist, album); + RemoveExistingTrackFiles(author, book); } - // Publish album edited event. - // Deliberatly don't put in the old album since we don't want to trigger an ArtistScan. - _eventAggregator.PublishEvent(new AlbumEditedEvent(album, album)); + // Publish book edited event. + // Deliberatly don't put in the old book since we don't want to trigger an ArtistScan. + _eventAggregator.PublishEvent(new BookEditedEvent(book, book)); } var qualifiedImports = decisions.Where(c => c.Approved) - .GroupBy(c => c.Item.Artist.Id, (i, s) => s - .OrderByDescending(c => c.Item.Quality, new QualityModelComparer(s.First().Item.Artist.QualityProfile)) + .GroupBy(c => c.Item.Author.Id, (i, s) => s + .OrderByDescending(c => c.Item.Quality, new QualityModelComparer(s.First().Item.Author.QualityProfile)) .ThenByDescending(c => c.Item.Size)) .SelectMany(c => c) .ToList(); @@ -135,15 +135,15 @@ namespace NzbDrone.Core.MediaFiles.TrackImport try { //check if already imported - if (importResults.Select(r => r.ImportDecision.Item.Album.Id).Contains(localTrack.Album.Id)) + if (importResults.Select(r => r.ImportDecision.Item.Book.Id).Contains(localTrack.Book.Id)) { importResults.Add(new ImportResult(importDecision, "Book has already been imported")); continue; } - localTrack.Album.Author = localTrack.Artist; + localTrack.Book.Author = localTrack.Author; - var trackFile = new BookFile + var bookFile = new BookFile { Path = localTrack.Path.CleanFilePath(), Size = localTrack.Size, @@ -152,9 +152,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport ReleaseGroup = localTrack.ReleaseGroup, Quality = localTrack.Quality, MediaInfo = localTrack.FileTrackInfo.MediaInfo, - BookId = localTrack.Album.Id, - Artist = localTrack.Artist, - Album = localTrack.Album + BookId = localTrack.Book.Id, + Author = localTrack.Author, + Book = localTrack.Book }; bool copyOnly; @@ -174,15 +174,15 @@ namespace NzbDrone.Core.MediaFiles.TrackImport if (!localTrack.ExistingFile) { - trackFile.SceneName = GetSceneReleaseName(downloadClientItem); + bookFile.SceneName = GetSceneReleaseName(downloadClientItem); - var moveResult = _trackFileUpgrader.UpgradeTrackFile(trackFile, localTrack, copyOnly); + var moveResult = _bookFileUpgrader.UpgradeBookFile(bookFile, localTrack, copyOnly); oldFiles = moveResult.OldFiles; } else { // Delete existing files from the DB mapped to this path - var previousFile = _mediaFileService.GetFileWithPath(trackFile.Path); + var previousFile = _mediaFileService.GetFileWithPath(bookFile.Path); if (previousFile != null) { @@ -192,50 +192,50 @@ namespace NzbDrone.Core.MediaFiles.TrackImport var rootFolder = _rootFolderService.GetBestRootFolder(localTrack.Path); if (rootFolder.IsCalibreLibrary) { - trackFile.CalibreId = trackFile.Path.ParseCalibreId(); + bookFile.CalibreId = bookFile.Path.ParseCalibreId(); } - _audioTagService.WriteTags(trackFile, false); + _audioTagService.WriteTags(bookFile, false); } - filesToAdd.Add(trackFile); + filesToAdd.Add(bookFile); importResults.Add(new ImportResult(importDecision)); if (!localTrack.ExistingFile) { - _extraService.ImportTrack(localTrack, trackFile, copyOnly); + _extraService.ImportTrack(localTrack, bookFile, copyOnly); } - allImportedTrackFiles.Add(trackFile); + allImportedTrackFiles.Add(bookFile); allOldTrackFiles.AddRange(oldFiles); // create all the import events here, but we can't publish until the trackfiles have been // inserted and ids created - trackImportedEvents.Add(new TrackImportedEvent(localTrack, trackFile, oldFiles, !localTrack.ExistingFile, downloadClientItem)); + trackImportedEvents.Add(new TrackImportedEvent(localTrack, bookFile, oldFiles, !localTrack.ExistingFile, downloadClientItem)); } catch (RootFolderNotFoundException e) { - _logger.Warn(e, "Couldn't import track " + localTrack); + _logger.Warn(e, "Couldn't import book " + localTrack); _eventAggregator.PublishEvent(new TrackImportFailedEvent(e, localTrack, !localTrack.ExistingFile, downloadClientItem)); - importResults.Add(new ImportResult(importDecision, "Failed to import track, Root folder missing.")); + importResults.Add(new ImportResult(importDecision, "Failed to import book, Root folder missing.")); } catch (DestinationAlreadyExistsException e) { - _logger.Warn(e, "Couldn't import track " + localTrack); - importResults.Add(new ImportResult(importDecision, "Failed to import track, Destination already exists.")); + _logger.Warn(e, "Couldn't import book " + localTrack); + importResults.Add(new ImportResult(importDecision, "Failed to import book, Destination already exists.")); } catch (UnauthorizedAccessException e) { - _logger.Warn(e, "Couldn't import track " + localTrack); + _logger.Warn(e, "Couldn't import book " + localTrack); _eventAggregator.PublishEvent(new TrackImportFailedEvent(e, localTrack, !localTrack.ExistingFile, downloadClientItem)); - importResults.Add(new ImportResult(importDecision, "Failed to import track, Permissions error")); + importResults.Add(new ImportResult(importDecision, "Failed to import book, Permissions error")); } catch (Exception e) { - _logger.Warn(e, "Couldn't import track " + localTrack); - importResults.Add(new ImportResult(importDecision, "Failed to import track")); + _logger.Warn(e, "Couldn't import book " + localTrack); + importResults.Add(new ImportResult(importDecision, "Failed to import book")); } } @@ -250,21 +250,21 @@ namespace NzbDrone.Core.MediaFiles.TrackImport _eventAggregator.PublishEvent(trackImportedEvent); } - var albumImports = importResults.Where(e => e.ImportDecision.Item.Album != null) - .GroupBy(e => e.ImportDecision.Item.Album.Id).ToList(); + var albumImports = importResults.Where(e => e.ImportDecision.Item.Book != null) + .GroupBy(e => e.ImportDecision.Item.Book.Id).ToList(); foreach (var albumImport in albumImports) { - var album = albumImport.First().ImportDecision.Item.Album; - var artist = albumImport.First().ImportDecision.Item.Artist; + var book = albumImport.First().ImportDecision.Item.Book; + var author = albumImport.First().ImportDecision.Item.Author; - if (albumImport.Where(e => e.Errors.Count == 0).ToList().Count > 0 && artist != null && album != null) + if (albumImport.Where(e => e.Errors.Count == 0).ToList().Count > 0 && author != null && book != null) { - _eventAggregator.PublishEvent(new AlbumImportedEvent( - artist, - album, - allImportedTrackFiles.Where(s => s.BookId == album.Id).ToList(), - allOldTrackFiles.Where(s => s.BookId == album.Id).ToList(), + _eventAggregator.PublishEvent(new BookImportedEvent( + author, + book, + allImportedTrackFiles.Where(s => s.BookId == book.Id).ToList(), + allOldTrackFiles.Where(s => s.BookId == book.Id).ToList(), replaceExisting, downloadClientItem)); } @@ -275,134 +275,134 @@ namespace NzbDrone.Core.MediaFiles.TrackImport .Select(d => new ImportResult(d, d.Rejections.Select(r => r.Reason).ToArray()))); // Refresh any artists we added - if (addedArtists.Any()) + if (addedAuthors.Any()) { - _commandQueueManager.Push(new BulkRefreshArtistCommand(addedArtists.Select(x => x.Id).ToList(), true)); + _commandQueueManager.Push(new BulkRefreshAuthorCommand(addedAuthors.Select(x => x.Id).ToList(), true)); } return importResults; } - private Author EnsureArtistAdded(List<ImportDecision<LocalTrack>> decisions, List<Author> addedArtists) + private Author EnsureAuthorAdded(List<ImportDecision<LocalBook>> decisions, List<Author> addedArtists) { - var artist = decisions.First().Item.Artist; + var author = decisions.First().Item.Author; - if (artist.Id == 0) + if (author.Id == 0) { - var dbArtist = _artistService.FindById(artist.ForeignAuthorId); + var dbArtist = _authorService.FindById(author.ForeignAuthorId); if (dbArtist == null) { - _logger.Debug($"Adding remote artist {artist}"); + _logger.Debug($"Adding remote author {author}"); var path = decisions.First().Item.Path; var rootFolder = _rootFolderService.GetBestRootFolder(path); - artist.RootFolderPath = rootFolder.Path; - artist.MetadataProfileId = rootFolder.DefaultMetadataProfileId; - artist.QualityProfileId = rootFolder.DefaultQualityProfileId; - artist.Monitored = rootFolder.DefaultMonitorOption != MonitorTypes.None; - artist.Tags = rootFolder.DefaultTags; - artist.AddOptions = new AddArtistOptions + author.RootFolderPath = rootFolder.Path; + author.MetadataProfileId = rootFolder.DefaultMetadataProfileId; + author.QualityProfileId = rootFolder.DefaultQualityProfileId; + author.Monitored = rootFolder.DefaultMonitorOption != MonitorTypes.None; + author.Tags = rootFolder.DefaultTags; + author.AddOptions = new AddAuthorOptions { SearchForMissingAlbums = false, - Monitored = artist.Monitored, + Monitored = author.Monitored, Monitor = rootFolder.DefaultMonitorOption }; if (rootFolder.IsCalibreLibrary) { - // calibre has artist / book / files - artist.Path = path.GetParentPath().GetParentPath(); + // calibre has author / book / files + author.Path = path.GetParentPath().GetParentPath(); } try { - dbArtist = _addArtistService.AddArtist(artist, false); + dbArtist = _addAuthorService.AddAuthor(author, false); addedArtists.Add(dbArtist); } catch (Exception e) { - _logger.Error(e, "Failed to add artist {0}", artist); + _logger.Error(e, "Failed to add author {0}", author); foreach (var decision in decisions) { - decision.Reject(new Rejection("Failed to add missing artist", RejectionType.Temporary)); + decision.Reject(new Rejection("Failed to add missing author", RejectionType.Temporary)); } return null; } } - // Put in the newly loaded artist + // Put in the newly loaded author foreach (var decision in decisions) { - decision.Item.Artist = dbArtist; - decision.Item.Album.Author = dbArtist; - decision.Item.Album.AuthorMetadataId = dbArtist.AuthorMetadataId; + decision.Item.Author = dbArtist; + decision.Item.Book.Author = dbArtist; + decision.Item.Book.AuthorMetadataId = dbArtist.AuthorMetadataId; } - artist = dbArtist; + author = dbArtist; } - return artist; + return author; } - private Book EnsureAlbumAdded(List<ImportDecision<LocalTrack>> decisions) + private Book EnsureBookAdded(List<ImportDecision<LocalBook>> decisions) { - var album = decisions.First().Item.Album; + var book = decisions.First().Item.Book; - if (album.Id == 0) + if (book.Id == 0) { - var dbAlbum = _albumService.FindById(album.ForeignBookId); + var dbAlbum = _bookService.FindById(book.ForeignBookId); if (dbAlbum == null) { - _logger.Debug($"Adding remote album {album}"); + _logger.Debug($"Adding remote book {book}"); try { - album.Added = DateTime.UtcNow; - _albumService.InsertMany(new List<Book> { album }); - dbAlbum = _albumService.FindById(album.ForeignBookId); + book.Added = DateTime.UtcNow; + _bookService.InsertMany(new List<Book> { book }); + dbAlbum = _bookService.FindById(book.ForeignBookId); } catch (Exception e) { - _logger.Error(e, "Failed to add album {0}", album); + _logger.Error(e, "Failed to add book {0}", book); RejectAlbum(decisions); return null; } } - // Populate the new DB album + // Populate the new DB book foreach (var decision in decisions) { - decision.Item.Album = dbAlbum; + decision.Item.Book = dbAlbum; } } - return album; + return book; } - private void RejectAlbum(List<ImportDecision<LocalTrack>> decisions) + private void RejectAlbum(List<ImportDecision<LocalBook>> decisions) { foreach (var decision in decisions) { - decision.Reject(new Rejection("Failed to add missing album", RejectionType.Temporary)); + decision.Reject(new Rejection("Failed to add missing book", RejectionType.Temporary)); } } - private void RemoveExistingTrackFiles(Author artist, Book album) + private void RemoveExistingTrackFiles(Author author, Book book) { - var rootFolder = _diskProvider.GetParentFolder(artist.Path); - var previousFiles = _mediaFileService.GetFilesByAlbum(album.Id); + var rootFolder = _diskProvider.GetParentFolder(author.Path); + var previousFiles = _mediaFileService.GetFilesByBook(book.Id); - _logger.Debug($"Deleting {previousFiles.Count} existing files for {album}"); + _logger.Debug($"Deleting {previousFiles.Count} existing files for {book}"); foreach (var previousFile in previousFiles) { var subfolder = rootFolder.GetRelativePath(_diskProvider.GetParentFolder(previousFile.Path)); if (_diskProvider.FileExists(previousFile.Path)) { - _logger.Debug("Removing existing track file: {0}", previousFile); + _logger.Debug("Removing existing book file: {0}", previousFile); _recycleBinProvider.DeleteFile(previousFile.Path, subfolder); } @@ -416,7 +416,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport { var title = Parser.Parser.RemoveFileExtension(downloadClientItem.Title); - var parsedTitle = Parser.Parser.ParseAlbumTitle(title); + var parsedTitle = Parser.Parser.ParseBookTitle(title); if (parsedTitle != null) { diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/ImportArtistDefaults.cs b/src/NzbDrone.Core/MediaFiles/BookImport/ImportArtistDefaults.cs similarity index 83% rename from src/NzbDrone.Core/MediaFiles/TrackImport/ImportArtistDefaults.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/ImportArtistDefaults.cs index ab0b4e0c1..80e36e1ea 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/ImportArtistDefaults.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/ImportArtistDefaults.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; -namespace NzbDrone.Core.MediaFiles.TrackImport +namespace NzbDrone.Core.MediaFiles.BookImport { public class ImportArtistDefaults { diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/ImportDecision.cs b/src/NzbDrone.Core/MediaFiles/BookImport/ImportDecision.cs similarity index 92% rename from src/NzbDrone.Core/MediaFiles/TrackImport/ImportDecision.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/ImportDecision.cs index fb15eca90..d8a90350f 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/ImportDecision.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/ImportDecision.cs @@ -3,7 +3,7 @@ using System.Linq; using NzbDrone.Common.Extensions; using NzbDrone.Core.DecisionEngine; -namespace NzbDrone.Core.MediaFiles.TrackImport +namespace NzbDrone.Core.MediaFiles.BookImport { public class ImportDecision<T> { diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/ImportDecisionMaker.cs b/src/NzbDrone.Core/MediaFiles/BookImport/ImportDecisionMaker.cs similarity index 75% rename from src/NzbDrone.Core/MediaFiles/TrackImport/ImportDecisionMaker.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/ImportDecisionMaker.cs index 794730a70..9c32f7596 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/ImportDecisionMaker.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/ImportDecisionMaker.cs @@ -5,25 +5,25 @@ using System.Linq; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Common.Instrumentation.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; -using NzbDrone.Core.MediaFiles.TrackImport.Aggregation; -using NzbDrone.Core.MediaFiles.TrackImport.Identification; -using NzbDrone.Core.Music; +using NzbDrone.Core.MediaFiles.BookImport.Aggregation; +using NzbDrone.Core.MediaFiles.BookImport.Identification; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Qualities; using NzbDrone.Core.RootFolders; -namespace NzbDrone.Core.MediaFiles.TrackImport +namespace NzbDrone.Core.MediaFiles.BookImport { public interface IMakeImportDecision { - List<ImportDecision<LocalTrack>> GetImportDecisions(List<IFileInfo> musicFiles, IdentificationOverrides idOverrides, ImportDecisionMakerInfo itemInfo, ImportDecisionMakerConfig config); + List<ImportDecision<LocalBook>> GetImportDecisions(List<IFileInfo> musicFiles, IdentificationOverrides idOverrides, ImportDecisionMakerInfo itemInfo, ImportDecisionMakerConfig config); } public class IdentificationOverrides { - public Author Artist { get; set; } + public Author Author { get; set; } public Book Album { get; set; } } @@ -39,13 +39,13 @@ namespace NzbDrone.Core.MediaFiles.TrackImport public bool NewDownload { get; set; } public bool SingleRelease { get; set; } public bool IncludeExisting { get; set; } - public bool AddNewArtists { get; set; } + public bool AddNewAuthors { get; set; } } public class ImportDecisionMaker : IMakeImportDecision { - private readonly IEnumerable<IImportDecisionEngineSpecification<LocalTrack>> _trackSpecifications; - private readonly IEnumerable<IImportDecisionEngineSpecification<LocalAlbumRelease>> _albumSpecifications; + private readonly IEnumerable<IImportDecisionEngineSpecification<LocalBook>> _trackSpecifications; + private readonly IEnumerable<IImportDecisionEngineSpecification<LocalAlbumRelease>> _bookSpecifications; private readonly IMediaFileService _mediaFileService; private readonly IEBookTagService _eBookTagService; private readonly IAudioTagService _audioTagService; @@ -55,7 +55,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport private readonly IProfileService _qualityProfileService; private readonly Logger _logger; - public ImportDecisionMaker(IEnumerable<IImportDecisionEngineSpecification<LocalTrack>> trackSpecifications, + public ImportDecisionMaker(IEnumerable<IImportDecisionEngineSpecification<LocalBook>> trackSpecifications, IEnumerable<IImportDecisionEngineSpecification<LocalAlbumRelease>> albumSpecifications, IMediaFileService mediaFileService, IEBookTagService eBookTagService, @@ -67,7 +67,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport Logger logger) { _trackSpecifications = trackSpecifications; - _albumSpecifications = albumSpecifications; + _bookSpecifications = albumSpecifications; _mediaFileService = mediaFileService; _eBookTagService = eBookTagService; _audioTagService = audioTagService; @@ -78,15 +78,15 @@ namespace NzbDrone.Core.MediaFiles.TrackImport _logger = logger; } - public Tuple<List<LocalTrack>, List<ImportDecision<LocalTrack>>> GetLocalTracks(List<IFileInfo> musicFiles, DownloadClientItem downloadClientItem, ParsedTrackInfo folderInfo, FilterFilesType filter) + public Tuple<List<LocalBook>, List<ImportDecision<LocalBook>>> GetLocalTracks(List<IFileInfo> musicFiles, DownloadClientItem downloadClientItem, ParsedTrackInfo folderInfo, FilterFilesType filter) { var watch = new System.Diagnostics.Stopwatch(); watch.Start(); var files = _mediaFileService.FilterUnchangedFiles(musicFiles, filter); - var localTracks = new List<LocalTrack>(); - var decisions = new List<ImportDecision<LocalTrack>>(); + var localTracks = new List<LocalBook>(); + var decisions = new List<ImportDecision<LocalBook>>(); _logger.Debug("Analyzing {0}/{1} files.", files.Count, musicFiles.Count); @@ -95,11 +95,11 @@ namespace NzbDrone.Core.MediaFiles.TrackImport return Tuple.Create(localTracks, decisions); } - ParsedAlbumInfo downloadClientItemInfo = null; + ParsedBookInfo downloadClientItemInfo = null; if (downloadClientItem != null) { - downloadClientItemInfo = Parser.Parser.ParseAlbumTitle(downloadClientItem.Title); + downloadClientItemInfo = Parser.Parser.ParseBookTitle(downloadClientItem.Title); } int i = 1; @@ -107,7 +107,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport { _logger.ProgressInfo($"Reading file {i++}/{files.Count}"); - var localTrack = new LocalTrack + var localTrack = new LocalBook { DownloadClientAlbumInfo = downloadClientItemInfo, FolderTrackInfo = folderInfo, @@ -126,13 +126,13 @@ namespace NzbDrone.Core.MediaFiles.TrackImport } catch (AugmentingFailedException) { - decisions.Add(new ImportDecision<LocalTrack>(localTrack, new Rejection("Unable to parse file"))); + decisions.Add(new ImportDecision<LocalBook>(localTrack, new Rejection("Unable to parse file"))); } catch (Exception e) { _logger.Error(e, "Couldn't import file. {0}", localTrack.Path); - decisions.Add(new ImportDecision<LocalTrack>(localTrack, new Rejection("Unexpected error processing file"))); + decisions.Add(new ImportDecision<LocalBook>(localTrack, new Rejection("Unexpected error processing file"))); } } @@ -141,7 +141,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport return Tuple.Create(localTracks, decisions); } - public List<ImportDecision<LocalTrack>> GetImportDecisions(List<IFileInfo> musicFiles, IdentificationOverrides idOverrides, ImportDecisionMakerInfo itemInfo, ImportDecisionMakerConfig config) + public List<ImportDecision<LocalBook>> GetImportDecisions(List<IFileInfo> musicFiles, IdentificationOverrides idOverrides, ImportDecisionMakerInfo itemInfo, ImportDecisionMakerConfig config) { idOverrides = idOverrides ?? new IdentificationOverrides(); itemInfo = itemInfo ?? new ImportDecisionMakerInfo(); @@ -156,14 +156,14 @@ namespace NzbDrone.Core.MediaFiles.TrackImport foreach (var release in releases) { - // make sure the appropriate quality profile is set for the release artist - // in case it's a new artist + // make sure the appropriate quality profile is set for the release author + // in case it's a new author EnsureData(release); release.NewDownload = config.NewDownload; var releaseDecision = GetDecision(release, itemInfo.DownloadClientItem); - foreach (var localTrack in release.LocalTracks) + foreach (var localTrack in release.LocalBooks) { if (releaseDecision.Approved) { @@ -171,7 +171,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport } else { - decisions.Add(new ImportDecision<LocalTrack>(localTrack, releaseDecision.Rejections.ToArray())); + decisions.Add(new ImportDecision<LocalBook>(localTrack, releaseDecision.Rejections.ToArray())); } } } @@ -183,12 +183,12 @@ namespace NzbDrone.Core.MediaFiles.TrackImport { if (release.Book != null && release.Book.Author.Value.QualityProfileId == 0) { - var rootFolder = _rootFolderService.GetBestRootFolder(release.LocalTracks.First().Path); + var rootFolder = _rootFolderService.GetBestRootFolder(release.LocalBooks.First().Path); var qualityProfile = _qualityProfileService.Get(rootFolder.DefaultQualityProfileId); - var artist = release.Book.Author.Value; - artist.QualityProfileId = qualityProfile.Id; - artist.QualityProfile = qualityProfile; + var author = release.Book.Author.Value; + author.QualityProfileId = qualityProfile.Id; + author.QualityProfile = qualityProfile; } } @@ -202,7 +202,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport } else { - var reasons = _albumSpecifications.Select(c => EvaluateSpec(c, localAlbumRelease, downloadClientItem)) + var reasons = _bookSpecifications.Select(c => EvaluateSpec(c, localAlbumRelease, downloadClientItem)) .Where(c => c != null); decision = new ImportDecision<LocalAlbumRelease>(localAlbumRelease, reasons.ToArray()); @@ -224,25 +224,25 @@ namespace NzbDrone.Core.MediaFiles.TrackImport return decision; } - private ImportDecision<LocalTrack> GetDecision(LocalTrack localTrack, DownloadClientItem downloadClientItem) + private ImportDecision<LocalBook> GetDecision(LocalBook localBook, DownloadClientItem downloadClientItem) { - ImportDecision<LocalTrack> decision = null; + ImportDecision<LocalBook> decision = null; - if (localTrack.Album == null) + if (localBook.Book == null) { - decision = new ImportDecision<LocalTrack>(localTrack, new Rejection($"Couldn't parse album from: {localTrack.FileTrackInfo}")); + decision = new ImportDecision<LocalBook>(localBook, new Rejection($"Couldn't parse book from: {localBook.FileTrackInfo}")); } else { - var reasons = _trackSpecifications.Select(c => EvaluateSpec(c, localTrack, downloadClientItem)) + var reasons = _trackSpecifications.Select(c => EvaluateSpec(c, localBook, downloadClientItem)) .Where(c => c != null); - decision = new ImportDecision<LocalTrack>(localTrack, reasons.ToArray()); + decision = new ImportDecision<LocalBook>(localBook, reasons.ToArray()); } if (decision == null) { - _logger.Error("Unable to make a decision on {0}", localTrack.Path); + _logger.Error("Unable to make a decision on {0}", localBook.Path); } else if (decision.Rejections.Any()) { diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/ImportMode.cs b/src/NzbDrone.Core/MediaFiles/BookImport/ImportMode.cs similarity index 67% rename from src/NzbDrone.Core/MediaFiles/TrackImport/ImportMode.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/ImportMode.cs index 43236bc86..691aa5062 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/ImportMode.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/ImportMode.cs @@ -1,4 +1,4 @@ -namespace NzbDrone.Core.MediaFiles.TrackImport +namespace NzbDrone.Core.MediaFiles.BookImport { public enum ImportMode { diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/ImportResult.cs b/src/NzbDrone.Core/MediaFiles/BookImport/ImportResult.cs similarity index 75% rename from src/NzbDrone.Core/MediaFiles/TrackImport/ImportResult.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/ImportResult.cs index f52cb5260..f6d053cea 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/ImportResult.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/ImportResult.cs @@ -1,13 +1,13 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using NzbDrone.Common.EnsureThat; using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.MediaFiles.TrackImport +namespace NzbDrone.Core.MediaFiles.BookImport { public class ImportResult { - public ImportDecision<LocalTrack> ImportDecision { get; private set; } + public ImportDecision<LocalBook> ImportDecision { get; private set; } public List<string> Errors { get; private set; } public ImportResultType Result @@ -28,7 +28,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport } } - public ImportResult(ImportDecision<LocalTrack> importDecision, params string[] errors) + public ImportResult(ImportDecision<LocalBook> importDecision, params string[] errors) { Ensure.That(importDecision, () => importDecision).IsNotNull(); diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/ImportResultType.cs b/src/NzbDrone.Core/MediaFiles/BookImport/ImportResultType.cs similarity index 66% rename from src/NzbDrone.Core/MediaFiles/TrackImport/ImportResultType.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/ImportResultType.cs index e4e3eaef8..0ab49f407 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/ImportResultType.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/ImportResultType.cs @@ -1,4 +1,4 @@ -namespace NzbDrone.Core.MediaFiles.TrackImport +namespace NzbDrone.Core.MediaFiles.BookImport { public enum ImportResultType { diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Manual/ManualImportCommand.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Manual/ManualImportCommand.cs similarity index 88% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Manual/ManualImportCommand.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Manual/ManualImportCommand.cs index 93e0fc0c1..3dd11f15d 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Manual/ManualImportCommand.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Manual/ManualImportCommand.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using NzbDrone.Core.Messaging.Commands; -namespace NzbDrone.Core.MediaFiles.TrackImport.Manual +namespace NzbDrone.Core.MediaFiles.BookImport.Manual { public class ManualImportCommand : Command { diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Manual/ManualImportFile.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Manual/ManualImportFile.cs similarity index 95% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Manual/ManualImportFile.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Manual/ManualImportFile.cs index 58d28466f..58156d2ca 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Manual/ManualImportFile.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Manual/ManualImportFile.cs @@ -2,7 +2,7 @@ using System; using NzbDrone.Common.Extensions; using NzbDrone.Core.Qualities; -namespace NzbDrone.Core.MediaFiles.TrackImport.Manual +namespace NzbDrone.Core.MediaFiles.BookImport.Manual { public class ManualImportFile : IEquatable<ManualImportFile> { diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Manual/ManualImportItem.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Manual/ManualImportItem.cs similarity index 81% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Manual/ManualImportItem.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Manual/ManualImportItem.cs index e11e1a62b..75621e34e 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Manual/ManualImportItem.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Manual/ManualImportItem.cs @@ -1,11 +1,11 @@ using System.Collections.Generic; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; -namespace NzbDrone.Core.MediaFiles.TrackImport.Manual +namespace NzbDrone.Core.MediaFiles.BookImport.Manual { public class ManualImportItem : ModelBase { @@ -16,8 +16,8 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Manual public string Path { get; set; } public string Name { get; set; } public long Size { get; set; } - public Author Artist { get; set; } - public Book Album { get; set; } + public Author Author { get; set; } + public Book Book { get; set; } public QualityModel Quality { get; set; } public string DownloadId { get; set; } public IEnumerable<Rejection> Rejections { get; set; } diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Manual/ManualImportService.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Manual/ManualImportService.cs similarity index 79% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Manual/ManualImportService.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Manual/ManualImportService.cs index 1e4733beb..bb86e8e0b 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Manual/ManualImportService.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Manual/ManualImportService.cs @@ -9,17 +9,17 @@ using NzbDrone.Common.Crypto; using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; using NzbDrone.Common.Instrumentation.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.RootFolders; -namespace NzbDrone.Core.MediaFiles.TrackImport.Manual +namespace NzbDrone.Core.MediaFiles.BookImport.Manual { public interface IManualImportService { @@ -34,12 +34,12 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Manual private readonly IRootFolderService _rootFolderService; private readonly IDiskScanService _diskScanService; private readonly IMakeImportDecision _importDecisionMaker; - private readonly IArtistService _artistService; - private readonly IAlbumService _albumService; + private readonly IAuthorService _authorService; + private readonly IBookService _bookService; private readonly IAudioTagService _audioTagService; - private readonly IImportApprovedTracks _importApprovedTracks; + private readonly IImportApprovedBooks _importApprovedBooks; private readonly ITrackedDownloadService _trackedDownloadService; - private readonly IDownloadedTracksImportService _downloadedTracksImportService; + private readonly IDownloadedBooksImportService _downloadedTracksImportService; private readonly IEventAggregator _eventAggregator; private readonly Logger _logger; @@ -48,12 +48,12 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Manual IRootFolderService rootFolderService, IDiskScanService diskScanService, IMakeImportDecision importDecisionMaker, - IArtistService artistService, - IAlbumService albumService, + IAuthorService authorService, + IBookService bookService, IAudioTagService audioTagService, - IImportApprovedTracks importApprovedTracks, + IImportApprovedBooks importApprovedBooks, ITrackedDownloadService trackedDownloadService, - IDownloadedTracksImportService downloadedTracksImportService, + IDownloadedBooksImportService downloadedTracksImportService, IEventAggregator eventAggregator, Logger logger) { @@ -62,10 +62,10 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Manual _rootFolderService = rootFolderService; _diskScanService = diskScanService; _importDecisionMaker = importDecisionMaker; - _artistService = artistService; - _albumService = albumService; + _authorService = authorService; + _bookService = bookService; _audioTagService = audioTagService; - _importApprovedTracks = importApprovedTracks; + _importApprovedBooks = importApprovedBooks; _trackedDownloadService = trackedDownloadService; _downloadedTracksImportService = downloadedTracksImportService; _eventAggregator = eventAggregator; @@ -101,7 +101,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Manual NewDownload = true, SingleRelease = false, IncludeExisting = !replaceExistingFiles, - AddNewArtists = false + AddNewAuthors = false }; var decision = _importDecisionMaker.GetImportDecisions(files, null, null, config); @@ -117,28 +117,28 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Manual { DownloadClientItem downloadClientItem = null; var directoryInfo = new DirectoryInfo(folder); - var artist = _parsingService.GetArtist(directoryInfo.Name); + var author = _parsingService.GetArtist(directoryInfo.Name); if (downloadId.IsNotNullOrWhiteSpace()) { var trackedDownload = _trackedDownloadService.Find(downloadId); downloadClientItem = trackedDownload.DownloadItem; - if (artist == null) + if (author == null) { - artist = trackedDownload.RemoteAlbum?.Artist; + author = trackedDownload.RemoteBook?.Author; } } - var artistFiles = _diskScanService.GetAudioFiles(folder).ToList(); + var authorFiles = _diskScanService.GetBookFiles(folder).ToList(); var idOverrides = new IdentificationOverrides { - Artist = artist + Author = author }; var itemInfo = new ImportDecisionMakerInfo { DownloadClientItem = downloadClientItem, - ParsedTrackInfo = Parser.Parser.ParseMusicTitle(directoryInfo.Name) + ParsedTrackInfo = Parser.Parser.ParseTitle(directoryInfo.Name) }; var config = new ImportDecisionMakerConfig { @@ -146,13 +146,13 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Manual NewDownload = true, SingleRelease = false, IncludeExisting = !replaceExistingFiles, - AddNewArtists = false + AddNewAuthors = false }; - var decisions = _importDecisionMaker.GetImportDecisions(artistFiles, idOverrides, itemInfo, config); + var decisions = _importDecisionMaker.GetImportDecisions(authorFiles, idOverrides, itemInfo, config); // paths will be different for new and old files which is why we need to map separately - var newFiles = artistFiles.Join(decisions, + var newFiles = authorFiles.Join(decisions, f => f.FullName, d => d.Item.Path, (f, d) => new { File = f, Decision = d }, @@ -168,7 +168,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Manual public List<ManualImportItem> UpdateItems(List<ManualImportItem> items) { var replaceExistingFiles = items.All(x => x.ReplaceExistingFiles); - var groupedItems = items.Where(x => !x.AdditionalFile).GroupBy(x => x.Album?.Id); + var groupedItems = items.Where(x => !x.AdditionalFile).GroupBy(x => x.Book?.Id); _logger.Debug($"UpdateItems, {groupedItems.Count()} groups, replaceExisting {replaceExistingFiles}"); var result = new List<ManualImportItem>(); @@ -180,8 +180,8 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Manual var files = group.Select(x => _diskProvider.GetFileInfo(x.Path)).ToList(); var idOverride = new IdentificationOverrides { - Artist = group.First().Artist, - Album = group.First().Album, + Author = group.First().Author, + Album = group.First().Book, }; var config = new ImportDecisionMakerConfig { @@ -189,7 +189,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Manual NewDownload = true, SingleRelease = true, IncludeExisting = !replaceExistingFiles, - AddNewArtists = false + AddNewAuthors = false }; var decisions = _importDecisionMaker.GetImportDecisions(files, idOverride, null, config); @@ -204,14 +204,14 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Manual var item = pair.Item; var decision = pair.Decision; - if (decision.Item.Artist != null) + if (decision.Item.Author != null) { - item.Artist = decision.Item.Artist; + item.Author = decision.Item.Author; } - if (decision.Item.Album != null) + if (decision.Item.Book != null) { - item.Album = decision.Item.Album; + item.Book = decision.Item.Book; } item.Rejections = decision.Rejections; @@ -226,7 +226,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Manual return result; } - private ManualImportItem MapItem(ImportDecision<LocalTrack> decision, string downloadId, bool replaceExistingFiles) + private ManualImportItem MapItem(ImportDecision<LocalBook> decision, string downloadId, bool replaceExistingFiles) { var item = new ManualImportItem(); @@ -235,14 +235,14 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Manual item.Name = Path.GetFileNameWithoutExtension(decision.Item.Path); item.DownloadId = downloadId; - if (decision.Item.Artist != null) + if (decision.Item.Author != null) { - item.Artist = decision.Item.Artist; + item.Author = decision.Item.Author; } - if (decision.Item.Album != null) + if (decision.Item.Book != null) { - item.Album = decision.Item.Album; + item.Book = decision.Item.Book; } item.Quality = decision.Item.Quality; @@ -266,34 +266,34 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Manual foreach (var importBookId in bookIds) { - var albumImportDecisions = new List<ImportDecision<LocalTrack>>(); + var albumImportDecisions = new List<ImportDecision<LocalBook>>(); foreach (var file in importBookId) { _logger.ProgressTrace("Processing file {0} of {1}", fileCount + 1, message.Files.Count); - var artist = _artistService.GetArtist(file.AuthorId); - var album = _albumService.GetAlbum(file.BookId); + var author = _authorService.GetAuthor(file.AuthorId); + var book = _bookService.GetBook(file.BookId); var fileTrackInfo = _audioTagService.ReadTags(file.Path) ?? new ParsedTrackInfo(); var fileInfo = _diskProvider.GetFileInfo(file.Path); - var localTrack = new LocalTrack + var localTrack = new LocalBook { - ExistingFile = artist.Path.IsParentPath(file.Path), + ExistingFile = author.Path.IsParentPath(file.Path), FileTrackInfo = fileTrackInfo, Path = file.Path, Size = fileInfo.Length, Modified = fileInfo.LastWriteTimeUtc, Quality = file.Quality, - Artist = artist, - Album = album + Author = author, + Book = book }; - var importDecision = new ImportDecision<LocalTrack>(localTrack); - if (_rootFolderService.GetBestRootFolder(artist.Path) == null) + var importDecision = new ImportDecision<LocalBook>(localTrack); + if (_rootFolderService.GetBestRootFolder(author.Path) == null) { - _logger.Warn($"Destination artist folder {artist.Path} not in a Root Folder, skipping import"); - importDecision.Reject(new Rejection($"Destination artist folder {artist.Path} is not in a Root Folder")); + _logger.Warn($"Destination author folder {author.Path} not in a Root Folder, skipping import"); + importDecision.Reject(new Rejection($"Destination author folder {author.Path} is not in a Root Folder")); } albumImportDecisions.Add(importDecision); @@ -303,12 +303,12 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Manual var downloadId = importBookId.Select(x => x.DownloadId).FirstOrDefault(x => x.IsNotNullOrWhiteSpace()); if (downloadId.IsNullOrWhiteSpace()) { - imported.AddRange(_importApprovedTracks.Import(albumImportDecisions, message.ReplaceExistingFiles, null, message.ImportMode)); + imported.AddRange(_importApprovedBooks.Import(albumImportDecisions, message.ReplaceExistingFiles, null, message.ImportMode)); } else { var trackedDownload = _trackedDownloadService.Find(downloadId); - var importResults = _importApprovedTracks.Import(albumImportDecisions, message.ReplaceExistingFiles, trackedDownload.DownloadItem, message.ImportMode); + var importResults = _importApprovedBooks.Import(albumImportDecisions, message.ReplaceExistingFiles, trackedDownload.DownloadItem, message.ImportMode); imported.AddRange(importResults); @@ -333,13 +333,13 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Manual { if (_downloadedTracksImportService.ShouldDeleteFolder( _diskProvider.GetDirectoryInfo(trackedDownload.DownloadItem.OutputPath.FullPath), - trackedDownload.RemoteAlbum.Artist) && trackedDownload.DownloadItem.CanMoveFiles) + trackedDownload.RemoteBook.Author) && trackedDownload.DownloadItem.CanMoveFiles) { _diskProvider.DeleteFolder(trackedDownload.DownloadItem.OutputPath.FullPath, true); } } - if (groupedTrackedDownload.Select(c => c.ImportResult).Count(c => c.Result == ImportResultType.Imported) >= Math.Max(1, trackedDownload.RemoteAlbum.Albums.Count)) + if (groupedTrackedDownload.Select(c => c.ImportResult).Count(c => c.Result == ImportResultType.Imported) >= Math.Max(1, trackedDownload.RemoteBook.Books.Count)) { trackedDownload.State = TrackedDownloadState.Imported; _eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload)); diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Manual/ManuallyImportedFile.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Manual/ManuallyImportedFile.cs similarity index 80% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Manual/ManuallyImportedFile.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Manual/ManuallyImportedFile.cs index d5c3b622e..b1abefe74 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Manual/ManuallyImportedFile.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Manual/ManuallyImportedFile.cs @@ -1,6 +1,6 @@ using NzbDrone.Core.Download.TrackedDownloads; -namespace NzbDrone.Core.MediaFiles.TrackImport.Manual +namespace NzbDrone.Core.MediaFiles.BookImport.Manual { public class ManuallyImportedFile { diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/RootFolderNotFoundException.cs b/src/NzbDrone.Core/MediaFiles/BookImport/RootFolderNotFoundException.cs similarity index 93% rename from src/NzbDrone.Core/MediaFiles/TrackImport/RootFolderNotFoundException.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/RootFolderNotFoundException.cs index f865176be..e5a397007 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/RootFolderNotFoundException.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/RootFolderNotFoundException.cs @@ -2,7 +2,7 @@ using System; using System.IO; using System.Runtime.Serialization; -namespace NzbDrone.Core.MediaFiles.TrackImport +namespace NzbDrone.Core.MediaFiles.BookImport { public class RootFolderNotFoundException : DirectoryNotFoundException { diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/AlbumUpgradeSpecification.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Specifications/AlbumUpgradeSpecification.cs similarity index 90% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/AlbumUpgradeSpecification.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Specifications/AlbumUpgradeSpecification.cs index d11acc2ad..12ddea265 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/AlbumUpgradeSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Specifications/AlbumUpgradeSpecification.cs @@ -5,7 +5,7 @@ using NzbDrone.Core.Download; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; -namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications +namespace NzbDrone.Core.MediaFiles.BookImport.Specifications { public class AlbumUpgradeSpecification : IImportDecisionEngineSpecification<LocalAlbumRelease> { @@ -21,7 +21,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications var qualityComparer = new QualityModelComparer(item.Book.Author.Value.QualityProfile); // min quality of all new tracks - var newMinQuality = item.LocalTracks.Select(x => x.Quality).OrderBy(x => x, qualityComparer).First(); + var newMinQuality = item.LocalBooks.Select(x => x.Quality).OrderBy(x => x, qualityComparer).First(); _logger.Debug("Min quality of new files: {0}", newMinQuality); // get minimum quality of existing release diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/AlreadyImportedSpecification.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Specifications/AlreadyImportedSpecification.cs similarity index 91% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/AlreadyImportedSpecification.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Specifications/AlreadyImportedSpecification.cs index c89bdc7b8..d91c571e9 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/AlreadyImportedSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Specifications/AlreadyImportedSpecification.cs @@ -4,10 +4,10 @@ using NzbDrone.Common.Extensions; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.History; -using NzbDrone.Core.MediaFiles.TrackImport; +using NzbDrone.Core.MediaFiles.BookImport; using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications +namespace NzbDrone.Core.MediaFiles.BookImport.Specifications { public class AlreadyImportedSpecification : IImportDecisionEngineSpecification<LocalAlbumRelease> { @@ -39,7 +39,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications return Decision.Accept(); } - var albumHistory = _historyService.GetByAlbum(albumRelease.Id, null); + var albumHistory = _historyService.GetByBook(albumRelease.Id, null); var lastImported = albumHistory.FirstOrDefault(h => h.EventType == HistoryEventType.DownloadImported); var lastGrabbed = albumHistory.FirstOrDefault(h => h.EventType == HistoryEventType.Grabbed); diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/ArtistPathInRootFolderSpecification.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Specifications/AuthorPathInRootFolderSpecification.cs similarity index 73% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/ArtistPathInRootFolderSpecification.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Specifications/AuthorPathInRootFolderSpecification.cs index 74df21c42..e98f6e89c 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/ArtistPathInRootFolderSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Specifications/AuthorPathInRootFolderSpecification.cs @@ -6,14 +6,14 @@ using NzbDrone.Core.Download; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.RootFolders; -namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications +namespace NzbDrone.Core.MediaFiles.BookImport.Specifications { - public class ArtistPathInRootFolderSpecification : IImportDecisionEngineSpecification<LocalAlbumRelease> + public class AuthorPathInRootFolderSpecification : IImportDecisionEngineSpecification<LocalAlbumRelease> { private readonly IRootFolderService _rootFolderService; private readonly Logger _logger; - public ArtistPathInRootFolderSpecification(IRootFolderService rootFolderService, + public AuthorPathInRootFolderSpecification(IRootFolderService rootFolderService, Logger logger) { _rootFolderService = rootFolderService; @@ -23,10 +23,10 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications public Decision IsSatisfiedBy(LocalAlbumRelease item, DownloadClientItem downloadClientItem) { // Prevent imports to artists that are no longer inside a root folder Readarr manages - var artist = item.Book.Author.Value; + var author = item.Book.Author.Value; - // a new artist will have empty path, and will end up having path assinged based on file location - var pathToCheck = artist.Path.IsNotNullOrWhiteSpace() ? artist.Path : item.LocalTracks.First().Path.GetParentPath(); + // a new author will have empty path, and will end up having path assinged based on file location + var pathToCheck = author.Path.IsNotNullOrWhiteSpace() ? author.Path : item.LocalBooks.First().Path.GetParentPath(); if (_rootFolderService.GetBestRootFolder(pathToCheck) == null) { diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/CloseAlbumMatchSpecification.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Specifications/CloseAlbumMatchSpecification.cs similarity index 97% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/CloseAlbumMatchSpecification.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Specifications/CloseAlbumMatchSpecification.cs index 6eb9a6f0f..a8a0020c8 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/CloseAlbumMatchSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Specifications/CloseAlbumMatchSpecification.cs @@ -4,7 +4,7 @@ using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications +namespace NzbDrone.Core.MediaFiles.BookImport.Specifications { public class CloseAlbumMatchSpecification : IImportDecisionEngineSpecification<LocalAlbumRelease> { diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/FreeSpaceSpecification.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Specifications/FreeSpaceSpecification.cs similarity index 89% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/FreeSpaceSpecification.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Specifications/FreeSpaceSpecification.cs index 37b310cc1..9db19acd1 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/FreeSpaceSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Specifications/FreeSpaceSpecification.cs @@ -7,9 +7,9 @@ using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications +namespace NzbDrone.Core.MediaFiles.BookImport.Specifications { - public class FreeSpaceSpecification : IImportDecisionEngineSpecification<LocalTrack> + public class FreeSpaceSpecification : IImportDecisionEngineSpecification<LocalBook> { private readonly IDiskProvider _diskProvider; private readonly IConfigService _configService; @@ -22,7 +22,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications _logger = logger; } - public Decision IsSatisfiedBy(LocalTrack item, DownloadClientItem downloadClientItem) + public Decision IsSatisfiedBy(LocalBook item, DownloadClientItem downloadClientItem) { if (_configService.SkipFreeSpaceCheckWhenImporting) { @@ -34,11 +34,11 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications { if (item.ExistingFile) { - _logger.Debug("Skipping free space check for existing track"); + _logger.Debug("Skipping free space check for existing book"); return Decision.Accept(); } - var path = Directory.GetParent(item.Artist.Path); + var path = Directory.GetParent(item.Author.Path); var freeSpace = _diskProvider.GetAvailableSpace(path.FullName); if (!freeSpace.HasValue) diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/NotUnpackingSpecification.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Specifications/NotUnpackingSpecification.cs similarity index 88% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/NotUnpackingSpecification.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Specifications/NotUnpackingSpecification.cs index 8f95b3e4c..4edf1382d 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/NotUnpackingSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Specifications/NotUnpackingSpecification.cs @@ -8,9 +8,9 @@ using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications +namespace NzbDrone.Core.MediaFiles.BookImport.Specifications { - public class NotUnpackingSpecification : IImportDecisionEngineSpecification<LocalTrack> + public class NotUnpackingSpecification : IImportDecisionEngineSpecification<LocalBook> { private readonly IDiskProvider _diskProvider; private readonly IConfigService _configService; @@ -23,11 +23,11 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications _logger = logger; } - public Decision IsSatisfiedBy(LocalTrack item, DownloadClientItem downloadClientItem) + public Decision IsSatisfiedBy(LocalBook item, DownloadClientItem downloadClientItem) { if (item.ExistingFile) { - _logger.Debug("{0} is in artist folder, skipping unpacking check", item.Path); + _logger.Debug("{0} is in author folder, skipping unpacking check", item.Path); return Decision.Accept(); } diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/SameFileSpecification.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Specifications/SameFileSpecification.cs similarity index 61% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/SameFileSpecification.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Specifications/SameFileSpecification.cs index 8bb252b2e..c66fe9dce 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/SameFileSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Specifications/SameFileSpecification.cs @@ -4,9 +4,9 @@ using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications +namespace NzbDrone.Core.MediaFiles.BookImport.Specifications { - public class SameFileSpecification : IImportDecisionEngineSpecification<LocalTrack> + public class SameFileSpecification : IImportDecisionEngineSpecification<LocalBook> { private readonly Logger _logger; @@ -15,19 +15,19 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications _logger = logger; } - public Decision IsSatisfiedBy(LocalTrack item, DownloadClientItem downloadClientItem) + public Decision IsSatisfiedBy(LocalBook item, DownloadClientItem downloadClientItem) { - var trackFiles = item.Album?.BookFiles?.Value; + var bookFiles = item.Book?.BookFiles?.Value; - if (trackFiles == null || !trackFiles.Any()) + if (bookFiles == null || !bookFiles.Any()) { - _logger.Debug("No existing track file, skipping"); + _logger.Debug("No existing book file, skipping"); return Decision.Accept(); } - foreach (var trackFile in trackFiles) + foreach (var bookFile in bookFiles) { - if (trackFile.Size == item.Size) + if (bookFile.Size == item.Size) { _logger.Debug("'{0}' Has the same filesize as existing file", item.Path); return Decision.Reject("Has the same filesize as existing file"); diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/UpgradeSpecification.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Specifications/UpgradeSpecification.cs similarity index 67% rename from src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/UpgradeSpecification.cs rename to src/NzbDrone.Core/MediaFiles/BookImport/Specifications/UpgradeSpecification.cs index 4c7c70051..07fad0a1e 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/UpgradeSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Specifications/UpgradeSpecification.cs @@ -6,9 +6,9 @@ using NzbDrone.Core.Download; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; -namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications +namespace NzbDrone.Core.MediaFiles.BookImport.Specifications { - public class UpgradeSpecification : IImportDecisionEngineSpecification<LocalTrack> + public class UpgradeSpecification : IImportDecisionEngineSpecification<LocalBook> { private readonly IConfigService _configService; private readonly Logger _logger; @@ -19,33 +19,33 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications _logger = logger; } - public Decision IsSatisfiedBy(LocalTrack item, DownloadClientItem downloadClientItem) + public Decision IsSatisfiedBy(LocalBook item, DownloadClientItem downloadClientItem) { - var files = item.Album?.BookFiles?.Value; + var files = item.Book?.BookFiles?.Value; if (files == null || !files.Any()) { - // No existing tracks, skip. This guards against new artists not having a QualityProfile. + // No existing books, skip. This guards against new artists not having a QualityProfile. return Decision.Accept(); } var downloadPropersAndRepacks = _configService.DownloadPropersAndRepacks; - var qualityComparer = new QualityModelComparer(item.Artist.QualityProfile); + var qualityComparer = new QualityModelComparer(item.Author.QualityProfile); - foreach (var trackFile in files) + foreach (var bookFile in files) { - var qualityCompare = qualityComparer.Compare(item.Quality.Quality, trackFile.Quality.Quality); + var qualityCompare = qualityComparer.Compare(item.Quality.Quality, bookFile.Quality.Quality); if (qualityCompare < 0) { - _logger.Debug("This file isn't a quality upgrade for all tracks. Skipping {0}", item.Path); - return Decision.Reject("Not an upgrade for existing track file(s)"); + _logger.Debug("This file isn't a quality upgrade for all books. Skipping {0}", item.Path); + return Decision.Reject("Not an upgrade for existing book file(s)"); } if (qualityCompare == 0 && downloadPropersAndRepacks != ProperDownloadTypes.DoNotPrefer && - item.Quality.Revision.CompareTo(trackFile.Quality.Revision) < 0) + item.Quality.Revision.CompareTo(bookFile.Quality.Revision) < 0) { - _logger.Debug("This file isn't a quality upgrade for all tracks. Skipping {0}", item.Path); - return Decision.Reject("Not an upgrade for existing track file(s)"); + _logger.Debug("This file isn't a quality upgrade for all books. Skipping {0}", item.Path); + return Decision.Reject("Not an upgrade for existing book file(s)"); } } diff --git a/src/NzbDrone.Core/MediaFiles/Commands/DownloadedAlbumsScanCommand.cs b/src/NzbDrone.Core/MediaFiles/Commands/DownloadedBooksScanCommand.cs similarity index 75% rename from src/NzbDrone.Core/MediaFiles/Commands/DownloadedAlbumsScanCommand.cs rename to src/NzbDrone.Core/MediaFiles/Commands/DownloadedBooksScanCommand.cs index 52742bd81..feadfc939 100644 --- a/src/NzbDrone.Core/MediaFiles/Commands/DownloadedAlbumsScanCommand.cs +++ b/src/NzbDrone.Core/MediaFiles/Commands/DownloadedBooksScanCommand.cs @@ -1,9 +1,9 @@ -using NzbDrone.Core.MediaFiles.TrackImport; +using NzbDrone.Core.MediaFiles.BookImport; using NzbDrone.Core.Messaging.Commands; namespace NzbDrone.Core.MediaFiles.Commands { - public class DownloadedAlbumsScanCommand : Command + public class DownloadedBooksScanCommand : Command { // Properties used by third-party apps, do not modify. public string Path { get; set; } diff --git a/src/NzbDrone.Core/MediaFiles/Commands/RenameArtistCommand.cs b/src/NzbDrone.Core/MediaFiles/Commands/RenameAuthorCommand.cs similarity index 81% rename from src/NzbDrone.Core/MediaFiles/Commands/RenameArtistCommand.cs rename to src/NzbDrone.Core/MediaFiles/Commands/RenameAuthorCommand.cs index b35bcb112..4058f09eb 100644 --- a/src/NzbDrone.Core/MediaFiles/Commands/RenameArtistCommand.cs +++ b/src/NzbDrone.Core/MediaFiles/Commands/RenameAuthorCommand.cs @@ -3,14 +3,14 @@ using NzbDrone.Core.Messaging.Commands; namespace NzbDrone.Core.MediaFiles.Commands { - public class RenameArtistCommand : Command + public class RenameAuthorCommand : Command { public List<int> AuthorIds { get; set; } public override bool SendUpdatesToClient => true; public override bool RequiresDiskAccess => true; - public RenameArtistCommand() + public RenameAuthorCommand() { AuthorIds = new List<int>(); } diff --git a/src/NzbDrone.Core/MediaFiles/Commands/RetagArtistCommand.cs b/src/NzbDrone.Core/MediaFiles/Commands/RetagAuthorCommand.cs similarity index 81% rename from src/NzbDrone.Core/MediaFiles/Commands/RetagArtistCommand.cs rename to src/NzbDrone.Core/MediaFiles/Commands/RetagAuthorCommand.cs index 891fe85bb..76ddca774 100644 --- a/src/NzbDrone.Core/MediaFiles/Commands/RetagArtistCommand.cs +++ b/src/NzbDrone.Core/MediaFiles/Commands/RetagAuthorCommand.cs @@ -3,14 +3,14 @@ using NzbDrone.Core.Messaging.Commands; namespace NzbDrone.Core.MediaFiles.Commands { - public class RetagArtistCommand : Command + public class RetagAuthorCommand : Command { public List<int> AuthorIds { get; set; } public override bool SendUpdatesToClient => true; public override bool RequiresDiskAccess => true; - public RetagArtistCommand() + public RetagAuthorCommand() { AuthorIds = new List<int>(); } diff --git a/src/NzbDrone.Core/MediaFiles/DiskScanService.cs b/src/NzbDrone.Core/MediaFiles/DiskScanService.cs index ac5c7ec20..dd51bdb22 100644 --- a/src/NzbDrone.Core/MediaFiles/DiskScanService.cs +++ b/src/NzbDrone.Core/MediaFiles/DiskScanService.cs @@ -11,13 +11,13 @@ using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; using NzbDrone.Common.Instrumentation.Extensions; using NzbDrone.Common.Serializer; +using NzbDrone.Core.Books; using NzbDrone.Core.Books.Calibre; +using NzbDrone.Core.MediaFiles.BookImport; using NzbDrone.Core.MediaFiles.Commands; using NzbDrone.Core.MediaFiles.Events; -using NzbDrone.Core.MediaFiles.TrackImport; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser; using NzbDrone.Core.RootFolders; @@ -26,8 +26,8 @@ namespace NzbDrone.Core.MediaFiles public interface IDiskScanService { void Scan(List<string> folders = null, FilterFilesType filter = FilterFilesType.Known, bool addNewArtists = false, List<int> authorIds = null); - IFileInfo[] GetAudioFiles(string path, bool allDirectories = true); - string[] GetNonAudioFiles(string path, bool allDirectories = true); + IFileInfo[] GetBookFiles(string path, bool allDirectories = true); + string[] GetNonBookFiles(string path, bool allDirectories = true); List<IFileInfo> FilterFiles(string basePath, IEnumerable<IFileInfo> files); List<string> FilterFiles(string basePath, IEnumerable<string> files); } @@ -43,8 +43,8 @@ namespace NzbDrone.Core.MediaFiles private readonly ICalibreProxy _calibre; private readonly IMediaFileService _mediaFileService; private readonly IMakeImportDecision _importDecisionMaker; - private readonly IImportApprovedTracks _importApprovedTracks; - private readonly IArtistService _artistService; + private readonly IImportApprovedBooks _importApprovedTracks; + private readonly IAuthorService _authorService; private readonly IMediaFileTableCleanupService _mediaFileTableCleanupService; private readonly IRootFolderService _rootFolderService; private readonly IEventAggregator _eventAggregator; @@ -54,8 +54,8 @@ namespace NzbDrone.Core.MediaFiles ICalibreProxy calibre, IMediaFileService mediaFileService, IMakeImportDecision importDecisionMaker, - IImportApprovedTracks importApprovedTracks, - IArtistService artistService, + IImportApprovedBooks importApprovedTracks, + IAuthorService authorService, IRootFolderService rootFolderService, IMediaFileTableCleanupService mediaFileTableCleanupService, IEventAggregator eventAggregator, @@ -67,7 +67,7 @@ namespace NzbDrone.Core.MediaFiles _mediaFileService = mediaFileService; _importDecisionMaker = importDecisionMaker; _importApprovedTracks = importApprovedTracks; - _artistService = artistService; + _authorService = authorService; _mediaFileTableCleanupService = mediaFileTableCleanupService; _rootFolderService = rootFolderService; _eventAggregator = eventAggregator; @@ -106,8 +106,8 @@ namespace NzbDrone.Core.MediaFiles { _logger.Warn("Root folder {0} doesn't exist.", rootFolder.Path); - var skippedArtists = _artistService.GetArtists(authorIds); - skippedArtists.ForEach(x => _eventAggregator.PublishEvent(new ArtistScanSkippedEvent(x, ArtistScanSkippedReason.RootFolderDoesNotExist))); + var skippedArtists = _authorService.GetAuthors(authorIds); + skippedArtists.ForEach(x => _eventAggregator.PublishEvent(new AuthorScanSkippedEvent(x, AuthorScanSkippedReason.RootFolderDoesNotExist))); return; } @@ -115,8 +115,8 @@ namespace NzbDrone.Core.MediaFiles { _logger.Warn("Root folder {0} is empty.", rootFolder.Path); - var skippedArtists = _artistService.GetArtists(authorIds); - skippedArtists.ForEach(x => _eventAggregator.PublishEvent(new ArtistScanSkippedEvent(x, ArtistScanSkippedReason.RootFolderIsEmpty))); + var skippedArtists = _authorService.GetAuthors(authorIds); + skippedArtists.ForEach(x => _eventAggregator.PublishEvent(new AuthorScanSkippedEvent(x, AuthorScanSkippedReason.RootFolderIsEmpty))); return; } @@ -130,7 +130,7 @@ namespace NzbDrone.Core.MediaFiles _logger.ProgressInfo("Scanning {0}", folder); - var files = FilterFiles(folder, GetAudioFiles(folder)); + var files = FilterFiles(folder, GetBookFiles(folder)); if (!files.Any()) { @@ -151,7 +151,7 @@ namespace NzbDrone.Core.MediaFiles { Filter = filter, IncludeExisting = true, - AddNewArtists = addNewArtists + AddNewAuthors = addNewArtists }; var decisions = _importDecisionMaker.GetImportDecisions(mediaFileList, null, null, config); @@ -212,14 +212,14 @@ namespace NzbDrone.Core.MediaFiles _logger.Debug($"Updated info for {updatedFiles.Count} known files"); - var artists = _artistService.GetArtists(authorIds); - foreach (var artist in artists) + var artists = _authorService.GetAuthors(authorIds); + foreach (var author in artists) { - CompletedScanning(artist); + CompletedScanning(author); } importStopwatch.Stop(); - _logger.Debug("Track import complete for:\n{0} [{1}]", folders.ConcatToString("\n"), importStopwatch.Elapsed); + _logger.Debug("Book import complete for:\n{0} [{1}]", folders.ConcatToString("\n"), importStopwatch.Elapsed); } private void CleanMediaFiles(string folder, List<string> mediaFileList) @@ -228,13 +228,13 @@ namespace NzbDrone.Core.MediaFiles _mediaFileTableCleanupService.Clean(folder, mediaFileList); } - private void CompletedScanning(Author artist) + private void CompletedScanning(Author author) { - _logger.Info("Completed scanning disk for {0}", artist.Name); - _eventAggregator.PublishEvent(new ArtistScannedEvent(artist)); + _logger.Info("Completed scanning disk for {0}", author.Name); + _eventAggregator.PublishEvent(new AuthorScannedEvent(author)); } - public IFileInfo[] GetAudioFiles(string path, bool allDirectories = true) + public IFileInfo[] GetBookFiles(string path, bool allDirectories = true) { IEnumerable<IFileInfo> filesOnDisk; @@ -252,7 +252,7 @@ namespace NzbDrone.Core.MediaFiles } else { - _logger.Debug("Scanning '{0}' for music files", path); + _logger.Debug("Scanning '{0}' for ebook files", path); var searchOption = allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; filesOnDisk = _diskProvider.GetFileInfos(path, searchOption); @@ -268,9 +268,9 @@ namespace NzbDrone.Core.MediaFiles return mediaFileList; } - public string[] GetNonAudioFiles(string path, bool allDirectories = true) + public string[] GetNonBookFiles(string path, bool allDirectories = true) { - _logger.Debug("Scanning '{0}' for non-music files", path); + _logger.Debug("Scanning '{0}' for non-ebook files", path); var searchOption = allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; var filesOnDisk = _diskProvider.GetFiles(path, searchOption).ToList(); @@ -279,7 +279,7 @@ namespace NzbDrone.Core.MediaFiles .ToList(); _logger.Trace("{0} files were found in {1}", filesOnDisk.Count, path); - _logger.Debug("{0} non-music files were found in {1}", mediaFileList.Count, path); + _logger.Debug("{0} non-ebook files were found in {1}", mediaFileList.Count, path); return mediaFileList.ToArray(); } diff --git a/src/NzbDrone.Core/MediaFiles/DownloadedAlbumsCommandService.cs b/src/NzbDrone.Core/MediaFiles/DownloadedBooksCommandService.cs similarity index 83% rename from src/NzbDrone.Core/MediaFiles/DownloadedAlbumsCommandService.cs rename to src/NzbDrone.Core/MediaFiles/DownloadedBooksCommandService.cs index 0fa97b9fa..de1df773c 100644 --- a/src/NzbDrone.Core/MediaFiles/DownloadedAlbumsCommandService.cs +++ b/src/NzbDrone.Core/MediaFiles/DownloadedBooksCommandService.cs @@ -5,20 +5,20 @@ using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; using NzbDrone.Core.Download.TrackedDownloads; +using NzbDrone.Core.MediaFiles.BookImport; using NzbDrone.Core.MediaFiles.Commands; -using NzbDrone.Core.MediaFiles.TrackImport; using NzbDrone.Core.Messaging.Commands; namespace NzbDrone.Core.MediaFiles { - public class DownloadedAlbumsCommandService : IExecute<DownloadedAlbumsScanCommand> + public class DownloadedBooksCommandService : IExecute<DownloadedBooksScanCommand> { - private readonly IDownloadedTracksImportService _downloadedTracksImportService; + private readonly IDownloadedBooksImportService _downloadedTracksImportService; private readonly ITrackedDownloadService _trackedDownloadService; private readonly IDiskProvider _diskProvider; private readonly Logger _logger; - public DownloadedAlbumsCommandService(IDownloadedTracksImportService downloadedTracksImportService, + public DownloadedBooksCommandService(IDownloadedBooksImportService downloadedTracksImportService, ITrackedDownloadService trackedDownloadService, IDiskProvider diskProvider, Logger logger) @@ -29,7 +29,7 @@ namespace NzbDrone.Core.MediaFiles _logger = logger; } - private List<ImportResult> ProcessPath(DownloadedAlbumsScanCommand message) + private List<ImportResult> ProcessPath(DownloadedBooksScanCommand message) { if (!_diskProvider.FolderExists(message.Path) && !_diskProvider.FileExists(message.Path)) { @@ -45,7 +45,7 @@ namespace NzbDrone.Core.MediaFiles { _logger.Debug("External directory scan request for known download {0}. [{1}]", message.DownloadClientId, message.Path); - return _downloadedTracksImportService.ProcessPath(message.Path, message.ImportMode, trackedDownload.RemoteAlbum.Artist, trackedDownload.DownloadItem); + return _downloadedTracksImportService.ProcessPath(message.Path, message.ImportMode, trackedDownload.RemoteBook.Author, trackedDownload.DownloadItem); } else { @@ -58,7 +58,7 @@ namespace NzbDrone.Core.MediaFiles return _downloadedTracksImportService.ProcessPath(message.Path, message.ImportMode); } - public void Execute(DownloadedAlbumsScanCommand message) + public void Execute(DownloadedBooksScanCommand message) { List<ImportResult> importResults; diff --git a/src/NzbDrone.Core/MediaFiles/DownloadedTracksImportService.cs b/src/NzbDrone.Core/MediaFiles/DownloadedBooksImportService.cs similarity index 76% rename from src/NzbDrone.Core/MediaFiles/DownloadedTracksImportService.cs rename to src/NzbDrone.Core/MediaFiles/DownloadedBooksImportService.cs index 83eefcbd7..a8d4a30b2 100644 --- a/src/NzbDrone.Core/MediaFiles/DownloadedTracksImportService.cs +++ b/src/NzbDrone.Core/MediaFiles/DownloadedBooksImportService.cs @@ -6,49 +6,49 @@ using System.Linq; using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.EnvironmentInfo; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; +using NzbDrone.Core.MediaFiles.BookImport; using NzbDrone.Core.MediaFiles.Events; -using NzbDrone.Core.MediaFiles.TrackImport; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.MediaFiles { - public interface IDownloadedTracksImportService + public interface IDownloadedBooksImportService { List<ImportResult> ProcessRootFolder(IDirectoryInfo directoryInfo); - List<ImportResult> ProcessPath(string path, ImportMode importMode = ImportMode.Auto, Author artist = null, DownloadClientItem downloadClientItem = null); - bool ShouldDeleteFolder(IDirectoryInfo directoryInfo, Author artist); + List<ImportResult> ProcessPath(string path, ImportMode importMode = ImportMode.Auto, Author author = null, DownloadClientItem downloadClientItem = null); + bool ShouldDeleteFolder(IDirectoryInfo directoryInfo, Author author); } - public class DownloadedTracksImportService : IDownloadedTracksImportService + public class DownloadedBooksImportService : IDownloadedBooksImportService { private readonly IDiskProvider _diskProvider; private readonly IDiskScanService _diskScanService; - private readonly IArtistService _artistService; + private readonly IAuthorService _authorService; private readonly IParsingService _parsingService; private readonly IMakeImportDecision _importDecisionMaker; - private readonly IImportApprovedTracks _importApprovedTracks; + private readonly IImportApprovedBooks _importApprovedTracks; private readonly IEventAggregator _eventAggregator; private readonly IRuntimeInfo _runtimeInfo; private readonly Logger _logger; - public DownloadedTracksImportService(IDiskProvider diskProvider, + public DownloadedBooksImportService(IDiskProvider diskProvider, IDiskScanService diskScanService, - IArtistService artistService, + IAuthorService authorService, IParsingService parsingService, IMakeImportDecision importDecisionMaker, - IImportApprovedTracks importApprovedTracks, + IImportApprovedBooks importApprovedTracks, IEventAggregator eventAggregator, IRuntimeInfo runtimeInfo, Logger logger) { _diskProvider = diskProvider; _diskScanService = diskScanService; - _artistService = artistService; + _authorService = authorService; _parsingService = parsingService; _importDecisionMaker = importDecisionMaker; _importApprovedTracks = importApprovedTracks; @@ -67,7 +67,7 @@ namespace NzbDrone.Core.MediaFiles results.AddRange(folderResults); } - foreach (var audioFile in _diskScanService.GetAudioFiles(directoryInfo.FullName, false)) + foreach (var audioFile in _diskScanService.GetBookFiles(directoryInfo.FullName, false)) { var fileResults = ProcessFile(audioFile, ImportMode.Auto, null); results.AddRange(fileResults); @@ -76,30 +76,30 @@ namespace NzbDrone.Core.MediaFiles return results; } - public List<ImportResult> ProcessPath(string path, ImportMode importMode = ImportMode.Auto, Author artist = null, DownloadClientItem downloadClientItem = null) + public List<ImportResult> ProcessPath(string path, ImportMode importMode = ImportMode.Auto, Author author = null, DownloadClientItem downloadClientItem = null) { if (_diskProvider.FolderExists(path)) { var directoryInfo = _diskProvider.GetDirectoryInfo(path); - if (artist == null) + if (author == null) { return ProcessFolder(directoryInfo, importMode, downloadClientItem); } - return ProcessFolder(directoryInfo, importMode, artist, downloadClientItem); + return ProcessFolder(directoryInfo, importMode, author, downloadClientItem); } if (_diskProvider.FileExists(path)) { var fileInfo = _diskProvider.GetFileInfo(path); - if (artist == null) + if (author == null) { return ProcessFile(fileInfo, importMode, downloadClientItem); } - return ProcessFile(fileInfo, importMode, artist, downloadClientItem); + return ProcessFile(fileInfo, importMode, author, downloadClientItem); } LogInaccessiblePathError(path); @@ -108,22 +108,22 @@ namespace NzbDrone.Core.MediaFiles return new List<ImportResult>(); } - public bool ShouldDeleteFolder(IDirectoryInfo directoryInfo, Author artist) + public bool ShouldDeleteFolder(IDirectoryInfo directoryInfo, Author author) { - var audioFiles = _diskScanService.GetAudioFiles(directoryInfo.FullName); + var bookFiles = _diskScanService.GetBookFiles(directoryInfo.FullName); var rarFiles = _diskProvider.GetFiles(directoryInfo.FullName, SearchOption.AllDirectories).Where(f => Path.GetExtension(f).Equals(".rar", StringComparison.OrdinalIgnoreCase)); - foreach (var audioFile in audioFiles) + foreach (var bookFile in bookFiles) { - var albumParseResult = Parser.Parser.ParseMusicTitle(audioFile.Name); + var bookParseResult = Parser.Parser.ParseTitle(bookFile.Name); - if (albumParseResult == null) + if (bookParseResult == null) { - _logger.Warn("Unable to parse file on import: [{0}]", audioFile); + _logger.Warn("Unable to parse file on import: [{0}]", bookFile); return false; } - _logger.Warn("Audio file detected: [{0}]", audioFile); + _logger.Warn("Book file detected: [{0}]", bookFile); return false; } @@ -139,31 +139,31 @@ namespace NzbDrone.Core.MediaFiles private List<ImportResult> ProcessFolder(IDirectoryInfo directoryInfo, ImportMode importMode, DownloadClientItem downloadClientItem) { var cleanedUpName = GetCleanedUpFolderName(directoryInfo.Name); - var artist = _parsingService.GetArtist(cleanedUpName); + var author = _parsingService.GetArtist(cleanedUpName); - if (artist == null) + if (author == null) { - _logger.Debug("Unknown Artist {0}", cleanedUpName); + _logger.Debug("Unknown Author {0}", cleanedUpName); return new List<ImportResult> { - UnknownArtistResult("Unknown Artist") + UnknownAuthorResult("Unknown Author") }; } - return ProcessFolder(directoryInfo, importMode, artist, downloadClientItem); + return ProcessFolder(directoryInfo, importMode, author, downloadClientItem); } - private List<ImportResult> ProcessFolder(IDirectoryInfo directoryInfo, ImportMode importMode, Author artist, DownloadClientItem downloadClientItem) + private List<ImportResult> ProcessFolder(IDirectoryInfo directoryInfo, ImportMode importMode, Author author, DownloadClientItem downloadClientItem) { - if (_artistService.ArtistPathExists(directoryInfo.FullName)) + if (_authorService.AuthorPathExists(directoryInfo.FullName)) { - _logger.Warn("Unable to process folder that is mapped to an existing artist"); + _logger.Warn("Unable to process folder that is mapped to an existing author"); return new List<ImportResult>(); } var cleanedUpName = GetCleanedUpFolderName(directoryInfo.Name); - var folderInfo = Parser.Parser.ParseAlbumTitle(directoryInfo.Name); + var folderInfo = Parser.Parser.ParseBookTitle(directoryInfo.Name); var trackInfo = new ParsedTrackInfo { }; if (folderInfo != null) @@ -172,8 +172,8 @@ namespace NzbDrone.Core.MediaFiles trackInfo = new ParsedTrackInfo { - AlbumTitle = folderInfo.AlbumTitle, - ArtistTitle = folderInfo.ArtistName, + AlbumTitle = folderInfo.BookTitle, + ArtistTitle = folderInfo.AuthorName, Quality = folderInfo.Quality, ReleaseGroup = folderInfo.ReleaseGroup, ReleaseHash = folderInfo.ReleaseHash, @@ -184,7 +184,7 @@ namespace NzbDrone.Core.MediaFiles trackInfo = null; } - var audioFiles = _diskScanService.FilterFiles(directoryInfo.FullName, _diskScanService.GetAudioFiles(directoryInfo.FullName)); + var audioFiles = _diskScanService.FilterFiles(directoryInfo.FullName, _diskScanService.GetBookFiles(directoryInfo.FullName)); if (downloadClientItem == null) { @@ -202,7 +202,7 @@ namespace NzbDrone.Core.MediaFiles var idOverrides = new IdentificationOverrides { - Artist = artist + Author = author }; var idInfo = new ImportDecisionMakerInfo { @@ -215,7 +215,7 @@ namespace NzbDrone.Core.MediaFiles NewDownload = true, SingleRelease = false, IncludeExisting = false, - AddNewArtists = false + AddNewAuthors = false }; var decisions = _importDecisionMaker.GetImportDecisions(audioFiles, idOverrides, idInfo, idConfig); @@ -228,7 +228,7 @@ namespace NzbDrone.Core.MediaFiles if (importMode == ImportMode.Move && importResults.Any(i => i.Result == ImportResultType.Imported) && - ShouldDeleteFolder(directoryInfo, artist)) + ShouldDeleteFolder(directoryInfo, author)) { _logger.Debug("Deleting folder after importing valid files"); _diskProvider.DeleteFolder(directoryInfo.FullName, true); @@ -239,22 +239,22 @@ namespace NzbDrone.Core.MediaFiles private List<ImportResult> ProcessFile(IFileInfo fileInfo, ImportMode importMode, DownloadClientItem downloadClientItem) { - var artist = _parsingService.GetArtist(Path.GetFileNameWithoutExtension(fileInfo.Name)); + var author = _parsingService.GetArtist(Path.GetFileNameWithoutExtension(fileInfo.Name)); - if (artist == null) + if (author == null) { - _logger.Debug("Unknown Artist for file: {0}", fileInfo.Name); + _logger.Debug("Unknown Author for file: {0}", fileInfo.Name); return new List<ImportResult> { - UnknownArtistResult(string.Format("Unknown Artist for file: {0}", fileInfo.Name), fileInfo.FullName) + UnknownAuthorResult(string.Format("Unknown Author for file: {0}", fileInfo.Name), fileInfo.FullName) }; } - return ProcessFile(fileInfo, importMode, artist, downloadClientItem); + return ProcessFile(fileInfo, importMode, author, downloadClientItem); } - private List<ImportResult> ProcessFile(IFileInfo fileInfo, ImportMode importMode, Author artist, DownloadClientItem downloadClientItem) + private List<ImportResult> ProcessFile(IFileInfo fileInfo, ImportMode importMode, Author author, DownloadClientItem downloadClientItem) { if (Path.GetFileNameWithoutExtension(fileInfo.Name).StartsWith("._")) { @@ -262,7 +262,7 @@ namespace NzbDrone.Core.MediaFiles return new List<ImportResult> { - new ImportResult(new ImportDecision<LocalTrack>(new LocalTrack { Path = fileInfo.FullName }, new Rejection("Invalid music file, filename starts with '._'")), "Invalid music file, filename starts with '._'") + new ImportResult(new ImportDecision<LocalBook>(new LocalBook { Path = fileInfo.FullName }, new Rejection("Invalid music file, filename starts with '._'")), "Invalid music file, filename starts with '._'") }; } @@ -279,7 +279,7 @@ namespace NzbDrone.Core.MediaFiles var idOverrides = new IdentificationOverrides { - Artist = artist + Author = author }; var idInfo = new ImportDecisionMakerInfo { @@ -291,7 +291,7 @@ namespace NzbDrone.Core.MediaFiles NewDownload = true, SingleRelease = false, IncludeExisting = false, - AddNewArtists = false + AddNewAuthors = false }; var decisions = _importDecisionMaker.GetImportDecisions(new List<IFileInfo>() { fileInfo }, idOverrides, idInfo, idConfig); @@ -310,14 +310,14 @@ namespace NzbDrone.Core.MediaFiles private ImportResult FileIsLockedResult(string audioFile) { _logger.Debug("[{0}] is currently locked by another process, skipping", audioFile); - return new ImportResult(new ImportDecision<LocalTrack>(new LocalTrack { Path = audioFile }, new Rejection("Locked file, try again later")), "Locked file, try again later"); + return new ImportResult(new ImportDecision<LocalBook>(new LocalBook { Path = audioFile }, new Rejection("Locked file, try again later")), "Locked file, try again later"); } - private ImportResult UnknownArtistResult(string message, string audioFile = null) + private ImportResult UnknownAuthorResult(string message, string bookFile = null) { - var localTrack = audioFile == null ? null : new LocalTrack { Path = audioFile }; + var localTrack = bookFile == null ? null : new LocalBook { Path = bookFile }; - return new ImportResult(new ImportDecision<LocalTrack>(localTrack, new Rejection("Unknown Artist")), message); + return new ImportResult(new ImportDecision<LocalBook>(localTrack, new Rejection("Unknown Author")), message); } private void LogInaccessiblePathError(string path) diff --git a/src/NzbDrone.Core/MediaFiles/EbookTagService.cs b/src/NzbDrone.Core/MediaFiles/EbookTagService.cs index 0819d12ce..7865f6721 100644 --- a/src/NzbDrone.Core/MediaFiles/EbookTagService.cs +++ b/src/NzbDrone.Core/MediaFiles/EbookTagService.cs @@ -43,7 +43,7 @@ namespace NzbDrone.Core.MediaFiles case ".mobi": return ReadAzw3(file.FullName); default: - return Parser.Parser.ParseMusicTitle(file.FullName); + return Parser.Parser.ParseTitle(file.FullName); } } diff --git a/src/NzbDrone.Core/MediaFiles/Events/ArtistRenamedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/ArtistRenamedEvent.cs deleted file mode 100644 index 65385efd1..000000000 --- a/src/NzbDrone.Core/MediaFiles/Events/ArtistRenamedEvent.cs +++ /dev/null @@ -1,15 +0,0 @@ -using NzbDrone.Common.Messaging; -using NzbDrone.Core.Music; - -namespace NzbDrone.Core.MediaFiles.Events -{ - public class ArtistRenamedEvent : IEvent - { - public Author Artist { get; private set; } - - public ArtistRenamedEvent(Author artist) - { - Artist = artist; - } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/Events/ArtistScanSkippedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/ArtistScanSkippedEvent.cs deleted file mode 100644 index 19d40054c..000000000 --- a/src/NzbDrone.Core/MediaFiles/Events/ArtistScanSkippedEvent.cs +++ /dev/null @@ -1,23 +0,0 @@ -using NzbDrone.Common.Messaging; -using NzbDrone.Core.Music; - -namespace NzbDrone.Core.MediaFiles.Events -{ - public class ArtistScanSkippedEvent : IEvent - { - public Author Artist { get; private set; } - public ArtistScanSkippedReason Reason { get; private set; } - - public ArtistScanSkippedEvent(Author artist, ArtistScanSkippedReason reason) - { - Artist = artist; - Reason = reason; - } - } - - public enum ArtistScanSkippedReason - { - RootFolderDoesNotExist, - RootFolderIsEmpty - } -} diff --git a/src/NzbDrone.Core/MediaFiles/Events/ArtistScannedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/ArtistScannedEvent.cs deleted file mode 100644 index 9acd144e0..000000000 --- a/src/NzbDrone.Core/MediaFiles/Events/ArtistScannedEvent.cs +++ /dev/null @@ -1,15 +0,0 @@ -using NzbDrone.Common.Messaging; -using NzbDrone.Core.Music; - -namespace NzbDrone.Core.MediaFiles.Events -{ - public class ArtistScannedEvent : IEvent - { - public Author Artist { get; private set; } - - public ArtistScannedEvent(Author artist) - { - Artist = artist; - } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/Events/AuthorRenamedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/AuthorRenamedEvent.cs new file mode 100644 index 000000000..5d95e1982 --- /dev/null +++ b/src/NzbDrone.Core/MediaFiles/Events/AuthorRenamedEvent.cs @@ -0,0 +1,15 @@ +using NzbDrone.Common.Messaging; +using NzbDrone.Core.Books; + +namespace NzbDrone.Core.MediaFiles.Events +{ + public class AuthorRenamedEvent : IEvent + { + public Author Author { get; private set; } + + public AuthorRenamedEvent(Author author) + { + Author = author; + } + } +} diff --git a/src/NzbDrone.Core/MediaFiles/Events/AuthorScanSkippedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/AuthorScanSkippedEvent.cs new file mode 100644 index 000000000..87138b588 --- /dev/null +++ b/src/NzbDrone.Core/MediaFiles/Events/AuthorScanSkippedEvent.cs @@ -0,0 +1,23 @@ +using NzbDrone.Common.Messaging; +using NzbDrone.Core.Books; + +namespace NzbDrone.Core.MediaFiles.Events +{ + public class AuthorScanSkippedEvent : IEvent + { + public Author Author { get; private set; } + public AuthorScanSkippedReason Reason { get; private set; } + + public AuthorScanSkippedEvent(Author author, AuthorScanSkippedReason reason) + { + Author = author; + Reason = reason; + } + } + + public enum AuthorScanSkippedReason + { + RootFolderDoesNotExist, + RootFolderIsEmpty + } +} diff --git a/src/NzbDrone.Core/MediaFiles/Events/AuthorScannedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/AuthorScannedEvent.cs new file mode 100644 index 000000000..3727a172a --- /dev/null +++ b/src/NzbDrone.Core/MediaFiles/Events/AuthorScannedEvent.cs @@ -0,0 +1,15 @@ +using NzbDrone.Common.Messaging; +using NzbDrone.Core.Books; + +namespace NzbDrone.Core.MediaFiles.Events +{ + public class AuthorScannedEvent : IEvent + { + public Author Author { get; private set; } + + public AuthorScannedEvent(Author author) + { + Author = author; + } + } +} diff --git a/src/NzbDrone.Core/MediaFiles/Events/BookFileAddedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/BookFileAddedEvent.cs new file mode 100644 index 000000000..7947f2e99 --- /dev/null +++ b/src/NzbDrone.Core/MediaFiles/Events/BookFileAddedEvent.cs @@ -0,0 +1,14 @@ +using NzbDrone.Common.Messaging; + +namespace NzbDrone.Core.MediaFiles.Events +{ + public class BookFileAddedEvent : IEvent + { + public BookFile BookFile { get; private set; } + + public BookFileAddedEvent(BookFile bookFile) + { + BookFile = bookFile; + } + } +} diff --git a/src/NzbDrone.Core/MediaFiles/Events/BookFileDeletedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/BookFileDeletedEvent.cs new file mode 100644 index 000000000..4cf7271f8 --- /dev/null +++ b/src/NzbDrone.Core/MediaFiles/Events/BookFileDeletedEvent.cs @@ -0,0 +1,16 @@ +using NzbDrone.Common.Messaging; + +namespace NzbDrone.Core.MediaFiles.Events +{ + public class BookFileDeletedEvent : IEvent + { + public BookFile BookFile { get; private set; } + public DeleteMediaFileReason Reason { get; private set; } + + public BookFileDeletedEvent(BookFile bookFile, DeleteMediaFileReason reason) + { + BookFile = bookFile; + Reason = reason; + } + } +} diff --git a/src/NzbDrone.Core/MediaFiles/Events/BookFileRenamedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/BookFileRenamedEvent.cs new file mode 100644 index 000000000..5fc115a90 --- /dev/null +++ b/src/NzbDrone.Core/MediaFiles/Events/BookFileRenamedEvent.cs @@ -0,0 +1,19 @@ +using NzbDrone.Common.Messaging; +using NzbDrone.Core.Books; + +namespace NzbDrone.Core.MediaFiles.Events +{ + public class BookFileRenamedEvent : IEvent + { + public Author Author { get; private set; } + public BookFile BookFile { get; private set; } + public string OriginalPath { get; private set; } + + public BookFileRenamedEvent(Author author, BookFile bookFile, string originalPath) + { + Author = author; + BookFile = bookFile; + OriginalPath = originalPath; + } + } +} diff --git a/src/NzbDrone.Core/MediaFiles/Events/TrackFileRetaggedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/BookFileRetaggedEvent.cs similarity index 57% rename from src/NzbDrone.Core/MediaFiles/Events/TrackFileRetaggedEvent.cs rename to src/NzbDrone.Core/MediaFiles/Events/BookFileRetaggedEvent.cs index 6917eabb5..97629d519 100644 --- a/src/NzbDrone.Core/MediaFiles/Events/TrackFileRetaggedEvent.cs +++ b/src/NzbDrone.Core/MediaFiles/Events/BookFileRetaggedEvent.cs @@ -1,24 +1,24 @@ using System; using System.Collections.Generic; using NzbDrone.Common.Messaging; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; namespace NzbDrone.Core.MediaFiles.Events { - public class TrackFileRetaggedEvent : IEvent + public class BookFileRetaggedEvent : IEvent { - public Author Artist { get; private set; } - public BookFile TrackFile { get; private set; } + public Author Author { get; private set; } + public BookFile BookFile { get; private set; } public Dictionary<string, Tuple<string, string>> Diff { get; private set; } public bool Scrubbed { get; private set; } - public TrackFileRetaggedEvent(Author artist, - BookFile trackFile, + public BookFileRetaggedEvent(Author author, + BookFile bookFile, Dictionary<string, Tuple<string, string>> diff, bool scrubbed) { - Artist = artist; - TrackFile = trackFile; + Author = author; + BookFile = bookFile; Diff = diff; Scrubbed = scrubbed; } diff --git a/src/NzbDrone.Core/MediaFiles/Events/AlbumImportIncompleteEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/BookImportIncompleteEvent.cs similarity index 68% rename from src/NzbDrone.Core/MediaFiles/Events/AlbumImportIncompleteEvent.cs rename to src/NzbDrone.Core/MediaFiles/Events/BookImportIncompleteEvent.cs index 94d7b7424..20a9cd9ae 100644 --- a/src/NzbDrone.Core/MediaFiles/Events/AlbumImportIncompleteEvent.cs +++ b/src/NzbDrone.Core/MediaFiles/Events/BookImportIncompleteEvent.cs @@ -3,11 +3,11 @@ using NzbDrone.Core.Download.TrackedDownloads; namespace NzbDrone.Core.MediaFiles.Events { - public class AlbumImportIncompleteEvent : IEvent + public class BookImportIncompleteEvent : IEvent { public TrackedDownload TrackedDownload { get; private set; } - public AlbumImportIncompleteEvent(TrackedDownload trackedDownload) + public BookImportIncompleteEvent(TrackedDownload trackedDownload) { TrackedDownload = trackedDownload; } diff --git a/src/NzbDrone.Core/MediaFiles/Events/AlbumImportedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/BookImportedEvent.cs similarity index 56% rename from src/NzbDrone.Core/MediaFiles/Events/AlbumImportedEvent.cs rename to src/NzbDrone.Core/MediaFiles/Events/BookImportedEvent.cs index 228b2448d..f67a2de92 100644 --- a/src/NzbDrone.Core/MediaFiles/Events/AlbumImportedEvent.cs +++ b/src/NzbDrone.Core/MediaFiles/Events/BookImportedEvent.cs @@ -1,25 +1,25 @@ using System.Collections.Generic; using NzbDrone.Common.Messaging; +using NzbDrone.Core.Books; using NzbDrone.Core.Download; -using NzbDrone.Core.Music; namespace NzbDrone.Core.MediaFiles.Events { - public class AlbumImportedEvent : IEvent + public class BookImportedEvent : IEvent { - public Author Artist { get; private set; } - public Book Album { get; private set; } - public List<BookFile> ImportedTracks { get; private set; } + public Author Author { get; private set; } + public Book Book { get; private set; } + public List<BookFile> ImportedBooks { get; private set; } public List<BookFile> OldFiles { get; private set; } public bool NewDownload { get; private set; } public string DownloadClient { get; private set; } public string DownloadId { get; private set; } - public AlbumImportedEvent(Author artist, Book album, List<BookFile> importedTracks, List<BookFile> oldFiles, bool newDownload, DownloadClientItem downloadClientItem) + public BookImportedEvent(Author author, Book book, List<BookFile> importedBooks, List<BookFile> oldFiles, bool newDownload, DownloadClientItem downloadClientItem) { - Artist = artist; - Album = album; - ImportedTracks = importedTracks; + Author = author; + Book = book; + ImportedBooks = importedBooks; OldFiles = oldFiles; NewDownload = newDownload; diff --git a/src/NzbDrone.Core/MediaFiles/Events/TrackFileAddedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/TrackFileAddedEvent.cs deleted file mode 100644 index 975c0d142..000000000 --- a/src/NzbDrone.Core/MediaFiles/Events/TrackFileAddedEvent.cs +++ /dev/null @@ -1,14 +0,0 @@ -using NzbDrone.Common.Messaging; - -namespace NzbDrone.Core.MediaFiles.Events -{ - public class TrackFileAddedEvent : IEvent - { - public BookFile TrackFile { get; private set; } - - public TrackFileAddedEvent(BookFile trackFile) - { - TrackFile = trackFile; - } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/Events/TrackFileDeletedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/TrackFileDeletedEvent.cs deleted file mode 100644 index ae94d2841..000000000 --- a/src/NzbDrone.Core/MediaFiles/Events/TrackFileDeletedEvent.cs +++ /dev/null @@ -1,16 +0,0 @@ -using NzbDrone.Common.Messaging; - -namespace NzbDrone.Core.MediaFiles.Events -{ - public class TrackFileDeletedEvent : IEvent - { - public BookFile TrackFile { get; private set; } - public DeleteMediaFileReason Reason { get; private set; } - - public TrackFileDeletedEvent(BookFile trackFile, DeleteMediaFileReason reason) - { - TrackFile = trackFile; - Reason = reason; - } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/Events/TrackFileRenamedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/TrackFileRenamedEvent.cs deleted file mode 100644 index 6119699e3..000000000 --- a/src/NzbDrone.Core/MediaFiles/Events/TrackFileRenamedEvent.cs +++ /dev/null @@ -1,19 +0,0 @@ -using NzbDrone.Common.Messaging; -using NzbDrone.Core.Music; - -namespace NzbDrone.Core.MediaFiles.Events -{ - public class TrackFileRenamedEvent : IEvent - { - public Author Artist { get; private set; } - public BookFile TrackFile { get; private set; } - public string OriginalPath { get; private set; } - - public TrackFileRenamedEvent(Author artist, BookFile trackFile, string originalPath) - { - Artist = artist; - TrackFile = trackFile; - OriginalPath = originalPath; - } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/Events/TrackFolderCreatedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/TrackFolderCreatedEvent.cs index 7d715cbca..8ec004fb5 100644 --- a/src/NzbDrone.Core/MediaFiles/Events/TrackFolderCreatedEvent.cs +++ b/src/NzbDrone.Core/MediaFiles/Events/TrackFolderCreatedEvent.cs @@ -1,20 +1,20 @@ -using NzbDrone.Common.Messaging; -using NzbDrone.Core.Music; +using NzbDrone.Common.Messaging; +using NzbDrone.Core.Books; namespace NzbDrone.Core.MediaFiles.Events { public class TrackFolderCreatedEvent : IEvent { - public Author Artist { get; private set; } - public BookFile TrackFile { get; private set; } - public string ArtistFolder { get; set; } - public string AlbumFolder { get; set; } + public Author Author { get; private set; } + public BookFile BookFile { get; private set; } + public string AuthorFolder { get; set; } + public string BookFolder { get; set; } public string TrackFolder { get; set; } - public TrackFolderCreatedEvent(Author artist, BookFile trackFile) + public TrackFolderCreatedEvent(Author author, BookFile bookFile) { - Artist = artist; - TrackFile = trackFile; + Author = author; + BookFile = bookFile; } } } diff --git a/src/NzbDrone.Core/MediaFiles/Events/TrackImportFailedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/TrackImportFailedEvent.cs index 6a6c0f8bf..346f054b8 100644 --- a/src/NzbDrone.Core/MediaFiles/Events/TrackImportFailedEvent.cs +++ b/src/NzbDrone.Core/MediaFiles/Events/TrackImportFailedEvent.cs @@ -8,15 +8,15 @@ namespace NzbDrone.Core.MediaFiles.Events public class TrackImportFailedEvent : IEvent { public Exception Exception { get; set; } - public LocalTrack TrackInfo { get; } + public LocalBook BookInfo { get; } public bool NewDownload { get; } public string DownloadClient { get; } public string DownloadId { get; } - public TrackImportFailedEvent(Exception exception, LocalTrack trackInfo, bool newDownload, DownloadClientItem downloadClientItem) + public TrackImportFailedEvent(Exception exception, LocalBook bookInfo, bool newDownload, DownloadClientItem downloadClientItem) { Exception = exception; - TrackInfo = trackInfo; + BookInfo = bookInfo; NewDownload = newDownload; if (downloadClientItem != null) diff --git a/src/NzbDrone.Core/MediaFiles/Events/TrackImportedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/TrackImportedEvent.cs index 3957e80b5..5f7e039d9 100644 --- a/src/NzbDrone.Core/MediaFiles/Events/TrackImportedEvent.cs +++ b/src/NzbDrone.Core/MediaFiles/Events/TrackImportedEvent.cs @@ -7,17 +7,17 @@ namespace NzbDrone.Core.MediaFiles.Events { public class TrackImportedEvent : IEvent { - public LocalTrack TrackInfo { get; private set; } - public BookFile ImportedTrack { get; private set; } + public LocalBook BookInfo { get; private set; } + public BookFile ImportedBook { get; private set; } public List<BookFile> OldFiles { get; private set; } public bool NewDownload { get; private set; } public string DownloadClient { get; private set; } public string DownloadId { get; private set; } - public TrackImportedEvent(LocalTrack trackInfo, BookFile importedTrack, List<BookFile> oldFiles, bool newDownload, DownloadClientItem downloadClientItem) + public TrackImportedEvent(LocalBook bookInfo, BookFile importedBook, List<BookFile> oldFiles, bool newDownload, DownloadClientItem downloadClientItem) { - TrackInfo = trackInfo; - ImportedTrack = importedTrack; + BookInfo = bookInfo; + ImportedBook = importedBook; OldFiles = oldFiles; NewDownload = newDownload; diff --git a/src/NzbDrone.Core/MediaFiles/MediaFileAttributeService.cs b/src/NzbDrone.Core/MediaFiles/MediaFileAttributeService.cs index cc7c400c1..5591bb599 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaFileAttributeService.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaFileAttributeService.cs @@ -70,7 +70,7 @@ namespace NzbDrone.Core.MediaFiles { if (OsInfo.IsWindows) { - _logger.Debug("Setting last write time on artist folder: {0}", path); + _logger.Debug("Setting last write time on author folder: {0}", path); _diskProvider.FolderSetLastWriteTime(path, time); } } diff --git a/src/NzbDrone.Core/MediaFiles/MediaFileDeletionService.cs b/src/NzbDrone.Core/MediaFiles/MediaFileDeletionService.cs index 11c7c3471..98385730c 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaFileDeletionService.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaFileDeletionService.cs @@ -4,85 +4,85 @@ using System.Net; using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; +using NzbDrone.Core.Books.Events; using NzbDrone.Core.Configuration; using NzbDrone.Core.Exceptions; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; -using NzbDrone.Core.Music.Events; namespace NzbDrone.Core.MediaFiles { public interface IDeleteMediaFiles { - void DeleteTrackFile(Author artist, BookFile trackFile); - void DeleteTrackFile(BookFile trackFile, string subfolder = ""); + void DeleteTrackFile(Author author, BookFile bookFile); + void DeleteTrackFile(BookFile bookFile, string subfolder = ""); } public class MediaFileDeletionService : IDeleteMediaFiles, - IHandleAsync<ArtistDeletedEvent>, - IHandleAsync<AlbumDeletedEvent>, - IHandle<TrackFileDeletedEvent> + IHandleAsync<AuthorDeletedEvent>, + IHandleAsync<BookDeletedEvent>, + IHandle<BookFileDeletedEvent> { private readonly IDiskProvider _diskProvider; private readonly IRecycleBinProvider _recycleBinProvider; private readonly IMediaFileService _mediaFileService; - private readonly IArtistService _artistService; + private readonly IAuthorService _authorService; private readonly IConfigService _configService; private readonly Logger _logger; public MediaFileDeletionService(IDiskProvider diskProvider, IRecycleBinProvider recycleBinProvider, IMediaFileService mediaFileService, - IArtistService artistService, + IAuthorService authorService, IConfigService configService, Logger logger) { _diskProvider = diskProvider; _recycleBinProvider = recycleBinProvider; _mediaFileService = mediaFileService; - _artistService = artistService; + _authorService = authorService; _configService = configService; _logger = logger; } - public void DeleteTrackFile(Author artist, BookFile trackFile) + public void DeleteTrackFile(Author author, BookFile bookFile) { - var fullPath = trackFile.Path; - var rootFolder = _diskProvider.GetParentFolder(artist.Path); + var fullPath = bookFile.Path; + var rootFolder = _diskProvider.GetParentFolder(author.Path); if (!_diskProvider.FolderExists(rootFolder)) { - _logger.Warn("Artist's root folder ({0}) doesn't exist.", rootFolder); - throw new NzbDroneClientException(HttpStatusCode.Conflict, "Artist's root folder ({0}) doesn't exist.", rootFolder); + _logger.Warn("Author's root folder ({0}) doesn't exist.", rootFolder); + throw new NzbDroneClientException(HttpStatusCode.Conflict, "Author's root folder ({0}) doesn't exist.", rootFolder); } if (_diskProvider.GetDirectories(rootFolder).Empty()) { - _logger.Warn("Artist's root folder ({0}) is empty.", rootFolder); - throw new NzbDroneClientException(HttpStatusCode.Conflict, "Artist's root folder ({0}) is empty.", rootFolder); + _logger.Warn("Author's root folder ({0}) is empty.", rootFolder); + throw new NzbDroneClientException(HttpStatusCode.Conflict, "Author's root folder ({0}) is empty.", rootFolder); } - if (_diskProvider.FolderExists(artist.Path)) + if (_diskProvider.FolderExists(author.Path)) { - var subfolder = _diskProvider.GetParentFolder(artist.Path).GetRelativePath(_diskProvider.GetParentFolder(fullPath)); - DeleteTrackFile(trackFile, subfolder); + var subfolder = _diskProvider.GetParentFolder(author.Path).GetRelativePath(_diskProvider.GetParentFolder(fullPath)); + DeleteTrackFile(bookFile, subfolder); } else { - // delete from db even if the artist folder is missing - _mediaFileService.Delete(trackFile, DeleteMediaFileReason.Manual); + // delete from db even if the author folder is missing + _mediaFileService.Delete(bookFile, DeleteMediaFileReason.Manual); } } - public void DeleteTrackFile(BookFile trackFile, string subfolder = "") + public void DeleteTrackFile(BookFile bookFile, string subfolder = "") { - var fullPath = trackFile.Path; + var fullPath = bookFile.Path; if (_diskProvider.FileExists(fullPath)) { - _logger.Info("Deleting track file: {0}", fullPath); + _logger.Info("Deleting book file: {0}", fullPath); try { @@ -90,54 +90,54 @@ namespace NzbDrone.Core.MediaFiles } catch (Exception e) { - _logger.Error(e, "Unable to delete track file"); - throw new NzbDroneClientException(HttpStatusCode.InternalServerError, "Unable to delete track file"); + _logger.Error(e, "Unable to delete book file"); + throw new NzbDroneClientException(HttpStatusCode.InternalServerError, "Unable to delete book file"); } } // Delete the track file from the database to clean it up even if the file was already deleted - _mediaFileService.Delete(trackFile, DeleteMediaFileReason.Manual); + _mediaFileService.Delete(bookFile, DeleteMediaFileReason.Manual); } - public void HandleAsync(ArtistDeletedEvent message) + public void HandleAsync(AuthorDeletedEvent message) { if (message.DeleteFiles) { - var artist = message.Artist; - var allArtists = _artistService.GetAllArtists(); + var author = message.Author; + var allArtists = _authorService.GetAllAuthors(); foreach (var s in allArtists) { - if (s.Id == artist.Id) + if (s.Id == author.Id) { continue; } - if (artist.Path.IsParentPath(s.Path)) + if (author.Path.IsParentPath(s.Path)) { - _logger.Error("Artist path: '{0}' is a parent of another artist, not deleting files.", artist.Path); + _logger.Error("Author path: '{0}' is a parent of another author, not deleting files.", author.Path); return; } - if (artist.Path.PathEquals(s.Path)) + if (author.Path.PathEquals(s.Path)) { - _logger.Error("Artist path: '{0}' is the same as another artist, not deleting files.", artist.Path); + _logger.Error("Author path: '{0}' is the same as another author, not deleting files.", author.Path); return; } } - if (_diskProvider.FolderExists(message.Artist.Path)) + if (_diskProvider.FolderExists(message.Author.Path)) { - _recycleBinProvider.DeleteFolder(message.Artist.Path); + _recycleBinProvider.DeleteFolder(message.Author.Path); } } } - public void HandleAsync(AlbumDeletedEvent message) + public void HandleAsync(BookDeletedEvent message) { if (message.DeleteFiles) { - var files = _mediaFileService.GetFilesByAlbum(message.Album.Id); + var files = _mediaFileService.GetFilesByBook(message.Book.Id); foreach (var file in files) { _recycleBinProvider.DeleteFile(file.Path); @@ -146,7 +146,7 @@ namespace NzbDrone.Core.MediaFiles } [EventHandleOrder(EventHandleOrder.Last)] - public void Handle(TrackFileDeletedEvent message) + public void Handle(BookFileDeletedEvent message) { if (message.Reason == DeleteMediaFileReason.Upgrade) { @@ -155,16 +155,16 @@ namespace NzbDrone.Core.MediaFiles if (_configService.DeleteEmptyFolders) { - var artist = message.TrackFile.Artist.Value; - var albumFolder = message.TrackFile.Path.GetParentPath(); + var author = message.BookFile.Author.Value; + var bookFolder = message.BookFile.Path.GetParentPath(); - if (_diskProvider.GetFiles(artist.Path, SearchOption.AllDirectories).Empty()) + if (_diskProvider.GetFiles(author.Path, SearchOption.AllDirectories).Empty()) { - _diskProvider.DeleteFolder(artist.Path, true); + _diskProvider.DeleteFolder(author.Path, true); } - else if (_diskProvider.GetFiles(albumFolder, SearchOption.AllDirectories).Empty()) + else if (_diskProvider.GetFiles(bookFolder, SearchOption.AllDirectories).Empty()) { - _diskProvider.RemoveEmptySubfolders(albumFolder); + _diskProvider.RemoveEmptySubfolders(bookFolder); } } } diff --git a/src/NzbDrone.Core/MediaFiles/MediaFileRepository.cs b/src/NzbDrone.Core/MediaFiles/MediaFileRepository.cs index 1b3dbc8fc..a577722ae 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaFileRepository.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaFileRepository.cs @@ -3,22 +3,22 @@ using System.IO; using System.Linq; using Dapper; using NzbDrone.Common; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; namespace NzbDrone.Core.MediaFiles { public interface IMediaFileRepository : IBasicRepository<BookFile> { - List<BookFile> GetFilesByArtist(int authorId); - List<BookFile> GetFilesByAlbum(int bookId); + List<BookFile> GetFilesByAuthor(int authorId); + List<BookFile> GetFilesByBook(int bookId); List<BookFile> GetUnmappedFiles(); List<BookFile> GetFilesWithBasePath(string path); List<BookFile> GetFileWithPath(List<string> paths); BookFile GetFileWithPath(string path); - void DeleteFilesByAlbum(int bookId); - void UnlinkFilesByAlbum(int bookId); + void DeleteFilesByBook(int bookId); + void UnlinkFilesByBook(int bookId); } public class MediaFileRepository : BasicRepository<BookFile>, IMediaFileRepository @@ -32,36 +32,36 @@ namespace NzbDrone.Core.MediaFiles // needed more often than not so better to load it all now protected override SqlBuilder Builder() => new SqlBuilder() .LeftJoin<BookFile, Book>((t, a) => t.BookId == a.Id) - .LeftJoin<Book, Author>((album, artist) => album.AuthorMetadataId == artist.AuthorMetadataId) + .LeftJoin<Book, Author>((book, author) => book.AuthorMetadataId == author.AuthorMetadataId) .LeftJoin<Author, AuthorMetadata>((a, m) => a.AuthorMetadataId == m.Id); protected override List<BookFile> Query(SqlBuilder builder) => Query(_database, builder).ToList(); public static IEnumerable<BookFile> Query(IDatabase database, SqlBuilder builder) { - return database.QueryJoined<BookFile, Book, Author, AuthorMetadata>(builder, (file, album, artist, metadata) => Map(file, album, artist, metadata)); + return database.QueryJoined<BookFile, Book, Author, AuthorMetadata>(builder, (file, book, author, metadata) => Map(file, book, author, metadata)); } - private static BookFile Map(BookFile file, Book album, Author artist, AuthorMetadata metadata) + private static BookFile Map(BookFile file, Book book, Author author, AuthorMetadata metadata) { - file.Album = album; + file.Book = book; - if (artist != null) + if (author != null) { - artist.Metadata = metadata; + author.Metadata = metadata; } - file.Artist = artist; + file.Author = author; return file; } - public List<BookFile> GetFilesByArtist(int authorId) + public List<BookFile> GetFilesByAuthor(int authorId) { return Query(Builder().Where<Author>(a => a.Id == authorId)); } - public List<BookFile> GetFilesByAlbum(int bookId) + public List<BookFile> GetFilesByBook(int bookId) { return Query(Builder().Where<BookFile>(f => f.BookId == bookId)); } @@ -76,12 +76,12 @@ namespace NzbDrone.Core.MediaFiles #pragma warning restore CS0472 } - public void DeleteFilesByAlbum(int bookId) + public void DeleteFilesByBook(int bookId) { Delete(x => x.BookId == bookId); } - public void UnlinkFilesByAlbum(int bookId) + public void UnlinkFilesByBook(int bookId) { var files = Query(x => x.BookId == bookId); files.ForEach(x => x.BookId = 0); @@ -114,7 +114,7 @@ namespace NzbDrone.Core.MediaFiles private BookFile MapTrack(BookFile file, Book book) { - file.Album = book; + file.Book = book; return file; } } diff --git a/src/NzbDrone.Core/MediaFiles/MediaFileService.cs b/src/NzbDrone.Core/MediaFiles/MediaFileService.cs index aab47538e..640f4e6c7 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaFileService.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaFileService.cs @@ -5,24 +5,24 @@ using System.Linq; using NLog; using NzbDrone.Common; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books.Events; using NzbDrone.Core.Datastore.Events; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music.Events; using NzbDrone.Core.RootFolders; namespace NzbDrone.Core.MediaFiles { public interface IMediaFileService { - BookFile Add(BookFile trackFile); - void AddMany(List<BookFile> trackFiles); - void Update(BookFile trackFile); - void Update(List<BookFile> trackFile); - void Delete(BookFile trackFile, DeleteMediaFileReason reason); - void DeleteMany(List<BookFile> trackFiles, DeleteMediaFileReason reason); - List<BookFile> GetFilesByArtist(int authorId); - List<BookFile> GetFilesByAlbum(int bookId); + BookFile Add(BookFile bookFile); + void AddMany(List<BookFile> bookFiles); + void Update(BookFile bookFile); + void Update(List<BookFile> bookFiles); + void Delete(BookFile bookFile, DeleteMediaFileReason reason); + void DeleteMany(List<BookFile> bookFiles, DeleteMediaFileReason reason); + List<BookFile> GetFilesByAuthor(int authorId); + List<BookFile> GetFilesByBook(int bookId); List<BookFile> GetUnmappedFiles(); List<IFileInfo> FilterUnchangedFiles(List<IFileInfo> files, FilterFilesType filter); BookFile Get(int id); @@ -30,12 +30,12 @@ namespace NzbDrone.Core.MediaFiles List<BookFile> GetFilesWithBasePath(string path); List<BookFile> GetFileWithPath(List<string> path); BookFile GetFileWithPath(string path); - void UpdateMediaInfo(List<BookFile> trackFiles); + void UpdateMediaInfo(List<BookFile> bookFiles); } public class MediaFileService : IMediaFileService, - IHandle<ArtistMovedEvent>, - IHandleAsync<AlbumDeletedEvent>, + IHandle<AuthorMovedEvent>, + IHandleAsync<BookDeletedEvent>, IHandleAsync<ModelEvent<RootFolder>> { private readonly IEventAggregator _eventAggregator; @@ -49,51 +49,51 @@ namespace NzbDrone.Core.MediaFiles _logger = logger; } - public BookFile Add(BookFile trackFile) + public BookFile Add(BookFile bookFile) { - var addedFile = _mediaFileRepository.Insert(trackFile); - _eventAggregator.PublishEvent(new TrackFileAddedEvent(addedFile)); + var addedFile = _mediaFileRepository.Insert(bookFile); + _eventAggregator.PublishEvent(new BookFileAddedEvent(addedFile)); return addedFile; } - public void AddMany(List<BookFile> trackFiles) + public void AddMany(List<BookFile> bookFiles) { - _mediaFileRepository.InsertMany(trackFiles); - foreach (var addedFile in trackFiles) + _mediaFileRepository.InsertMany(bookFiles); + foreach (var addedFile in bookFiles) { - _eventAggregator.PublishEvent(new TrackFileAddedEvent(addedFile)); + _eventAggregator.PublishEvent(new BookFileAddedEvent(addedFile)); } } - public void Update(BookFile trackFile) + public void Update(BookFile bookFile) { - _mediaFileRepository.Update(trackFile); + _mediaFileRepository.Update(bookFile); } - public void Update(List<BookFile> trackFiles) + public void Update(List<BookFile> bookFiles) { - _mediaFileRepository.UpdateMany(trackFiles); + _mediaFileRepository.UpdateMany(bookFiles); } - public void Delete(BookFile trackFile, DeleteMediaFileReason reason) + public void Delete(BookFile bookFile, DeleteMediaFileReason reason) { - _mediaFileRepository.Delete(trackFile); + _mediaFileRepository.Delete(bookFile); // If the trackfile wasn't mapped to a track, don't publish an event - if (trackFile.BookId > 0) + if (bookFile.BookId > 0) { - _eventAggregator.PublishEvent(new TrackFileDeletedEvent(trackFile, reason)); + _eventAggregator.PublishEvent(new BookFileDeletedEvent(bookFile, reason)); } } - public void DeleteMany(List<BookFile> trackFiles, DeleteMediaFileReason reason) + public void DeleteMany(List<BookFile> bookFiles, DeleteMediaFileReason reason) { - _mediaFileRepository.DeleteMany(trackFiles); + _mediaFileRepository.DeleteMany(bookFiles); // publish events where trackfile was mapped to a track - foreach (var trackFile in trackFiles.Where(x => x.BookId > 0)) + foreach (var bookFile in bookFiles.Where(x => x.BookId > 0)) { - _eventAggregator.PublishEvent(new TrackFileDeletedEvent(trackFile, reason)); + _eventAggregator.PublishEvent(new BookFileDeletedEvent(bookFile, reason)); } } @@ -138,7 +138,7 @@ namespace NzbDrone.Core.MediaFiles unwanted = combined .Where(x => x.DiskFile.Length == x.DbFile.Size && Math.Abs((x.DiskFile.LastWriteTimeUtc - x.DbFile.Modified).TotalSeconds) <= 1 && - (x.DbFile.Album == null || (x.DbFile.Album.IsLoaded && x.DbFile.Album.Value != null))) + (x.DbFile.Book == null || (x.DbFile.Book.IsLoaded && x.DbFile.Book.Value != null))) .Select(x => x.DiskFile) .ToList(); _logger.Trace($"{unwanted.Count} unchanged and matched files"); @@ -176,14 +176,14 @@ namespace NzbDrone.Core.MediaFiles return _mediaFileRepository.GetFileWithPath(path); } - public List<BookFile> GetFilesByArtist(int authorId) + public List<BookFile> GetFilesByAuthor(int authorId) { - return _mediaFileRepository.GetFilesByArtist(authorId); + return _mediaFileRepository.GetFilesByAuthor(authorId); } - public List<BookFile> GetFilesByAlbum(int bookId) + public List<BookFile> GetFilesByBook(int bookId) { - return _mediaFileRepository.GetFilesByAlbum(bookId); + return _mediaFileRepository.GetFilesByBook(bookId); } public List<BookFile> GetUnmappedFiles() @@ -191,12 +191,12 @@ namespace NzbDrone.Core.MediaFiles return _mediaFileRepository.GetUnmappedFiles(); } - public void UpdateMediaInfo(List<BookFile> trackFiles) + public void UpdateMediaInfo(List<BookFile> bookFiles) { - _mediaFileRepository.SetFields(trackFiles, t => t.MediaInfo); + _mediaFileRepository.SetFields(bookFiles, t => t.MediaInfo); } - public void Handle(ArtistMovedEvent message) + public void Handle(AuthorMovedEvent message) { var files = _mediaFileRepository.GetFilesWithBasePath(message.SourcePath); @@ -209,15 +209,15 @@ namespace NzbDrone.Core.MediaFiles Update(files); } - public void HandleAsync(AlbumDeletedEvent message) + public void HandleAsync(BookDeletedEvent message) { if (message.DeleteFiles) { - _mediaFileRepository.DeleteFilesByAlbum(message.Album.Id); + _mediaFileRepository.DeleteFilesByBook(message.Book.Id); } else { - _mediaFileRepository.UnlinkFilesByAlbum(message.Album.Id); + _mediaFileRepository.UnlinkFilesByBook(message.Book.Id); } } diff --git a/src/NzbDrone.Core/MediaFiles/RenameTrackFilePreview.cs b/src/NzbDrone.Core/MediaFiles/RenameBookFilePreview.cs similarity index 69% rename from src/NzbDrone.Core/MediaFiles/RenameTrackFilePreview.cs rename to src/NzbDrone.Core/MediaFiles/RenameBookFilePreview.cs index a85c0dd10..19854705d 100644 --- a/src/NzbDrone.Core/MediaFiles/RenameTrackFilePreview.cs +++ b/src/NzbDrone.Core/MediaFiles/RenameBookFilePreview.cs @@ -1,13 +1,13 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace NzbDrone.Core.MediaFiles { - public class RenameTrackFilePreview + public class RenameBookFilePreview { public int AuthorId { get; set; } public int BookId { get; set; } public List<int> TrackNumbers { get; set; } - public int TrackFileId { get; set; } + public int BookFileId { get; set; } public string ExistingPath { get; set; } public string NewPath { get; set; } } diff --git a/src/NzbDrone.Core/MediaFiles/RenameBookFileService.cs b/src/NzbDrone.Core/MediaFiles/RenameBookFileService.cs new file mode 100644 index 000000000..ac54f74a8 --- /dev/null +++ b/src/NzbDrone.Core/MediaFiles/RenameBookFileService.cs @@ -0,0 +1,171 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using NLog; +using NzbDrone.Common.Disk; +using NzbDrone.Common.Extensions; +using NzbDrone.Common.Instrumentation.Extensions; +using NzbDrone.Core.Books; +using NzbDrone.Core.MediaFiles.Commands; +using NzbDrone.Core.MediaFiles.Events; +using NzbDrone.Core.Messaging.Commands; +using NzbDrone.Core.Messaging.Events; +using NzbDrone.Core.Organizer; + +namespace NzbDrone.Core.MediaFiles +{ + public interface IRenameTrackFileService + { + List<RenameBookFilePreview> GetRenamePreviews(int authorId); + List<RenameBookFilePreview> GetRenamePreviews(int authorId, int bookId); + } + + public class RenameBookFileService : IRenameTrackFileService, IExecute<RenameFilesCommand>, IExecute<RenameAuthorCommand> + { + private readonly IAuthorService _authorService; + private readonly IMediaFileService _mediaFileService; + private readonly IMoveBookFiles _bookFileMover; + private readonly IEventAggregator _eventAggregator; + private readonly IBuildFileNames _filenameBuilder; + private readonly IDiskProvider _diskProvider; + private readonly Logger _logger; + + public RenameBookFileService(IAuthorService authorService, + IMediaFileService mediaFileService, + IMoveBookFiles bookFileMover, + IEventAggregator eventAggregator, + IBuildFileNames filenameBuilder, + IDiskProvider diskProvider, + Logger logger) + { + _authorService = authorService; + _mediaFileService = mediaFileService; + _bookFileMover = bookFileMover; + _eventAggregator = eventAggregator; + _filenameBuilder = filenameBuilder; + _diskProvider = diskProvider; + _logger = logger; + } + + public List<RenameBookFilePreview> GetRenamePreviews(int authorId) + { + var author = _authorService.GetAuthor(authorId); + var files = _mediaFileService.GetFilesByAuthor(authorId); + + _logger.Trace($"got {files.Count} files"); + + return GetPreviews(author, files) + .OrderByDescending(e => e.BookId) + .ToList(); + } + + public List<RenameBookFilePreview> GetRenamePreviews(int authorId, int bookId) + { + var author = _authorService.GetAuthor(authorId); + var files = _mediaFileService.GetFilesByBook(bookId); + + return GetPreviews(author, files) + .OrderByDescending(e => e.TrackNumbers.First()).ToList(); + } + + private IEnumerable<RenameBookFilePreview> GetPreviews(Author author, List<BookFile> files) + { + foreach (var f in files) + { + var file = f; + var book = file.Book.Value; + var bookFilePath = file.Path; + + if (book == null) + { + _logger.Warn("File ({0}) is not linked to a book", bookFilePath); + continue; + } + + var newName = _filenameBuilder.BuildBookFileName(author, book, file); + + _logger.Trace($"got name {newName}"); + + var newPath = _filenameBuilder.BuildBookFilePath(author, book, newName, Path.GetExtension(bookFilePath)); + + _logger.Trace($"got path {newPath}"); + + if (!bookFilePath.PathEquals(newPath, StringComparison.Ordinal)) + { + yield return new RenameBookFilePreview + { + AuthorId = author.Id, + BookId = book.Id, + BookFileId = file.Id, + ExistingPath = file.Path, + NewPath = newPath + }; + } + } + } + + private void RenameFiles(List<BookFile> bookFiles, Author author) + { + var renamed = new List<BookFile>(); + + foreach (var bookFile in bookFiles) + { + var bookFilePath = bookFile.Path; + + try + { + _logger.Debug("Renaming book file: {0}", bookFile); + _bookFileMover.MoveBookFile(bookFile, author); + + _mediaFileService.Update(bookFile); + renamed.Add(bookFile); + + _logger.Debug("Renamed book file: {0}", bookFile); + + _eventAggregator.PublishEvent(new BookFileRenamedEvent(author, bookFile, bookFilePath)); + } + catch (SameFilenameException ex) + { + _logger.Debug("File not renamed, source and destination are the same: {0}", ex.Filename); + } + catch (Exception ex) + { + _logger.Error(ex, "Failed to rename file {0}", bookFilePath); + } + } + + if (renamed.Any()) + { + _eventAggregator.PublishEvent(new AuthorRenamedEvent(author)); + + _logger.Debug("Removing Empty Subfolders from: {0}", author.Path); + _diskProvider.RemoveEmptySubfolders(author.Path); + } + } + + public void Execute(RenameFilesCommand message) + { + var author = _authorService.GetAuthor(message.AuthorId); + var bookFiles = _mediaFileService.Get(message.Files); + + _logger.ProgressInfo("Renaming {0} files for {1}", bookFiles.Count, author.Name); + RenameFiles(bookFiles, author); + _logger.ProgressInfo("Selected book files renamed for {0}", author.Name); + } + + public void Execute(RenameAuthorCommand message) + { + _logger.Debug("Renaming all files for selected author"); + var artistToRename = _authorService.GetAuthors(message.AuthorIds); + + foreach (var author in artistToRename) + { + var bookFiles = _mediaFileService.GetFilesByAuthor(author.Id); + _logger.ProgressInfo("Renaming all files in author: {0}", author.Name); + RenameFiles(bookFiles, author); + _logger.ProgressInfo("All book files renamed for {0}", author.Name); + } + } + } +} diff --git a/src/NzbDrone.Core/MediaFiles/RenameTrackFileService.cs b/src/NzbDrone.Core/MediaFiles/RenameTrackFileService.cs deleted file mode 100644 index 32176f285..000000000 --- a/src/NzbDrone.Core/MediaFiles/RenameTrackFileService.cs +++ /dev/null @@ -1,171 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using NLog; -using NzbDrone.Common.Disk; -using NzbDrone.Common.Extensions; -using NzbDrone.Common.Instrumentation.Extensions; -using NzbDrone.Core.MediaFiles.Commands; -using NzbDrone.Core.MediaFiles.Events; -using NzbDrone.Core.Messaging.Commands; -using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; -using NzbDrone.Core.Organizer; - -namespace NzbDrone.Core.MediaFiles -{ - public interface IRenameTrackFileService - { - List<RenameTrackFilePreview> GetRenamePreviews(int authorId); - List<RenameTrackFilePreview> GetRenamePreviews(int authorId, int bookId); - } - - public class RenameTrackFileService : IRenameTrackFileService, IExecute<RenameFilesCommand>, IExecute<RenameArtistCommand> - { - private readonly IArtistService _artistService; - private readonly IMediaFileService _mediaFileService; - private readonly IMoveTrackFiles _trackFileMover; - private readonly IEventAggregator _eventAggregator; - private readonly IBuildFileNames _filenameBuilder; - private readonly IDiskProvider _diskProvider; - private readonly Logger _logger; - - public RenameTrackFileService(IArtistService artistService, - IMediaFileService mediaFileService, - IMoveTrackFiles trackFileMover, - IEventAggregator eventAggregator, - IBuildFileNames filenameBuilder, - IDiskProvider diskProvider, - Logger logger) - { - _artistService = artistService; - _mediaFileService = mediaFileService; - _trackFileMover = trackFileMover; - _eventAggregator = eventAggregator; - _filenameBuilder = filenameBuilder; - _diskProvider = diskProvider; - _logger = logger; - } - - public List<RenameTrackFilePreview> GetRenamePreviews(int authorId) - { - var artist = _artistService.GetArtist(authorId); - var files = _mediaFileService.GetFilesByArtist(authorId); - - _logger.Trace($"got {files.Count} files"); - - return GetPreviews(artist, files) - .OrderByDescending(e => e.BookId) - .ToList(); - } - - public List<RenameTrackFilePreview> GetRenamePreviews(int authorId, int bookId) - { - var artist = _artistService.GetArtist(authorId); - var files = _mediaFileService.GetFilesByAlbum(bookId); - - return GetPreviews(artist, files) - .OrderByDescending(e => e.TrackNumbers.First()).ToList(); - } - - private IEnumerable<RenameTrackFilePreview> GetPreviews(Author artist, List<BookFile> files) - { - foreach (var f in files) - { - var file = f; - var book = file.Album.Value; - var trackFilePath = file.Path; - - if (book == null) - { - _logger.Warn("File ({0}) is not linked to a book", trackFilePath); - continue; - } - - var newName = _filenameBuilder.BuildTrackFileName(artist, book, file); - - _logger.Trace($"got name {newName}"); - - var newPath = _filenameBuilder.BuildTrackFilePath(artist, book, newName, Path.GetExtension(trackFilePath)); - - _logger.Trace($"got path {newPath}"); - - if (!trackFilePath.PathEquals(newPath, StringComparison.Ordinal)) - { - yield return new RenameTrackFilePreview - { - AuthorId = artist.Id, - BookId = book.Id, - TrackFileId = file.Id, - ExistingPath = file.Path, - NewPath = newPath - }; - } - } - } - - private void RenameFiles(List<BookFile> trackFiles, Author artist) - { - var renamed = new List<BookFile>(); - - foreach (var trackFile in trackFiles) - { - var trackFilePath = trackFile.Path; - - try - { - _logger.Debug("Renaming track file: {0}", trackFile); - _trackFileMover.MoveTrackFile(trackFile, artist); - - _mediaFileService.Update(trackFile); - renamed.Add(trackFile); - - _logger.Debug("Renamed track file: {0}", trackFile); - - _eventAggregator.PublishEvent(new TrackFileRenamedEvent(artist, trackFile, trackFilePath)); - } - catch (SameFilenameException ex) - { - _logger.Debug("File not renamed, source and destination are the same: {0}", ex.Filename); - } - catch (Exception ex) - { - _logger.Error(ex, "Failed to rename file {0}", trackFilePath); - } - } - - if (renamed.Any()) - { - _eventAggregator.PublishEvent(new ArtistRenamedEvent(artist)); - - _logger.Debug("Removing Empty Subfolders from: {0}", artist.Path); - _diskProvider.RemoveEmptySubfolders(artist.Path); - } - } - - public void Execute(RenameFilesCommand message) - { - var artist = _artistService.GetArtist(message.AuthorId); - var trackFiles = _mediaFileService.Get(message.Files); - - _logger.ProgressInfo("Renaming {0} files for {1}", trackFiles.Count, artist.Name); - RenameFiles(trackFiles, artist); - _logger.ProgressInfo("Selected track files renamed for {0}", artist.Name); - } - - public void Execute(RenameArtistCommand message) - { - _logger.Debug("Renaming all files for selected artist"); - var artistToRename = _artistService.GetArtists(message.AuthorIds); - - foreach (var artist in artistToRename) - { - var trackFiles = _mediaFileService.GetFilesByArtist(artist.Id); - _logger.ProgressInfo("Renaming all files in artist: {0}", artist.Name); - RenameFiles(trackFiles, artist); - _logger.ProgressInfo("All track files renamed for {0}", artist.Name); - } - } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/RetagTrackFilePreview.cs b/src/NzbDrone.Core/MediaFiles/RetagBookFilePreview.cs similarity index 77% rename from src/NzbDrone.Core/MediaFiles/RetagTrackFilePreview.cs rename to src/NzbDrone.Core/MediaFiles/RetagBookFilePreview.cs index 0149cc1ba..359de3341 100644 --- a/src/NzbDrone.Core/MediaFiles/RetagTrackFilePreview.cs +++ b/src/NzbDrone.Core/MediaFiles/RetagBookFilePreview.cs @@ -1,14 +1,14 @@ -using System; +using System; using System.Collections.Generic; namespace NzbDrone.Core.MediaFiles { - public class RetagTrackFilePreview + public class RetagBookFilePreview { public int AuthorId { get; set; } public int BookId { get; set; } public List<int> TrackNumbers { get; set; } - public int TrackFileId { get; set; } + public int BookFileId { get; set; } public string Path { get; set; } public Dictionary<string, Tuple<string, string>> Changes { get; set; } } diff --git a/src/NzbDrone.Core/MediaFiles/TrackFileMovingService.cs b/src/NzbDrone.Core/MediaFiles/TrackFileMovingService.cs deleted file mode 100644 index a247cceb2..000000000 --- a/src/NzbDrone.Core/MediaFiles/TrackFileMovingService.cs +++ /dev/null @@ -1,213 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using NLog; -using NzbDrone.Common.Disk; -using NzbDrone.Common.EnsureThat; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Configuration; -using NzbDrone.Core.MediaFiles.Events; -using NzbDrone.Core.MediaFiles.TrackImport; -using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; -using NzbDrone.Core.Organizer; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.MediaFiles -{ - public interface IMoveTrackFiles - { - BookFile MoveTrackFile(BookFile trackFile, Author artist); - BookFile MoveTrackFile(BookFile trackFile, LocalTrack localTrack); - BookFile CopyTrackFile(BookFile trackFile, LocalTrack localTrack); - } - - public class TrackFileMovingService : IMoveTrackFiles - { - private readonly IAlbumService _albumService; - private readonly IUpdateTrackFileService _updateTrackFileService; - private readonly IBuildFileNames _buildFileNames; - private readonly IDiskTransferService _diskTransferService; - private readonly IDiskProvider _diskProvider; - private readonly IRootFolderWatchingService _rootFolderWatchingService; - private readonly IMediaFileAttributeService _mediaFileAttributeService; - private readonly IEventAggregator _eventAggregator; - private readonly IConfigService _configService; - private readonly Logger _logger; - - public TrackFileMovingService(IAlbumService albumService, - IUpdateTrackFileService updateTrackFileService, - IBuildFileNames buildFileNames, - IDiskTransferService diskTransferService, - IDiskProvider diskProvider, - IRootFolderWatchingService rootFolderWatchingService, - IMediaFileAttributeService mediaFileAttributeService, - IEventAggregator eventAggregator, - IConfigService configService, - Logger logger) - { - _albumService = albumService; - _updateTrackFileService = updateTrackFileService; - _buildFileNames = buildFileNames; - _diskTransferService = diskTransferService; - _diskProvider = diskProvider; - _rootFolderWatchingService = rootFolderWatchingService; - _mediaFileAttributeService = mediaFileAttributeService; - _eventAggregator = eventAggregator; - _configService = configService; - _logger = logger; - } - - public BookFile MoveTrackFile(BookFile trackFile, Author artist) - { - var album = _albumService.GetAlbum(trackFile.BookId); - var newFileName = _buildFileNames.BuildTrackFileName(artist, album, trackFile); - var filePath = _buildFileNames.BuildTrackFilePath(artist, album, newFileName, Path.GetExtension(trackFile.Path)); - - EnsureTrackFolder(trackFile, artist, album, filePath); - - _logger.Debug("Renaming track file: {0} to {1}", trackFile, filePath); - - return TransferFile(trackFile, artist, null, filePath, TransferMode.Move); - } - - public BookFile MoveTrackFile(BookFile trackFile, LocalTrack localTrack) - { - var newFileName = _buildFileNames.BuildTrackFileName(localTrack.Artist, localTrack.Album, trackFile); - var filePath = _buildFileNames.BuildTrackFilePath(localTrack.Artist, localTrack.Album, newFileName, Path.GetExtension(localTrack.Path)); - - EnsureTrackFolder(trackFile, localTrack, filePath); - - _logger.Debug("Moving track file: {0} to {1}", trackFile.Path, filePath); - - return TransferFile(trackFile, localTrack.Artist, null, filePath, TransferMode.Move); - } - - public BookFile CopyTrackFile(BookFile trackFile, LocalTrack localTrack) - { - var newFileName = _buildFileNames.BuildTrackFileName(localTrack.Artist, localTrack.Album, trackFile); - var filePath = _buildFileNames.BuildTrackFilePath(localTrack.Artist, localTrack.Album, newFileName, Path.GetExtension(localTrack.Path)); - - EnsureTrackFolder(trackFile, localTrack, filePath); - - if (_configService.CopyUsingHardlinks) - { - _logger.Debug("Hardlinking track file: {0} to {1}", trackFile.Path, filePath); - return TransferFile(trackFile, localTrack.Artist, localTrack.Album, filePath, TransferMode.HardLinkOrCopy); - } - - _logger.Debug("Copying track file: {0} to {1}", trackFile.Path, filePath); - return TransferFile(trackFile, localTrack.Artist, localTrack.Album, filePath, TransferMode.Copy); - } - - private BookFile TransferFile(BookFile trackFile, Author artist, Book book, string destinationFilePath, TransferMode mode) - { - Ensure.That(trackFile, () => trackFile).IsNotNull(); - Ensure.That(artist, () => artist).IsNotNull(); - Ensure.That(destinationFilePath, () => destinationFilePath).IsValidPath(); - - var trackFilePath = trackFile.Path; - - if (!_diskProvider.FileExists(trackFilePath)) - { - throw new FileNotFoundException("Track file path does not exist", trackFilePath); - } - - if (trackFilePath == destinationFilePath) - { - throw new SameFilenameException("File not moved, source and destination are the same", trackFilePath); - } - - _rootFolderWatchingService.ReportFileSystemChangeBeginning(trackFilePath, destinationFilePath); - _diskTransferService.TransferFile(trackFilePath, destinationFilePath, mode); - - trackFile.Path = destinationFilePath; - - _updateTrackFileService.ChangeFileDateForFile(trackFile, artist, book); - - try - { - _mediaFileAttributeService.SetFolderLastWriteTime(artist.Path, trackFile.DateAdded); - } - catch (Exception ex) - { - _logger.Warn(ex, "Unable to set last write time"); - } - - _mediaFileAttributeService.SetFilePermissions(destinationFilePath); - - return trackFile; - } - - private void EnsureTrackFolder(BookFile trackFile, LocalTrack localTrack, string filePath) - { - EnsureTrackFolder(trackFile, localTrack.Artist, localTrack.Album, filePath); - } - - private void EnsureTrackFolder(BookFile trackFile, Author artist, Book album, string filePath) - { - var trackFolder = Path.GetDirectoryName(filePath); - var albumFolder = _buildFileNames.BuildAlbumPath(artist, album); - var artistFolder = artist.Path; - var rootFolder = new OsPath(artistFolder).Directory.FullPath; - - if (!_diskProvider.FolderExists(rootFolder)) - { - throw new RootFolderNotFoundException(string.Format("Root folder '{0}' was not found.", rootFolder)); - } - - var changed = false; - var newEvent = new TrackFolderCreatedEvent(artist, trackFile); - - _rootFolderWatchingService.ReportFileSystemChangeBeginning(artistFolder, albumFolder, trackFolder); - - if (!_diskProvider.FolderExists(artistFolder)) - { - CreateFolder(artistFolder); - newEvent.ArtistFolder = artistFolder; - changed = true; - } - - if (artistFolder != albumFolder && !_diskProvider.FolderExists(albumFolder)) - { - CreateFolder(albumFolder); - newEvent.AlbumFolder = albumFolder; - changed = true; - } - - if (albumFolder != trackFolder && !_diskProvider.FolderExists(trackFolder)) - { - CreateFolder(trackFolder); - newEvent.TrackFolder = trackFolder; - changed = true; - } - - if (changed) - { - _eventAggregator.PublishEvent(newEvent); - } - } - - private void CreateFolder(string directoryName) - { - Ensure.That(directoryName, () => directoryName).IsNotNullOrWhiteSpace(); - - var parentFolder = new OsPath(directoryName).Directory.FullPath; - if (!_diskProvider.FolderExists(parentFolder)) - { - CreateFolder(parentFolder); - } - - try - { - _diskProvider.CreateFolder(directoryName); - } - catch (IOException ex) - { - _logger.Error(ex, "Unable to create directory: {0}", directoryName); - } - - _mediaFileAttributeService.SetFolderPermissions(directoryName); - } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/UpdateTrackFileService.cs b/src/NzbDrone.Core/MediaFiles/UpdateTrackFileService.cs index b40862c62..88c5c7ddb 100644 --- a/src/NzbDrone.Core/MediaFiles/UpdateTrackFileService.cs +++ b/src/NzbDrone.Core/MediaFiles/UpdateTrackFileService.cs @@ -5,58 +5,58 @@ using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Instrumentation.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; namespace NzbDrone.Core.MediaFiles { - public interface IUpdateTrackFileService + public interface IUpdateBookFileService { - void ChangeFileDateForFile(BookFile trackFile, Author artist, Book book); + void ChangeFileDateForFile(BookFile bookFile, Author author, Book book); } - public class UpdateTrackFileService : IUpdateTrackFileService, - IHandle<ArtistScannedEvent> + public class UpdateTrackFileService : IUpdateBookFileService, + IHandle<AuthorScannedEvent> { private readonly IDiskProvider _diskProvider; - private readonly IAlbumService _albumService; + private readonly IBookService _bookService; private readonly IConfigService _configService; private readonly Logger _logger; private static readonly DateTime EpochTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); public UpdateTrackFileService(IDiskProvider diskProvider, IConfigService configService, - IAlbumService albumService, + IBookService bookService, Logger logger) { _diskProvider = diskProvider; _configService = configService; - _albumService = albumService; + _bookService = bookService; _logger = logger; } - public void ChangeFileDateForFile(BookFile trackFile, Author artist, Book book) + public void ChangeFileDateForFile(BookFile bookFile, Author author, Book book) { - ChangeFileDate(trackFile, book); + ChangeFileDate(bookFile, book); } - private bool ChangeFileDate(BookFile trackFile, Book album) + private bool ChangeFileDate(BookFile bookFile, Book book) { - var trackFilePath = trackFile.Path; + var trackFilePath = bookFile.Path; switch (_configService.FileDate) { case FileDateType.AlbumReleaseDate: { - if (!album.ReleaseDate.HasValue) + if (!book.ReleaseDate.HasValue) { _logger.Debug("Could not create valid date to change file [{0}]", trackFilePath); return false; } - var relDate = album.ReleaseDate.Value; + var relDate = book.ReleaseDate.Value; // avoiding false +ve checks and set date skewing by not using UTC (Windows) var oldDateTime = _diskProvider.FileGetLastWrite(trackFilePath); @@ -89,16 +89,16 @@ namespace NzbDrone.Core.MediaFiles return false; } - public void Handle(ArtistScannedEvent message) + public void Handle(AuthorScannedEvent message) { if (_configService.FileDate == FileDateType.None) { return; } - var books = _albumService.GetArtistAlbumsWithFiles(message.Artist); + var books = _bookService.GetAuthorBooksWithFiles(message.Author); - var trackFiles = new List<BookFile>(); + var bookFiles = new List<BookFile>(); var updated = new List<BookFile>(); foreach (var book in books) @@ -106,7 +106,7 @@ namespace NzbDrone.Core.MediaFiles var files = book.BookFiles.Value; foreach (var file in files) { - trackFiles.Add(file); + bookFiles.Add(file); if (ChangeFileDate(file, book)) { updated.Add(file); @@ -116,11 +116,11 @@ namespace NzbDrone.Core.MediaFiles if (updated.Any()) { - _logger.ProgressDebug("Changed file date for {0} files of {1} in {2}", updated.Count, trackFiles.Count, message.Artist.Name); + _logger.ProgressDebug("Changed file date for {0} files of {1} in {2}", updated.Count, bookFiles.Count, message.Author.Name); } else { - _logger.ProgressDebug("No file dates changed for {0}", message.Artist.Name); + _logger.ProgressDebug("No file dates changed for {0}", message.Author.Name); } } } diff --git a/src/NzbDrone.Core/MediaFiles/UpgradeMediaFileService.cs b/src/NzbDrone.Core/MediaFiles/UpgradeMediaFileService.cs index d5b403adb..35e5debe8 100644 --- a/src/NzbDrone.Core/MediaFiles/UpgradeMediaFileService.cs +++ b/src/NzbDrone.Core/MediaFiles/UpgradeMediaFileService.cs @@ -5,7 +5,7 @@ using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; using NzbDrone.Core.Books.Calibre; -using NzbDrone.Core.MediaFiles.TrackImport; +using NzbDrone.Core.MediaFiles.BookImport; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.RootFolders; @@ -13,7 +13,7 @@ namespace NzbDrone.Core.MediaFiles { public interface IUpgradeMediaFiles { - TrackFileMoveResult UpgradeTrackFile(BookFile trackFile, LocalTrack localTrack, bool copyOnly = false); + BookFileMoveResult UpgradeBookFile(BookFile bookFile, LocalBook localBook, bool copyOnly = false); } public class UpgradeMediaFileService : IUpgradeMediaFiles @@ -21,7 +21,7 @@ namespace NzbDrone.Core.MediaFiles private readonly IRecycleBinProvider _recycleBinProvider; private readonly IMediaFileService _mediaFileService; private readonly IAudioTagService _audioTagService; - private readonly IMoveTrackFiles _trackFileMover; + private readonly IMoveBookFiles _bookFileMover; private readonly IDiskProvider _diskProvider; private readonly IRootFolderService _rootFolderService; private readonly IRootFolderWatchingService _rootFolderWatchingService; @@ -31,7 +31,7 @@ namespace NzbDrone.Core.MediaFiles public UpgradeMediaFileService(IRecycleBinProvider recycleBinProvider, IMediaFileService mediaFileService, IAudioTagService audioTagService, - IMoveTrackFiles trackFileMover, + IMoveBookFiles bookFileMover, IDiskProvider diskProvider, IRootFolderService rootFolderService, IRootFolderWatchingService rootFolderWatchingService, @@ -41,7 +41,7 @@ namespace NzbDrone.Core.MediaFiles _recycleBinProvider = recycleBinProvider; _mediaFileService = mediaFileService; _audioTagService = audioTagService; - _trackFileMover = trackFileMover; + _bookFileMover = bookFileMover; _diskProvider = diskProvider; _rootFolderService = rootFolderService; _rootFolderWatchingService = rootFolderWatchingService; @@ -49,18 +49,18 @@ namespace NzbDrone.Core.MediaFiles _logger = logger; } - public TrackFileMoveResult UpgradeTrackFile(BookFile trackFile, LocalTrack localTrack, bool copyOnly = false) + public BookFileMoveResult UpgradeBookFile(BookFile bookFile, LocalBook localBook, bool copyOnly = false) { - var moveFileResult = new TrackFileMoveResult(); - var existingFiles = localTrack.Album.BookFiles.Value; + var moveFileResult = new BookFileMoveResult(); + var existingFiles = localBook.Book.BookFiles.Value; - var rootFolderPath = _diskProvider.GetParentFolder(localTrack.Artist.Path); + var rootFolderPath = _diskProvider.GetParentFolder(localBook.Author.Path); var rootFolder = _rootFolderService.GetBestRootFolder(rootFolderPath); var isCalibre = rootFolder.IsCalibreLibrary && rootFolder.CalibreSettings != null; var settings = rootFolder.CalibreSettings; - // If there are existing track files and the root folder is missing, throw, so the old file isn't left behind during the import process. + // If there are existing book files and the root folder is missing, throw, so the old file isn't left behind during the import process. if (existingFiles.Any() && !_diskProvider.FolderExists(rootFolderPath)) { throw new RootFolderNotFoundException($"Root folder '{rootFolderPath}' was not found."); @@ -71,11 +71,11 @@ namespace NzbDrone.Core.MediaFiles var trackFilePath = file.Path; var subfolder = rootFolderPath.GetRelativePath(_diskProvider.GetParentFolder(trackFilePath)); - trackFile.CalibreId = file.CalibreId; + bookFile.CalibreId = file.CalibreId; if (_diskProvider.FileExists(trackFilePath)) { - _logger.Debug("Removing existing track file: {0}", file); + _logger.Debug("Removing existing book file: {0}", file); if (!isCalibre) { @@ -86,7 +86,7 @@ namespace NzbDrone.Core.MediaFiles _calibre.RemoveFormats(file.CalibreId, new[] { - Path.GetExtension(trackFile.Path) + Path.GetExtension(bookFile.Path) }, settings); } @@ -100,20 +100,20 @@ namespace NzbDrone.Core.MediaFiles { if (copyOnly) { - moveFileResult.TrackFile = _trackFileMover.CopyTrackFile(trackFile, localTrack); + moveFileResult.BookFile = _bookFileMover.CopyBookFile(bookFile, localBook); } else { - moveFileResult.TrackFile = _trackFileMover.MoveTrackFile(trackFile, localTrack); + moveFileResult.BookFile = _bookFileMover.MoveBookFile(bookFile, localBook); } - _audioTagService.WriteTags(trackFile, true); + _audioTagService.WriteTags(bookFile, true); } else { - var source = trackFile.Path; + var source = bookFile.Path; - moveFileResult.TrackFile = CalibreAddAndConvert(trackFile, settings); + moveFileResult.BookFile = CalibreAddAndConvert(bookFile, settings); if (!copyOnly) { diff --git a/src/NzbDrone.Core/MetadataSource/IProvideAuthorInfo.cs b/src/NzbDrone.Core/MetadataSource/IProvideAuthorInfo.cs index 7a1c6dd2b..dfab0f1b5 100644 --- a/src/NzbDrone.Core/MetadataSource/IProvideAuthorInfo.cs +++ b/src/NzbDrone.Core/MetadataSource/IProvideAuthorInfo.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; namespace NzbDrone.Core.MetadataSource { diff --git a/src/NzbDrone.Core/MetadataSource/IProvideAlbumInfo.cs b/src/NzbDrone.Core/MetadataSource/IProvideBookInfo.cs similarity index 70% rename from src/NzbDrone.Core/MetadataSource/IProvideAlbumInfo.cs rename to src/NzbDrone.Core/MetadataSource/IProvideBookInfo.cs index ee7b72972..b1efebe32 100644 --- a/src/NzbDrone.Core/MetadataSource/IProvideAlbumInfo.cs +++ b/src/NzbDrone.Core/MetadataSource/IProvideBookInfo.cs @@ -1,12 +1,12 @@ using System; using System.Collections.Generic; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; namespace NzbDrone.Core.MetadataSource { public interface IProvideBookInfo { Tuple<string, Book, List<AuthorMetadata>> GetBookInfo(string id); - HashSet<string> GetChangedAlbums(DateTime startTime); + HashSet<string> GetChangedBooks(DateTime startTime); } } diff --git a/src/NzbDrone.Core/MetadataSource/ISearchForNewArtist.cs b/src/NzbDrone.Core/MetadataSource/ISearchForNewAuthor.cs similarity index 87% rename from src/NzbDrone.Core/MetadataSource/ISearchForNewArtist.cs rename to src/NzbDrone.Core/MetadataSource/ISearchForNewAuthor.cs index 3bdf52728..7986c2e95 100644 --- a/src/NzbDrone.Core/MetadataSource/ISearchForNewArtist.cs +++ b/src/NzbDrone.Core/MetadataSource/ISearchForNewAuthor.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; namespace NzbDrone.Core.MetadataSource { diff --git a/src/NzbDrone.Core/MetadataSource/ISearchForNewAlbum.cs b/src/NzbDrone.Core/MetadataSource/ISearchForNewBook.cs similarity index 79% rename from src/NzbDrone.Core/MetadataSource/ISearchForNewAlbum.cs rename to src/NzbDrone.Core/MetadataSource/ISearchForNewBook.cs index 455650d41..701d95207 100644 --- a/src/NzbDrone.Core/MetadataSource/ISearchForNewAlbum.cs +++ b/src/NzbDrone.Core/MetadataSource/ISearchForNewBook.cs @@ -1,11 +1,11 @@ using System.Collections.Generic; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; namespace NzbDrone.Core.MetadataSource { public interface ISearchForNewBook { - List<Book> SearchForNewBook(string title, string artist); + List<Book> SearchForNewBook(string title, string author); List<Book> SearchByIsbn(string isbn); List<Book> SearchByAsin(string asin); List<Book> SearchByGoodreadsId(int goodreadsId); diff --git a/src/NzbDrone.Core/MetadataSource/SearchArtistComparer.cs b/src/NzbDrone.Core/MetadataSource/SearchAuthorComparer.cs similarity index 95% rename from src/NzbDrone.Core/MetadataSource/SearchArtistComparer.cs rename to src/NzbDrone.Core/MetadataSource/SearchAuthorComparer.cs index 8c7978029..8f19602db 100644 --- a/src/NzbDrone.Core/MetadataSource/SearchArtistComparer.cs +++ b/src/NzbDrone.Core/MetadataSource/SearchAuthorComparer.cs @@ -2,11 +2,11 @@ using System; using System.Collections.Generic; using System.Text.RegularExpressions; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; namespace NzbDrone.Core.MetadataSource { - public class SearchArtistComparer : IComparer<Author> + public class SearchAuthorComparer : IComparer<Author> { private static readonly Regex RegexCleanPunctuation = new Regex("[-._:]", RegexOptions.Compiled); private static readonly Regex RegexCleanCountryYearPostfix = new Regex(@"(?<=.+)( \([A-Z]{2}\)| \(\d{4}\)| \([A-Z]{2}\) \(\d{4}\))$", RegexOptions.Compiled); @@ -17,7 +17,7 @@ namespace NzbDrone.Core.MetadataSource private readonly string _searchQueryWithoutYear; private int? _year; - public SearchArtistComparer(string searchQuery) + public SearchAuthorComparer(string searchQuery) { SearchQuery = searchQuery; diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index 36c6ebb2c..23b8690c2 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -6,9 +6,9 @@ using NLog; using NzbDrone.Common.Cache; using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; +using NzbDrone.Core.Books; using NzbDrone.Core.Exceptions; using NzbDrone.Core.MediaCover; -using NzbDrone.Core.Music; namespace NzbDrone.Core.MetadataSource.SkyHook { @@ -16,22 +16,22 @@ namespace NzbDrone.Core.MetadataSource.SkyHook { private readonly IHttpClient _httpClient; private readonly Logger _logger; - private readonly IArtistService _authorService; - private readonly IAlbumService _bookService; + private readonly IAuthorService _authorService; + private readonly IBookService _bookService; private readonly IMetadataRequestBuilder _requestBuilder; private readonly ICached<HashSet<string>> _cache; public SkyHookProxy(IHttpClient httpClient, IMetadataRequestBuilder requestBuilder, - IArtistService authorService, - IAlbumService albumService, + IAuthorService authorService, + IBookService bookService, Logger logger, ICacheManager cacheManager) { _httpClient = httpClient; _requestBuilder = requestBuilder; _authorService = authorService; - _bookService = albumService; + _bookService = bookService; _cache = cacheManager.GetCache<HashSet<string>>(GetType()); _logger = logger; } @@ -58,7 +58,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook { if (httpResponse.StatusCode == HttpStatusCode.NotFound) { - throw new ArtistNotFoundException(foreignAuthorId); + throw new AuthorNotFoundException(foreignAuthorId); } else if (httpResponse.StatusCode == HttpStatusCode.BadRequest) { @@ -73,7 +73,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook return MapAuthor(httpResponse.Resource); } - public HashSet<string> GetChangedAlbums(DateTime startTime) + public HashSet<string> GetChangedBooks(DateTime startTime) { return _cache.Get("ChangedAlbums", () => GetChangedAlbumsUncached(startTime), TimeSpan.FromMinutes(30)); } @@ -100,7 +100,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook { if (httpResponse.StatusCode == HttpStatusCode.NotFound) { - throw new AlbumNotFoundException(foreignBookId); + throw new BookNotFoundException(foreignBookId); } else if (httpResponse.StatusCode == HttpStatusCode.BadRequest) { @@ -129,7 +129,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook return books.Select(x => x.Author.Value).ToList(); } - public List<Book> SearchForNewBook(string title, string artist) + public List<Book> SearchForNewBook(string title, string author) { try { @@ -168,9 +168,9 @@ namespace NzbDrone.Core.MetadataSource.SkyHook } var q = title.ToLower().Trim(); - if (artist != null) + if (author != null) { - q += " " + artist; + q += " " + author; } var httpRequest = _requestBuilder.GetRequestBuilder().Create() @@ -276,7 +276,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook var result = new Author { Metadata = metadata, - CleanName = Parser.Parser.CleanArtistName(metadata.Name), + CleanName = Parser.Parser.CleanAuthorName(metadata.Name), SortName = Parser.Parser.NormalizeTitle(metadata.Name), Books = books, Series = series @@ -380,7 +380,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook Title = resource.Title.CleanSpaces(), Language = resource.Language, Publisher = resource.Publisher, - CleanTitle = Parser.Parser.CleanArtistName(resource.Title), + CleanTitle = Parser.Parser.CleanAuthorName(resource.Title), Overview = resource.Description, ReleaseDate = resource.ReleaseDate, Ratings = new Ratings { Votes = resource.RatingCount, Value = (decimal)resource.AverageRating } @@ -428,7 +428,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook author = new Author { - CleanName = Parser.Parser.CleanArtistName(authorMetadata.Name), + CleanName = Parser.Parser.CleanAuthorName(authorMetadata.Name), Metadata = authorMetadata }; } diff --git a/src/NzbDrone.Core/Notifications/AlbumDownloadMessage.cs b/src/NzbDrone.Core/Notifications/BookDownloadMessage.cs similarity index 66% rename from src/NzbDrone.Core/Notifications/AlbumDownloadMessage.cs rename to src/NzbDrone.Core/Notifications/BookDownloadMessage.cs index 6dbad8ccf..a3c036bf2 100644 --- a/src/NzbDrone.Core/Notifications/AlbumDownloadMessage.cs +++ b/src/NzbDrone.Core/Notifications/BookDownloadMessage.cs @@ -1,15 +1,15 @@ using System.Collections.Generic; +using NzbDrone.Core.Books; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; namespace NzbDrone.Core.Notifications { - public class AlbumDownloadMessage + public class BookDownloadMessage { public string Message { get; set; } - public Author Artist { get; set; } - public Book Album { get; set; } - public List<BookFile> TrackFiles { get; set; } + public Author Author { get; set; } + public Book Book { get; set; } + public List<BookFile> BookFiles { get; set; } public List<BookFile> OldFiles { get; set; } public string DownloadClient { get; set; } public string DownloadId { get; set; } diff --git a/src/NzbDrone.Core/Notifications/TrackRetagMessage.cs b/src/NzbDrone.Core/Notifications/BookRetagMessage.cs similarity index 66% rename from src/NzbDrone.Core/Notifications/TrackRetagMessage.cs rename to src/NzbDrone.Core/Notifications/BookRetagMessage.cs index 5292cd644..aff79f9a9 100644 --- a/src/NzbDrone.Core/Notifications/TrackRetagMessage.cs +++ b/src/NzbDrone.Core/Notifications/BookRetagMessage.cs @@ -1,16 +1,16 @@ using System; using System.Collections.Generic; +using NzbDrone.Core.Books; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; namespace NzbDrone.Core.Notifications { - public class TrackRetagMessage + public class BookRetagMessage { public string Message { get; set; } - public Author Artist { get; set; } - public Book Album { get; set; } - public BookFile TrackFile { get; set; } + public Author Author { get; set; } + public Book Book { get; set; } + public BookFile BookFile { get; set; } public Dictionary<string, Tuple<string, string>> Diff { get; set; } public bool Scrubbed { get; set; } diff --git a/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs b/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs index 2afbff1ed..178170b41 100644 --- a/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs +++ b/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs @@ -21,7 +21,7 @@ namespace NzbDrone.Core.Notifications.Boxcar _proxy.SendNotification(BOOK_GRABBED_TITLE, grabMessage.Message, Settings); } - public override void OnReleaseImport(AlbumDownloadMessage message) + public override void OnReleaseImport(BookDownloadMessage message) { _proxy.SendNotification(BOOK_DOWNLOADED_TITLE, message.Message, Settings); } @@ -36,7 +36,7 @@ namespace NzbDrone.Core.Notifications.Boxcar _proxy.SendNotification(DOWNLOAD_FAILURE_TITLE, message.Message, Settings); } - public override void OnImportFailure(AlbumDownloadMessage message) + public override void OnImportFailure(BookDownloadMessage message) { _proxy.SendNotification(IMPORT_FAILURE_TITLE, message.Message, Settings); } diff --git a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs index 2b0819566..5d35a620b 100644 --- a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs +++ b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs @@ -7,7 +7,7 @@ using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.Processes; using NzbDrone.Common.Serializer; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.Validation; @@ -34,24 +34,24 @@ namespace NzbDrone.Core.Notifications.CustomScript public override void OnGrab(GrabMessage message) { - var artist = message.Artist; - var remoteAlbum = message.Album; - var releaseGroup = remoteAlbum.ParsedAlbumInfo.ReleaseGroup; + var author = message.Author; + var remoteBook = message.Book; + var releaseGroup = remoteBook.ParsedBookInfo.ReleaseGroup; var environmentVariables = new StringDictionary(); environmentVariables.Add("Readarr_EventType", "Grab"); - environmentVariables.Add("Readarr_Artist_Id", artist.Id.ToString()); - environmentVariables.Add("Readarr_Artist_Name", artist.Metadata.Value.Name); - environmentVariables.Add("Readarr_Artist_MBId", artist.Metadata.Value.ForeignAuthorId); - environmentVariables.Add("Readarr_Artist_Type", artist.Metadata.Value.Type); - environmentVariables.Add("Readarr_Release_AlbumCount", remoteAlbum.Albums.Count.ToString()); - environmentVariables.Add("Readarr_Release_AlbumReleaseDates", string.Join(",", remoteAlbum.Albums.Select(e => e.ReleaseDate))); - environmentVariables.Add("Readarr_Release_AlbumTitles", string.Join("|", remoteAlbum.Albums.Select(e => e.Title))); - environmentVariables.Add("Readarr_Release_Title", remoteAlbum.Release.Title); - environmentVariables.Add("Readarr_Release_Indexer", remoteAlbum.Release.Indexer ?? string.Empty); - environmentVariables.Add("Readarr_Release_Size", remoteAlbum.Release.Size.ToString()); - environmentVariables.Add("Readarr_Release_Quality", remoteAlbum.ParsedAlbumInfo.Quality.Quality.Name); - environmentVariables.Add("Readarr_Release_QualityVersion", remoteAlbum.ParsedAlbumInfo.Quality.Revision.Version.ToString()); + environmentVariables.Add("Readarr_Author_Id", author.Id.ToString()); + environmentVariables.Add("Readarr_Author_Name", author.Metadata.Value.Name); + environmentVariables.Add("Readarr_Author_MBId", author.Metadata.Value.ForeignAuthorId); + environmentVariables.Add("Readarr_Author_Type", author.Metadata.Value.Type); + environmentVariables.Add("Readarr_Release_BookCount", remoteBook.Books.Count.ToString()); + environmentVariables.Add("Readarr_Release_BookReleaseDates", string.Join(",", remoteBook.Books.Select(e => e.ReleaseDate))); + environmentVariables.Add("Readarr_Release_BookTitles", string.Join("|", remoteBook.Books.Select(e => e.Title))); + environmentVariables.Add("Readarr_Release_Title", remoteBook.Release.Title); + environmentVariables.Add("Readarr_Release_Indexer", remoteBook.Release.Indexer ?? string.Empty); + environmentVariables.Add("Readarr_Release_Size", remoteBook.Release.Size.ToString()); + environmentVariables.Add("Readarr_Release_Quality", remoteBook.ParsedBookInfo.Quality.Quality.Name); + environmentVariables.Add("Readarr_Release_QualityVersion", remoteBook.ParsedBookInfo.Quality.Revision.Version.ToString()); environmentVariables.Add("Readarr_Release_ReleaseGroup", releaseGroup ?? string.Empty); environmentVariables.Add("Readarr_Download_Client", message.DownloadClient ?? string.Empty); environmentVariables.Add("Readarr_Download_Id", message.DownloadId ?? string.Empty); @@ -59,28 +59,28 @@ namespace NzbDrone.Core.Notifications.CustomScript ExecuteScript(environmentVariables); } - public override void OnReleaseImport(AlbumDownloadMessage message) + public override void OnReleaseImport(BookDownloadMessage message) { - var artist = message.Artist; - var album = message.Album; + var author = message.Author; + var book = message.Book; var environmentVariables = new StringDictionary(); - environmentVariables.Add("Readarr_EventType", "AlbumDownload"); - environmentVariables.Add("Readarr_Artist_Id", artist.Id.ToString()); - environmentVariables.Add("Readarr_Artist_Name", artist.Metadata.Value.Name); - environmentVariables.Add("Readarr_Artist_Path", artist.Path); - environmentVariables.Add("Readarr_Artist_MBId", artist.Metadata.Value.ForeignAuthorId); - environmentVariables.Add("Readarr_Artist_Type", artist.Metadata.Value.Type); - environmentVariables.Add("Readarr_Album_Id", album.Id.ToString()); - environmentVariables.Add("Readarr_Album_Title", album.Title); - environmentVariables.Add("Readarr_Album_MBId", album.ForeignBookId); - environmentVariables.Add("Readarr_Album_ReleaseDate", album.ReleaseDate.ToString()); + environmentVariables.Add("Readarr_EventType", "BookDownload"); + environmentVariables.Add("Readarr_Author_Id", author.Id.ToString()); + environmentVariables.Add("Readarr_Author_Name", author.Metadata.Value.Name); + environmentVariables.Add("Readarr_Author_Path", author.Path); + environmentVariables.Add("Readarr_Author_MBId", author.Metadata.Value.ForeignAuthorId); + environmentVariables.Add("Readarr_Author_Type", author.Metadata.Value.Type); + environmentVariables.Add("Readarr_Book_Id", book.Id.ToString()); + environmentVariables.Add("Readarr_Book_Title", book.Title); + environmentVariables.Add("Readarr_Book_MBId", book.ForeignBookId); + environmentVariables.Add("Readarr_Book_ReleaseDate", book.ReleaseDate.ToString()); environmentVariables.Add("Readarr_Download_Client", message.DownloadClient ?? string.Empty); environmentVariables.Add("Readarr_Download_Id", message.DownloadId ?? string.Empty); - if (message.TrackFiles.Any()) + if (message.BookFiles.Any()) { - environmentVariables.Add("Readarr_AddedTrackPaths", string.Join("|", message.TrackFiles.Select(e => e.Path))); + environmentVariables.Add("Readarr_AddedTrackPaths", string.Join("|", message.BookFiles.Select(e => e.Path))); } if (message.OldFiles.Any()) @@ -91,43 +91,43 @@ namespace NzbDrone.Core.Notifications.CustomScript ExecuteScript(environmentVariables); } - public override void OnRename(Author artist) + public override void OnRename(Author author) { var environmentVariables = new StringDictionary(); environmentVariables.Add("Readarr_EventType", "Rename"); - environmentVariables.Add("Readarr_Artist_Id", artist.Id.ToString()); - environmentVariables.Add("Readarr_Artist_Name", artist.Metadata.Value.Name); - environmentVariables.Add("Readarr_Artist_Path", artist.Path); - environmentVariables.Add("Readarr_Artist_MBId", artist.Metadata.Value.ForeignAuthorId); - environmentVariables.Add("Readarr_Artist_Type", artist.Metadata.Value.Type); + environmentVariables.Add("Readarr_Author_Id", author.Id.ToString()); + environmentVariables.Add("Readarr_Author_Name", author.Metadata.Value.Name); + environmentVariables.Add("Readarr_Author_Path", author.Path); + environmentVariables.Add("Readarr_Author_MBId", author.Metadata.Value.ForeignAuthorId); + environmentVariables.Add("Readarr_Author_Type", author.Metadata.Value.Type); ExecuteScript(environmentVariables); } - public override void OnTrackRetag(TrackRetagMessage message) + public override void OnTrackRetag(BookRetagMessage message) { - var artist = message.Artist; - var album = message.Album; - var trackFile = message.TrackFile; + var author = message.Author; + var book = message.Book; + var bookFile = message.BookFile; var environmentVariables = new StringDictionary(); environmentVariables.Add("Readarr_EventType", "TrackRetag"); - environmentVariables.Add("Readarr_Artist_Id", artist.Id.ToString()); - environmentVariables.Add("Readarr_Artist_Name", artist.Metadata.Value.Name); - environmentVariables.Add("Readarr_Artist_Path", artist.Path); - environmentVariables.Add("Readarr_Artist_MBId", artist.Metadata.Value.ForeignAuthorId); - environmentVariables.Add("Readarr_Artist_Type", artist.Metadata.Value.Type); - environmentVariables.Add("Readarr_Album_Id", album.Id.ToString()); - environmentVariables.Add("Readarr_Album_Title", album.Title); - environmentVariables.Add("Readarr_Album_MBId", album.ForeignBookId); - environmentVariables.Add("Readarr_Album_ReleaseDate", album.ReleaseDate.ToString()); - environmentVariables.Add("Readarr_TrackFile_Id", trackFile.Id.ToString()); - environmentVariables.Add("Readarr_TrackFile_Path", trackFile.Path); - environmentVariables.Add("Readarr_TrackFile_Quality", trackFile.Quality.Quality.Name); - environmentVariables.Add("Readarr_TrackFile_QualityVersion", trackFile.Quality.Revision.Version.ToString()); - environmentVariables.Add("Readarr_TrackFile_ReleaseGroup", trackFile.ReleaseGroup ?? string.Empty); - environmentVariables.Add("Readarr_TrackFile_SceneName", trackFile.SceneName ?? string.Empty); + environmentVariables.Add("Readarr_Author_Id", author.Id.ToString()); + environmentVariables.Add("Readarr_Author_Name", author.Metadata.Value.Name); + environmentVariables.Add("Readarr_Author_Path", author.Path); + environmentVariables.Add("Readarr_Author_MBId", author.Metadata.Value.ForeignAuthorId); + environmentVariables.Add("Readarr_Author_Type", author.Metadata.Value.Type); + environmentVariables.Add("Readarr_Book_Id", book.Id.ToString()); + environmentVariables.Add("Readarr_Book_Title", book.Title); + environmentVariables.Add("Readarr_Book_MBId", book.ForeignBookId); + environmentVariables.Add("Readarr_Book_ReleaseDate", book.ReleaseDate.ToString()); + environmentVariables.Add("Readarr_BookFile_Id", bookFile.Id.ToString()); + environmentVariables.Add("Readarr_BookFile_Path", bookFile.Path); + environmentVariables.Add("Readarr_BookFile_Quality", bookFile.Quality.Quality.Name); + environmentVariables.Add("Readarr_BookFile_QualityVersion", bookFile.Quality.Revision.Version.ToString()); + environmentVariables.Add("Readarr_BookFile_ReleaseGroup", bookFile.ReleaseGroup ?? string.Empty); + environmentVariables.Add("Readarr_BookFile_SceneName", bookFile.SceneName ?? string.Empty); environmentVariables.Add("Readarr_Tags_Diff", message.Diff.ToJson()); environmentVariables.Add("Readarr_Tags_Scrubbed", message.Scrubbed.ToString()); diff --git a/src/NzbDrone.Core/Notifications/Discord/Discord.cs b/src/NzbDrone.Core/Notifications/Discord/Discord.cs index 9b44f9e9d..4a8a72a04 100644 --- a/src/NzbDrone.Core/Notifications/Discord/Discord.cs +++ b/src/NzbDrone.Core/Notifications/Discord/Discord.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Notifications.Discord.Payloads; using NzbDrone.Core.Validation; @@ -27,7 +27,7 @@ namespace NzbDrone.Core.Notifications.Discord new Embed { Description = message.Message, - Title = message.Artist.Name, + Title = message.Author.Name, Text = message.Message, Color = (int)DiscordColors.Warning } @@ -37,14 +37,14 @@ namespace NzbDrone.Core.Notifications.Discord _proxy.SendPayload(payload, Settings); } - public override void OnReleaseImport(AlbumDownloadMessage message) + public override void OnReleaseImport(BookDownloadMessage message) { var attachments = new List<Embed> { new Embed { Description = message.Message, - Title = message.Artist.Name, + Title = message.Author.Name, Text = message.Message, Color = (int)DiscordColors.Success } @@ -54,13 +54,13 @@ namespace NzbDrone.Core.Notifications.Discord _proxy.SendPayload(payload, Settings); } - public override void OnRename(Author artist) + public override void OnRename(Author author) { var attachments = new List<Embed> { new Embed { - Title = artist.Name, + Title = author.Name, } }; @@ -86,7 +86,7 @@ namespace NzbDrone.Core.Notifications.Discord _proxy.SendPayload(payload, Settings); } - public override void OnTrackRetag(TrackRetagMessage message) + public override void OnTrackRetag(BookRetagMessage message) { var attachments = new List<Embed> { @@ -119,14 +119,14 @@ namespace NzbDrone.Core.Notifications.Discord _proxy.SendPayload(payload, Settings); } - public override void OnImportFailure(AlbumDownloadMessage message) + public override void OnImportFailure(BookDownloadMessage message) { var attachments = new List<Embed> { new Embed { Description = message.Message, - Title = message.Album.Title, + Title = message.Book.Title, Text = message.Message, Color = (int)DiscordColors.Warning } diff --git a/src/NzbDrone.Core/Notifications/Email/Email.cs b/src/NzbDrone.Core/Notifications/Email/Email.cs index 12b1117a3..96acc0779 100644 --- a/src/NzbDrone.Core/Notifications/Email/Email.cs +++ b/src/NzbDrone.Core/Notifications/Email/Email.cs @@ -24,11 +24,11 @@ namespace NzbDrone.Core.Notifications.Email _emailService.SendEmail(Settings, BOOK_GRABBED_TITLE_BRANDED, body); } - public override void OnReleaseImport(AlbumDownloadMessage message) + public override void OnReleaseImport(BookDownloadMessage message) { var body = $"{message.Message} Downloaded and sorted."; - var paths = Settings.AttachFiles ? message.TrackFiles.SelectList(a => a.Path) : null; + var paths = Settings.AttachFiles ? message.BookFiles.SelectList(a => a.Path) : null; _emailService.SendEmail(Settings, BOOK_DOWNLOADED_TITLE_BRANDED, body, false, paths); } @@ -43,7 +43,7 @@ namespace NzbDrone.Core.Notifications.Email _emailService.SendEmail(Settings, DOWNLOAD_FAILURE_TITLE_BRANDED, message.Message); } - public override void OnImportFailure(AlbumDownloadMessage message) + public override void OnImportFailure(BookDownloadMessage message) { _emailService.SendEmail(Settings, IMPORT_FAILURE_TITLE_BRANDED, message.Message); } diff --git a/src/NzbDrone.Core/Notifications/Gotify/Gotify.cs b/src/NzbDrone.Core/Notifications/Gotify/Gotify.cs index 0270b139b..f5174cb04 100644 --- a/src/NzbDrone.Core/Notifications/Gotify/Gotify.cs +++ b/src/NzbDrone.Core/Notifications/Gotify/Gotify.cs @@ -24,7 +24,7 @@ namespace NzbDrone.Core.Notifications.Gotify _proxy.SendNotification(BOOK_GRABBED_TITLE, grabMessage.Message, Settings); } - public override void OnReleaseImport(AlbumDownloadMessage message) + public override void OnReleaseImport(BookDownloadMessage message) { _proxy.SendNotification(BOOK_DOWNLOADED_TITLE, message.Message, Settings); } @@ -39,7 +39,7 @@ namespace NzbDrone.Core.Notifications.Gotify _proxy.SendNotification(DOWNLOAD_FAILURE_TITLE, message.Message, Settings); } - public override void OnImportFailure(AlbumDownloadMessage message) + public override void OnImportFailure(BookDownloadMessage message) { _proxy.SendNotification(IMPORT_FAILURE_TITLE, message.Message, Settings); } diff --git a/src/NzbDrone.Core/Notifications/GrabMessage.cs b/src/NzbDrone.Core/Notifications/GrabMessage.cs index 864f8d063..16f738b90 100644 --- a/src/NzbDrone.Core/Notifications/GrabMessage.cs +++ b/src/NzbDrone.Core/Notifications/GrabMessage.cs @@ -1,4 +1,4 @@ -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; @@ -7,8 +7,8 @@ namespace NzbDrone.Core.Notifications public class GrabMessage { public string Message { get; set; } - public Author Artist { get; set; } - public RemoteAlbum Album { get; set; } + public Author Author { get; set; } + public RemoteBook Book { get; set; } public QualityModel Quality { get; set; } public string DownloadClient { get; set; } public string DownloadId { get; set; } diff --git a/src/NzbDrone.Core/Notifications/INotification.cs b/src/NzbDrone.Core/Notifications/INotification.cs index 770eaaf0c..480db3c0a 100644 --- a/src/NzbDrone.Core/Notifications/INotification.cs +++ b/src/NzbDrone.Core/Notifications/INotification.cs @@ -1,4 +1,4 @@ -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.ThingiProvider; namespace NzbDrone.Core.Notifications @@ -8,12 +8,12 @@ namespace NzbDrone.Core.Notifications string Link { get; } void OnGrab(GrabMessage grabMessage); - void OnReleaseImport(AlbumDownloadMessage message); - void OnRename(Author artist); + void OnReleaseImport(BookDownloadMessage message); + void OnRename(Author author); void OnHealthIssue(HealthCheck.HealthCheck healthCheck); void OnDownloadFailure(DownloadFailedMessage message); - void OnImportFailure(AlbumDownloadMessage message); - void OnTrackRetag(TrackRetagMessage message); + void OnImportFailure(BookDownloadMessage message); + void OnTrackRetag(BookRetagMessage message); bool SupportsOnGrab { get; } bool SupportsOnReleaseImport { get; } bool SupportsOnUpgrade { get; } diff --git a/src/NzbDrone.Core/Notifications/Join/Join.cs b/src/NzbDrone.Core/Notifications/Join/Join.cs index 0d1c657dd..6a8ffb641 100644 --- a/src/NzbDrone.Core/Notifications/Join/Join.cs +++ b/src/NzbDrone.Core/Notifications/Join/Join.cs @@ -22,7 +22,7 @@ namespace NzbDrone.Core.Notifications.Join _proxy.SendNotification(BOOK_GRABBED_TITLE_BRANDED, message.Message, Settings); } - public override void OnReleaseImport(AlbumDownloadMessage message) + public override void OnReleaseImport(BookDownloadMessage message) { _proxy.SendNotification(BOOK_DOWNLOADED_TITLE_BRANDED, message.Message, Settings); } diff --git a/src/NzbDrone.Core/Notifications/NotificationBase.cs b/src/NzbDrone.Core/Notifications/NotificationBase.cs index 060dcfad6..d888d291e 100644 --- a/src/NzbDrone.Core/Notifications/NotificationBase.cs +++ b/src/NzbDrone.Core/Notifications/NotificationBase.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using FluentValidation.Results; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.ThingiProvider; namespace NzbDrone.Core.Notifications @@ -40,11 +40,11 @@ namespace NzbDrone.Core.Notifications { } - public virtual void OnReleaseImport(AlbumDownloadMessage message) + public virtual void OnReleaseImport(BookDownloadMessage message) { } - public virtual void OnRename(Author artist) + public virtual void OnRename(Author author) { } @@ -56,11 +56,11 @@ namespace NzbDrone.Core.Notifications { } - public virtual void OnImportFailure(AlbumDownloadMessage message) + public virtual void OnImportFailure(BookDownloadMessage message) { } - public virtual void OnTrackRetag(TrackRetagMessage message) + public virtual void OnTrackRetag(BookRetagMessage message) { } diff --git a/src/NzbDrone.Core/Notifications/NotificationService.cs b/src/NzbDrone.Core/Notifications/NotificationService.cs index 6f486cbe1..06326c357 100644 --- a/src/NzbDrone.Core/Notifications/NotificationService.cs +++ b/src/NzbDrone.Core/Notifications/NotificationService.cs @@ -3,25 +3,25 @@ using System.Collections.Generic; using System.Linq; using NLog; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.Download; using NzbDrone.Core.HealthCheck; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; using NzbDrone.Core.Qualities; using NzbDrone.Core.ThingiProvider; namespace NzbDrone.Core.Notifications { public class NotificationService - : IHandle<AlbumGrabbedEvent>, - IHandle<AlbumImportedEvent>, - IHandle<ArtistRenamedEvent>, + : IHandle<BookGrabbedEvent>, + IHandle<BookImportedEvent>, + IHandle<AuthorRenamedEvent>, IHandle<HealthCheckFailedEvent>, IHandle<DownloadFailedEvent>, - IHandle<AlbumImportIncompleteEvent>, - IHandle<TrackFileRetaggedEvent> + IHandle<BookImportIncompleteEvent>, + IHandle<BookFileRetaggedEvent> { private readonly INotificationFactory _notificationFactory; private readonly Logger _logger; @@ -32,7 +32,7 @@ namespace NzbDrone.Core.Notifications _logger = logger; } - private string GetMessage(Author artist, List<Book> albums, QualityModel quality) + private string GetMessage(Author author, List<Book> albums, QualityModel quality) { var qualityString = quality.Quality.ToString(); @@ -44,15 +44,15 @@ namespace NzbDrone.Core.Notifications var albumTitles = string.Join(" + ", albums.Select(e => e.Title)); return string.Format("{0} - {1} - [{2}]", - artist.Name, + author.Name, albumTitles, qualityString); } - private string GetAlbumDownloadMessage(Author artist, Book album, List<BookFile> tracks) + private string GetAlbumDownloadMessage(Author author, Book album, List<BookFile> tracks) { return string.Format("{0} - {1} ({2} Tracks Imported)", - artist.Name, + author.Name, album.Title, tracks.Count); } @@ -69,14 +69,14 @@ namespace NzbDrone.Core.Notifications return text.IsNullOrWhiteSpace() ? "<missing>" : text; } - private string GetTrackRetagMessage(Author artist, BookFile trackFile, Dictionary<string, Tuple<string, string>> diff) + private string GetTrackRetagMessage(Author author, BookFile bookFile, Dictionary<string, Tuple<string, string>> diff) { return string.Format("{0}:\n{1}", - trackFile.Path, + bookFile.Path, string.Join("\n", diff.Select(x => $"{x.Key}: {FormatMissing(x.Value.Item1)} → {FormatMissing(x.Value.Item2)}"))); } - private bool ShouldHandleArtist(ProviderDefinition definition, Author artist) + private bool ShouldHandleArtist(ProviderDefinition definition, Author author) { if (definition.Tags.Empty()) { @@ -84,14 +84,14 @@ namespace NzbDrone.Core.Notifications return true; } - if (definition.Tags.Intersect(artist.Tags).Any()) + if (definition.Tags.Intersect(author.Tags).Any()) { - _logger.Debug("Notification and artist have one or more intersecting tags."); + _logger.Debug("Notification and author have one or more intersecting tags."); return true; } //TODO: this message could be more clear - _logger.Debug("{0} does not have any intersecting tags with {1}. Notification will not be sent.", definition.Name, artist.Name); + _logger.Debug("{0} does not have any intersecting tags with {1}. Notification will not be sent.", definition.Name, author.Name); return false; } @@ -110,14 +110,14 @@ namespace NzbDrone.Core.Notifications return false; } - public void Handle(AlbumGrabbedEvent message) + public void Handle(BookGrabbedEvent message) { var grabMessage = new GrabMessage { - Message = GetMessage(message.Album.Artist, message.Album.Albums, message.Album.ParsedAlbumInfo.Quality), - Artist = message.Album.Artist, - Quality = message.Album.ParsedAlbumInfo.Quality, - Album = message.Album, + Message = GetMessage(message.Book.Author, message.Book.Books, message.Book.ParsedBookInfo.Quality), + Author = message.Book.Author, + Quality = message.Book.ParsedBookInfo.Quality, + Book = message.Book, DownloadClient = message.DownloadClient, DownloadId = message.DownloadId }; @@ -126,7 +126,7 @@ namespace NzbDrone.Core.Notifications { try { - if (!ShouldHandleArtist(notification.Definition, message.Album.Artist)) + if (!ShouldHandleArtist(notification.Definition, message.Book.Author)) { continue; } @@ -140,21 +140,21 @@ namespace NzbDrone.Core.Notifications } } - public void Handle(AlbumImportedEvent message) + public void Handle(BookImportedEvent message) { if (!message.NewDownload) { return; } - var downloadMessage = new AlbumDownloadMessage + var downloadMessage = new BookDownloadMessage { - Message = GetAlbumDownloadMessage(message.Artist, message.Album, message.ImportedTracks), - Artist = message.Artist, - Album = message.Album, + Message = GetAlbumDownloadMessage(message.Author, message.Book, message.ImportedBooks), + Author = message.Author, + Book = message.Book, DownloadClient = message.DownloadClient, DownloadId = message.DownloadId, - TrackFiles = message.ImportedTracks, + BookFiles = message.ImportedBooks, OldFiles = message.OldFiles, }; @@ -162,7 +162,7 @@ namespace NzbDrone.Core.Notifications { try { - if (ShouldHandleArtist(notification.Definition, message.Artist)) + if (ShouldHandleArtist(notification.Definition, message.Author)) { if (downloadMessage.OldFiles.Empty() || ((NotificationDefinition)notification.Definition).OnUpgrade) { @@ -177,15 +177,15 @@ namespace NzbDrone.Core.Notifications } } - public void Handle(ArtistRenamedEvent message) + public void Handle(AuthorRenamedEvent message) { foreach (var notification in _notificationFactory.OnRenameEnabled()) { try { - if (ShouldHandleArtist(notification.Definition, message.Artist)) + if (ShouldHandleArtist(notification.Definition, message.Author)) { - notification.OnRename(message.Artist); + notification.OnRename(message.Author); } } catch (Exception ex) @@ -226,45 +226,45 @@ namespace NzbDrone.Core.Notifications foreach (var notification in _notificationFactory.OnDownloadFailureEnabled()) { - if (ShouldHandleArtist(notification.Definition, message.TrackedDownload.RemoteAlbum.Artist)) + if (ShouldHandleArtist(notification.Definition, message.TrackedDownload.RemoteBook.Author)) { notification.OnDownloadFailure(downloadFailedMessage); } } } - public void Handle(AlbumImportIncompleteEvent message) + public void Handle(BookImportIncompleteEvent message) { // TODO: Build out this message so that we can pass on what failed and what was successful - var downloadMessage = new AlbumDownloadMessage + var downloadMessage = new BookDownloadMessage { Message = GetAlbumIncompleteImportMessage(message.TrackedDownload.DownloadItem.Title), }; foreach (var notification in _notificationFactory.OnImportFailureEnabled()) { - if (ShouldHandleArtist(notification.Definition, message.TrackedDownload.RemoteAlbum.Artist)) + if (ShouldHandleArtist(notification.Definition, message.TrackedDownload.RemoteBook.Author)) { notification.OnImportFailure(downloadMessage); } } } - public void Handle(TrackFileRetaggedEvent message) + public void Handle(BookFileRetaggedEvent message) { - var retagMessage = new TrackRetagMessage + var retagMessage = new BookRetagMessage { - Message = GetTrackRetagMessage(message.Artist, message.TrackFile, message.Diff), - Artist = message.Artist, - Album = message.TrackFile.Album, - TrackFile = message.TrackFile, + Message = GetTrackRetagMessage(message.Author, message.BookFile, message.Diff), + Author = message.Author, + Book = message.BookFile.Book, + BookFile = message.BookFile, Diff = message.Diff, Scrubbed = message.Scrubbed }; foreach (var notification in _notificationFactory.OnTrackRetagEnabled()) { - if (ShouldHandleArtist(notification.Definition, message.Artist)) + if (ShouldHandleArtist(notification.Definition, message.Author)) { notification.OnTrackRetag(retagMessage); } diff --git a/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs b/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs index 788c6b2ff..535cbb0a4 100644 --- a/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs +++ b/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs @@ -24,7 +24,7 @@ namespace NzbDrone.Core.Notifications.PushBullet _proxy.SendNotification(BOOK_GRABBED_TITLE_BRANDED, grabMessage.Message, Settings); } - public override void OnReleaseImport(AlbumDownloadMessage message) + public override void OnReleaseImport(BookDownloadMessage message) { _proxy.SendNotification(BOOK_DOWNLOADED_TITLE_BRANDED, message.Message, Settings); } @@ -39,7 +39,7 @@ namespace NzbDrone.Core.Notifications.PushBullet _proxy.SendNotification(DOWNLOAD_FAILURE_TITLE_BRANDED, message.Message, Settings); } - public override void OnImportFailure(AlbumDownloadMessage message) + public override void OnImportFailure(BookDownloadMessage message) { _proxy.SendNotification(IMPORT_FAILURE_TITLE_BRANDED, message.Message, Settings); } diff --git a/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs b/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs index 5e99526f6..001d7d616 100644 --- a/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs +++ b/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs @@ -21,7 +21,7 @@ namespace NzbDrone.Core.Notifications.Pushover _proxy.SendNotification(BOOK_GRABBED_TITLE, grabMessage.Message, Settings); } - public override void OnReleaseImport(AlbumDownloadMessage message) + public override void OnReleaseImport(BookDownloadMessage message) { _proxy.SendNotification(BOOK_DOWNLOADED_TITLE, message.Message, Settings); } @@ -36,7 +36,7 @@ namespace NzbDrone.Core.Notifications.Pushover _proxy.SendNotification(DOWNLOAD_FAILURE_TITLE, message.Message, Settings); } - public override void OnImportFailure(AlbumDownloadMessage message) + public override void OnImportFailure(BookDownloadMessage message) { _proxy.SendNotification(IMPORT_FAILURE_TITLE, message.Message, Settings); } diff --git a/src/NzbDrone.Core/Notifications/Slack/Slack.cs b/src/NzbDrone.Core/Notifications/Slack/Slack.cs index e55f306ec..c8d7ee3ca 100644 --- a/src/NzbDrone.Core/Notifications/Slack/Slack.cs +++ b/src/NzbDrone.Core/Notifications/Slack/Slack.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Notifications.Slack.Payloads; using NzbDrone.Core.Validation; @@ -27,7 +27,7 @@ namespace NzbDrone.Core.Notifications.Slack new Attachment { Fallback = message.Message, - Title = message.Artist.Name, + Title = message.Author.Name, Text = message.Message, Color = "warning" } @@ -37,14 +37,14 @@ namespace NzbDrone.Core.Notifications.Slack _proxy.SendPayload(payload, Settings); } - public override void OnReleaseImport(AlbumDownloadMessage message) + public override void OnReleaseImport(BookDownloadMessage message) { var attachments = new List<Attachment> { new Attachment { Fallback = message.Message, - Title = message.Artist.Name, + Title = message.Author.Name, Text = message.Message, Color = "good" } @@ -54,13 +54,13 @@ namespace NzbDrone.Core.Notifications.Slack _proxy.SendPayload(payload, Settings); } - public override void OnRename(Author artist) + public override void OnRename(Author author) { var attachments = new List<Attachment> { new Attachment { - Title = artist.Name, + Title = author.Name, } }; @@ -86,7 +86,7 @@ namespace NzbDrone.Core.Notifications.Slack _proxy.SendPayload(payload, Settings); } - public override void OnTrackRetag(TrackRetagMessage message) + public override void OnTrackRetag(BookRetagMessage message) { var attachments = new List<Attachment> { @@ -119,7 +119,7 @@ namespace NzbDrone.Core.Notifications.Slack _proxy.SendPayload(payload, Settings); } - public override void OnImportFailure(AlbumDownloadMessage message) + public override void OnImportFailure(BookDownloadMessage message) { var attachments = new List<Attachment> { diff --git a/src/NzbDrone.Core/Notifications/Subsonic/Subsonic.cs b/src/NzbDrone.Core/Notifications/Subsonic/Subsonic.cs index 50f29b131..fbfabef2c 100644 --- a/src/NzbDrone.Core/Notifications/Subsonic/Subsonic.cs +++ b/src/NzbDrone.Core/Notifications/Subsonic/Subsonic.cs @@ -3,7 +3,7 @@ using System.Net.Sockets; using FluentValidation.Results; using NLog; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; namespace NzbDrone.Core.Notifications.Subsonic { @@ -27,7 +27,7 @@ namespace NzbDrone.Core.Notifications.Subsonic Notify(Settings, header, grabMessage.Message); } - public override void OnReleaseImport(AlbumDownloadMessage message) + public override void OnReleaseImport(BookDownloadMessage message) { const string header = "Readarr - Downloaded"; @@ -35,7 +35,7 @@ namespace NzbDrone.Core.Notifications.Subsonic Update(); } - public override void OnRename(Author artist) + public override void OnRename(Author author) { Update(); } @@ -45,7 +45,7 @@ namespace NzbDrone.Core.Notifications.Subsonic Notify(Settings, HEALTH_ISSUE_TITLE_BRANDED, healthCheck.Message); } - public override void OnTrackRetag(TrackRetagMessage message) + public override void OnTrackRetag(BookRetagMessage message) { Notify(Settings, BOOK_RETAGGED_TITLE_BRANDED, message.Message); } diff --git a/src/NzbDrone.Core/Notifications/Synology/SynologyIndexer.cs b/src/NzbDrone.Core/Notifications/Synology/SynologyIndexer.cs index 1fb649b73..09ebba899 100644 --- a/src/NzbDrone.Core/Notifications/Synology/SynologyIndexer.cs +++ b/src/NzbDrone.Core/Notifications/Synology/SynologyIndexer.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; namespace NzbDrone.Core.Notifications.Synology { @@ -18,7 +18,7 @@ namespace NzbDrone.Core.Notifications.Synology public override string Link => "https://www.synology.com"; public override string Name => "Synology Indexer"; - public override void OnReleaseImport(AlbumDownloadMessage message) + public override void OnReleaseImport(BookDownloadMessage message) { if (Settings.UpdateLibrary) { @@ -29,7 +29,7 @@ namespace NzbDrone.Core.Notifications.Synology _indexerProxy.DeleteFile(fullPath); } - foreach (var newFile in message.TrackFiles) + foreach (var newFile in message.BookFiles) { var fullPath = newFile.Path; @@ -38,19 +38,19 @@ namespace NzbDrone.Core.Notifications.Synology } } - public override void OnRename(Author artist) + public override void OnRename(Author author) { if (Settings.UpdateLibrary) { - _indexerProxy.UpdateFolder(artist.Path); + _indexerProxy.UpdateFolder(author.Path); } } - public override void OnTrackRetag(TrackRetagMessage message) + public override void OnTrackRetag(BookRetagMessage message) { if (Settings.UpdateLibrary) { - _indexerProxy.UpdateFolder(message.Artist.Path); + _indexerProxy.UpdateFolder(message.Author.Path); } } diff --git a/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs b/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs index 3417cf8b7..6df08082c 100644 --- a/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs +++ b/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs @@ -21,7 +21,7 @@ namespace NzbDrone.Core.Notifications.Telegram _proxy.SendNotification(BOOK_GRABBED_TITLE, grabMessage.Message, Settings); } - public override void OnReleaseImport(AlbumDownloadMessage message) + public override void OnReleaseImport(BookDownloadMessage message) { _proxy.SendNotification(BOOK_DOWNLOADED_TITLE, message.Message, Settings); } @@ -36,7 +36,7 @@ namespace NzbDrone.Core.Notifications.Telegram _proxy.SendNotification(DOWNLOAD_FAILURE_TITLE, message.Message, Settings); } - public override void OnImportFailure(AlbumDownloadMessage message) + public override void OnImportFailure(BookDownloadMessage message) { _proxy.SendNotification(IMPORT_FAILURE_TITLE, message.Message, Settings); } diff --git a/src/NzbDrone.Core/Notifications/Twitter/Twitter.cs b/src/NzbDrone.Core/Notifications/Twitter/Twitter.cs index 0f6c375aa..3807add3c 100644 --- a/src/NzbDrone.Core/Notifications/Twitter/Twitter.cs +++ b/src/NzbDrone.Core/Notifications/Twitter/Twitter.cs @@ -23,7 +23,7 @@ namespace NzbDrone.Core.Notifications.Twitter _twitterService.SendNotification($"Grabbed: {message.Message}", Settings); } - public override void OnReleaseImport(AlbumDownloadMessage message) + public override void OnReleaseImport(BookDownloadMessage message) { _twitterService.SendNotification($"Imported: {message.Message}", Settings); } @@ -38,7 +38,7 @@ namespace NzbDrone.Core.Notifications.Twitter _twitterService.SendNotification($"Download Failed: {message.Message}", Settings); } - public override void OnImportFailure(AlbumDownloadMessage message) + public override void OnImportFailure(BookDownloadMessage message) { _twitterService.SendNotification($"Import Failed: {message.Message}", Settings); } diff --git a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs index 57992ecd3..ccec4b456 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using FluentValidation.Results; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Validation; namespace NzbDrone.Core.Notifications.Webhook @@ -20,19 +20,19 @@ namespace NzbDrone.Core.Notifications.Webhook public override void OnGrab(GrabMessage message) { - var remoteAlbum = message.Album; + var remoteAlbum = message.Book; var quality = message.Quality; var payload = new WebhookGrabPayload { EventType = "Grab", - Artist = new WebhookArtist(message.Artist), - Albums = remoteAlbum.Albums.ConvertAll(x => new WebhookAlbum(x) + Author = new WebhookAuthor(message.Author), + Books = remoteAlbum.Books.ConvertAll(x => new WebhookBook(x) { // TODO: Stop passing these parameters inside an album v3 Quality = quality.Quality.Name, QualityVersion = quality.Revision.Version, - ReleaseGroup = remoteAlbum.ParsedAlbumInfo.ReleaseGroup + ReleaseGroup = remoteAlbum.ParsedBookInfo.ReleaseGroup }), Release = new WebhookRelease(quality, remoteAlbum) }; @@ -40,39 +40,39 @@ namespace NzbDrone.Core.Notifications.Webhook _proxy.SendWebhook(payload, Settings); } - public override void OnReleaseImport(AlbumDownloadMessage message) + public override void OnReleaseImport(BookDownloadMessage message) { - var trackFiles = message.TrackFiles; + var bookFiles = message.BookFiles; var payload = new WebhookImportPayload { EventType = "Download", - Artist = new WebhookArtist(message.Artist), - Book = new WebhookAlbum(message.Album), - TrackFiles = trackFiles.ConvertAll(x => new WebhookTrackFile(x)), + Author = new WebhookAuthor(message.Author), + Book = new WebhookBook(message.Book), + BookFiles = bookFiles.ConvertAll(x => new WebhookBookFile(x)), IsUpgrade = message.OldFiles.Any() }; _proxy.SendWebhook(payload, Settings); } - public override void OnRename(Author artist) + public override void OnRename(Author author) { var payload = new WebhookPayload { EventType = "Rename", - Artist = new WebhookArtist(artist) + Author = new WebhookAuthor(author) }; _proxy.SendWebhook(payload, Settings); } - public override void OnTrackRetag(TrackRetagMessage message) + public override void OnTrackRetag(BookRetagMessage message) { var payload = new WebhookPayload { EventType = "Retag", - Artist = new WebhookArtist(message.Artist) + Author = new WebhookAuthor(message.Author) }; _proxy.SendWebhook(payload, Settings); @@ -96,16 +96,16 @@ namespace NzbDrone.Core.Notifications.Webhook var payload = new WebhookGrabPayload { EventType = "Test", - Artist = new WebhookArtist() + Author = new WebhookAuthor() { Id = 1, Name = "Test Name", Path = "C:\\testpath", MBId = "aaaaa-aaa-aaaa-aaaaaa" }, - Albums = new List<WebhookAlbum>() + Books = new List<WebhookBook>() { - new WebhookAlbum() + new WebhookBook() { Id = 123, Title = "Test title" diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookArtist.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookArtist.cs deleted file mode 100644 index 8dd1899ab..000000000 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookArtist.cs +++ /dev/null @@ -1,24 +0,0 @@ -using NzbDrone.Core.Music; - -namespace NzbDrone.Core.Notifications.Webhook -{ - public class WebhookArtist - { - public int Id { get; set; } - public string Name { get; set; } - public string Path { get; set; } - public string MBId { get; set; } - - public WebhookArtist() - { - } - - public WebhookArtist(Author artist) - { - Id = artist.Id; - Name = artist.Name; - Path = artist.Path; - MBId = artist.Metadata.Value.ForeignAuthorId; - } - } -} diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookAuthor.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookAuthor.cs new file mode 100644 index 000000000..f099f8943 --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookAuthor.cs @@ -0,0 +1,24 @@ +using NzbDrone.Core.Books; + +namespace NzbDrone.Core.Notifications.Webhook +{ + public class WebhookAuthor + { + public int Id { get; set; } + public string Name { get; set; } + public string Path { get; set; } + public string MBId { get; set; } + + public WebhookAuthor() + { + } + + public WebhookAuthor(Author author) + { + Id = author.Id; + Name = author.Name; + Path = author.Path; + MBId = author.Metadata.Value.ForeignAuthorId; + } + } +} diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookAlbum.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookBook.cs similarity index 65% rename from src/NzbDrone.Core/Notifications/Webhook/WebhookAlbum.cs rename to src/NzbDrone.Core/Notifications/Webhook/WebhookBook.cs index b9f13a82c..59302ed7f 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookAlbum.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookBook.cs @@ -1,19 +1,19 @@ using System; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; namespace NzbDrone.Core.Notifications.Webhook { - public class WebhookAlbum + public class WebhookBook { - public WebhookAlbum() + public WebhookBook() { } - public WebhookAlbum(Book album) + public WebhookBook(Book book) { - Id = album.Id; - Title = album.Title; - ReleaseDate = album.ReleaseDate; + Id = book.Id; + Title = book.Title; + ReleaseDate = book.ReleaseDate; } public int Id { get; set; } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookTrackFile.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookBookFile.cs similarity index 50% rename from src/NzbDrone.Core/Notifications/Webhook/WebhookTrackFile.cs rename to src/NzbDrone.Core/Notifications/Webhook/WebhookBookFile.cs index f5ee8d8bc..140f027e7 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookTrackFile.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookBookFile.cs @@ -2,20 +2,20 @@ using NzbDrone.Core.MediaFiles; namespace NzbDrone.Core.Notifications.Webhook { - public class WebhookTrackFile + public class WebhookBookFile { - public WebhookTrackFile() + public WebhookBookFile() { } - public WebhookTrackFile(BookFile trackFile) + public WebhookBookFile(BookFile bookFile) { - Id = trackFile.Id; - Path = trackFile.Path; - Quality = trackFile.Quality.Quality.Name; - QualityVersion = trackFile.Quality.Revision.Version; - ReleaseGroup = trackFile.ReleaseGroup; - SceneName = trackFile.SceneName; + Id = bookFile.Id; + Path = bookFile.Path; + Quality = bookFile.Quality.Quality.Name; + QualityVersion = bookFile.Quality.Revision.Version; + ReleaseGroup = bookFile.ReleaseGroup; + SceneName = bookFile.SceneName; } public int Id { get; set; } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookGrabPayload.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookGrabPayload.cs index 4cb7c868b..60e42a8dc 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookGrabPayload.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookGrabPayload.cs @@ -4,7 +4,7 @@ namespace NzbDrone.Core.Notifications.Webhook { public class WebhookGrabPayload : WebhookPayload { - public List<WebhookAlbum> Albums { get; set; } + public List<WebhookBook> Books { get; set; } public WebhookRelease Release { get; set; } } } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookImportPayload.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookImportPayload.cs index 988f64f78..807e0b1bf 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookImportPayload.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookImportPayload.cs @@ -4,8 +4,8 @@ namespace NzbDrone.Core.Notifications.Webhook { public class WebhookImportPayload : WebhookPayload { - public WebhookAlbum Book { get; set; } - public List<WebhookTrackFile> TrackFiles { get; set; } + public WebhookBook Book { get; set; } + public List<WebhookBookFile> BookFiles { get; set; } public bool IsUpgrade { get; set; } } } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookPayload.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookPayload.cs index 3beff4105..d54d00ea2 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookPayload.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookPayload.cs @@ -3,6 +3,6 @@ namespace NzbDrone.Core.Notifications.Webhook public class WebhookPayload { public string EventType { get; set; } - public WebhookArtist Artist { get; set; } + public WebhookAuthor Author { get; set; } } } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookRelease.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookRelease.cs index a3fa1823e..0d953f1b4 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookRelease.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookRelease.cs @@ -9,11 +9,11 @@ namespace NzbDrone.Core.Notifications.Webhook { } - public WebhookRelease(QualityModel quality, RemoteAlbum remoteAlbum) + public WebhookRelease(QualityModel quality, RemoteBook remoteAlbum) { Quality = quality.Quality.Name; QualityVersion = quality.Revision.Version; - ReleaseGroup = remoteAlbum.ParsedAlbumInfo.ReleaseGroup; + ReleaseGroup = remoteAlbum.ParsedBookInfo.ReleaseGroup; ReleaseTitle = remoteAlbum.Release.Title; Indexer = remoteAlbum.Release.Indexer; Size = remoteAlbum.Release.Size; diff --git a/src/NzbDrone.Core/Organizer/AbsoluteBookFormat.cs b/src/NzbDrone.Core/Organizer/AbsoluteBookFormat.cs new file mode 100644 index 000000000..db6c55b16 --- /dev/null +++ b/src/NzbDrone.Core/Organizer/AbsoluteBookFormat.cs @@ -0,0 +1,8 @@ +namespace NzbDrone.Core.Organizer +{ + public class AbsoluteBookFormat + { + public string Separator { get; set; } + public string AbsoluteBookPattern { get; set; } + } +} diff --git a/src/NzbDrone.Core/Organizer/AbsoluteTrackFormat.cs b/src/NzbDrone.Core/Organizer/AbsoluteTrackFormat.cs deleted file mode 100644 index 77febda7b..000000000 --- a/src/NzbDrone.Core/Organizer/AbsoluteTrackFormat.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace NzbDrone.Core.Organizer -{ - public class TrackFormat - { - public string Separator { get; set; } - public string TrackPattern { get; set; } - public string TrackSeparator { get; set; } - } -} diff --git a/src/NzbDrone.Core/Organizer/BookFormat.cs b/src/NzbDrone.Core/Organizer/BookFormat.cs new file mode 100644 index 000000000..b37c327b2 --- /dev/null +++ b/src/NzbDrone.Core/Organizer/BookFormat.cs @@ -0,0 +1,9 @@ +namespace NzbDrone.Core.Organizer +{ + public class BookFormat + { + public string Separator { get; set; } + public string BookPattern { get; set; } + public string BookSeparator { get; set; } + } +} diff --git a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs index a548e4078..f85a50623 100644 --- a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs +++ b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs @@ -8,8 +8,8 @@ using NLog; using NzbDrone.Common.Cache; using NzbDrone.Common.EnsureThat; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Profiles.Releases; using NzbDrone.Core.Qualities; @@ -17,11 +17,11 @@ namespace NzbDrone.Core.Organizer { public interface IBuildFileNames { - string BuildTrackFileName(Author artist, Book album, BookFile trackFile, NamingConfig namingConfig = null, List<string> preferredWords = null); - string BuildTrackFilePath(Author artist, Book album, string fileName, string extension); - string BuildAlbumPath(Author artist, Book album); + string BuildBookFileName(Author author, Book book, BookFile bookFile, NamingConfig namingConfig = null, List<string> preferredWords = null); + string BuildBookFilePath(Author author, Book book, string fileName, string extension); + string BuildBookPath(Author author, Book book); BasicNamingConfig GetBasicNamingConfig(NamingConfig nameSpec); - string GetArtistFolder(Author artist, NamingConfig namingConfig = null); + string GetAuthorFolder(Author author, NamingConfig namingConfig = null); } public class FileNameBuilder : IBuildFileNames @@ -29,8 +29,8 @@ namespace NzbDrone.Core.Organizer private readonly INamingConfigService _namingConfigService; private readonly IQualityDefinitionService _qualityDefinitionService; private readonly IPreferredWordService _preferredWordService; - private readonly ICached<TrackFormat[]> _trackFormatCache; - private readonly ICached<AbsoluteTrackFormat[]> _absoluteTrackFormatCache; + private readonly ICached<BookFormat[]> _trackFormatCache; + private readonly ICached<AbsoluteBookFormat[]> _absoluteTrackFormatCache; private readonly Logger _logger; private static readonly Regex TitleRegex = new Regex(@"\{(?<prefix>[- ._\[(]*)(?<token>(?:[a-z0-9]+)(?:(?<separator>[- ._]+)(?:[a-z0-9]+))?)(?::(?<customFormat>[a-z0-9]+))?(?<suffix>[- ._)\]]*)\}", @@ -47,13 +47,10 @@ namespace NzbDrone.Core.Organizer public static readonly Regex ReleaseDateRegex = new Regex(@"\{Release(\s|\W|_)Year\}", RegexOptions.Compiled | RegexOptions.IgnoreCase); - public static readonly Regex ArtistNameRegex = new Regex(@"(?<token>\{(?:Artist)(?<separator>[- ._])(Clean)?Name(The)?\})", + public static readonly Regex AuthorNameRegex = new Regex(@"(?<token>\{(?:Author)(?<separator>[- ._])(Clean)?Name(The)?\})", RegexOptions.Compiled | RegexOptions.IgnoreCase); - public static readonly Regex AlbumTitleRegex = new Regex(@"(?<token>\{(?:Album)(?<separator>[- ._])(Clean)?Title(The)?\})", - RegexOptions.Compiled | RegexOptions.IgnoreCase); - - public static readonly Regex TrackTitleRegex = new Regex(@"(?<token>\{(?:Track)(?<separator>[- ._])(Clean)?Title(The)?\})", + public static readonly Regex BookTitleRegex = new Regex(@"(?<token>\{(?:Book)(?<separator>[- ._])(Clean)?Title(The)?\})", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex FileNameCleanupRegex = new Regex(@"([- ._])(\1)+", RegexOptions.Compiled); @@ -78,41 +75,41 @@ namespace NzbDrone.Core.Organizer _namingConfigService = namingConfigService; _qualityDefinitionService = qualityDefinitionService; _preferredWordService = preferredWordService; - _trackFormatCache = cacheManager.GetCache<TrackFormat[]>(GetType(), "trackFormat"); - _absoluteTrackFormatCache = cacheManager.GetCache<AbsoluteTrackFormat[]>(GetType(), "absoluteTrackFormat"); + _trackFormatCache = cacheManager.GetCache<BookFormat[]>(GetType(), "bookFormat"); + _absoluteTrackFormatCache = cacheManager.GetCache<AbsoluteBookFormat[]>(GetType(), "absoluteBookFormat"); _logger = logger; } - public string BuildTrackFileName(Author artist, Book album, BookFile trackFile, NamingConfig namingConfig = null, List<string> preferredWords = null) + public string BuildBookFileName(Author author, Book book, BookFile bookFile, NamingConfig namingConfig = null, List<string> preferredWords = null) { if (namingConfig == null) { namingConfig = _namingConfigService.GetConfig(); } - if (!namingConfig.RenameTracks) + if (!namingConfig.RenameBooks) { - return GetOriginalFileName(trackFile); + return GetOriginalFileName(bookFile); } - if (namingConfig.StandardTrackFormat.IsNullOrWhiteSpace()) + if (namingConfig.StandardBookFormat.IsNullOrWhiteSpace()) { throw new NamingFormatException("File name format cannot be empty"); } - var pattern = namingConfig.StandardTrackFormat; + var pattern = namingConfig.StandardBookFormat; var subFolders = pattern.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries); var safePattern = subFolders.Aggregate("", (current, folderLevel) => Path.Combine(current, folderLevel)); var tokenHandlers = new Dictionary<string, Func<TokenMatch, string>>(FileNameBuilderTokenEqualityComparer.Instance); - AddArtistTokens(tokenHandlers, artist); - AddAlbumTokens(tokenHandlers, album); - AddTrackFileTokens(tokenHandlers, trackFile); - AddQualityTokens(tokenHandlers, artist, trackFile); - AddMediaInfoTokens(tokenHandlers, trackFile); - AddPreferredWords(tokenHandlers, artist, trackFile, preferredWords); + AddAuthorTokens(tokenHandlers, author); + AddBookTokens(tokenHandlers, book); + AddBookFileTokens(tokenHandlers, bookFile); + AddQualityTokens(tokenHandlers, author, bookFile); + AddMediaInfoTokens(tokenHandlers, bookFile); + AddPreferredWords(tokenHandlers, author, bookFile, preferredWords); var fileName = ReplaceTokens(safePattern, tokenHandlers, namingConfig).Trim(); fileName = FileNameCleanupRegex.Replace(fileName, match => match.Captures[0].Value[0].ToString()); @@ -121,25 +118,25 @@ namespace NzbDrone.Core.Organizer return fileName; } - public string BuildTrackFilePath(Author artist, Book album, string fileName, string extension) + public string BuildBookFilePath(Author author, Book book, string fileName, string extension) { Ensure.That(extension, () => extension).IsNotNullOrWhiteSpace(); - var path = BuildAlbumPath(artist, album); + var path = BuildBookPath(author, book); return Path.Combine(path, fileName + extension); } - public string BuildAlbumPath(Author artist, Book album) + public string BuildBookPath(Author author, Book book) { - var path = artist.Path; + var path = author.Path; return path; } public BasicNamingConfig GetBasicNamingConfig(NamingConfig nameSpec) { - var trackFormat = GetTrackFormat(nameSpec.StandardTrackFormat).LastOrDefault(); + var trackFormat = GetTrackFormat(nameSpec.StandardBookFormat).LastOrDefault(); if (trackFormat == null) { @@ -151,7 +148,7 @@ namespace NzbDrone.Core.Organizer Separator = trackFormat.Separator }; - var titleTokens = TitleRegex.Matches(nameSpec.StandardTrackFormat); + var titleTokens = TitleRegex.Matches(nameSpec.StandardBookFormat); foreach (Match match in titleTokens) { @@ -163,7 +160,7 @@ namespace NzbDrone.Core.Organizer basicNamingConfig.ReplaceSpaces = true; } - if (token.StartsWith("{Artist", StringComparison.InvariantCultureIgnoreCase)) + if (token.StartsWith("{Author", StringComparison.InvariantCultureIgnoreCase)) { basicNamingConfig.IncludeArtistName = true; } @@ -182,7 +179,7 @@ namespace NzbDrone.Core.Organizer return basicNamingConfig; } - public string GetArtistFolder(Author artist, NamingConfig namingConfig = null) + public string GetAuthorFolder(Author author, NamingConfig namingConfig = null) { if (namingConfig == null) { @@ -191,9 +188,9 @@ namespace NzbDrone.Core.Organizer var tokenHandlers = new Dictionary<string, Func<TokenMatch, string>>(FileNameBuilderTokenEqualityComparer.Instance); - AddArtistTokens(tokenHandlers, artist); + AddAuthorTokens(tokenHandlers, author); - return CleanFolderName(ReplaceTokens(namingConfig.ArtistFolderFormat, tokenHandlers, namingConfig)); + return CleanFolderName(ReplaceTokens(namingConfig.AuthorFolderFormat, tokenHandlers, namingConfig)); } public static string CleanTitle(string title) @@ -230,32 +227,32 @@ namespace NzbDrone.Core.Organizer return name.Trim(' ', '.'); } - private void AddArtistTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, Author artist) + private void AddAuthorTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, Author author) { - tokenHandlers["{Artist Name}"] = m => artist.Name; - tokenHandlers["{Artist CleanName}"] = m => CleanTitle(artist.Name); - tokenHandlers["{Artist NameThe}"] = m => TitleThe(artist.Name); + tokenHandlers["{Author Name}"] = m => author.Name; + tokenHandlers["{Author CleanName}"] = m => CleanTitle(author.Name); + tokenHandlers["{Author NameThe}"] = m => TitleThe(author.Name); - if (artist.Metadata.Value.Disambiguation != null) + if (author.Metadata.Value.Disambiguation != null) { - tokenHandlers["{Artist Disambiguation}"] = m => artist.Metadata.Value.Disambiguation; + tokenHandlers["{Author Disambiguation}"] = m => author.Metadata.Value.Disambiguation; } } - private void AddAlbumTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, Book album) + private void AddBookTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, Book book) { - tokenHandlers["{Album Title}"] = m => album.Title; - tokenHandlers["{Album CleanTitle}"] = m => CleanTitle(album.Title); - tokenHandlers["{Album TitleThe}"] = m => TitleThe(album.Title); + tokenHandlers["{Book Title}"] = m => book.Title; + tokenHandlers["{Book CleanTitle}"] = m => CleanTitle(book.Title); + tokenHandlers["{Book TitleThe}"] = m => TitleThe(book.Title); - if (album.Disambiguation != null) + if (book.Disambiguation != null) { - tokenHandlers["{Album Disambiguation}"] = m => album.Disambiguation; + tokenHandlers["{Book Disambiguation}"] = m => book.Disambiguation; } - if (album.ReleaseDate.HasValue) + if (book.ReleaseDate.HasValue) { - tokenHandlers["{Release Year}"] = m => album.ReleaseDate.Value.Year.ToString(); + tokenHandlers["{Release Year}"] = m => book.ReleaseDate.Value.Year.ToString(); } else { @@ -263,19 +260,19 @@ namespace NzbDrone.Core.Organizer } } - private void AddTrackFileTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, BookFile trackFile) + private void AddBookFileTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, BookFile bookFile) { - tokenHandlers["{Original Title}"] = m => GetOriginalTitle(trackFile); - tokenHandlers["{Original Filename}"] = m => GetOriginalFileName(trackFile); - tokenHandlers["{Release Group}"] = m => trackFile.ReleaseGroup ?? m.DefaultValue("Readarr"); + tokenHandlers["{Original Title}"] = m => GetOriginalTitle(bookFile); + tokenHandlers["{Original Filename}"] = m => GetOriginalFileName(bookFile); + tokenHandlers["{Release Group}"] = m => bookFile.ReleaseGroup ?? m.DefaultValue("Readarr"); } - private void AddQualityTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, Author artist, BookFile trackFile) + private void AddQualityTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, Author author, BookFile bookFile) { - var qualityTitle = _qualityDefinitionService.Get(trackFile.Quality.Quality).Title; - var qualityProper = GetQualityProper(trackFile.Quality); + var qualityTitle = _qualityDefinitionService.Get(bookFile.Quality.Quality).Title; + var qualityProper = GetQualityProper(bookFile.Quality); - //var qualityReal = GetQualityReal(artist, trackFile.Quality); + //var qualityReal = GetQualityReal(author, bookFile.Quality); tokenHandlers["{Quality Full}"] = m => string.Format("{0}", qualityTitle); tokenHandlers["{Quality Title}"] = m => qualityTitle; tokenHandlers["{Quality Proper}"] = m => qualityProper; @@ -283,33 +280,33 @@ namespace NzbDrone.Core.Organizer //tokenHandlers["{Quality Real}"] = m => qualityReal; } - private void AddMediaInfoTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, BookFile trackFile) + private void AddMediaInfoTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, BookFile bookFile) { - if (trackFile.MediaInfo == null) + if (bookFile.MediaInfo == null) { - _logger.Trace("Media info is unavailable for {0}", trackFile); + _logger.Trace("Media info is unavailable for {0}", bookFile); return; } - var audioCodec = MediaInfoFormatter.FormatAudioCodec(trackFile.MediaInfo); - var audioChannels = MediaInfoFormatter.FormatAudioChannels(trackFile.MediaInfo); + var audioCodec = MediaInfoFormatter.FormatAudioCodec(bookFile.MediaInfo); + var audioChannels = MediaInfoFormatter.FormatAudioChannels(bookFile.MediaInfo); var audioChannelsFormatted = audioChannels > 0 ? audioChannels.ToString("F1", CultureInfo.InvariantCulture) : string.Empty; tokenHandlers["{MediaInfo AudioCodec}"] = m => audioCodec; tokenHandlers["{MediaInfo AudioChannels}"] = m => audioChannelsFormatted; - tokenHandlers["{MediaInfo AudioBitRate}"] = m => MediaInfoFormatter.FormatAudioBitrate(trackFile.MediaInfo); - tokenHandlers["{MediaInfo AudioBitsPerSample}"] = m => MediaInfoFormatter.FormatAudioBitsPerSample(trackFile.MediaInfo); - tokenHandlers["{MediaInfo AudioSampleRate}"] = m => MediaInfoFormatter.FormatAudioSampleRate(trackFile.MediaInfo); + tokenHandlers["{MediaInfo AudioBitRate}"] = m => MediaInfoFormatter.FormatAudioBitrate(bookFile.MediaInfo); + tokenHandlers["{MediaInfo AudioBitsPerSample}"] = m => MediaInfoFormatter.FormatAudioBitsPerSample(bookFile.MediaInfo); + tokenHandlers["{MediaInfo AudioSampleRate}"] = m => MediaInfoFormatter.FormatAudioSampleRate(bookFile.MediaInfo); } - private void AddPreferredWords(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, Author artist, BookFile trackFile, List<string> preferredWords = null) + private void AddPreferredWords(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, Author author, BookFile bookFile, List<string> preferredWords = null) { if (preferredWords == null) { - preferredWords = _preferredWordService.GetMatchingPreferredWords(artist, trackFile.GetSceneOrFileName()); + preferredWords = _preferredWordService.GetMatchingPreferredWords(author, bookFile.GetSceneOrFileName()); } tokenHandlers["{Preferred Words}"] = m => string.Join(" ", preferredWords); @@ -365,14 +362,14 @@ namespace NzbDrone.Core.Organizer return replacementText; } - private TrackFormat[] GetTrackFormat(string pattern) + private BookFormat[] GetTrackFormat(string pattern) { return _trackFormatCache.Get(pattern, () => SeasonEpisodePatternRegex.Matches(pattern).OfType<Match>() - .Select(match => new TrackFormat + .Select(match => new BookFormat { - TrackSeparator = match.Groups["episodeSeparator"].Value, + BookSeparator = match.Groups["episodeSeparator"].Value, Separator = match.Groups["separator"].Value, - TrackPattern = match.Groups["episode"].Value, + BookPattern = match.Groups["episode"].Value, }).ToArray()); } @@ -391,19 +388,19 @@ namespace NzbDrone.Core.Organizer return string.Empty; } - private string GetOriginalTitle(BookFile trackFile) + private string GetOriginalTitle(BookFile bookFile) { - if (trackFile.SceneName.IsNullOrWhiteSpace()) + if (bookFile.SceneName.IsNullOrWhiteSpace()) { - return GetOriginalFileName(trackFile); + return GetOriginalFileName(bookFile); } - return trackFile.SceneName; + return bookFile.SceneName; } - private string GetOriginalFileName(BookFile trackFile) + private string GetOriginalFileName(BookFile bookFile) { - return Path.GetFileNameWithoutExtension(trackFile.Path); + return Path.GetFileNameWithoutExtension(bookFile.Path); } } diff --git a/src/NzbDrone.Core/Organizer/FileNameSampleService.cs b/src/NzbDrone.Core/Organizer/FileNameSampleService.cs index 2f8a3bd6c..e82d095a7 100644 --- a/src/NzbDrone.Core/Organizer/FileNameSampleService.cs +++ b/src/NzbDrone.Core/Organizer/FileNameSampleService.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; +using NzbDrone.Core.Books; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; @@ -10,15 +10,15 @@ namespace NzbDrone.Core.Organizer { SampleResult GetStandardTrackSample(NamingConfig nameSpec); SampleResult GetMultiDiscTrackSample(NamingConfig nameSpec); - string GetArtistFolderSample(NamingConfig nameSpec); + string GetAuthorFolderSample(NamingConfig nameSpec); } public class FileNameSampleService : IFilenameSampleService { private readonly IBuildFileNames _buildFileNames; - private static Author _standardArtist; - private static Book _standardAlbum; + private static Author _standardAuthor; + private static Book _standardBook; private static BookFile _singleTrackFile; private static List<string> _preferredWords; @@ -26,7 +26,7 @@ namespace NzbDrone.Core.Organizer { _buildFileNames = buildFileNames; - _standardArtist = new Author + _standardAuthor = new Author { Metadata = new AuthorMetadata { @@ -35,7 +35,7 @@ namespace NzbDrone.Core.Organizer } }; - _standardAlbum = new Book + _standardBook = new Book { Title = "The Book Title", ReleaseDate = System.DateTime.Today, @@ -54,8 +54,8 @@ namespace NzbDrone.Core.Organizer _singleTrackFile = new BookFile { Quality = new QualityModel(Quality.MP3_320, new Revision(2)), - Path = "/music/Artist.Name.Album.Name.TrackNum.Track.Title.MP3256.mp3", - SceneName = "Artist.Name.Album.Name.TrackNum.Track.Title.MP3256", + Path = "/music/Author.Name.Book.Name.TrackNum.Track.Title.MP3256.mp3", + SceneName = "Author.Name.Book.Name.TrackNum.Track.Title.MP3256", ReleaseGroup = "RlsGrp", MediaInfo = mediaInfo }; @@ -70,10 +70,10 @@ namespace NzbDrone.Core.Organizer { var result = new SampleResult { - FileName = BuildTrackSample(_standardArtist, _standardAlbum, _singleTrackFile, nameSpec), - Artist = _standardArtist, - Album = _standardAlbum, - TrackFile = _singleTrackFile + FileName = BuildTrackSample(_standardAuthor, _standardBook, _singleTrackFile, nameSpec), + Author = _standardAuthor, + Book = _standardBook, + BookFile = _singleTrackFile }; return result; @@ -83,25 +83,25 @@ namespace NzbDrone.Core.Organizer { var result = new SampleResult { - FileName = BuildTrackSample(_standardArtist, _standardAlbum, _singleTrackFile, nameSpec), - Artist = _standardArtist, - Album = _standardAlbum, - TrackFile = _singleTrackFile + FileName = BuildTrackSample(_standardAuthor, _standardBook, _singleTrackFile, nameSpec), + Author = _standardAuthor, + Book = _standardBook, + BookFile = _singleTrackFile }; return result; } - public string GetArtistFolderSample(NamingConfig nameSpec) + public string GetAuthorFolderSample(NamingConfig nameSpec) { - return _buildFileNames.GetArtistFolder(_standardArtist, nameSpec); + return _buildFileNames.GetAuthorFolder(_standardAuthor, nameSpec); } - private string BuildTrackSample(Author artist, Book album, BookFile trackFile, NamingConfig nameSpec) + private string BuildTrackSample(Author author, Book book, BookFile bookFile, NamingConfig nameSpec) { try { - return _buildFileNames.BuildTrackFileName(artist, album, trackFile, nameSpec, _preferredWords); + return _buildFileNames.BuildBookFileName(author, book, bookFile, nameSpec, _preferredWords); } catch (NamingFormatException) { diff --git a/src/NzbDrone.Core/Organizer/FileNameValidation.cs b/src/NzbDrone.Core/Organizer/FileNameValidation.cs index 79461dd09..1a7aa77a0 100644 --- a/src/NzbDrone.Core/Organizer/FileNameValidation.cs +++ b/src/NzbDrone.Core/Organizer/FileNameValidation.cs @@ -9,23 +9,23 @@ namespace NzbDrone.Core.Organizer internal static readonly Regex OriginalTokenRegex = new Regex(@"(\{original[- ._](?:title|filename)\})", RegexOptions.Compiled | RegexOptions.IgnoreCase); - public static IRuleBuilderOptions<T, string> ValidTrackFormat<T>(this IRuleBuilder<T, string> ruleBuilder) + public static IRuleBuilderOptions<T, string> ValidBookFormat<T>(this IRuleBuilder<T, string> ruleBuilder) { ruleBuilder.SetValidator(new NotEmptyValidator(null)); return ruleBuilder.SetValidator(new ValidStandardTrackFormatValidator()); } - public static IRuleBuilderOptions<T, string> ValidArtistFolderFormat<T>(this IRuleBuilder<T, string> ruleBuilder) + public static IRuleBuilderOptions<T, string> ValidAuthorFolderFormat<T>(this IRuleBuilder<T, string> ruleBuilder) { ruleBuilder.SetValidator(new NotEmptyValidator(null)); - return ruleBuilder.SetValidator(new RegularExpressionValidator(FileNameBuilder.ArtistNameRegex)).WithMessage("Must contain Artist name"); + return ruleBuilder.SetValidator(new RegularExpressionValidator(FileNameBuilder.AuthorNameRegex)).WithMessage("Must contain Author name"); } } public class ValidStandardTrackFormatValidator : PropertyValidator { public ValidStandardTrackFormatValidator() - : base("Must contain Album Title") + : base("Must contain Book Title") { } @@ -33,7 +33,7 @@ namespace NzbDrone.Core.Organizer { var value = context.PropertyValue as string; - if (!FileNameBuilder.AlbumTitleRegex.IsMatch(value)) + if (!FileNameBuilder.BookTitleRegex.IsMatch(value)) { return false; } diff --git a/src/NzbDrone.Core/Organizer/FileNameValidationService.cs b/src/NzbDrone.Core/Organizer/FileNameValidationService.cs index 606b445aa..615860487 100644 --- a/src/NzbDrone.Core/Organizer/FileNameValidationService.cs +++ b/src/NzbDrone.Core/Organizer/FileNameValidationService.cs @@ -13,7 +13,7 @@ namespace NzbDrone.Core.Organizer public ValidationFailure ValidateTrackFilename(SampleResult sampleResult) { - var validationFailure = new ValidationFailure("StandardTrackFormat", ERROR_MESSAGE); + var validationFailure = new ValidationFailure("StandardBookFormat", ERROR_MESSAGE); //TODO Add Validation for TrackFilename //var parsedEpisodeInfo = Parser.Parser.ParseTitle(sampleResult.FileName); diff --git a/src/NzbDrone.Core/Organizer/NamingConfig.cs b/src/NzbDrone.Core/Organizer/NamingConfig.cs index 502528d61..12bd6d41e 100644 --- a/src/NzbDrone.Core/Organizer/NamingConfig.cs +++ b/src/NzbDrone.Core/Organizer/NamingConfig.cs @@ -7,15 +7,15 @@ namespace NzbDrone.Core.Organizer { public static NamingConfig Default => new NamingConfig { - RenameTracks = false, + RenameBooks = false, ReplaceIllegalCharacters = true, - StandardTrackFormat = "{Album Title}" + Path.DirectorySeparatorChar + "{Artist Name} - {Album Title}", - ArtistFolderFormat = "{Artist Name}", + StandardBookFormat = "{Book Title}" + Path.DirectorySeparatorChar + "{Author Name} - {Book Title}", + AuthorFolderFormat = "{Author Name}", }; - public bool RenameTracks { get; set; } + public bool RenameBooks { get; set; } public bool ReplaceIllegalCharacters { get; set; } - public string StandardTrackFormat { get; set; } - public string ArtistFolderFormat { get; set; } + public string StandardBookFormat { get; set; } + public string AuthorFolderFormat { get; set; } } } diff --git a/src/NzbDrone.Core/Organizer/SampleResult.cs b/src/NzbDrone.Core/Organizer/SampleResult.cs index 23b53961a..42d2fcadf 100644 --- a/src/NzbDrone.Core/Organizer/SampleResult.cs +++ b/src/NzbDrone.Core/Organizer/SampleResult.cs @@ -1,13 +1,13 @@ +using NzbDrone.Core.Books; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; namespace NzbDrone.Core.Organizer { public class SampleResult { public string FileName { get; set; } - public Author Artist { get; set; } - public Book Album { get; set; } - public BookFile TrackFile { get; set; } + public Author Author { get; set; } + public Book Book { get; set; } + public BookFile BookFile { get; set; } } } diff --git a/src/NzbDrone.Core/Organizer/TrackFormat.cs b/src/NzbDrone.Core/Organizer/TrackFormat.cs deleted file mode 100644 index bf37011e3..000000000 --- a/src/NzbDrone.Core/Organizer/TrackFormat.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace NzbDrone.Core.Organizer -{ - public class AbsoluteTrackFormat - { - public string Separator { get; set; } - public string AbsoluteTrackPattern { get; set; } - } -} diff --git a/src/NzbDrone.Core/Parser/FingerprintingService.cs b/src/NzbDrone.Core/Parser/FingerprintingService.cs index 4119f89e4..c1ab00753 100644 --- a/src/NzbDrone.Core/Parser/FingerprintingService.cs +++ b/src/NzbDrone.Core/Parser/FingerprintingService.cs @@ -21,7 +21,7 @@ namespace NzbDrone.Core.Parser { bool IsSetup(); Version FpcalcVersion(); - void Lookup(List<LocalTrack> tracks, double threshold); + void Lookup(List<LocalBook> tracks, double threshold); } public class AcoustId @@ -324,7 +324,7 @@ namespace NzbDrone.Core.Parser return null; } - public void Lookup(List<LocalTrack> tracks, double threshold) + public void Lookup(List<LocalBook> tracks, double threshold) { if (!IsSetup()) { @@ -334,7 +334,7 @@ namespace NzbDrone.Core.Parser Lookup(tracks.Select(x => Tuple.Create(x, GetFingerprint(x.Path))).ToList(), threshold); } - public void Lookup(List<Tuple<LocalTrack, AcoustId>> files, double threshold) + public void Lookup(List<Tuple<LocalBook, AcoustId>> files, double threshold) { var toLookup = files.Where(x => x.Item2 != null).ToList(); if (!toLookup.Any()) @@ -347,7 +347,7 @@ namespace NzbDrone.Core.Parser ParseResponse(response, toLookup, threshold); } - public HttpRequest GenerateRequest(List<Tuple<LocalTrack, AcoustId>> toLookup) + public HttpRequest GenerateRequest(List<Tuple<LocalBook, AcoustId>> toLookup) { var httpRequest = _customerRequestBuilder.Create() .WithRateLimit(0.334) @@ -414,7 +414,7 @@ namespace NzbDrone.Core.Parser return response; } - private void ParseResponse(LookupResponse response, List<Tuple<LocalTrack, AcoustId>> toLookup, double threshold) + private void ParseResponse(LookupResponse response, List<Tuple<LocalBook, AcoustId>> toLookup, double threshold) { if (response == null) { diff --git a/src/NzbDrone.Core/Parser/Model/ArtistTitleInfo.cs b/src/NzbDrone.Core/Parser/Model/AuthorTitleInfo.cs similarity index 85% rename from src/NzbDrone.Core/Parser/Model/ArtistTitleInfo.cs rename to src/NzbDrone.Core/Parser/Model/AuthorTitleInfo.cs index edae3cf1f..d6059fbe0 100644 --- a/src/NzbDrone.Core/Parser/Model/ArtistTitleInfo.cs +++ b/src/NzbDrone.Core/Parser/Model/AuthorTitleInfo.cs @@ -1,6 +1,6 @@ namespace NzbDrone.Core.Parser.Model { - public class ArtistTitleInfo + public class AuthorTitleInfo { public string Title { get; set; } public string TitleWithoutYear { get; set; } diff --git a/src/NzbDrone.Core/Parser/Model/ImportListItemInfo.cs b/src/NzbDrone.Core/Parser/Model/ImportListItemInfo.cs index fa61ba218..16c0762bc 100644 --- a/src/NzbDrone.Core/Parser/Model/ImportListItemInfo.cs +++ b/src/NzbDrone.Core/Parser/Model/ImportListItemInfo.cs @@ -6,15 +6,15 @@ namespace NzbDrone.Core.Parser.Model { public int ImportListId { get; set; } public string ImportList { get; set; } - public string Artist { get; set; } + public string Author { get; set; } public string ArtistMusicBrainzId { get; set; } - public string Album { get; set; } + public string Book { get; set; } public string AlbumMusicBrainzId { get; set; } public DateTime ReleaseDate { get; set; } public override string ToString() { - return string.Format("[{0}] {1} [{2}]", ReleaseDate, Artist, Album); + return string.Format("[{0}] {1} [{2}]", ReleaseDate, Author, Book); } } } diff --git a/src/NzbDrone.Core/Parser/Model/LocalAlbumRelease.cs b/src/NzbDrone.Core/Parser/Model/LocalAlbumRelease.cs index 59bb9ec59..aa59b93db 100644 --- a/src/NzbDrone.Core/Parser/Model/LocalAlbumRelease.cs +++ b/src/NzbDrone.Core/Parser/Model/LocalAlbumRelease.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; using System.IO; using System.Linq; using NzbDrone.Common.Extensions; -using NzbDrone.Core.MediaFiles.TrackImport.Identification; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; +using NzbDrone.Core.MediaFiles.BookImport.Identification; namespace NzbDrone.Core.Parser.Model { @@ -12,46 +12,46 @@ namespace NzbDrone.Core.Parser.Model { public LocalAlbumRelease() { - LocalTracks = new List<LocalTrack>(); + LocalBooks = new List<LocalBook>(); // A dummy distance, will be replaced Distance = new Distance(); Distance.Add("album_id", 1.0); } - public LocalAlbumRelease(List<LocalTrack> tracks) + public LocalAlbumRelease(List<LocalBook> tracks) { - LocalTracks = tracks; + LocalBooks = tracks; // A dummy distance, will be replaced Distance = new Distance(); Distance.Add("album_id", 1.0); } - public List<LocalTrack> LocalTracks { get; set; } - public int TrackCount => LocalTracks.Count; + public List<LocalBook> LocalBooks { get; set; } + public int TrackCount => LocalBooks.Count; public Distance Distance { get; set; } public Book Book { get; set; } - public List<LocalTrack> ExistingTracks { get; set; } + public List<LocalBook> ExistingTracks { get; set; } public bool NewDownload { get; set; } public void PopulateMatch() { if (Book != null) { - LocalTracks = LocalTracks.Concat(ExistingTracks).DistinctBy(x => x.Path).ToList(); - foreach (var localTrack in LocalTracks) + LocalBooks = LocalBooks.Concat(ExistingTracks).DistinctBy(x => x.Path).ToList(); + foreach (var localTrack in LocalBooks) { - localTrack.Album = Book; - localTrack.Artist = Book.Author.Value; + localTrack.Book = Book; + localTrack.Author = Book.Author.Value; } } } public override string ToString() { - return "[" + string.Join(", ", LocalTracks.Select(x => Path.GetDirectoryName(x.Path)).Distinct()) + "]"; + return "[" + string.Join(", ", LocalBooks.Select(x => Path.GetDirectoryName(x.Path)).Distinct()) + "]"; } } } diff --git a/src/NzbDrone.Core/Parser/Model/LocalTrack.cs b/src/NzbDrone.Core/Parser/Model/LocalBook.cs similarity index 75% rename from src/NzbDrone.Core/Parser/Model/LocalTrack.cs rename to src/NzbDrone.Core/Parser/Model/LocalBook.cs index e90b91aa1..e3760727b 100644 --- a/src/NzbDrone.Core/Parser/Model/LocalTrack.cs +++ b/src/NzbDrone.Core/Parser/Model/LocalBook.cs @@ -1,22 +1,22 @@ using System; using System.Collections.Generic; -using NzbDrone.Core.MediaFiles.TrackImport.Identification; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; +using NzbDrone.Core.MediaFiles.BookImport.Identification; using NzbDrone.Core.Qualities; namespace NzbDrone.Core.Parser.Model { - public class LocalTrack + public class LocalBook { public string Path { get; set; } public long Size { get; set; } public DateTime Modified { get; set; } public ParsedTrackInfo FileTrackInfo { get; set; } public ParsedTrackInfo FolderTrackInfo { get; set; } - public ParsedAlbumInfo DownloadClientAlbumInfo { get; set; } + public ParsedBookInfo DownloadClientAlbumInfo { get; set; } public List<string> AcoustIdResults { get; set; } - public Author Artist { get; set; } - public Book Album { get; set; } + public Author Author { get; set; } + public Book Book { get; set; } public Distance Distance { get; set; } public QualityModel Quality { get; set; } public bool ExistingFile { get; set; } diff --git a/src/NzbDrone.Core/Parser/Model/ParsedAlbumInfo.cs b/src/NzbDrone.Core/Parser/Model/ParsedBookInfo.cs similarity index 57% rename from src/NzbDrone.Core/Parser/Model/ParsedAlbumInfo.cs rename to src/NzbDrone.Core/Parser/Model/ParsedBookInfo.cs index 8a783baf2..3cb3e7b6e 100644 --- a/src/NzbDrone.Core/Parser/Model/ParsedAlbumInfo.cs +++ b/src/NzbDrone.Core/Parser/Model/ParsedBookInfo.cs @@ -2,11 +2,11 @@ using NzbDrone.Core.Qualities; namespace NzbDrone.Core.Parser.Model { - public class ParsedAlbumInfo + public class ParsedBookInfo { - public string AlbumTitle { get; set; } - public string ArtistName { get; set; } - public ArtistTitleInfo ArtistTitleInfo { get; set; } + public string BookTitle { get; set; } + public string AuthorName { get; set; } + public AuthorTitleInfo AuthorTitleInfo { get; set; } public QualityModel Quality { get; set; } public string ReleaseDate { get; set; } public bool Discography { get; set; } @@ -18,14 +18,14 @@ namespace NzbDrone.Core.Parser.Model public override string ToString() { - string albumString = "[Unknown Album]"; + string bookString = "[Unknown Book]"; - if (AlbumTitle != null) + if (BookTitle != null) { - albumString = string.Format("{0}", AlbumTitle); + bookString = string.Format("{0}", BookTitle); } - return string.Format("{0} - {1} {2}", ArtistName, albumString, Quality); + return string.Format("{0} - {1} {2}", AuthorName, bookString, Quality); } } } diff --git a/src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs b/src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs index c320ab82a..e514e2872 100644 --- a/src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs +++ b/src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs @@ -15,8 +15,8 @@ namespace NzbDrone.Core.Parser.Model public string CommentUrl { get; set; } public int IndexerId { get; set; } public string Indexer { get; set; } - public string Artist { get; set; } - public string Album { get; set; } + public string Author { get; set; } + public string Book { get; set; } public DownloadProtocol DownloadProtocol { get; set; } public DateTime PublishDate { get; set; } diff --git a/src/NzbDrone.Core/Parser/Model/RemoteAlbum.cs b/src/NzbDrone.Core/Parser/Model/RemoteBook.cs similarity index 60% rename from src/NzbDrone.Core/Parser/Model/RemoteAlbum.cs rename to src/NzbDrone.Core/Parser/Model/RemoteBook.cs index 154fbc573..6c53df720 100644 --- a/src/NzbDrone.Core/Parser/Model/RemoteAlbum.cs +++ b/src/NzbDrone.Core/Parser/Model/RemoteBook.cs @@ -1,29 +1,29 @@ using System; using System.Collections.Generic; using System.Linq; +using NzbDrone.Core.Books; using NzbDrone.Core.Download.Clients; -using NzbDrone.Core.Music; namespace NzbDrone.Core.Parser.Model { - public class RemoteAlbum + public class RemoteBook { public ReleaseInfo Release { get; set; } - public ParsedAlbumInfo ParsedAlbumInfo { get; set; } - public Author Artist { get; set; } - public List<Book> Albums { get; set; } + public ParsedBookInfo ParsedBookInfo { get; set; } + public Author Author { get; set; } + public List<Book> Books { get; set; } public bool DownloadAllowed { get; set; } public TorrentSeedConfiguration SeedConfiguration { get; set; } public int PreferredWordScore { get; set; } - public RemoteAlbum() + public RemoteBook() { - Albums = new List<Book>(); + Books = new List<Book>(); } public bool IsRecentAlbum() { - return Albums.Any(e => e.ReleaseDate >= DateTime.UtcNow.Date.AddDays(-14)); + return Books.Any(e => e.ReleaseDate >= DateTime.UtcNow.Date.AddDays(-14)); } public override string ToString() diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index 3d8401e8b..200d8e129 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -6,7 +6,7 @@ using System.Text.RegularExpressions; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Common.Instrumentation; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.Parser @@ -17,114 +17,114 @@ namespace NzbDrone.Core.Parser private static readonly Regex[] ReportMusicTitleRegex = new[] { - // Track with artist (01 - artist - trackName) - new Regex(@"(?<trackNumber>\d*){0,1}([-| ]{0,1})(?<artist>[a-zA-Z0-9, ().&_]*)[-| ]{0,1}(?<trackName>[a-zA-Z0-9, ().&_]+)", + // Track with author (01 - author - trackName) + new Regex(@"(?<trackNumber>\d*){0,1}([-| ]{0,1})(?<author>[a-zA-Z0-9, ().&_]*)[-| ]{0,1}(?<trackName>[a-zA-Z0-9, ().&_]+)", RegexOptions.IgnoreCase | RegexOptions.Compiled), - // Track without artist (01 - trackName) + // Track without author (01 - trackName) new Regex(@"(?<trackNumber>\d*)[-| .]{0,1}(?<trackName>[a-zA-Z0-9, ().&_]+)", RegexOptions.IgnoreCase | RegexOptions.Compiled), - // Track without trackNumber or artist(trackName) + // Track without trackNumber or author(trackName) new Regex(@"(?<trackNumber>\d*)[-| .]{0,1}(?<trackName>[a-zA-Z0-9, ().&_]+)", RegexOptions.IgnoreCase | RegexOptions.Compiled), - // Track without trackNumber and with artist(artist - trackName) + // Track without trackNumber and with author(author - trackName) new Regex(@"(?<trackNumber>\d*)[-| .]{0,1}(?<trackName>[a-zA-Z0-9, ().&_]+)", RegexOptions.IgnoreCase | RegexOptions.Compiled), - // Track with artist and starting title (01 - artist - trackName) - new Regex(@"(?<trackNumber>\d*){0,1}[-| ]{0,1}(?<artist>[a-zA-Z0-9, ().&_]*)[-| ]{0,1}(?<trackName>[a-zA-Z0-9, ().&_]+)", + // Track with author and starting title (01 - author - trackName) + new Regex(@"(?<trackNumber>\d*){0,1}[-| ]{0,1}(?<author>[a-zA-Z0-9, ().&_]*)[-| ]{0,1}(?<trackName>[a-zA-Z0-9, ().&_]+)", RegexOptions.IgnoreCase | RegexOptions.Compiled), }; private static readonly Regex[] ReportAlbumTitleRegex = new[] { //ruTracker - (Genre) [Source]? Artist - Discography - new Regex(@"^(?:\(.+?\))(?:\W*(?:\[(?<source>.+?)\]))?\W*(?<artist>.+?)(?: - )(?<discography>Discography|Discografia).+?(?<startyear>\d{4}).+?(?<endyear>\d{4})", + new Regex(@"^(?:\(.+?\))(?:\W*(?:\[(?<source>.+?)\]))?\W*(?<author>.+?)(?: - )(?<discography>Discography|Discografia).+?(?<startyear>\d{4}).+?(?<endyear>\d{4})", RegexOptions.IgnoreCase | RegexOptions.Compiled), //Artist - Discography with two years - new Regex(@"^(?<artist>.+?)(?: - )(?:.+?)?(?<discography>Discography|Discografia).+?(?<startyear>\d{4}).+?(?<endyear>\d{4})", + new Regex(@"^(?<author>.+?)(?: - )(?:.+?)?(?<discography>Discography|Discografia).+?(?<startyear>\d{4}).+?(?<endyear>\d{4})", RegexOptions.IgnoreCase | RegexOptions.Compiled), //Artist - Discography with end year - new Regex(@"^(?<artist>.+?)(?: - )(?:.+?)?(?<discography>Discography|Discografia).+?(?<endyear>\d{4})", + new Regex(@"^(?<author>.+?)(?: - )(?:.+?)?(?<discography>Discography|Discografia).+?(?<endyear>\d{4})", RegexOptions.IgnoreCase | RegexOptions.Compiled), //Artist Discography with two years - new Regex(@"^(?<artist>.+?)\W*(?<discography>Discography|Discografia).+?(?<startyear>\d{4}).+?(?<endyear>\d{4})", + new Regex(@"^(?<author>.+?)\W*(?<discography>Discography|Discografia).+?(?<startyear>\d{4}).+?(?<endyear>\d{4})", RegexOptions.IgnoreCase | RegexOptions.Compiled), //Artist Discography with end year - new Regex(@"^(?<artist>.+?)\W*(?<discography>Discography|Discografia).+?(?<endyear>\d{4})", + new Regex(@"^(?<author>.+?)\W*(?<discography>Discography|Discografia).+?(?<endyear>\d{4})", RegexOptions.IgnoreCase | RegexOptions.Compiled), //Artist Discography - new Regex(@"^(?<artist>.+?)\W*(?<discography>Discography|Discografia)", + new Regex(@"^(?<author>.+?)\W*(?<discography>Discography|Discografia)", RegexOptions.IgnoreCase | RegexOptions.Compiled), //ruTracker - (Genre) [Source]? Artist - Album - Year - new Regex(@"^(?:\(.+?\))(?:\W*(?:\[(?<source>.+?)\]))?\W*(?<artist>.+?)(?: - )(?<album>.+?)(?: - )(?<releaseyear>\d{4})", + new Regex(@"^(?:\(.+?\))(?:\W*(?:\[(?<source>.+?)\]))?\W*(?<author>.+?)(?: - )(?<album>.+?)(?: - )(?<releaseyear>\d{4})", RegexOptions.IgnoreCase | RegexOptions.Compiled), //Artist-Album-Version-Source-Year //ex. Imagine Dragons-Smoke And Mirrors-Deluxe Edition-2CD-FLAC-2015-JLM - new Regex(@"^(?<artist>.+?)[-](?<album>.+?)[-](?:[\(|\[]?)(?<version>.+?(?:Edition)?)(?:[\)|\]]?)[-](?<source>\d?CD|WEB).+?(?<releaseyear>\d{4})", + new Regex(@"^(?<author>.+?)[-](?<album>.+?)[-](?:[\(|\[]?)(?<version>.+?(?:Edition)?)(?:[\)|\]]?)[-](?<source>\d?CD|WEB).+?(?<releaseyear>\d{4})", RegexOptions.IgnoreCase | RegexOptions.Compiled), //Artist-Album-Source-Year //ex. Dani_Sbert-Togheter-WEB-2017-FURY - new Regex(@"^(?<artist>.+?)[-](?<album>.+?)[-](?<source>\d?CD|WEB).+?(?<releaseyear>\d{4})", + new Regex(@"^(?<author>.+?)[-](?<album>.+?)[-](?<source>\d?CD|WEB).+?(?<releaseyear>\d{4})", RegexOptions.IgnoreCase | RegexOptions.Compiled), //Artist - Album (Year) Strict - new Regex(@"^(?:(?<artist>.+?)(?: - )+)(?<album>.+?)\W*(?:\(|\[).+?(?<releaseyear>\d{4})", + new Regex(@"^(?:(?<author>.+?)(?: - )+)(?<album>.+?)\W*(?:\(|\[).+?(?<releaseyear>\d{4})", RegexOptions.IgnoreCase | RegexOptions.Compiled), //Artist - Album (Year) - new Regex(@"^(?:(?<artist>.+?)(?: - )+)(?<album>.+?)\W*(?:\(|\[)(?<releaseyear>\d{4})", + new Regex(@"^(?:(?<author>.+?)(?: - )+)(?<album>.+?)\W*(?:\(|\[)(?<releaseyear>\d{4})", RegexOptions.IgnoreCase | RegexOptions.Compiled), //Artist - Album - Year [something] - new Regex(@"^(?:(?<artist>.+?)(?: - )+)(?<album>.+?)\W*(?: - )(?<releaseyear>\d{4})\W*(?:\(|\[)", + new Regex(@"^(?:(?<author>.+?)(?: - )+)(?<album>.+?)\W*(?: - )(?<releaseyear>\d{4})\W*(?:\(|\[)", RegexOptions.IgnoreCase | RegexOptions.Compiled), //Artist - Album [something] or Artist - Album (something) - new Regex(@"^(?:(?<artist>.+?)(?: - )+)(?<album>.+?)\W*(?:\(|\[)", + new Regex(@"^(?:(?<author>.+?)(?: - )+)(?<album>.+?)\W*(?:\(|\[)", RegexOptions.IgnoreCase | RegexOptions.Compiled), //Artist - Album Year - new Regex(@"^(?:(?<artist>.+?)(?: - )+)(?<album>.+?)\W*(?<releaseyear>\d{4})", + new Regex(@"^(?:(?<author>.+?)(?: - )+)(?<album>.+?)\W*(?<releaseyear>\d{4})", RegexOptions.IgnoreCase | RegexOptions.Compiled), //Artist-Album (Year) Strict - //Hyphen no space between artist and album - new Regex(@"^(?:(?<artist>.+?)(?:-)+)(?<album>.+?)\W*(?:\(|\[).+?(?<releaseyear>\d{4})", + //Hyphen no space between author and album + new Regex(@"^(?:(?<author>.+?)(?:-)+)(?<album>.+?)\W*(?:\(|\[).+?(?<releaseyear>\d{4})", RegexOptions.IgnoreCase | RegexOptions.Compiled), //Artist-Album (Year) - //Hyphen no space between artist and album - new Regex(@"^(?:(?<artist>.+?)(?:-)+)(?<album>.+?)\W*(?:\(|\[)(?<releaseyear>\d{4})", + //Hyphen no space between author and album + new Regex(@"^(?:(?<author>.+?)(?:-)+)(?<album>.+?)\W*(?:\(|\[)(?<releaseyear>\d{4})", RegexOptions.IgnoreCase | RegexOptions.Compiled), //Artist-Album [something] or Artist-Album (something) - //Hyphen no space between artist and album - new Regex(@"^(?:(?<artist>.+?)(?:-)+)(?<album>.+?)\W*(?:\(|\[)", + //Hyphen no space between author and album + new Regex(@"^(?:(?<author>.+?)(?:-)+)(?<album>.+?)\W*(?:\(|\[)", RegexOptions.IgnoreCase | RegexOptions.Compiled), //Artist-Album-something-Year - new Regex(@"^(?:(?<artist>.+?)(?:-)+)(?<album>.+?)(?:-.+?)(?<releaseyear>\d{4})", + new Regex(@"^(?:(?<author>.+?)(?:-)+)(?<album>.+?)(?:-.+?)(?<releaseyear>\d{4})", RegexOptions.IgnoreCase | RegexOptions.Compiled), //Artist-Album Year - //Hyphen no space between artist and album - new Regex(@"^(?:(?<artist>.+?)(?:-)+)(?:(?<album>.+?)(?:-)+)(?<releaseyear>\d{4})", + //Hyphen no space between author and album + new Regex(@"^(?:(?<author>.+?)(?:-)+)(?:(?<album>.+?)(?:-)+)(?<releaseyear>\d{4})", RegexOptions.IgnoreCase | RegexOptions.Compiled), //Artist - Year - Album - // Hypen with no or more spaces between artist/album/year - new Regex(@"^(?:(?<artist>.+?)(?:-))(?<releaseyear>\d{4})(?:-)(?<album>[^-]+)", + // Hypen with no or more spaces between author/album/year + new Regex(@"^(?:(?<author>.+?)(?:-))(?<releaseyear>\d{4})(?:-)(?<album>[^-]+)", RegexOptions.IgnoreCase | RegexOptions.Compiled), }; @@ -227,19 +227,19 @@ namespace NzbDrone.Core.Parser ParsedTrackInfo result = null; - Logger.Debug("Attempting to parse track info using directory and file names. {0}", fileInfo.Directory.Name); - result = ParseMusicTitle(fileInfo.Directory.Name + " " + fileInfo.Name); + Logger.Debug("Attempting to parse book info using directory and file names. {0}", fileInfo.Directory.Name); + result = ParseTitle(fileInfo.Directory.Name + " " + fileInfo.Name); if (result == null) { - Logger.Debug("Attempting to parse track info using directory name. {0}", fileInfo.Directory.Name); - result = ParseMusicTitle(fileInfo.Directory.Name + fileInfo.Extension); + Logger.Debug("Attempting to parse book info using directory name. {0}", fileInfo.Directory.Name); + result = ParseTitle(fileInfo.Directory.Name + fileInfo.Extension); } return result; } - public static ParsedTrackInfo ParseMusicTitle(string title) + public static ParsedTrackInfo ParseTitle(string title) { try { @@ -319,7 +319,7 @@ namespace NzbDrone.Core.Parser return null; } - public static ParsedAlbumInfo ParseAlbumTitleWithSearchCriteria(string title, Author artist, List<Book> album) + public static ParsedBookInfo ParseAlbumTitleWithSearchCriteria(string title, Author author, List<Book> album) { try { @@ -328,9 +328,9 @@ namespace NzbDrone.Core.Parser return null; } - var artistName = artist.Name == "Various Artists" ? "VA" : artist.Name.RemoveAccent(); + var artistName = author.Name == "Various Artists" ? "VA" : author.Name.RemoveAccent(); - Logger.Debug("Parsing string '{0}' using search criteria artist: '{1}' album: '{2}'", + Logger.Debug("Parsing string '{0}' using search criteria author: '{1}' album: '{2}'", title, artistName.RemoveAccent(), string.Join(", ", album.Select(a => a.Title.RemoveAccent()))); @@ -355,11 +355,11 @@ namespace NzbDrone.Core.Parser return null; } - var result = new ParsedAlbumInfo + var result = new ParsedBookInfo { - ArtistName = foundArtist, - ArtistTitleInfo = GetArtistTitleInfo(foundArtist), - AlbumTitle = foundAlbum + AuthorName = foundArtist, + AuthorTitleInfo = GetArtistTitleInfo(foundArtist), + BookTitle = foundAlbum }; try @@ -470,7 +470,7 @@ namespace NzbDrone.Core.Parser return match.Success ? int.Parse(match.Groups["id"].Value) : 0; } - public static ParsedAlbumInfo ParseAlbumTitle(string title) + public static ParsedBookInfo ParseBookTitle(string title) { try { @@ -566,7 +566,7 @@ namespace NzbDrone.Core.Parser return null; } - public static string CleanArtistName(this string name) + public static string CleanAuthorName(this string name) { // If Title only contains numbers return it as is. if (long.TryParse(name, out _)) @@ -681,7 +681,7 @@ namespace NzbDrone.Core.Parser private static ParsedTrackInfo ParseMatchMusicCollection(MatchCollection matchCollection) { - var artistName = matchCollection[0].Groups["artist"].Value./*Removed for cases like Will.I.Am Replace('.', ' ').*/Replace('_', ' '); + var artistName = matchCollection[0].Groups["author"].Value./*Removed for cases like Will.I.Am Replace('.', ' ').*/Replace('_', ' '); artistName = RequestInfoRegex.Replace(artistName, "").Trim(' '); // Coppied from Radarr (https://github.com/Radarr/Radarr/blob/develop/src/NzbDrone.Core/Parser/Parser.cs) @@ -732,9 +732,9 @@ namespace NzbDrone.Core.Parser return result; } - private static ArtistTitleInfo GetArtistTitleInfo(string title) + private static AuthorTitleInfo GetArtistTitleInfo(string title) { - var artistTitleInfo = new ArtistTitleInfo(); + var artistTitleInfo = new AuthorTitleInfo(); artistTitleInfo.Title = title; return artistTitleInfo; @@ -744,19 +744,19 @@ namespace NzbDrone.Core.Parser { Logger.Debug("Parsing string '{0}'", title); - var parseResult = ParseAlbumTitle(title); + var parseResult = ParseBookTitle(title); if (parseResult == null) { - return CleanArtistName(title); + return CleanAuthorName(title); } - return parseResult.ArtistName; + return parseResult.AuthorName; } - private static ParsedAlbumInfo ParseAlbumMatchCollection(MatchCollection matchCollection) + private static ParsedBookInfo ParseAlbumMatchCollection(MatchCollection matchCollection) { - var artistName = matchCollection[0].Groups["artist"].Value.Replace('.', ' ').Replace('_', ' '); + var artistName = matchCollection[0].Groups["author"].Value.Replace('.', ' ').Replace('_', ' '); var albumTitle = matchCollection[0].Groups["album"].Value.Replace('.', ' ').Replace('_', ' '); var releaseVersion = matchCollection[0].Groups["version"].Value.Replace('.', ' ').Replace('_', ' '); artistName = RequestInfoRegex.Replace(artistName, "").Trim(' '); @@ -766,13 +766,13 @@ namespace NzbDrone.Core.Parser int releaseYear; int.TryParse(matchCollection[0].Groups["releaseyear"].Value, out releaseYear); - ParsedAlbumInfo result; + ParsedBookInfo result; - result = new ParsedAlbumInfo(); + result = new ParsedBookInfo(); - result.ArtistName = artistName; - result.AlbumTitle = albumTitle; - result.ArtistTitleInfo = GetArtistTitleInfo(result.ArtistName); + result.AuthorName = artistName; + result.BookTitle = albumTitle; + result.AuthorTitleInfo = GetArtistTitleInfo(result.AuthorName); result.ReleaseDate = releaseYear.ToString(); result.ReleaseVersion = releaseVersion; @@ -794,7 +794,7 @@ namespace NzbDrone.Core.Parser result.DiscographyEnd = discEnd; } - result.AlbumTitle = "Discography"; + result.BookTitle = "Discography"; } Logger.Debug("Album Parsed. {0}", result); diff --git a/src/NzbDrone.Core/Parser/ParsingService.cs b/src/NzbDrone.Core/Parser/ParsingService.cs index 3d765c6fe..69e057868 100644 --- a/src/NzbDrone.Core/Parser/ParsingService.cs +++ b/src/NzbDrone.Core/Parser/ParsingService.cs @@ -4,9 +4,9 @@ using System.IO; using System.Linq; using NLog; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.Parser @@ -15,49 +15,49 @@ namespace NzbDrone.Core.Parser { Author GetArtist(string title); Author GetArtistFromTag(string file); - RemoteAlbum Map(ParsedAlbumInfo parsedAlbumInfo, SearchCriteriaBase searchCriteria = null); - RemoteAlbum Map(ParsedAlbumInfo parsedAlbumInfo, int authorId, IEnumerable<int> bookIds); - List<Book> GetAlbums(ParsedAlbumInfo parsedAlbumInfo, Author artist, SearchCriteriaBase searchCriteria = null); + RemoteBook Map(ParsedBookInfo parsedAlbumInfo, SearchCriteriaBase searchCriteria = null); + RemoteBook Map(ParsedBookInfo parsedAlbumInfo, int authorId, IEnumerable<int> bookIds); + List<Book> GetAlbums(ParsedBookInfo parsedAlbumInfo, Author author, SearchCriteriaBase searchCriteria = null); - ParsedAlbumInfo ParseAlbumTitleFuzzy(string title); + ParsedBookInfo ParseAlbumTitleFuzzy(string title); // Music stuff here - Book GetLocalAlbum(string filename, Author artist); + Book GetLocalAlbum(string filename, Author author); } public class ParsingService : IParsingService { - private readonly IArtistService _artistService; - private readonly IAlbumService _albumService; + private readonly IAuthorService _authorService; + private readonly IBookService _bookService; private readonly IMediaFileService _mediaFileService; private readonly Logger _logger; - public ParsingService(IArtistService artistService, - IAlbumService albumService, + public ParsingService(IAuthorService authorService, + IBookService bookService, IMediaFileService mediaFileService, Logger logger) { - _albumService = albumService; - _artistService = artistService; + _bookService = bookService; + _authorService = authorService; _mediaFileService = mediaFileService; _logger = logger; } public Author GetArtist(string title) { - var parsedAlbumInfo = Parser.ParseAlbumTitle(title); + var parsedAlbumInfo = Parser.ParseBookTitle(title); - if (parsedAlbumInfo != null && !parsedAlbumInfo.ArtistName.IsNullOrWhiteSpace()) + if (parsedAlbumInfo != null && !parsedAlbumInfo.AuthorName.IsNullOrWhiteSpace()) { - title = parsedAlbumInfo.ArtistName; + title = parsedAlbumInfo.AuthorName; } - var artistInfo = _artistService.FindByName(title); + var artistInfo = _authorService.FindByName(title); if (artistInfo == null) { - _logger.Debug("Trying inexact artist match for {0}", title); - artistInfo = _artistService.FindByNameInexact(title); + _logger.Debug("Trying inexact author match for {0}", title); + artistInfo = _authorService.FindByNameInexact(title); } return artistInfo; @@ -67,15 +67,15 @@ namespace NzbDrone.Core.Parser { var parsedTrackInfo = Parser.ParseMusicPath(file); - var artist = new Author(); + var author = new Author(); if (parsedTrackInfo.ArtistMBId.IsNotNullOrWhiteSpace()) { - artist = _artistService.FindById(parsedTrackInfo.ArtistMBId); + author = _authorService.FindById(parsedTrackInfo.ArtistMBId); - if (artist != null) + if (author != null) { - return artist; + return author; } } @@ -84,43 +84,43 @@ namespace NzbDrone.Core.Parser return null; } - artist = _artistService.FindByName(parsedTrackInfo.ArtistTitle); + author = _authorService.FindByName(parsedTrackInfo.ArtistTitle); - if (artist == null) + if (author == null) { - _logger.Debug("Trying inexact artist match for {0}", parsedTrackInfo.ArtistTitle); - artist = _artistService.FindByNameInexact(parsedTrackInfo.ArtistTitle); + _logger.Debug("Trying inexact author match for {0}", parsedTrackInfo.ArtistTitle); + author = _authorService.FindByNameInexact(parsedTrackInfo.ArtistTitle); } - return artist; + return author; } - public RemoteAlbum Map(ParsedAlbumInfo parsedAlbumInfo, SearchCriteriaBase searchCriteria = null) + public RemoteBook Map(ParsedBookInfo parsedAlbumInfo, SearchCriteriaBase searchCriteria = null) { - var remoteAlbum = new RemoteAlbum + var remoteAlbum = new RemoteBook { - ParsedAlbumInfo = parsedAlbumInfo, + ParsedBookInfo = parsedAlbumInfo, }; - var artist = GetArtist(parsedAlbumInfo, searchCriteria); + var author = GetArtist(parsedAlbumInfo, searchCriteria); - if (artist == null) + if (author == null) { return remoteAlbum; } - remoteAlbum.Artist = artist; - remoteAlbum.Albums = GetAlbums(parsedAlbumInfo, artist, searchCriteria); + remoteAlbum.Author = author; + remoteAlbum.Books = GetAlbums(parsedAlbumInfo, author, searchCriteria); return remoteAlbum; } - public List<Book> GetAlbums(ParsedAlbumInfo parsedAlbumInfo, Author artist, SearchCriteriaBase searchCriteria = null) + public List<Book> GetAlbums(ParsedBookInfo parsedAlbumInfo, Author author, SearchCriteriaBase searchCriteria = null) { - var albumTitle = parsedAlbumInfo.AlbumTitle; + var albumTitle = parsedAlbumInfo.BookTitle; var result = new List<Book>(); - if (parsedAlbumInfo.AlbumTitle == null) + if (parsedAlbumInfo.BookTitle == null) { return new List<Book>(); } @@ -131,7 +131,7 @@ namespace NzbDrone.Core.Parser { if (parsedAlbumInfo.DiscographyStart > 0) { - return _albumService.ArtistAlbumsBetweenDates(artist, + return _bookService.AuthorBooksBetweenDates(author, new DateTime(parsedAlbumInfo.DiscographyStart, 1, 1), new DateTime(parsedAlbumInfo.DiscographyEnd, 12, 31), false); @@ -139,30 +139,30 @@ namespace NzbDrone.Core.Parser if (parsedAlbumInfo.DiscographyEnd > 0) { - return _albumService.ArtistAlbumsBetweenDates(artist, + return _bookService.AuthorBooksBetweenDates(author, new DateTime(1800, 1, 1), new DateTime(parsedAlbumInfo.DiscographyEnd, 12, 31), false); } - return _albumService.GetAlbumsByArtist(artist.Id); + return _bookService.GetBooksByAuthor(author.Id); } if (searchCriteria != null) { - albumInfo = searchCriteria.Albums.ExclusiveOrDefault(e => e.Title == albumTitle); + albumInfo = searchCriteria.Books.ExclusiveOrDefault(e => e.Title == albumTitle); } if (albumInfo == null) { // TODO: Search by Title and Year instead of just Title when matching - albumInfo = _albumService.FindByTitle(artist.AuthorMetadataId, parsedAlbumInfo.AlbumTitle); + albumInfo = _bookService.FindByTitle(author.AuthorMetadataId, parsedAlbumInfo.BookTitle); } if (albumInfo == null) { - _logger.Debug("Trying inexact album match for {0}", parsedAlbumInfo.AlbumTitle); - albumInfo = _albumService.FindByTitleInexact(artist.AuthorMetadataId, parsedAlbumInfo.AlbumTitle); + _logger.Debug("Trying inexact book match for {0}", parsedAlbumInfo.BookTitle); + albumInfo = _bookService.FindByTitleInexact(author.AuthorMetadataId, parsedAlbumInfo.BookTitle); } if (albumInfo != null) @@ -177,60 +177,60 @@ namespace NzbDrone.Core.Parser return result; } - public RemoteAlbum Map(ParsedAlbumInfo parsedAlbumInfo, int authorId, IEnumerable<int> bookIds) + public RemoteBook Map(ParsedBookInfo parsedAlbumInfo, int authorId, IEnumerable<int> bookIds) { - return new RemoteAlbum + return new RemoteBook { - ParsedAlbumInfo = parsedAlbumInfo, - Artist = _artistService.GetArtist(authorId), - Albums = _albumService.GetAlbums(bookIds) + ParsedBookInfo = parsedAlbumInfo, + Author = _authorService.GetAuthor(authorId), + Books = _bookService.GetBooks(bookIds) }; } - private Author GetArtist(ParsedAlbumInfo parsedAlbumInfo, SearchCriteriaBase searchCriteria) + private Author GetArtist(ParsedBookInfo parsedAlbumInfo, SearchCriteriaBase searchCriteria) { - Author artist = null; + Author author = null; if (searchCriteria != null) { - if (searchCriteria.Artist.CleanName == parsedAlbumInfo.ArtistName.CleanArtistName()) + if (searchCriteria.Author.CleanName == parsedAlbumInfo.AuthorName.CleanAuthorName()) { - return searchCriteria.Artist; + return searchCriteria.Author; } } - artist = _artistService.FindByName(parsedAlbumInfo.ArtistName); + author = _authorService.FindByName(parsedAlbumInfo.AuthorName); - if (artist == null) + if (author == null) { - _logger.Debug("Trying inexact artist match for {0}", parsedAlbumInfo.ArtistName); - artist = _artistService.FindByNameInexact(parsedAlbumInfo.ArtistName); + _logger.Debug("Trying inexact author match for {0}", parsedAlbumInfo.AuthorName); + author = _authorService.FindByNameInexact(parsedAlbumInfo.AuthorName); } - if (artist == null) + if (author == null) { - _logger.Debug("No matching artist {0}", parsedAlbumInfo.ArtistName); + _logger.Debug("No matching author {0}", parsedAlbumInfo.AuthorName); return null; } - return artist; + return author; } - public ParsedAlbumInfo ParseAlbumTitleFuzzy(string title) + public ParsedBookInfo ParseAlbumTitleFuzzy(string title) { var bestScore = 0.0; Author bestAuthor = null; Book bestBook = null; - var possibleAuthors = _artistService.GetReportCandidates(title); + var possibleAuthors = _authorService.GetReportCandidates(title); foreach (var author in possibleAuthors) { _logger.Trace($"Trying possible author {author}"); var authorMatch = title.FuzzyMatch(author.Metadata.Value.Name, 0.5); - var possibleBooks = _albumService.GetCandidates(author.AuthorMetadataId, title); + var possibleBooks = _bookService.GetCandidates(author.AuthorMetadataId, title); foreach (var book in possibleBooks) { @@ -257,19 +257,19 @@ namespace NzbDrone.Core.Parser return null; } - public Book GetLocalAlbum(string filename, Author artist) + public Book GetLocalAlbum(string filename, Author author) { if (Path.HasExtension(filename)) { filename = Path.GetDirectoryName(filename); } - var tracksInAlbum = _mediaFileService.GetFilesByArtist(artist.Id) + var tracksInAlbum = _mediaFileService.GetFilesByAuthor(author.Id) .FindAll(s => Path.GetDirectoryName(s.Path) == filename) .DistinctBy(s => s.BookId) .ToList(); - return tracksInAlbum.Count == 1 ? _albumService.GetAlbum(tracksInAlbum.First().BookId) : null; + return tracksInAlbum.Count == 1 ? _bookService.GetBook(tracksInAlbum.First().BookId) : null; } } } diff --git a/src/NzbDrone.Core/Parser/SceneChecker.cs b/src/NzbDrone.Core/Parser/SceneChecker.cs index 24220d1bd..f99d85afe 100644 --- a/src/NzbDrone.Core/Parser/SceneChecker.cs +++ b/src/NzbDrone.Core/Parser/SceneChecker.cs @@ -16,7 +16,7 @@ namespace NzbDrone.Core.Parser return false; } - var parsedTitle = Parser.ParseMusicTitle(title); + var parsedTitle = Parser.ParseTitle(title); if (parsedTitle == null || parsedTitle.ReleaseGroup == null || diff --git a/src/NzbDrone.Core/Profiles/Metadata/MetadataProfileService.cs b/src/NzbDrone.Core/Profiles/Metadata/MetadataProfileService.cs index 6730c9e06..e37ca809f 100644 --- a/src/NzbDrone.Core/Profiles/Metadata/MetadataProfileService.cs +++ b/src/NzbDrone.Core/Profiles/Metadata/MetadataProfileService.cs @@ -4,10 +4,10 @@ using System.Linq; using System.Text.RegularExpressions; using NLog; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.ImportLists; using NzbDrone.Core.Lifecycle; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; using NzbDrone.Core.RootFolders; namespace NzbDrone.Core.Profiles.Metadata @@ -30,19 +30,19 @@ namespace NzbDrone.Core.Profiles.Metadata private static readonly Regex PartOrSetRegex = new Regex(@"(?:\d+ of \d+|\d+/\d+|(?<from>\d+)-(?<to>\d+))"); private readonly IMetadataProfileRepository _profileRepository; - private readonly IArtistService _artistService; + private readonly IAuthorService _authorService; private readonly IImportListFactory _importListFactory; private readonly IRootFolderService _rootFolderService; private readonly Logger _logger; public MetadataProfileService(IMetadataProfileRepository profileRepository, - IArtistService artistService, + IAuthorService authorService, IImportListFactory importListFactory, IRootFolderService rootFolderService, Logger logger) { _profileRepository = profileRepository; - _artistService = artistService; + _authorService = authorService; _importListFactory = importListFactory; _rootFolderService = rootFolderService; _logger = logger; @@ -68,7 +68,7 @@ namespace NzbDrone.Core.Profiles.Metadata var profile = _profileRepository.Get(id); if (profile.Name == NONE_PROFILE_NAME || - _artistService.GetAllArtists().Any(c => c.MetadataProfileId == id) || + _authorService.GetAllAuthors().Any(c => c.MetadataProfileId == id) || _importListFactory.All().Any(c => c.MetadataProfileId == id) || _rootFolderService.All().Any(c => c.DefaultMetadataProfileId == id)) { diff --git a/src/NzbDrone.Core/Profiles/Qualities/QualityProfileService.cs b/src/NzbDrone.Core/Profiles/Qualities/QualityProfileService.cs index 5bee70b35..a130721dd 100644 --- a/src/NzbDrone.Core/Profiles/Qualities/QualityProfileService.cs +++ b/src/NzbDrone.Core/Profiles/Qualities/QualityProfileService.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; using System.Linq; using NLog; +using NzbDrone.Core.Books; using NzbDrone.Core.ImportLists; using NzbDrone.Core.Lifecycle; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; using NzbDrone.Core.Qualities; using NzbDrone.Core.RootFolders; @@ -24,19 +24,19 @@ namespace NzbDrone.Core.Profiles.Qualities public class QualityProfileService : IProfileService, IHandle<ApplicationStartedEvent> { private readonly IProfileRepository _profileRepository; - private readonly IArtistService _artistService; + private readonly IAuthorService _authorService; private readonly IImportListFactory _importListFactory; private readonly IRootFolderService _rootFolderService; private readonly Logger _logger; public QualityProfileService(IProfileRepository profileRepository, - IArtistService artistService, + IAuthorService authorService, IImportListFactory importListFactory, IRootFolderService rootFolderService, Logger logger) { _profileRepository = profileRepository; - _artistService = artistService; + _authorService = authorService; _importListFactory = importListFactory; _rootFolderService = rootFolderService; _logger = logger; @@ -54,7 +54,7 @@ namespace NzbDrone.Core.Profiles.Qualities public void Delete(int id) { - if (_artistService.GetAllArtists().Any(c => c.QualityProfileId == id) || + if (_authorService.GetAllAuthors().Any(c => c.QualityProfileId == id) || _importListFactory.All().Any(c => c.ProfileId == id) || _rootFolderService.All().Any(c => c.DefaultQualityProfileId == id)) { diff --git a/src/NzbDrone.Core/Profiles/Releases/PreferredWordService.cs b/src/NzbDrone.Core/Profiles/Releases/PreferredWordService.cs index ff2909d56..4cd695b46 100644 --- a/src/NzbDrone.Core/Profiles/Releases/PreferredWordService.cs +++ b/src/NzbDrone.Core/Profiles/Releases/PreferredWordService.cs @@ -2,14 +2,14 @@ using System.Collections.Generic; using System.Linq; using NLog; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; namespace NzbDrone.Core.Profiles.Releases { public interface IPreferredWordService { - int Calculate(Author artist, string title); - List<string> GetMatchingPreferredWords(Author artist, string title); + int Calculate(Author author, string title); + List<string> GetMatchingPreferredWords(Author author, string title); } public class PreferredWordService : IPreferredWordService @@ -52,9 +52,9 @@ namespace NzbDrone.Core.Profiles.Releases return score; } - public List<string> GetMatchingPreferredWords(Author artist, string title) + public List<string> GetMatchingPreferredWords(Author author, string title) { - var releaseProfiles = _releaseProfileService.AllForTags(artist.Tags); + var releaseProfiles = _releaseProfileService.AllForTags(author.Tags); var matchingPairs = new List<KeyValuePair<string, int>>(); _logger.Trace("Calculating preferred word score for '{0}'", title); diff --git a/src/NzbDrone.Core/Queue/Queue.cs b/src/NzbDrone.Core/Queue/Queue.cs index a509ae210..a8a3cfbc8 100644 --- a/src/NzbDrone.Core/Queue/Queue.cs +++ b/src/NzbDrone.Core/Queue/Queue.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.Indexers; -using NzbDrone.Core.Music; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; @@ -11,8 +11,8 @@ namespace NzbDrone.Core.Queue { public class Queue : ModelBase { - public Author Artist { get; set; } - public Book Album { get; set; } + public Author Author { get; set; } + public Book Book { get; set; } public QualityModel Quality { get; set; } public decimal Size { get; set; } public string Title { get; set; } @@ -24,7 +24,7 @@ namespace NzbDrone.Core.Queue public TrackedDownloadState? TrackedDownloadState { get; set; } public List<TrackedDownloadStatusMessage> StatusMessages { get; set; } public string DownloadId { get; set; } - public RemoteAlbum RemoteAlbum { get; set; } + public RemoteBook RemoteBook { get; set; } public DownloadProtocol Protocol { get; set; } public string DownloadClient { get; set; } public string Indexer { get; set; } diff --git a/src/NzbDrone.Core/Queue/QueueService.cs b/src/NzbDrone.Core/Queue/QueueService.cs index bdec36a37..95007fdbd 100644 --- a/src/NzbDrone.Core/Queue/QueueService.cs +++ b/src/NzbDrone.Core/Queue/QueueService.cs @@ -2,10 +2,10 @@ using System; using System.Collections.Generic; using System.Linq; using NzbDrone.Common.Crypto; +using NzbDrone.Core.Books; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.History; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; using NzbDrone.Core.Qualities; namespace NzbDrone.Core.Queue @@ -47,11 +47,11 @@ namespace NzbDrone.Core.Queue private IEnumerable<Queue> MapQueue(TrackedDownload trackedDownload) { - if (trackedDownload.RemoteAlbum?.Albums != null && trackedDownload.RemoteAlbum.Albums.Any()) + if (trackedDownload.RemoteBook?.Books != null && trackedDownload.RemoteBook.Books.Any()) { - foreach (var album in trackedDownload.RemoteAlbum.Albums) + foreach (var book in trackedDownload.RemoteBook.Books) { - yield return MapQueueItem(trackedDownload, album); + yield return MapQueueItem(trackedDownload, book); } } else @@ -60,7 +60,7 @@ namespace NzbDrone.Core.Queue } } - private Queue MapQueueItem(TrackedDownload trackedDownload, Book album) + private Queue MapQueueItem(TrackedDownload trackedDownload, Book book) { bool downloadForced = false; var history = _historyService.Find(trackedDownload.DownloadItem.DownloadId, HistoryEventType.Grabbed).FirstOrDefault(); @@ -71,9 +71,9 @@ namespace NzbDrone.Core.Queue var queue = new Queue { - Artist = trackedDownload.RemoteAlbum?.Artist, - Album = album, - Quality = trackedDownload.RemoteAlbum?.ParsedAlbumInfo.Quality ?? new QualityModel(Quality.Unknown), + Author = trackedDownload.RemoteBook?.Author, + Book = book, + Quality = trackedDownload.RemoteBook?.ParsedBookInfo.Quality ?? new QualityModel(Quality.Unknown), Title = Parser.Parser.RemoveFileExtension(trackedDownload.DownloadItem.Title), Size = trackedDownload.DownloadItem.TotalSize, Sizeleft = trackedDownload.DownloadItem.RemainingSize, @@ -83,7 +83,7 @@ namespace NzbDrone.Core.Queue TrackedDownloadState = trackedDownload.State, StatusMessages = trackedDownload.StatusMessages.ToList(), ErrorMessage = trackedDownload.DownloadItem.Message, - RemoteAlbum = trackedDownload.RemoteAlbum, + RemoteBook = trackedDownload.RemoteBook, DownloadId = trackedDownload.DownloadItem.DownloadId, Protocol = trackedDownload.Protocol, DownloadClient = trackedDownload.DownloadItem.DownloadClient, @@ -92,9 +92,9 @@ namespace NzbDrone.Core.Queue DownloadForced = downloadForced }; - if (album != null) + if (book != null) { - queue.Id = HashConverter.GetHashInt31(string.Format("trackedDownload-{0}-album{1}", trackedDownload.DownloadItem.DownloadId, album.Id)); + queue.Id = HashConverter.GetHashInt31(string.Format("trackedDownload-{0}-book{1}", trackedDownload.DownloadItem.DownloadId, book.Id)); } else { diff --git a/src/NzbDrone.Core/RootFolders/RootFolder.cs b/src/NzbDrone.Core/RootFolders/RootFolder.cs index 5daaa2451..cdc8c7947 100644 --- a/src/NzbDrone.Core/RootFolders/RootFolder.cs +++ b/src/NzbDrone.Core/RootFolders/RootFolder.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; +using NzbDrone.Core.Books; using NzbDrone.Core.Books.Calibre; using NzbDrone.Core.Datastore; -using NzbDrone.Core.Music; namespace NzbDrone.Core.RootFolders { diff --git a/src/NzbDrone.Core/Tags/TagService.cs b/src/NzbDrone.Core/Tags/TagService.cs index 37a4f2a92..b113ee01d 100644 --- a/src/NzbDrone.Core/Tags/TagService.cs +++ b/src/NzbDrone.Core/Tags/TagService.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using System.Linq; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.ImportLists; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; using NzbDrone.Core.Notifications; using NzbDrone.Core.Profiles.Delay; using NzbDrone.Core.Profiles.Releases; @@ -31,7 +31,7 @@ namespace NzbDrone.Core.Tags private readonly IImportListFactory _importListFactory; private readonly INotificationFactory _notificationFactory; private readonly IReleaseProfileService _releaseProfileService; - private readonly IArtistService _artistService; + private readonly IAuthorService _authorService; private readonly IRootFolderService _rootFolderService; public TagService(ITagRepository repo, @@ -40,7 +40,7 @@ namespace NzbDrone.Core.Tags ImportListFactory importListFactory, INotificationFactory notificationFactory, IReleaseProfileService releaseProfileService, - IArtistService artistService, + IAuthorService authorService, IRootFolderService rootFolderService) { _repo = repo; @@ -49,7 +49,7 @@ namespace NzbDrone.Core.Tags _importListFactory = importListFactory; _notificationFactory = notificationFactory; _releaseProfileService = releaseProfileService; - _artistService = artistService; + _authorService = authorService; _rootFolderService = rootFolderService; } @@ -77,7 +77,7 @@ namespace NzbDrone.Core.Tags var importLists = _importListFactory.AllForTag(tagId); var notifications = _notificationFactory.AllForTag(tagId); var restrictions = _releaseProfileService.AllForTag(tagId); - var artist = _artistService.AllForTag(tagId); + var author = _authorService.AllForTag(tagId); var rootFolders = _rootFolderService.AllForTag(tagId); return new TagDetails @@ -88,7 +88,7 @@ namespace NzbDrone.Core.Tags ImportListIds = importLists.Select(c => c.Id).ToList(), NotificationIds = notifications.Select(c => c.Id).ToList(), RestrictionIds = restrictions.Select(c => c.Id).ToList(), - AuthorIds = artist.Select(c => c.Id).ToList(), + AuthorIds = author.Select(c => c.Id).ToList(), RootFolderIds = rootFolders.Select(c => c.Id).ToList() }; } @@ -100,7 +100,7 @@ namespace NzbDrone.Core.Tags var importLists = _importListFactory.All(); var notifications = _notificationFactory.All(); var restrictions = _releaseProfileService.All(); - var artists = _artistService.GetAllArtists(); + var artists = _authorService.GetAllAuthors(); var rootFolders = _rootFolderService.All(); var details = new List<TagDetails>(); diff --git a/src/NzbDrone.Core/Validation/Paths/ArtistAncestorValidator.cs b/src/NzbDrone.Core/Validation/Paths/ArtistAncestorValidator.cs index fc4c73d7d..72905aaf5 100644 --- a/src/NzbDrone.Core/Validation/Paths/ArtistAncestorValidator.cs +++ b/src/NzbDrone.Core/Validation/Paths/ArtistAncestorValidator.cs @@ -1,18 +1,18 @@ using System.Linq; using FluentValidation.Validators; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; namespace NzbDrone.Core.Validation.Paths { - public class ArtistAncestorValidator : PropertyValidator + public class AuthorAncestorValidator : PropertyValidator { - private readonly IArtistService _artistService; + private readonly IAuthorService _authorService; - public ArtistAncestorValidator(IArtistService artistService) - : base("Path is an ancestor of an existing artist") + public AuthorAncestorValidator(IAuthorService authorService) + : base("Path is an ancestor of an existing author") { - _artistService = artistService; + _authorService = authorService; } protected override bool IsValid(PropertyValidatorContext context) @@ -22,7 +22,7 @@ namespace NzbDrone.Core.Validation.Paths return true; } - return !_artistService.GetAllArtists().Any(s => context.PropertyValue.ToString().IsParentPath(s.Path)); + return !_authorService.GetAllAuthors().Any(s => context.PropertyValue.ToString().IsParentPath(s.Path)); } } } diff --git a/src/NzbDrone.Core/Validation/Paths/ArtistExistsValidator.cs b/src/NzbDrone.Core/Validation/Paths/ArtistExistsValidator.cs index 7812f5ddc..f68bea0ee 100644 --- a/src/NzbDrone.Core/Validation/Paths/ArtistExistsValidator.cs +++ b/src/NzbDrone.Core/Validation/Paths/ArtistExistsValidator.cs @@ -1,16 +1,16 @@ using FluentValidation.Validators; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; namespace NzbDrone.Core.Validation.Paths { public class ArtistExistsValidator : PropertyValidator { - private readonly IArtistService _artistService; + private readonly IAuthorService _authorService; - public ArtistExistsValidator(IArtistService artistService) - : base("This artist has already been added.") + public ArtistExistsValidator(IAuthorService authorService) + : base("This author has already been added.") { - _artistService = artistService; + _authorService = authorService; } protected override bool IsValid(PropertyValidatorContext context) @@ -20,7 +20,7 @@ namespace NzbDrone.Core.Validation.Paths return true; } - return !_artistService.GetAllArtists().Exists(s => s.Metadata.Value.ForeignAuthorId == context.PropertyValue.ToString()); + return !_authorService.GetAllAuthors().Exists(s => s.Metadata.Value.ForeignAuthorId == context.PropertyValue.ToString()); } } } diff --git a/src/NzbDrone.Core/Validation/Paths/ArtistPathValidator.cs b/src/NzbDrone.Core/Validation/Paths/ArtistPathValidator.cs index accd36b03..463d0f1af 100644 --- a/src/NzbDrone.Core/Validation/Paths/ArtistPathValidator.cs +++ b/src/NzbDrone.Core/Validation/Paths/ArtistPathValidator.cs @@ -1,17 +1,17 @@ using FluentValidation.Validators; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; namespace NzbDrone.Core.Validation.Paths { - public class ArtistPathValidator : PropertyValidator + public class AuthorPathValidator : PropertyValidator { - private readonly IArtistService _artistService; + private readonly IAuthorService _authorService; - public ArtistPathValidator(IArtistService artistService) - : base("Path is already configured for another artist") + public AuthorPathValidator(IAuthorService authorService) + : base("Path is already configured for another author") { - _artistService = artistService; + _authorService = authorService; } protected override bool IsValid(PropertyValidatorContext context) @@ -24,7 +24,7 @@ namespace NzbDrone.Core.Validation.Paths dynamic instance = context.ParentContext.InstanceToValidate; var instanceId = (int)instance.Id; - return !_artistService.GetAllArtists().Exists(s => s.Path.PathEquals(context.PropertyValue.ToString()) && s.Id != instanceId); + return !_authorService.GetAllAuthors().Exists(s => s.Path.PathEquals(context.PropertyValue.ToString()) && s.Id != instanceId); } } } diff --git a/src/NzbDrone.Host.Test/ContainerFixture.cs b/src/NzbDrone.Host.Test/ContainerFixture.cs index af4383be3..d42c5c31f 100644 --- a/src/NzbDrone.Host.Test/ContainerFixture.cs +++ b/src/NzbDrone.Host.Test/ContainerFixture.cs @@ -89,7 +89,7 @@ namespace NzbDrone.App.Test [Test] public void should_return_same_instance_of_singletons_by_different_interfaces() { - var first = _container.ResolveAll<IHandle<AlbumGrabbedEvent>>().OfType<DownloadMonitoringService>().Single(); + var first = _container.ResolveAll<IHandle<BookGrabbedEvent>>().OfType<DownloadMonitoringService>().Single(); var second = (DownloadMonitoringService)_container.Resolve<IExecute<RefreshMonitoredDownloadsCommand>>(); first.Should().BeSameAs(second); diff --git a/src/NzbDrone.Integration.Test/ApiTests/NamingConfigFixture.cs b/src/NzbDrone.Integration.Test/ApiTests/NamingConfigFixture.cs index afdb65865..83ca65061 100644 --- a/src/NzbDrone.Integration.Test/ApiTests/NamingConfigFixture.cs +++ b/src/NzbDrone.Integration.Test/ApiTests/NamingConfigFixture.cs @@ -24,12 +24,12 @@ namespace NzbDrone.Integration.Test.ApiTests public void should_be_able_to_update() { var config = NamingConfig.GetSingle(); - config.RenameTracks = false; - config.StandardTrackFormat = "{Artist Name} - {Album Title} - {track:00} - {Track Title}"; + config.RenameBooks = false; + config.StandardBookFormat = "{Author Name} - {Book Title}"; var result = NamingConfig.Put(config); - result.RenameTracks.Should().BeFalse(); - result.StandardTrackFormat.Should().Be(config.StandardTrackFormat); + result.RenameBooks.Should().BeFalse(); + result.StandardBookFormat.Should().Be(config.StandardBookFormat); } [Test] @@ -38,8 +38,8 @@ namespace NzbDrone.Integration.Test.ApiTests IgnoreOnMonoVersions("5.12", "5.14"); var config = NamingConfig.GetSingle(); - config.RenameTracks = true; - config.StandardTrackFormat = ""; + config.RenameBooks = true; + config.StandardBookFormat = ""; var errors = NamingConfig.InvalidPut(config); errors.Should().NotBeNull(); @@ -51,8 +51,8 @@ namespace NzbDrone.Integration.Test.ApiTests IgnoreOnMonoVersions("5.12", "5.14"); var config = NamingConfig.GetSingle(); - config.RenameTracks = true; - config.StandardTrackFormat = "{track:00}"; + config.RenameBooks = true; + config.StandardBookFormat = "{track:00}"; var errors = NamingConfig.InvalidPut(config); errors.Should().NotBeNull(); @@ -64,8 +64,8 @@ namespace NzbDrone.Integration.Test.ApiTests IgnoreOnMonoVersions("5.12", "5.14"); var config = NamingConfig.GetSingle(); - config.RenameTracks = false; - config.StandardTrackFormat = ""; + config.RenameBooks = false; + config.StandardBookFormat = ""; var errors = NamingConfig.InvalidPut(config); errors.Should().NotBeNull(); @@ -77,8 +77,8 @@ namespace NzbDrone.Integration.Test.ApiTests IgnoreOnMonoVersions("5.12", "5.14"); var config = NamingConfig.GetSingle(); - config.RenameTracks = true; - config.StandardTrackFormat = ""; + config.RenameBooks = true; + config.StandardBookFormat = ""; var errors = NamingConfig.InvalidPut(config); errors.Should().NotBeNull(); @@ -90,7 +90,7 @@ namespace NzbDrone.Integration.Test.ApiTests IgnoreOnMonoVersions("5.12", "5.14"); var config = NamingConfig.GetSingle(); - config.RenameTracks = true; + config.RenameBooks = true; config.ArtistFolderFormat = "This and That"; var errors = NamingConfig.InvalidPut(config); diff --git a/src/NzbDrone.Integration.Test/ApiTests/WantedFixture.cs b/src/NzbDrone.Integration.Test/ApiTests/WantedFixture.cs index 7f0dce79c..f59870719 100644 --- a/src/NzbDrone.Integration.Test/ApiTests/WantedFixture.cs +++ b/src/NzbDrone.Integration.Test/ApiTests/WantedFixture.cs @@ -1,7 +1,7 @@ using System.Linq; using FluentAssertions; using NUnit.Framework; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Qualities; using Readarr.Api.V1.RootFolders; diff --git a/src/NzbDrone.Integration.Test/IntegrationTestBase.cs b/src/NzbDrone.Integration.Test/IntegrationTestBase.cs index f7186842e..d989e89f2 100644 --- a/src/NzbDrone.Integration.Test/IntegrationTestBase.cs +++ b/src/NzbDrone.Integration.Test/IntegrationTestBase.cs @@ -11,7 +11,7 @@ using NLog.Config; using NLog.Targets; using NUnit.Framework; using NzbDrone.Common.EnvironmentInfo; -using NzbDrone.Core.MediaFiles.TrackImport.Manual; +using NzbDrone.Core.MediaFiles.BookImport.Manual; using NzbDrone.Core.Qualities; using NzbDrone.Integration.Test.Client; using NzbDrone.SignalR; @@ -261,7 +261,7 @@ namespace NzbDrone.Integration.Test artist.MetadataProfileId = 1; artist.Path = Path.Combine(ArtistRootFolder, artist.ArtistName); artist.Monitored = true; - artist.AddOptions = new Core.Music.AddArtistOptions(); + artist.AddOptions = new Core.Books.AddAuthorOptions(); Directory.CreateDirectory(artist.Path); result = Artist.Post(artist); diff --git a/src/Readarr.Api.V1/AlbumStudio/AlbumStudioModule.cs b/src/Readarr.Api.V1/AlbumStudio/AlbumStudioModule.cs index f4c162d2c..5e5829311 100644 --- a/src/Readarr.Api.V1/AlbumStudio/AlbumStudioModule.cs +++ b/src/Readarr.Api.V1/AlbumStudio/AlbumStudioModule.cs @@ -1,19 +1,19 @@ using System.Linq; using Nancy; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using Readarr.Http.Extensions; namespace Readarr.Api.V1.AlbumStudio { public class AlbumStudioModule : ReadarrV1Module { - private readonly IArtistService _artistService; - private readonly IAlbumMonitoredService _albumMonitoredService; + private readonly IAuthorService _authorService; + private readonly IBookMonitoredService _albumMonitoredService; - public AlbumStudioModule(IArtistService artistService, IAlbumMonitoredService albumMonitoredService) + public AlbumStudioModule(IAuthorService authorService, IBookMonitoredService albumMonitoredService) : base("/albumstudio") { - _artistService = artistService; + _authorService = authorService; _albumMonitoredService = albumMonitoredService; Post("/", artist => UpdateAll()); } @@ -22,7 +22,7 @@ namespace Readarr.Api.V1.AlbumStudio { //Read from request var request = Request.Body.FromJson<AlbumStudioResource>(); - var artistToUpdate = _artistService.GetArtists(request.Artist.Select(s => s.Id)); + var artistToUpdate = _authorService.GetAuthors(request.Artist.Select(s => s.Id)); foreach (var s in request.Artist) { @@ -38,7 +38,7 @@ namespace Readarr.Api.V1.AlbumStudio artist.Monitored = false; } - _albumMonitoredService.SetAlbumMonitoredStatus(artist, request.MonitoringOptions); + _albumMonitoredService.SetBookMonitoredStatus(artist, request.MonitoringOptions); } return ResponseWithCode("ok", HttpStatusCode.Accepted); diff --git a/src/Readarr.Api.V1/AlbumStudio/AlbumStudioResource.cs b/src/Readarr.Api.V1/AlbumStudio/AlbumStudioResource.cs index fcfb87900..746606495 100644 --- a/src/Readarr.Api.V1/AlbumStudio/AlbumStudioResource.cs +++ b/src/Readarr.Api.V1/AlbumStudio/AlbumStudioResource.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; namespace Readarr.Api.V1.AlbumStudio { diff --git a/src/Readarr.Api.V1/Albums/AlbumLookupModule.cs b/src/Readarr.Api.V1/Albums/AlbumLookupModule.cs index 1ed6078cc..311f1ac27 100644 --- a/src/Readarr.Api.V1/Albums/AlbumLookupModule.cs +++ b/src/Readarr.Api.V1/Albums/AlbumLookupModule.cs @@ -24,7 +24,7 @@ namespace Readarr.Api.V1.Albums return MapToResource(searchResults).ToList(); } - private static IEnumerable<AlbumResource> MapToResource(IEnumerable<NzbDrone.Core.Music.Book> albums) + private static IEnumerable<AlbumResource> MapToResource(IEnumerable<NzbDrone.Core.Books.Book> albums) { foreach (var currentAlbum in albums) { diff --git a/src/Readarr.Api.V1/Albums/AlbumModule.cs b/src/Readarr.Api.V1/Albums/AlbumModule.cs index d3b9defce..5aa15c3d5 100644 --- a/src/Readarr.Api.V1/Albums/AlbumModule.cs +++ b/src/Readarr.Api.V1/Albums/AlbumModule.cs @@ -4,7 +4,9 @@ using System.Linq; using FluentValidation; using Nancy; using NzbDrone.Common.Extensions; -using NzbDrone.Core.ArtistStats; +using NzbDrone.Core.AuthorStats; +using NzbDrone.Core.Books; +using NzbDrone.Core.Books.Events; using NzbDrone.Core.Datastore.Events; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Download; @@ -12,8 +14,6 @@ using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; -using NzbDrone.Core.Music.Events; using NzbDrone.Core.Validation; using NzbDrone.Core.Validation.Paths; using NzbDrone.SignalR; @@ -22,30 +22,30 @@ using Readarr.Http.Extensions; namespace Readarr.Api.V1.Albums { public class AlbumModule : AlbumModuleWithSignalR, - IHandle<AlbumGrabbedEvent>, - IHandle<AlbumEditedEvent>, - IHandle<AlbumUpdatedEvent>, - IHandle<AlbumImportedEvent>, + IHandle<BookGrabbedEvent>, + IHandle<BookEditedEvent>, + IHandle<BookUpdatedEvent>, + IHandle<BookImportedEvent>, IHandle<TrackImportedEvent>, - IHandle<TrackFileDeletedEvent> + IHandle<BookFileDeletedEvent> { - protected readonly IArtistService _artistService; - protected readonly IAddAlbumService _addAlbumService; + protected readonly IAuthorService _authorService; + protected readonly IAddBookService _addBookService; - public AlbumModule(IArtistService artistService, - IAlbumService albumService, - IAddAlbumService addAlbumService, - IArtistStatisticsService artistStatisticsService, + public AlbumModule(IAuthorService authorService, + IBookService bookService, + IAddBookService addBookService, + IAuthorStatisticsService artistStatisticsService, IMapCoversToLocal coverMapper, IUpgradableSpecification upgradableSpecification, IBroadcastSignalRMessage signalRBroadcaster, QualityProfileExistsValidator qualityProfileExistsValidator, MetadataProfileExistsValidator metadataProfileExistsValidator) - : base(albumService, artistStatisticsService, coverMapper, upgradableSpecification, signalRBroadcaster) + : base(bookService, artistStatisticsService, coverMapper, upgradableSpecification, signalRBroadcaster) { - _artistService = artistService; - _addAlbumService = addAlbumService; + _authorService = authorService; + _addBookService = addBookService; GetResourceAll = GetAlbums; CreateResource = AddAlbum; @@ -69,9 +69,9 @@ namespace Readarr.Api.V1.Albums if (!Request.Query.AuthorId.HasValue && !bookIdsQuery.HasValue && !slugQuery.HasValue) { - var albums = _albumService.GetAllAlbums(); + var albums = _bookService.GetAllBooks(); - var artists = _artistService.GetAllArtists().ToDictionary(x => x.AuthorMetadataId); + var artists = _authorService.GetAllAuthors().ToDictionary(x => x.AuthorMetadataId); foreach (var album in albums) { @@ -85,14 +85,14 @@ namespace Readarr.Api.V1.Albums { int authorId = Convert.ToInt32(authorIdQuery.Value); - return MapToResource(_albumService.GetAlbumsByArtist(authorId), false); + return MapToResource(_bookService.GetBooksByAuthor(authorId), false); } if (slugQuery.HasValue) { string titleSlug = slugQuery.Value.ToString(); - var album = _albumService.FindBySlug(titleSlug); + var album = _bookService.FindBySlug(titleSlug); if (album == null) { @@ -101,7 +101,7 @@ namespace Readarr.Api.V1.Albums if (includeAllArtistAlbumsQuery.HasValue && Convert.ToBoolean(includeAllArtistAlbumsQuery.Value)) { - return MapToResource(_albumService.GetAlbumsByArtist(album.AuthorId), false); + return MapToResource(_bookService.GetBooksByAuthor(album.AuthorId), false); } else { @@ -115,23 +115,23 @@ namespace Readarr.Api.V1.Albums .Select(e => Convert.ToInt32(e)) .ToList(); - return MapToResource(_albumService.GetAlbums(bookIds), false); + return MapToResource(_bookService.GetBooks(bookIds), false); } private int AddAlbum(AlbumResource albumResource) { - var album = _addAlbumService.AddAlbum(albumResource.ToModel()); + var album = _addBookService.AddBook(albumResource.ToModel()); return album.Id; } private void UpdateAlbum(AlbumResource albumResource) { - var album = _albumService.GetAlbum(albumResource.Id); + var album = _bookService.GetBook(albumResource.Id); var model = albumResource.ToModel(album); - _albumService.UpdateAlbum(model); + _bookService.UpdateBook(model); BroadcastResourceChange(ModelAction.Updated, model.Id); } @@ -141,21 +141,21 @@ namespace Readarr.Api.V1.Albums var deleteFiles = Request.GetBooleanQueryParameter("deleteFiles"); var addImportListExclusion = Request.GetBooleanQueryParameter("addImportListExclusion"); - _albumService.DeleteAlbum(id, deleteFiles, addImportListExclusion); + _bookService.DeleteBook(id, deleteFiles, addImportListExclusion); } private object SetAlbumsMonitored() { var resource = Request.Body.FromJson<AlbumsMonitoredResource>(); - _albumService.SetMonitored(resource.BookIds, resource.Monitored); + _bookService.SetMonitored(resource.BookIds, resource.Monitored); - return ResponseWithCode(MapToResource(_albumService.GetAlbums(resource.BookIds), false), HttpStatusCode.Accepted); + return ResponseWithCode(MapToResource(_bookService.GetBooks(resource.BookIds), false), HttpStatusCode.Accepted); } - public void Handle(AlbumGrabbedEvent message) + public void Handle(BookGrabbedEvent message) { - foreach (var album in message.Album.Albums) + foreach (var album in message.Book.Books) { var resource = album.ToResource(); resource.Grabbed = true; @@ -164,39 +164,39 @@ namespace Readarr.Api.V1.Albums } } - public void Handle(AlbumEditedEvent message) + public void Handle(BookEditedEvent message) { BroadcastResourceChange(ModelAction.Updated, MapToResource(message.Album, true)); } - public void Handle(AlbumUpdatedEvent message) + public void Handle(BookUpdatedEvent message) { - BroadcastResourceChange(ModelAction.Updated, MapToResource(message.Album, true)); + BroadcastResourceChange(ModelAction.Updated, MapToResource(message.Book, true)); } - public void Handle(AlbumDeletedEvent message) + public void Handle(BookDeletedEvent message) { - BroadcastResourceChange(ModelAction.Deleted, message.Album.ToResource()); + BroadcastResourceChange(ModelAction.Deleted, message.Book.ToResource()); } - public void Handle(AlbumImportedEvent message) + public void Handle(BookImportedEvent message) { - BroadcastResourceChange(ModelAction.Updated, MapToResource(message.Album, true)); + BroadcastResourceChange(ModelAction.Updated, MapToResource(message.Book, true)); } public void Handle(TrackImportedEvent message) { - BroadcastResourceChange(ModelAction.Updated, message.TrackInfo.Album.ToResource()); + BroadcastResourceChange(ModelAction.Updated, message.BookInfo.Book.ToResource()); } - public void Handle(TrackFileDeletedEvent message) + public void Handle(BookFileDeletedEvent message) { if (message.Reason == DeleteMediaFileReason.Upgrade) { return; } - BroadcastResourceChange(ModelAction.Updated, MapToResource(message.TrackFile.Album.Value, true)); + BroadcastResourceChange(ModelAction.Updated, MapToResource(message.BookFile.Book.Value, true)); } } } diff --git a/src/Readarr.Api.V1/Albums/AlbumModuleWithSignalR.cs b/src/Readarr.Api.V1/Albums/AlbumModuleWithSignalR.cs index 21331cee3..e492e0ac3 100644 --- a/src/Readarr.Api.V1/Albums/AlbumModuleWithSignalR.cs +++ b/src/Readarr.Api.V1/Albums/AlbumModuleWithSignalR.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; using System.Linq; using NzbDrone.Common.Extensions; -using NzbDrone.Core.ArtistStats; +using NzbDrone.Core.AuthorStats; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.MediaCover; -using NzbDrone.Core.Music; using NzbDrone.SignalR; using Readarr.Api.V1.Artist; using Readarr.Http; @@ -13,19 +13,19 @@ namespace Readarr.Api.V1.Albums { public abstract class AlbumModuleWithSignalR : ReadarrRestModuleWithSignalR<AlbumResource, Book> { - protected readonly IAlbumService _albumService; - protected readonly IArtistStatisticsService _artistStatisticsService; + protected readonly IBookService _bookService; + protected readonly IAuthorStatisticsService _artistStatisticsService; protected readonly IUpgradableSpecification _qualityUpgradableSpecification; protected readonly IMapCoversToLocal _coverMapper; - protected AlbumModuleWithSignalR(IAlbumService albumService, - IArtistStatisticsService artistStatisticsService, + protected AlbumModuleWithSignalR(IBookService bookService, + IAuthorStatisticsService artistStatisticsService, IMapCoversToLocal coverMapper, IUpgradableSpecification qualityUpgradableSpecification, IBroadcastSignalRMessage signalRBroadcaster) : base(signalRBroadcaster) { - _albumService = albumService; + _bookService = bookService; _artistStatisticsService = artistStatisticsService; _coverMapper = coverMapper; _qualityUpgradableSpecification = qualityUpgradableSpecification; @@ -33,15 +33,15 @@ namespace Readarr.Api.V1.Albums GetResourceById = GetAlbum; } - protected AlbumModuleWithSignalR(IAlbumService albumService, - IArtistStatisticsService artistStatisticsService, + protected AlbumModuleWithSignalR(IBookService bookService, + IAuthorStatisticsService artistStatisticsService, IMapCoversToLocal coverMapper, IUpgradableSpecification qualityUpgradableSpecification, IBroadcastSignalRMessage signalRBroadcaster, string resource) : base(signalRBroadcaster, resource) { - _albumService = albumService; + _bookService = bookService; _artistStatisticsService = artistStatisticsService; _coverMapper = coverMapper; _qualityUpgradableSpecification = qualityUpgradableSpecification; @@ -51,7 +51,7 @@ namespace Readarr.Api.V1.Albums protected AlbumResource GetAlbum(int id) { - var album = _albumService.GetAlbum(id); + var album = _bookService.GetBook(id); var resource = MapToResource(album, true); return resource; } @@ -79,7 +79,7 @@ namespace Readarr.Api.V1.Albums if (includeArtist) { - var artistDict = new Dictionary<int, NzbDrone.Core.Music.Author>(); + var artistDict = new Dictionary<int, NzbDrone.Core.Books.Author>(); for (var i = 0; i < albums.Count; i++) { var album = albums[i]; @@ -91,7 +91,7 @@ namespace Readarr.Api.V1.Albums } } - var artistStats = _artistStatisticsService.ArtistStatistics(); + var artistStats = _artistStatisticsService.AuthorStatistics(); LinkArtistStatistics(result, artistStats); MapCoversToLocal(result.ToArray()); @@ -100,10 +100,10 @@ namespace Readarr.Api.V1.Albums private void FetchAndLinkAlbumStatistics(AlbumResource resource) { - LinkArtistStatistics(resource, _artistStatisticsService.ArtistStatistics(resource.AuthorId)); + LinkArtistStatistics(resource, _artistStatisticsService.AuthorStatistics(resource.AuthorId)); } - private void LinkArtistStatistics(List<AlbumResource> resources, List<ArtistStatistics> artistStatistics) + private void LinkArtistStatistics(List<AlbumResource> resources, List<AuthorStatistics> artistStatistics) { foreach (var album in resources) { @@ -112,11 +112,11 @@ namespace Readarr.Api.V1.Albums } } - private void LinkArtistStatistics(AlbumResource resource, ArtistStatistics artistStatistics) + private void LinkArtistStatistics(AlbumResource resource, AuthorStatistics artistStatistics) { - if (artistStatistics?.AlbumStatistics != null) + if (artistStatistics?.BookStatistics != null) { - var dictAlbumStats = artistStatistics.AlbumStatistics.ToDictionary(v => v.BookId); + var dictAlbumStats = artistStatistics.BookStatistics.ToDictionary(v => v.BookId); resource.Statistics = dictAlbumStats.GetValueOrDefault(resource.Id).ToResource(); } @@ -126,7 +126,7 @@ namespace Readarr.Api.V1.Albums { foreach (var albumResource in albums) { - _coverMapper.ConvertToLocalUrls(albumResource.Id, MediaCoverEntity.Album, albumResource.Images); + _coverMapper.ConvertToLocalUrls(albumResource.Id, MediaCoverEntity.Book, albumResource.Images); } } } diff --git a/src/Readarr.Api.V1/Albums/AlbumResource.cs b/src/Readarr.Api.V1/Albums/AlbumResource.cs index 6f9d2836c..30491ce2f 100644 --- a/src/Readarr.Api.V1/Albums/AlbumResource.cs +++ b/src/Readarr.Api.V1/Albums/AlbumResource.cs @@ -2,8 +2,8 @@ using System; using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; +using NzbDrone.Core.Books; using NzbDrone.Core.MediaCover; -using NzbDrone.Core.Music; using Readarr.Api.V1.Artist; using Readarr.Api.V1.TrackFiles; using Readarr.Http.REST; @@ -31,7 +31,7 @@ namespace Readarr.Api.V1.Albums public List<MediaCover> Images { get; set; } public List<Links> Links { get; set; } public AlbumStatisticsResource Statistics { get; set; } - public AddAlbumOptions AddOptions { get; set; } + public AddBookOptions AddOptions { get; set; } public string RemoteCover { get; set; } //Hiding this so people don't think its usable (only used to set the initial state) @@ -79,7 +79,7 @@ namespace Readarr.Api.V1.Albums return null; } - var artist = resource.Artist?.ToModel() ?? new NzbDrone.Core.Music.Author(); + var artist = resource.Artist?.ToModel() ?? new NzbDrone.Core.Books.Author(); return new Book { diff --git a/src/Readarr.Api.V1/Albums/AlbumStatisticsResource.cs b/src/Readarr.Api.V1/Albums/AlbumStatisticsResource.cs index cc42aab48..b7c96f72f 100644 --- a/src/Readarr.Api.V1/Albums/AlbumStatisticsResource.cs +++ b/src/Readarr.Api.V1/Albums/AlbumStatisticsResource.cs @@ -1,4 +1,4 @@ -using NzbDrone.Core.ArtistStats; +using NzbDrone.Core.AuthorStats; namespace Readarr.Api.V1.Albums { @@ -25,7 +25,7 @@ namespace Readarr.Api.V1.Albums public static class AlbumStatisticsResourceMapper { - public static AlbumStatisticsResource ToResource(this AlbumStatistics model) + public static AlbumStatisticsResource ToResource(this BookStatistics model) { if (model == null) { @@ -34,9 +34,8 @@ namespace Readarr.Api.V1.Albums return new AlbumStatisticsResource { - TrackFileCount = model.TrackFileCount, - TrackCount = model.TrackCount, - TotalTrackCount = model.TotalTrackCount, + TrackFileCount = model.BookFileCount, + TrackCount = model.BookCount, SizeOnDisk = model.SizeOnDisk }; } diff --git a/src/Readarr.Api.V1/Albums/RenameBookResource.cs b/src/Readarr.Api.V1/Albums/RenameBookResource.cs index 3d6b67a1c..95dde854b 100644 --- a/src/Readarr.Api.V1/Albums/RenameBookResource.cs +++ b/src/Readarr.Api.V1/Albums/RenameBookResource.cs @@ -15,7 +15,7 @@ namespace Readarr.Api.V1.Albums public static class RenameTrackResourceMapper { - public static RenameTrackResource ToResource(this NzbDrone.Core.MediaFiles.RenameTrackFilePreview model) + public static RenameTrackResource ToResource(this NzbDrone.Core.MediaFiles.RenameBookFilePreview model) { if (model == null) { @@ -26,13 +26,13 @@ namespace Readarr.Api.V1.Albums { AuthorId = model.AuthorId, BookId = model.BookId, - TrackFileId = model.TrackFileId, + TrackFileId = model.BookFileId, ExistingPath = model.ExistingPath, NewPath = model.NewPath }; } - public static List<RenameTrackResource> ToResource(this IEnumerable<NzbDrone.Core.MediaFiles.RenameTrackFilePreview> models) + public static List<RenameTrackResource> ToResource(this IEnumerable<NzbDrone.Core.MediaFiles.RenameBookFilePreview> models) { return models.Select(ToResource).ToList(); } diff --git a/src/Readarr.Api.V1/Albums/RetagBookResource.cs b/src/Readarr.Api.V1/Albums/RetagBookResource.cs index 52cef0906..d13e74396 100644 --- a/src/Readarr.Api.V1/Albums/RetagBookResource.cs +++ b/src/Readarr.Api.V1/Albums/RetagBookResource.cs @@ -23,7 +23,7 @@ namespace Readarr.Api.V1.Albums public static class RetagTrackResourceMapper { - public static RetagTrackResource ToResource(this NzbDrone.Core.MediaFiles.RetagTrackFilePreview model) + public static RetagTrackResource ToResource(this NzbDrone.Core.MediaFiles.RetagBookFilePreview model) { if (model == null) { @@ -35,7 +35,7 @@ namespace Readarr.Api.V1.Albums AuthorId = model.AuthorId, BookId = model.BookId, TrackNumbers = model.TrackNumbers.ToList(), - TrackFileId = model.TrackFileId, + TrackFileId = model.BookFileId, Path = model.Path, Changes = model.Changes.Select(x => new TagDifference { @@ -46,7 +46,7 @@ namespace Readarr.Api.V1.Albums }; } - public static List<RetagTrackResource> ToResource(this IEnumerable<NzbDrone.Core.MediaFiles.RetagTrackFilePreview> models) + public static List<RetagTrackResource> ToResource(this IEnumerable<NzbDrone.Core.MediaFiles.RetagBookFilePreview> models) { return models.Select(ToResource).ToList(); } diff --git a/src/Readarr.Api.V1/Artist/ArtistEditorModule.cs b/src/Readarr.Api.V1/Artist/ArtistEditorModule.cs index 6463d5ce5..3b9e7b354 100644 --- a/src/Readarr.Api.V1/Artist/ArtistEditorModule.cs +++ b/src/Readarr.Api.V1/Artist/ArtistEditorModule.cs @@ -2,22 +2,22 @@ using System.Collections.Generic; using System.Linq; using Nancy; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; +using NzbDrone.Core.Books.Commands; using NzbDrone.Core.Messaging.Commands; -using NzbDrone.Core.Music; -using NzbDrone.Core.Music.Commands; using Readarr.Http.Extensions; namespace Readarr.Api.V1.Artist { public class ArtistEditorModule : ReadarrV1Module { - private readonly IArtistService _artistService; + private readonly IAuthorService _authorService; private readonly IManageCommandQueue _commandQueueManager; - public ArtistEditorModule(IArtistService artistService, IManageCommandQueue commandQueueManager) + public ArtistEditorModule(IAuthorService authorService, IManageCommandQueue commandQueueManager) : base("/artist/editor") { - _artistService = artistService; + _authorService = authorService; _commandQueueManager = commandQueueManager; Put("/", artist => SaveAll()); Delete("/", artist => DeleteArtist()); @@ -26,8 +26,8 @@ namespace Readarr.Api.V1.Artist private object SaveAll() { var resource = Request.Body.FromJson<ArtistEditorResource>(); - var artistToUpdate = _artistService.GetArtists(resource.AuthorIds); - var artistToMove = new List<BulkMoveArtist>(); + var artistToUpdate = _authorService.GetAuthors(resource.AuthorIds); + var artistToMove = new List<BulkMoveAuthor>(); foreach (var artist in artistToUpdate) { @@ -49,7 +49,7 @@ namespace Readarr.Api.V1.Artist if (resource.RootFolderPath.IsNotNullOrWhiteSpace()) { artist.RootFolderPath = resource.RootFolderPath; - artistToMove.Add(new BulkMoveArtist + artistToMove.Add(new BulkMoveAuthor { AuthorId = artist.Id, SourcePath = artist.Path @@ -78,14 +78,14 @@ namespace Readarr.Api.V1.Artist if (resource.MoveFiles && artistToMove.Any()) { - _commandQueueManager.Push(new BulkMoveArtistCommand + _commandQueueManager.Push(new BulkMoveAuthorCommand { DestinationRootFolder = resource.RootFolderPath, - Artist = artistToMove + Author = artistToMove }); } - return ResponseWithCode(_artistService.UpdateArtists(artistToUpdate, !resource.MoveFiles) + return ResponseWithCode(_authorService.UpdateAuthors(artistToUpdate, !resource.MoveFiles) .ToResource(), HttpStatusCode.Accepted); } @@ -96,7 +96,7 @@ namespace Readarr.Api.V1.Artist foreach (var authorId in resource.AuthorIds) { - _artistService.DeleteArtist(authorId, false); + _authorService.DeleteAuthor(authorId, false); } return new object(); diff --git a/src/Readarr.Api.V1/Artist/ArtistImportModule.cs b/src/Readarr.Api.V1/Artist/ArtistImportModule.cs index 2ab0f9bd8..e8d5249d6 100644 --- a/src/Readarr.Api.V1/Artist/ArtistImportModule.cs +++ b/src/Readarr.Api.V1/Artist/ArtistImportModule.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using Nancy; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using Readarr.Http; using Readarr.Http.Extensions; @@ -8,12 +8,12 @@ namespace Readarr.Api.V1.Artist { public class ArtistImportModule : ReadarrRestModule<ArtistResource> { - private readonly IAddArtistService _addArtistService; + private readonly IAddAuthorService _addAuthorService; - public ArtistImportModule(IAddArtistService addArtistService) + public ArtistImportModule(IAddAuthorService addAuthorService) : base("/artist/import") { - _addArtistService = addArtistService; + _addAuthorService = addAuthorService; Post("/", x => Import()); } @@ -22,7 +22,7 @@ namespace Readarr.Api.V1.Artist var resource = Request.Body.FromJson<List<ArtistResource>>(); var newArtists = resource.ToModel(); - return _addArtistService.AddArtists(newArtists).ToResource(); + return _addAuthorService.AddAuthors(newArtists).ToResource(); } } } diff --git a/src/Readarr.Api.V1/Artist/ArtistLookupModule.cs b/src/Readarr.Api.V1/Artist/ArtistLookupModule.cs index a606f2925..73a9a3309 100644 --- a/src/Readarr.Api.V1/Artist/ArtistLookupModule.cs +++ b/src/Readarr.Api.V1/Artist/ArtistLookupModule.cs @@ -24,7 +24,7 @@ namespace Readarr.Api.V1.Artist return MapToResource(searchResults).ToList(); } - private static IEnumerable<ArtistResource> MapToResource(IEnumerable<NzbDrone.Core.Music.Author> artist) + private static IEnumerable<ArtistResource> MapToResource(IEnumerable<NzbDrone.Core.Books.Author> artist) { foreach (var currentArtist in artist) { diff --git a/src/Readarr.Api.V1/Artist/ArtistModule.cs b/src/Readarr.Api.V1/Artist/ArtistModule.cs index f84cbdbd2..7bce63dd3 100644 --- a/src/Readarr.Api.V1/Artist/ArtistModule.cs +++ b/src/Readarr.Api.V1/Artist/ArtistModule.cs @@ -2,16 +2,16 @@ using System.Collections.Generic; using System.Linq; using FluentValidation; using NzbDrone.Common.Extensions; -using NzbDrone.Core.ArtistStats; +using NzbDrone.Core.AuthorStats; +using NzbDrone.Core.Books; +using NzbDrone.Core.Books.Commands; +using NzbDrone.Core.Books.Events; using NzbDrone.Core.Datastore.Events; using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; -using NzbDrone.Core.Music.Commands; -using NzbDrone.Core.Music.Events; using NzbDrone.Core.RootFolders; using NzbDrone.Core.Validation; using NzbDrone.Core.Validation.Paths; @@ -21,45 +21,45 @@ using Readarr.Http.Extensions; namespace Readarr.Api.V1.Artist { - public class ArtistModule : ReadarrRestModuleWithSignalR<ArtistResource, NzbDrone.Core.Music.Author>, - IHandle<AlbumImportedEvent>, - IHandle<AlbumEditedEvent>, - IHandle<TrackFileDeletedEvent>, - IHandle<ArtistUpdatedEvent>, - IHandle<ArtistEditedEvent>, - IHandle<ArtistDeletedEvent>, - IHandle<ArtistRenamedEvent>, + public class ArtistModule : ReadarrRestModuleWithSignalR<ArtistResource, NzbDrone.Core.Books.Author>, + IHandle<BookImportedEvent>, + IHandle<BookEditedEvent>, + IHandle<BookFileDeletedEvent>, + IHandle<AuthorUpdatedEvent>, + IHandle<AuthorEditedEvent>, + IHandle<AuthorDeletedEvent>, + IHandle<AuthorRenamedEvent>, IHandle<MediaCoversUpdatedEvent> { - private readonly IArtistService _artistService; - private readonly IAlbumService _albumService; - private readonly IAddArtistService _addArtistService; - private readonly IArtistStatisticsService _artistStatisticsService; + private readonly IAuthorService _authorService; + private readonly IBookService _bookService; + private readonly IAddAuthorService _addAuthorService; + private readonly IAuthorStatisticsService _artistStatisticsService; private readonly IMapCoversToLocal _coverMapper; private readonly IManageCommandQueue _commandQueueManager; private readonly IRootFolderService _rootFolderService; public ArtistModule(IBroadcastSignalRMessage signalRBroadcaster, - IArtistService artistService, - IAlbumService albumService, - IAddArtistService addArtistService, - IArtistStatisticsService artistStatisticsService, + IAuthorService authorService, + IBookService bookService, + IAddAuthorService addAuthorService, + IAuthorStatisticsService artistStatisticsService, IMapCoversToLocal coverMapper, IManageCommandQueue commandQueueManager, IRootFolderService rootFolderService, RootFolderValidator rootFolderValidator, MappedNetworkDriveValidator mappedNetworkDriveValidator, - ArtistPathValidator artistPathValidator, + AuthorPathValidator artistPathValidator, ArtistExistsValidator artistExistsValidator, - ArtistAncestorValidator artistAncestorValidator, + AuthorAncestorValidator artistAncestorValidator, SystemFolderValidator systemFolderValidator, QualityProfileExistsValidator qualityProfileExistsValidator, MetadataProfileExistsValidator metadataProfileExistsValidator) : base(signalRBroadcaster) { - _artistService = artistService; - _albumService = albumService; - _addArtistService = addArtistService; + _authorService = authorService; + _bookService = bookService; + _addAuthorService = addAuthorService; _artistStatisticsService = artistStatisticsService; _coverMapper = coverMapper; @@ -98,11 +98,11 @@ namespace Readarr.Api.V1.Artist private ArtistResource GetArtist(int id) { - var artist = _artistService.GetArtist(id); + var artist = _authorService.GetAuthor(id); return GetArtistResource(artist); } - private ArtistResource GetArtistResource(NzbDrone.Core.Music.Author artist) + private ArtistResource GetArtistResource(NzbDrone.Core.Books.Author artist) { if (artist == null) { @@ -122,8 +122,8 @@ namespace Readarr.Api.V1.Artist private List<ArtistResource> AllArtists() { - var artistStats = _artistStatisticsService.ArtistStatistics(); - var artistsResources = _artistService.GetAllArtists().ToResource(); + var artistStats = _artistStatisticsService.AuthorStatistics(); + var artistsResources = _authorService.GetAllAuthors().ToResource(); MapCoversToLocal(artistsResources.ToArray()); LinkNextPreviousAlbums(artistsResources.ToArray()); @@ -135,7 +135,7 @@ namespace Readarr.Api.V1.Artist private int AddArtist(ArtistResource artistResource) { - var artist = _addArtistService.AddArtist(artistResource.ToModel()); + var artist = _addAuthorService.AddAuthor(artistResource.ToModel()); return artist.Id; } @@ -143,14 +143,14 @@ namespace Readarr.Api.V1.Artist private void UpdateArtist(ArtistResource artistResource) { var moveFiles = Request.GetBooleanQueryParameter("moveFiles"); - var artist = _artistService.GetArtist(artistResource.Id); + var artist = _authorService.GetAuthor(artistResource.Id); if (moveFiles) { var sourcePath = artist.Path; var destinationPath = artistResource.Path; - _commandQueueManager.Push(new MoveArtistCommand + _commandQueueManager.Push(new MoveAuthorCommand { AuthorId = artist.Id, SourcePath = sourcePath, @@ -161,7 +161,7 @@ namespace Readarr.Api.V1.Artist var model = artistResource.ToModel(artist); - _artistService.UpdateArtist(model); + _authorService.UpdateAuthor(model); BroadcastResourceChange(ModelAction.Updated, artistResource); } @@ -171,21 +171,21 @@ namespace Readarr.Api.V1.Artist var deleteFiles = Request.GetBooleanQueryParameter("deleteFiles"); var addImportListExclusion = Request.GetBooleanQueryParameter("addImportListExclusion"); - _artistService.DeleteArtist(id, deleteFiles, addImportListExclusion); + _authorService.DeleteAuthor(id, deleteFiles, addImportListExclusion); } private void MapCoversToLocal(params ArtistResource[] artists) { foreach (var artistResource in artists) { - _coverMapper.ConvertToLocalUrls(artistResource.Id, MediaCoverEntity.Artist, artistResource.Images); + _coverMapper.ConvertToLocalUrls(artistResource.Id, MediaCoverEntity.Author, artistResource.Images); } } private void LinkNextPreviousAlbums(params ArtistResource[] artists) { - var nextAlbums = _albumService.GetNextAlbumsByArtistMetadataId(artists.Select(x => x.ArtistMetadataId)); - var lastAlbums = _albumService.GetLastAlbumsByArtistMetadataId(artists.Select(x => x.ArtistMetadataId)); + var nextAlbums = _bookService.GetNextBooksByAuthorMetadataId(artists.Select(x => x.ArtistMetadataId)); + var lastAlbums = _bookService.GetLastBooksByAuthorMetadataId(artists.Select(x => x.ArtistMetadataId)); foreach (var artistResource in artists) { @@ -196,10 +196,10 @@ namespace Readarr.Api.V1.Artist private void FetchAndLinkArtistStatistics(ArtistResource resource) { - LinkArtistStatistics(resource, _artistStatisticsService.ArtistStatistics(resource.Id)); + LinkArtistStatistics(resource, _artistStatisticsService.AuthorStatistics(resource.Id)); } - private void LinkArtistStatistics(List<ArtistResource> resources, List<ArtistStatistics> artistStatistics) + private void LinkArtistStatistics(List<ArtistResource> resources, List<AuthorStatistics> artistStatistics) { foreach (var artist in resources) { @@ -213,7 +213,7 @@ namespace Readarr.Api.V1.Artist } } - private void LinkArtistStatistics(ArtistResource resource, ArtistStatistics artistStatistics) + private void LinkArtistStatistics(ArtistResource resource, AuthorStatistics artistStatistics) { resource.Statistics = artistStatistics.ToResource(); } @@ -239,49 +239,49 @@ namespace Readarr.Api.V1.Artist resource.RootFolderPath = _rootFolderService.GetBestRootFolderPath(resource.Path); } - public void Handle(AlbumImportedEvent message) + public void Handle(BookImportedEvent message) { - BroadcastResourceChange(ModelAction.Updated, GetArtistResource(message.Artist)); + BroadcastResourceChange(ModelAction.Updated, GetArtistResource(message.Author)); } - public void Handle(AlbumEditedEvent message) + public void Handle(BookEditedEvent message) { BroadcastResourceChange(ModelAction.Updated, GetArtistResource(message.Album.Author.Value)); } - public void Handle(TrackFileDeletedEvent message) + public void Handle(BookFileDeletedEvent message) { if (message.Reason == DeleteMediaFileReason.Upgrade) { return; } - BroadcastResourceChange(ModelAction.Updated, GetArtistResource(message.TrackFile.Artist.Value)); + BroadcastResourceChange(ModelAction.Updated, GetArtistResource(message.BookFile.Author.Value)); } - public void Handle(ArtistUpdatedEvent message) + public void Handle(AuthorUpdatedEvent message) { - BroadcastResourceChange(ModelAction.Updated, GetArtistResource(message.Artist)); + BroadcastResourceChange(ModelAction.Updated, GetArtistResource(message.Author)); } - public void Handle(ArtistEditedEvent message) + public void Handle(AuthorEditedEvent message) { - BroadcastResourceChange(ModelAction.Updated, GetArtistResource(message.Artist)); + BroadcastResourceChange(ModelAction.Updated, GetArtistResource(message.Author)); } - public void Handle(ArtistDeletedEvent message) + public void Handle(AuthorDeletedEvent message) { - BroadcastResourceChange(ModelAction.Deleted, message.Artist.ToResource()); + BroadcastResourceChange(ModelAction.Deleted, message.Author.ToResource()); } - public void Handle(ArtistRenamedEvent message) + public void Handle(AuthorRenamedEvent message) { - BroadcastResourceChange(ModelAction.Updated, message.Artist.Id); + BroadcastResourceChange(ModelAction.Updated, message.Author.Id); } public void Handle(MediaCoversUpdatedEvent message) { - BroadcastResourceChange(ModelAction.Updated, GetArtistResource(message.Artist)); + BroadcastResourceChange(ModelAction.Updated, GetArtistResource(message.Author)); } } } diff --git a/src/Readarr.Api.V1/Artist/ArtistResource.cs b/src/Readarr.Api.V1/Artist/ArtistResource.cs index f740bc8e4..6ebff5ae9 100644 --- a/src/Readarr.Api.V1/Artist/ArtistResource.cs +++ b/src/Readarr.Api.V1/Artist/ArtistResource.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Books; using NzbDrone.Core.MediaCover; -using NzbDrone.Core.Music; using Readarr.Http.REST; namespace Readarr.Api.V1.Artist @@ -16,9 +16,9 @@ namespace Readarr.Api.V1.Artist //Todo: We should get the entire Profile instead of ID and Name separately [JsonIgnore] public int ArtistMetadataId { get; set; } - public ArtistStatusType Status { get; set; } + public AuthorStatusType Status { get; set; } - public bool Ended => Status == ArtistStatusType.Ended; + public bool Ended => Status == AuthorStatusType.Ended; public string ArtistName { get; set; } public string ForeignAuthorId { get; set; } @@ -51,7 +51,7 @@ namespace Readarr.Api.V1.Artist public string SortName { get; set; } public HashSet<int> Tags { get; set; } public DateTime Added { get; set; } - public AddArtistOptions AddOptions { get; set; } + public AddAuthorOptions AddOptions { get; set; } public Ratings Ratings { get; set; } public ArtistStatisticsResource Statistics { get; set; } @@ -59,7 +59,7 @@ namespace Readarr.Api.V1.Artist public static class ArtistResourceMapper { - public static ArtistResource ToResource(this NzbDrone.Core.Music.Author model) + public static ArtistResource ToResource(this NzbDrone.Core.Books.Author model) { if (model == null) { @@ -107,18 +107,18 @@ namespace Readarr.Api.V1.Artist }; } - public static NzbDrone.Core.Music.Author ToModel(this ArtistResource resource) + public static NzbDrone.Core.Books.Author ToModel(this ArtistResource resource) { if (resource == null) { return null; } - return new NzbDrone.Core.Music.Author + return new NzbDrone.Core.Books.Author { Id = resource.Id, - Metadata = new NzbDrone.Core.Music.AuthorMetadata + Metadata = new NzbDrone.Core.Books.AuthorMetadata { ForeignAuthorId = resource.ForeignAuthorId, GoodreadsId = resource.GoodreadsId, @@ -150,7 +150,7 @@ namespace Readarr.Api.V1.Artist }; } - public static NzbDrone.Core.Music.Author ToModel(this ArtistResource resource, NzbDrone.Core.Music.Author artist) + public static NzbDrone.Core.Books.Author ToModel(this ArtistResource resource, NzbDrone.Core.Books.Author artist) { var updatedArtist = resource.ToModel(); @@ -159,12 +159,12 @@ namespace Readarr.Api.V1.Artist return artist; } - public static List<ArtistResource> ToResource(this IEnumerable<NzbDrone.Core.Music.Author> artist) + public static List<ArtistResource> ToResource(this IEnumerable<NzbDrone.Core.Books.Author> artist) { return artist.Select(ToResource).ToList(); } - public static List<NzbDrone.Core.Music.Author> ToModel(this IEnumerable<ArtistResource> resources) + public static List<NzbDrone.Core.Books.Author> ToModel(this IEnumerable<ArtistResource> resources) { return resources.Select(ToModel).ToList(); } diff --git a/src/Readarr.Api.V1/Artist/ArtistStatisticsResource.cs b/src/Readarr.Api.V1/Artist/ArtistStatisticsResource.cs index 930471f4d..9b760a4a9 100644 --- a/src/Readarr.Api.V1/Artist/ArtistStatisticsResource.cs +++ b/src/Readarr.Api.V1/Artist/ArtistStatisticsResource.cs @@ -1,11 +1,11 @@ -using NzbDrone.Core.ArtistStats; +using NzbDrone.Core.AuthorStats; namespace Readarr.Api.V1.Artist { public class ArtistStatisticsResource { - public int AlbumCount { get; set; } - public int TrackFileCount { get; set; } + public int BookCount { get; set; } + public int BookFileCount { get; set; } public int TrackCount { get; set; } public int TotalTrackCount { get; set; } public long SizeOnDisk { get; set; } @@ -19,14 +19,14 @@ namespace Readarr.Api.V1.Artist return 0; } - return TrackFileCount / (decimal)TrackCount * 100; + return BookFileCount / (decimal)TrackCount * 100; } } } public static class ArtistStatisticsResourceMapper { - public static ArtistStatisticsResource ToResource(this ArtistStatistics model) + public static ArtistStatisticsResource ToResource(this AuthorStatistics model) { if (model == null) { @@ -35,10 +35,8 @@ namespace Readarr.Api.V1.Artist return new ArtistStatisticsResource { - AlbumCount = model.AlbumCount, - TrackFileCount = model.TrackFileCount, - TrackCount = model.TrackCount, - TotalTrackCount = model.TotalTrackCount, + BookCount = model.BookCount, + BookFileCount = model.BookFileCount, SizeOnDisk = model.SizeOnDisk }; } diff --git a/src/Readarr.Api.V1/Blacklist/BlacklistResource.cs b/src/Readarr.Api.V1/Blacklist/BlacklistResource.cs index 9918a1cea..0e728ff94 100644 --- a/src/Readarr.Api.V1/Blacklist/BlacklistResource.cs +++ b/src/Readarr.Api.V1/Blacklist/BlacklistResource.cs @@ -43,7 +43,7 @@ namespace Readarr.Api.V1.Blacklist Indexer = model.Indexer, Message = model.Message, - Artist = model.Artist.ToResource() + Artist = model.Author.ToResource() }; } } diff --git a/src/Readarr.Api.V1/Calendar/CalendarFeedModule.cs b/src/Readarr.Api.V1/Calendar/CalendarFeedModule.cs index 231417134..13138bf3a 100644 --- a/src/Readarr.Api.V1/Calendar/CalendarFeedModule.cs +++ b/src/Readarr.Api.V1/Calendar/CalendarFeedModule.cs @@ -8,7 +8,7 @@ using Ical.Net.Serialization; using Nancy; using Nancy.Responses; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using NzbDrone.Core.Tags; using Readarr.Http.Extensions; @@ -16,15 +16,15 @@ namespace Readarr.Api.V1.Calendar { public class CalendarFeedModule : ReadarrV1FeedModule { - private readonly IAlbumService _albumService; - private readonly IArtistService _artistService; + private readonly IBookService _bookService; + private readonly IAuthorService _authorService; private readonly ITagService _tagService; - public CalendarFeedModule(IAlbumService albumService, IArtistService artistService, ITagService tagService) + public CalendarFeedModule(IBookService bookService, IAuthorService authorService, ITagService tagService) : base("calendar") { - _albumService = albumService; - _artistService = artistService; + _bookService = bookService; + _authorService = authorService; _tagService = tagService; Get("/Readarr.ics", options => GetCalendarFeed()); @@ -61,7 +61,7 @@ namespace Readarr.Api.V1.Calendar tags.AddRange(tagInput.Split(',').Select(_tagService.GetTag).Select(t => t.Id)); } - var albums = _albumService.AlbumsBetweenDates(start, end, unmonitored); + var albums = _bookService.BooksBetweenDates(start, end, unmonitored); var calendar = new Ical.Net.Calendar { ProductId = "-//readarr.com//Readarr//EN" @@ -73,7 +73,7 @@ namespace Readarr.Api.V1.Calendar foreach (var album in albums.OrderBy(v => v.ReleaseDate.Value)) { - var artist = _artistService.GetArtist(album.AuthorId); // Temp fix TODO: Figure out why Album.Artist is not populated during AlbumsBetweenDates Query + var artist = _authorService.GetAuthor(album.AuthorId); // Temp fix TODO: Figure out why Album.Artist is not populated during AlbumsBetweenDates Query if (tags.Any() && tags.None(artist.Tags.Contains)) { diff --git a/src/Readarr.Api.V1/Calendar/CalendarModule.cs b/src/Readarr.Api.V1/Calendar/CalendarModule.cs index 9f14bab3c..22a6b7360 100644 --- a/src/Readarr.Api.V1/Calendar/CalendarModule.cs +++ b/src/Readarr.Api.V1/Calendar/CalendarModule.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; using System.Linq; -using NzbDrone.Core.ArtistStats; +using NzbDrone.Core.AuthorStats; +using NzbDrone.Core.Books; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.MediaCover; -using NzbDrone.Core.Music; using NzbDrone.SignalR; using Readarr.Api.V1.Albums; using Readarr.Http.Extensions; @@ -13,12 +13,12 @@ namespace Readarr.Api.V1.Calendar { public class CalendarModule : AlbumModuleWithSignalR { - public CalendarModule(IAlbumService albumService, - IArtistStatisticsService artistStatisticsService, + public CalendarModule(IBookService bookService, + IAuthorStatisticsService artistStatisticsService, IMapCoversToLocal coverMapper, IUpgradableSpecification upgradableSpecification, IBroadcastSignalRMessage signalRBroadcaster) - : base(albumService, artistStatisticsService, coverMapper, upgradableSpecification, signalRBroadcaster, "calendar") + : base(bookService, artistStatisticsService, coverMapper, upgradableSpecification, signalRBroadcaster, "calendar") { GetResourceAll = GetCalendar; } @@ -46,7 +46,7 @@ namespace Readarr.Api.V1.Calendar end = DateTime.Parse(queryEnd.Value); } - var resources = MapToResource(_albumService.AlbumsBetweenDates(start, end, includeUnmonitored), includeArtist); + var resources = MapToResource(_bookService.BooksBetweenDates(start, end, includeUnmonitored), includeArtist); return resources.OrderBy(e => e.ReleaseDate).ToList(); } diff --git a/src/Readarr.Api.V1/Config/NamingConfigModule.cs b/src/Readarr.Api.V1/Config/NamingConfigModule.cs index 82e4318fc..8741a5237 100644 --- a/src/Readarr.Api.V1/Config/NamingConfigModule.cs +++ b/src/Readarr.Api.V1/Config/NamingConfigModule.cs @@ -32,8 +32,8 @@ namespace Readarr.Api.V1.Config Get("/examples", x => GetExamples(this.Bind<NamingConfigResource>())); - SharedValidator.RuleFor(c => c.StandardTrackFormat).ValidTrackFormat(); - SharedValidator.RuleFor(c => c.ArtistFolderFormat).ValidArtistFolderFormat(); + SharedValidator.RuleFor(c => c.StandardBookFormat).ValidBookFormat(); + SharedValidator.RuleFor(c => c.ArtistFolderFormat).ValidAuthorFolderFormat(); } private void UpdateNamingConfig(NamingConfigResource resource) @@ -49,7 +49,7 @@ namespace Readarr.Api.V1.Config var nameSpec = _namingConfigService.GetConfig(); var resource = nameSpec.ToResource(); - if (resource.StandardTrackFormat.IsNotNullOrWhiteSpace()) + if (resource.StandardBookFormat.IsNotNullOrWhiteSpace()) { var basicConfig = _filenameBuilder.GetBasicNamingConfig(nameSpec); basicConfig.AddToResource(resource); @@ -79,9 +79,9 @@ namespace Readarr.Api.V1.Config ? null : singleTrackSampleResult.FileName; - sampleResource.ArtistFolderExample = nameSpec.ArtistFolderFormat.IsNullOrWhiteSpace() + sampleResource.ArtistFolderExample = nameSpec.AuthorFolderFormat.IsNullOrWhiteSpace() ? null - : _filenameSampleService.GetArtistFolderSample(nameSpec); + : _filenameSampleService.GetAuthorFolderSample(nameSpec); return sampleResource; } diff --git a/src/Readarr.Api.V1/Config/NamingConfigResource.cs b/src/Readarr.Api.V1/Config/NamingConfigResource.cs index 1b32e6cbb..9be268dce 100644 --- a/src/Readarr.Api.V1/Config/NamingConfigResource.cs +++ b/src/Readarr.Api.V1/Config/NamingConfigResource.cs @@ -4,9 +4,9 @@ namespace Readarr.Api.V1.Config { public class NamingConfigResource : RestResource { - public bool RenameTracks { get; set; } + public bool RenameBooks { get; set; } public bool ReplaceIllegalCharacters { get; set; } - public string StandardTrackFormat { get; set; } + public string StandardBookFormat { get; set; } public string ArtistFolderFormat { get; set; } public bool IncludeArtistName { get; set; } public bool IncludeAlbumTitle { get; set; } diff --git a/src/Readarr.Api.V1/Config/NamingExampleResource.cs b/src/Readarr.Api.V1/Config/NamingExampleResource.cs index 615a8bf10..8d4ea576b 100644 --- a/src/Readarr.Api.V1/Config/NamingExampleResource.cs +++ b/src/Readarr.Api.V1/Config/NamingExampleResource.cs @@ -16,10 +16,10 @@ namespace Readarr.Api.V1.Config { Id = model.Id, - RenameTracks = model.RenameTracks, + RenameBooks = model.RenameBooks, ReplaceIllegalCharacters = model.ReplaceIllegalCharacters, - StandardTrackFormat = model.StandardTrackFormat, - ArtistFolderFormat = model.ArtistFolderFormat + StandardBookFormat = model.StandardBookFormat, + ArtistFolderFormat = model.AuthorFolderFormat }; } @@ -39,10 +39,10 @@ namespace Readarr.Api.V1.Config { Id = resource.Id, - RenameTracks = resource.RenameTracks, + RenameBooks = resource.RenameBooks, ReplaceIllegalCharacters = resource.ReplaceIllegalCharacters, - StandardTrackFormat = resource.StandardTrackFormat, - ArtistFolderFormat = resource.ArtistFolderFormat, + StandardBookFormat = resource.StandardBookFormat, + AuthorFolderFormat = resource.ArtistFolderFormat, }; } } diff --git a/src/Readarr.Api.V1/FileSystem/FileSystemModule.cs b/src/Readarr.Api.V1/FileSystem/FileSystemModule.cs index 509f43744..e98dc5f79 100644 --- a/src/Readarr.Api.V1/FileSystem/FileSystemModule.cs +++ b/src/Readarr.Api.V1/FileSystem/FileSystemModule.cs @@ -59,7 +59,7 @@ namespace Readarr.Api.V1.FileSystem return new string[0]; } - return _diskScanService.GetAudioFiles(path).Select(f => new + return _diskScanService.GetBookFiles(path).Select(f => new { Path = f.FullName, Name = f.Name diff --git a/src/Readarr.Api.V1/History/HistoryModule.cs b/src/Readarr.Api.V1/History/HistoryModule.cs index 78949625f..35fd1a4d1 100644 --- a/src/Readarr.Api.V1/History/HistoryModule.cs +++ b/src/Readarr.Api.V1/History/HistoryModule.cs @@ -40,17 +40,17 @@ namespace Readarr.Api.V1.History if (includeArtist) { - resource.Artist = model.Artist.ToResource(); + resource.Artist = model.Author.ToResource(); } if (includeAlbum) { - resource.Album = model.Album.ToResource(); + resource.Album = model.Book.ToResource(); } - if (model.Artist != null) + if (model.Author != null) { - resource.QualityCutoffNotMet = _upgradableSpecification.QualityCutoffNotMet(model.Artist.QualityProfile.Value, model.Quality); + resource.QualityCutoffNotMet = _upgradableSpecification.QualityCutoffNotMet(model.Author.QualityProfile.Value, model.Quality); } return resource; @@ -135,10 +135,10 @@ namespace Readarr.Api.V1.History { int bookId = Convert.ToInt32(queryBookId.Value); - return _historyService.GetByAlbum(bookId, eventType).Select(h => MapToResource(h, includeArtist, includeAlbum)).ToList(); + return _historyService.GetByBook(bookId, eventType).Select(h => MapToResource(h, includeArtist, includeAlbum)).ToList(); } - return _historyService.GetByArtist(authorId, eventType).Select(h => MapToResource(h, includeArtist, includeAlbum)).ToList(); + return _historyService.GetByAuthor(authorId, eventType).Select(h => MapToResource(h, includeArtist, includeAlbum)).ToList(); } private object MarkAsFailed() diff --git a/src/Readarr.Api.V1/Indexers/ReleaseModule.cs b/src/Readarr.Api.V1/Indexers/ReleaseModule.cs index 8494dd085..6152303ac 100644 --- a/src/Readarr.Api.V1/Indexers/ReleaseModule.cs +++ b/src/Readarr.Api.V1/Indexers/ReleaseModule.cs @@ -24,7 +24,7 @@ namespace Readarr.Api.V1.Indexers private readonly IDownloadService _downloadService; private readonly Logger _logger; - private readonly ICached<RemoteAlbum> _remoteAlbumCache; + private readonly ICached<RemoteBook> _remoteAlbumCache; public ReleaseModule(IFetchAndParseRss rssFetcherAndParser, ISearchForNzb nzbSearchService, @@ -47,7 +47,7 @@ namespace Readarr.Api.V1.Indexers PostValidator.RuleFor(s => s.IndexerId).ValidId(); PostValidator.RuleFor(s => s.Guid).NotEmpty(); - _remoteAlbumCache = cacheManager.GetCache<RemoteAlbum>(GetType(), "remoteAlbums"); + _remoteAlbumCache = cacheManager.GetCache<RemoteBook>(GetType(), "remoteAlbums"); } private object DownloadRelease(ReleaseResource release) @@ -135,7 +135,7 @@ namespace Readarr.Api.V1.Indexers protected override ReleaseResource MapDecision(DownloadDecision decision, int initialWeight) { var resource = base.MapDecision(decision, initialWeight); - _remoteAlbumCache.Set(GetCacheKey(resource), decision.RemoteAlbum, TimeSpan.FromMinutes(30)); + _remoteAlbumCache.Set(GetCacheKey(resource), decision.RemoteBook, TimeSpan.FromMinutes(30)); return resource; } diff --git a/src/Readarr.Api.V1/Indexers/ReleaseModuleBase.cs b/src/Readarr.Api.V1/Indexers/ReleaseModuleBase.cs index a6ac2b15b..f9254467e 100644 --- a/src/Readarr.Api.V1/Indexers/ReleaseModuleBase.cs +++ b/src/Readarr.Api.V1/Indexers/ReleaseModuleBase.cs @@ -26,10 +26,10 @@ namespace Readarr.Api.V1.Indexers release.ReleaseWeight = initialWeight; - if (decision.RemoteAlbum.Artist != null) + if (decision.RemoteBook.Author != null) { - release.QualityWeight = decision.RemoteAlbum - .Artist + release.QualityWeight = decision.RemoteBook + .Author .QualityProfile.Value.GetIndex(release.Quality.Quality).Index * 100; } diff --git a/src/Readarr.Api.V1/Indexers/ReleasePushModule.cs b/src/Readarr.Api.V1/Indexers/ReleasePushModule.cs index 88f0acf90..dba77e649 100644 --- a/src/Readarr.Api.V1/Indexers/ReleasePushModule.cs +++ b/src/Readarr.Api.V1/Indexers/ReleasePushModule.cs @@ -52,7 +52,7 @@ namespace Readarr.Api.V1.Indexers var firstDecision = decisions.FirstOrDefault(); - if (firstDecision?.RemoteAlbum.ParsedAlbumInfo == null) + if (firstDecision?.RemoteBook.ParsedBookInfo == null) { throw new ValidationException(new List<ValidationFailure> { new ValidationFailure("Title", "Unable to parse", release.Title) }); } diff --git a/src/Readarr.Api.V1/Indexers/ReleaseResource.cs b/src/Readarr.Api.V1/Indexers/ReleaseResource.cs index 5e7e12e3c..c019a9987 100644 --- a/src/Readarr.Api.V1/Indexers/ReleaseResource.cs +++ b/src/Readarr.Api.V1/Indexers/ReleaseResource.cs @@ -64,10 +64,10 @@ namespace Readarr.Api.V1.Indexers { public static ReleaseResource ToResource(this DownloadDecision model) { - var releaseInfo = model.RemoteAlbum.Release; - var parsedAlbumInfo = model.RemoteAlbum.ParsedAlbumInfo; - var remoteAlbum = model.RemoteAlbum; - var torrentInfo = (model.RemoteAlbum.Release as TorrentInfo) ?? new TorrentInfo(); + var releaseInfo = model.RemoteBook.Release; + var parsedAlbumInfo = model.RemoteBook.ParsedBookInfo; + var remoteAlbum = model.RemoteBook; + var torrentInfo = (model.RemoteBook.Release as TorrentInfo) ?? new TorrentInfo(); // TODO: Clean this mess up. don't mix data from multiple classes, use sub-resources instead? (Got a huge Deja Vu, didn't we talk about this already once?) return new ReleaseResource @@ -85,8 +85,8 @@ namespace Readarr.Api.V1.Indexers ReleaseGroup = parsedAlbumInfo.ReleaseGroup, ReleaseHash = parsedAlbumInfo.ReleaseHash, Title = releaseInfo.Title, - ArtistName = parsedAlbumInfo.ArtistName, - AlbumTitle = parsedAlbumInfo.AlbumTitle, + ArtistName = parsedAlbumInfo.AuthorName, + AlbumTitle = parsedAlbumInfo.BookTitle, Discography = parsedAlbumInfo.Discography, Approved = model.Approved, TemporarilyRejected = model.TemporarilyRejected, diff --git a/src/Readarr.Api.V1/ManualImport/ManualImportModule.cs b/src/Readarr.Api.V1/ManualImport/ManualImportModule.cs index 556abdd41..5307f20ed 100644 --- a/src/Readarr.Api.V1/ManualImport/ManualImportModule.cs +++ b/src/Readarr.Api.V1/ManualImport/ManualImportModule.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using System.Linq; using Nancy; using NLog; +using NzbDrone.Core.Books; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.MediaFiles.TrackImport.Manual; -using NzbDrone.Core.Music; +using NzbDrone.Core.MediaFiles.BookImport.Manual; using NzbDrone.Core.Qualities; using Readarr.Http; using Readarr.Http.Extensions; @@ -13,18 +13,18 @@ namespace Readarr.Api.V1.ManualImport { public class ManualImportModule : ReadarrRestModule<ManualImportResource> { - private readonly IArtistService _artistService; - private readonly IAlbumService _albumService; + private readonly IAuthorService _authorService; + private readonly IBookService _bookService; private readonly IManualImportService _manualImportService; private readonly Logger _logger; public ManualImportModule(IManualImportService manualImportService, - IArtistService artistService, - IAlbumService albumService, + IAuthorService authorService, + IBookService bookService, Logger logger) { - _artistService = artistService; - _albumService = albumService; + _authorService = authorService; + _bookService = bookService; _manualImportService = manualImportService; _logger = logger; @@ -70,8 +70,8 @@ namespace Readarr.Api.V1.ManualImport Path = resource.Path, Name = resource.Name, Size = resource.Size, - Artist = resource.Artist == null ? null : _artistService.GetArtist(resource.Artist.Id), - Album = resource.Album == null ? null : _albumService.GetAlbum(resource.Album.Id), + Author = resource.Artist == null ? null : _authorService.GetAuthor(resource.Artist.Id), + Book = resource.Album == null ? null : _bookService.GetBook(resource.Album.Id), Quality = resource.Quality, DownloadId = resource.DownloadId, AdditionalFile = resource.AdditionalFile, diff --git a/src/Readarr.Api.V1/ManualImport/ManualImportResource.cs b/src/Readarr.Api.V1/ManualImport/ManualImportResource.cs index 0f13b5b69..51275939a 100644 --- a/src/Readarr.Api.V1/ManualImport/ManualImportResource.cs +++ b/src/Readarr.Api.V1/ManualImport/ManualImportResource.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.MediaFiles.TrackImport.Manual; +using NzbDrone.Core.MediaFiles.BookImport.Manual; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; using Readarr.Api.V1.Albums; @@ -41,8 +41,8 @@ namespace Readarr.Api.V1.ManualImport Path = model.Path, Name = model.Name, Size = model.Size, - Artist = model.Artist.ToResource(), - Album = model.Album.ToResource(), + Artist = model.Author.ToResource(), + Album = model.Book.ToResource(), Quality = model.Quality, //QualityWeight diff --git a/src/Readarr.Api.V1/Parse/ParseModule.cs b/src/Readarr.Api.V1/Parse/ParseModule.cs index d0a2ff631..6a07c2619 100644 --- a/src/Readarr.Api.V1/Parse/ParseModule.cs +++ b/src/Readarr.Api.V1/Parse/ParseModule.cs @@ -19,7 +19,7 @@ namespace Readarr.Api.V1.Parse private ParseResource Parse() { var title = Request.Query.Title.Value as string; - var parsedAlbumInfo = Parser.ParseAlbumTitle(title); + var parsedAlbumInfo = Parser.ParseBookTitle(title); if (parsedAlbumInfo == null) { @@ -33,9 +33,9 @@ namespace Readarr.Api.V1.Parse return new ParseResource { Title = title, - ParsedAlbumInfo = remoteAlbum.ParsedAlbumInfo, - Artist = remoteAlbum.Artist.ToResource(), - Albums = remoteAlbum.Albums.ToResource() + ParsedAlbumInfo = remoteAlbum.ParsedBookInfo, + Artist = remoteAlbum.Author.ToResource(), + Albums = remoteAlbum.Books.ToResource() }; } else diff --git a/src/Readarr.Api.V1/Parse/ParseResource.cs b/src/Readarr.Api.V1/Parse/ParseResource.cs index ed51589cd..67152b497 100644 --- a/src/Readarr.Api.V1/Parse/ParseResource.cs +++ b/src/Readarr.Api.V1/Parse/ParseResource.cs @@ -9,7 +9,7 @@ namespace Readarr.Api.V1.Parse public class ParseResource : RestResource { public string Title { get; set; } - public ParsedAlbumInfo ParsedAlbumInfo { get; set; } + public ParsedBookInfo ParsedAlbumInfo { get; set; } public ArtistResource Artist { get; set; } public List<AlbumResource> Albums { get; set; } } diff --git a/src/Readarr.Api.V1/Queue/QueueActionModule.cs b/src/Readarr.Api.V1/Queue/QueueActionModule.cs index 67b7e4b77..767324229 100644 --- a/src/Readarr.Api.V1/Queue/QueueActionModule.cs +++ b/src/Readarr.Api.V1/Queue/QueueActionModule.cs @@ -53,7 +53,7 @@ namespace Readarr.Api.V1.Queue throw new NotFoundException(); } - _downloadService.DownloadReport(pendingRelease.RemoteAlbum); + _downloadService.DownloadReport(pendingRelease.RemoteBook); return new object(); } @@ -71,7 +71,7 @@ namespace Readarr.Api.V1.Queue throw new NotFoundException(); } - _downloadService.DownloadReport(pendingRelease.RemoteAlbum); + _downloadService.DownloadReport(pendingRelease.RemoteBook); } return new object(); diff --git a/src/Readarr.Api.V1/Queue/QueueDetailsModule.cs b/src/Readarr.Api.V1/Queue/QueueDetailsModule.cs index eb3387e4d..28640441c 100644 --- a/src/Readarr.Api.V1/Queue/QueueDetailsModule.cs +++ b/src/Readarr.Api.V1/Queue/QueueDetailsModule.cs @@ -38,7 +38,7 @@ namespace Readarr.Api.V1.Queue if (authorIdQuery.HasValue) { - return fullQueue.Where(q => q.Artist?.Id == (int)authorIdQuery).ToResource(includeArtist, includeAlbum); + return fullQueue.Where(q => q.Author?.Id == (int)authorIdQuery).ToResource(includeArtist, includeAlbum); } if (bookIdsQuery.HasValue) @@ -49,7 +49,7 @@ namespace Readarr.Api.V1.Queue .Select(e => Convert.ToInt32(e)) .ToList(); - return fullQueue.Where(q => q.Album != null && bookIds.Contains(q.Album.Id)).ToResource(includeArtist, includeAlbum); + return fullQueue.Where(q => q.Book != null && bookIds.Contains(q.Book.Id)).ToResource(includeArtist, includeAlbum); } return fullQueue.ToResource(includeArtist, includeAlbum); diff --git a/src/Readarr.Api.V1/Queue/QueueModule.cs b/src/Readarr.Api.V1/Queue/QueueModule.cs index 74b6bab47..53360bf92 100644 --- a/src/Readarr.Api.V1/Queue/QueueModule.cs +++ b/src/Readarr.Api.V1/Queue/QueueModule.cs @@ -51,7 +51,7 @@ namespace Readarr.Api.V1.Queue var orderByFunc = GetOrderByFunc(pagingSpec); var queue = _queueService.GetQueue(); - var filteredQueue = includeUnknownArtistItems ? queue : queue.Where(q => q.Artist != null); + var filteredQueue = includeUnknownArtistItems ? queue : queue.Where(q => q.Author != null); var pending = _pendingReleaseService.GetPendingQueue(); var fullQueue = filteredQueue.Concat(pending).ToList(); IOrderedEnumerable<NzbDrone.Core.Queue.Queue> ordered; @@ -119,15 +119,15 @@ namespace Readarr.Api.V1.Queue case "status": return q => q.Status; case "authors.sortName": - return q => q.Artist?.SortName; + return q => q.Author?.SortName; case "title": return q => q.Title; case "album": - return q => q.Album; + return q => q.Book; case "books.title": - return q => q.Album?.Title; + return q => q.Book?.Title; case "album.releaseDate": - return q => q.Album?.ReleaseDate; + return q => q.Book?.ReleaseDate; case "quality": return q => q.Quality; case "progress": diff --git a/src/Readarr.Api.V1/Queue/QueueResource.cs b/src/Readarr.Api.V1/Queue/QueueResource.cs index 0164c4858..c10f84389 100644 --- a/src/Readarr.Api.V1/Queue/QueueResource.cs +++ b/src/Readarr.Api.V1/Queue/QueueResource.cs @@ -48,10 +48,10 @@ namespace Readarr.Api.V1.Queue return new QueueResource { Id = model.Id, - AuthorId = model.Artist?.Id, - BookId = model.Album?.Id, - Artist = includeArtist && model.Artist != null ? model.Artist.ToResource() : null, - Album = includeAlbum && model.Album != null ? model.Album.ToResource() : null, + AuthorId = model.Author?.Id, + BookId = model.Book?.Id, + Artist = includeArtist && model.Author != null ? model.Author.ToResource() : null, + Album = includeAlbum && model.Book != null ? model.Book.ToResource() : null, Quality = model.Quality, Size = model.Size, Title = model.Title, diff --git a/src/Readarr.Api.V1/Queue/QueueStatusModule.cs b/src/Readarr.Api.V1/Queue/QueueStatusModule.cs index 21e4b7f0b..8d6f66591 100644 --- a/src/Readarr.Api.V1/Queue/QueueStatusModule.cs +++ b/src/Readarr.Api.V1/Queue/QueueStatusModule.cs @@ -44,12 +44,12 @@ namespace Readarr.Api.V1.Queue var resource = new QueueStatusResource { TotalCount = queue.Count + pending.Count, - Count = queue.Count(q => q.Artist != null) + pending.Count, - UnknownCount = queue.Count(q => q.Artist == null), - Errors = queue.Any(q => q.Artist != null && q.TrackedDownloadStatus == TrackedDownloadStatus.Error), - Warnings = queue.Any(q => q.Artist != null && q.TrackedDownloadStatus == TrackedDownloadStatus.Warning), - UnknownErrors = queue.Any(q => q.Artist == null && q.TrackedDownloadStatus == TrackedDownloadStatus.Error), - UnknownWarnings = queue.Any(q => q.Artist == null && q.TrackedDownloadStatus == TrackedDownloadStatus.Warning) + Count = queue.Count(q => q.Author != null) + pending.Count, + UnknownCount = queue.Count(q => q.Author == null), + Errors = queue.Any(q => q.Author != null && q.TrackedDownloadStatus == TrackedDownloadStatus.Error), + Warnings = queue.Any(q => q.Author != null && q.TrackedDownloadStatus == TrackedDownloadStatus.Warning), + UnknownErrors = queue.Any(q => q.Author == null && q.TrackedDownloadStatus == TrackedDownloadStatus.Error), + UnknownWarnings = queue.Any(q => q.Author == null && q.TrackedDownloadStatus == TrackedDownloadStatus.Warning) }; _broadcastDebounce.Resume(); diff --git a/src/Readarr.Api.V1/RootFolders/RootFolderResource.cs b/src/Readarr.Api.V1/RootFolders/RootFolderResource.cs index 3bcd07423..946ebbc7a 100644 --- a/src/Readarr.Api.V1/RootFolders/RootFolderResource.cs +++ b/src/Readarr.Api.V1/RootFolders/RootFolderResource.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; +using NzbDrone.Core.Books; using NzbDrone.Core.Books.Calibre; -using NzbDrone.Core.Music; using NzbDrone.Core.RootFolders; using Readarr.Http.REST; diff --git a/src/Readarr.Api.V1/Search/SearchModule.cs b/src/Readarr.Api.V1/Search/SearchModule.cs index 6b987c203..816c2487c 100644 --- a/src/Readarr.Api.V1/Search/SearchModule.cs +++ b/src/Readarr.Api.V1/Search/SearchModule.cs @@ -35,9 +35,9 @@ namespace Readarr.Api.V1.Search var resource = new SearchResource(); resource.Id = id++; - if (result is NzbDrone.Core.Music.Author) + if (result is NzbDrone.Core.Books.Author) { - var artist = (NzbDrone.Core.Music.Author)result; + var artist = (NzbDrone.Core.Books.Author)result; resource.Artist = artist.ToResource(); resource.ForeignId = artist.ForeignAuthorId; @@ -47,9 +47,9 @@ namespace Readarr.Api.V1.Search resource.Artist.RemotePoster = poster.Url; } } - else if (result is NzbDrone.Core.Music.Book) + else if (result is NzbDrone.Core.Books.Book) { - var album = (NzbDrone.Core.Music.Book)result; + var album = (NzbDrone.Core.Books.Book)result; resource.Album = album.ToResource(); resource.ForeignId = album.ForeignBookId; diff --git a/src/Readarr.Api.V1/Series/SeriesBookLinkResource.cs b/src/Readarr.Api.V1/Series/SeriesBookLinkResource.cs index c5ca540bf..2fbb04a9b 100644 --- a/src/Readarr.Api.V1/Series/SeriesBookLinkResource.cs +++ b/src/Readarr.Api.V1/Series/SeriesBookLinkResource.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using System.Linq; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using Readarr.Http.REST; namespace Readarr.Api.V1.Series diff --git a/src/Readarr.Api.V1/Series/SeriesModule.cs b/src/Readarr.Api.V1/Series/SeriesModule.cs index bb6b14350..96bca4321 100644 --- a/src/Readarr.Api.V1/Series/SeriesModule.cs +++ b/src/Readarr.Api.V1/Series/SeriesModule.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using Nancy; -using NzbDrone.Core.Music; +using NzbDrone.Core.Books; using Readarr.Http; using Readarr.Http.REST; diff --git a/src/Readarr.Api.V1/Series/SeriesResource.cs b/src/Readarr.Api.V1/Series/SeriesResource.cs index 5637dd919..c65ad77bf 100644 --- a/src/Readarr.Api.V1/Series/SeriesResource.cs +++ b/src/Readarr.Api.V1/Series/SeriesResource.cs @@ -13,7 +13,7 @@ namespace Readarr.Api.V1.Series public static class SeriesResourceMapper { - public static SeriesResource ToResource(this NzbDrone.Core.Music.Series model) + public static SeriesResource ToResource(this NzbDrone.Core.Books.Series model) { if (model == null) { @@ -29,7 +29,7 @@ namespace Readarr.Api.V1.Series }; } - public static List<SeriesResource> ToResource(this IEnumerable<NzbDrone.Core.Music.Series> models) + public static List<SeriesResource> ToResource(this IEnumerable<NzbDrone.Core.Books.Series> models) { return models?.Select(ToResource).ToList(); } diff --git a/src/Readarr.Api.V1/TrackFiles/TrackFileModule.cs b/src/Readarr.Api.V1/TrackFiles/TrackFileModule.cs index 32278cb93..ab48e5c66 100644 --- a/src/Readarr.Api.V1/TrackFiles/TrackFileModule.cs +++ b/src/Readarr.Api.V1/TrackFiles/TrackFileModule.cs @@ -2,13 +2,13 @@ using System; using System.Collections.Generic; using System.Linq; using Nancy; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore.Events; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Exceptions; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Music; using NzbDrone.SignalR; using Readarr.Http; using Readarr.Http.Extensions; @@ -17,30 +17,30 @@ using HttpStatusCode = System.Net.HttpStatusCode; namespace Readarr.Api.V1.TrackFiles { public class TrackFileModule : ReadarrRestModuleWithSignalR<TrackFileResource, BookFile>, - IHandle<TrackFileAddedEvent>, - IHandle<TrackFileDeletedEvent> + IHandle<BookFileAddedEvent>, + IHandle<BookFileDeletedEvent> { private readonly IMediaFileService _mediaFileService; private readonly IDeleteMediaFiles _mediaFileDeletionService; private readonly IAudioTagService _audioTagService; - private readonly IArtistService _artistService; - private readonly IAlbumService _albumService; + private readonly IAuthorService _authorService; + private readonly IBookService _bookService; private readonly IUpgradableSpecification _upgradableSpecification; public TrackFileModule(IBroadcastSignalRMessage signalRBroadcaster, IMediaFileService mediaFileService, IDeleteMediaFiles mediaFileDeletionService, IAudioTagService audioTagService, - IArtistService artistService, - IAlbumService albumService, + IAuthorService authorService, + IBookService bookService, IUpgradableSpecification upgradableSpecification) : base(signalRBroadcaster) { _mediaFileService = mediaFileService; _mediaFileDeletionService = mediaFileDeletionService; _audioTagService = audioTagService; - _artistService = artistService; - _albumService = albumService; + _authorService = authorService; + _bookService = bookService; _upgradableSpecification = upgradableSpecification; GetResourceById = GetTrackFile; @@ -54,9 +54,9 @@ namespace Readarr.Api.V1.TrackFiles private TrackFileResource MapToResource(BookFile trackFile) { - if (trackFile.BookId > 0 && trackFile.Artist != null && trackFile.Artist.Value != null) + if (trackFile.BookId > 0 && trackFile.Author != null && trackFile.Author.Value != null) { - return trackFile.ToResource(trackFile.Artist.Value, _upgradableSpecification); + return trackFile.ToResource(trackFile.Author.Value, _upgradableSpecification); } else { @@ -92,9 +92,9 @@ namespace Readarr.Api.V1.TrackFiles if (authorIdQuery.HasValue && !bookIdQuery.HasValue) { int authorId = Convert.ToInt32(authorIdQuery.Value); - var artist = _artistService.GetArtist(authorId); + var artist = _authorService.GetAuthor(authorId); - return _mediaFileService.GetFilesByArtist(authorId).ConvertAll(f => f.ToResource(artist, _upgradableSpecification)); + return _mediaFileService.GetFilesByAuthor(authorId).ConvertAll(f => f.ToResource(artist, _upgradableSpecification)); } if (bookIdQuery.HasValue) @@ -108,9 +108,9 @@ namespace Readarr.Api.V1.TrackFiles var result = new List<TrackFileResource>(); foreach (var bookId in bookIds) { - var album = _albumService.GetAlbum(bookId); - var albumArtist = _artistService.GetArtist(album.AuthorId); - result.AddRange(_mediaFileService.GetFilesByAlbum(album.Id).ConvertAll(f => f.ToResource(albumArtist, _upgradableSpecification))); + var album = _bookService.GetBook(bookId); + var albumArtist = _authorService.GetAuthor(album.AuthorId); + result.AddRange(_mediaFileService.GetFilesByBook(album.Id).ConvertAll(f => f.ToResource(albumArtist, _upgradableSpecification))); } return result; @@ -151,7 +151,7 @@ namespace Readarr.Api.V1.TrackFiles _mediaFileService.Update(trackFiles); - return ResponseWithCode(trackFiles.ConvertAll(f => f.ToResource(trackFiles.First().Artist.Value, _upgradableSpecification)), + return ResponseWithCode(trackFiles.ConvertAll(f => f.ToResource(trackFiles.First().Author.Value, _upgradableSpecification)), Nancy.HttpStatusCode.Accepted); } @@ -164,9 +164,9 @@ namespace Readarr.Api.V1.TrackFiles throw new NzbDroneClientException(HttpStatusCode.NotFound, "Track file not found"); } - if (trackFile.BookId > 0 && trackFile.Artist != null && trackFile.Artist.Value != null) + if (trackFile.BookId > 0 && trackFile.Author != null && trackFile.Author.Value != null) { - _mediaFileDeletionService.DeleteTrackFile(trackFile.Artist.Value, trackFile); + _mediaFileDeletionService.DeleteTrackFile(trackFile.Author.Value, trackFile); } else { @@ -178,7 +178,7 @@ namespace Readarr.Api.V1.TrackFiles { var resource = Request.Body.FromJson<TrackFileListResource>(); var trackFiles = _mediaFileService.Get(resource.TrackFileIds); - var artist = trackFiles.First().Artist.Value; + var artist = trackFiles.First().Author.Value; foreach (var trackFile in trackFiles) { @@ -188,14 +188,14 @@ namespace Readarr.Api.V1.TrackFiles return new object(); } - public void Handle(TrackFileAddedEvent message) + public void Handle(BookFileAddedEvent message) { - BroadcastResourceChange(ModelAction.Updated, MapToResource(message.TrackFile)); + BroadcastResourceChange(ModelAction.Updated, MapToResource(message.BookFile)); } - public void Handle(TrackFileDeletedEvent message) + public void Handle(BookFileDeletedEvent message) { - BroadcastResourceChange(ModelAction.Deleted, MapToResource(message.TrackFile)); + BroadcastResourceChange(ModelAction.Deleted, MapToResource(message.BookFile)); } } } diff --git a/src/Readarr.Api.V1/TrackFiles/TrackFileResource.cs b/src/Readarr.Api.V1/TrackFiles/TrackFileResource.cs index 7545af5c1..2ea38a282 100644 --- a/src/Readarr.Api.V1/TrackFiles/TrackFileResource.cs +++ b/src/Readarr.Api.V1/TrackFiles/TrackFileResource.cs @@ -59,7 +59,7 @@ namespace Readarr.Api.V1.TrackFiles }; } - public static TrackFileResource ToResource(this BookFile model, NzbDrone.Core.Music.Author artist, IUpgradableSpecification upgradableSpecification) + public static TrackFileResource ToResource(this BookFile model, NzbDrone.Core.Books.Author artist, IUpgradableSpecification upgradableSpecification) { if (model == null) { diff --git a/src/Readarr.Api.V1/Wanted/CutoffModule.cs b/src/Readarr.Api.V1/Wanted/CutoffModule.cs index 91d9656af..267bd6fce 100644 --- a/src/Readarr.Api.V1/Wanted/CutoffModule.cs +++ b/src/Readarr.Api.V1/Wanted/CutoffModule.cs @@ -1,9 +1,9 @@ using System.Linq; -using NzbDrone.Core.ArtistStats; +using NzbDrone.Core.AuthorStats; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.MediaCover; -using NzbDrone.Core.Music; using NzbDrone.SignalR; using Readarr.Api.V1.Albums; using Readarr.Http; @@ -13,15 +13,15 @@ namespace Readarr.Api.V1.Wanted { public class CutoffModule : AlbumModuleWithSignalR { - private readonly IAlbumCutoffService _albumCutoffService; + private readonly IBookCutoffService _albumCutoffService; - public CutoffModule(IAlbumCutoffService albumCutoffService, - IAlbumService albumService, - IArtistStatisticsService artistStatisticsService, + public CutoffModule(IBookCutoffService albumCutoffService, + IBookService bookService, + IAuthorStatisticsService artistStatisticsService, IMapCoversToLocal coverMapper, IUpgradableSpecification upgradableSpecification, IBroadcastSignalRMessage signalRBroadcaster) - : base(albumService, artistStatisticsService, coverMapper, upgradableSpecification, signalRBroadcaster, "wanted/cutoff") + : base(bookService, artistStatisticsService, coverMapper, upgradableSpecification, signalRBroadcaster, "wanted/cutoff") { _albumCutoffService = albumCutoffService; GetResourcePaged = GetCutoffUnmetAlbums; @@ -49,7 +49,7 @@ namespace Readarr.Api.V1.Wanted pagingSpec.FilterExpressions.Add(v => v.Monitored == true && v.Author.Value.Monitored == true); } - var resource = ApplyToPage(_albumCutoffService.AlbumsWhereCutoffUnmet, pagingSpec, v => MapToResource(v, includeArtist)); + var resource = ApplyToPage(_albumCutoffService.BooksWhereCutoffUnmet, pagingSpec, v => MapToResource(v, includeArtist)); return resource; } diff --git a/src/Readarr.Api.V1/Wanted/MissingModule.cs b/src/Readarr.Api.V1/Wanted/MissingModule.cs index 41d931744..31f9d438a 100644 --- a/src/Readarr.Api.V1/Wanted/MissingModule.cs +++ b/src/Readarr.Api.V1/Wanted/MissingModule.cs @@ -1,9 +1,9 @@ using System.Linq; -using NzbDrone.Core.ArtistStats; +using NzbDrone.Core.AuthorStats; +using NzbDrone.Core.Books; using NzbDrone.Core.Datastore; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.MediaCover; -using NzbDrone.Core.Music; using NzbDrone.SignalR; using Readarr.Api.V1.Albums; using Readarr.Http; @@ -13,12 +13,12 @@ namespace Readarr.Api.V1.Wanted { public class MissingModule : AlbumModuleWithSignalR { - public MissingModule(IAlbumService albumService, - IArtistStatisticsService artistStatisticsService, + public MissingModule(IBookService bookService, + IAuthorStatisticsService artistStatisticsService, IMapCoversToLocal coverMapper, IUpgradableSpecification upgradableSpecification, IBroadcastSignalRMessage signalRBroadcaster) - : base(albumService, artistStatisticsService, coverMapper, upgradableSpecification, signalRBroadcaster, "wanted/missing") + : base(bookService, artistStatisticsService, coverMapper, upgradableSpecification, signalRBroadcaster, "wanted/missing") { GetResourcePaged = GetMissingAlbums; } @@ -45,7 +45,7 @@ namespace Readarr.Api.V1.Wanted pagingSpec.FilterExpressions.Add(v => v.Monitored == true && v.Author.Value.Monitored == true); } - var resource = ApplyToPage(_albumService.AlbumsWithoutFiles, pagingSpec, v => MapToResource(v, includeArtist)); + var resource = ApplyToPage(_bookService.BooksWithoutFiles, pagingSpec, v => MapToResource(v, includeArtist)); return resource; }