From 25e10e26e308b4ad41dcaa428e4a171413b2ae08 Mon Sep 17 00:00:00 2001 From: Qstick Date: Wed, 14 Mar 2018 16:41:36 -0400 Subject: [PATCH] Added: A Huge Cleanup of old Series Code. (Let's pray nothing breaks :P) (#2589) --- .../Blacklist/BlacklistResource.cs | 2 - .../Calendar/CalendarFeedModule.cs | 2 +- src/NzbDrone.Api/Calendar/CalendarModule.cs | 10 +- src/NzbDrone.Api/Config/NamingConfigModule.cs | 14 +- .../Config/NamingConfigResource.cs | 14 +- src/NzbDrone.Api/Indexers/ReleaseModule.cs | 72 +-- src/NzbDrone.Api/Indexers/ReleaseResource.cs | 104 +-- .../ManualImport/ManualImportModule.cs | 2 +- .../ManualImport/ManualImportResource.cs | 4 +- .../MovieFiles/MovieFileModule.cs | 2 +- .../MovieFiles/MovieFileResource.cs | 2 +- .../Movies/AlternativeTitleModule.cs | 6 +- .../Movies/AlternativeTitleResource.cs | 2 +- .../Movies/AlternativeYearModule.cs | 6 +- .../Movies/AlternativeYearResource.cs | 2 +- .../Movies/FetchMovieListModule.cs | 4 +- .../Movies/MovieBulkImportModule.cs | 16 +- .../Movies/MovieDiscoverModule.cs | 2 +- src/NzbDrone.Api/Movies/MovieEditorModule.cs | 2 +- src/NzbDrone.Api/Movies/MovieLookupModule.cs | 2 +- src/NzbDrone.Api/Movies/MovieModule.cs | 61 +- .../Movies/MovieModuleWithSignalR.cs | 6 +- src/NzbDrone.Api/Movies/MovieResource.cs | 12 +- .../NetImport/ImportExclusionsResource.cs | 2 +- .../NetImport/ListImportModule.cs | 2 +- .../NetImport/NetImportResource.cs | 2 +- src/NzbDrone.Api/Series/SeriesModule.cs | 2 +- src/NzbDrone.Api/Wanted/MovieCutoffModule.cs | 4 +- src/NzbDrone.Api/Wanted/MovieMissingModule.cs | 4 +- src/NzbDrone.App.Test/ContainerFixture.cs | 10 +- .../BlacklistRepositoryFixture.cs | 6 +- .../Blacklisting/BlacklistServiceFixture.cs | 4 +- .../BulkImport/AddMultiMoviesFixture.cs | 4 +- .../DailySeriesDataProxyFixture.cs | 28 - .../Scene/SceneMappingProxyFixture.cs | 35 - .../Scene/SceneMappingServiceFixture.cs | 337 ---------- .../Datastore/DatabaseFixture.cs | 6 +- .../Datastore/DatabaseRelationshipFixture.cs | 21 +- .../Datastore/MappingExtentionFixture.cs | 8 +- .../Datastore/MarrDataLazyLoadingFixture.cs | 68 +- .../PagingOffsetFixture.cs | 6 +- .../ToSortDirectionFixture.cs | 10 +- .../AcceptableSizeSpecificationFixture.cs | 206 ++---- ...AnimeVersionUpgradeSpecificationFixture.cs | 110 ---- .../DownloadDecisionMakerFixture.cs | 51 +- .../FullSeasonSpecificationFixture.cs | 76 --- .../HistorySpecificationFixture.cs | 45 +- .../LanguageSpecificationFixture.cs | 18 +- .../MinimumAgeSpecificationFixture.cs | 8 +- ... => MonitoredMovieSpecificationFixture.cs} | 70 +- .../PrioritizeDownloadDecisionFixture.cs | 2 +- .../ProtocolSpecificationFixture.cs | 12 +- ...ityAllowedByProfileSpecificationFixture.cs | 28 +- .../QueueSpecificationFixture.cs | 187 ++---- .../RawDiskSpecificationFixture.cs | 22 +- ...ReleaseRestrictionsSpecificationFixture.cs | 30 +- .../RetentionSpecificationFixture.cs | 24 +- .../RssSync/DelaySpecificationFixture.cs | 8 +- .../RssSync/ProperSpecificationFixture.cs | 64 +- .../SameEpisodesSpecificationFixture.cs | 76 --- ...ixture.cs => MovieSpecificationFixture.cs} | 24 +- .../TorrentSeedingSpecificationFixture.cs | 32 +- .../UpgradeDiskSpecificationFixture.cs | 82 +-- .../CompletedDownloadServiceFixture.cs | 10 +- .../DownloadApprovedFixture.cs | 2 +- .../DownloadClientFixtureBase.cs | 2 +- .../PneumaticProviderFixture.cs | 14 +- .../SabnzbdTests/SabnzbdFixture.cs | 2 +- .../Download/DownloadServiceFixture.cs | 53 +- .../Download/FailedDownloadServiceFixture.cs | 11 +- .../PendingReleaseServiceTests/AddFixture.cs | 6 +- .../RemoveGrabbedFixture.cs | 6 +- .../RemovePendingFixture.cs | 60 +- .../RemoveRejectedFixture.cs | 6 +- .../TrackedDownloadServiceFixture.cs | 6 +- .../Checks/DeleteBadMediaCovers.cs | 4 +- .../Checks/RootFolderCheckFixture.cs | 26 +- .../HistoryTests/HistoryServiceFixture.cs | 2 +- .../CleanupOrphanedBlacklistFixture.cs | 8 +- .../CleanupOrphanedEpisodesFixture.cs | 43 -- .../CleanupOrphanedHistoryItemsFixture.cs | 2 +- .../CleanupOrphanedMetadataFilesFixture.cs | 2 +- ...cs => CleanupOrphanedMovieFilesFixture.cs} | 6 +- .../CleanupOrphanedPendingReleasesFixture.cs | 2 +- .../NzbSearchServiceFixture.cs | 265 -------- .../SearchDefinitionFixture.cs | 2 +- .../SeriesSearchServiceFixture.cs | 80 --- .../IndexerIntegrationTests.cs | 17 +- .../NewznabRequestGeneratorFixture.cs | 2 +- .../IndexerTests/SeasonSearchFixture.cs | 92 --- .../DatabaseTargetFixture.cs | 4 +- .../MediaCoverServiceFixture.cs | 22 +- .../DiskScanServiceTests/ScanFixture.cs | 138 ++-- .../DownloadedMoviesCommandServiceFixture.cs | 4 +- .../DownloadedMoviesImportServiceFixture.cs | 12 +- .../MoveEpisodeFileFixture.cs | 51 +- .../FullSeasonSpecificationFixture.cs | 46 -- .../MatchesFolderSpecificationFixture.cs | 84 --- .../NotSampleSpecificationFixture.cs | 48 -- .../UpgradeSpecificationFixture.cs | 156 ----- .../ImportApprovedEpisodesFixture.cs | 117 ++-- .../MediaFiles/MediaFileRepositoryFixture.cs | 12 +- .../MediaFileServiceTests/FilterFixture.cs | 38 +- .../MediaFileTableCleanupServiceFixture.cs | 70 +- .../UpdateMediaInfoServiceFixture.cs | 2 +- .../ImportDecisionMakerFixture.cs | 149 ++--- .../SampleServiceFixture.cs | 87 +-- .../FreeSpaceSpecificationFixture.cs | 52 +- .../MatchesFolderSpecificationFixture.cs | 67 ++ .../NotSampleSpecificationFixture.cs | 40 ++ .../NotUnpackingSpecificationFixture.cs | 24 +- .../SameFileSpecificationFixture.cs | 6 +- .../UpgradeSpecificationFixture.cs | 77 +++ ...re.cs => RenameMovieFileServiceFixture.cs} | 59 +- .../UpgradeMediaFileServiceFixture.cs | 108 +--- .../CommandEqualityComparerFixture.cs | 63 +- .../Roksbox/FindMetadataFileFixture.cs | 2 +- .../Consumers/Wdtv/FindMetadataFileFixture.cs | 2 +- ...xture.cs => SearchMovieComparerFixture.cs} | 20 +- .../SkyHook/SkyHookProxyFixture.cs | 85 +-- .../SkyHook/SkyHookProxySearchFixture.cs | 22 +- .../MoveMovieServiceFixture.cs} | 52 +- .../MovieRepositoryFixture.cs} | 14 +- .../MovieServiceTests/AddMovieFixture.cs | 39 ++ .../MovieServiceTests/UpdateMovieFixture.cs | 42 ++ .../UpdateMultipleMoviesFixture.cs} | 145 +++-- .../MovieTitleNormalizerFixture.cs} | 12 +- .../MovieTests/RefreshMovieServiceFixture.cs | 86 +++ .../MovieTests/ShouldRefreshMovieFixture.cs | 125 ++++ .../SynologyIndexerFixture.cs | 2 +- .../Xbmc/Json/GetMoviePathFixture.cs | 2 +- .../Xbmc/Json/UpdateMovieFixture.cs | 2 +- .../Xbmc/OnDownloadFixture.cs | 2 +- .../NzbDrone.Core.Test.csproj | 97 +-- .../OrganizerTests/BuildFilePathFixture.cs | 64 -- .../FileNameBuilderTests/CleanTitleFixture.cs | 47 +- .../EpisodeTitleCollapseFixture.cs | 113 ---- .../FileNameBuilderFixture.cs | 502 ++++----------- .../MultiEpisodeFixture.cs | 271 -------- .../OrganizerTests/GetMovieFolderFixture.cs | 4 +- .../OrganizerTests/GetSeasonFolderFixture.cs | 34 - .../OrganizerTests/GetSeriesFolderFixture.cs | 39 -- .../AbsoluteEpisodeNumberParserFixture.cs | 132 ---- .../ParserTests/AnimeMetadataParserFixture.cs | 34 - .../ParserTests/CrapParserFixture.cs | 8 +- .../ParserTests/DailyEpisodeParserFixture.cs | 81 --- .../ParserTests/HashedReleaseFixture.cs | 6 +- .../IsPossibleSpecialEpisodeFixture.cs | 43 -- .../ParserTests/LanguageParserFixture.cs | 4 +- .../MiniSeriesEpisodeParserFixture.cs | 31 - .../ParserTests/MultiEpisodeParserFixture.cs | 70 -- .../ParserTests/ParserFixture.cs | 27 +- .../ParsingServiceTests/GetEpisodesFixture.cs | 346 ---------- ...GetSeriesFixture.cs => GetMovieFixture.cs} | 26 +- .../ParsingServiceTests/MapFixture.cs | 39 +- .../ParserTests/PathParserFixture.cs | 10 +- .../ParserTests/ReleaseGroupParserFixture.cs | 2 +- .../ParserTests/SeasonParserFixture.cs | 58 -- .../ParserTests/SeriesTitleInfoFixture.cs | 12 +- .../ParserTests/SingleEpisodeParserFixture.cs | 9 +- .../Profiles/ProfileServiceFixture.cs | 2 +- .../GetVideoFilesFixture.cs | 8 +- .../QueueTests/QueueServiceFixture.cs | 20 +- .../RootFolderServiceFixture.cs | 2 +- .../SeriesStatisticsFixture.cs | 182 ------ .../SetEpisodeMontitoredFixture.cs | 221 ------- .../ByAirDateFixture.cs | 71 --- .../EpisodesBetweenDatesFixture.cs | 40 -- .../EpisodesRepositoryReadFixture.cs | 47 -- .../EpisodesWhereCutoffUnmetFixture.cs | 184 ------ .../EpisodesWithFilesFixture.cs | 81 --- .../EpisodesWithoutFilesFixture.cs | 167 ----- .../FindEpisodeFixture.cs | 85 --- .../FindEpisodeByTitleFixture.cs | 71 --- .../HandleEpisodeFileDeletedFixture.cs | 123 ---- .../TvTests/RefreshEpisodeServiceFixture.cs | 397 ------------ .../TvTests/RefreshSeriesServiceFixture.cs | 184 ------ .../SeriesServiceTests/AddSeriesFixture.cs | 39 -- .../SeriesServiceTests/UpdateSeriesFixture.cs | 72 --- .../TvTests/ShouldRefreshSeriesFixture.cs | 135 ---- src/NzbDrone.Core/Blacklisting/Blacklist.cs | 7 +- .../Blacklisting/BlacklistRepository.cs | 15 +- .../Blacklisting/BlacklistService.cs | 14 +- .../DailySeries/DailySeries.cs | 7 - .../DailySeries/DailySeriesDataProxy.cs | 46 -- .../DailySeries/DailySeriesService.cs | 30 - .../Scene/ISceneMappingProvider.cs | 9 - .../DataAugmentation/Scene/SceneMapping.cs | 22 - .../Scene/SceneMappingProxy.cs | 32 - .../Scene/SceneMappingRepository.cs | 31 - .../Scene/SceneMappingService.cs | 253 -------- .../Scene/SceneMappingsUpdatedEvent.cs | 8 - .../Scene/ServicesProvider.cs | 19 - .../Scene/UpdateSceneMappingCommand.cs | 9 - .../Migration/104_add_moviefiles_table.cs | 2 +- .../Migration/133_add_minimumavailability.cs | 2 +- .../Migration/136_add_pathstate_to_movies.cs | 2 +- .../138_add_physical_release_note.cs | 2 +- .../Datastore/Migration/143_clean_core_tv.cs | 36 ++ src/NzbDrone.Core/Datastore/TableMapping.cs | 35 +- .../DecisionEngine/DownloadDecision.cs | 31 +- .../DownloadDecisionComparer.cs | 48 +- .../DecisionEngine/DownloadDecisionMaker.cs | 128 +--- .../DownloadDecisionPriorizationService.cs | 15 +- .../IDecisionEngineSpecification.cs | 4 +- .../SameEpisodesSpecification.cs | 35 - .../AcceptableSizeSpecification.cs | 92 +-- .../AnimeVersionUpgradeSpecification.cs | 38 +- .../Specifications/BlacklistSpecification.cs | 11 - .../Specifications/CutoffSpecification.cs | 17 - .../Specifications/FullSeasonSpecification.cs | 45 -- .../Specifications/LanguageSpecification.cs | 15 - .../Specifications/MinimumAgeSpecification.cs | 33 +- .../Specifications/NotSampleSpecification.cs | 13 +- .../Specifications/ProtocolSpecification.cs | 27 +- .../QualityAllowedByProfileSpecification.cs | 12 - .../Specifications/QueueSpecification.cs | 28 - .../Specifications/RawDiskSpecification.cs | 22 - .../ReleaseRestrictionsSpecification.cs | 40 -- .../RequiredIndexerFlagsSpecification.cs | 44 +- .../Specifications/RetentionSpecification.cs | 23 +- .../RssSync/AvailabilitySpecification.cs | 29 +- .../RssSync/DelaySpecification.cs | 70 +- .../RssSync/HistorySpecification.cs | 7 +- .../RssSync/MonitoredEpisodeSpecification.cs | 66 -- .../RssSync/MonitoredMovieSpecification.cs | 39 ++ .../RssSync/ProperSpecification.cs | 28 - .../SameEpisodesGrabSpecification.cs | 37 -- .../Search/DailyEpisodeMatchSpecification.cs | 30 +- .../Search/EpisodeRequestedSpecification.cs | 45 -- .../Search/MovieSpecification.cs | 36 ++ .../Search/SeasonMatchSpecification.cs | 44 -- .../Search/SeriesSpecification.cs | 54 -- .../Search/SingleEpisodeMatchSpecification.cs | 45 -- .../SingleEpisodeSearchMatchSpecification.cs | 56 -- .../TorrentSeedingSpecification.cs | 45 +- .../UpgradeDiskSpecification.cs | 15 - .../DiskSpace/DiskSpaceService.cs | 18 +- .../Clients/Blackhole/TorrentBlackhole.cs | 13 +- .../Clients/Blackhole/UsenetBlackhole.cs | 7 +- .../Download/Clients/Deluge/Deluge.cs | 12 +- .../DownloadStation/TorrentDownloadStation.cs | 18 +- .../DownloadStation/UsenetDownloadStation.cs | 9 +- .../Download/Clients/Hadouken/Hadouken.cs | 12 +- .../Download/Clients/NzbVortex/NzbVortex.cs | 9 +- .../Download/Clients/Nzbget/Nzbget.cs | 5 - .../Download/Clients/Pneumatic/Pneumatic.cs | 16 +- .../Clients/QBittorrent/QBittorrent.cs | 10 - .../Download/Clients/Sabnzbd/Sabnzbd.cs | 5 - .../Clients/Transmission/TransmissionBase.cs | 12 +- .../Download/Clients/rTorrent/RTorrent.cs | 12 +- .../Download/Clients/uTorrent/UTorrent.cs | 10 - .../Download/CompletedDownloadService.cs | 4 +- .../Download/DownloadClientBase.cs | 7 +- .../Download/DownloadFailedEvent.cs | 8 +- src/NzbDrone.Core/Download/DownloadService.cs | 59 +- .../Download/EpisodeGrabbedEvent.cs | 17 - .../Download/FailedDownloadService.cs | 4 +- src/NzbDrone.Core/Download/IDownloadClient.cs | 5 +- .../Download/Pending/PendingRelease.cs | 5 +- .../Pending/PendingReleaseRepository.cs | 16 +- .../Download/Pending/PendingReleaseService.cs | 12 +- .../Download/ProcessDownloadDecisions.cs | 156 ++--- .../RedownloadFailedDownloadService.cs | 6 +- .../Download/TorrentClientBase.cs | 228 +------ .../DownloadMonitoringService.cs | 10 +- .../TrackedDownloads/TrackedDownload.cs | 3 +- .../TrackedDownloadService.cs | 2 +- .../Download/UsenetClientBase.cs | 61 +- .../Exceptions/SeriesNotFoundException.cs | 27 - src/NzbDrone.Core/Extras/ExtraService.cs | 2 +- .../Extras/Files/ExtraFileManager.cs | 2 +- .../Extras/Files/ExtraFileService.cs | 4 +- .../Extras/IImportExistingExtraFiles.cs | 2 +- .../Extras/ImportExistingExtraFilesBase.cs | 2 +- .../MediaBrowser/MediaBrowserMetadata.cs | 2 +- .../Consumers/Roksbox/RoksboxMetadata.cs | 2 +- .../Metadata/Consumers/Wdtv/WdtvMetadata.cs | 2 +- .../Metadata/Consumers/Xbmc/XbmcMetadata.cs | 2 +- .../Metadata/ExistingMetadataImporter.cs | 2 +- .../Files/CleanMetadataFileService.cs | 2 +- .../Metadata/Files/MetadataFileService.cs | 2 +- .../Extras/Metadata/IMetadata.cs | 2 +- .../Extras/Metadata/MetadataBase.cs | 2 +- .../Extras/Metadata/MetadataService.cs | 8 +- .../Others/ExistingOtherExtraImporter.cs | 2 +- .../Extras/Others/OtherExtraFileService.cs | 2 +- .../Extras/Others/OtherExtraService.cs | 2 +- .../Subtitles/ExistingSubtitleImporter.cs | 2 +- .../Extras/Subtitles/SubtitleFileService.cs | 2 +- .../Extras/Subtitles/SubtitleService.cs | 2 +- .../HealthCheck/Checks/RootFolderCheck.cs | 12 +- src/NzbDrone.Core/History/History.cs | 10 +- .../History/HistoryRepository.cs | 8 +- src/NzbDrone.Core/History/HistoryService.cs | 16 +- .../Housekeepers/CleanupOrphanedEpisodes.cs | 26 - .../CleanupOrphanedHistoryItems.cs | 28 +- ...eFiles.cs => CleanupOrphanedMovieFiles.cs} | 6 +- .../Housekeepers/CleanupUnusedTags.cs | 4 +- .../Housekeepers/DeleteBadMediaCovers.cs | 2 +- ...Series.cs => UpdateCleanTitleForMovies.cs} | 8 +- .../Definitions/AnimeEpisodeSearchCriteria.cs | 12 - .../Definitions/DailyEpisodeSearchCriteria.cs | 14 - .../Definitions/SearchCriteriaBase.cs | 7 +- .../Definitions/SeasonSearchCriteria.cs | 14 - .../SingleEpisodeSearchCriteria.cs | 13 - .../SpecialEpisodeSearchCriteria.cs | 21 - .../IndexerSearch/EpisodeSearchCommand.cs | 21 - .../IndexerSearch/EpisodeSearchService.cs | 131 ---- .../MissingEpisodeSearchCommand.cs | 20 - .../IndexerSearch/MoviesSearchService.cs | 2 +- .../IndexerSearch/NzbSearchService.cs | 222 +------ .../IndexerSearch/SeasonSearchCommand.cs | 12 - .../IndexerSearch/SeasonSearchService.cs | 31 - .../IndexerSearch/SeriesSearchCommand.cs | 11 - .../IndexerSearch/SeriesSearchService.cs | 49 -- .../AwesomeHD/AwesomeHDRequestGenerator.cs | 25 - .../Indexers/HDBits/HDBitsRequestGenerator.cs | 29 +- src/NzbDrone.Core/Indexers/HttpIndexerBase.cs | 62 +- src/NzbDrone.Core/Indexers/IIndexer.cs | 7 +- .../Indexers/IIndexerRequestGenerator.cs | 9 +- .../IPTorrents/IPTorrentsRequestGenerator.cs | 29 +- src/NzbDrone.Core/Indexers/IndexerBase.cs | 7 +- .../Newznab/NewznabRequestGenerator.cs | 28 +- .../Indexers/Nyaa/NyaaRequestGenerator.cs | 50 +- .../Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs | 65 +- .../PassThePopcornRequestGenerator.cs | 29 +- .../Indexers/Rarbg/RarbgParser.cs | 12 +- .../Indexers/Rarbg/RarbgRequestGenerator.cs | 27 +- .../Indexers/Rarbg/RarbgResponse.cs | 2 +- .../Indexers/RssIndexerRequestGenerator.cs | 27 +- .../TorrentPotatoRequestGenerator.cs | 27 +- .../TorrentRssIndexerRequestGenerator.cs | 27 +- src/NzbDrone.Core/Jobs/TaskManager.cs | 6 +- .../MediaCover/MediaCoverService.cs | 135 +--- .../MediaCover/MediaCoversUpdatedEvent.cs | 11 +- .../Commands/DownloadedEpisodesScanCommand.cs | 17 - .../Commands/DownloadedMovieScanCommand.cs | 2 +- .../MediaFiles/Commands/RenameFilesCommand.cs | 10 +- .../Commands/RenameSeriesCommand.cs | 16 - .../Commands/RescanSeriesCommand.cs | 20 - .../MediaFiles/DiskScanService.cs | 126 +--- .../DownloadedEpisodesCommandService.cs | 105 --- .../DownloadedEpisodesImportService.cs | 265 -------- .../DownloadedMovieCommandService.cs | 2 +- .../DownloadedMovieImportService.cs | 16 +- src/NzbDrone.Core/MediaFiles/EpisodeFile.cs | 31 - .../MediaFiles/EpisodeFileMoveResult.cs | 15 - .../MediaFiles/EpisodeFileMovingService.cs | 215 ------- .../EpisodeImport/ImportApprovedEpisodes.cs | 175 ----- .../Specifications/FullSeasonSpecification.cs | 33 - .../MatchesFolderSpecification.cs | 98 --- .../NotUnpackingSpecification.cs | 96 --- .../SameEpisodesImportSpecification.cs | 38 -- .../UnverifiedSceneNumberingSpecification.cs | 40 -- .../Specifications/UpgradeSpecification.cs | 36 -- .../Events/EpisodeDownloadedEvent.cs | 20 - .../Events/EpisodeFileAddedEvent.cs | 14 - .../Events/EpisodeFileDeletedEvent.cs | 16 - .../Events/EpisodeFolderCreatedEvent.cs | 20 - .../MediaFiles/Events/EpisodeImportedEvent.cs | 32 - .../MediaFiles/Events/MovieDownloadedEvent.cs | 6 +- .../MediaFiles/Events/MovieFileAddedEvent.cs | 8 +- .../Events/MovieFileDeletedEvent.cs | 8 +- .../Events/MovieFolderCreatedEvent.cs | 6 +- .../MediaFiles/Events/MovieImportedEvent.cs | 12 +- .../MediaFiles/Events/MovieRenamedEvent.cs | 2 +- .../Events/MovieScanSkippedEvent.cs | 2 +- .../MediaFiles/Events/MovieScannedEvent.cs | 2 +- .../MediaFiles/Events/SeriesRenamedEvent.cs | 15 - .../Events/SeriesScanSkippedEvent.cs | 24 - .../MediaFiles/Events/SeriesScannedEvent.cs | 15 - .../MediaFiles/MediaFileAttributeService.cs | 4 +- .../MediaFiles/MediaFileRepository.cs | 26 +- .../MediaFiles/MediaFileService.cs | 135 +--- .../MediaFileTableCleanupService.cs | 68 +- .../MediaInfo/UpdateMediaInfoService.cs | 8 +- src/NzbDrone.Core/MediaFiles/MovieFile.cs | 2 +- .../MediaFiles/MovieFileMovingService.cs | 2 +- .../MediaFiles/MovieFileRepository.cs | 32 - .../DetectSample.cs | 76 +-- .../IImportDecisionEngineSpecification.cs | 6 +- .../ImportApprovedMovie.cs | 10 +- .../ImportDecision.cs | 11 +- .../ImportDecisionMaker.cs | 185 +----- .../ImportMode.cs | 2 +- .../ImportResult.cs | 2 +- .../ImportResultType.cs | 2 +- .../Manual/ManualImportCommand.cs | 2 +- .../Manual/ManualImportFile.cs | 2 +- .../Manual/ManualImportItem.cs | 9 +- .../Manual/ManualImportService.cs | 175 +---- .../Manual/ManuallyImportedFile.cs | 2 +- .../Specifications/FreeSpaceSpecification.cs | 49 +- .../GrabbedReleaseQualitySpecification.cs | 30 +- .../MatchesFolderSpecification.cs | 44 ++ .../Specifications/NotSampleSpecification.cs | 26 +- .../NotUnpackingSpecification.cs | 61 ++ .../Specifications/SameFileSpecification.cs | 7 +- .../UnverifiedSceneNumberingSpecification.cs | 23 + .../Specifications/UpgradeSpecification.cs | 24 + .../MediaFiles/RecycleBinProvider.cs | 17 +- .../MediaFiles/RenameEpisodeFilePreview.cs | 14 - .../MediaFiles/RenameEpisodeFileService.cs | 171 ----- .../MediaFiles/RenameMovieFileService.cs | 2 +- .../MediaFiles/UpdateEpisodeFileService.cs | 175 ----- .../MediaFiles/UpdateMovieFileService.cs | 2 +- .../MediaFiles/UpgradeMediaFileService.cs | 45 +- .../MetadataSource/IDiscoverNewMovies.cs | 2 +- .../MetadataSource/IProvideMovieInfo.cs | 2 +- .../MetadataSource/IProvideSeriesInfo.cs | 11 - .../MetadataSource/ISearchForNewMovie.cs | 2 +- .../MetadataSource/ISearchForNewSeries.cs | 10 - .../MetadataSource/PreDB/PreDBService.cs | 2 +- .../MetadataSource/PreDB/PreDBSyncEvent.cs | 2 +- ...riesComparer.cs => SearchMovieComparer.cs} | 18 +- .../MetadataSource/SkyHook/SkyHookProxy.cs | 188 +----- .../MovieStats/MovieStatistics.cs | 42 -- .../MovieStats/MovieStatisticsRepository.cs | 86 --- .../MovieStats/MovieStatisticsService.cs | 63 -- .../MovieStats/SeasonStatistics.cs | 41 -- src/NzbDrone.Core/{Tv => Movies}/Actor.cs | 4 +- src/NzbDrone.Core/Movies/AddMovieOptions.cs | 7 + .../AlternativeTitles/AlternativeTitle.cs | 2 +- .../AlternativeTitleService.cs | 7 +- .../Commands/MoveMovieCommand.cs} | 8 +- .../Commands/RefreshMovieCommand.cs | 2 +- .../{Tv => Movies}/Events/MovieAddedEvent.cs | 2 +- .../Events/MovieDeletedEvent.cs | 2 +- .../{Tv => Movies}/Events/MovieEditedEvent.cs | 2 +- .../Movies/Events/MovieMovedEvent.cs | 18 + .../Events/MovieRefreshStartingEvent.cs | 2 +- .../{Tv => Movies}/Events/MovieUpdateEvent.cs | 2 +- .../{Tv => Movies}/MonitoringOptions.cs | 2 +- .../MoveMovieService.cs} | 38 +- src/NzbDrone.Core/{Tv => Movies}/Movie.cs | 9 +- .../{Tv => Movies}/MovieAddedHandler.cs | 6 +- .../{Tv => Movies}/MovieCutoffService.cs | 2 +- .../{Tv => Movies}/MovieEditedService.cs | 6 +- .../{Tv => Movies}/MovieRepository.cs | 8 +- .../{Tv => Movies}/MovieScannedHandler.cs | 2 +- .../{Tv => Movies}/MovieService.cs | 17 +- .../{Tv => Movies}/MovieStatusType.cs | 2 +- .../{Tv => Movies}/MovieTitleNormalizer.cs | 2 +- .../{Tv => Movies}/QueryExtensions.cs | 2 +- src/NzbDrone.Core/{Tv => Movies}/Ratings.cs | 2 +- .../{Tv => Movies}/RefreshMovieService.cs | 6 +- .../{Tv => Movies}/ShouldRefreshMovie.cs | 8 +- .../CouchPotato/CouchPotatoParser.cs | 8 +- .../NetImport/HttpNetImportBase.cs | 2 +- src/NzbDrone.Core/NetImport/INetImport.cs | 2 +- .../NetImport/IProcessNetImportResponse.cs | 2 +- .../ImportExclusionsService.cs | 5 +- src/NzbDrone.Core/NetImport/NetImportBase.cs | 2 +- .../NetImport/NetImportDefinition.cs | 2 +- .../NetImport/NetImportSearchService.cs | 2 +- .../NetImport/RSSImport/RSSImportParser.cs | 2 +- .../NetImport/Radarr/RadarrParser.cs | 4 +- .../NetImport/StevenLu/StevenLuParser.cs | 6 +- .../NetImport/TMDb/TMDbParser.cs | 4 +- .../NetImport/Trakt/TraktParser.cs | 8 +- .../Notifications/Boxcar/Boxcar.cs | 2 +- .../CustomScript/CustomScript.cs | 2 +- .../Notifications/DownloadMessage.cs | 2 +- .../Notifications/Email/Email.cs | 2 +- .../Notifications/GrabMessage.cs | 2 +- .../Notifications/Growl/Growl.cs | 2 +- .../Notifications/INotification.cs | 2 +- src/NzbDrone.Core/Notifications/Join/Join.cs | 2 +- .../MediaBrowser/MediaBrowser.cs | 2 +- .../MediaBrowser/MediaBrowserService.cs | 2 +- .../Notifications/NotificationBase.cs | 2 +- .../Notifications/NotificationService.cs | 22 +- .../NotifyMyAndroid/NotifyMyAndroid.cs | 2 +- .../Notifications/Plex/PlexClient.cs | 2 +- .../Notifications/Plex/PlexHomeTheater.cs | 2 +- .../Notifications/Plex/PlexServer.cs | 2 +- .../Notifications/Plex/PlexServerService.cs | 2 +- .../Notifications/Prowl/Prowl.cs | 2 +- .../Notifications/PushBullet/PushBullet.cs | 2 +- .../Notifications/Pushalot/Pushalot.cs | 2 +- .../Notifications/Pushover/Pushover.cs | 2 +- .../Notifications/Slack/Slack.cs | 2 +- .../Notifications/Synology/SynologyIndexer.cs | 2 +- .../Notifications/Telegram/Telegram.cs | 2 +- .../Notifications/Twitter/Twitter.cs | 2 +- .../Notifications/Webhook/Webhook.cs | 2 +- .../Notifications/Webhook/WebhookMovie.cs | 4 +- .../Webhook/WebhookRemoteMovie.cs | 2 +- .../Notifications/Xbmc/IApiProvider.cs | 2 +- .../Notifications/Xbmc/JsonApiProvider.cs | 2 +- src/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs | 2 +- .../Notifications/Xbmc/XbmcService.cs | 2 +- src/NzbDrone.Core/NzbDrone.Core.csproj | 215 ++----- .../Organizer/FileNameBuilder.cs | 596 ++---------------- .../Organizer/FileNameSampleService.cs | 202 +----- .../Organizer/FileNameValidation.cs | 2 +- .../Organizer/FileNameValidationService.cs | 92 +-- src/NzbDrone.Core/Organizer/NamingConfig.cs | 12 +- src/NzbDrone.Core/Organizer/SampleResult.cs | 9 +- .../Parser/Model/LocalEpisode.cs | 40 -- src/NzbDrone.Core/Parser/Model/LocalMovie.cs | 2 +- .../Parser/Model/ParsedEpisodeInfo.cs | 92 --- .../Parser/Model/RemoteEpisode.cs | 26 - src/NzbDrone.Core/Parser/Model/RemoteMovie.cs | 5 +- src/NzbDrone.Core/Parser/Parser.cs | 504 +-------------- src/NzbDrone.Core/Parser/ParsingService.cs | 457 +------------- src/NzbDrone.Core/Profiles/ProfileService.cs | 2 +- src/NzbDrone.Core/Queue/Queue.cs | 7 +- src/NzbDrone.Core/Queue/QueueService.cs | 44 +- .../RootFolders/RootFolderService.cs | 40 +- .../SeriesStats/SeasonStatistics.cs | 41 -- .../SeriesStats/SeriesStatistics.cs | 42 -- .../SeriesStats/SeriesStatisticsRepository.cs | 82 --- .../SeriesStats/SeriesStatisticsService.cs | 63 -- src/NzbDrone.Core/Tv/AddSeriesOptions.cs | 7 - .../Tv/Commands/RefreshSeriesCommand.cs | 22 - src/NzbDrone.Core/Tv/Episode.cs | 49 -- src/NzbDrone.Core/Tv/EpisodeAddedService.cs | 88 --- src/NzbDrone.Core/Tv/EpisodeCutoffService.cs | 48 -- .../Tv/EpisodeMonitoredService.cs | 109 ---- src/NzbDrone.Core/Tv/EpisodeRepository.cs | 266 -------- src/NzbDrone.Core/Tv/EpisodeService.cs | 225 ------- .../Tv/Events/EpisodeInfoRefreshedEvent.cs | 20 - .../Tv/Events/SeriesAddedEvent.cs | 14 - .../Tv/Events/SeriesDeletedEvent.cs | 16 - .../Tv/Events/SeriesEditedEvent.cs | 16 - .../Tv/Events/SeriesMovedEvent.cs | 18 - .../Tv/Events/SeriesRefreshStartingEvent.cs | 14 - .../Tv/Events/SeriesUpdatedEvent.cs | 14 - src/NzbDrone.Core/Tv/RefreshEpisodeService.cs | 199 ------ src/NzbDrone.Core/Tv/RefreshSeriesService.cs | 190 ------ src/NzbDrone.Core/Tv/Season.cs | 17 - src/NzbDrone.Core/Tv/Series.cs | 61 -- src/NzbDrone.Core/Tv/SeriesAddedHandler.cs | 22 - src/NzbDrone.Core/Tv/SeriesEditedService.cs | 25 - src/NzbDrone.Core/Tv/SeriesRepository.cs | 56 -- src/NzbDrone.Core/Tv/SeriesScannedHandler.cs | 62 -- src/NzbDrone.Core/Tv/SeriesService.cs | 226 ------- src/NzbDrone.Core/Tv/SeriesStatusType.cs | 8 - src/NzbDrone.Core/Tv/SeriesTitleNormalizer.cs | 24 - src/NzbDrone.Core/Tv/SeriesTypes.cs | 9 - src/NzbDrone.Core/Tv/ShouldRefreshSeries.cs | 55 -- .../Paths/MovieAncestorValidator.cs | 14 +- .../Validation/Paths/MovieExistsValidator.cs | 14 +- .../Validation/Paths/MoviePathValidation.cs | 2 +- .../Paths/SeriesAncestorValidator.cs | 25 - .../Validation/Paths/SeriesExistsValidator.cs | 26 - .../Validation/Paths/SeriesPathValidator.cs | 27 - .../ApiTests/MovieFixture.cs | 2 +- .../IntegrationTestBase.cs | 4 +- 551 files changed, 2837 insertions(+), 18869 deletions(-) delete mode 100644 src/NzbDrone.Core.Test/DataAugmentation/DailySeries/DailySeriesDataProxyFixture.cs delete mode 100644 src/NzbDrone.Core.Test/DataAugmentation/Scene/SceneMappingProxyFixture.cs delete mode 100644 src/NzbDrone.Core.Test/DataAugmentation/Scene/SceneMappingServiceFixture.cs delete mode 100644 src/NzbDrone.Core.Test/DecisionEngineTests/AnimeVersionUpgradeSpecificationFixture.cs delete mode 100644 src/NzbDrone.Core.Test/DecisionEngineTests/FullSeasonSpecificationFixture.cs rename src/NzbDrone.Core.Test/DecisionEngineTests/{MonitoredEpisodeSpecificationFixture.cs => MonitoredMovieSpecificationFixture.cs} (52%) delete mode 100644 src/NzbDrone.Core.Test/DecisionEngineTests/SameEpisodesSpecificationFixture.cs rename src/NzbDrone.Core.Test/DecisionEngineTests/Search/{SeriesSpecificationFixture.cs => MovieSpecificationFixture.cs} (54%) delete mode 100644 src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedEpisodesFixture.cs rename src/NzbDrone.Core.Test/Housekeeping/Housekeepers/{CleanupOrphanedEpisodeFilesFixture.cs => CleanupOrphanedMovieFilesFixture.cs} (91%) delete mode 100644 src/NzbDrone.Core.Test/IndexerSearchTests/NzbSearchServiceFixture.cs delete mode 100644 src/NzbDrone.Core.Test/IndexerSearchTests/SeriesSearchServiceFixture.cs delete mode 100644 src/NzbDrone.Core.Test/IndexerTests/SeasonSearchFixture.cs delete mode 100644 src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/FullSeasonSpecificationFixture.cs delete mode 100644 src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecificationFixture.cs delete mode 100644 src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/NotSampleSpecificationFixture.cs delete mode 100644 src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/UpgradeSpecificationFixture.cs rename src/NzbDrone.Core.Test/MediaFiles/{EpisodeImport => MovieImport}/ImportDecisionMakerFixture.cs (60%) rename src/NzbDrone.Core.Test/MediaFiles/{EpisodeImport => MovieImport}/SampleServiceFixture.cs (55%) rename src/NzbDrone.Core.Test/MediaFiles/{EpisodeImport => MovieImport}/Specifications/FreeSpaceSpecificationFixture.cs (65%) create mode 100644 src/NzbDrone.Core.Test/MediaFiles/MovieImport/Specifications/MatchesFolderSpecificationFixture.cs create mode 100644 src/NzbDrone.Core.Test/MediaFiles/MovieImport/Specifications/NotSampleSpecificationFixture.cs rename src/NzbDrone.Core.Test/MediaFiles/{EpisodeImport => MovieImport}/Specifications/NotUnpackingSpecificationFixture.cs (70%) rename src/NzbDrone.Core.Test/MediaFiles/{EpisodeImport => MovieImport}/Specifications/SameFileSpecificationFixture.cs (93%) create mode 100644 src/NzbDrone.Core.Test/MediaFiles/MovieImport/Specifications/UpgradeSpecificationFixture.cs rename src/NzbDrone.Core.Test/MediaFiles/{RenameEpisodeFileServiceFixture.cs => RenameMovieFileServiceFixture.cs} (50%) rename src/NzbDrone.Core.Test/MetadataSource/{SearchSeriesComparerFixture.cs => SearchMovieComparerFixture.cs} (74%) rename src/NzbDrone.Core.Test/{TvTests/MoveSeriesServiceFixture.cs => MovieTests/MoveMovieServiceFixture.cs} (52%) rename src/NzbDrone.Core.Test/{TvTests/SeriesRepositoryTests/SeriesRepositoryFixture.cs => MovieTests/MovieRepositoryTests/MovieRepositoryFixture.cs} (70%) create mode 100644 src/NzbDrone.Core.Test/MovieTests/MovieServiceTests/AddMovieFixture.cs create mode 100644 src/NzbDrone.Core.Test/MovieTests/MovieServiceTests/UpdateMovieFixture.cs rename src/NzbDrone.Core.Test/{TvTests/SeriesServiceTests/UpdateMultipleSeriesFixture.cs => MovieTests/MovieServiceTests/UpdateMultipleMoviesFixture.cs} (52%) rename src/NzbDrone.Core.Test/{TvTests/SeriesTitleNormalizerFixture.cs => MovieTests/MovieTitleNormalizerFixture.cs} (73%) create mode 100644 src/NzbDrone.Core.Test/MovieTests/RefreshMovieServiceFixture.cs create mode 100644 src/NzbDrone.Core.Test/MovieTests/ShouldRefreshMovieFixture.cs delete mode 100644 src/NzbDrone.Core.Test/OrganizerTests/BuildFilePathFixture.cs delete mode 100644 src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/EpisodeTitleCollapseFixture.cs delete mode 100644 src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/MultiEpisodeFixture.cs delete mode 100644 src/NzbDrone.Core.Test/OrganizerTests/GetSeasonFolderFixture.cs delete mode 100644 src/NzbDrone.Core.Test/OrganizerTests/GetSeriesFolderFixture.cs delete mode 100644 src/NzbDrone.Core.Test/ParserTests/AbsoluteEpisodeNumberParserFixture.cs delete mode 100644 src/NzbDrone.Core.Test/ParserTests/AnimeMetadataParserFixture.cs delete mode 100644 src/NzbDrone.Core.Test/ParserTests/DailyEpisodeParserFixture.cs delete mode 100644 src/NzbDrone.Core.Test/ParserTests/IsPossibleSpecialEpisodeFixture.cs delete mode 100644 src/NzbDrone.Core.Test/ParserTests/MiniSeriesEpisodeParserFixture.cs delete mode 100644 src/NzbDrone.Core.Test/ParserTests/MultiEpisodeParserFixture.cs delete mode 100644 src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetEpisodesFixture.cs rename src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/{GetSeriesFixture.cs => GetMovieFixture.cs} (54%) delete mode 100644 src/NzbDrone.Core.Test/ParserTests/SeasonParserFixture.cs delete mode 100644 src/NzbDrone.Core.Test/SeriesStatsTests/SeriesStatisticsFixture.cs delete mode 100644 src/NzbDrone.Core.Test/TvTests/EpisodeMonitoredServiceTests/SetEpisodeMontitoredFixture.cs delete mode 100644 src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/ByAirDateFixture.cs delete mode 100644 src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesBetweenDatesFixture.cs delete mode 100644 src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesRepositoryReadFixture.cs delete mode 100644 src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWhereCutoffUnmetFixture.cs delete mode 100644 src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWithFilesFixture.cs delete mode 100644 src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWithoutFilesFixture.cs delete mode 100644 src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/FindEpisodeFixture.cs delete mode 100644 src/NzbDrone.Core.Test/TvTests/EpisodeServiceTests/FindEpisodeByTitleFixture.cs delete mode 100644 src/NzbDrone.Core.Test/TvTests/EpisodeServiceTests/HandleEpisodeFileDeletedFixture.cs delete mode 100644 src/NzbDrone.Core.Test/TvTests/RefreshEpisodeServiceFixture.cs delete mode 100644 src/NzbDrone.Core.Test/TvTests/RefreshSeriesServiceFixture.cs delete mode 100644 src/NzbDrone.Core.Test/TvTests/SeriesServiceTests/AddSeriesFixture.cs delete mode 100644 src/NzbDrone.Core.Test/TvTests/SeriesServiceTests/UpdateSeriesFixture.cs delete mode 100644 src/NzbDrone.Core.Test/TvTests/ShouldRefreshSeriesFixture.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeries.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesDataProxy.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesService.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/Scene/ISceneMappingProvider.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/Scene/SceneMapping.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingProxy.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingRepository.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingsUpdatedEvent.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/Scene/ServicesProvider.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/Scene/UpdateSceneMappingCommand.cs create mode 100644 src/NzbDrone.Core/Datastore/Migration/143_clean_core_tv.cs delete mode 100644 src/NzbDrone.Core/DecisionEngine/SameEpisodesSpecification.cs delete mode 100644 src/NzbDrone.Core/DecisionEngine/Specifications/FullSeasonSpecification.cs delete mode 100644 src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredEpisodeSpecification.cs create mode 100644 src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredMovieSpecification.cs delete mode 100644 src/NzbDrone.Core/DecisionEngine/Specifications/SameEpisodesGrabSpecification.cs delete mode 100644 src/NzbDrone.Core/DecisionEngine/Specifications/Search/EpisodeRequestedSpecification.cs create mode 100644 src/NzbDrone.Core/DecisionEngine/Specifications/Search/MovieSpecification.cs delete mode 100644 src/NzbDrone.Core/DecisionEngine/Specifications/Search/SeasonMatchSpecification.cs delete mode 100644 src/NzbDrone.Core/DecisionEngine/Specifications/Search/SeriesSpecification.cs delete mode 100644 src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleEpisodeMatchSpecification.cs delete mode 100644 src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleEpisodeSearchMatchSpecification.cs delete mode 100644 src/NzbDrone.Core/Download/EpisodeGrabbedEvent.cs delete mode 100644 src/NzbDrone.Core/Exceptions/SeriesNotFoundException.cs delete mode 100644 src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedEpisodes.cs rename src/NzbDrone.Core/Housekeeping/Housekeepers/{CleanupOrphanedEpisodeFiles.cs => CleanupOrphanedMovieFiles.cs} (80%) rename src/NzbDrone.Core/Housekeeping/Housekeepers/{UpdateCleanTitleForSeries.cs => UpdateCleanTitleForMovies.cs} (74%) delete mode 100644 src/NzbDrone.Core/IndexerSearch/Definitions/AnimeEpisodeSearchCriteria.cs delete mode 100644 src/NzbDrone.Core/IndexerSearch/Definitions/DailyEpisodeSearchCriteria.cs delete mode 100644 src/NzbDrone.Core/IndexerSearch/Definitions/SeasonSearchCriteria.cs delete mode 100644 src/NzbDrone.Core/IndexerSearch/Definitions/SingleEpisodeSearchCriteria.cs delete mode 100644 src/NzbDrone.Core/IndexerSearch/Definitions/SpecialEpisodeSearchCriteria.cs delete mode 100644 src/NzbDrone.Core/IndexerSearch/EpisodeSearchCommand.cs delete mode 100644 src/NzbDrone.Core/IndexerSearch/EpisodeSearchService.cs delete mode 100644 src/NzbDrone.Core/IndexerSearch/MissingEpisodeSearchCommand.cs delete mode 100644 src/NzbDrone.Core/IndexerSearch/SeasonSearchCommand.cs delete mode 100644 src/NzbDrone.Core/IndexerSearch/SeasonSearchService.cs delete mode 100644 src/NzbDrone.Core/IndexerSearch/SeriesSearchCommand.cs delete mode 100644 src/NzbDrone.Core/IndexerSearch/SeriesSearchService.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/Commands/DownloadedEpisodesScanCommand.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/Commands/RenameSeriesCommand.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/Commands/RescanSeriesCommand.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/DownloadedEpisodesCommandService.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/EpisodeFile.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/EpisodeFileMoveResult.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FullSeasonSpecification.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecification.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotUnpackingSpecification.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/SameEpisodesImportSpecification.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/UnverifiedSceneNumberingSpecification.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/UpgradeSpecification.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/Events/EpisodeDownloadedEvent.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/Events/EpisodeFileAddedEvent.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/Events/EpisodeFileDeletedEvent.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/Events/EpisodeFolderCreatedEvent.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/Events/EpisodeImportedEvent.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/Events/SeriesRenamedEvent.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/Events/SeriesScanSkippedEvent.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/Events/SeriesScannedEvent.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/MovieFileRepository.cs rename src/NzbDrone.Core/MediaFiles/{EpisodeImport => MovieImport}/DetectSample.cs (58%) rename src/NzbDrone.Core/MediaFiles/{EpisodeImport => MovieImport}/IImportDecisionEngineSpecification.cs (60%) rename src/NzbDrone.Core/MediaFiles/{EpisodeImport => MovieImport}/ImportApprovedMovie.cs (94%) rename src/NzbDrone.Core/MediaFiles/{EpisodeImport => MovieImport}/ImportDecision.cs (72%) rename src/NzbDrone.Core/MediaFiles/{EpisodeImport => MovieImport}/ImportDecisionMaker.cs (73%) rename src/NzbDrone.Core/MediaFiles/{EpisodeImport => MovieImport}/ImportMode.cs (66%) rename src/NzbDrone.Core/MediaFiles/{EpisodeImport => MovieImport}/ImportResult.cs (95%) rename src/NzbDrone.Core/MediaFiles/{EpisodeImport => MovieImport}/ImportResultType.cs (66%) rename src/NzbDrone.Core/MediaFiles/{EpisodeImport => MovieImport}/Manual/ManualImportCommand.cs (84%) rename src/NzbDrone.Core/MediaFiles/{EpisodeImport => MovieImport}/Manual/ManualImportFile.cs (87%) rename src/NzbDrone.Core/MediaFiles/{EpisodeImport => MovieImport}/Manual/ManualImportItem.cs (65%) rename src/NzbDrone.Core/MediaFiles/{EpisodeImport => MovieImport}/Manual/ManualImportService.cs (61%) rename src/NzbDrone.Core/MediaFiles/{EpisodeImport => MovieImport}/Manual/ManuallyImportedFile.cs (79%) rename src/NzbDrone.Core/MediaFiles/{EpisodeImport => MovieImport}/Specifications/FreeSpaceSpecification.cs (57%) rename src/NzbDrone.Core/MediaFiles/{EpisodeImport => MovieImport}/Specifications/GrabbedReleaseQualitySpecification.cs (58%) create mode 100644 src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/MatchesFolderSpecification.cs rename src/NzbDrone.Core/MediaFiles/{EpisodeImport => MovieImport}/Specifications/NotSampleSpecification.cs (56%) create mode 100644 src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/NotUnpackingSpecification.cs rename src/NzbDrone.Core/MediaFiles/{EpisodeImport => MovieImport}/Specifications/SameFileSpecification.cs (84%) create mode 100644 src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/UnverifiedSceneNumberingSpecification.cs create mode 100644 src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/UpgradeSpecification.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/RenameEpisodeFilePreview.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/RenameEpisodeFileService.cs delete mode 100644 src/NzbDrone.Core/MediaFiles/UpdateEpisodeFileService.cs delete mode 100644 src/NzbDrone.Core/MetadataSource/IProvideSeriesInfo.cs delete mode 100644 src/NzbDrone.Core/MetadataSource/ISearchForNewSeries.cs rename src/NzbDrone.Core/MetadataSource/{SearchSeriesComparer.cs => SearchMovieComparer.cs} (89%) delete mode 100644 src/NzbDrone.Core/MovieStats/MovieStatistics.cs delete mode 100644 src/NzbDrone.Core/MovieStats/MovieStatisticsRepository.cs delete mode 100644 src/NzbDrone.Core/MovieStats/MovieStatisticsService.cs delete mode 100644 src/NzbDrone.Core/MovieStats/SeasonStatistics.cs rename src/NzbDrone.Core/{Tv => Movies}/Actor.cs (84%) create mode 100644 src/NzbDrone.Core/Movies/AddMovieOptions.cs rename src/NzbDrone.Core/{Tv/Commands/MoveSeriesCommand.cs => Movies/Commands/MoveMovieCommand.cs} (51%) rename src/NzbDrone.Core/{Tv => Movies}/Commands/RefreshMovieCommand.cs (91%) rename src/NzbDrone.Core/{Tv => Movies}/Events/MovieAddedEvent.cs (86%) rename src/NzbDrone.Core/{Tv => Movies}/Events/MovieDeletedEvent.cs (89%) rename src/NzbDrone.Core/{Tv => Movies}/Events/MovieEditedEvent.cs (89%) create mode 100644 src/NzbDrone.Core/Movies/Events/MovieMovedEvent.cs rename src/NzbDrone.Core/{Tv => Movies}/Events/MovieRefreshStartingEvent.cs (87%) rename src/NzbDrone.Core/{Tv => Movies}/Events/MovieUpdateEvent.cs (85%) rename src/NzbDrone.Core/{Tv => Movies}/MonitoringOptions.cs (87%) rename src/NzbDrone.Core/{Tv/MoveSeriesService.cs => Movies/MoveMovieService.cs} (65%) rename src/NzbDrone.Core/{Tv => Movies}/Movie.cs (96%) rename src/NzbDrone.Core/{Tv => Movies}/MovieAddedHandler.cs (83%) rename src/NzbDrone.Core/{Tv => Movies}/MovieCutoffService.cs (98%) rename src/NzbDrone.Core/{Tv => Movies}/MovieEditedService.cs (87%) rename src/NzbDrone.Core/{Tv => Movies}/MovieRepository.cs (98%) rename src/NzbDrone.Core/{Tv => Movies}/MovieScannedHandler.cs (98%) rename src/NzbDrone.Core/{Tv => Movies}/MovieService.cs (95%) rename src/NzbDrone.Core/{Tv => Movies}/MovieStatusType.cs (94%) rename src/NzbDrone.Core/{Tv => Movies}/MovieTitleNormalizer.cs (95%) rename src/NzbDrone.Core/{Tv => Movies}/QueryExtensions.cs (97%) rename src/NzbDrone.Core/{Tv => Movies}/Ratings.cs (85%) rename src/NzbDrone.Core/{Tv => Movies}/RefreshMovieService.cs (98%) rename src/NzbDrone.Core/{Tv => Movies}/ShouldRefreshMovie.cs (87%) delete mode 100644 src/NzbDrone.Core/Parser/Model/LocalEpisode.cs delete mode 100644 src/NzbDrone.Core/Parser/Model/ParsedEpisodeInfo.cs delete mode 100644 src/NzbDrone.Core/Parser/Model/RemoteEpisode.cs delete mode 100644 src/NzbDrone.Core/SeriesStats/SeasonStatistics.cs delete mode 100644 src/NzbDrone.Core/SeriesStats/SeriesStatistics.cs delete mode 100644 src/NzbDrone.Core/SeriesStats/SeriesStatisticsRepository.cs delete mode 100644 src/NzbDrone.Core/SeriesStats/SeriesStatisticsService.cs delete mode 100644 src/NzbDrone.Core/Tv/AddSeriesOptions.cs delete mode 100644 src/NzbDrone.Core/Tv/Commands/RefreshSeriesCommand.cs delete mode 100644 src/NzbDrone.Core/Tv/Episode.cs delete mode 100644 src/NzbDrone.Core/Tv/EpisodeAddedService.cs delete mode 100644 src/NzbDrone.Core/Tv/EpisodeCutoffService.cs delete mode 100644 src/NzbDrone.Core/Tv/EpisodeMonitoredService.cs delete mode 100644 src/NzbDrone.Core/Tv/EpisodeRepository.cs delete mode 100644 src/NzbDrone.Core/Tv/EpisodeService.cs delete mode 100644 src/NzbDrone.Core/Tv/Events/EpisodeInfoRefreshedEvent.cs delete mode 100644 src/NzbDrone.Core/Tv/Events/SeriesAddedEvent.cs delete mode 100644 src/NzbDrone.Core/Tv/Events/SeriesDeletedEvent.cs delete mode 100644 src/NzbDrone.Core/Tv/Events/SeriesEditedEvent.cs delete mode 100644 src/NzbDrone.Core/Tv/Events/SeriesMovedEvent.cs delete mode 100644 src/NzbDrone.Core/Tv/Events/SeriesRefreshStartingEvent.cs delete mode 100644 src/NzbDrone.Core/Tv/Events/SeriesUpdatedEvent.cs delete mode 100644 src/NzbDrone.Core/Tv/RefreshEpisodeService.cs delete mode 100644 src/NzbDrone.Core/Tv/RefreshSeriesService.cs delete mode 100644 src/NzbDrone.Core/Tv/Season.cs delete mode 100644 src/NzbDrone.Core/Tv/Series.cs delete mode 100644 src/NzbDrone.Core/Tv/SeriesAddedHandler.cs delete mode 100644 src/NzbDrone.Core/Tv/SeriesEditedService.cs delete mode 100644 src/NzbDrone.Core/Tv/SeriesRepository.cs delete mode 100644 src/NzbDrone.Core/Tv/SeriesScannedHandler.cs delete mode 100644 src/NzbDrone.Core/Tv/SeriesService.cs delete mode 100644 src/NzbDrone.Core/Tv/SeriesStatusType.cs delete mode 100644 src/NzbDrone.Core/Tv/SeriesTitleNormalizer.cs delete mode 100644 src/NzbDrone.Core/Tv/SeriesTypes.cs delete mode 100644 src/NzbDrone.Core/Tv/ShouldRefreshSeries.cs delete mode 100644 src/NzbDrone.Core/Validation/Paths/SeriesAncestorValidator.cs delete mode 100644 src/NzbDrone.Core/Validation/Paths/SeriesExistsValidator.cs delete mode 100644 src/NzbDrone.Core/Validation/Paths/SeriesPathValidator.cs diff --git a/src/NzbDrone.Api/Blacklist/BlacklistResource.cs b/src/NzbDrone.Api/Blacklist/BlacklistResource.cs index 305e7966f..f3259fd3c 100644 --- a/src/NzbDrone.Api/Blacklist/BlacklistResource.cs +++ b/src/NzbDrone.Api/Blacklist/BlacklistResource.cs @@ -31,8 +31,6 @@ namespace NzbDrone.Api.Blacklist { Id = model.Id, MovieId = model.MovieId, - SeriesId = model.SeriesId, - EpisodeIds = model.EpisodeIds, SourceTitle = model.SourceTitle, Quality = model.Quality, Date = model.Date, diff --git a/src/NzbDrone.Api/Calendar/CalendarFeedModule.cs b/src/NzbDrone.Api/Calendar/CalendarFeedModule.cs index 90c0ee75b..11497f05e 100644 --- a/src/NzbDrone.Api/Calendar/CalendarFeedModule.cs +++ b/src/NzbDrone.Api/Calendar/CalendarFeedModule.cs @@ -8,7 +8,7 @@ using Ical.Net.General; using Ical.Net.Interfaces.Serialization; using Ical.Net.Serialization; using Ical.Net.Serialization.iCalendar.Factory; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using Nancy.Responses; using NzbDrone.Core.Tags; using NzbDrone.Common.Extensions; diff --git a/src/NzbDrone.Api/Calendar/CalendarModule.cs b/src/NzbDrone.Api/Calendar/CalendarModule.cs index a44cf2f37..40f56ec77 100644 --- a/src/NzbDrone.Api/Calendar/CalendarModule.cs +++ b/src/NzbDrone.Api/Calendar/CalendarModule.cs @@ -8,11 +8,9 @@ using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.MovieStats; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Tv.Events; +using NzbDrone.Core.Movies; +using NzbDrone.Core.Movies.Events; using NzbDrone.Core.Validation.Paths; -using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.Validation; using NzbDrone.Core.DecisionEngine; using NzbDrone.SignalR; @@ -23,10 +21,8 @@ namespace NzbDrone.Api.Calendar { public CalendarModule(IBroadcastSignalRMessage signalR, IMovieService moviesService, - IMovieStatisticsService moviesStatisticsService, - ISceneMappingService sceneMappingService, IMapCoversToLocal coverMapper) - : base(signalR, moviesService, moviesStatisticsService, sceneMappingService, coverMapper, "calendar") + : base(signalR, moviesService, coverMapper, "calendar") { GetResourceAll = GetCalendar; diff --git a/src/NzbDrone.Api/Config/NamingConfigModule.cs b/src/NzbDrone.Api/Config/NamingConfigModule.cs index 94b515473..474bcae45 100644 --- a/src/NzbDrone.Api/Config/NamingConfigModule.cs +++ b/src/NzbDrone.Api/Config/NamingConfigModule.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using FluentValidation; using FluentValidation.Results; @@ -131,20 +131,8 @@ namespace NzbDrone.Api.Config private void ValidateFormatResult(NamingConfig nameSpec) { - var singleEpisodeSampleResult = _filenameSampleService.GetStandardSample(nameSpec); - var multiEpisodeSampleResult = _filenameSampleService.GetMultiEpisodeSample(nameSpec); - var dailyEpisodeSampleResult = _filenameSampleService.GetDailySample(nameSpec); - var animeEpisodeSampleResult = _filenameSampleService.GetAnimeSample(nameSpec); - var animeMultiEpisodeSampleResult = _filenameSampleService.GetAnimeMultiEpisodeSample(nameSpec); - var movieSampleResult = _filenameSampleService.GetMovieSample(nameSpec); - var singleEpisodeValidationResult = _filenameValidationService.ValidateStandardFilename(singleEpisodeSampleResult); - var multiEpisodeValidationResult = _filenameValidationService.ValidateStandardFilename(multiEpisodeSampleResult); - var dailyEpisodeValidationResult = _filenameValidationService.ValidateDailyFilename(dailyEpisodeSampleResult); - var animeEpisodeValidationResult = _filenameValidationService.ValidateAnimeFilename(animeEpisodeSampleResult); - var animeMultiEpisodeValidationResult = _filenameValidationService.ValidateAnimeFilename(animeMultiEpisodeSampleResult); - //var standardMovieValidationResult = _filenameValidationService.ValidateMovieFilename(movieSampleResult); For now, let's hope the user is not stupid enough :/ var validationFailures = new List(); diff --git a/src/NzbDrone.Api/Config/NamingConfigResource.cs b/src/NzbDrone.Api/Config/NamingConfigResource.cs index f65d90e48..e78395bbf 100644 --- a/src/NzbDrone.Api/Config/NamingConfigResource.cs +++ b/src/NzbDrone.Api/Config/NamingConfigResource.cs @@ -1,4 +1,4 @@ -using NzbDrone.Api.REST; +using NzbDrone.Api.REST; using NzbDrone.Core.Organizer; namespace NzbDrone.Api.Config @@ -10,11 +10,6 @@ namespace NzbDrone.Api.Config public string StandardMovieFormat { get; set; } public string MovieFolderFormat { get; set; } public int MultiEpisodeStyle { get; set; } - public string StandardEpisodeFormat { get; set; } - public string DailyEpisodeFormat { get; set; } - public string AnimeEpisodeFormat { get; set; } - public string SeriesFolderFormat { get; set; } - public string SeasonFolderFormat { get; set; } public bool IncludeSeriesTitle { get; set; } public bool IncludeEpisodeTitle { get; set; } public bool IncludeQuality { get; set; } @@ -34,11 +29,6 @@ namespace NzbDrone.Api.Config RenameEpisodes = model.RenameEpisodes, ReplaceIllegalCharacters = model.ReplaceIllegalCharacters, MultiEpisodeStyle = model.MultiEpisodeStyle, - StandardEpisodeFormat = model.StandardEpisodeFormat, - DailyEpisodeFormat = model.DailyEpisodeFormat, - AnimeEpisodeFormat = model.AnimeEpisodeFormat, - SeriesFolderFormat = model.SeriesFolderFormat, - SeasonFolderFormat = model.SeasonFolderFormat, StandardMovieFormat = model.StandardMovieFormat, MovieFolderFormat = model.MovieFolderFormat //IncludeSeriesTitle @@ -79,4 +69,4 @@ namespace NzbDrone.Api.Config }; } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Api/Indexers/ReleaseModule.cs b/src/NzbDrone.Api/Indexers/ReleaseModule.cs index e625d8046..510ceac86 100644 --- a/src/NzbDrone.Api/Indexers/ReleaseModule.cs +++ b/src/NzbDrone.Api/Indexers/ReleaseModule.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using FluentValidation; using Nancy; @@ -24,8 +24,7 @@ namespace NzbDrone.Api.Indexers private readonly IPrioritizeDownloadDecision _prioritizeDownloadDecision; private readonly IDownloadService _downloadService; private readonly Logger _logger; - - private readonly ICached _remoteEpisodeCache; + private readonly ICached _remoteMovieCache; public ReleaseModule(IFetchAndParseRss rssFetcherAndParser, @@ -48,44 +47,23 @@ namespace NzbDrone.Api.Indexers //PostValidator.RuleFor(s => s.DownloadAllowed).Equal(true); PostValidator.RuleFor(s => s.Guid).NotEmpty(); - - _remoteEpisodeCache = cacheManager.GetCache(GetType(), "remoteEpisodes"); + _remoteMovieCache = cacheManager.GetCache(GetType(), "remoteMovies"); } private Response DownloadRelease(ReleaseResource release) { - var remoteEpisode = _remoteEpisodeCache.Find(release.Guid); + var remoteMovie = _remoteMovieCache.Find(release.Guid); - if (remoteEpisode == null) + if (remoteMovie == null) { _logger.Debug("Couldn't find requested release in cache, cache timeout probably expired."); - var remoteMovie = _remoteMovieCache.Find(release.Guid); - - if (remoteMovie == null) - { - return new NotFoundResponse(); - } - - try - { - _downloadService.DownloadReport(remoteMovie, false); - } - catch (ReleaseDownloadException ex) - { - _logger.Error(ex, ex.Message); - throw new NzbDroneClientException(HttpStatusCode.Conflict, "Getting release from indexer failed"); - } - - return release.AsResponse(); - - + return new NotFoundResponse(); } - try { - _downloadService.DownloadReport(remoteEpisode); + _downloadService.DownloadReport(remoteMovie, false); } catch (ReleaseDownloadException ex) { @@ -98,11 +76,6 @@ namespace NzbDrone.Api.Indexers private List GetReleases() { - if (Request.Query.episodeId != null) - { - return GetEpisodeReleases(Request.Query.episodeId); - } - if (Request.Query.movieId != null) { return GetMovieReleases(Request.Query.movieId); @@ -111,23 +84,6 @@ namespace NzbDrone.Api.Indexers return GetRss(); } - private List GetEpisodeReleases(int episodeId) - { - try - { - var decisions = _nzbSearchService.EpisodeSearch(episodeId, true); - var prioritizedDecisions = _prioritizeDownloadDecision.PrioritizeDecisions(decisions); - - return MapDecisions(prioritizedDecisions); - } - catch (Exception ex) - { - _logger.Error(ex, "Episode search failed: " + ex.Message); - } - - return new List(); - } - private List GetMovieReleases(int movieId) { try @@ -153,23 +109,17 @@ namespace NzbDrone.Api.Indexers { var reports = _rssFetcherAndParser.Fetch(); var decisions = _downloadDecisionMaker.GetRssDecision(reports); - var prioritizedDecisions = _prioritizeDownloadDecision.PrioritizeDecisions(decisions); + var prioritizedDecisions = _prioritizeDownloadDecision.PrioritizeDecisionsForMovies(decisions); return MapDecisions(prioritizedDecisions); } protected override ReleaseResource MapDecision(DownloadDecision decision, int initialWeight) { - if (decision.IsForMovie) - { - _remoteMovieCache.Set(decision.RemoteMovie.Release.Guid, decision.RemoteMovie, TimeSpan.FromMinutes(30)); - } - else - { - _remoteEpisodeCache.Set(decision.RemoteEpisode.Release.Guid, decision.RemoteEpisode, TimeSpan.FromMinutes(30)); - } + + _remoteMovieCache.Set(decision.RemoteMovie.Release.Guid, decision.RemoteMovie, TimeSpan.FromMinutes(30)); return base.MapDecision(decision, initialWeight); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Api/Indexers/ReleaseResource.cs b/src/NzbDrone.Api/Indexers/ReleaseResource.cs index 35c6f1adb..f1280be69 100644 --- a/src/NzbDrone.Api/Indexers/ReleaseResource.cs +++ b/src/NzbDrone.Api/Indexers/ReleaseResource.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using Newtonsoft.Json; using NzbDrone.Api.REST; @@ -48,7 +48,7 @@ namespace NzbDrone.Api.Indexers public int ReleaseWeight { get; set; } public int SuspectedMovieId { get; set; } - public IEnumerable IndexerFlags { get; set; } + public IEnumerable IndexerFlags { get; set; } public string MagnetUrl { get; set; } public string InfoHash { get; set; } @@ -86,90 +86,31 @@ namespace NzbDrone.Api.Indexers { public static ReleaseResource ToResource(this DownloadDecision model) { - var releaseInfo = model.RemoteEpisode.Release; - var parsedEpisodeInfo = model.RemoteEpisode.ParsedEpisodeInfo; - var remoteEpisode = model.RemoteEpisode; - var torrentInfo = (model.RemoteEpisode.Release as TorrentInfo) ?? new TorrentInfo(); + var releaseInfo = model.RemoteMovie.Release; + var remoteMovie = model.RemoteMovie; + var torrentInfo = (model.RemoteMovie.Release as TorrentInfo) ?? new TorrentInfo(); var mappingResult = MappingResultType.Success; - if (model.IsForMovie) - { - mappingResult = model.RemoteMovie.MappingResult; - var parsedMovieInfo = model.RemoteMovie.ParsedMovieInfo; - var movieId = model.RemoteMovie.Movie?.Id ?? 0; - - return new ReleaseResource - { - Guid = releaseInfo.Guid, - Quality = parsedMovieInfo.Quality, - QualityWeight = parsedMovieInfo.Quality.Quality.Id, //Id kinda hacky for wheight, but what you gonna do? TODO: Fix this shit! - Age = releaseInfo.Age, - AgeHours = releaseInfo.AgeHours, - AgeMinutes = releaseInfo.AgeMinutes, - Size = releaseInfo.Size, - IndexerId = releaseInfo.IndexerId, - Indexer = releaseInfo.Indexer, - ReleaseGroup = parsedMovieInfo.ReleaseGroup, - ReleaseHash = parsedMovieInfo.ReleaseHash, - Title = releaseInfo.Title, - //FullSeason = parsedMovieInfo.FullSeason, - //SeasonNumber = parsedMovieInfo.SeasonNumber, - Language = parsedMovieInfo.Language, - Year = parsedMovieInfo.Year, - MovieTitle = parsedMovieInfo.MovieTitle, - EpisodeNumbers = new int[0], - AbsoluteEpisodeNumbers = new int[0], - Approved = model.Approved, - TemporarilyRejected = model.TemporarilyRejected, - Rejected = model.Rejected, - TvdbId = releaseInfo.TvdbId, - TvRageId = releaseInfo.TvRageId, - Rejections = model.Rejections.Select(r => r.Reason).ToList(), - PublishDate = releaseInfo.PublishDate, - CommentUrl = releaseInfo.CommentUrl, - DownloadUrl = releaseInfo.DownloadUrl, - InfoUrl = releaseInfo.InfoUrl, - MappingResult = mappingResult, - //ReleaseWeight - - SuspectedMovieId = movieId, + mappingResult = model.RemoteMovie.MappingResult; + var parsedMovieInfo = model.RemoteMovie.ParsedMovieInfo; + var movieId = model.RemoteMovie.Movie?.Id ?? 0; //Why not pull this out in frontend instead of passing another variable - MagnetUrl = torrentInfo.MagnetUrl, - InfoHash = torrentInfo.InfoHash, - Seeders = torrentInfo.Seeders, - Leechers = (torrentInfo.Peers.HasValue && torrentInfo.Seeders.HasValue) ? (torrentInfo.Peers.Value - torrentInfo.Seeders.Value) : (int?)null, - Protocol = releaseInfo.DownloadProtocol, - IndexerFlags = torrentInfo.IndexerFlags.ToString().Split(new string[] { ", " }, StringSplitOptions.None), - Edition = parsedMovieInfo.Edition, - - IsDaily = false, - IsAbsoluteNumbering = false, - IsPossibleSpecialEpisode = false, - //Special = parsedMovieInfo.Special, - }; - } - - // 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 { Guid = releaseInfo.Guid, - Quality = parsedEpisodeInfo.Quality, - //QualityWeight + Quality = parsedMovieInfo.Quality, + QualityWeight = parsedMovieInfo.Quality.Quality.Id, //Id kinda hacky for wheight, but what you gonna do? TODO: Fix this shit! Age = releaseInfo.Age, AgeHours = releaseInfo.AgeHours, AgeMinutes = releaseInfo.AgeMinutes, Size = releaseInfo.Size, IndexerId = releaseInfo.IndexerId, Indexer = releaseInfo.Indexer, - ReleaseGroup = parsedEpisodeInfo.ReleaseGroup, - ReleaseHash = parsedEpisodeInfo.ReleaseHash, + ReleaseGroup = parsedMovieInfo.ReleaseGroup, + ReleaseHash = parsedMovieInfo.ReleaseHash, Title = releaseInfo.Title, - FullSeason = parsedEpisodeInfo.FullSeason, - SeasonNumber = parsedEpisodeInfo.SeasonNumber, - Language = parsedEpisodeInfo.Language, - //AirDate = parsedEpisodeInfo.AirDate, - //SeriesTitle = parsedEpisodeInfo.SeriesTitle, - EpisodeNumbers = parsedEpisodeInfo.EpisodeNumbers, - AbsoluteEpisodeNumbers = parsedEpisodeInfo.AbsoluteEpisodeNumbers, + Language = parsedMovieInfo.Language, + Year = parsedMovieInfo.Year, + MovieTitle = parsedMovieInfo.MovieTitle, Approved = model.Approved, TemporarilyRejected = model.TemporarilyRejected, Rejected = model.Rejected, @@ -180,19 +121,20 @@ namespace NzbDrone.Api.Indexers CommentUrl = releaseInfo.CommentUrl, DownloadUrl = releaseInfo.DownloadUrl, InfoUrl = releaseInfo.InfoUrl, - //DownloadAllowed = downloadAllowed, + MappingResult = mappingResult, //ReleaseWeight + SuspectedMovieId = movieId, + MagnetUrl = torrentInfo.MagnetUrl, InfoHash = torrentInfo.InfoHash, Seeders = torrentInfo.Seeders, Leechers = (torrentInfo.Peers.HasValue && torrentInfo.Seeders.HasValue) ? (torrentInfo.Peers.Value - torrentInfo.Seeders.Value) : (int?)null, Protocol = releaseInfo.DownloadProtocol, - - IsDaily = parsedEpisodeInfo.IsDaily, - IsAbsoluteNumbering = parsedEpisodeInfo.IsAbsoluteNumbering, - IsPossibleSpecialEpisode = parsedEpisodeInfo.IsPossibleSpecialEpisode, - Special = parsedEpisodeInfo.Special, + IndexerFlags = torrentInfo.IndexerFlags.ToString().Split(new string[] { ", " }, StringSplitOptions.None), + Edition = parsedMovieInfo.Edition, + + //Special = parsedMovieInfo.Special, }; } @@ -232,4 +174,4 @@ namespace NzbDrone.Api.Indexers return model; } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Api/ManualImport/ManualImportModule.cs b/src/NzbDrone.Api/ManualImport/ManualImportModule.cs index 024b8e452..7cc1a71e3 100644 --- a/src/NzbDrone.Api/ManualImport/ManualImportModule.cs +++ b/src/NzbDrone.Api/ManualImport/ManualImportModule.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using System.Linq; -using NzbDrone.Core.MediaFiles.EpisodeImport.Manual; +using NzbDrone.Core.MediaFiles.MovieImport.Manual; using NzbDrone.Core.Qualities; namespace NzbDrone.Api.ManualImport diff --git a/src/NzbDrone.Api/ManualImport/ManualImportResource.cs b/src/NzbDrone.Api/ManualImport/ManualImportResource.cs index 6fff834c7..eee878cdf 100644 --- a/src/NzbDrone.Api/ManualImport/ManualImportResource.cs +++ b/src/NzbDrone.Api/ManualImport/ManualImportResource.cs @@ -23,7 +23,7 @@ namespace NzbDrone.Api.ManualImport public static class ManualImportResourceMapper { - public static ManualImportResource ToResource(this Core.MediaFiles.EpisodeImport.Manual.ManualImportItem model) + public static ManualImportResource ToResource(this Core.MediaFiles.MovieImport.Manual.ManualImportItem model) { if (model == null) return null; @@ -43,7 +43,7 @@ namespace NzbDrone.Api.ManualImport }; } - public static List ToResource(this IEnumerable models) + public static List ToResource(this IEnumerable models) { return models.Select(ToResource).ToList(); } diff --git a/src/NzbDrone.Api/MovieFiles/MovieFileModule.cs b/src/NzbDrone.Api/MovieFiles/MovieFileModule.cs index b706d703f..c65c449e2 100644 --- a/src/NzbDrone.Api/MovieFiles/MovieFileModule.cs +++ b/src/NzbDrone.Api/MovieFiles/MovieFileModule.cs @@ -6,7 +6,7 @@ using NzbDrone.Core.Datastore.Events; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.DecisionEngine; using NzbDrone.SignalR; diff --git a/src/NzbDrone.Api/MovieFiles/MovieFileResource.cs b/src/NzbDrone.Api/MovieFiles/MovieFileResource.cs index e4679ccce..6d8786fba 100644 --- a/src/NzbDrone.Api/MovieFiles/MovieFileResource.cs +++ b/src/NzbDrone.Api/MovieFiles/MovieFileResource.cs @@ -4,7 +4,7 @@ using System.Linq; using NzbDrone.Api.REST; using NzbDrone.Api.Movies; using NzbDrone.Core.MediaCover; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Qualities; using NzbDrone.Core.MediaFiles; diff --git a/src/NzbDrone.Api/Movies/AlternativeTitleModule.cs b/src/NzbDrone.Api/Movies/AlternativeTitleModule.cs index 4a88e932d..d5192e2d6 100644 --- a/src/NzbDrone.Api/Movies/AlternativeTitleModule.cs +++ b/src/NzbDrone.Api/Movies/AlternativeTitleModule.cs @@ -8,14 +8,14 @@ using NzbDrone.Common.Cache; using NzbDrone.Common.Extensions; using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.MediaFiles.EpisodeImport; +using NzbDrone.Core.MediaFiles.MovieImport; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.MetadataSource; using NzbDrone.Core.MetadataSource.RadarrAPI; using NzbDrone.Core.Movies.AlternativeTitles; using NzbDrone.Core.RootFolders; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Tv.Events; +using NzbDrone.Core.Movies; +using NzbDrone.Core.Movies.Events; namespace NzbDrone.Api.Movies { diff --git a/src/NzbDrone.Api/Movies/AlternativeTitleResource.cs b/src/NzbDrone.Api/Movies/AlternativeTitleResource.cs index 64254a9f1..b3bc26930 100644 --- a/src/NzbDrone.Api/Movies/AlternativeTitleResource.cs +++ b/src/NzbDrone.Api/Movies/AlternativeTitleResource.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using NzbDrone.Api.REST; using NzbDrone.Core.MediaCover; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Qualities; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Movies.AlternativeTitles; diff --git a/src/NzbDrone.Api/Movies/AlternativeYearModule.cs b/src/NzbDrone.Api/Movies/AlternativeYearModule.cs index cf58a9f5b..598d0e14b 100644 --- a/src/NzbDrone.Api/Movies/AlternativeYearModule.cs +++ b/src/NzbDrone.Api/Movies/AlternativeYearModule.cs @@ -9,14 +9,14 @@ using NzbDrone.Common.Extensions; using NzbDrone.Common.Messaging; using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.MediaFiles.EpisodeImport; +using NzbDrone.Core.MediaFiles.MovieImport; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.MetadataSource; using NzbDrone.Core.MetadataSource.RadarrAPI; using NzbDrone.Core.Movies.AlternativeTitles; using NzbDrone.Core.RootFolders; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Tv.Events; +using NzbDrone.Core.Movies; +using NzbDrone.Core.Movies.Events; namespace NzbDrone.Api.Movies { diff --git a/src/NzbDrone.Api/Movies/AlternativeYearResource.cs b/src/NzbDrone.Api/Movies/AlternativeYearResource.cs index e075b0445..6e3ebf787 100644 --- a/src/NzbDrone.Api/Movies/AlternativeYearResource.cs +++ b/src/NzbDrone.Api/Movies/AlternativeYearResource.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using NzbDrone.Api.REST; using NzbDrone.Core.MediaCover; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Qualities; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Movies.AlternativeTitles; diff --git a/src/NzbDrone.Api/Movies/FetchMovieListModule.cs b/src/NzbDrone.Api/Movies/FetchMovieListModule.cs index 0c56fd483..a1580460d 100644 --- a/src/NzbDrone.Api/Movies/FetchMovieListModule.cs +++ b/src/NzbDrone.Api/Movies/FetchMovieListModule.cs @@ -26,7 +26,7 @@ namespace NzbDrone.Api.Movies { var results = _fetchNetImport.FetchAndFilter((int) Request.Query.listId, false); - List realResults = new List(); + List realResults = new List(); /*foreach (var movie in results) { @@ -42,7 +42,7 @@ namespace NzbDrone.Api.Movies } - private static IEnumerable MapToResource(IEnumerable movies) + private static IEnumerable MapToResource(IEnumerable movies) { foreach (var currentSeries in movies) { diff --git a/src/NzbDrone.Api/Movies/MovieBulkImportModule.cs b/src/NzbDrone.Api/Movies/MovieBulkImportModule.cs index 87e8accc8..b40f153dc 100644 --- a/src/NzbDrone.Api/Movies/MovieBulkImportModule.cs +++ b/src/NzbDrone.Api/Movies/MovieBulkImportModule.cs @@ -10,10 +10,10 @@ using Marr.Data; using NzbDrone.Common.Extensions; using NzbDrone.Core.Datastore; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.MediaFiles.EpisodeImport; +using NzbDrone.Core.MediaFiles.MovieImport; using NzbDrone.Core.RootFolders; using NzbDrone.Common.Cache; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Api.Movies { @@ -32,7 +32,7 @@ namespace NzbDrone.Api.Movies private readonly IRootFolderService _rootFolderService; private readonly IMakeImportDecision _importDecisionMaker; private readonly IDiskScanService _diskScanService; - private readonly ICached _mappedMovies; + private readonly ICached _mappedMovies; private readonly IMovieService _movieService; public MovieBulkImportModule(ISearchForNewMovie searchProxy, IRootFolderService rootFolderService, IMakeImportDecision importDecisionMaker, @@ -43,7 +43,7 @@ namespace NzbDrone.Api.Movies _rootFolderService = rootFolderService; _importDecisionMaker = importDecisionMaker; _diskScanService = diskScanService; - _mappedMovies = cacheManager.GetCache(GetType(), "mappedMoviesCache"); + _mappedMovies = cacheManager.GetCache(GetType(), "mappedMoviesCache"); _movieService = movieService; Get["/"] = x => Search(); } @@ -80,7 +80,7 @@ namespace NzbDrone.Api.Movies var mapped = paged.Select(f => { - Core.Tv.Movie m = null; + Core.Movies.Movie m = null; var mappedMovie = _mappedMovies.Find(f.Name); @@ -92,7 +92,7 @@ namespace NzbDrone.Api.Movies var parsedTitle = Parser.ParseMoviePath(f.Name, false); if (parsedTitle == null) { - m = new Core.Tv.Movie + m = new Core.Movies.Movie { Title = f.Name.Replace(".", " ").Replace("-", " "), Path = f.Path, @@ -100,7 +100,7 @@ namespace NzbDrone.Api.Movies } else { - m = new Core.Tv.Movie + m = new Core.Movies.Movie { Title = parsedTitle.MovieTitle, Year = parsedTitle.Year, @@ -156,7 +156,7 @@ namespace NzbDrone.Api.Movies } - private static IEnumerable MapToResource(IEnumerable movies) + private static IEnumerable MapToResource(IEnumerable movies) { foreach (var currentMovie in movies) { diff --git a/src/NzbDrone.Api/Movies/MovieDiscoverModule.cs b/src/NzbDrone.Api/Movies/MovieDiscoverModule.cs index cd78ea850..7decab287 100644 --- a/src/NzbDrone.Api/Movies/MovieDiscoverModule.cs +++ b/src/NzbDrone.Api/Movies/MovieDiscoverModule.cs @@ -45,7 +45,7 @@ namespace NzbDrone.Api.Movies }).AsResponse(); } - private static IEnumerable MapToResource(IEnumerable movies) + private static IEnumerable MapToResource(IEnumerable movies) { foreach (var currentSeries in movies) { diff --git a/src/NzbDrone.Api/Movies/MovieEditorModule.cs b/src/NzbDrone.Api/Movies/MovieEditorModule.cs index bde336a9b..db90a3f95 100644 --- a/src/NzbDrone.Api/Movies/MovieEditorModule.cs +++ b/src/NzbDrone.Api/Movies/MovieEditorModule.cs @@ -5,7 +5,7 @@ using Nancy; using Nancy.Responses; using NzbDrone.Api.Extensions; using NzbDrone.Api.REST; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Api.Movies { diff --git a/src/NzbDrone.Api/Movies/MovieLookupModule.cs b/src/NzbDrone.Api/Movies/MovieLookupModule.cs index 17692d094..1801f90dc 100644 --- a/src/NzbDrone.Api/Movies/MovieLookupModule.cs +++ b/src/NzbDrone.Api/Movies/MovieLookupModule.cs @@ -49,7 +49,7 @@ namespace NzbDrone.Api.Movies return MapToResource(imdbResults).AsResponse(); } - private static IEnumerable MapToResource(IEnumerable movies) + private static IEnumerable MapToResource(IEnumerable movies) { foreach (var currentSeries in movies) { diff --git a/src/NzbDrone.Api/Movies/MovieModule.cs b/src/NzbDrone.Api/Movies/MovieModule.cs index f0424e0eb..fb7538f20 100644 --- a/src/NzbDrone.Api/Movies/MovieModule.cs +++ b/src/NzbDrone.Api/Movies/MovieModule.cs @@ -9,11 +9,9 @@ using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.MovieStats; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Tv.Events; +using NzbDrone.Core.Movies; +using NzbDrone.Core.Movies.Events; using NzbDrone.Core.Validation.Paths; -using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.Validation; using NzbDrone.SignalR; using NzbDrone.Core.Datastore; @@ -22,8 +20,8 @@ using Nancy; namespace NzbDrone.Api.Movies { - public class MovieModule : NzbDroneRestModuleWithSignalR, - IHandle, + public class MovieModule : NzbDroneRestModuleWithSignalR, + IHandle, IHandle, IHandle, IHandle, @@ -33,15 +31,12 @@ namespace NzbDrone.Api.Movies { protected readonly IMovieService _moviesService; - private readonly IMovieStatisticsService _moviesStatisticsService; private readonly IMapCoversToLocal _coverMapper; private const string TITLE_SLUG_ROUTE = "/titleslug/(?[^/]+)"; public MovieModule(IBroadcastSignalRMessage signalRBroadcaster, IMovieService moviesService, - IMovieStatisticsService moviesStatisticsService, - ISceneMappingService sceneMappingService, IMapCoversToLocal coverMapper, RootFolderValidator rootFolderValidator, MoviePathValidator moviesPathValidator, @@ -53,7 +48,6 @@ namespace NzbDrone.Api.Movies : base(signalRBroadcaster) { _moviesService = moviesService; - _moviesStatisticsService = moviesStatisticsService; _coverMapper = coverMapper; @@ -93,14 +87,11 @@ namespace NzbDrone.Api.Movies public MovieModule(IBroadcastSignalRMessage signalRBroadcaster, IMovieService moviesService, - IMovieStatisticsService moviesStatisticsService, - ISceneMappingService sceneMappingService, IMapCoversToLocal coverMapper, string resource) : base(signalRBroadcaster, resource) { _moviesService = moviesService; - _moviesStatisticsService = moviesStatisticsService; _coverMapper = coverMapper; @@ -119,14 +110,14 @@ namespace NzbDrone.Api.Movies private PagingResource GetMoviePaged(PagingResource pagingResource) { - var pagingSpec = pagingResource.MapToPagingSpec(); + var pagingSpec = pagingResource.MapToPagingSpec(); pagingSpec.FilterExpression = _moviesService.ConstructFilterExpression(pagingResource.FilterKey, pagingResource.FilterValue, pagingResource.FilterType); return ApplyToPage(_moviesService.Paged, pagingSpec, MapToResource); } - protected MovieResource MapToResource(Core.Tv.Movie movies) + protected MovieResource MapToResource(Core.Movies.Movie movies) { if (movies == null) return null; @@ -140,11 +131,11 @@ namespace NzbDrone.Api.Movies private List AllMovie() { - var moviesStats = _moviesStatisticsService.MovieStatistics(); + //var moviesStats = _moviesStatisticsService.MovieStatistics(); var moviesResources = _moviesService.GetAllMovies().ToResource(); MapCoversToLocal(moviesResources.ToArray()); - LinkMovieStatistics(moviesResources, moviesStats); + //LinkMovieStatistics(moviesResources, moviesStats); PopulateAlternateTitles(moviesResources); return moviesResources; @@ -216,28 +207,28 @@ namespace NzbDrone.Api.Movies } } - private void FetchAndLinkMovieStatistics(MovieResource resource) - { - LinkMovieStatistics(resource, _moviesStatisticsService.MovieStatistics(resource.Id)); - } + //private void FetchAndLinkMovieStatistics(MovieResource resource) + //{ + // LinkMovieStatistics(resource, _moviesStatisticsService.MovieStatistics(resource.Id)); + //} - private void LinkMovieStatistics(List resources, List moviesStatistics) - { - var dictMovieStats = moviesStatistics.ToDictionary(v => v.MovieId); + //private void LinkMovieStatistics(List resources, List moviesStatistics) + //{ + // var dictMovieStats = moviesStatistics.ToDictionary(v => v.MovieId); - foreach (var movies in resources) - { - var stats = dictMovieStats.GetValueOrDefault(movies.Id); - if (stats == null) continue; + // foreach (var movies in resources) + // { + // var stats = dictMovieStats.GetValueOrDefault(movies.Id); + // if (stats == null) continue; - LinkMovieStatistics(movies, stats); - } - } + // LinkMovieStatistics(movies, stats); + // } + //} - private void LinkMovieStatistics(MovieResource resource, MovieStatistics moviesStatistics) - { - //resource.SizeOnDisk = 0;//TODO: incorporate movie statistics moviesStatistics.SizeOnDisk; - } + //private void LinkMovieStatistics(MovieResource resource, MovieStatistics moviesStatistics) + //{ + // //resource.SizeOnDisk = 0;//TODO: incorporate movie statistics moviesStatistics.SizeOnDisk; + //} private void PopulateAlternateTitles(List resources) { diff --git a/src/NzbDrone.Api/Movies/MovieModuleWithSignalR.cs b/src/NzbDrone.Api/Movies/MovieModuleWithSignalR.cs index 280376596..2a59157c9 100644 --- a/src/NzbDrone.Api/Movies/MovieModuleWithSignalR.cs +++ b/src/NzbDrone.Api/Movies/MovieModuleWithSignalR.cs @@ -4,12 +4,12 @@ using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.SignalR; namespace NzbDrone.Api.Movies { - public abstract class MovieModuleWithSignalR : NzbDroneRestModuleWithSignalR, + public abstract class MovieModuleWithSignalR : NzbDroneRestModuleWithSignalR, IHandle, IHandle { @@ -46,7 +46,7 @@ namespace NzbDrone.Api.Movies return resource; } - protected MovieResource MapToResource(Core.Tv.Movie episode, bool includeSeries) + protected MovieResource MapToResource(Core.Movies.Movie episode, bool includeSeries) { var resource = episode.ToResource(); diff --git a/src/NzbDrone.Api/Movies/MovieResource.cs b/src/NzbDrone.Api/Movies/MovieResource.cs index c4581beb2..3024b4c00 100644 --- a/src/NzbDrone.Api/Movies/MovieResource.cs +++ b/src/NzbDrone.Api/Movies/MovieResource.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using NzbDrone.Api.REST; using NzbDrone.Core.MediaCover; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Api.MovieFiles; namespace NzbDrone.Api.Movies @@ -88,7 +88,7 @@ namespace NzbDrone.Api.Movies public static class MovieResourceMapper { - public static MovieResource ToResource(this Core.Tv.Movie model) + public static MovieResource ToResource(this Core.Movies.Movie model) { if (model == null) return null; @@ -171,11 +171,11 @@ namespace NzbDrone.Api.Movies }; } - public static Core.Tv.Movie ToModel(this MovieResource resource) + public static Core.Movies.Movie ToModel(this MovieResource resource) { if (resource == null) return null; - return new Core.Tv.Movie + return new Core.Movies.Movie { Id = resource.Id, TmdbId = resource.TmdbId, @@ -225,7 +225,7 @@ namespace NzbDrone.Api.Movies }; } - public static Core.Tv.Movie ToModel(this MovieResource resource, Core.Tv.Movie movie) + public static Core.Movies.Movie ToModel(this MovieResource resource, Core.Movies.Movie movie) { movie.ImdbId = resource.ImdbId; movie.TmdbId = resource.TmdbId; @@ -244,7 +244,7 @@ namespace NzbDrone.Api.Movies return movie; } - public static List ToResource(this IEnumerable movies) + public static List ToResource(this IEnumerable movies) { return movies.Select(ToResource).ToList(); } diff --git a/src/NzbDrone.Api/NetImport/ImportExclusionsResource.cs b/src/NzbDrone.Api/NetImport/ImportExclusionsResource.cs index 9233cb815..0e5f26678 100644 --- a/src/NzbDrone.Api/NetImport/ImportExclusionsResource.cs +++ b/src/NzbDrone.Api/NetImport/ImportExclusionsResource.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; using NzbDrone.Core.NetImport; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Api.NetImport { diff --git a/src/NzbDrone.Api/NetImport/ListImportModule.cs b/src/NzbDrone.Api/NetImport/ListImportModule.cs index 789a1556f..ccbe48119 100644 --- a/src/NzbDrone.Api/NetImport/ListImportModule.cs +++ b/src/NzbDrone.Api/NetImport/ListImportModule.cs @@ -5,7 +5,7 @@ using Nancy.Extensions; using NzbDrone.Api.Extensions; using NzbDrone.Api.Movies; using NzbDrone.Core.MetadataSource; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Api.NetImport { diff --git a/src/NzbDrone.Api/NetImport/NetImportResource.cs b/src/NzbDrone.Api/NetImport/NetImportResource.cs index 01a9104a6..360494d40 100644 --- a/src/NzbDrone.Api/NetImport/NetImportResource.cs +++ b/src/NzbDrone.Api/NetImport/NetImportResource.cs @@ -1,4 +1,4 @@ -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Api.NetImport { diff --git a/src/NzbDrone.Api/Series/SeriesModule.cs b/src/NzbDrone.Api/Series/SeriesModule.cs index e018b1614..f4fe44135 100644 --- a/src/NzbDrone.Api/Series/SeriesModule.cs +++ b/src/NzbDrone.Api/Series/SeriesModule.cs @@ -5,7 +5,7 @@ using NzbDrone.SignalR; namespace NzbDrone.Api.Series { [Obsolete("SeriesModule is Obsolete, Remove with new UI")] - public class SeriesModule : NzbDroneRestModuleWithSignalR + public class SeriesModule : NzbDroneRestModuleWithSignalR { public SeriesModule(IBroadcastSignalRMessage signalRBroadcaster diff --git a/src/NzbDrone.Api/Wanted/MovieCutoffModule.cs b/src/NzbDrone.Api/Wanted/MovieCutoffModule.cs index 7f4ebbf76..f032f0b12 100644 --- a/src/NzbDrone.Api/Wanted/MovieCutoffModule.cs +++ b/src/NzbDrone.Api/Wanted/MovieCutoffModule.cs @@ -1,6 +1,6 @@ using NzbDrone.Api.Movies; using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Datastore; using NzbDrone.SignalR; @@ -22,7 +22,7 @@ namespace NzbDrone.Api.Wanted private PagingResource GetCutoffUnmetMovies(PagingResource pagingResource) { - var pagingSpec = pagingResource.MapToPagingSpec("title", SortDirection.Ascending); + var pagingSpec = pagingResource.MapToPagingSpec("title", SortDirection.Ascending); pagingSpec.FilterExpression = _movieService.ConstructFilterExpression(pagingResource.FilterKey, pagingResource.FilterValue); diff --git a/src/NzbDrone.Api/Wanted/MovieMissingModule.cs b/src/NzbDrone.Api/Wanted/MovieMissingModule.cs index 653c89502..e4b1868b2 100644 --- a/src/NzbDrone.Api/Wanted/MovieMissingModule.cs +++ b/src/NzbDrone.Api/Wanted/MovieMissingModule.cs @@ -1,6 +1,6 @@ using NzbDrone.Api.Movies; using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Datastore; using NzbDrone.SignalR; using NzbDrone.Core.Download; @@ -27,7 +27,7 @@ namespace NzbDrone.Api.Wanted private PagingResource GetMissingMovies(PagingResource pagingResource) { - var pagingSpec = pagingResource.MapToPagingSpec("title", SortDirection.Descending); + var pagingSpec = pagingResource.MapToPagingSpec("title", SortDirection.Descending); pagingSpec.FilterExpression = _movieService.ConstructFilterExpression(pagingResource.FilterKey, pagingResource.FilterValue); diff --git a/src/NzbDrone.App.Test/ContainerFixture.cs b/src/NzbDrone.App.Test/ContainerFixture.cs index 0d1324350..5a0018152 100644 --- a/src/NzbDrone.App.Test/ContainerFixture.cs +++ b/src/NzbDrone.App.Test/ContainerFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using NUnit.Framework; using NzbDrone.Common; using NzbDrone.Common.EnvironmentInfo; @@ -77,8 +77,8 @@ namespace NzbDrone.App.Test [Test] public void should_return_same_instance_of_singletons_by_different_same_interface() { - var first = _container.ResolveAll>().OfType().Single(); - var second = _container.ResolveAll>().OfType().Single(); + var first = _container.ResolveAll>().OfType().Single(); + var second = _container.ResolveAll>().OfType().Single(); first.Should().BeSameAs(second); } @@ -86,10 +86,10 @@ namespace NzbDrone.App.Test [Test] public void should_return_same_instance_of_singletons_by_different_interfaces() { - var first = _container.ResolveAll>().OfType().Single(); + var first = _container.ResolveAll>().OfType().Single(); var second = (DownloadMonitoringService)_container.Resolve>(); first.Should().BeSameAs(second); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core.Test/Blacklisting/BlacklistRepositoryFixture.cs b/src/NzbDrone.Core.Test/Blacklisting/BlacklistRepositoryFixture.cs index 1256ba1a2..a96aca907 100644 --- a/src/NzbDrone.Core.Test/Blacklisting/BlacklistRepositoryFixture.cs +++ b/src/NzbDrone.Core.Test/Blacklisting/BlacklistRepositoryFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using FluentAssertions; @@ -19,9 +19,7 @@ namespace NzbDrone.Core.Test.Blacklisting { _blacklist = new Blacklist { - SeriesId = 12345, MovieId = 1234, - EpisodeIds = new List { 1 }, Quality = new QualityModel(Quality.Bluray720p), SourceTitle = "series.title.s01e01", Date = DateTime.UtcNow @@ -40,7 +38,7 @@ namespace NzbDrone.Core.Test.Blacklisting { Subject.Insert(_blacklist); - Subject.All().First().EpisodeIds.Should().Contain(_blacklist.EpisodeIds); + Subject.All().First().MovieId.Should().Be(_blacklist.MovieId); } [Test] diff --git a/src/NzbDrone.Core.Test/Blacklisting/BlacklistServiceFixture.cs b/src/NzbDrone.Core.Test/Blacklisting/BlacklistServiceFixture.cs index 4609d03be..e96175fb3 100644 --- a/src/NzbDrone.Core.Test/Blacklisting/BlacklistServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Blacklisting/BlacklistServiceFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using Moq; using NUnit.Framework; @@ -19,9 +19,7 @@ namespace NzbDrone.Core.Test.Blacklisting { _event = new DownloadFailedEvent { - SeriesId = 0, MovieId = 69, - EpisodeIds = null, Quality = new QualityModel(Quality.Bluray720p), SourceTitle = "series.title.s01e01", DownloadClient = "SabnzbdClient", diff --git a/src/NzbDrone.Core.Test/BulkImport/AddMultiMoviesFixture.cs b/src/NzbDrone.Core.Test/BulkImport/AddMultiMoviesFixture.cs index c0910ec50..f54d802ec 100644 --- a/src/NzbDrone.Core.Test/BulkImport/AddMultiMoviesFixture.cs +++ b/src/NzbDrone.Core.Test/BulkImport/AddMultiMoviesFixture.cs @@ -3,9 +3,9 @@ using FluentAssertions; using NUnit.Framework; using Moq; using NzbDrone.Core.Organizer; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv.Events; +using NzbDrone.Core.Movies.Events; using System.Collections.Generic; namespace NzbDrone.Core.Test.BulkImport diff --git a/src/NzbDrone.Core.Test/DataAugmentation/DailySeries/DailySeriesDataProxyFixture.cs b/src/NzbDrone.Core.Test/DataAugmentation/DailySeries/DailySeriesDataProxyFixture.cs deleted file mode 100644 index 0078b914d..000000000 --- a/src/NzbDrone.Core.Test/DataAugmentation/DailySeries/DailySeriesDataProxyFixture.cs +++ /dev/null @@ -1,28 +0,0 @@ -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.DataAugmentation.DailySeries; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Test.Common.Categories; - -namespace NzbDrone.Core.Test.DataAugmentation.DailySeries -{ - [TestFixture] - [IntegrationTest] - public class DailySeriesDataProxyFixture : CoreTest - { - [SetUp] - public void Setup() - { - UseRealHttp(); - } - - [Test] - [Ignore("Series")] - public void should_get_list_of_daily_series() - { - var list = Subject.GetDailySeriesIds(); - list.Should().NotBeEmpty(); - list.Should().OnlyHaveUniqueItems(); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/DataAugmentation/Scene/SceneMappingProxyFixture.cs b/src/NzbDrone.Core.Test/DataAugmentation/Scene/SceneMappingProxyFixture.cs deleted file mode 100644 index b1b39ea2c..000000000 --- a/src/NzbDrone.Core.Test/DataAugmentation/Scene/SceneMappingProxyFixture.cs +++ /dev/null @@ -1,35 +0,0 @@ -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.DataAugmentation.Scene; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Test.Common.Categories; - -namespace NzbDrone.Core.Test.DataAugmentation.Scene -{ - [TestFixture] - [Ignore("Series")] - [IntegrationTest] - public class SceneMappingProxyFixture : CoreTest - { - [SetUp] - public void Setup() - { - UseRealHttp(); - } - - [Test] - - public void fetch_should_return_list_of_mappings() - { - var mappings = Subject.Fetch(); - - mappings.Should().NotBeEmpty(); - - mappings.Should().NotContain(c => c.SearchTerm.IsNullOrWhiteSpace()); - mappings.Should().NotContain(c => c.Title.IsNullOrWhiteSpace()); - mappings.Should().Contain(c => c.SeasonNumber > 0); - } - - } -} diff --git a/src/NzbDrone.Core.Test/DataAugmentation/Scene/SceneMappingServiceFixture.cs b/src/NzbDrone.Core.Test/DataAugmentation/Scene/SceneMappingServiceFixture.cs deleted file mode 100644 index b94578c32..000000000 --- a/src/NzbDrone.Core.Test/DataAugmentation/Scene/SceneMappingServiceFixture.cs +++ /dev/null @@ -1,337 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Net; -using FizzWare.NBuilder; -using Moq; -using NUnit.Framework; -using NzbDrone.Core.DataAugmentation.Scene; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Test.Common; -using FluentAssertions; -using NzbDrone.Common.Extensions; - -namespace NzbDrone.Core.Test.DataAugmentation.Scene -{ - [TestFixture] - - public class SceneMappingServiceFixture : CoreTest - { - private List _fakeMappings; - - private Mock _provider1; - private Mock _provider2; - - [SetUp] - public void Setup() - { - _fakeMappings = Builder.CreateListOfSize(5).BuildListOfNew(); - - _fakeMappings[0].SearchTerm = "Words"; - _fakeMappings[1].SearchTerm = "That"; - _fakeMappings[2].SearchTerm = "Can"; - _fakeMappings[3].SearchTerm = "Be"; - _fakeMappings[4].SearchTerm = "Cleaned"; - - _fakeMappings[0].ParseTerm = "Words"; - _fakeMappings[1].ParseTerm = "That"; - _fakeMappings[2].ParseTerm = "Can"; - _fakeMappings[3].ParseTerm = "Be"; - _fakeMappings[4].ParseTerm = "Cleaned"; - - _provider1 = new Mock(); - _provider1.Setup(s => s.GetSceneMappings()).Returns(_fakeMappings); - - _provider2 = new Mock(); - _provider2.Setup(s => s.GetSceneMappings()).Returns(_fakeMappings); - } - - private void GivenProviders(IEnumerable> providers) - { - Mocker.SetConstant>(providers.Select(s => s.Object)); - } - - [Test] - public void should_purge_existing_mapping_and_add_new_ones() - { - GivenProviders(new [] { _provider1 }); - - Mocker.GetMock().Setup(c => c.All()).Returns(_fakeMappings); - - Subject.Execute(new UpdateSceneMappingCommand()); - - AssertMappingUpdated(); - } - - [Test] - public void should_not_delete_if_fetch_fails() - { - GivenProviders(new[] { _provider1 }); - - _provider1.Setup(c => c.GetSceneMappings()).Throws(new WebException()); - - Subject.Execute(new UpdateSceneMappingCommand()); - - AssertNoUpdate(); - - ExceptionVerification.ExpectedErrors(1); - } - - [Test] - public void should_not_delete_if_fetch_returns_empty_list() - { - GivenProviders(new[] { _provider1 }); - - _provider1.Setup(c => c.GetSceneMappings()).Returns(new List()); - - Subject.Execute(new UpdateSceneMappingCommand()); - - AssertNoUpdate(); - - ExceptionVerification.ExpectedWarns(1); - } - - [Test] - public void should_get_mappings_for_all_providers() - { - GivenProviders(new[] { _provider1, _provider2 }); - - Mocker.GetMock().Setup(c => c.All()).Returns(_fakeMappings); - - Subject.Execute(new UpdateSceneMappingCommand()); - - _provider1.Verify(c => c.GetSceneMappings(), Times.Once()); - _provider2.Verify(c => c.GetSceneMappings(), Times.Once()); - } - - [Test] - public void should_refresh_cache_if_cache_is_empty_when_looking_for_tvdb_id() - { - Subject.FindTvdbId("title"); - - Mocker.GetMock() - .Verify(v => v.All(), Times.Once()); - } - - [Test] - public void should_not_refresh_cache_if_cache_is_not_empty_when_looking_for_tvdb_id() - { - GivenProviders(new[] { _provider1 }); - - Mocker.GetMock() - .Setup(s => s.All()) - .Returns(Builder.CreateListOfSize(1).Build()); - - - Subject.Execute(new UpdateSceneMappingCommand()); - - Mocker.GetMock() - .Verify(v => v.All(), Times.Once()); - - Subject.FindTvdbId("title"); - - Mocker.GetMock() - .Verify(v => v.All(), Times.Once()); - } - - [Test] - public void should_not_add_mapping_with_blank_title() - { - GivenProviders(new[] { _provider1 }); - - var fakeMappings = Builder.CreateListOfSize(2) - .TheLast(1) - .With(m => m.Title = null) - .Build() - .ToList(); - - _provider1.Setup(s => s.GetSceneMappings()).Returns(fakeMappings); - - Mocker.GetMock().Setup(c => c.All()).Returns(_fakeMappings); - - Subject.Execute(new UpdateSceneMappingCommand()); - - Mocker.GetMock().Verify(c => c.InsertMany(It.Is>(m => !m.Any(s => s.Title.IsNullOrWhiteSpace()))), Times.Once()); - ExceptionVerification.ExpectedWarns(1); - } - - [Test] - public void should_not_add_mapping_with_blank_search_title() - { - GivenProviders(new[] { _provider1 }); - - var fakeMappings = Builder.CreateListOfSize(2) - .TheLast(1) - .With(m => m.SearchTerm = null) - .Build() - .ToList(); - - _provider1.Setup(s => s.GetSceneMappings()).Returns(fakeMappings); - - Mocker.GetMock().Setup(c => c.All()).Returns(_fakeMappings); - - Subject.Execute(new UpdateSceneMappingCommand()); - - Mocker.GetMock().Verify(c => c.InsertMany(It.Is>(m => !m.Any(s => s. SearchTerm.IsNullOrWhiteSpace()))), Times.Once()); - ExceptionVerification.ExpectedWarns(1); - } - - - [TestCase("Working!!", "Working!!", 1)] - [TestCase("Working`!!", "Working`!!", 2)] - [TestCase("Working!!!", "Working!!!", 3)] - [TestCase("Working!!!!", "Working!!!", 3)] - [TestCase("Working !!", "Working!!", 1)] - public void should_return_single_match(string parseTitle, string title, int expectedSeasonNumber) - { - var mappings = new List - { - new SceneMapping { Title = "Working!!", ParseTerm = "working", SearchTerm = "Working!!", TvdbId = 100, SceneSeasonNumber = 1 }, - new SceneMapping { Title = "Working`!!", ParseTerm = "working", SearchTerm = "Working`!!", TvdbId = 100, SceneSeasonNumber = 2 }, - new SceneMapping { Title = "Working!!!", ParseTerm = "working", SearchTerm = "Working!!!", TvdbId = 100, SceneSeasonNumber = 3 }, - }; - - Mocker.GetMock().Setup(c => c.All()).Returns(mappings); - - var tvdbId = Subject.FindTvdbId(parseTitle); - var seasonNumber = Subject.GetSceneSeasonNumber(parseTitle); - - tvdbId.Should().Be(100); - seasonNumber.Should().Be(expectedSeasonNumber); - } - - [Test] - public void should_return_alternate_title_for_global_season() - { - var mappings = new List - { - new SceneMapping { Title = "Fudanshi Koukou Seikatsu 1", ParseTerm = "fudanshikoukouseikatsu1", SearchTerm = "Fudanshi Koukou Seikatsu 1", TvdbId = 100, SeasonNumber = null, SceneSeasonNumber = null }, - new SceneMapping { Title = "Fudanshi Koukou Seikatsu 2", ParseTerm = "fudanshikoukouseikatsu2", SearchTerm = "Fudanshi Koukou Seikatsu 2", TvdbId = 100, SeasonNumber = -1, SceneSeasonNumber = null }, - new SceneMapping { Title = "Fudanshi Koukou Seikatsu 3", ParseTerm = "fudanshikoukouseikatsu3", SearchTerm = "Fudanshi Koukou Seikatsu 3", TvdbId = 100, SeasonNumber = null, SceneSeasonNumber = -1 }, - new SceneMapping { Title = "Fudanshi Koukou Seikatsu 4", ParseTerm = "fudanshikoukouseikatsu4", SearchTerm = "Fudanshi Koukou Seikatsu 4", TvdbId = 100, SeasonNumber = -1, SceneSeasonNumber = -1 }, - }; - - Mocker.GetMock().Setup(c => c.All()).Returns(mappings); - - var names = Subject.GetSceneNames(100, new List { 10 }, new List { 10 }); - names.Should().HaveCount(4); - } - - [Test] - public void should_return_alternate_title_for_season() - { - var mappings = new List - { - new SceneMapping { Title = "Fudanshi Koukou Seikatsu", ParseTerm = "fudanshikoukouseikatsu", SearchTerm = "Fudanshi Koukou Seikatsu", TvdbId = 100, SeasonNumber = 1, SceneSeasonNumber = null } - }; - - Mocker.GetMock().Setup(c => c.All()).Returns(mappings); - - var names = Subject.GetSceneNames(100, new List { 1 }, new List { 10 }); - names.Should().HaveCount(1); - } - - [Test] - public void should_not_return_alternate_title_for_season() - { - var mappings = new List - { - new SceneMapping { Title = "Fudanshi Koukou Seikatsu", ParseTerm = "fudanshikoukouseikatsu", SearchTerm = "Fudanshi Koukou Seikatsu", TvdbId = 100, SeasonNumber = 1, SceneSeasonNumber = null } - }; - - Mocker.GetMock().Setup(c => c.All()).Returns(mappings); - - var names = Subject.GetSceneNames(100, new List { 2 }, new List { 10 }); - names.Should().BeEmpty(); - } - - [Test] - public void should_return_alternate_title_for_sceneseason() - { - var mappings = new List - { - new SceneMapping { Title = "Fudanshi Koukou Seikatsu", ParseTerm = "fudanshikoukouseikatsu", SearchTerm = "Fudanshi Koukou Seikatsu", TvdbId = 100, SeasonNumber = null, SceneSeasonNumber = 1 } - }; - - Mocker.GetMock().Setup(c => c.All()).Returns(mappings); - - var names = Subject.GetSceneNames(100, new List { 10 }, new List { 1 }); - names.Should().HaveCount(1); - } - - [Test] - public void should_not_return_alternate_title_for_sceneseason() - { - var mappings = new List - { - new SceneMapping { Title = "Fudanshi Koukou Seikatsu", ParseTerm = "fudanshikoukouseikatsu", SearchTerm = "Fudanshi Koukou Seikatsu", TvdbId = 100, SeasonNumber = null, SceneSeasonNumber = 1 } - }; - - Mocker.GetMock().Setup(c => c.All()).Returns(mappings); - - var names = Subject.GetSceneNames(100, new List { 10 }, new List { 2 }); - names.Should().BeEmpty(); - } - - [Test] - public void should_return_alternate_title_for_fairy_tail() - { - var mappings = new List - { - new SceneMapping { Title = "Fairy Tail S2", ParseTerm = "fairytails2", SearchTerm = "Fairy Tail S2", TvdbId = 100, SeasonNumber = null, SceneSeasonNumber = 2 } - }; - - Mocker.GetMock().Setup(c => c.All()).Returns(mappings); - - Subject.GetSceneNames(100, new List { 4 }, new List { 20 }).Should().BeEmpty(); - Subject.GetSceneNames(100, new List { 5 }, new List { 20 }).Should().BeEmpty(); - Subject.GetSceneNames(100, new List { 6 }, new List { 20 }).Should().BeEmpty(); - Subject.GetSceneNames(100, new List { 7 }, new List { 20 }).Should().BeEmpty(); - - Subject.GetSceneNames(100, new List { 20 }, new List { 1 }).Should().BeEmpty(); - Subject.GetSceneNames(100, new List { 20 }, new List { 2 }).Should().NotBeEmpty(); - Subject.GetSceneNames(100, new List { 20 }, new List { 3 }).Should().BeEmpty(); - Subject.GetSceneNames(100, new List { 20 }, new List { 4 }).Should().BeEmpty(); - } - - [Test] - public void should_return_alternate_title_for_fudanshi() - { - var mappings = new List - { - new SceneMapping { Title = "Fudanshi Koukou Seikatsu", ParseTerm = "fudanshikoukouseikatsu", SearchTerm = "Fudanshi Koukou Seikatsu", TvdbId = 100, SeasonNumber = null, SceneSeasonNumber = 1 } - }; - - Mocker.GetMock().Setup(c => c.All()).Returns(mappings); - - Subject.GetSceneNames(100, new List { 1 }, new List { 20 }).Should().BeEmpty(); - Subject.GetSceneNames(100, new List { 2 }, new List { 20 }).Should().BeEmpty(); - Subject.GetSceneNames(100, new List { 3 }, new List { 20 }).Should().BeEmpty(); - Subject.GetSceneNames(100, new List { 4 }, new List { 20 }).Should().BeEmpty(); - - Subject.GetSceneNames(100, new List { 1 }, new List { 1 }).Should().NotBeEmpty(); - Subject.GetSceneNames(100, new List { 2 }, new List { 2 }).Should().BeEmpty(); - Subject.GetSceneNames(100, new List { 3 }, new List { 3 }).Should().BeEmpty(); - Subject.GetSceneNames(100, new List { 4 }, new List { 4 }).Should().BeEmpty(); - } - - private void AssertNoUpdate() - { - _provider1.Verify(c => c.GetSceneMappings(), Times.Once()); - Mocker.GetMock().Verify(c => c.Clear(It.IsAny()), Times.Never()); - Mocker.GetMock().Verify(c => c.InsertMany(_fakeMappings), Times.Never()); - } - - private void AssertMappingUpdated() - { - _provider1.Verify(c => c.GetSceneMappings(), Times.Once()); - Mocker.GetMock().Verify(c => c.Clear(It.IsAny()), Times.Once()); - Mocker.GetMock().Verify(c => c.InsertMany(_fakeMappings), Times.Once()); - - foreach (var sceneMapping in _fakeMappings) - { - Subject.GetSceneNames(sceneMapping.TvdbId, _fakeMappings.Select(m => m.SeasonNumber.Value).Distinct().ToList(), new List()).Should().Contain(sceneMapping.SearchTerm); - Subject.FindTvdbId(sceneMapping.ParseTerm).Should().Be(sceneMapping.TvdbId); - } - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/DatabaseFixture.cs b/src/NzbDrone.Core.Test/Datastore/DatabaseFixture.cs index e1942d6c3..0196db290 100644 --- a/src/NzbDrone.Core.Test/Datastore/DatabaseFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/DatabaseFixture.cs @@ -4,7 +4,7 @@ using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.Datastore; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.Datastore { @@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.Datastore public void SingleOrDefault_should_return_null_on_empty_db() { Mocker.Resolve() - .GetDataMapper().Query() + .GetDataMapper().Query() .SingleOrDefault(c => c.CleanTitle == "SomeTitle") .Should() .BeNull(); @@ -33,4 +33,4 @@ namespace NzbDrone.Core.Test.Datastore Mocker.Resolve().Version.Should().BeGreaterThan(new Version("3.0.0")); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core.Test/Datastore/DatabaseRelationshipFixture.cs b/src/NzbDrone.Core.Test/Datastore/DatabaseRelationshipFixture.cs index 761ad59cb..89a3860cc 100644 --- a/src/NzbDrone.Core.Test/Datastore/DatabaseRelationshipFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/DatabaseRelationshipFixture.cs @@ -1,11 +1,11 @@ -using System.Linq; +using System.Linq; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.Datastore { @@ -15,19 +15,19 @@ namespace NzbDrone.Core.Test.Datastore [Test] public void one_to_one() { - var episodeFile = Builder.CreateNew() + var episodeFile = Builder.CreateNew() .With(c => c.Quality = new QualityModel()) .BuildNew(); Db.Insert(episodeFile); - var episode = Builder.CreateNew() - .With(c => c.EpisodeFileId = episodeFile.Id) + var episode = Builder.CreateNew() + .With(c => c.MovieFileId = episodeFile.Id) .BuildNew(); Db.Insert(episode); - var loadedEpisodeFile = Db.Single().EpisodeFile.Value; + var loadedEpisodeFile = Db.Single().MovieFile; loadedEpisodeFile.Should().NotBeNull(); loadedEpisodeFile.ShouldBeEquivalentTo(episodeFile, @@ -35,20 +35,19 @@ namespace NzbDrone.Core.Test.Datastore .IncludingAllRuntimeProperties() .Excluding(c => c.DateAdded) .Excluding(c => c.Path) - .Excluding(c => c.Series) - .Excluding(c => c.Episodes)); + .Excluding(c => c.Movie)); } [Test] public void one_to_one_should_not_query_db_if_foreign_key_is_zero() { - var episode = Builder.CreateNew() - .With(c => c.EpisodeFileId = 0) + var episode = Builder.CreateNew() + .With(c => c.MovieFileId = 0) .BuildNew(); Db.Insert(episode); - Db.Single().EpisodeFile.Value.Should().BeNull(); + Db.Single().MovieFile.Should().BeNull(); } diff --git a/src/NzbDrone.Core.Test/Datastore/MappingExtentionFixture.cs b/src/NzbDrone.Core.Test/Datastore/MappingExtentionFixture.cs index 76558e6f1..a8fc9670f 100644 --- a/src/NzbDrone.Core.Test/Datastore/MappingExtentionFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/MappingExtentionFixture.cs @@ -1,11 +1,11 @@ -using System.Collections.Generic; +using System.Collections.Generic; using FluentAssertions; using Marr.Data; using NUnit.Framework; using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore.Converters; using NzbDrone.Core.Datastore.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.Datastore { @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.Datastore public class TypeWithNoMappableProperties { - public Series Series { get; set; } + public Movie Movie { get; set; } public int ReadOnly { get; private set; } public int WriteOnly { private get; set; } @@ -62,4 +62,4 @@ namespace NzbDrone.Core.Test.Datastore properties.Should().NotContain(c => MappingExtensions.IsMappableProperty(c)); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core.Test/Datastore/MarrDataLazyLoadingFixture.cs b/src/NzbDrone.Core.Test/Datastore/MarrDataLazyLoadingFixture.cs index 49d67f063..02fca245c 100644 --- a/src/NzbDrone.Core.Test/Datastore/MarrDataLazyLoadingFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/MarrDataLazyLoadingFixture.cs @@ -1,9 +1,9 @@ -using FizzWare.NBuilder; +using FizzWare.NBuilder; using NUnit.Framework; using NzbDrone.Core.Datastore; using NzbDrone.Core.Profiles; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Qualities; using NzbDrone.Core.MediaFiles; @@ -26,82 +26,30 @@ namespace NzbDrone.Core.Test.Datastore profile = Db.Insert(profile); - var series = Builder.CreateListOfSize(1) + var series = Builder.CreateListOfSize(1) .All() .With(v => v.ProfileId = profile.Id) .BuildListOfNew(); Db.InsertMany(series); - var episodeFiles = Builder.CreateListOfSize(1) + var episodeFiles = Builder.CreateListOfSize(1) .All() - .With(v => v.SeriesId = series[0].Id) + .With(v => v.MovieId = series[0].Id) .With(v => v.Quality = new QualityModel()) .BuildListOfNew(); Db.InsertMany(episodeFiles); - var episodes = Builder.CreateListOfSize(10) + var episodes = Builder.CreateListOfSize(10) .All() .With(v => v.Monitored = true) - .With(v => v.EpisodeFileId = episodeFiles[0].Id) - .With(v => v.SeriesId = series[0].Id) + .With(v => v.MovieFileId = episodeFiles[0].Id) .BuildListOfNew(); Db.InsertMany(episodes); } - [Test] - public void should_lazy_load_profile_if_not_joined() - { - var db = Mocker.Resolve(); - var DataMapper = db.GetDataMapper(); - - var episodes = DataMapper.Query() - .Join(Marr.Data.QGen.JoinType.Inner, v => v.Series, (l, r) => l.SeriesId == r.Id) - .ToList(); - - foreach (var episode in episodes) - { - Assert.IsNotNull(episode.Series); - Assert.IsFalse(episode.Series.Profile.IsLoaded); - } - } - - [Test] - public void should_explicit_load_episodefile_if_joined() - { - var db = Mocker.Resolve(); - var DataMapper = db.GetDataMapper(); - - var episodes = DataMapper.Query() - .Join(Marr.Data.QGen.JoinType.Inner, v => v.EpisodeFile, (l, r) => l.EpisodeFileId == r.Id) - .ToList(); - - foreach (var episode in episodes) - { - Assert.IsNull(episode.Series); - Assert.IsTrue(episode.EpisodeFile.IsLoaded); - } - } - - [Test] - public void should_explicit_load_profile_if_joined() - { - var db = Mocker.Resolve(); - var DataMapper = db.GetDataMapper(); - - var episodes = DataMapper.Query() - .Join(Marr.Data.QGen.JoinType.Inner, v => v.Series, (l, r) => l.SeriesId == r.Id) - .Join(Marr.Data.QGen.JoinType.Inner, v => v.Profile, (l, r) => l.ProfileId == r.Id) - .ToList(); - - foreach (var episode in episodes) - { - Assert.IsNotNull(episode.Series); - Assert.IsTrue(episode.Series.Profile.IsLoaded); - } - } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core.Test/Datastore/PagingSpecExtensionsTests/PagingOffsetFixture.cs b/src/NzbDrone.Core.Test/Datastore/PagingSpecExtensionsTests/PagingOffsetFixture.cs index 5ece0f8a4..ad64ff036 100644 --- a/src/NzbDrone.Core.Test/Datastore/PagingSpecExtensionsTests/PagingOffsetFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/PagingSpecExtensionsTests/PagingOffsetFixture.cs @@ -1,8 +1,8 @@ -using FluentAssertions; +using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.Datastore.PagingSpecExtensionsTests { @@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.Datastore.PagingSpecExtensionsTests [TestCase(1, 100, 0)] public void should_calcuate_expected_offset(int page, int pageSize, int expected) { - var pagingSpec = new PagingSpec + var pagingSpec = new PagingSpec { Page = page, PageSize = pageSize, diff --git a/src/NzbDrone.Core.Test/Datastore/PagingSpecExtensionsTests/ToSortDirectionFixture.cs b/src/NzbDrone.Core.Test/Datastore/PagingSpecExtensionsTests/ToSortDirectionFixture.cs index d2cecde84..0067adb1f 100644 --- a/src/NzbDrone.Core.Test/Datastore/PagingSpecExtensionsTests/ToSortDirectionFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/PagingSpecExtensionsTests/ToSortDirectionFixture.cs @@ -1,8 +1,8 @@ -using FluentAssertions; +using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.Datastore.PagingSpecExtensionsTests { @@ -11,7 +11,7 @@ namespace NzbDrone.Core.Test.Datastore.PagingSpecExtensionsTests [Test] public void should_convert_default_to_asc() { - var pagingSpec = new PagingSpec + var pagingSpec = new PagingSpec { Page = 1, PageSize = 10, @@ -25,7 +25,7 @@ namespace NzbDrone.Core.Test.Datastore.PagingSpecExtensionsTests [Test] public void should_convert_ascending_to_asc() { - var pagingSpec = new PagingSpec + var pagingSpec = new PagingSpec { Page = 1, PageSize = 10, @@ -39,7 +39,7 @@ namespace NzbDrone.Core.Test.Datastore.PagingSpecExtensionsTests [Test] public void should_convert_descending_to_desc() { - var pagingSpec = new PagingSpec + var pagingSpec = new PagingSpec { Page = 1, PageSize = 10, diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/AcceptableSizeSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/AcceptableSizeSpecificationFixture.cs index ea5d0951e..ea3934725 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/AcceptableSizeSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/AcceptableSizeSpecificationFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using FizzWare.NBuilder; using FluentAssertions; @@ -8,7 +8,7 @@ using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.DecisionEngineTests { @@ -16,54 +16,23 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class AcceptableSizeSpecificationFixture : CoreTest { - private RemoteEpisode parseResultMultiSet; - private RemoteEpisode parseResultMulti; - private RemoteEpisode parseResultSingle; - private Series series; - private Movie movie; - private RemoteMovie remoteMovie; + private Movie movie; + private RemoteMovie remoteMovie; private QualityDefinition qualityType; [SetUp] public void Setup() { - series = Builder.CreateNew() - .Build(); - movie = Builder.CreateNew().Build(); - - remoteMovie = new RemoteMovie - { - Movie = movie, - Release = new ReleaseInfo(), - ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.SDTV, new Revision(version: 2)) }, - - }; - - parseResultMultiSet = new RemoteEpisode - { - Series = series, - Release = new ReleaseInfo(), - ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.SDTV, new Revision(version: 2)) }, - Episodes = new List { new Episode(), new Episode(), new Episode(), new Episode(), new Episode(), new Episode() } - }; - - parseResultMulti = new RemoteEpisode - { - Series = series, - Release = new ReleaseInfo(), - ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.SDTV, new Revision(version: 2)) }, - Episodes = new List { new Episode(), new Episode() } - }; - - parseResultSingle = new RemoteEpisode - { - Series = series, - Release = new ReleaseInfo(), - ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.SDTV, new Revision(version: 2)) }, - Episodes = new List { new Episode() { Id = 2 } } - - }; + movie = Builder.CreateNew().Build(); + + remoteMovie = new RemoteMovie + { + Movie = movie, + Release = new ReleaseInfo(), + ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.SDTV, new Revision(version: 2)) }, + + }; Mocker.GetMock() .Setup(v => v.Get(It.IsAny())) @@ -76,22 +45,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests .Build(); Mocker.GetMock().Setup(s => s.Get(Quality.SDTV)).Returns(qualityType); - - Mocker.GetMock().Setup( - s => s.GetEpisodesBySeason(It.IsAny(), It.IsAny())) - .Returns(new List() { - new Episode(), new Episode(), new Episode(), new Episode(), new Episode(), - new Episode(), new Episode(), new Episode(), new Episode() { Id = 2 }, new Episode() }); } - private void GivenLastEpisode() - { - Mocker.GetMock().Setup( - s => s.GetEpisodesBySeason(It.IsAny(), It.IsAny())) - .Returns(new List() { - new Episode(), new Episode(), new Episode(), new Episode(), new Episode(), - new Episode(), new Episode(), new Episode(), new Episode(), new Episode() { Id = 2 } }); - } [TestCase(30, 50, false)] [TestCase(30, 250, true)] @@ -100,145 +55,58 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [TestCase(60, 500, true)] [TestCase(60, 1000, false)] public void single_episode(int runtime, int sizeInMegaBytes, bool expectedResult) - { - series.Runtime = runtime; - parseResultSingle.Series = series; - parseResultSingle.Release.Size = sizeInMegaBytes.Megabytes(); - - Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().Be(expectedResult); - } - - [TestCase(30, 500, true)] - [TestCase(30, 1000, false)] - [TestCase(60, 1000, true)] - [TestCase(60, 2000, false)] - public void single_episode_first_or_last(int runtime, int sizeInMegaBytes, bool expectedResult) - { - GivenLastEpisode(); - - series.Runtime = runtime; - parseResultSingle.Series = series; - parseResultSingle.Release.Size = sizeInMegaBytes.Megabytes(); - - Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().Be(expectedResult); - } - - [TestCase(30, 50 * 2, false)] - [TestCase(30, 250 * 2, true)] - [TestCase(30, 500 * 2, false)] - [TestCase(60, 100 * 2, false)] - [TestCase(60, 500 * 2, true)] - [TestCase(60, 1000 * 2, false)] - public void multi_episode(int runtime, int sizeInMegaBytes, bool expectedResult) - { - series.Runtime = runtime; - parseResultMulti.Series = series; - parseResultMulti.Release.Size = sizeInMegaBytes.Megabytes(); - - Subject.IsSatisfiedBy(parseResultMulti, null).Accepted.Should().Be(expectedResult); - } - - [TestCase(30, 50 * 6, false)] - [TestCase(30, 250 * 6, true)] - [TestCase(30, 500 * 6, false)] - [TestCase(60, 100 * 6, false)] - [TestCase(60, 500 * 6, true)] - [TestCase(60, 1000 * 6, false)] - public void multiset_episode(int runtime, int sizeInMegaBytes, bool expectedResult) { - series.Runtime = runtime; - parseResultMultiSet.Series = series; - parseResultMultiSet.Release.Size = sizeInMegaBytes.Megabytes(); + movie.Runtime = runtime; + remoteMovie.Movie = movie; + remoteMovie.Release.Size = sizeInMegaBytes.Megabytes(); - Subject.IsSatisfiedBy(parseResultMultiSet, null).Accepted.Should().Be(expectedResult); + Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().Be(expectedResult); } [Test] public void should_return_true_if_size_is_zero() { - GivenLastEpisode(); - - series.Runtime = 30; - parseResultSingle.Series = series; - parseResultSingle.Release.Size = 0; + movie.Runtime = 120; + remoteMovie.Movie = movie; + remoteMovie.Release.Size = 0; qualityType.MinSize = 10; qualityType.MaxSize = 20; - Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().BeTrue(); } [Test] public void should_return_true_if_unlimited_30_minute() { - GivenLastEpisode(); - - series.Runtime = 30; - parseResultSingle.Series = series; - parseResultSingle.Release.Size = 18457280000; + movie.Runtime = 30; + remoteMovie.Movie = movie; + remoteMovie.Release.Size = 18457280000; qualityType.MaxSize = null; - Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().BeTrue(); } - + [Test] public void should_return_true_if_unlimited_60_minute() { - GivenLastEpisode(); - - series.Runtime = 60; - parseResultSingle.Series = series; - parseResultSingle.Release.Size = 36857280000; + movie.Runtime = 60; + remoteMovie.Movie = movie; + remoteMovie.Release.Size = 36857280000; qualityType.MaxSize = null; - Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue(); - } - - [Test] - public void should_treat_daily_series_as_single_episode() - { - GivenLastEpisode(); - - series.Runtime = 60; - parseResultSingle.Series = series; - parseResultSingle.Series.SeriesType = SeriesTypes.Daily; - parseResultSingle.Release.Size = 300.Megabytes(); - - qualityType.MaxSize = 10; - - Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().BeTrue(); } - //[Test] - //public void should_return_true_if_RAWHD() - //{ - // parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.RAWHD); - - // series.Runtime = 45; - // parseResultSingle.Series = series; - // parseResultSingle.Series.SeriesType = SeriesTypes.Daily; - // parseResultSingle.Release.Size = 8000.Megabytes(); - - // Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue(); - //} - [Test] - public void should_return_true_for_special() + public void should_use_110_minutes_if_runtime_is_0() { - parseResultSingle.ParsedEpisodeInfo.Special = true; + movie.Runtime = 0; + remoteMovie.Movie = movie; + remoteMovie.Release.Size = 1095.Megabytes(); - Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().Be(true); + remoteMovie.Release.Size = 1105.Megabytes(); + Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().Be(false); } - - [Test] - public void should_use_110_minutes_if_runtime_is_0() - { - movie.Runtime = 0; - remoteMovie.Movie = movie; - remoteMovie.Release.Size = 1095.Megabytes(); - - Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().Be(true); - remoteMovie.Release.Size = 1105.Megabytes(); - Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().Be(false); - } } } diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/AnimeVersionUpgradeSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/AnimeVersionUpgradeSpecificationFixture.cs deleted file mode 100644 index 2a555a186..000000000 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/AnimeVersionUpgradeSpecificationFixture.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using Marr.Data; -using NUnit.Framework; -using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.DecisionEngine.Specifications; -using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.DecisionEngineTests -{ - [TestFixture] - public class AnimeVersionUpgradeSpecificationFixture : CoreTest - { - private AnimeVersionUpgradeSpecification _subject; - private RemoteEpisode _remoteEpisode; - private EpisodeFile _episodeFile; - - [SetUp] - public void Setup() - { - Mocker.Resolve(); - _subject = Mocker.Resolve(); - - _episodeFile = new EpisodeFile - { - Quality = new QualityModel(Quality.HDTV720p, new Revision()), - ReleaseGroup = "DRONE2" - }; - - _remoteEpisode = new RemoteEpisode(); - _remoteEpisode.Series = new Series { SeriesType = SeriesTypes.Anime }; - _remoteEpisode.ParsedEpisodeInfo = new ParsedEpisodeInfo - { - Quality = new QualityModel(Quality.HDTV720p, new Revision(2)), - ReleaseGroup = "DRONE" - }; - - _remoteEpisode.Episodes = Builder.CreateListOfSize(1) - .All() - .With(e => e.EpisodeFile = new LazyLoaded(_episodeFile)) - .Build() - .ToList(); - } - - private void GivenStandardSeries() - { - _remoteEpisode.Series.SeriesType = SeriesTypes.Standard; - } - - private void GivenNoVersionUpgrade() - { - _remoteEpisode.ParsedEpisodeInfo.Quality.Revision = new Revision(); - } - - [Test] - public void should_be_true_when_no_existing_file() - { - _remoteEpisode.Episodes.First().EpisodeFileId = 0; - - _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); - } - - [Test] - public void should_be_true_if_series_is_not_anime() - { - GivenStandardSeries(); - _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); - } - - [Test] - public void should_be_true_if_is_not_a_version_upgrade_for_existing_file() - { - GivenNoVersionUpgrade(); - _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); - } - - [Test] - public void should_be_true_when_release_group_matches() - { - _episodeFile.ReleaseGroup = _remoteEpisode.ParsedEpisodeInfo.ReleaseGroup; - - _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); - } - - [Test] - public void should_be_false_when_existing_file_doesnt_have_a_release_group() - { - _episodeFile.ReleaseGroup = string.Empty; - _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); - } - - [Test] - public void should_should_be_false_when_release_doesnt_have_a_release_group() - { - _remoteEpisode.ParsedEpisodeInfo.ReleaseGroup = string.Empty; - _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); - } - - [Test] - public void should_be_false_when_release_group_does_not_match() - { - _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/DownloadDecisionMakerFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/DownloadDecisionMakerFixture.cs index 52736c9fb..c8242e536 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/DownloadDecisionMakerFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/DownloadDecisionMakerFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using FluentAssertions; using Moq; @@ -8,7 +8,7 @@ using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; using FizzWare.NBuilder; @@ -206,51 +206,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests result.Should().HaveCount(1); } - [Test] - [Ignore( "Series")] - public void should_only_include_reports_for_requested_episodes() - { - var series = Builder.CreateNew().Build(); - - var episodes = Builder.CreateListOfSize(2) - .All() - .With(v => v.SeriesId, series.Id) - .With(v => v.Series, series) - .With(v => v.SeasonNumber, 1) - .With(v => v.SceneSeasonNumber, 2) - .BuildList(); - - var criteria = new SeasonSearchCriteria { Episodes = episodes.Take(1).ToList(), SeasonNumber = 1 }; - - var reports = episodes.Select(v => - new ReleaseInfo() - { - Title = string.Format("{0}.S{1:00}E{2:00}.720p.WEB-DL-DRONE", series.Title, v.SceneSeasonNumber, v.SceneEpisodeNumber) - }).ToList(); - - Mocker.GetMock() - .Setup(v => v.Map(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) - .Returns((p,tvdbid,tvrageid,c) => - new RemoteEpisode - { - DownloadAllowed = true, - ParsedEpisodeInfo = p, - Series = series, - Episodes = episodes.Where(v => v.SceneEpisodeNumber == p.EpisodeNumbers.First()).ToList() - }); - - Mocker.SetConstant>(new List - { - Mocker.Resolve() - }); - - var decisions = Subject.GetSearchDecision(reports, criteria); - - var approvedDecisions = decisions.Where(v => v.Approved).ToList(); - - approvedDecisions.Count.Should().Be(1); - } - [Test] public void should_not_allow_download_if_series_is_unknown() { @@ -299,4 +254,4 @@ namespace NzbDrone.Core.Test.DecisionEngineTests ExceptionVerification.ExpectedErrors(1); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/FullSeasonSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/FullSeasonSpecificationFixture.cs deleted file mode 100644 index 1416ec17e..000000000 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/FullSeasonSpecificationFixture.cs +++ /dev/null @@ -1,76 +0,0 @@ - -using System; -using NUnit.Framework; -using NzbDrone.Core.DecisionEngine.Specifications; -using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Test.Framework; -using FizzWare.NBuilder; -using System.Linq; -using FluentAssertions; -using NzbDrone.Core.Tv; -using Moq; -using System.Collections.Generic; - -namespace NzbDrone.Core.Test.DecisionEngineTests -{ - [TestFixture] - [Ignore("Series")] - public class FullSeasonSpecificationFixture : CoreTest - { - private RemoteEpisode _remoteEpisode; - - [SetUp] - public void Setup() - { - var show = Builder.CreateNew().With(s => s.Id = 1234).Build(); - _remoteEpisode = new RemoteEpisode - { - ParsedEpisodeInfo = new ParsedEpisodeInfo - { - FullSeason = true - }, - Episodes = Builder.CreateListOfSize(3) - .All() - .With(e => e.AirDateUtc = DateTime.UtcNow.AddDays(-8)) - .With(s => s.SeriesId = show.Id) - .BuildList(), - Series = show, - Release = new ReleaseInfo - { - Title = "Series.Title.S01.720p.BluRay.X264-RlsGrp" - } - }; - - Mocker.GetMock().Setup(s => s.EpisodesBetweenDates(It.IsAny(), It.IsAny(), false)) - .Returns(new List()); - } - - [Test] - public void should_return_true_if_is_not_a_full_season() - { - _remoteEpisode.ParsedEpisodeInfo.FullSeason = false; - _remoteEpisode.Episodes.Last().AirDateUtc = DateTime.UtcNow.AddDays(+2); - Mocker.Resolve().IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); - } - - [Test] - public void should_return_true_if_all_episodes_have_aired() - { - Mocker.Resolve().IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); - } - - [Test] - public void should_return_false_if_one_episode_has_not_aired() - { - _remoteEpisode.Episodes.Last().AirDateUtc = DateTime.UtcNow.AddDays(+2); - Mocker.Resolve().IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); - } - - [Test] - public void should_return_false_if_an_episode_does_not_have_an_air_date() - { - _remoteEpisode.Episodes.Last().AirDateUtc = null; - Mocker.Resolve().IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); - } - } -} diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/HistorySpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/HistorySpecificationFixture.cs index 0e9785e83..af1c15503 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/HistorySpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/HistorySpecificationFixture.cs @@ -11,7 +11,7 @@ using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Test.Framework; @@ -23,11 +23,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { private HistorySpecification _upgradeHistory; - private RemoteEpisode _parseResultMulti; - private RemoteEpisode _parseResultSingle; + private RemoteMovie _parseResultMulti; + private RemoteMovie _parseResultSingle; private QualityModel _upgradableQuality; private QualityModel _notupgradableQuality; - private Series _fakeSeries; + private Movie _fakeMovie; private const int FIRST_EPISODE_ID = 1; private const int SECOND_EPISODE_ID = 2; @@ -37,29 +37,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests Mocker.Resolve(); _upgradeHistory = Mocker.Resolve(); - var singleEpisodeList = new List { new Episode { Id = FIRST_EPISODE_ID, SeasonNumber = 12, EpisodeNumber = 3 } }; - var doubleEpisodeList = new List { - new Episode {Id = FIRST_EPISODE_ID, SeasonNumber = 12, EpisodeNumber = 3 }, - new Episode {Id = SECOND_EPISODE_ID, SeasonNumber = 12, EpisodeNumber = 4 }, - new Episode {Id = 3, SeasonNumber = 12, EpisodeNumber = 5 } - }; - - _fakeSeries = Builder.CreateNew() + _fakeMovie = Builder.CreateNew() .With(c => c.Profile = new Profile { Cutoff = Quality.Bluray1080p, Items = Qualities.QualityFixture.GetDefaultQualities() }) .Build(); - _parseResultMulti = new RemoteEpisode - { - Series = _fakeSeries, - ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) }, - Episodes = doubleEpisodeList - }; - - _parseResultSingle = new RemoteEpisode + _parseResultSingle = new RemoteMovie { - Series = _fakeSeries, - ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) }, - Episodes = singleEpisodeList + Movie = _fakeMovie, + ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) } }; _upgradableQuality = new QualityModel(Quality.SDTV, new Revision(version: 1)); @@ -86,7 +71,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [Test] public void should_return_true_if_it_is_a_search() { - _upgradeHistory.IsSatisfiedBy(_parseResultMulti, new SeasonSearchCriteria()).Accepted.Should().BeTrue(); + _upgradeHistory.IsSatisfiedBy(_parseResultMulti, new MovieSearchCriteria()).Accepted.Should().BeTrue(); } [Test] @@ -159,8 +144,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [Test] public void should_not_be_upgradable_if_episode_is_of_same_quality_as_existing() { - _fakeSeries.Profile = new Profile { Cutoff = Quality.Bluray1080p, Items = Qualities.QualityFixture.GetDefaultQualities() }; - _parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.WEBDL1080p, new Revision(version: 1)); + _fakeMovie.Profile = new Profile { Cutoff = Quality.Bluray1080p, Items = Qualities.QualityFixture.GetDefaultQualities() }; + _parseResultSingle.ParsedMovieInfo.Quality = new QualityModel(Quality.WEBDL1080p, new Revision(version: 1)); _upgradableQuality = new QualityModel(Quality.WEBDL1080p, new Revision(version: 1)); GivenMostRecentForEpisode(FIRST_EPISODE_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); @@ -171,8 +156,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [Test] public void should_not_be_upgradable_if_cutoff_already_met() { - _fakeSeries.Profile = new Profile { Cutoff = Quality.WEBDL1080p, Items = Qualities.QualityFixture.GetDefaultQualities() }; - _parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.WEBDL1080p, new Revision(version: 1)); + _fakeMovie.Profile = new Profile { Cutoff = Quality.WEBDL1080p, Items = Qualities.QualityFixture.GetDefaultQualities() }; + _parseResultSingle.ParsedMovieInfo.Quality = new QualityModel(Quality.WEBDL1080p, new Revision(version: 1)); _upgradableQuality = new QualityModel(Quality.Bluray1080p, new Revision(version: 1)); GivenMostRecentForEpisode(FIRST_EPISODE_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); @@ -199,8 +184,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void should_return_false_if_cutoff_already_met_and_cdh_is_disabled() { GivenCdhDisabled(); - _fakeSeries.Profile = new Profile { Cutoff = Quality.WEBDL1080p, Items = Qualities.QualityFixture.GetDefaultQualities() }; - _parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 1)); + _fakeMovie.Profile = new Profile { Cutoff = Quality.WEBDL1080p, Items = Qualities.QualityFixture.GetDefaultQualities() }; + _parseResultSingle.ParsedMovieInfo.Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 1)); _upgradableQuality = new QualityModel(Quality.WEBDL1080p, new Revision(version: 1)); GivenMostRecentForEpisode(FIRST_EPISODE_ID, "test", _upgradableQuality, DateTime.UtcNow.AddDays(-100), HistoryEventType.Grabbed); diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/LanguageSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/LanguageSpecificationFixture.cs index f190677c3..677997799 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/LanguageSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/LanguageSpecificationFixture.cs @@ -1,4 +1,4 @@ -using FluentAssertions; +using FluentAssertions; using Marr.Data; using NUnit.Framework; using NzbDrone.Core.DecisionEngine.Specifications; @@ -6,7 +6,7 @@ using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.DecisionEngineTests { @@ -14,18 +14,18 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class LanguageSpecificationFixture : CoreTest { - private RemoteEpisode _remoteEpisode; + private RemoteMovie _remoteEpisode; [SetUp] public void Setup() { - _remoteEpisode = new RemoteEpisode + _remoteEpisode = new RemoteMovie { - ParsedEpisodeInfo = new ParsedEpisodeInfo + ParsedMovieInfo = new ParsedMovieInfo { Language = Language.English }, - Series = new Series + Movie = new Movie { Profile = new LazyLoaded(new Profile { @@ -37,12 +37,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests private void WithEnglishRelease() { - _remoteEpisode.ParsedEpisodeInfo.Language = Language.English; + _remoteEpisode.ParsedMovieInfo.Language = Language.English; } private void WithGermanRelease() { - _remoteEpisode.ParsedEpisodeInfo.Language = Language.German; + _remoteEpisode.ParsedMovieInfo.Language = Language.German; } [Test] @@ -61,4 +61,4 @@ namespace NzbDrone.Core.Test.DecisionEngineTests Mocker.Resolve().IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/MinimumAgeSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/MinimumAgeSpecificationFixture.cs index 745eb68d5..1ebb17b30 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/MinimumAgeSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/MinimumAgeSpecificationFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.Configuration; @@ -13,12 +13,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class MinimumAgeSpecificationFixture : CoreTest { - private RemoteEpisode _remoteEpisode; + private RemoteMovie _remoteEpisode; [SetUp] public void Setup() { - _remoteEpisode = new RemoteEpisode + _remoteEpisode = new RemoteMovie { Release = new ReleaseInfo() { DownloadProtocol = DownloadProtocol.Usenet } }; @@ -61,4 +61,4 @@ namespace NzbDrone.Core.Test.DecisionEngineTests Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/MonitoredMovieSpecificationFixture.cs similarity index 52% rename from src/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs rename to src/NzbDrone.Core.Test/DecisionEngineTests/MonitoredMovieSpecificationFixture.cs index 36a46337d..ba6d394e0 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/MonitoredMovieSpecificationFixture.cs @@ -1,53 +1,51 @@ -using System.Collections.Generic; +using System.Collections.Generic; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.DecisionEngine.Specifications.RssSync; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.DecisionEngineTests { [TestFixture] - public class MonitoredEpisodeSpecificationFixture : CoreTest + public class MonitoredMovieSpecificationFixture : CoreTest { - private MonitoredEpisodeSpecification _monitoredEpisodeSpecification; + private MonitoredMovieSpecification _monitoredEpisodeSpecification; - private RemoteEpisode _parseResultMulti; - private RemoteEpisode _parseResultSingle; - private Series _fakeSeries; - private Episode _firstEpisode; - private Episode _secondEpisode; + private RemoteMovie _parseResultMulti; + private RemoteMovie _parseResultSingle; + private Movie _fakeSeries; + private Movie _firstEpisode; + private Movie _secondEpisode; [SetUp] public void Setup() { - _monitoredEpisodeSpecification = Mocker.Resolve(); + _monitoredEpisodeSpecification = Mocker.Resolve(); - _fakeSeries = Builder.CreateNew() + _fakeSeries = Builder.CreateNew() .With(c => c.Monitored = true) .Build(); - _firstEpisode = new Episode { Monitored = true }; - _secondEpisode = new Episode { Monitored = true }; + _firstEpisode = new Movie() { Monitored = true }; + _secondEpisode = new Movie() { Monitored = true }; - var singleEpisodeList = new List { _firstEpisode }; - var doubleEpisodeList = new List { _firstEpisode, _secondEpisode }; + var singleEpisodeList = new List { _firstEpisode }; + var doubleEpisodeList = new List { _firstEpisode, _secondEpisode }; - _parseResultMulti = new RemoteEpisode + _parseResultMulti = new RemoteMovie { - Series = _fakeSeries, - Episodes = doubleEpisodeList + Movie = _fakeSeries }; - _parseResultSingle = new RemoteEpisode + _parseResultSingle = new RemoteMovie { - Series = _fakeSeries, - Episodes = singleEpisodeList + Movie = _fakeSeries }; } @@ -108,34 +106,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void should_return_true_for_single_episode_search() { _fakeSeries.Monitored = false; - _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SingleEpisodeSearchCriteria()).Accepted.Should().BeTrue(); + _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new MovieSearchCriteria()).Accepted.Should().BeTrue(); } - [Test] - public void should_return_true_if_episode_is_monitored_for_season_search() - { - _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SeasonSearchCriteria()).Accepted.Should().BeTrue(); - } - - [Test] - public void should_return_false_if_episode_is_not_monitored_for_season_search() - { - WithFirstEpisodeUnmonitored(); - _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SeasonSearchCriteria()).Accepted.Should().BeFalse(); - } - - [Test] - public void should_return_true_if_episode_is_not_monitored_and_monitoredEpisodesOnly_flag_is_false() - { - WithFirstEpisodeUnmonitored(); - _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SingleEpisodeSearchCriteria { MonitoredEpisodesOnly = false }).Accepted.Should().BeTrue(); - } - - [Test] - public void should_return_false_if_episode_is_not_monitored_and_monitoredEpisodesOnly_flag_is_true() - { - WithFirstEpisodeUnmonitored(); - _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SingleEpisodeSearchCriteria{ MonitoredEpisodesOnly = true}).Accepted.Should().BeFalse(); - } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/PrioritizeDownloadDecisionFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/PrioritizeDownloadDecisionFixture.cs index 5d08ba2db..a03d7692b 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/PrioritizeDownloadDecisionFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/PrioritizeDownloadDecisionFixture.cs @@ -4,7 +4,7 @@ using System.Linq; using Moq; using NzbDrone.Core.Indexers; using NzbDrone.Core.Profiles.Delay; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; using NzbDrone.Core.Parser.Model; diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/ProtocolSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/ProtocolSpecificationFixture.cs index 4bfaf34dc..d25c7ac85 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/ProtocolSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/ProtocolSpecificationFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using FluentAssertions; using Moq; using NUnit.Framework; @@ -7,22 +7,22 @@ using NzbDrone.Core.Indexers; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Delay; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.DecisionEngineTests { [TestFixture] public class ProtocolSpecificationFixture : CoreTest { - private RemoteEpisode _remoteEpisode; + private RemoteMovie _remoteEpisode; private DelayProfile _delayProfile; [SetUp] public void Setup() { - _remoteEpisode = new RemoteEpisode(); + _remoteEpisode = new RemoteMovie(); _remoteEpisode.Release = new ReleaseInfo(); - _remoteEpisode.Series = new Series(); + _remoteEpisode.Movie = new Movie(); _delayProfile = new DelayProfile(); @@ -72,4 +72,4 @@ namespace NzbDrone.Core.Test.DecisionEngineTests Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().Be(false); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/QualityAllowedByProfileSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/QualityAllowedByProfileSpecificationFixture.cs index e833cd8d2..c92a27c8b 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/QualityAllowedByProfileSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/QualityAllowedByProfileSpecificationFixture.cs @@ -1,4 +1,4 @@ -using FizzWare.NBuilder; +using FizzWare.NBuilder; using FluentAssertions; using Marr.Data; using NUnit.Framework; @@ -6,7 +6,7 @@ using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.DecisionEngineTests @@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class QualityAllowedByProfileSpecificationFixture : CoreTest { - private RemoteEpisode remoteEpisode; + private RemoteMovie remoteMovie; public static object[] AllowedTestCases = { @@ -34,33 +34,33 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [SetUp] public void Setup() { - var fakeSeries = Builder.CreateNew() + var fakeSeries = Builder.CreateNew() .With(c => c.Profile = (LazyLoaded)new Profile { Cutoff = Quality.Bluray1080p }) .Build(); - remoteEpisode = new RemoteEpisode + remoteMovie = new RemoteMovie { - Series = fakeSeries, - ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) }, + Movie = fakeSeries, + ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) }, }; } [Test, TestCaseSource("AllowedTestCases")] public void should_allow_if_quality_is_defined_in_profile(Quality qualityType) { - remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType; - remoteEpisode.Series.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p); + remoteMovie.ParsedMovieInfo.Quality.Quality = qualityType; + remoteMovie.Movie.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p); - Subject.IsSatisfiedBy(remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().BeTrue(); } [Test, TestCaseSource("DeniedTestCases")] public void should_not_allow_if_quality_is_not_defined_in_profile(Quality qualityType) { - remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType; - remoteEpisode.Series.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p); + remoteMovie.ParsedMovieInfo.Quality.Quality = qualityType; + remoteMovie.Movie.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p); - Subject.IsSatisfiedBy(remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().BeFalse(); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs index 6ed0cbde4..1cf3d38c5 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using FizzWare.NBuilder; using FluentAssertions; @@ -9,7 +9,7 @@ using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; using NzbDrone.Core.Queue; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.DecisionEngineTests @@ -17,41 +17,27 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [TestFixture] public class QueueSpecificationFixture : CoreTest { - private Series _series; - private Episode _episode; - private RemoteEpisode _remoteEpisode; + private Movie _movie; + private RemoteMovie _remoteMovie; - private Series _otherSeries; - private Episode _otherEpisode; + private Movie _otherMovie; [SetUp] public void Setup() { Mocker.Resolve(); - _series = Builder.CreateNew() + _movie = Builder.CreateNew() .With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() }) .Build(); - _episode = Builder.CreateNew() - .With(e => e.SeriesId = _series.Id) - .Build(); - - _otherSeries = Builder.CreateNew() + _otherMovie = Builder.CreateNew() .With(s => s.Id = 2) .Build(); - _otherEpisode = Builder.CreateNew() - .With(e => e.SeriesId = _otherSeries.Id) - .With(e => e.Id = 2) - .With(e => e.SeasonNumber = 2) - .With(e => e.EpisodeNumber = 2) - .Build(); - - _remoteEpisode = Builder.CreateNew() - .With(r => r.Series = _series) - .With(r => r.Episodes = new List { _episode }) - .With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD) }) + _remoteMovie = Builder.CreateNew() + .With(r => r.Movie = _movie) + .With(r => r.ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.DVD) }) .Build(); } @@ -62,11 +48,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests .Returns(new List()); } - private void GivenQueue(IEnumerable remoteEpisodes) + private void GivenQueue(IEnumerable remoteEpisodes) { var queue = remoteEpisodes.Select(remoteEpisode => new Queue.Queue { - RemoteEpisode = remoteEpisode + RemoteMovie = remoteEpisode }); Mocker.GetMock() @@ -78,181 +64,100 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void should_return_true_when_queue_is_empty() { GivenEmptyQueue(); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } [Test] public void should_return_true_when_series_doesnt_match() { - var remoteEpisode = Builder.CreateNew() - .With(r => r.Series = _otherSeries) - .With(r => r.Episodes = new List { _episode }) + var remoteEpisode = Builder.CreateNew() + .With(r => r.Movie = _otherMovie) .Build(); - GivenQueue(new List { remoteEpisode }); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + GivenQueue(new List { remoteEpisode }); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } [Test] public void should_return_true_when_quality_in_queue_is_lower() { - _series.Profile.Value.Cutoff = Quality.Bluray1080p; + _movie.Profile.Value.Cutoff = Quality.Bluray1080p; - var remoteEpisode = Builder.CreateNew() - .With(r => r.Series = _series) - .With(r => r.Episodes = new List { _episode }) - .With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo + var remoteEpisode = Builder.CreateNew() + .With(r => r.Movie = _movie) + .With(r => r.ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.SDTV) }) .Build(); - GivenQueue(new List { remoteEpisode }); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + GivenQueue(new List { remoteEpisode }); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } [Test] public void should_return_true_when_episode_doesnt_match() { - var remoteEpisode = Builder.CreateNew() - .With(r => r.Series = _series) - .With(r => r.Episodes = new List { _otherEpisode }) - .With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo + var remoteEpisode = Builder.CreateNew() + .With(r => r.Movie = _movie) + .With(r => r.ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.DVD) }) .Build(); - GivenQueue(new List { remoteEpisode }); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + GivenQueue(new List { remoteEpisode }); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } [Test] public void should_return_false_when_qualities_are_the_same() { - var remoteEpisode = Builder.CreateNew() - .With(r => r.Series = _series) - .With(r => r.Episodes = new List { _episode }) - .With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo + var remoteEpisode = Builder.CreateNew() + .With(r => r.Movie = _movie) + .With(r => r.ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.DVD) }) .Build(); - GivenQueue(new List { remoteEpisode }); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + GivenQueue(new List { remoteEpisode }); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse(); } [Test] public void should_return_false_when_quality_in_queue_is_better() { - _series.Profile.Value.Cutoff = Quality.Bluray1080p; + _movie.Profile.Value.Cutoff = Quality.Bluray1080p; - var remoteEpisode = Builder.CreateNew() - .With(r => r.Series = _series) - .With(r => r.Episodes = new List { _episode }) - .With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo + var remoteEpisode = Builder.CreateNew() + .With(r => r.Movie = _movie) + .With(r => r.ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.HDTV720p) }) .Build(); - GivenQueue(new List { remoteEpisode }); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); - } - - [Test] - public void should_return_false_if_matching_multi_episode_is_in_queue() - { - var remoteEpisode = Builder.CreateNew() - .With(r => r.Series = _series) - .With(r => r.Episodes = new List { _episode, _otherEpisode }) - .With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo - { - Quality = new QualityModel(Quality.HDTV720p) - }) - .Build(); - - GivenQueue(new List { remoteEpisode }); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); - } - - [Test] - public void should_return_false_if_multi_episode_has_one_episode_in_queue() - { - var remoteEpisode = Builder.CreateNew() - .With(r => r.Series = _series) - .With(r => r.Episodes = new List { _episode }) - .With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo - { - Quality = new QualityModel(Quality.HDTV720p) - }) - .Build(); - - _remoteEpisode.Episodes.Add(_otherEpisode); - - GivenQueue(new List { remoteEpisode }); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); - } - - [Test] - public void should_return_false_if_multi_part_episode_is_already_in_queue() - { - var remoteEpisode = Builder.CreateNew() - .With(r => r.Series = _series) - .With(r => r.Episodes = new List { _episode, _otherEpisode }) - .With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo - { - Quality = new QualityModel(Quality.HDTV720p) - }) - .Build(); - - _remoteEpisode.Episodes.Add(_otherEpisode); - - GivenQueue(new List { remoteEpisode }); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); - } - - [Test] - public void should_return_false_if_multi_part_episode_has_two_episodes_in_queue() - { - var remoteEpisodes = Builder.CreateListOfSize(2) - .All() - .With(r => r.Series = _series) - .With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo - { - Quality = - new QualityModel( - Quality.HDTV720p) - }) - .TheFirst(1) - .With(r => r.Episodes = new List { _episode }) - .TheNext(1) - .With(r => r.Episodes = new List { _otherEpisode }) - .Build(); - - _remoteEpisode.Episodes.Add(_otherEpisode); - GivenQueue(remoteEpisodes); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + GivenQueue(new List { remoteEpisode }); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse(); } [Test] public void should_return_false_if_quality_in_queue_meets_cutoff() { - _series.Profile.Value.Cutoff = _remoteEpisode.ParsedEpisodeInfo.Quality.Quality; + _movie.Profile.Value.Cutoff = _remoteMovie.ParsedMovieInfo.Quality.Quality; - var remoteEpisode = Builder.CreateNew() - .With(r => r.Series = _series) - .With(r => r.Episodes = new List { _episode }) - .With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo + var remoteEpisode = Builder.CreateNew() + .With(r => r.Movie = _movie) + .With(r => r.ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.HDTV720p) }) .Build(); - GivenQueue(new List { remoteEpisode }); + GivenQueue(new List { remoteEpisode }); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse(); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/RawDiskSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/RawDiskSpecificationFixture.cs index 024c3763b..ef36d40bf 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/RawDiskSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/RawDiskSpecificationFixture.cs @@ -1,4 +1,4 @@ -using FluentAssertions; +using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Parser.Model; @@ -12,12 +12,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class RawDiskSpecificationFixture : CoreTest { - private RemoteEpisode _remoteEpisode; + private RemoteMovie _remoteMovie; [SetUp] public void Setup() { - _remoteEpisode = new RemoteEpisode + _remoteMovie = new RemoteMovie { Release = new ReleaseInfo() { DownloadProtocol = DownloadProtocol.Torrent } }; @@ -25,49 +25,49 @@ namespace NzbDrone.Core.Test.DecisionEngineTests private void WithContainer(string container) { - _remoteEpisode.Release.Container = container; + _remoteMovie.Release.Container = container; } [Test] public void should_return_true_if_no_container_specified() { - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } [Test] public void should_return_true_if_mkv() { WithContainer("MKV"); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } [Test] public void should_return_false_if_vob() { WithContainer("VOB"); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse(); } [Test] public void should_return_false_if_iso() { WithContainer("ISO"); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse(); } [Test] public void should_return_false_if_m2ts() { WithContainer("M2TS"); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse(); } [Test] public void should_compare_case_insensitive() { WithContainer("vob"); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse(); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/ReleaseRestrictionsSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/ReleaseRestrictionsSpecificationFixture.cs index 5ccaaaedb..f06408a5c 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/ReleaseRestrictionsSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/ReleaseRestrictionsSpecificationFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using FluentAssertions; using Moq; using NUnit.Framework; @@ -6,21 +6,21 @@ using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Restrictions; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.DecisionEngineTests { [TestFixture] public class ReleaseRestrictionsSpecificationFixture : CoreTest { - private RemoteEpisode _remoteEpisode; + private RemoteMovie _remoteMovie; [SetUp] public void Setup() { - _remoteEpisode = new RemoteEpisode - { - Series = new Series + _remoteMovie = new RemoteMovie + { + Movie = new Movie { Tags = new HashSet() }, @@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests .Setup(s => s.AllForTags(It.IsAny>())) .Returns(new List()); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } [Test] @@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenRestictions("WEBRip", null); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } [Test] @@ -68,7 +68,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenRestictions("doesnt,exist", null); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse(); } [Test] @@ -76,7 +76,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenRestictions(null, "ignored"); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } [Test] @@ -84,7 +84,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenRestictions(null, "edited"); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse(); } [TestCase("EdiTED")] @@ -95,7 +95,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenRestictions(required, null); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } [TestCase("EdiTED")] @@ -106,13 +106,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenRestictions(null, ignored); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse(); } [Test] public void should_be_false_when_release_contains_one_restricted_word_and_one_required_word() { - _remoteEpisode.Release.Title = "[ www.Speed.cd ] -Whose.Line.is.it.Anyway.US.S10E24.720p.HDTV.x264-BAJSKORV"; + _remoteMovie.Release.Title = "[ www.Speed.cd ] -Whose.Line.is.it.Anyway.US.S10E24.720p.HDTV.x264-BAJSKORV"; Mocker.GetMock() .Setup(s => s.AllForTags(It.IsAny>())) @@ -121,7 +121,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests new Restriction { Required = "x264", Ignored = "www.Speed.cd" } }); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse(); } } } diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs index a9c8ace61..747783edd 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.Configuration; @@ -13,12 +13,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class RetentionSpecificationFixture : CoreTest { - private RemoteEpisode _remoteEpisode; + private RemoteMovie _remoteMovie; [SetUp] public void Setup() { - _remoteEpisode = new RemoteEpisode + _remoteMovie = new RemoteMovie { Release = new ReleaseInfo() { DownloadProtocol = DownloadProtocol.Usenet } }; @@ -31,7 +31,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests private void WithAge(int days) { - _remoteEpisode.Release.PublishDate = DateTime.UtcNow.AddDays(-days); + _remoteMovie.Release.PublishDate = DateTime.UtcNow.AddDays(-days); } [Test] @@ -40,7 +40,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests WithRetention(0); WithAge(100); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } [Test] @@ -49,7 +49,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests WithRetention(1000); WithAge(100); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } [Test] @@ -58,7 +58,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests WithRetention(100); WithAge(100); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } [Test] @@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests WithRetention(10); WithAge(100); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse(); } [Test] @@ -76,18 +76,18 @@ namespace NzbDrone.Core.Test.DecisionEngineTests WithRetention(0); WithAge(100); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } [Test] public void should_return_true_when_release_is_not_usenet() { - _remoteEpisode.Release.DownloadProtocol = DownloadProtocol.Torrent; + _remoteMovie.Release.DownloadProtocol = DownloadProtocol.Torrent; WithRetention(10); WithAge(100); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DelaySpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DelaySpecificationFixture.cs index c012f8b6e..1f01c4ae1 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DelaySpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DelaySpecificationFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using FizzWare.NBuilder; @@ -17,7 +17,7 @@ using NzbDrone.Core.Profiles; using NzbDrone.Core.Profiles.Delay; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync { @@ -91,7 +91,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync [Test] public void should_be_true_when_user_invoked_search() { - Subject.IsSatisfiedBy(new RemoteEpisode(), new SingleEpisodeSearchCriteria { UserInvokedSearch = true }).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(new RemoteMovie(), new MovieSearchCriteria() { UserInvokedSearch = true }).Accepted.Should().BeTrue(); } [Test] @@ -102,7 +102,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync _delayProfile.UsenetDelay = 720; - Subject.IsSatisfiedBy(_remoteEpisode, new SingleEpisodeSearchCriteria()).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteEpisode, new MovieSearchCriteria()).Accepted.Should().BeFalse(); } [Test] diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/ProperSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/ProperSpecificationFixture.cs index 0d711c1a0..9dd3a100a 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/ProperSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/ProperSpecificationFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using FizzWare.NBuilder; using FluentAssertions; @@ -10,7 +10,7 @@ using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Test.Framework; @@ -21,38 +21,26 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync public class ProperSpecificationFixture : CoreTest { - private RemoteEpisode _parseResultMulti; - private RemoteEpisode _parseResultSingle; - private EpisodeFile _firstFile; - private EpisodeFile _secondFile; + private RemoteMovie _parseResultSingle; + private MovieFile _firstFile; + private MovieFile _secondFile; [SetUp] public void Setup() { Mocker.Resolve(); - _firstFile = new EpisodeFile { Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 1)), DateAdded = DateTime.Now }; - _secondFile = new EpisodeFile { Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 1)), DateAdded = DateTime.Now }; + _firstFile = new MovieFile { Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 1)), DateAdded = DateTime.Now }; + _secondFile = new MovieFile { Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 1)), DateAdded = DateTime.Now }; - var singleEpisodeList = new List { new Episode { EpisodeFile = _firstFile, EpisodeFileId = 1 }, new Episode { EpisodeFile = null } }; - var doubleEpisodeList = new List { new Episode { EpisodeFile = _firstFile, EpisodeFileId = 1 }, new Episode { EpisodeFile = _secondFile, EpisodeFileId = 1 }, new Episode { EpisodeFile = null } }; - - var fakeSeries = Builder.CreateNew() + var fakeSeries = Builder.CreateNew() .With(c => c.Profile = new Profile { Cutoff = Quality.Bluray1080p }) .Build(); - _parseResultMulti = new RemoteEpisode + _parseResultSingle = new RemoteMovie { - Series = fakeSeries, - ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) }, - Episodes = doubleEpisodeList - }; - - _parseResultSingle = new RemoteEpisode - { - Series = fakeSeries, - ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) }, - Episodes = singleEpisodeList + Movie = fakeSeries, + ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) }, }; } @@ -69,7 +57,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync } [Test] - public void should_return_false_when_episodeFile_was_added_more_than_7_days_ago() + public void should_return_false_when_movieFile_was_added_more_than_7_days_ago() { _firstFile.Quality.Quality = Quality.DVD; @@ -78,27 +66,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync } [Test] - public void should_return_false_when_first_episodeFile_was_added_more_than_7_days_ago() - { - _firstFile.Quality.Quality = Quality.DVD; - _secondFile.Quality.Quality = Quality.DVD; - - _firstFile.DateAdded = DateTime.Today.AddDays(-30); - Subject.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); - } - - [Test] - public void should_return_false_when_second_episodeFile_was_added_more_than_7_days_ago() - { - _firstFile.Quality.Quality = Quality.DVD; - _secondFile.Quality.Quality = Quality.DVD; - - _secondFile.DateAdded = DateTime.Today.AddDays(-30); - Subject.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); - } - - [Test] - public void should_return_true_when_episodeFile_was_added_more_than_7_days_ago_but_proper_is_for_better_quality() + public void should_return_true_when_movieFile_was_added_more_than_7_days_ago_but_proper_is_for_better_quality() { WithFirstFileUpgradable(); @@ -112,7 +80,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync WithFirstFileUpgradable(); _firstFile.DateAdded = DateTime.Today.AddDays(-30); - Subject.IsSatisfiedBy(_parseResultSingle, new SingleEpisodeSearchCriteria()).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_parseResultSingle, new MovieSearchCriteria()).Accepted.Should().BeTrue(); } [Test] @@ -125,7 +93,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync } [Test] - public void should_return_true_when_episodeFile_was_added_today() + public void should_return_true_when_movieFile_was_added_today() { GivenAutoDownloadPropers(); @@ -135,4 +103,4 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue(); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/SameEpisodesSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/SameEpisodesSpecificationFixture.cs deleted file mode 100644 index 183b6cc77..000000000 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/SameEpisodesSpecificationFixture.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using Moq; -using NUnit.Framework; -using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Tv; - -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.DecisionEngineTests -{ - [TestFixture] - public class SameEpisodesSpecificationFixture : CoreTest - { - private List _episodes; - - [SetUp] - public void Setup() - { - _episodes = Builder.CreateListOfSize(2) - .All() - .With(e => e.EpisodeFileId = 1) - .BuildList(); - } - - private void GivenEpisodesInFile(List episodes) - { - Mocker.GetMock() - .Setup(s => s.GetEpisodesByFileId(It.IsAny())) - .Returns(episodes); - } - - [Test] - public void should_not_upgrade_when_new_release_contains_less_episodes() - { - GivenEpisodesInFile(_episodes); - - Subject.IsSatisfiedBy(new List { _episodes.First() }).Should().BeFalse(); - } - - [Test] - public void should_upgrade_when_new_release_contains_more_episodes() - { - GivenEpisodesInFile(new List { _episodes.First() }); - - Subject.IsSatisfiedBy(_episodes).Should().BeTrue(); - } - - [Test] - public void should_upgrade_when_new_release_contains_the_same_episodes() - { - GivenEpisodesInFile(_episodes); - - Subject.IsSatisfiedBy(_episodes).Should().BeTrue(); - } - - [Test] - public void should_upgrade_when_release_contains_the_same_episodes_as_multiple_files() - { - var episodes = Builder.CreateListOfSize(2) - .BuildList(); - - Mocker.GetMock() - .Setup(s => s.GetEpisodesByFileId(episodes.First().EpisodeFileId)) - .Returns(new List { episodes.First() }); - - Mocker.GetMock() - .Setup(s => s.GetEpisodesByFileId(episodes.Last().EpisodeFileId)) - .Returns(new List { episodes.Last() }); - - Subject.IsSatisfiedBy(episodes).Should().BeTrue(); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/Search/SeriesSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/Search/MovieSpecificationFixture.cs similarity index 54% rename from src/NzbDrone.Core.Test/DecisionEngineTests/Search/SeriesSpecificationFixture.cs rename to src/NzbDrone.Core.Test/DecisionEngineTests/Search/MovieSpecificationFixture.cs index 279890763..ca44fe186 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/Search/SeriesSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/Search/MovieSpecificationFixture.cs @@ -1,35 +1,35 @@ -using FizzWare.NBuilder; +using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.DecisionEngine.Specifications.Search; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.DecisionEngineTests.Search { [TestFixture] - public class SeriesSpecificationFixture : TestBase + public class MovieSpecificationFixture : TestBase { - private Series _series1; - private Series _series2; - private RemoteEpisode _remoteEpisode = new RemoteEpisode(); - private SearchCriteriaBase _searchCriteria = new SingleEpisodeSearchCriteria(); + private Movie _movie1; + private Movie _movie2; + private RemoteMovie _remoteEpisode = new RemoteMovie(); + private SearchCriteriaBase _searchCriteria = new MovieSearchCriteria(); [SetUp] public void Setup() { - _series1 = Builder.CreateNew().With(s => s.Id = 1).Build(); - _series2 = Builder.CreateNew().With(s => s.Id = 2).Build(); + _movie1 = Builder.CreateNew().With(s => s.Id = 1).Build(); + _movie2 = Builder.CreateNew().With(s => s.Id = 2).Build(); - _remoteEpisode.Series = _series1; + _remoteEpisode.Movie = _movie1; } [Test] public void should_return_false_if_series_doesnt_match() { - _searchCriteria.Series = _series2; + _searchCriteria.Movie = _movie2; Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Accepted.Should().BeFalse(); } @@ -37,7 +37,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search [Test] public void should_return_true_when_series_ids_match() { - _searchCriteria.Series = _series1; + _searchCriteria.Movie = _movie1; Subject.IsSatisfiedBy(_remoteEpisode, _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 56c4ac84f..97bdec044 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/Search/TorrentSeedingSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/Search/TorrentSeedingSpecificationFixture.cs @@ -1,4 +1,4 @@ -using FizzWare.NBuilder; +using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; @@ -8,7 +8,7 @@ using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers.TorrentRss; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.DecisionEngineTests.Search @@ -16,18 +16,18 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search [TestFixture] public class TorrentSeedingSpecificationFixture : TestBase { - private Series _series; - private RemoteEpisode _remoteEpisode; + private Movie _movie; + private RemoteMovie _remoteMovie; private IndexerDefinition _indexerDefinition; [SetUp] public void Setup() { - _series = Builder.CreateNew().With(s => s.Id = 1).Build(); + _movie = Builder.CreateNew().With(s => s.Id = 1).Build(); - _remoteEpisode = new RemoteEpisode + _remoteMovie = new RemoteMovie { - Series = _series, + Movie = _movie, Release = new TorrentInfo { IndexerId = 1, @@ -49,27 +49,27 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search private void GivenReleaseSeeders(int? seeders) { - (_remoteEpisode.Release as TorrentInfo).Seeders = seeders; + (_remoteMovie.Release as TorrentInfo).Seeders = seeders; } [Test] public void should_return_true_if_not_torrent() { - _remoteEpisode.Release = new ReleaseInfo + _remoteMovie.Release = new ReleaseInfo { IndexerId = 1, Title = "Series.Title.S01.720p.BluRay.X264-RlsGrp" }; - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } [Test] public void should_return_true_if_indexer_not_specified() { - _remoteEpisode.Release.IndexerId = 0; + _remoteMovie.Release.IndexerId = 0; - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } [Test] @@ -79,7 +79,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search .Setup(v => v.Get(It.IsAny())) .Callback(i => { throw new ModelNotFoundException(typeof(IndexerDefinition), i); }); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } [Test] @@ -87,7 +87,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search { GivenReleaseSeeders(null); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } [TestCase(5)] @@ -96,7 +96,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search { GivenReleaseSeeders(seeders); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } [TestCase(0)] @@ -105,7 +105,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search { GivenReleaseSeeders(seeders); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse(); } } } diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/UpgradeDiskSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/UpgradeDiskSpecificationFixture.cs index ab5795267..277fa1bd9 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/UpgradeDiskSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/UpgradeDiskSpecificationFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using FizzWare.NBuilder; using FluentAssertions; @@ -8,7 +8,7 @@ using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Test.Framework; @@ -20,11 +20,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class UpgradeDiskSpecificationFixture : CoreTest { private UpgradeDiskSpecification _upgradeDisk; - - private RemoteEpisode _parseResultMulti; - private RemoteEpisode _parseResultSingle; - private EpisodeFile _firstFile; - private EpisodeFile _secondFile; + + private RemoteMovie _parseResultSingle; + private MovieFile _firstFile; [SetUp] public void Setup() @@ -32,28 +30,17 @@ namespace NzbDrone.Core.Test.DecisionEngineTests Mocker.Resolve(); _upgradeDisk = Mocker.Resolve(); - _firstFile = new EpisodeFile { Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 2)), DateAdded = DateTime.Now }; - _secondFile = new EpisodeFile { Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 2)), DateAdded = DateTime.Now }; - - var singleEpisodeList = new List { new Episode { EpisodeFile = _firstFile, EpisodeFileId = 1 }, new Episode { EpisodeFile = null } }; - var doubleEpisodeList = new List { new Episode { EpisodeFile = _firstFile, EpisodeFileId = 1 }, new Episode { EpisodeFile = _secondFile, EpisodeFileId = 1 }, new Episode { EpisodeFile = null } }; + _firstFile = new MovieFile { Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 2)), DateAdded = DateTime.Now }; - var fakeSeries = Builder.CreateNew() + var fakeSeries = Builder.CreateNew() .With(c => c.Profile = new Profile { Cutoff = Quality.Bluray1080p, Items = Qualities.QualityFixture.GetDefaultQualities() }) + .With(e => e.MovieFile = _firstFile) .Build(); - _parseResultMulti = new RemoteEpisode - { - Series = fakeSeries, - ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) }, - Episodes = doubleEpisodeList - }; - - _parseResultSingle = new RemoteEpisode + _parseResultSingle = new RemoteMovie { - Series = fakeSeries, - ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) }, - Episodes = singleEpisodeList + Movie = fakeSeries, + ParsedMovieInfo = new ParsedMovieInfo() { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) }, }; } @@ -62,23 +49,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests _firstFile.Quality = new QualityModel(Quality.SDTV); } - private void WithSecondFileUpgradable() - { - _secondFile.Quality = new QualityModel(Quality.SDTV); - } - [Test] public void should_return_true_if_episode_has_no_existing_file() { - _parseResultSingle.Episodes.ForEach(c => c.EpisodeFileId = 0); - _upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue(); - } - - [Test] - public void should_return_true_if_single_episode_doesnt_exist_on_disk() - { - _parseResultSingle.Episodes = new List(); - + _parseResultSingle.Movie.MovieFileId = 0; _upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue(); } @@ -89,40 +63,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests _upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue(); } - [Test] - public void should_be_upgradable_if_both_episodes_are_upgradable() - { - WithFirstFileUpgradable(); - WithSecondFileUpgradable(); - _upgradeDisk.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue(); - } - - [Test] - public void should_be_not_upgradable_if_both_episodes_are_not_upgradable() - { - _upgradeDisk.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); - } - - [Test] - public void should_be_not_upgradable_if_only_first_episodes_is_upgradable() - { - WithFirstFileUpgradable(); - _upgradeDisk.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); - } - - [Test] - public void should_be_not_upgradable_if_only_second_episodes_is_upgradable() - { - WithSecondFileUpgradable(); - _upgradeDisk.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); - } - [Test] public void should_not_be_upgradable_if_qualities_are_the_same() { _firstFile.Quality = new QualityModel(Quality.WEBDL1080p); - _parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.WEBDL1080p); + _parseResultSingle.ParsedMovieInfo.Quality = new QualityModel(Quality.WEBDL1080p); _upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse(); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core.Test/Download/CompletedDownloadServiceFixture.cs b/src/NzbDrone.Core.Test/Download/CompletedDownloadServiceFixture.cs index 618f276de..efdcff54d 100644 --- a/src/NzbDrone.Core.Test/Download/CompletedDownloadServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Download/CompletedDownloadServiceFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using FizzWare.NBuilder; using FluentAssertions; using Moq; @@ -10,12 +10,12 @@ using NzbDrone.Core.Download; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.History; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.MediaFiles.EpisodeImport; +using NzbDrone.Core.MediaFiles.MovieImport; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.Download @@ -83,7 +83,7 @@ namespace NzbDrone.Core.Test.Download .Setup(v => v.ProcessPath(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(new List { - new ImportResult(new ImportDecision(new LocalEpisode() { Path = @"C:\TestPath\Droned.1998.mkv" })) + new ImportResult(new ImportDecision(new LocalMovie() { Path = @"C:\TestPath\Droned.1998.mkv" })) }); } @@ -307,7 +307,7 @@ namespace NzbDrone.Core.Test.Download .Setup(v => v.ProcessPath(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(new List { - new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.1998.mkv"})) + new ImportResult(new ImportDecision(new LocalMovie {Path = @"C:\TestPath\Droned.1998.mkv"})) }); Mocker.GetMock() diff --git a/src/NzbDrone.Core.Test/Download/DownloadApprovedReportsTests/DownloadApprovedFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadApprovedReportsTests/DownloadApprovedFixture.cs index f77a2c30d..57fae86c0 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadApprovedReportsTests/DownloadApprovedFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadApprovedReportsTests/DownloadApprovedFixture.cs @@ -11,7 +11,7 @@ using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs index ae34ba53e..71a40ed31 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs @@ -8,7 +8,7 @@ using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Download; using NzbDrone.Core.Configuration; using NzbDrone.Core.RemotePathMappings; diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs index 158116e36..ba3a4fdb0 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Net; using Moq; @@ -38,8 +38,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests _remoteMovie.Release.Title = _title; _remoteMovie.Release.DownloadUrl = _nzbUrl; - _remoteMovie.ParsedEpisodeInfo = new ParsedEpisodeInfo(); - _remoteMovie.ParsedEpisodeInfo.FullSeason = false; + _remoteMovie.ParsedMovieInfo = new ParsedMovieInfo(); Subject.Definition = new DownloadClientDefinition(); Subject.Definition.Settings = new PneumaticSettings @@ -70,15 +69,6 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests Assert.Throws(() => Subject.Download(_remoteMovie)); } - [Test] - public void should_throw_if_full_season_download() - { - _remoteMovie.Release.Title = "30 Rock - Season 1"; - _remoteMovie.ParsedEpisodeInfo.FullSeason = true; - - Assert.Throws(() => Subject.Download(_remoteMovie)); - } - [Test] public void should_throw_item_is_removed() { diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs index a9eb1b97f..181d827b8 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs @@ -8,7 +8,7 @@ using NUnit.Framework; using NzbDrone.Core.Download; using NzbDrone.Core.Download.Clients.Sabnzbd; using NzbDrone.Core.Download.Clients.Sabnzbd.Responses; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; using NzbDrone.Core.RemotePathMappings; using NzbDrone.Common.Disk; diff --git a/src/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs index b82216b19..77811aa8f 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs @@ -12,7 +12,7 @@ using NzbDrone.Core.Exceptions; using NzbDrone.Core.Indexers; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.Download @@ -20,7 +20,7 @@ namespace NzbDrone.Core.Test.Download [TestFixture] public class DownloadServiceFixture : CoreTest { - private RemoteEpisode _parseResult; + private RemoteMovie _parseResult; private List _downloadClients; [SetUp] public void Setup() @@ -35,21 +35,14 @@ namespace NzbDrone.Core.Test.Download .Setup(v => v.GetDownloadClient(It.IsAny())) .Returns(v => _downloadClients.FirstOrDefault(d => d.Protocol == v)); - var episodes = Builder.CreateListOfSize(2) - .TheFirst(1).With(s => s.Id = 12) - .TheNext(1).With(s => s.Id = 99) - .All().With(s => s.SeriesId = 5) - .Build().ToList(); - var releaseInfo = Builder.CreateNew() .With(v => v.DownloadProtocol = DownloadProtocol.Usenet) .With(v => v.DownloadUrl = "http://test.site/download1.ext") .Build(); - _parseResult = Builder.CreateNew() - .With(c => c.Series = Builder.CreateNew().Build()) + _parseResult = Builder.CreateNew() + .With(c => c.Movie = Builder.CreateNew().Build()) .With(c => c.Release = releaseInfo) - .With(c => c.Episodes = episodes) .Build(); } @@ -81,42 +74,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 +127,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)); }); @@ -153,8 +146,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)); }); @@ -170,7 +163,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 +177,8 @@ namespace NzbDrone.Core.Test.Download { 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(); ExceptionVerification.ExpectedWarns(1); } @@ -198,8 +191,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] @@ -212,8 +205,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/FailedDownloadServiceFixture.cs b/src/NzbDrone.Core.Test/Download/FailedDownloadServiceFixture.cs index 42b589e6b..9524efa17 100644 --- a/src/NzbDrone.Core.Test/Download/FailedDownloadServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Download/FailedDownloadServiceFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using FizzWare.NBuilder; using FluentAssertions; using Moq; @@ -10,7 +10,7 @@ using NzbDrone.Core.History; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.Download @@ -32,16 +32,15 @@ namespace NzbDrone.Core.Test.Download _grabHistory = Builder.CreateListOfSize(2).BuildList(); - var remoteEpisode = new RemoteEpisode + var remoteEpisode = new RemoteMovie { - Series = new Series(), - Episodes = new List { new Episode { Id = 1 } } + Movie = new Movie(), }; _trackedDownload = Builder.CreateNew() .With(c => c.State = TrackedDownloadStage.Downloading) .With(c => c.DownloadItem = completed) - .With(c => c.RemoteEpisode = remoteEpisode) + .With(c => c.RemoteMovie = remoteEpisode) .Build(); diff --git a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/AddFixture.cs b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/AddFixture.cs index 2d5f78ee6..8bd505e1a 100644 --- a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/AddFixture.cs +++ b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/AddFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using FizzWare.NBuilder; using Marr.Data; @@ -12,7 +12,7 @@ using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests { @@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests .Returns(_movie); Mocker.GetMock() - .Setup(s => s.PrioritizeDecisions(It.IsAny>())) + .Setup(s => s.PrioritizeDecisionsForMovies(It.IsAny>())) .Returns((List d) => d); } diff --git a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveGrabbedFixture.cs b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveGrabbedFixture.cs index 43f03ee8d..c627f15d8 100644 --- a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveGrabbedFixture.cs +++ b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveGrabbedFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using FizzWare.NBuilder; using Marr.Data; using Moq; @@ -12,7 +12,7 @@ using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests { @@ -72,7 +72,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests // .Returns(_episode); Mocker.GetMock() - .Setup(s => s.PrioritizeDecisions(It.IsAny>())) + .Setup(s => s.PrioritizeDecisionsForMovies(It.IsAny>())) .Returns((List d) => d); } diff --git a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemovePendingFixture.cs b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemovePendingFixture.cs index d4cffe1a0..752103109 100644 --- a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemovePendingFixture.cs +++ b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemovePendingFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using FizzWare.NBuilder; using Moq; @@ -8,7 +8,7 @@ using NzbDrone.Core.Download.Pending; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests { @@ -17,18 +17,18 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests public class RemovePendingFixture : CoreTest { private List _pending; - private Episode _episode; + private Movie _movie; [SetUp] public void Setup() { _pending = new List(); - _episode = Builder.CreateNew() + _movie = Builder.CreateNew() .Build(); Mocker.GetMock() - .Setup(s => s.AllBySeriesId(It.IsAny())) + .Setup(s => s.AllByMovieId(It.IsAny())) .Returns(_pending); Mocker.GetMock() @@ -44,21 +44,21 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests .Returns(_movie);*/ } - private void AddPending(int id, int seasonNumber, int[] episodes) + private void AddPending(int id, string title, int year) { _pending.Add(new PendingRelease { Id = id, - ParsedEpisodeInfo = new ParsedEpisodeInfo { SeasonNumber = seasonNumber, EpisodeNumbers = episodes } + ParsedMovieInfo = new ParsedMovieInfo { MovieTitle = title, Year = year } }); } [Test] public void should_remove_same_release() { - AddPending(id: 1, seasonNumber: 2, episodes: new[] { 3 }); + AddPending(id: 1, title: "Movie", year: 2001); - var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _episode.Id)); + var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _movie.Id)); Subject.RemovePendingQueueItems(queueId); @@ -68,12 +68,12 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests [Test] public void should_remove_multiple_releases_release() { - AddPending(id: 1, seasonNumber: 2, episodes: new[] { 1 }); - AddPending(id: 2, seasonNumber: 2, episodes: new[] { 2 }); - AddPending(id: 3, seasonNumber: 2, episodes: new[] { 3 }); - AddPending(id: 4, seasonNumber: 2, episodes: new[] { 3 }); + AddPending(id: 1, title: "Movie", year: 2001); + AddPending(id: 2, title: "Movie", year: 2002); + AddPending(id: 3, title: "Movie", year: 2003); + AddPending(id: 4, title: "Movie", year: 2003); - var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 3, _episode.Id)); + var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 3, _movie.Id)); Subject.RemovePendingQueueItems(queueId); @@ -83,12 +83,12 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests [Test] public void should_not_remove_diffrent_season() { - AddPending(id: 1, seasonNumber: 2, episodes: new[] { 1 }); - AddPending(id: 2, seasonNumber: 2, episodes: new[] { 1 }); - AddPending(id: 3, seasonNumber: 3, episodes: new[] { 1 }); - AddPending(id: 4, seasonNumber: 3, episodes: new[] { 1 }); + AddPending(id: 1, title: "Movie", year: 2001); + AddPending(id: 2, title: "Movie", year: 2001); + AddPending(id: 3, title: "Movie", year: 2001); + AddPending(id: 4, title: "Movie", year: 2001); - var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _episode.Id)); + var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _movie.Id)); Subject.RemovePendingQueueItems(queueId); @@ -98,12 +98,12 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests [Test] public void should_not_remove_diffrent_episodes() { - AddPending(id: 1, seasonNumber: 2, episodes: new[] { 1 }); - AddPending(id: 2, seasonNumber: 2, episodes: new[] { 1 }); - AddPending(id: 3, seasonNumber: 2, episodes: new[] { 2 }); - AddPending(id: 4, seasonNumber: 2, episodes: new[] { 3 }); + AddPending(id: 1, title: "Movie", year: 2001); + AddPending(id: 2, title: "Movie", year: 2001); + AddPending(id: 3, title: "Movie", year: 2001); + AddPending(id: 4, title: "Movie", year: 2001); - var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _episode.Id)); + var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _movie.Id)); Subject.RemovePendingQueueItems(queueId); @@ -113,10 +113,10 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests [Test] public void should_not_remove_multiepisodes() { - AddPending(id: 1, seasonNumber: 2, episodes: new[] { 1 }); - AddPending(id: 2, seasonNumber: 2, episodes: new[] { 1, 2 }); + AddPending(id: 1, title: "Movie", year: 2001); + AddPending(id: 2, title: "Movie", year: 2001); - var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _episode.Id)); + var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _movie.Id)); Subject.RemovePendingQueueItems(queueId); @@ -126,10 +126,10 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests [Test] public void should_not_remove_singleepisodes() { - AddPending(id: 1, seasonNumber: 2, episodes: new[] { 1 }); - AddPending(id: 2, seasonNumber: 2, episodes: new[] { 1, 2 }); + AddPending(id: 1, title: "Movie", year: 2001); + AddPending(id: 2, title: "Movie", year: 2001); - var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 2, _episode.Id)); + var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 2, _movie.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 b3df82d45..1399498db 100644 --- a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveRejectedFixture.cs +++ b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveRejectedFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using FizzWare.NBuilder; using Marr.Data; @@ -14,7 +14,7 @@ using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests { @@ -75,7 +75,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests .Returns(_movie); Mocker.GetMock() - .Setup(s => s.PrioritizeDecisions(It.IsAny>())) + .Setup(s => s.PrioritizeDecisionsForMovies(It.IsAny>())) .Returns((List d) => d); } diff --git a/src/NzbDrone.Core.Test/Download/TrackedDownloads/TrackedDownloadServiceFixture.cs b/src/NzbDrone.Core.Test/Download/TrackedDownloads/TrackedDownloadServiceFixture.cs index a70934be4..e3e7c93b7 100644 --- a/src/NzbDrone.Core.Test/Download/TrackedDownloads/TrackedDownloadServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Download/TrackedDownloads/TrackedDownloadServiceFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using FluentAssertions; using Moq; using NUnit.Framework; @@ -8,7 +8,7 @@ using NzbDrone.Core.History; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Indexers; using System.Linq; @@ -25,8 +25,6 @@ namespace NzbDrone.Core.Test.Download.TrackedDownloads new History.History(){ DownloadId = "35238", SourceTitle = "TV Series S01", - SeriesId = 5, - EpisodeId = 4, MovieId = 3, } }); diff --git a/src/NzbDrone.Core.Test/HealthCheck/Checks/DeleteBadMediaCovers.cs b/src/NzbDrone.Core.Test/HealthCheck/Checks/DeleteBadMediaCovers.cs index cc4b3ae95..40a980074 100644 --- a/src/NzbDrone.Core.Test/HealthCheck/Checks/DeleteBadMediaCovers.cs +++ b/src/NzbDrone.Core.Test/HealthCheck/Checks/DeleteBadMediaCovers.cs @@ -11,7 +11,7 @@ using NzbDrone.Core.Extras.Metadata; using NzbDrone.Core.Extras.Metadata.Files; using NzbDrone.Core.Housekeeping.Housekeepers; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.HealthCheck.Checks @@ -80,7 +80,7 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks Subject.Clean(); Mocker.GetMock().VerifySet(c => c.CleanupMetadataImages = true, Times.Never()); - Mocker.GetMock().Verify(c => c.GetAllSeries(), Times.Never()); + Mocker.GetMock().Verify(c => c.GetAllMovies(), Times.Never()); AssertImageWasNotRemoved(); } diff --git a/src/NzbDrone.Core.Test/HealthCheck/Checks/RootFolderCheckFixture.cs b/src/NzbDrone.Core.Test/HealthCheck/Checks/RootFolderCheckFixture.cs index 45ad31207..bf1a06cf4 100644 --- a/src/NzbDrone.Core.Test/HealthCheck/Checks/RootFolderCheckFixture.cs +++ b/src/NzbDrone.Core.Test/HealthCheck/Checks/RootFolderCheckFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using FizzWare.NBuilder; using Moq; @@ -6,7 +6,7 @@ using NUnit.Framework; using NzbDrone.Common.Disk; using NzbDrone.Core.HealthCheck.Checks; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.HealthCheck.Checks { @@ -15,17 +15,17 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks { private void GivenMissingRootFolder() { - var series = Builder.CreateListOfSize(1) + var movies = Builder.CreateListOfSize(1) .Build() .ToList(); - Mocker.GetMock() - .Setup(s => s.GetAllSeries()) - .Returns(series); + Mocker.GetMock() + .Setup(s => s.GetAllMovies()) + .Returns(movies); Mocker.GetMock() - .Setup(s => s.GetParentFolder(series.First().Path)) - .Returns(@"C:\TV"); + .Setup(s => s.GetParentFolder(movies.First().Path)) + .Returns(@"C:\Movies"); Mocker.GetMock() .Setup(s => s.FolderExists(It.IsAny())) @@ -33,17 +33,17 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks } [Test] - public void should_not_return_error_when_no_series() + public void should_not_return_error_when_no_movie() { - Mocker.GetMock() - .Setup(s => s.GetAllSeries()) - .Returns(new List()); + Mocker.GetMock() + .Setup(s => s.GetAllMovies()) + .Returns(new List()); Subject.Check().ShouldBeOk(); } [Test] - public void should_return_error_if_series_parent_is_missing() + public void should_return_error_if_movie_parent_is_missing() { GivenMissingRootFolder(); diff --git a/src/NzbDrone.Core.Test/HistoryTests/HistoryServiceFixture.cs b/src/NzbDrone.Core.Test/HistoryTests/HistoryServiceFixture.cs index 6e100e2ae..9619e4a50 100644 --- a/src/NzbDrone.Core.Test/HistoryTests/HistoryServiceFixture.cs +++ b/src/NzbDrone.Core.Test/HistoryTests/HistoryServiceFixture.cs @@ -13,7 +13,7 @@ using NzbDrone.Core.Qualities; using System.Collections.Generic; using NzbDrone.Core.Test.Qualities; using FluentAssertions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.HistoryTests { diff --git a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedBlacklistFixture.cs b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedBlacklistFixture.cs index 6fe71c805..3e0208545 100644 --- a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedBlacklistFixture.cs +++ b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedBlacklistFixture.cs @@ -1,11 +1,11 @@ -using FizzWare.NBuilder; +using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.Blacklisting; using NzbDrone.Core.Housekeeping.Housekeepers; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using System.Collections.Generic; namespace NzbDrone.Core.Test.Housekeeping.Housekeepers @@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers public void should_delete_orphaned_blacklist_items() { var blacklist = Builder.CreateNew() - .With(h => h.EpisodeIds = new List()) + .With(h => h.MovieId = new int()) .With(h => h.Quality = new QualityModel()) .BuildNew(); @@ -34,7 +34,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers Db.Insert(movie); var blacklist = Builder.CreateNew() - .With(h => h.EpisodeIds = new List()) + .With(h => h.MovieId = new int()) .With(h => h.Quality = new QualityModel()) .With(b => b.MovieId = movie.Id) .BuildNew(); diff --git a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedEpisodesFixture.cs b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedEpisodesFixture.cs deleted file mode 100644 index 03f8b395e..000000000 --- a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedEpisodesFixture.cs +++ /dev/null @@ -1,43 +0,0 @@ -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Housekeeping.Housekeepers; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Test.Housekeeping.Housekeepers -{ - [TestFixture] - public class CleanupOrphanedEpisodesFixture : DbTest - { - [Test] - public void should_delete_orphaned_episodes() - { - var episode = Builder.CreateNew() - .BuildNew(); - - Db.Insert(episode); - Subject.Clean(); - AllStoredModels.Should().BeEmpty(); - } - - [Test] - public void should_not_delete_unorphaned_episodes() - { - var series = Builder.CreateNew() - .BuildNew(); - - Db.Insert(series); - - var episodes = Builder.CreateListOfSize(2) - .TheFirst(1) - .With(e => e.SeriesId = series.Id) - .BuildListOfNew(); - - Db.InsertMany(episodes); - Subject.Clean(); - AllStoredModels.Should().HaveCount(1); - AllStoredModels.Should().Contain(e => e.SeriesId == series.Id); - } - } -} diff --git a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedHistoryItemsFixture.cs b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedHistoryItemsFixture.cs index b7fea3dd5..fb1b257c3 100644 --- a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedHistoryItemsFixture.cs +++ b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedHistoryItemsFixture.cs @@ -4,7 +4,7 @@ using NUnit.Framework; using NzbDrone.Core.Housekeeping.Housekeepers; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.Housekeeping.Housekeepers { diff --git a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedMetadataFilesFixture.cs b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedMetadataFilesFixture.cs index 468e6b58a..7bb0dd880 100644 --- a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedMetadataFilesFixture.cs +++ b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedMetadataFilesFixture.cs @@ -7,7 +7,7 @@ using NzbDrone.Core.Housekeeping.Housekeepers; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.Housekeeping.Housekeepers { diff --git a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedEpisodeFilesFixture.cs b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedMovieFilesFixture.cs similarity index 91% rename from src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedEpisodeFilesFixture.cs rename to src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedMovieFilesFixture.cs index 725e1f5f6..d924d7991 100644 --- a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedEpisodeFilesFixture.cs +++ b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedMovieFilesFixture.cs @@ -1,17 +1,17 @@ -using System.Linq; +using System.Linq; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.Housekeeping.Housekeepers; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Qualities; namespace NzbDrone.Core.Test.Housekeeping.Housekeepers { [TestFixture] - public class CleanupOrphanedEpisodeFilesFixture : DbTest + public class CleanupOrphanedMovieFilesFixture : DbTest { [Test] public void should_delete_orphaned_episode_files() diff --git a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedPendingReleasesFixture.cs b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedPendingReleasesFixture.cs index a2ebefa59..503d7f6f2 100644 --- a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedPendingReleasesFixture.cs +++ b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedPendingReleasesFixture.cs @@ -5,7 +5,7 @@ using NzbDrone.Core.Download.Pending; using NzbDrone.Core.Housekeeping.Housekeepers; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.Housekeeping.Housekeepers { diff --git a/src/NzbDrone.Core.Test/IndexerSearchTests/NzbSearchServiceFixture.cs b/src/NzbDrone.Core.Test/IndexerSearchTests/NzbSearchServiceFixture.cs deleted file mode 100644 index f6089004e..000000000 --- a/src/NzbDrone.Core.Test/IndexerSearchTests/NzbSearchServiceFixture.cs +++ /dev/null @@ -1,265 +0,0 @@ -using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.DataAugmentation.Scene; -using NzbDrone.Core.IndexerSearch; -using NzbDrone.Core.Test.Framework; -using FizzWare.NBuilder; -using System.Collections.Generic; -using System.Linq; -using FluentAssertions; -using Moq; -using NUnit.Framework; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Indexers; -using NzbDrone.Core.IndexerSearch.Definitions; - -namespace NzbDrone.Core.Test.IndexerSearchTests -{ - public class NzbSearchServiceFixture : CoreTest - { - private Mock _mockIndexer; - private Series _xemSeries; - private List _xemEpisodes; - - [SetUp] - public void SetUp() - { - _mockIndexer = Mocker.GetMock(); - _mockIndexer.SetupGet(s => s.Definition).Returns(new IndexerDefinition { Id = 1 }); - _mockIndexer.SetupGet(s => s.SupportsSearch).Returns(true); - - Mocker.GetMock() - .Setup(s => s.SearchEnabled(true)) - .Returns(new List { _mockIndexer.Object }); - - Mocker.GetMock() - .Setup(s => s.GetSearchDecision(It.IsAny>(), It.IsAny())) - .Returns(new List()); - - _xemSeries = Builder.CreateNew() - .With(v => v.UseSceneNumbering = true) - .With(v => v.Monitored = true) - .Build(); - - _xemEpisodes = new List(); - - Mocker.GetMock() - .Setup(v => v.GetSeries(_xemSeries.Id)) - .Returns(_xemSeries); - - Mocker.GetMock() - .Setup(v => v.GetEpisodesBySeason(_xemSeries.Id, It.IsAny())) - .Returns((i, j) => _xemEpisodes.Where(d => d.SeasonNumber == j).ToList()); - - Mocker.GetMock() - .Setup(s => s.GetSceneNames(It.IsAny(), It.IsAny>(), It.IsAny>())) - .Returns(new List()); - } - - private void WithEpisode(int seasonNumber, int episodeNumber, int? sceneSeasonNumber, int? sceneEpisodeNumber) - { - var episode = Builder.CreateNew() - .With(v => v.SeriesId == _xemSeries.Id) - .With(v => v.Series == _xemSeries) - .With(v => v.SeasonNumber, seasonNumber) - .With(v => v.EpisodeNumber, episodeNumber) - .With(v => v.SceneSeasonNumber, sceneSeasonNumber) - .With(v => v.SceneEpisodeNumber, sceneEpisodeNumber) - .With(v => v.Monitored = true) - .Build(); - - _xemEpisodes.Add(episode); - } - - private void WithEpisodes() - { - // Season 1 maps to Scene Season 2 (one-to-one) - WithEpisode(1, 12, 2, 3); - WithEpisode(1, 13, 2, 4); - - // Season 2 maps to Scene Season 3 & 4 (one-to-one) - WithEpisode(2, 1, 3, 11); - WithEpisode(2, 2, 3, 12); - WithEpisode(2, 3, 4, 11); - WithEpisode(2, 4, 4, 12); - - // Season 3 maps to Scene Season 5 (partial) - // Season 4 maps to Scene Season 5 & 6 (partial) - WithEpisode(3, 1, 5, 11); - WithEpisode(3, 2, 5, 12); - WithEpisode(4, 1, 5, 13); - WithEpisode(4, 2, 5, 14); - WithEpisode(4, 3, 6, 11); - WithEpisode(5, 1, 6, 12); - - // Season 7+ maps normally, so no mapping specified. - WithEpisode(7, 1, null, null); - WithEpisode(7, 2, null, null); - } - - private List WatchForSearchCriteria() - { - var result = new List(); - - _mockIndexer.Setup(v => v.Fetch(It.IsAny())) - .Callback(s => result.Add(s)) - .Returns(new List()); - - _mockIndexer.Setup(v => v.Fetch(It.IsAny())) - .Callback(s => result.Add(s)) - .Returns(new List()); - - _mockIndexer.Setup(v => v.Fetch(It.IsAny())) - .Callback(s => result.Add(s)) - .Returns(new List()); - - return result; - } - - [Test] - public void scene_episodesearch() - { - WithEpisodes(); - - var allCriteria = WatchForSearchCriteria(); - - Subject.EpisodeSearch(_xemEpisodes.First(), true); - - var criteria = allCriteria.OfType().ToList(); - - criteria.Count.Should().Be(1); - criteria[0].SeasonNumber.Should().Be(2); - criteria[0].EpisodeNumber.Should().Be(3); - } - - [Test] - public void scene_seasonsearch() - { - WithEpisodes(); - - var allCriteria = WatchForSearchCriteria(); - - Subject.SeasonSearch(_xemSeries.Id, 1, false, true); - - var criteria = allCriteria.OfType().ToList(); - - criteria.Count.Should().Be(1); - criteria[0].SeasonNumber.Should().Be(2); - } - - [Test] - public void scene_seasonsearch_should_search_multiple_seasons() - { - WithEpisodes(); - - var allCriteria = WatchForSearchCriteria(); - - Subject.SeasonSearch(_xemSeries.Id, 2, false, true); - - var criteria = allCriteria.OfType().ToList(); - - criteria.Count.Should().Be(2); - criteria[0].SeasonNumber.Should().Be(3); - criteria[1].SeasonNumber.Should().Be(4); - } - - [Test] - public void scene_seasonsearch_should_search_single_episode_if_possible() - { - WithEpisodes(); - - var allCriteria = WatchForSearchCriteria(); - - Subject.SeasonSearch(_xemSeries.Id, 4, false, true); - - var criteria1 = allCriteria.OfType().ToList(); - var criteria2 = allCriteria.OfType().ToList(); - - criteria1.Count.Should().Be(1); - criteria1[0].SeasonNumber.Should().Be(5); - - criteria2.Count.Should().Be(1); - criteria2[0].SeasonNumber.Should().Be(6); - criteria2[0].EpisodeNumber.Should().Be(11); - } - - [Test] - public void scene_seasonsearch_should_use_seasonnumber_if_no_scene_number_is_available() - { - WithEpisodes(); - - var allCriteria = WatchForSearchCriteria(); - - Subject.SeasonSearch(_xemSeries.Id, 7, false, true); - - var criteria = allCriteria.OfType().ToList(); - - criteria.Count.Should().Be(1); - criteria[0].SeasonNumber.Should().Be(7); - } - - [Test] - public void season_search_for_anime_should_search_for_each_monitored_episode() - { - WithEpisodes(); - _xemSeries.SeriesType = SeriesTypes.Anime; - _xemEpisodes.ForEach(e => e.EpisodeFileId = 0); - - var seasonNumber = 1; - var allCriteria = WatchForSearchCriteria(); - - Subject.SeasonSearch(_xemSeries.Id, seasonNumber, true, true); - - var criteria = allCriteria.OfType().ToList(); - - criteria.Count.Should().Be(_xemEpisodes.Count(e => e.SeasonNumber == seasonNumber)); - } - - [Test] - public void season_search_for_anime_should_not_search_for_unmonitored_episodes() - { - WithEpisodes(); - _xemSeries.SeriesType = SeriesTypes.Anime; - _xemEpisodes.ForEach(e => e.Monitored = false); - _xemEpisodes.ForEach(e => e.EpisodeFileId = 0); - - var seasonNumber = 1; - var allCriteria = WatchForSearchCriteria(); - - Subject.SeasonSearch(_xemSeries.Id, seasonNumber, false, true); - - var criteria = allCriteria.OfType().ToList(); - - criteria.Count.Should().Be(0); - } - - [Test] - public void season_search_for_anime_should_not_search_for_episodes_with_files() - { - WithEpisodes(); - _xemSeries.SeriesType = SeriesTypes.Anime; - _xemEpisodes.ForEach(e => e.EpisodeFileId = 1); - - var seasonNumber = 1; - var allCriteria = WatchForSearchCriteria(); - - Subject.SeasonSearch(_xemSeries.Id, seasonNumber, true, true); - - var criteria = allCriteria.OfType().ToList(); - - criteria.Count.Should().Be(0); - } - - [Test] - public void getscenenames_should_use_seasonnumber_if_no_scene_seasonnumber_is_available() - { - WithEpisodes(); - - var allCriteria = WatchForSearchCriteria(); - - Subject.SeasonSearch(_xemSeries.Id, 7, false, true); - - Mocker.GetMock() - .Verify(v => v.GetSceneNames(_xemSeries.Id, It.Is>(l => l.Contains(7)), It.Is>(l => l.Contains(7))), Times.Once()); - } - } -} diff --git a/src/NzbDrone.Core.Test/IndexerSearchTests/SearchDefinitionFixture.cs b/src/NzbDrone.Core.Test/IndexerSearchTests/SearchDefinitionFixture.cs index 02c4db4bb..4e1f4db6d 100644 --- a/src/NzbDrone.Core.Test/IndexerSearchTests/SearchDefinitionFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerSearchTests/SearchDefinitionFixture.cs @@ -7,7 +7,7 @@ using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.IndexerSearchTests { - public class SearchDefinitionFixture : CoreTest + public class SearchDefinitionFixture : CoreTest { [TestCase("Betty White's Off Their Rockers", "Betty+Whites+Off+Their+Rockers")] [TestCase("Star Wars: The Clone Wars", "Star+Wars+The+Clone+Wars")] diff --git a/src/NzbDrone.Core.Test/IndexerSearchTests/SeriesSearchServiceFixture.cs b/src/NzbDrone.Core.Test/IndexerSearchTests/SeriesSearchServiceFixture.cs deleted file mode 100644 index 906a9f071..000000000 --- a/src/NzbDrone.Core.Test/IndexerSearchTests/SeriesSearchServiceFixture.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using FluentAssertions; -using Moq; -using NUnit.Framework; -using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Download; -using NzbDrone.Core.IndexerSearch; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Messaging.Commands; - -namespace NzbDrone.Core.Test.IndexerSearchTests -{ - [TestFixture] - public class SeriesSearchServiceFixture : CoreTest - { - private Series _series; - - [SetUp] - public void Setup() - { - _series = new Series - { - Id = 1, - Title = "Title", - Seasons = new List() - }; - - Mocker.GetMock() - .Setup(s => s.GetSeries(It.IsAny())) - .Returns(_series); - - Mocker.GetMock() - .Setup(s => s.SeasonSearch(_series.Id, It.IsAny(), false, true)) - .Returns(new List()); - - Mocker.GetMock() - .Setup(s => s.ProcessDecisions(It.IsAny>())) - .Returns(new ProcessedDecisions(new List(), new List(), new List())); - } - - [Test] - public void should_only_include_monitored_seasons() - { - _series.Seasons = new List - { - new Season { SeasonNumber = 0, Monitored = false }, - new Season { SeasonNumber = 1, Monitored = true } - }; - - Subject.Execute(new SeriesSearchCommand { SeriesId = _series.Id, Trigger = CommandTrigger.Manual }); - - Mocker.GetMock() - .Verify(v => v.SeasonSearch(_series.Id, It.IsAny(), false, true), Times.Exactly(_series.Seasons.Count(s => s.Monitored))); - } - - [Test] - public void should_start_with_lower_seasons_first() - { - var seasonOrder = new List(); - - _series.Seasons = new List - { - new Season { SeasonNumber = 3, Monitored = true }, - new Season { SeasonNumber = 1, Monitored = true }, - new Season { SeasonNumber = 2, Monitored = true } - }; - - Mocker.GetMock() - .Setup(s => s.SeasonSearch(_series.Id, It.IsAny(), false, true)) - .Returns(new List()) - .Callback((seriesId, seasonNumber, missingOnly, userInvokedSearch) => seasonOrder.Add(seasonNumber)); - - Subject.Execute(new SeriesSearchCommand { SeriesId = _series.Id, Trigger = CommandTrigger.Manual }); - - seasonOrder.First().Should().Be(_series.Seasons.OrderBy(s => s.SeasonNumber).First().SeasonNumber); - } - } -} diff --git a/src/NzbDrone.Core.Test/IndexerTests/IntegrationTests/IndexerIntegrationTests.cs b/src/NzbDrone.Core.Test/IndexerTests/IntegrationTests/IndexerIntegrationTests.cs index b9ae64a9b..2ac169b30 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/IntegrationTests/IndexerIntegrationTests.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/IntegrationTests/IndexerIntegrationTests.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using FluentAssertions; using NUnit.Framework; @@ -17,26 +17,17 @@ namespace NzbDrone.Core.Test.IndexerTests.IntegrationTests [Ignore("Nyaa is down!")] public class IndexerIntegrationTests : CoreTest { - private SingleEpisodeSearchCriteria _singleSearchCriteria; - private AnimeEpisodeSearchCriteria _animeSearchCriteria; + private MovieSearchCriteria _singleSearchCriteria; [SetUp] public void SetUp() { UseRealHttp(); - _singleSearchCriteria = new SingleEpisodeSearchCriteria() + _singleSearchCriteria = new MovieSearchCriteria() { SceneTitles = new List { "Person of Interest" }, - SeasonNumber = 1, - EpisodeNumber = 1 }; - - _animeSearchCriteria = new AnimeEpisodeSearchCriteria() - { - SceneTitles = new List { "Steins;Gate" }, - AbsoluteEpisodeNumber = 1 - }; } [Test] @@ -66,7 +57,7 @@ namespace NzbDrone.Core.Test.IndexerTests.IntegrationTests Settings = new NyaaSettings() }; - var result = indexer.Fetch(_animeSearchCriteria); + var result = indexer.Fetch(_singleSearchCriteria); ValidateTorrentResult(result, hasSize: true); } diff --git a/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabRequestGeneratorFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabRequestGeneratorFixture.cs index 0eccabc50..498a82ac0 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabRequestGeneratorFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabRequestGeneratorFixture.cs @@ -27,7 +27,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests _movieSearchCriteria = new MovieSearchCriteria { - Movie = new Tv.Movie { ImdbId = "tt0076759", Title = "Star Wars", Year = 1977 } + Movie = new Movies.Movie { ImdbId = "tt0076759", Title = "Star Wars", Year = 1977 } }; _capabilities = new NewznabCapabilities(); diff --git a/src/NzbDrone.Core.Test/IndexerTests/SeasonSearchFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/SeasonSearchFixture.cs deleted file mode 100644 index 075bb73e2..000000000 --- a/src/NzbDrone.Core.Test/IndexerTests/SeasonSearchFixture.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System.Collections.Generic; -using FizzWare.NBuilder; -using Moq; -using NUnit.Framework; -using NzbDrone.Common.Http; -using NzbDrone.Core.Indexers; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv; -using NzbDrone.Test.Common; - -namespace NzbDrone.Core.Test.IndexerTests -{ - [TestFixture] - public class SeasonSearchFixture : TestBase - { - private Series _series; - - [SetUp] - public void Setup() - { - _series = Builder.CreateNew().Build(); - - Mocker.GetMock() - .Setup(o => o.Execute(It.Is(v => v.Method == HttpMethod.GET))) - .Returns(r => new HttpResponse(r, new HttpHeader(), "")); - } - - private void WithIndexer(bool paging, int resultCount) - { - var definition = new IndexerDefinition(); - definition.Name = "Test"; - Subject.Definition = definition; - - Subject._supportedPageSize = paging ? 100 : 0; - - var requestGenerator = Mocker.GetMock(); - Subject._requestGenerator = requestGenerator.Object; - - var requests = Builder.CreateListOfSize(paging ? 100 : 1) - .All() - .WithConstructor(() => new IndexerRequest("http://my.feed.local/", HttpAccept.Rss)) - .With(v => v.HttpRequest.Method = HttpMethod.GET) - .Build(); - - var pageable = new IndexerPageableRequestChain(); - pageable.Add(requests); - - requestGenerator.Setup(s => s.GetSearchRequests(It.IsAny())) - .Returns(pageable); - - var parser = Mocker.GetMock(); - Subject._parser = parser.Object; - - var results = Builder.CreateListOfSize(resultCount) - .Build(); - - parser.Setup(s => s.ParseResponse(It.IsAny())) - .Returns(results); - } - - [Test] - public void should_not_use_offset_if_result_count_is_less_than_90() - { - WithIndexer(true, 25); - - Subject.Fetch(new SeasonSearchCriteria { Series = _series, SceneTitles = new List{_series.Title} }); - - Mocker.GetMock().Verify(v => v.Execute(It.IsAny()), Times.Once()); - } - - [Test] - public void should_not_use_offset_for_sites_that_do_not_support_it() - { - WithIndexer(false, 125); - - Subject.Fetch(new SeasonSearchCriteria { Series = _series, SceneTitles = new List { _series.Title } }); - - Mocker.GetMock().Verify(v => v.Execute(It.IsAny()), Times.Once()); - } - - [Test] - public void should_not_use_offset_if_its_already_tried_10_times() - { - WithIndexer(true, 100); - - Subject.Fetch(new SeasonSearchCriteria { Series = _series, SceneTitles = new List { _series.Title } }); - - Mocker.GetMock().Verify(v => v.Execute(It.IsAny()), Times.Exactly(10)); - } - } -} diff --git a/src/NzbDrone.Core.Test/InstrumentationTests/DatabaseTargetFixture.cs b/src/NzbDrone.Core.Test/InstrumentationTests/DatabaseTargetFixture.cs index ad614e646..098fd5f96 100644 --- a/src/NzbDrone.Core.Test/InstrumentationTests/DatabaseTargetFixture.cs +++ b/src/NzbDrone.Core.Test/InstrumentationTests/DatabaseTargetFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading; using FluentAssertions; using Marr.Data; @@ -118,7 +118,7 @@ namespace NzbDrone.Core.Test.InstrumentationTests [Test] public void null_string_as_arg_should_not_fail() { - var epFile = new EpisodeFile(); + var epFile = new MovieFile(); _logger.Debug("File {0} no longer exists on disk. removing from database.", epFile.RelativePath); Thread.Sleep(600); diff --git a/src/NzbDrone.Core.Test/MediaCoverTests/MediaCoverServiceFixture.cs b/src/NzbDrone.Core.Test/MediaCoverTests/MediaCoverServiceFixture.cs index 910c1eed9..bc559d548 100644 --- a/src/NzbDrone.Core.Test/MediaCoverTests/MediaCoverServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaCoverTests/MediaCoverServiceFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using FizzWare.NBuilder; @@ -9,22 +9,22 @@ using NzbDrone.Common.Disk; using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Core.MediaCover; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Tv.Events; +using NzbDrone.Core.Movies; +using NzbDrone.Core.Movies.Events; namespace NzbDrone.Core.Test.MediaCoverTests { [TestFixture] public class MediaCoverServiceFixture : CoreTest { - Series _series; + Movie _movie; [SetUp] public void Setup() { Mocker.SetConstant(new AppFolderInfo(Mocker.Resolve())); - _series = Builder.CreateNew() + _movie = Builder.CreateNew() .With(v => v.Id = 2) .With(v => v.Images = new List { new MediaCover.MediaCover(MediaCoverTypes.Poster, "") }) .Build(); @@ -76,7 +76,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests .Setup(v => v.FileExists(It.IsAny())) .Returns(true); - Subject.HandleAsync(new SeriesUpdatedEvent(_series)); + Subject.HandleAsync(new MovieUpdatedEvent(_movie)); Mocker.GetMock() .Verify(v => v.Resize(It.IsAny(), It.IsAny(), It.IsAny()), Times.Exactly(2)); @@ -93,7 +93,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests .Setup(v => v.FileExists(It.IsAny())) .Returns(false); - Subject.HandleAsync(new SeriesUpdatedEvent(_series)); + Subject.HandleAsync(new MovieUpdatedEvent(_movie)); Mocker.GetMock() .Verify(v => v.Resize(It.IsAny(), It.IsAny(), It.IsAny()), Times.Exactly(2)); @@ -114,7 +114,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests .Setup(v => v.GetFileSize(It.IsAny())) .Returns(1000); - Subject.HandleAsync(new SeriesUpdatedEvent(_series)); + Subject.HandleAsync(new MovieUpdatedEvent(_movie)); Mocker.GetMock() .Verify(v => v.Resize(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); @@ -135,7 +135,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests .Setup(v => v.GetFileSize(It.IsAny())) .Returns(0); - Subject.HandleAsync(new SeriesUpdatedEvent(_series)); + Subject.HandleAsync(new MovieUpdatedEvent(_movie)); Mocker.GetMock() .Verify(v => v.Resize(It.IsAny(), It.IsAny(), It.IsAny()), Times.Exactly(2)); @@ -156,10 +156,10 @@ namespace NzbDrone.Core.Test.MediaCoverTests .Setup(v => v.Resize(It.IsAny(), It.IsAny(), It.IsAny())) .Throws(); - Subject.HandleAsync(new SeriesUpdatedEvent(_series)); + Subject.HandleAsync(new MovieUpdatedEvent(_movie)); Mocker.GetMock() .Verify(v => v.Resize(It.IsAny(), It.IsAny(), It.IsAny()), Times.Exactly(2)); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs index 5bb18e455..478d7d1ef 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Linq; using FizzWare.NBuilder; @@ -6,9 +6,9 @@ using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.MediaFiles.EpisodeImport; +using NzbDrone.Core.MediaFiles.MovieImport; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests @@ -16,13 +16,13 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests [TestFixture] public class ScanFixture : CoreTest { - private Series _series; + private Movie _movie; [SetUp] public void Setup() { - _series = Builder.CreateNew() - .With(s => s.Path = @"C:\Test\TV\Series".AsOsAgnostic()) + _movie = Builder.CreateNew() + .With(s => s.Path = @"C:\Test\Movies\Movie".AsOsAgnostic()) .Build(); Mocker.GetMock() @@ -38,7 +38,7 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests Mocker.GetMock() .Setup(s => s.GetDirectories(It.IsAny())) - .Returns(new string[] { @"C:\Test\TV\Series2".AsOsAgnostic() }); + .Returns(new string[] { @"C:\Test\Movies\Movie2".AsOsAgnostic() }); } private void GivenFiles(IEnumerable files) @@ -49,18 +49,18 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests } [Test] - public void should_not_scan_if_series_root_folder_does_not_exist() + public void should_not_scan_if_movie_root_folder_does_not_exist() { - Subject.Scan(_series); + Subject.Scan(_movie); ExceptionVerification.ExpectedWarns(1); Mocker.GetMock() - .Verify(v => v.Clean(It.IsAny(), It.IsAny>()), Times.Never()); + .Verify(v => v.Clean(It.IsAny(), It.IsAny>()), Times.Never()); } [Test] - public void should_not_scan_if_series_root_folder_is_empty() + public void should_not_scan_if_movie_root_folder_is_empty() { Mocker.GetMock() .Setup(s => s.FolderExists(It.IsAny())) @@ -70,12 +70,12 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests .Setup(s => s.GetDirectories(It.IsAny())) .Returns(new string[0]); - Subject.Scan(_series); + Subject.Scan(_movie); ExceptionVerification.ExpectedWarns(1); Mocker.GetMock() - .Verify(v => v.Clean(It.IsAny(), new List()), Times.Never()); + .Verify(v => v.Clean(It.IsAny(), new List()), Times.Never()); } [Test] @@ -85,17 +85,17 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests GivenFiles(new List { - Path.Combine(_series.Path, "EXTRAS", "file1.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, "Extras", "file2.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, "EXTRAs", "file3.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, "ExTrAs", "file4.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic() + Path.Combine(_movie.Path, "EXTRAS", "file1.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, "Extras", "file2.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, "EXTRAs", "file3.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, "ExTrAs", "file4.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, "Season 1", "s01e01.mkv").AsOsAgnostic() }); - Subject.Scan(_series); + Subject.Scan(_movie); Mocker.GetMock() - .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 1), _series), Times.Once()); + .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 1), _movie), Times.Once()); } [Test] @@ -105,37 +105,37 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests GivenFiles(new List { - Path.Combine(_series.Path, ".AppleDouble", "file1.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, ".appledouble", "file2.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic() + Path.Combine(_movie.Path, ".AppleDouble", "file1.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, ".appledouble", "file2.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, "Season 1", "s01e01.mkv").AsOsAgnostic() }); - Subject.Scan(_series); + Subject.Scan(_movie); Mocker.GetMock() - .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 1), _series), Times.Once()); + .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 1), _movie), Times.Once()); } [Test] - public void should_scan_extras_series_and_subfolders() + public void should_scan_extras_movie_and_subfolders() { GivenParentFolderExists(); - _series.Path = @"C:\Test\TV\Extras".AsOsAgnostic(); + _movie.Path = @"C:\Test\Movies\Extras".AsOsAgnostic(); GivenFiles(new List { - Path.Combine(_series.Path, "Extras", "file1.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, ".AppleDouble", "file2.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, "Season 1", "s01e02.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, "Season 2", "s02e01.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, "Season 2", "s02e02.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, "Extras", "file1.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, ".AppleDouble", "file2.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, "Season 1", "s01e01.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, "Season 1", "s01e02.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, "Season 2", "s02e01.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, "Season 2", "s02e02.mkv").AsOsAgnostic(), }); - Subject.Scan(_series); + Subject.Scan(_movie); Mocker.GetMock() - .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 4), _series), Times.Once()); + .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 4), _movie), Times.Once()); } [Test] @@ -145,16 +145,16 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests GivenFiles(new List { - Path.Combine(_series.Path, ".@__thumb", "file1.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, ".@__THUMB", "file2.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, ".hidden", "file2.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic() + Path.Combine(_movie.Path, ".@__thumb", "file1.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, ".@__THUMB", "file2.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, ".hidden", "file2.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, "Season 1", "s01e01.mkv").AsOsAgnostic() }); - Subject.Scan(_series); + Subject.Scan(_movie); Mocker.GetMock() - .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 1), _series), Times.Once()); + .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 1), _movie), Times.Once()); } [Test] @@ -164,17 +164,17 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests GivenFiles(new List { - Path.Combine(_series.Path, "Season 1", ".@__thumb", "file1.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, "Season 1", ".@__THUMB", "file2.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, "Season 1", ".hidden", "file2.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, "Season 1", ".AppleDouble", "s01e01.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic() + Path.Combine(_movie.Path, "Season 1", ".@__thumb", "file1.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, "Season 1", ".@__THUMB", "file2.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, "Season 1", ".hidden", "file2.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, "Season 1", ".AppleDouble", "s01e01.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, "Season 1", "s01e01.mkv").AsOsAgnostic() }); - Subject.Scan(_series); + Subject.Scan(_movie); Mocker.GetMock() - .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 1), _series), Times.Once()); + .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 1), _movie), Times.Once()); } [Test] @@ -184,14 +184,14 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests GivenFiles(new List { - Path.Combine(_series.Path, "@eaDir", "file1.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic() + Path.Combine(_movie.Path, "@eaDir", "file1.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, "Season 1", "s01e01.mkv").AsOsAgnostic() }); - Subject.Scan(_series); + Subject.Scan(_movie); Mocker.GetMock() - .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 1), _series), Times.Once()); + .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 1), _movie), Times.Once()); } [Test] @@ -201,32 +201,32 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests GivenFiles(new List { - Path.Combine(_series.Path, ".@__thumb", "file1.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic() + Path.Combine(_movie.Path, ".@__thumb", "file1.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, "Season 1", "s01e01.mkv").AsOsAgnostic() }); - Subject.Scan(_series); + Subject.Scan(_movie); Mocker.GetMock() - .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 1), _series), Times.Once()); + .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 1), _movie), Times.Once()); } [Test] public void should_scan_dotHack_folder() { GivenParentFolderExists(); - _series.Path = @"C:\Test\TV\.hack".AsOsAgnostic(); + _movie.Path = @"C:\Test\TV\.hack".AsOsAgnostic(); GivenFiles(new List { - Path.Combine(_series.Path, "Season 1", "file1.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic() + Path.Combine(_movie.Path, "Season 1", "file1.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, "Season 1", "s01e01.mkv").AsOsAgnostic() }); - Subject.Scan(_series); + Subject.Scan(_movie); Mocker.GetMock() - .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 2), _series), Times.Once()); + .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 2), _movie), Times.Once()); } [Test] @@ -236,14 +236,14 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests GivenFiles(new List { - Path.Combine(_series.Path, "file1.mkv").AsOsAgnostic(), - Path.Combine(_series.Path, "s01e01.mkv").AsOsAgnostic() + Path.Combine(_movie.Path, "file1.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, "s01e01.mkv").AsOsAgnostic() }); - Subject.Scan(_series); + Subject.Scan(_movie); Mocker.GetMock() - .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 2), _series), Times.Once()); + .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 2), _movie), Times.Once()); } [Test] @@ -253,14 +253,14 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests GivenFiles(new List { - Path.Combine(_series.Path, "._24 The Status Quo Combustion.mp4").AsOsAgnostic(), - Path.Combine(_series.Path, "24 The Status Quo Combustion.mkv").AsOsAgnostic() + Path.Combine(_movie.Path, "._24 The Status Quo Combustion.mp4").AsOsAgnostic(), + Path.Combine(_movie.Path, "24 The Status Quo Combustion.mkv").AsOsAgnostic() }); - Subject.Scan(_series); + Subject.Scan(_movie); Mocker.GetMock() - .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 1), _series), Times.Once()); + .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 1), _movie), Times.Once()); } } } diff --git a/src/NzbDrone.Core.Test/MediaFiles/DownloadedMoviesCommandServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/DownloadedMoviesCommandServiceFixture.cs index 21919839c..82bf68495 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/DownloadedMoviesCommandServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/DownloadedMoviesCommandServiceFixture.cs @@ -9,10 +9,10 @@ using NzbDrone.Core.Download; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Commands; -using NzbDrone.Core.MediaFiles.EpisodeImport; +using NzbDrone.Core.MediaFiles.MovieImport; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MediaFiles diff --git a/src/NzbDrone.Core.Test/MediaFiles/DownloadedMoviesImportServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/DownloadedMoviesImportServiceFixture.cs index d05c5b58c..c9028effe 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/DownloadedMoviesImportServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/DownloadedMoviesImportServiceFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Linq; using FizzWare.NBuilder; @@ -6,12 +6,12 @@ using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.MediaFiles.EpisodeImport; +using NzbDrone.Core.MediaFiles.MovieImport; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; using FluentAssertions; using NzbDrone.Core.Download; @@ -341,7 +341,7 @@ namespace NzbDrone.Core.Test.MediaFiles .Setup(s => s.GetImportDecisions(It.IsAny>(), It.IsAny(), It.IsAny(), null, true)) .Returns(imported); - Mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Import(It.IsAny>(), true, null, ImportMode.Auto)) .Returns(new List()); @@ -365,13 +365,13 @@ namespace NzbDrone.Core.Test.MediaFiles 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/EpisodeFileMovingServiceTests/MoveEpisodeFileFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/EpisodeFileMovingServiceTests/MoveEpisodeFileFixture.cs index 595a19dd4..de34f7f30 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/EpisodeFileMovingServiceTests/MoveEpisodeFileFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/EpisodeFileMovingServiceTests/MoveEpisodeFileFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using FizzWare.NBuilder; @@ -12,47 +12,42 @@ using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Organizer; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MediaFiles.EpisodeFileMovingServiceTests { [TestFixture] - public class MoveEpisodeFileFixture : CoreTest + public class MoveEpisodeFileFixture : CoreTest { - private Series _series; - private EpisodeFile _episodeFile; - private LocalEpisode _localEpisode; + private Movie _series; + private MovieFile _episodeFile; + private LocalMovie _localEpisode; [SetUp] public void Setup() { - _series = Builder.CreateNew() + _series = Builder.CreateNew() .With(s => s.Path = @"C:\Test\TV\Series".AsOsAgnostic()) .Build(); - _episodeFile = Builder.CreateNew() + _episodeFile = Builder.CreateNew() .With(f => f.Path = null) .With(f => f.RelativePath = @"Season 1\File.avi") .Build(); - _localEpisode = Builder.CreateNew() - .With(l => l.Series = _series) - .With(l => l.Episodes = Builder.CreateListOfSize(1).Build().ToList()) + _localEpisode = Builder.CreateNew() + .With(l => l.Movie = _series) .Build(); Mocker.GetMock() - .Setup(s => s.BuildFileName(It.IsAny>(), It.IsAny(), It.IsAny(), null)) + .Setup(s => s.BuildFileName(It.IsAny(), It.IsAny(), null)) .Returns("File Name"); Mocker.GetMock() - .Setup(s => s.BuildFilePath(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) + .Setup(s => s.BuildFilePath(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(@"C:\Test\TV\Series\Season 01\File Name.avi".AsOsAgnostic()); - Mocker.GetMock() - .Setup(s => s.BuildSeasonPath(It.IsAny(), It.IsAny())) - .Returns(@"C:\Test\TV\Series\Season 01".AsOsAgnostic()); - var rootFolder = @"C:\Test\TV\".AsOsAgnostic(); Mocker.GetMock() .Setup(s => s.FolderExists(rootFolder)) @@ -72,7 +67,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeFileMovingServiceTests .Setup(s => s.InheritFolderPermissions(It.IsAny())) .Throws(); - Subject.MoveEpisodeFile(_episodeFile, _localEpisode); + Subject.MoveMovieFile(_episodeFile, _localEpisode); } [Test] @@ -84,29 +79,19 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeFileMovingServiceTests .Setup(s => s.InheritFolderPermissions(It.IsAny())) .Throws(); - Subject.MoveEpisodeFile(_episodeFile, _localEpisode); + Subject.MoveMovieFile(_episodeFile, _localEpisode); } [Test] public void should_notify_on_series_folder_creation() { - Subject.MoveEpisodeFile(_episodeFile, _localEpisode); + Subject.MoveMovieFile(_episodeFile, _localEpisode); Mocker.GetMock() - .Verify(s => s.PublishEvent(It.Is(p => + .Verify(s => s.PublishEvent(It.Is(p => p.SeriesFolder.IsNotNullOrWhiteSpace())), Times.Once()); } - [Test] - public void should_notify_on_season_folder_creation() - { - Subject.MoveEpisodeFile(_episodeFile, _localEpisode); - - Mocker.GetMock() - .Verify(s => s.PublishEvent(It.Is(p => - p.SeasonFolder.IsNotNullOrWhiteSpace())), Times.Once()); - } - [Test] public void should_not_notify_if_series_folder_already_exists() { @@ -114,10 +99,10 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeFileMovingServiceTests .Setup(s => s.FolderExists(_series.Path)) .Returns(true); - Subject.MoveEpisodeFile(_episodeFile, _localEpisode); + Subject.MoveMovieFile(_episodeFile, _localEpisode); Mocker.GetMock() - .Verify(s => s.PublishEvent(It.Is(p => + .Verify(s => s.PublishEvent(It.Is(p => p.SeriesFolder.IsNotNullOrWhiteSpace())), Times.Never()); } } diff --git a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/FullSeasonSpecificationFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/FullSeasonSpecificationFixture.cs deleted file mode 100644 index d8dced788..000000000 --- a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/FullSeasonSpecificationFixture.cs +++ /dev/null @@ -1,46 +0,0 @@ -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications; -using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; -using NzbDrone.Test.Common; - -namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications -{ - [TestFixture] - public class FullSeasonSpecificationFixture : CoreTest - { - private LocalEpisode _localEpisode; - - [SetUp] - public void Setup() - { - _localEpisode = new LocalEpisode - { - Path = @"C:\Test\30 Rock\30.rock.s01e01.avi".AsOsAgnostic(), - Size = 100, - Series = Builder.CreateNew().Build(), - ParsedEpisodeInfo = new ParsedEpisodeInfo - { - FullSeason = false - } - }; - } - - [Test] - public void should_return_false_when_file_contains_the_full_season() - { - _localEpisode.ParsedEpisodeInfo.FullSeason = true; - - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeFalse(); - } - - [Test] - public void should_return_true_when_file_does_not_contain_the_full_season() - { - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue(); - } - } -} diff --git a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecificationFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecificationFixture.cs deleted file mode 100644 index 71ff631a1..000000000 --- a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecificationFixture.cs +++ /dev/null @@ -1,84 +0,0 @@ -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications; -using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Test.Common; - -namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications -{ - [TestFixture] - public class MatchesFolderSpecificationFixture : CoreTest - { - private LocalEpisode _localEpisode; - - [SetUp] - public void Setup() - { - _localEpisode = Builder.CreateNew() - .With(l => l.Path = @"C:\Test\Unsorted\Series.Title.S01E01.720p.HDTV-Sonarr\S01E05.mkv".AsOsAgnostic()) - .With(l => l.ParsedEpisodeInfo = - Builder.CreateNew() - .With(p => p.EpisodeNumbers = new[] {5}) - .With(p => p.FullSeason = false) - .Build()) - .Build(); - } - - [Test] - public void should_be_accepted_for_existing_file() - { - _localEpisode.ExistingFile = true; - - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue(); - } - - [Test] - public void should_be_accepted_if_folder_name_is_not_parseable() - { - _localEpisode.Path = @"C:\Test\Unsorted\Series.Title\S01E01.mkv".AsOsAgnostic(); - - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue(); - } - - [Test] - public void should_should_be_accepted_for_full_season() - { - _localEpisode.Path = @"C:\Test\Unsorted\Series.Title.S01\S01E01.mkv".AsOsAgnostic(); - - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue(); - } - - [Test] - public void should_be_accepted_if_file_and_folder_have_the_same_episode() - { - _localEpisode.ParsedEpisodeInfo.EpisodeNumbers = new[] { 1 }; - _localEpisode.Path = @"C:\Test\Unsorted\Series.Title.S01E01.720p.HDTV-Sonarr\S01E01.mkv".AsOsAgnostic(); - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue(); - } - - [Test] - public void should_be_accepted_if_file_is_one_episode_in_folder() - { - _localEpisode.ParsedEpisodeInfo.EpisodeNumbers = new[] { 1 }; - _localEpisode.Path = @"C:\Test\Unsorted\Series.Title.S01E01E02.720p.HDTV-Sonarr\S01E01.mkv".AsOsAgnostic(); - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue(); - } - - [Test] - public void should_be_rejected_if_file_and_folder_do_not_have_same_episode() - { - _localEpisode.Path = @"C:\Test\Unsorted\Series.Title.S01E01.720p.HDTV-Sonarr\S01E05.mkv".AsOsAgnostic(); - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeFalse(); - } - - [Test] - public void should_be_rejected_if_file_and_folder_do_not_have_same_episodes() - { - _localEpisode.ParsedEpisodeInfo.EpisodeNumbers = new[] { 5, 6 }; - _localEpisode.Path = @"C:\Test\Unsorted\Series.Title.S01E01E02.720p.HDTV-Sonarr\S01E05E06.mkv".AsOsAgnostic(); - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeFalse(); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/NotSampleSpecificationFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/NotSampleSpecificationFixture.cs deleted file mode 100644 index 1f3492205..000000000 --- a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/NotSampleSpecificationFixture.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications; -using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Qualities; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications -{ - [TestFixture] - public class NotSampleSpecificationFixture : CoreTest - { - private Series _series; - private LocalEpisode _localEpisode; - - [SetUp] - public void Setup() - { - _series = Builder.CreateNew() - .With(s => s.SeriesType = SeriesTypes.Standard) - .Build(); - - var episodes = Builder.CreateListOfSize(1) - .All() - .With(e => e.SeasonNumber = 1) - .Build() - .ToList(); - - _localEpisode = new LocalEpisode - { - Path = @"C:\Test\30 Rock\30.rock.s01e01.avi", - Episodes = episodes, - Series = _series, - Quality = new QualityModel(Quality.HDTV720p) - }; - } - - [Test] - public void should_return_true_for_existing_file() - { - _localEpisode.ExistingFile = true; - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue(); - } - } -} diff --git a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/UpgradeSpecificationFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/UpgradeSpecificationFixture.cs deleted file mode 100644 index f55cdcce2..000000000 --- a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/UpgradeSpecificationFixture.cs +++ /dev/null @@ -1,156 +0,0 @@ -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using Marr.Data; -using NUnit.Framework; -using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications; -using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Profiles; -using NzbDrone.Core.Qualities; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications -{ - [TestFixture] - public class UpgradeSpecificationFixture : CoreTest - { - private Series _series; - private LocalEpisode _localEpisode; - - [SetUp] - public void Setup() - { - _series = Builder.CreateNew() - .With(s => s.SeriesType = SeriesTypes.Standard) - .With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() }) - .Build(); - - _localEpisode = new LocalEpisode - { - Path = @"C:\Test\30 Rock\30.rock.s01e01.avi", - Quality = new QualityModel(Quality.HDTV720p, new Revision(version: 1)), - Series = _series - }; - } - - [Test] - public void should_return_true_if_no_existing_episodeFile() - { - _localEpisode.Episodes = Builder.CreateListOfSize(1) - .All() - .With(e => e.EpisodeFileId = 0) - .With(e => e.EpisodeFile = null) - .Build() - .ToList(); - - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue(); - } - - [Test] - public void should_return_true_if_no_existing_episodeFile_for_multi_episodes() - { - _localEpisode.Episodes = Builder.CreateListOfSize(2) - .All() - .With(e => e.EpisodeFileId = 0) - .With(e => e.EpisodeFile = null) - .Build() - .ToList(); - - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue(); - } - - [Test] - public void should_return_true_if_upgrade_for_existing_episodeFile() - { - _localEpisode.Episodes = Builder.CreateListOfSize(1) - .All() - .With(e => e.EpisodeFileId = 1) - .With(e => e.EpisodeFile = new LazyLoaded( - new EpisodeFile - { - Quality = new QualityModel(Quality.SDTV, new Revision(version: 1)) - })) - .Build() - .ToList(); - - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue(); - } - - [Test] - public void should_return_true_if_upgrade_for_existing_episodeFile_for_multi_episodes() - { - _localEpisode.Episodes = Builder.CreateListOfSize(2) - .All() - .With(e => e.EpisodeFileId = 1) - .With(e => e.EpisodeFile = new LazyLoaded( - new EpisodeFile - { - Quality = new QualityModel(Quality.SDTV, new Revision(version: 1)) - })) - .Build() - .ToList(); - - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue(); - } - - [Test] - public void should_return_false_if_not_an_upgrade_for_existing_episodeFile() - { - _localEpisode.Episodes = Builder.CreateListOfSize(1) - .All() - .With(e => e.EpisodeFileId = 1) - .With(e => e.EpisodeFile = new LazyLoaded( - new EpisodeFile - { - Quality = new QualityModel(Quality.Bluray720p, new Revision(version: 1)) - })) - .Build() - .ToList(); - - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeFalse(); - } - - [Test] - public void should_return_false_if_not_an_upgrade_for_existing_episodeFile_for_multi_episodes() - { - _localEpisode.Episodes = Builder.CreateListOfSize(2) - .All() - .With(e => e.EpisodeFileId = 1) - .With(e => e.EpisodeFile = new LazyLoaded( - new EpisodeFile - { - Quality = new QualityModel(Quality.Bluray720p, new Revision(version: 1)) - })) - .Build() - .ToList(); - - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeFalse(); - } - - [Test] - public void should_return_false_if_not_an_upgrade_for_one_existing_episodeFile_for_multi_episode() - { - _localEpisode.Episodes = Builder.CreateListOfSize(2) - .TheFirst(1) - .With(e => e.EpisodeFileId = 1) - .With(e => e.EpisodeFile = new LazyLoaded( - new EpisodeFile - { - Quality = new QualityModel(Quality.SDTV, new Revision(version: 1)) - })) - .TheNext(1) - .With(e => e.EpisodeFileId = 2) - .With(e => e.EpisodeFile = new LazyLoaded( - new EpisodeFile - { - Quality = new QualityModel(Quality.Bluray720p, new Revision(version: 1)) - })) - .Build() - .ToList(); - - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeFalse(); - } - } -} diff --git a/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedEpisodesFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedEpisodesFixture.cs index fcecfa000..2b7440e90 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedEpisodesFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedEpisodesFixture.cs @@ -8,21 +8,21 @@ using NUnit.Framework; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.MediaFiles.EpisodeImport; +using NzbDrone.Core.MediaFiles.MovieImport; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MediaFiles { [TestFixture] - //TODO: Update all of this for movies. - public class ImportApprovedEpisodesFixture : CoreTest + //TODO: Update all of this for movies. + public class ImportApprovedEpisodesFixture : CoreTest { private List _rejectedDecisions; private List _approvedDecisions; @@ -35,40 +35,32 @@ namespace NzbDrone.Core.Test.MediaFiles _rejectedDecisions = new List(); _approvedDecisions = new List(); - var series = Builder.CreateNew() - .With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() }) - .With(s => s.Path = @"C:\Test\TV\30 Rock".AsOsAgnostic()) - .Build(); - - var episodes = Builder.CreateListOfSize(5) - .Build(); - - - - _rejectedDecisions.Add(new ImportDecision(new LocalEpisode(), new Rejection("Rejected!"))); - _rejectedDecisions.Add(new ImportDecision(new LocalEpisode(), new Rejection("Rejected!"))); - _rejectedDecisions.Add(new ImportDecision(new LocalEpisode(), new Rejection("Rejected!"))); - - foreach (var episode in episodes) - { - _approvedDecisions.Add(new ImportDecision - ( - new LocalEpisode - { - Series = series, - Episodes = new List { episode }, - Path = Path.Combine(series.Path, "30 Rock - S01E01 - Pilot.avi"), - Quality = new QualityModel(Quality.Bluray720p), - ParsedEpisodeInfo = new ParsedEpisodeInfo - { - ReleaseGroup = "DRONE" - } - })); - } + var movie = Builder.CreateNew() + .With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() }) + .With(s => s.Path = @"C:\Test\TV\30 Rock".AsOsAgnostic()) + .Build(); + + _rejectedDecisions.Add(new ImportDecision(new LocalMovie(), new Rejection("Rejected!"))); + _rejectedDecisions.Add(new ImportDecision(new LocalMovie(), new Rejection("Rejected!"))); + _rejectedDecisions.Add(new ImportDecision(new LocalMovie(), new Rejection("Rejected!"))); + + _approvedDecisions.Add(new ImportDecision + ( + new LocalMovie + { + Movie = movie, + Path = Path.Combine(movie.Path, "30 Rock - S01E01 - Pilot.avi"), + Quality = new QualityModel(Quality.Bluray720p), + ParsedMovieInfo = new ParsedMovieInfo() + { + ReleaseGroup = "DRONE" + } + })); + Mocker.GetMock() - .Setup(s => s.UpgradeEpisodeFile(It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(new EpisodeFileMoveResult()); + .Setup(s => s.UpgradeMovieFile(It.IsAny(), It.IsAny(), It.IsAny())) + .Returns(new MovieFileMoveResult()); _downloadClientItem = Builder.CreateNew().Build(); } @@ -78,7 +70,7 @@ namespace NzbDrone.Core.Test.MediaFiles { Subject.Import(_rejectedDecisions, false).Where(i => i.Result == ImportResultType.Imported).Should().BeEmpty(); - Mocker.GetMock().Verify(v => v.Add(It.IsAny()), Times.Never()); + Mocker.GetMock().Verify(v => v.Add(It.IsAny()), Times.Never()); } [Test] @@ -105,7 +97,7 @@ namespace NzbDrone.Core.Test.MediaFiles { var all = new List(); all.AddRange(_approvedDecisions); - all.Add(new ImportDecision(_approvedDecisions.First().LocalEpisode)); + all.Add(new ImportDecision(_approvedDecisions.First().LocalMovie)); var result = Subject.Import(all, false); @@ -118,7 +110,7 @@ namespace NzbDrone.Core.Test.MediaFiles Subject.Import(new List { _approvedDecisions.First() }, true); Mocker.GetMock() - .Verify(v => v.UpgradeEpisodeFile(It.IsAny(), _approvedDecisions.First().LocalEpisode, false), + .Verify(v => v.UpgradeMovieFile(It.IsAny(), _approvedDecisions.First().LocalMovie, false), Times.Once()); } @@ -128,7 +120,7 @@ namespace NzbDrone.Core.Test.MediaFiles Subject.Import(new List { _approvedDecisions.First() }, true); Mocker.GetMock() - .Verify(v => v.PublishEvent(It.IsAny()), Times.Once()); + .Verify(v => v.PublishEvent(It.IsAny()), Times.Once()); } [Test] @@ -137,7 +129,7 @@ namespace NzbDrone.Core.Test.MediaFiles Subject.Import(new List { _approvedDecisions.First() }, false); Mocker.GetMock() - .Verify(v => v.UpgradeEpisodeFile(It.IsAny(), _approvedDecisions.First().LocalEpisode, false), + .Verify(v => v.UpgradeMovieFile(It.IsAny(), _approvedDecisions.First().LocalMovie, false), Times.Never()); } @@ -148,7 +140,7 @@ namespace NzbDrone.Core.Test.MediaFiles Subject.Import(new List { _approvedDecisions.First() }, true, _downloadClientItem); - Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.SceneName == _downloadClientItem.Title))); + Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.SceneName == _downloadClientItem.Title))); } [TestCase(".mkv")] @@ -162,57 +154,56 @@ namespace NzbDrone.Core.Test.MediaFiles Subject.Import(new List { _approvedDecisions.First() }, true, _downloadClientItem); - Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.SceneName == title))); + Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.SceneName == title))); } [Test] - [Ignore("Series")] + [Ignore("Series")] public void should_not_use_nzb_title_as_scene_name_if_full_season() { - _approvedDecisions.First().LocalEpisode.Path = "c:\\tv\\season1\\malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot.mkv".AsOsAgnostic(); + _approvedDecisions.First().LocalMovie.Path = "c:\\tv\\season1\\malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot.mkv".AsOsAgnostic(); _downloadClientItem.Title = "malcolm.in.the.middle.s02.dvdrip.xvid-ingot"; Subject.Import(new List { _approvedDecisions.First() }, true, _downloadClientItem); - Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.SceneName == "malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot"))); + Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.SceneName == "malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot"))); } [Test] - [Ignore("Series")] + [Ignore("Series")] public void should_use_file_name_as_scenename_only_if_it_looks_like_scenename() { - _approvedDecisions.First().LocalEpisode.Path = "c:\\tv\\malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot.mkv".AsOsAgnostic(); + _approvedDecisions.First().LocalMovie.Path = "c:\\tv\\malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot.mkv".AsOsAgnostic(); Subject.Import(new List { _approvedDecisions.First() }, true); - Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.SceneName == "malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot"))); + Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.SceneName == "malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot"))); } [Test] public void should_not_use_file_name_as_scenename_if_it_doesnt_looks_like_scenename() { - _approvedDecisions.First().LocalEpisode.Path = "c:\\tv\\aaaaa.mkv".AsOsAgnostic(); + _approvedDecisions.First().LocalMovie.Path = "c:\\tv\\aaaaa.mkv".AsOsAgnostic(); Subject.Import(new List { _approvedDecisions.First() }, true); - Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.SceneName == null))); + Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.SceneName == null))); } [Test] public void should_import_larger_files_first() { var fileDecision = _approvedDecisions.First(); - fileDecision.LocalEpisode.Size = 1.Gigabytes(); + fileDecision.LocalMovie.Size = 1.Gigabytes(); var sampleDecision = new ImportDecision - (new LocalEpisode - { - Series = fileDecision.LocalEpisode.Series, - Episodes = new List { fileDecision.LocalEpisode.Episodes.First() }, - Path = @"C:\Test\TV\30 Rock\30 Rock - S01E01 - Pilot.avi".AsOsAgnostic(), - Quality = new QualityModel(Quality.Bluray720p), - Size = 80.Megabytes() - }); + (new LocalMovie + { + Movie = fileDecision.LocalMovie.Movie, + Path = @"C:\Test\TV\30 Rock\30 Rock - S01E01 - Pilot.avi".AsOsAgnostic(), + Quality = new QualityModel(Quality.Bluray720p), + Size = 80.Megabytes() + }); var all = new List(); @@ -223,7 +214,7 @@ namespace NzbDrone.Core.Test.MediaFiles results.Should().HaveCount(all.Count); results.Should().ContainSingle(d => d.Result == ImportResultType.Imported); - results.Should().ContainSingle(d => d.Result == ImportResultType.Imported && d.ImportDecision.LocalEpisode.Size == fileDecision.LocalEpisode.Size); + results.Should().ContainSingle(d => d.Result == ImportResultType.Imported && d.ImportDecision.LocalMovie.Size == fileDecision.LocalMovie.Size); } [Test] @@ -232,7 +223,7 @@ namespace NzbDrone.Core.Test.MediaFiles Subject.Import(new List { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "30.Rock.S01E01", IsReadOnly = true }); Mocker.GetMock() - .Verify(v => v.UpgradeEpisodeFile(It.IsAny(), _approvedDecisions.First().LocalEpisode, true), Times.Once()); + .Verify(v => v.UpgradeMovieFile(It.IsAny(), _approvedDecisions.First().LocalMovie, true), Times.Once()); } [Test] @@ -241,7 +232,7 @@ namespace NzbDrone.Core.Test.MediaFiles Subject.Import(new List { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "30.Rock.S01E01", IsReadOnly = true }, ImportMode.Move); Mocker.GetMock() - .Verify(v => v.UpgradeEpisodeFile(It.IsAny(), _approvedDecisions.First().LocalEpisode, false), Times.Once()); + .Verify(v => v.UpgradeMovieFile(It.IsAny(), _approvedDecisions.First().LocalMovie, false), Times.Once()); } } } diff --git a/src/NzbDrone.Core.Test/MediaFiles/MediaFileRepositoryFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MediaFileRepositoryFixture.cs index ace441e7b..d944b88cf 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/MediaFileRepositoryFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MediaFileRepositoryFixture.cs @@ -8,27 +8,27 @@ using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.MediaFiles { [TestFixture] - public class MediaFileRepositoryFixture : DbTest + public class MediaFileRepositoryFixture : DbTest { [Test] public void get_files_by_series() { - var files = Builder.CreateListOfSize(10) + var files = Builder.CreateListOfSize(10) .All() .With(c => c.Id = 0) .With(c => c.Quality =new QualityModel(Quality.Bluray720p)) .Random(4) - .With(s => s.SeriesId = 12) + .With(s => s.MovieId = 12) .BuildListOfNew(); Db.InsertMany(files); - var seriesFiles = Subject.GetFilesBySeries(12); + var seriesFiles = Subject.GetFilesByMovie(12); seriesFiles.Should().HaveCount(4); - seriesFiles.Should().OnlyContain(c => c.SeriesId == 12); + seriesFiles.Should().OnlyContain(c => c.MovieId == 12); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core.Test/MediaFiles/MediaFileServiceTests/FilterFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MediaFileServiceTests/FilterFixture.cs index 172d0c571..d74e53528 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/MediaFileServiceTests/FilterFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MediaFileServiceTests/FilterFixture.cs @@ -6,7 +6,7 @@ using Moq; using NUnit.Framework; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests @@ -14,12 +14,12 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests [TestFixture] public class FilterFixture : CoreTest { - private Series _series; + private Movie _series; [SetUp] public void Setup() { - _series = new Series + _series = new Movie { Id = 10, Path = @"C:\".AsOsAgnostic() @@ -37,8 +37,8 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests }; Mocker.GetMock() - .Setup(c => c.GetFilesBySeries(It.IsAny())) - .Returns(new List()); + .Setup(c => c.GetFilesByMovie(It.IsAny())) + .Returns(new List()); Subject.FilterExistingFiles(files, _series).Should().BeEquivalentTo(files); @@ -55,8 +55,8 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests }; Mocker.GetMock() - .Setup(c => c.GetFilesBySeries(It.IsAny())) - .Returns(files.Select(f => new EpisodeFile { RelativePath = Path.GetFileName(f) }).ToList()); + .Setup(c => c.GetFilesByMovie(It.IsAny())) + .Returns(files.Select(f => new MovieFile { RelativePath = Path.GetFileName(f) }).ToList()); Subject.FilterExistingFiles(files, _series).Should().BeEmpty(); @@ -73,10 +73,10 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests }; Mocker.GetMock() - .Setup(c => c.GetFilesBySeries(It.IsAny())) - .Returns(new List + .Setup(c => c.GetFilesByMovie(It.IsAny())) + .Returns(new List { - new EpisodeFile{ RelativePath = "file2.avi".AsOsAgnostic()} + new MovieFile{ RelativePath = "file2.avi".AsOsAgnostic()} }); @@ -97,10 +97,10 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests }; Mocker.GetMock() - .Setup(c => c.GetFilesBySeries(It.IsAny())) - .Returns(new List + .Setup(c => c.GetFilesByMovie(It.IsAny())) + .Returns(new List { - new EpisodeFile{ RelativePath = "file2.avi".AsOsAgnostic()} + new MovieFile{ RelativePath = "file2.avi".AsOsAgnostic()} }); @@ -121,10 +121,10 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests }; Mocker.GetMock() - .Setup(c => c.GetFilesBySeries(It.IsAny())) - .Returns(new List + .Setup(c => c.GetFilesByMovie(It.IsAny())) + .Returns(new List { - new EpisodeFile{ RelativePath = "file2.avi".AsOsAgnostic()} + new MovieFile{ RelativePath = "file2.avi".AsOsAgnostic()} }); Subject.FilterExistingFiles(files, _series).Should().HaveCount(3); @@ -139,12 +139,12 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests }; Mocker.GetMock() - .Setup(c => c.GetFilesBySeries(It.IsAny())) - .Returns(new List()); + .Setup(c => c.GetFilesByMovie(It.IsAny())) + .Returns(new List()); Subject.FilterExistingFiles(files, _series).Should().HaveCount(1); Subject.FilterExistingFiles(files, _series).Should().NotContain(files.First().ToLower()); Subject.FilterExistingFiles(files, _series).Should().Contain(files.First()); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core.Test/MediaFiles/MediaFileTableCleanupServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MediaFileTableCleanupServiceFixture.cs index bb249561b..1db4c985b 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/MediaFileTableCleanupServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MediaFileTableCleanupServiceFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.IO; using FizzWare.NBuilder; @@ -7,7 +7,7 @@ using NUnit.Framework; using NzbDrone.Common.Disk; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MediaFiles @@ -15,17 +15,12 @@ namespace NzbDrone.Core.Test.MediaFiles public class MediaFileTableCleanupServiceFixture : CoreTest { private const string DELETED_PATH = "ANY FILE WITH THIS PATH IS CONSIDERED DELETED!"; - private List _episodes; - private Series _series; + private Movie _movie; [SetUp] public void SetUp() { - _episodes = Builder.CreateListOfSize(10) - .Build() - .ToList(); - - _series = Builder.CreateNew() + _movie = Builder.CreateNew() .With(s => s.Path = @"C:\Test\TV\Series".AsOsAgnostic()) .Build(); @@ -33,99 +28,92 @@ namespace NzbDrone.Core.Test.MediaFiles .Setup(e => e.FileExists(It.Is(c => !c.Contains(DELETED_PATH)))) .Returns(true); - Mocker.GetMock() - .Setup(c => c.GetEpisodeBySeries(It.IsAny())) - .Returns(_episodes); } - private void GivenEpisodeFiles(IEnumerable episodeFiles) + private void GivenMovieFiles(IEnumerable movieFiles) { Mocker.GetMock() - .Setup(c => c.GetFilesBySeries(It.IsAny())) - .Returns(episodeFiles.ToList()); + .Setup(c => c.GetFilesByMovie(It.IsAny())) + .Returns(movieFiles.ToList()); } private void GivenFilesAreNotAttachedToEpisode() { - _episodes.ForEach(e => e.EpisodeFileId = 0); - - Mocker.GetMock() - .Setup(c => c.GetEpisodeBySeries(It.IsAny())) - .Returns(_episodes); + _movie.MovieFileId = 0; } - private List FilesOnDisk(IEnumerable episodeFiles) + private List FilesOnDisk(IEnumerable movieFiles) { - return episodeFiles.Select(e => Path.Combine(_series.Path, e.RelativePath)).ToList(); + return movieFiles.Select(e => Path.Combine(_movie.Path, e.RelativePath)).ToList(); } [Test] public void should_skip_files_that_exist_in_disk() { - var episodeFiles = Builder.CreateListOfSize(10) + var movieFiles = Builder.CreateListOfSize(10) .Build(); - GivenEpisodeFiles(episodeFiles); + GivenMovieFiles(movieFiles); - Subject.Clean(_series, FilesOnDisk(episodeFiles)); + Subject.Clean(_movie, FilesOnDisk(movieFiles)); - Mocker.GetMock().Verify(c => c.UpdateEpisode(It.IsAny()), Times.Never()); + Mocker.GetMock().Verify(c => c.UpdateMovie(It.IsAny()), Times.Never()); } [Test] public void should_delete_non_existent_files() { - var episodeFiles = Builder.CreateListOfSize(10) + var movieFiles = Builder.CreateListOfSize(10) .Random(2) .With(c => c.RelativePath = DELETED_PATH) .Build(); - GivenEpisodeFiles(episodeFiles); + GivenMovieFiles(movieFiles); - Subject.Clean(_series, FilesOnDisk(episodeFiles.Where(e => e.RelativePath != DELETED_PATH))); + Subject.Clean(_movie, FilesOnDisk(movieFiles.Where(e => e.RelativePath != DELETED_PATH))); - Mocker.GetMock().Verify(c => c.Delete(It.Is(e => e.RelativePath == DELETED_PATH), DeleteMediaFileReason.MissingFromDisk), Times.Exactly(2)); + Mocker.GetMock().Verify(c => c.Delete(It.Is(e => e.RelativePath == DELETED_PATH), DeleteMediaFileReason.MissingFromDisk), Times.Exactly(2)); } [Test] public void should_delete_files_that_dont_belong_to_any_episodes() { - var episodeFiles = Builder.CreateListOfSize(10) + var movieFiles = Builder.CreateListOfSize(10) .Random(10) .With(c => c.RelativePath = "ExistingPath") .Build(); - GivenEpisodeFiles(episodeFiles); + GivenMovieFiles(movieFiles); GivenFilesAreNotAttachedToEpisode(); - Subject.Clean(_series, FilesOnDisk(episodeFiles)); + Subject.Clean(_movie, FilesOnDisk(movieFiles)); - Mocker.GetMock().Verify(c => c.Delete(It.IsAny(), DeleteMediaFileReason.NoLinkedEpisodes), Times.Exactly(10)); + Mocker.GetMock().Verify(c => c.Delete(It.IsAny(), DeleteMediaFileReason.NoLinkedEpisodes), Times.Exactly(10)); } [Test] public void should_unlink_episode_when_episodeFile_does_not_exist() { - GivenEpisodeFiles(new List()); + GivenMovieFiles(new List()); - Subject.Clean(_series, new List()); + Subject.Clean(_movie, new List()); - Mocker.GetMock().Verify(c => c.UpdateEpisode(It.Is(e => e.EpisodeFileId == 0)), Times.Exactly(10)); + Mocker.GetMock().Verify(c => c.UpdateMovie(It.Is(e => e.MovieFileId == 0)), Times.Exactly(10)); } [Test] public void should_not_update_episode_when_episodeFile_exists() { - var episodeFiles = Builder.CreateListOfSize(10) + var movieFiles = Builder.CreateListOfSize(10) .Random(10) .With(c => c.RelativePath = "ExistingPath") .Build(); - GivenEpisodeFiles(episodeFiles); + GivenMovieFiles(movieFiles); - Subject.Clean(_series, FilesOnDisk(episodeFiles)); + Subject.Clean(_movie, FilesOnDisk(movieFiles)); - Mocker.GetMock().Verify(c => c.UpdateEpisode(It.IsAny()), Times.Never()); + Mocker.GetMock().Verify(c => c.UpdateMovie(It.IsAny()), Times.Never()); } } } diff --git a/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/UpdateMediaInfoServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/UpdateMediaInfoServiceFixture.cs index 85b9f53f5..10f78375f 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/UpdateMediaInfoServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/UpdateMediaInfoServiceFixture.cs @@ -7,7 +7,7 @@ using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.MediaFiles.MediaInfo; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; using NzbDrone.Core.Configuration; diff --git a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/ImportDecisionMakerFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MovieImport/ImportDecisionMakerFixture.cs similarity index 60% rename from src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/ImportDecisionMakerFixture.cs rename to src/NzbDrone.Core.Test/MediaFiles/MovieImport/ImportDecisionMakerFixture.cs index 6ac522ae4..fe36f9e6d 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/ImportDecisionMakerFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MovieImport/ImportDecisionMakerFixture.cs @@ -1,29 +1,30 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.MediaFiles.EpisodeImport; +using NzbDrone.Core.MediaFiles.MovieImport; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; using FizzWare.NBuilder; +using NzbDrone.Core.Download; -namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport +namespace NzbDrone.Core.Test.MediaFiles.MovieImport { [TestFixture] //TODO: Update all of this for movies. public class ImportDecisionMakerFixture : CoreTest { private List _videoFiles; - private LocalEpisode _localEpisode; - private Series _series; + private LocalMovie _localEpisode; + private Movie _series; private QualityModel _quality; private Mock _pass1; @@ -45,30 +46,29 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport _fail2 = new Mock(); _fail3 = new Mock(); - _pass1.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(Decision.Accept()); - _pass2.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(Decision.Accept()); - _pass3.Setup(c => c.IsSatisfiedBy(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())).Returns(Decision.Reject("_fail1")); - _fail2.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(Decision.Reject("_fail2")); - _fail3.Setup(c => c.IsSatisfiedBy(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")); - _series = Builder.CreateNew() + _series = Builder.CreateNew() .With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() }) .Build(); _quality = new QualityModel(Quality.DVD); - _localEpisode = new LocalEpisode + _localEpisode = new LocalMovie { - Series = _series, + Movie = _series, Quality = _quality, - Episodes = new List { new Episode() }, Path = @"C:\Test\Unsorted\The.Office.S03E115.DVDRip.XviD-OSiTV.avi" }; Mocker.GetMock() - .Setup(c => c.GetLocalEpisode(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) + .Setup(c => c.GetLocalMovie(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(_localEpisode); GivenVideoFiles(new List { @"C:\Test\Unsorted\The.Office.S03E115.DVDRip.XviD-OSiTV.avi".AsOsAgnostic() }); @@ -84,23 +84,24 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport _videoFiles = videoFiles.ToList(); Mocker.GetMock() - .Setup(c => c.FilterExistingFiles(_videoFiles, It.IsAny())) + .Setup(c => c.FilterExistingFiles(_videoFiles, It.IsAny())) .Returns(_videoFiles); } [Test] public void should_call_all_specifications() { + var downloadClientItem = Builder.CreateNew().Build(); GivenSpecifications(_pass1, _pass2, _pass3, _fail1, _fail2, _fail3); - Subject.GetImportDecisions(_videoFiles, new Series(), null, false); + Subject.GetImportDecisions(_videoFiles, new Movie(), downloadClientItem, null, false); - _fail1.Verify(c => c.IsSatisfiedBy(_localEpisode), Times.Once()); - _fail2.Verify(c => c.IsSatisfiedBy(_localEpisode), Times.Once()); - _fail3.Verify(c => c.IsSatisfiedBy(_localEpisode), Times.Once()); - _pass1.Verify(c => c.IsSatisfiedBy(_localEpisode), Times.Once()); - _pass2.Verify(c => c.IsSatisfiedBy(_localEpisode), Times.Once()); - _pass3.Verify(c => c.IsSatisfiedBy(_localEpisode), Times.Once()); + _fail1.Verify(c => c.IsSatisfiedBy(_localEpisode, downloadClientItem), Times.Once()); + _fail2.Verify(c => c.IsSatisfiedBy(_localEpisode, downloadClientItem), Times.Once()); + _fail3.Verify(c => c.IsSatisfiedBy(_localEpisode, downloadClientItem), Times.Once()); + _pass1.Verify(c => c.IsSatisfiedBy(_localEpisode, downloadClientItem), Times.Once()); + _pass2.Verify(c => c.IsSatisfiedBy(_localEpisode, downloadClientItem), Times.Once()); + _pass3.Verify(c => c.IsSatisfiedBy(_localEpisode, downloadClientItem), Times.Once()); } [Test] @@ -108,7 +109,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport { GivenSpecifications(_fail1); - var result = Subject.GetImportDecisions(_videoFiles, new Series()); + var result = Subject.GetImportDecisions(_videoFiles, new Movie()); result.Single().Approved.Should().BeFalse(); } @@ -118,7 +119,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport { GivenSpecifications(_pass1, _fail1, _pass2, _pass3); - var result = Subject.GetImportDecisions(_videoFiles, new Series()); + var result = Subject.GetImportDecisions(_videoFiles, new Movie()); result.Single().Approved.Should().BeFalse(); } @@ -128,7 +129,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport { GivenSpecifications(_pass1, _pass2, _pass3); - var result = Subject.GetImportDecisions(_videoFiles, new Series()); + var result = Subject.GetImportDecisions(_videoFiles, new Movie()); result.Single().Approved.Should().BeTrue(); } @@ -138,7 +139,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport { GivenSpecifications(_pass1, _pass2, _pass3, _fail1, _fail2, _fail3); - var result = Subject.GetImportDecisions(_videoFiles, new Series()); + var result = Subject.GetImportDecisions(_videoFiles, new Movie()); result.Single().Rejections.Should().HaveCount(3); } @@ -148,7 +149,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport GivenSpecifications(_pass1); Mocker.GetMock() - .Setup(c => c.GetLocalEpisode(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) + .Setup(c => c.GetLocalMovie(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .Throws(); _videoFiles = new List @@ -163,7 +164,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport Subject.GetImportDecisions(_videoFiles, _series); Mocker.GetMock() - .Verify(c => c.GetLocalEpisode(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Exactly(_videoFiles.Count)); + .Verify(c => c.GetLocalMovie(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Exactly(_videoFiles.Count)); ExceptionVerification.ExpectedErrors(3); } @@ -176,7 +177,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport var result = Subject.GetImportDecisions(_videoFiles, _series); - result.Single().LocalEpisode.Quality.Should().Be(expectedQuality); + result.Single().LocalMovie.Quality.Should().Be(expectedQuality); } [Test] @@ -185,9 +186,9 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport GivenSpecifications(_pass1, _pass2, _pass3); var expectedQuality = QualityParser.ParseQuality(_videoFiles.Single()); - var result = Subject.GetImportDecisions(_videoFiles, _series, new ParsedEpisodeInfo{Quality = new QualityModel(Quality.SDTV)}, true); + var result = Subject.GetImportDecisions(_videoFiles, _series, null, new ParsedMovieInfo{Quality = new QualityModel(Quality.SDTV)}, true); - result.Single().LocalEpisode.Quality.Should().Be(expectedQuality); + result.Single().LocalMovie.Quality.Should().Be(expectedQuality); } [Test] @@ -202,9 +203,9 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport var expectedQuality = new QualityModel(Quality.SDTV); - var result = Subject.GetImportDecisions(_videoFiles, _series, new ParsedEpisodeInfo { Quality = expectedQuality }, true); + var result = Subject.GetImportDecisions(_videoFiles, _series, null, new ParsedMovieInfo { Quality = expectedQuality }, true); - result.Single().LocalEpisode.Quality.Should().Be(expectedQuality); + result.Single().LocalMovie.Quality.Should().Be(expectedQuality); } [Test] @@ -218,9 +219,9 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport var expectedQuality = new QualityModel(Quality.Bluray720p); - var result = Subject.GetImportDecisions(_videoFiles, _series, new ParsedEpisodeInfo { Quality = expectedQuality }, true); + var result = Subject.GetImportDecisions(_videoFiles, _series, null, new ParsedMovieInfo { Quality = expectedQuality }, true); - result.Single().LocalEpisode.Quality.Should().Be(expectedQuality); + result.Single().LocalMovie.Quality.Should().Be(expectedQuality); } [Test] @@ -229,8 +230,8 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport GivenSpecifications(_pass1); Mocker.GetMock() - .Setup(c => c.GetLocalEpisode(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(new LocalEpisode() { Path = "test" }); + .Setup(c => c.GetLocalMovie(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) + .Returns(new LocalMovie() { Path = "test" }); _videoFiles = new List { @@ -244,7 +245,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport var decisions = Subject.GetImportDecisions(_videoFiles, _series); Mocker.GetMock() - .Verify(c => c.GetLocalEpisode(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Exactly(_videoFiles.Count)); + .Verify(c => c.GetLocalMovie(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Exactly(_videoFiles.Count)); decisions.Should().HaveCount(3); decisions.First().Rejections.Should().NotBeEmpty(); @@ -255,23 +256,23 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport { var videoFiles = new[] { - @"C:\Test\Unsorted\Series.Title.S01\S01E01.mkv".AsOsAgnostic(), - @"C:\Test\Unsorted\Series.Title.S01\S01E02.mkv".AsOsAgnostic(), - @"C:\Test\Unsorted\Series.Title.S01\S01E03.mkv".AsOsAgnostic() + @"C:\Test\Unsorted\Movie.Title.S01\S01E01.mkv".AsOsAgnostic(), + @"C:\Test\Unsorted\Movie.Title.S01\S01E02.mkv".AsOsAgnostic(), + @"C:\Test\Unsorted\Movie.Title.S01\S01E03.mkv".AsOsAgnostic() }; GivenSpecifications(_pass1); GivenVideoFiles(videoFiles); - var folderInfo = Parser.Parser.ParseTitle("Series.Title.S01"); + var folderInfo = Parser.Parser.ParseMovieTitle("Movie.Title.S01", false); - Subject.GetImportDecisions(_videoFiles, _series, folderInfo, true); + Subject.GetImportDecisions(_videoFiles, _series, null, folderInfo, true); Mocker.GetMock() - .Verify(c => c.GetLocalEpisode(It.IsAny(), It.IsAny(), null, true), Times.Exactly(3)); + .Verify(c => c.GetLocalMovie(It.IsAny(), It.IsAny(), null, true), Times.Exactly(3)); Mocker.GetMock() - .Verify(c => c.GetLocalEpisode(It.IsAny(), It.IsAny(), It.Is(p => p != null), true), Times.Never()); + .Verify(c => c.GetLocalMovie(It.IsAny(), It.IsAny(), It.Is(p => p != null), true), Times.Never()); } [Test] @@ -279,22 +280,22 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport { var videoFiles = new[] { - @"C:\Test\Unsorted\Series.Title.S01E01\S01E01.mkv".AsOsAgnostic(), - @"C:\Test\Unsorted\Series.Title.S01E01\1x01.mkv".AsOsAgnostic() + @"C:\Test\Unsorted\Movie.Title.S01E01\S01E01.mkv".AsOsAgnostic(), + @"C:\Test\Unsorted\Movie.Title.S01E01\1x01.mkv".AsOsAgnostic() }; GivenSpecifications(_pass1); GivenVideoFiles(videoFiles); - var folderInfo = Parser.Parser.ParseTitle("Series.Title.S01E01"); + var folderInfo = Parser.Parser.ParseMovieTitle("Movie.Title.S01E01", false); - Subject.GetImportDecisions(_videoFiles, _series, folderInfo, true); + Subject.GetImportDecisions(_videoFiles, _series, null, folderInfo, true); Mocker.GetMock() - .Verify(c => c.GetLocalEpisode(It.IsAny(), It.IsAny(), null, true), Times.Exactly(2)); + .Verify(c => c.GetLocalMovie(It.IsAny(), It.IsAny(), null, true), Times.Exactly(2)); Mocker.GetMock() - .Verify(c => c.GetLocalEpisode(It.IsAny(), It.IsAny(), It.Is(p => p != null), true), Times.Never()); + .Verify(c => c.GetLocalMovie(It.IsAny(), It.IsAny(), It.Is(p => p != null), true), Times.Never()); } [Test] @@ -302,21 +303,21 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport { var videoFiles = new[] { - @"C:\Test\Unsorted\Series.Title.S01E01\S01E01.mkv".AsOsAgnostic() + @"C:\Test\Unsorted\Movie.Title.S01E01\S01E01.mkv".AsOsAgnostic() }; GivenSpecifications(_pass1); GivenVideoFiles(videoFiles); - var folderInfo = Parser.Parser.ParseTitle("Series.Title.S01E01"); + var folderInfo = Parser.Parser.ParseMovieTitle("Movie.Title.S01E01", false); - Subject.GetImportDecisions(_videoFiles, _series, folderInfo, true); + Subject.GetImportDecisions(_videoFiles, _series, null, folderInfo, true); Mocker.GetMock() - .Verify(c => c.GetLocalEpisode(It.IsAny(), It.IsAny(), It.IsAny(), true), Times.Exactly(1)); + .Verify(c => c.GetLocalMovie(It.IsAny(), It.IsAny(), It.IsAny(), true), Times.Exactly(1)); Mocker.GetMock() - .Verify(c => c.GetLocalEpisode(It.IsAny(), It.IsAny(), null, true), Times.Never()); + .Verify(c => c.GetLocalMovie(It.IsAny(), It.IsAny(), null, true), Times.Never()); } [Test] @@ -324,8 +325,8 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport { var videoFiles = new[] { - @"C:\Test\Unsorted\Series.Title.S01E01\S01E01.mkv".AsOsAgnostic(), - @"C:\Test\Unsorted\Series.Title.S01E01\S01E01.sample.mkv".AsOsAgnostic() + @"C:\Test\Unsorted\Movie.Title.S01E01\S01E01.mkv".AsOsAgnostic(), + @"C:\Test\Unsorted\Movie.Title.S01E01\S01E01.sample.mkv".AsOsAgnostic() }; GivenSpecifications(_pass1); @@ -335,38 +336,38 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport .Setup(s => s.IsSample(_series, It.IsAny(), It.Is(c => c.Contains("sample")), It.IsAny(), It.IsAny())) .Returns(true); - var folderInfo = Parser.Parser.ParseTitle("Series.Title.S01E01"); + var folderInfo = Parser.Parser.ParseMovieTitle("Movie.Title.S01E01", false); - Subject.GetImportDecisions(_videoFiles, _series, folderInfo, true); + Subject.GetImportDecisions(_videoFiles, _series, null, folderInfo, true); Mocker.GetMock() - .Verify(c => c.GetLocalEpisode(It.IsAny(), It.IsAny(), It.IsAny(), true), Times.Exactly(2)); + .Verify(c => c.GetLocalMovie(It.IsAny(), It.IsAny(), It.IsAny(), true), Times.Exactly(2)); Mocker.GetMock() - .Verify(c => c.GetLocalEpisode(It.IsAny(), It.IsAny(), null, true), Times.Never()); + .Verify(c => c.GetLocalMovie(It.IsAny(), It.IsAny(), null, true), Times.Never()); } [Test] - [Ignore("Series")] + [Ignore("Movie")] public void should_not_use_folder_name_if_file_name_is_scene_name() { var videoFiles = new[] { - @"C:\Test\Unsorted\Series.Title.S01E01.720p.HDTV-LOL\Series.Title.S01E01.720p.HDTV-LOL.mkv".AsOsAgnostic() + @"C:\Test\Unsorted\Movie.Title.S01E01.720p.HDTV-LOL\Movie.Title.S01E01.720p.HDTV-LOL.mkv".AsOsAgnostic() }; GivenSpecifications(_pass1); GivenVideoFiles(videoFiles); - var folderInfo = Parser.Parser.ParseTitle("Series.Title.S01E01.720p.HDTV-LOL"); + var folderInfo = Parser.Parser.ParseMovieTitle("Movie.Title.S01E01.720p.HDTV-LOL", false); - Subject.GetImportDecisions(_videoFiles, _series, folderInfo, true); + Subject.GetImportDecisions(_videoFiles, _series, null, folderInfo, true); Mocker.GetMock() - .Verify(c => c.GetLocalEpisode(It.IsAny(), It.IsAny(), null, true), Times.Exactly(1)); + .Verify(c => c.GetLocalMovie(It.IsAny(), It.IsAny(), null, true), Times.Exactly(1)); Mocker.GetMock() - .Verify(c => c.GetLocalEpisode(It.IsAny(), It.IsAny(), It.Is(p => p != null), true), Times.Never()); + .Verify(c => c.GetLocalMovie(It.IsAny(), It.IsAny(), It.Is(p => p != null), true), Times.Never()); } [Test] @@ -382,16 +383,16 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport var folderQuality = new QualityModel(Quality.Unknown); - var result = Subject.GetImportDecisions(_videoFiles, _series, new ParsedEpisodeInfo { Quality = folderQuality}, true); + var result = Subject.GetImportDecisions(_videoFiles, _series, null, new ParsedMovieInfo { Quality = folderQuality}, true); - result.Single().LocalEpisode.Quality.Should().Be(_quality); + result.Single().LocalMovie.Quality.Should().Be(_quality); } [Test] public void should_return_a_decision_when_exception_is_caught() { Mocker.GetMock() - .Setup(c => c.GetLocalEpisode(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) + .Setup(c => c.GetLocalMovie(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .Throws(); _videoFiles = new List diff --git a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/SampleServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MovieImport/SampleServiceFixture.cs similarity index 55% rename from src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/SampleServiceFixture.cs rename to src/NzbDrone.Core.Test/MediaFiles/MovieImport/SampleServiceFixture.cs index febb5c42f..46f14a86f 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/SampleServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MovieImport/SampleServiceFixture.cs @@ -1,50 +1,42 @@ -using System; +using System; using System.Linq; using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; -using NzbDrone.Core.MediaFiles.EpisodeImport; +using NzbDrone.Core.MediaFiles.MovieImport; using NzbDrone.Core.MediaFiles.MediaInfo; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; -namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport +namespace NzbDrone.Core.Test.MediaFiles.MovieImport { [TestFixture] public class SampleServiceFixture : CoreTest { - private Series _series; - private LocalEpisode _localEpisode; + private Movie _movie; + private LocalMovie _localMovie; [SetUp] public void Setup() { - _series = Builder.CreateNew() - .With(s => s.SeriesType = SeriesTypes.Standard) + _movie = Builder.CreateNew() .With(s => s.Runtime = 30) .Build(); - var episodes = Builder.CreateListOfSize(1) - .All() - .With(e => e.SeasonNumber = 1) - .Build() - .ToList(); - - _localEpisode = new LocalEpisode + _localMovie = new LocalMovie { Path = @"C:\Test\30 Rock\30.rock.s01e01.avi", - Episodes = episodes, - Series = _series, + Movie = _movie, Quality = new QualityModel(Quality.HDTV720p) }; } private void GivenFileSize(long size) { - _localEpisode.Size = size; + _localMovie.Size = size; } private void GivenRuntime(int seconds) @@ -54,17 +46,10 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport .Returns(new TimeSpan(0, 0, seconds)); } - [Test] - public void should_return_false_if_season_zero() - { - _localEpisode.Episodes[0].SeasonNumber = 0; - ShouldBeFalse(); - } - [Test] public void should_return_false_for_flv() { - _localEpisode.Path = @"C:\Test\some.show.s01e01.flv"; + _localMovie.Path = @"C:\Test\some.show.s01e01.flv"; ShouldBeFalse(); @@ -74,7 +59,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport [Test] public void should_return_false_for_strm() { - _localEpisode.Path = @"C:\Test\some.show.s01e01.strm"; + _localMovie.Path = @"C:\Test\some.show.s01e01.strm"; ShouldBeFalse(); @@ -87,11 +72,11 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport GivenRuntime(120); GivenFileSize(1000.Megabytes()); - Subject.IsSample(_localEpisode.Series, - _localEpisode.Quality, - _localEpisode.Path, - _localEpisode.Size, - _localEpisode.IsSpecial); + Subject.IsSample(_localMovie.Movie, + _localMovie.Quality, + _localMovie.Path, + _localMovie.Size, + false); Mocker.GetMock().Verify(v => v.GetRunTime(It.IsAny()), Times.Once()); } @@ -115,7 +100,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport [Test] public void should_return_false_if_runtime_greater_than_webisode_minimum() { - _series.Runtime = 6; + _movie.Runtime = 6; GivenRuntime(299); ShouldBeFalse(); @@ -143,40 +128,26 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport ShouldBeTrue(); } - [Test] - public void should_not_treat_daily_episode_a_special() - { - GivenRuntime(600); - _series.SeriesType = SeriesTypes.Daily; - _localEpisode.Episodes[0].SeasonNumber = 0; - ShouldBeFalse(); - } - [Test] - public void should_return_false_for_anime_special() - { - _series.SeriesType = SeriesTypes.Anime; - _localEpisode.Episodes[0].SeasonNumber = 0; - ShouldBeFalse(); - } + private void ShouldBeTrue() { - Subject.IsSample(_localEpisode.Series, - _localEpisode.Quality, - _localEpisode.Path, - _localEpisode.Size, - _localEpisode.IsSpecial).Should().BeTrue(); + Subject.IsSample(_localMovie.Movie, + _localMovie.Quality, + _localMovie.Path, + _localMovie.Size, + false).Should().BeTrue(); } private void ShouldBeFalse() { - Subject.IsSample(_localEpisode.Series, - _localEpisode.Quality, - _localEpisode.Path, - _localEpisode.Size, - _localEpisode.IsSpecial).Should().BeFalse(); + Subject.IsSample(_localMovie.Movie, + _localMovie.Quality, + _localMovie.Path, + _localMovie.Size, + false).Should().BeFalse(); } } } diff --git a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecificationFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MovieImport/Specifications/FreeSpaceSpecificationFixture.cs similarity index 65% rename from src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecificationFixture.cs rename to src/NzbDrone.Core.Test/MediaFiles/MovieImport/Specifications/FreeSpaceSpecificationFixture.cs index a6f1afca1..324e2bcb6 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MovieImport/Specifications/FreeSpaceSpecificationFixture.cs @@ -1,4 +1,4 @@ -using System.IO; +using System.IO; using System.Linq; using FizzWare.NBuilder; using FluentAssertions; @@ -6,19 +6,19 @@ using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; using NzbDrone.Core.Configuration; -using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications; +using NzbDrone.Core.MediaFiles.MovieImport.Specifications; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; -namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications +namespace NzbDrone.Core.Test.MediaFiles.MovieImport.Specifications { [TestFixture] public class FreeSpaceSpecificationFixture : CoreTest { - private Series _series; - private LocalEpisode _localEpisode; + private Movie _movie; + private LocalMovie _localMovie; private string _rootFolder; [SetUp] @@ -26,28 +26,20 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications { _rootFolder = @"C:\Test\TV".AsOsAgnostic(); - _series = Builder.CreateNew() - .With(s => s.SeriesType = SeriesTypes.Standard) - .With(s => s.Path = Path.Combine(_rootFolder, "30 Rock")) - .Build(); + _movie = Builder.CreateNew() + .With(s => s.Path = Path.Combine(_rootFolder, "30 Rock")) + .Build(); - var episodes = Builder.CreateListOfSize(1) - .All() - .With(e => e.SeasonNumber = 1) - .Build() - .ToList(); - - _localEpisode = new LocalEpisode + _localMovie = new LocalMovie() { Path = @"C:\Test\Unsorted\30 Rock\30.rock.s01e01.avi".AsOsAgnostic(), - Episodes = episodes, - Series = _series + Movie = _movie }; } private void GivenFileSize(long size) { - _localEpisode.Size = size; + _localMovie.Size = size; } private void GivenFreeSpace(long? size) @@ -63,7 +55,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications GivenFileSize(100.Megabytes()); GivenFreeSpace(80.Megabytes()); - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeFalse(); ExceptionVerification.ExpectedWarns(1); } @@ -73,7 +65,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications GivenFileSize(100.Megabytes()); GivenFreeSpace(150.Megabytes()); - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeFalse(); ExceptionVerification.ExpectedWarns(1); } @@ -83,7 +75,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications GivenFileSize(100.Megabytes()); GivenFreeSpace(1.Gigabytes()); - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeTrue(); } [Test] @@ -92,7 +84,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications GivenFileSize(100.Megabytes()); GivenFreeSpace(1.Gigabytes()); - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeTrue(); Mocker.GetMock() .Verify(v => v.GetAvailableSpace(_rootFolder), Times.Once()); @@ -104,7 +96,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications GivenFileSize(100.Megabytes()); GivenFreeSpace(null); - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeTrue(); } [Test] @@ -116,16 +108,16 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications .Setup(s => s.GetAvailableSpace(It.IsAny())) .Throws(new TestException()); - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeTrue(); ExceptionVerification.ExpectedErrors(1); } [Test] public void should_skip_check_for_files_under_series_folder() { - _localEpisode.ExistingFile = true; + _localMovie.ExistingFile = true; - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeTrue(); Mocker.GetMock() .Verify(s => s.GetAvailableSpace(It.IsAny()), Times.Never()); @@ -140,7 +132,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications .Setup(s => s.GetAvailableSpace(It.IsAny())) .Returns(freeSpace); - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeTrue(); } [Test] @@ -150,7 +142,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications .Setup(s => s.SkipFreeSpaceCheckWhenImporting) .Returns(true); - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeTrue(); } } } diff --git a/src/NzbDrone.Core.Test/MediaFiles/MovieImport/Specifications/MatchesFolderSpecificationFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MovieImport/Specifications/MatchesFolderSpecificationFixture.cs new file mode 100644 index 000000000..2cb1e1893 --- /dev/null +++ b/src/NzbDrone.Core.Test/MediaFiles/MovieImport/Specifications/MatchesFolderSpecificationFixture.cs @@ -0,0 +1,67 @@ +using FizzWare.NBuilder; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.MediaFiles.MovieImport.Specifications; +using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Test.Framework; +using NzbDrone.Test.Common; + +namespace NzbDrone.Core.Test.MediaFiles.MovieImport.Specifications +{ + [TestFixture] + public class MatchesFolderSpecificationFixture : CoreTest + { + private LocalMovie _localMovie; + + [SetUp] + public void Setup() + { + _localMovie = Builder.CreateNew() + .With(l => l.Path = @"C:\Test\Unsorted\Series.Title.S01E01.720p.HDTV-Sonarr\S01E05.mkv".AsOsAgnostic()) + .With(l => l.ParsedMovieInfo = + Builder.CreateNew() + .Build()) + .Build(); + } + + [Test] + public void should_be_accepted_for_existing_file() + { + _localMovie.ExistingFile = true; + + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeTrue(); + } + + [Test] + public void should_be_accepted_if_folder_name_is_not_parseable() + { + _localMovie.Path = @"C:\Test\Unsorted\Series.Title\S01E01.mkv".AsOsAgnostic(); + + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeTrue(); + } + + [Test] + public void should_should_be_accepted_for_full_season() + { + _localMovie.Path = @"C:\Test\Unsorted\Series.Title.S01\S01E01.mkv".AsOsAgnostic(); + + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeTrue(); + } + + [Test] + public void should_be_accepted_if_file_and_folder_have_the_same_episode() + { + _localMovie.Path = @"C:\Test\Unsorted\Series.Title.S01E01.720p.HDTV-Sonarr\S01E01.mkv".AsOsAgnostic(); + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeTrue(); + } + + + [Test] + public void should_be_rejected_if_file_and_folder_do_not_have_same_episode() + { + _localMovie.Path = @"C:\Test\Unsorted\Series.Title.S01E01.720p.HDTV-Sonarr\S01E05.mkv".AsOsAgnostic(); + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeFalse(); + } + + } +} diff --git a/src/NzbDrone.Core.Test/MediaFiles/MovieImport/Specifications/NotSampleSpecificationFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MovieImport/Specifications/NotSampleSpecificationFixture.cs new file mode 100644 index 000000000..93168b27d --- /dev/null +++ b/src/NzbDrone.Core.Test/MediaFiles/MovieImport/Specifications/NotSampleSpecificationFixture.cs @@ -0,0 +1,40 @@ +using System.Linq; +using FizzWare.NBuilder; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.MediaFiles.MovieImport.Specifications; +using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Qualities; +using NzbDrone.Core.Test.Framework; +using NzbDrone.Core.Movies; + +namespace NzbDrone.Core.Test.MediaFiles.MovieImport.Specifications +{ + [TestFixture] + public class NotSampleSpecificationFixture : CoreTest + { + private Movie _movie; + private LocalMovie _localEpisode; + + [SetUp] + public void Setup() + { + _movie = Builder.CreateNew() + .Build(); + + _localEpisode = new LocalMovie + { + Path = @"C:\Test\30 Rock\30.rock.s01e01.avi", + Movie = _movie, + Quality = new QualityModel(Quality.HDTV720p) + }; + } + + [Test] + public void should_return_true_for_existing_file() + { + _localEpisode.ExistingFile = true; + Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeTrue(); + } + } +} diff --git a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/NotUnpackingSpecificationFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MovieImport/Specifications/NotUnpackingSpecificationFixture.cs similarity index 70% rename from src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/NotUnpackingSpecificationFixture.cs rename to src/NzbDrone.Core.Test/MediaFiles/MovieImport/Specifications/NotUnpackingSpecificationFixture.cs index ad27e402f..4fe107a06 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/NotUnpackingSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MovieImport/Specifications/NotUnpackingSpecificationFixture.cs @@ -1,22 +1,22 @@ -using System; +using System; using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; using NzbDrone.Core.Configuration; -using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications; +using NzbDrone.Core.MediaFiles.MovieImport.Specifications; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; -namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications +namespace NzbDrone.Core.Test.MediaFiles.MovieImport.Specifications { [TestFixture] public class NotUnpackingSpecificationFixture : CoreTest { - private LocalEpisode _localEpisode; + private LocalMovie _localMovie; [SetUp] public void Setup() @@ -25,17 +25,17 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications .SetupGet(s => s.DownloadClientWorkingFolders) .Returns("_UNPACK_|_FAILED_"); - _localEpisode = new LocalEpisode + _localMovie = new LocalMovie { Path = @"C:\Test\Unsorted TV\30.rock\30.rock.s01e01.avi".AsOsAgnostic(), Size = 100, - Series = Builder.CreateNew().Build() + Movie = Builder.CreateNew().Build() }; } private void GivenInWorkingFolder() { - _localEpisode.Path = @"C:\Test\Unsorted TV\_UNPACK_30.rock\someSubFolder\30.rock.s01e01.avi".AsOsAgnostic(); + _localMovie.Path = @"C:\Test\Unsorted TV\_UNPACK_30.rock\someSubFolder\30.rock.s01e01.avi".AsOsAgnostic(); } private void GivenLastWriteTimeUtc(DateTime time) @@ -48,7 +48,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications [Test] public void should_return_true_if_not_in_working_folder() { - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeTrue(); } [Test] @@ -59,7 +59,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications GivenInWorkingFolder(); GivenLastWriteTimeUtc(DateTime.UtcNow.AddHours(-1)); - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeTrue(); } [Test] @@ -68,7 +68,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications GivenInWorkingFolder(); GivenLastWriteTimeUtc(DateTime.UtcNow); - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeFalse(); } [Test] @@ -79,7 +79,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications GivenInWorkingFolder(); GivenLastWriteTimeUtc(DateTime.UtcNow.AddDays(-5)); - Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeFalse(); } } } diff --git a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/SameFileSpecificationFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MovieImport/Specifications/SameFileSpecificationFixture.cs similarity index 93% rename from src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/SameFileSpecificationFixture.cs rename to src/NzbDrone.Core.Test/MediaFiles/MovieImport/Specifications/SameFileSpecificationFixture.cs index 41b36d971..8e48d5173 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/SameFileSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MovieImport/Specifications/SameFileSpecificationFixture.cs @@ -4,12 +4,12 @@ using FluentAssertions; using Marr.Data; using NUnit.Framework; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications; +using NzbDrone.Core.MediaFiles.MovieImport.Specifications; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; -namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications +namespace NzbDrone.Core.Test.MediaFiles.MovieImport.Specifications { [TestFixture] public class SameFileSpecificationFixture : CoreTest diff --git a/src/NzbDrone.Core.Test/MediaFiles/MovieImport/Specifications/UpgradeSpecificationFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MovieImport/Specifications/UpgradeSpecificationFixture.cs new file mode 100644 index 000000000..4283ed370 --- /dev/null +++ b/src/NzbDrone.Core.Test/MediaFiles/MovieImport/Specifications/UpgradeSpecificationFixture.cs @@ -0,0 +1,77 @@ +using System.Linq; +using FizzWare.NBuilder; +using FluentAssertions; +using Marr.Data; +using NUnit.Framework; +using NzbDrone.Core.MediaFiles; +using NzbDrone.Core.MediaFiles.MovieImport.Specifications; +using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Profiles; +using NzbDrone.Core.Qualities; +using NzbDrone.Core.Test.Framework; +using NzbDrone.Core.Movies; + +namespace NzbDrone.Core.Test.MediaFiles.MovieImport.Specifications +{ + [TestFixture] + public class UpgradeSpecificationFixture : CoreTest + { + private Movie _movie; + private LocalMovie _localMovie; + + [SetUp] + public void Setup() + { + _movie = Builder.CreateNew() + .With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() }) + .Build(); + + _localMovie = new LocalMovie() + { + Path = @"C:\Test\30 Rock\30.rock.s01e01.avi", + Quality = new QualityModel(Quality.HDTV720p, new Revision(version: 1)), + Movie = _movie + }; + } + + [Test] + public void should_return_true_if_no_existing_episodeFile() + { + _localMovie.Movie.MovieFile = null; + _localMovie.Movie.MovieFileId = 0; + + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeTrue(); + } + + [Test] + public void should_return_true_if_upgrade_for_existing_episodeFile() + { + + _localMovie.Movie.MovieFileId = 1; + _localMovie.Movie.MovieFile = new LazyLoaded( + new MovieFile + { + Quality = new QualityModel(Quality.SDTV, new Revision(version: 1)) + } + ); + + + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeTrue(); + } + + + [Test] + public void should_return_false_if_not_an_upgrade_for_existing_episodeFile() + { + _localMovie.Movie.MovieFileId = 1; + _localMovie.Movie.MovieFile = new LazyLoaded( + new MovieFile + { + Quality = new QualityModel(Quality.Bluray720p, new Revision(version: 1)) + } + ); + + Subject.IsSatisfiedBy(_localMovie, null).Accepted.Should().BeFalse(); + } + } +} diff --git a/src/NzbDrone.Core.Test/MediaFiles/RenameEpisodeFileServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/RenameMovieFileServiceFixture.cs similarity index 50% rename from src/NzbDrone.Core.Test/MediaFiles/RenameEpisodeFileServiceFixture.cs rename to src/NzbDrone.Core.Test/MediaFiles/RenameMovieFileServiceFixture.cs index 5757641dc..ed13a3af2 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/RenameEpisodeFileServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/RenameMovieFileServiceFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using FizzWare.NBuilder; using Moq; @@ -8,51 +8,50 @@ using NzbDrone.Core.MediaFiles.Commands; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.MediaFiles { - public class RenameEpisodeFileServiceFixture : CoreTest + public class RenameMovieFileServiceFixture : CoreTest { - private Series _series; - private List _episodeFiles; + private Movie _movie; + private List _movieFiles; [SetUp] public void Setup() { - _series = Builder.CreateNew() + _movie = Builder.CreateNew() .Build(); - _episodeFiles = Builder.CreateListOfSize(2) + _movieFiles = Builder.CreateListOfSize(2) .All() - .With(e => e.SeriesId = _series.Id) - .With(e => e.SeasonNumber = 1) + .With(e => e.MovieId = _movie.Id) .Build() .ToList(); - Mocker.GetMock() - .Setup(s => s.GetSeries(_series.Id)) - .Returns(_series); + Mocker.GetMock() + .Setup(s => s.GetMovie(_movie.Id)) + .Returns(_movie); } private void GivenNoEpisodeFiles() { Mocker.GetMock() - .Setup(s => s.Get(It.IsAny>())) - .Returns(new List()); + .Setup(s => s.GetMovies(It.IsAny>())) + .Returns(new List()); } private void GivenEpisodeFiles() { Mocker.GetMock() - .Setup(s => s.Get(It.IsAny>())) - .Returns(_episodeFiles); + .Setup(s => s.GetMovies(It.IsAny>())) + .Returns(_movieFiles); } private void GivenMovedFiles() { - Mocker.GetMock() - .Setup(s => s.MoveEpisodeFile(It.IsAny(), _series)); + Mocker.GetMock() + .Setup(s => s.MoveMovieFile(It.IsAny(), _movie)); } [Test] @@ -60,10 +59,10 @@ namespace NzbDrone.Core.Test.MediaFiles { GivenNoEpisodeFiles(); - Subject.Execute(new RenameFilesCommand(_series.Id, new List{1})); + Subject.Execute(new RenameMovieFilesCommand(_movie.Id, new List{1})); Mocker.GetMock() - .Verify(v => v.PublishEvent(It.IsAny()), Times.Never()); + .Verify(v => v.PublishEvent(It.IsAny()), Times.Never()); } [Test] @@ -71,14 +70,14 @@ namespace NzbDrone.Core.Test.MediaFiles { GivenEpisodeFiles(); - Mocker.GetMock() - .Setup(s => s.MoveEpisodeFile(It.IsAny(), It.IsAny())) + Mocker.GetMock() + .Setup(s => s.MoveMovieFile(It.IsAny(), It.IsAny())) .Throws(new SameFilenameException("Same file name", "Filename")); - Subject.Execute(new RenameFilesCommand(_series.Id, new List { 1 })); + Subject.Execute(new RenameMovieFilesCommand(_movie.Id, new List { 1 })); Mocker.GetMock() - .Verify(v => v.PublishEvent(It.IsAny()), Times.Never()); + .Verify(v => v.PublishEvent(It.IsAny()), Times.Never()); } [Test] @@ -87,10 +86,10 @@ namespace NzbDrone.Core.Test.MediaFiles GivenEpisodeFiles(); GivenMovedFiles(); - Subject.Execute(new RenameFilesCommand(_series.Id, new List { 1 })); + Subject.Execute(new RenameMovieFilesCommand(_movie.Id, new List { 1 })); Mocker.GetMock() - .Verify(v => v.PublishEvent(It.IsAny()), Times.Once()); + .Verify(v => v.PublishEvent(It.IsAny()), Times.Once()); } [Test] @@ -99,10 +98,10 @@ namespace NzbDrone.Core.Test.MediaFiles GivenEpisodeFiles(); GivenMovedFiles(); - Subject.Execute(new RenameFilesCommand(_series.Id, new List { 1 })); + Subject.Execute(new RenameMovieFilesCommand(_movie.Id, new List { 1 })); Mocker.GetMock() - .Verify(v => v.Update(It.IsAny()), Times.Exactly(2)); + .Verify(v => v.Update(It.IsAny()), Times.Exactly(2)); } [Test] @@ -113,10 +112,10 @@ namespace NzbDrone.Core.Test.MediaFiles var files = new List { 1 }; - Subject.Execute(new RenameFilesCommand(_series.Id, files)); + Subject.Execute(new RenameMovieFilesCommand(_movie.Id, files)); Mocker.GetMock() - .Verify(v => v.Get(files), Times.Once()); + .Verify(v => v.GetMovies(files), Times.Once()); } } } diff --git a/src/NzbDrone.Core.Test/MediaFiles/UpgradeMediaFileServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/UpgradeMediaFileServiceFixture.cs index 2dfb17e8b..4cb43a9b7 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/UpgradeMediaFileServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/UpgradeMediaFileServiceFixture.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using FizzWare.NBuilder; using FluentAssertions; using Marr.Data; @@ -8,26 +8,26 @@ using NzbDrone.Common.Disk; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MediaFiles { public class UpgradeMediaFileServiceFixture : CoreTest { - private EpisodeFile _episodeFile; - private LocalEpisode _localEpisode; + private MovieFile _movieFile; + private LocalMovie _localMovie; [SetUp] public void Setup() { - _localEpisode = new LocalEpisode(); - _localEpisode.Series = new Series + _localMovie = new LocalMovie(); + _localMovie.Movie = new Movie { Path = @"C:\Test\TV\Series".AsOsAgnostic() }; - _episodeFile = Builder + _movieFile = Builder .CreateNew() .Build(); @@ -39,53 +39,13 @@ namespace NzbDrone.Core.Test.MediaFiles private void GivenSingleEpisodeWithSingleEpisodeFile() { - _localEpisode.Episodes = Builder.CreateListOfSize(1) - .All() - .With(e => e.EpisodeFileId = 1) - .With(e => e.EpisodeFile = new LazyLoaded( - new EpisodeFile - { - Id = 1, - RelativePath = @"Season 01\30.rock.s01e01.avi", - })) - .Build() - .ToList(); - } - - private void GivenMultipleEpisodesWithSingleEpisodeFile() - { - _localEpisode.Episodes = Builder.CreateListOfSize(2) - .All() - .With(e => e.EpisodeFileId = 1) - .With(e => e.EpisodeFile = new LazyLoaded( - new EpisodeFile - { - Id = 1, - RelativePath = @"Season 01\30.rock.s01e01.avi", - })) - .Build() - .ToList(); - } - - private void GivenMultipleEpisodesWithMultipleEpisodeFiles() - { - _localEpisode.Episodes = Builder.CreateListOfSize(2) - .TheFirst(1) - .With(e => e.EpisodeFile = new LazyLoaded( - new EpisodeFile - { - Id = 1, - RelativePath = @"Season 01\30.rock.s01e01.avi", - })) - .TheNext(1) - .With(e => e.EpisodeFile = new LazyLoaded( - new EpisodeFile - { - Id = 2, - RelativePath = @"Season 01\30.rock.s01e02.avi", - })) - .Build() - .ToList(); + _localMovie.Movie.MovieFileId = 1; + _localMovie.Movie.MovieFile = new LazyLoaded( + new MovieFile + { + Id = 1, + RelativePath = @"Season 01\30.rock.s01e01.avi", + }); } [Test] @@ -93,39 +53,21 @@ namespace NzbDrone.Core.Test.MediaFiles { GivenSingleEpisodeWithSingleEpisodeFile(); - Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode); - - Mocker.GetMock().Verify(v => v.DeleteFile(It.IsAny()), Times.Once()); - } - - [Test] - public void should_delete_the_same_episode_file_only_once() - { - GivenMultipleEpisodesWithSingleEpisodeFile(); - - Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode); + Subject.UpgradeMovieFile(_movieFile, _localMovie); Mocker.GetMock().Verify(v => v.DeleteFile(It.IsAny()), Times.Once()); } - [Test] - public void should_delete_multiple_different_episode_files() - { - GivenMultipleEpisodesWithMultipleEpisodeFiles(); - - Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode); - Mocker.GetMock().Verify(v => v.DeleteFile(It.IsAny()), Times.Exactly(2)); - } [Test] public void should_delete_episode_file_from_database() { GivenSingleEpisodeWithSingleEpisodeFile(); - Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode); + Subject.UpgradeMovieFile(_movieFile, _localMovie); - Mocker.GetMock().Verify(v => v.Delete(It.IsAny(), DeleteMediaFileReason.Upgrade), Times.Once()); + Mocker.GetMock().Verify(v => v.Delete(It.IsAny(), DeleteMediaFileReason.Upgrade), Times.Once()); } [Test] @@ -137,9 +79,9 @@ namespace NzbDrone.Core.Test.MediaFiles .Setup(c => c.FileExists(It.IsAny())) .Returns(false); - Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode); + Subject.UpgradeMovieFile(_movieFile, _localMovie); - Mocker.GetMock().Verify(v => v.Delete(_localEpisode.Episodes.Single().EpisodeFile.Value, DeleteMediaFileReason.Upgrade), Times.Once()); + Mocker.GetMock().Verify(v => v.Delete(_localMovie.Movie.MovieFile, DeleteMediaFileReason.Upgrade), Times.Once()); } [Test] @@ -151,7 +93,7 @@ namespace NzbDrone.Core.Test.MediaFiles .Setup(c => c.FileExists(It.IsAny())) .Returns(false); - Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode); + Subject.UpgradeMovieFile(_movieFile, _localMovie); Mocker.GetMock().Verify(v => v.DeleteFile(It.IsAny()), Times.Never()); } @@ -161,15 +103,7 @@ namespace NzbDrone.Core.Test.MediaFiles { GivenSingleEpisodeWithSingleEpisodeFile(); - Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode).OldFiles.Count.Should().Be(1); - } - - [Test] - public void should_return_old_episode_files_in_oldFiles() - { - GivenMultipleEpisodesWithMultipleEpisodeFiles(); - - Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode).OldFiles.Count.Should().Be(2); + Subject.UpgradeMovieFile(_movieFile, _localMovie).OldFiles.Count.Should().Be(1); } } } diff --git a/src/NzbDrone.Core.Test/Messaging/Commands/CommandEqualityComparerFixture.cs b/src/NzbDrone.Core.Test/Messaging/Commands/CommandEqualityComparerFixture.cs index c15e2cfd4..99fc460f9 100644 --- a/src/NzbDrone.Core.Test/Messaging/Commands/CommandEqualityComparerFixture.cs +++ b/src/NzbDrone.Core.Test/Messaging/Commands/CommandEqualityComparerFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.Indexers; @@ -24,17 +24,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands [Test] public void should_return_true_when_single_property_matches() { - var command1 = new EpisodeSearchCommand { EpisodeIds = new List{ 1 } }; - var command2 = new EpisodeSearchCommand { EpisodeIds = new List { 1 } }; - - CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeTrue(); - } - - [Test] - public void should_return_true_when_multiple_properties_match() - { - var command1 = new SeasonSearchCommand { SeriesId = 1, SeasonNumber = 1 }; - var command2 = new SeasonSearchCommand { SeriesId = 1, SeasonNumber = 1 }; + var command1 = new MoviesSearchCommand { MovieIds = new List{ 1 } }; + var command2 = new MoviesSearchCommand { MovieIds = new List { 1 } }; CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeTrue(); } @@ -42,44 +33,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands [Test] public void should_return_false_when_single_property_doesnt_match() { - var command1 = new EpisodeSearchCommand { EpisodeIds = new List { 1 } }; - var command2 = new EpisodeSearchCommand { EpisodeIds = new List { 2 } }; - - CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse(); - } - - [Test] - public void should_return_false_when_only_one_property_matches() - { - var command1 = new SeasonSearchCommand { SeriesId = 1, SeasonNumber = 1 }; - var command2 = new SeasonSearchCommand { SeriesId = 1, SeasonNumber = 2 }; - - CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse(); - } - - [Test] - public void should_return_false_when_no_properties_match() - { - var command1 = new SeasonSearchCommand { SeriesId = 1, SeasonNumber = 1 }; - var command2 = new SeasonSearchCommand { SeriesId = 2, SeasonNumber = 2 }; - - CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse(); - } - - [Test] - public void should_return_false_when_only_one_has_properties() - { - var command1 = new SeasonSearchCommand(); - var command2 = new SeasonSearchCommand { SeriesId = 2, SeasonNumber = 2 }; - - CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse(); - } - - [Test] - public void should_return_false_when_only_one_has_null_property() - { - var command1 = new EpisodeSearchCommand(null); - var command2 = new EpisodeSearchCommand(new List()); + var command1 = new MoviesSearchCommand { MovieIds = new List { 1 } }; + var command2 = new MoviesSearchCommand { MovieIds = new List { 2 } }; CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse(); } @@ -93,8 +48,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands [Test] public void should_return_false_when_commands_list_are_different_lengths() { - var command1 = new EpisodeSearchCommand { EpisodeIds = new List { 1 } }; - var command2 = new EpisodeSearchCommand { EpisodeIds = new List { 1, 2 } }; + var command1 = new MoviesSearchCommand { MovieIds = new List { 1 } }; + var command2 = new MoviesSearchCommand { MovieIds = new List { 1, 2 } }; CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse(); } @@ -102,8 +57,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands [Test] public void should_return_false_when_commands_list_dont_match() { - var command1 = new EpisodeSearchCommand { EpisodeIds = new List { 1 } }; - var command2 = new EpisodeSearchCommand { EpisodeIds = new List { 2 } }; + var command1 = new MoviesSearchCommand { MovieIds = new List { 1 } }; + var command2 = new MoviesSearchCommand { MovieIds = new List { 2 } }; CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeFalse(); } diff --git a/src/NzbDrone.Core.Test/Metadata/Consumers/Roksbox/FindMetadataFileFixture.cs b/src/NzbDrone.Core.Test/Metadata/Consumers/Roksbox/FindMetadataFileFixture.cs index 99fa8549f..6d075667f 100644 --- a/src/NzbDrone.Core.Test/Metadata/Consumers/Roksbox/FindMetadataFileFixture.cs +++ b/src/NzbDrone.Core.Test/Metadata/Consumers/Roksbox/FindMetadataFileFixture.cs @@ -5,7 +5,7 @@ using NUnit.Framework; using NzbDrone.Core.Extras.Metadata; using NzbDrone.Core.Extras.Metadata.Consumers.Roksbox; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.Metadata.Consumers.Roksbox diff --git a/src/NzbDrone.Core.Test/Metadata/Consumers/Wdtv/FindMetadataFileFixture.cs b/src/NzbDrone.Core.Test/Metadata/Consumers/Wdtv/FindMetadataFileFixture.cs index 9f73f68a0..e8d305f51 100644 --- a/src/NzbDrone.Core.Test/Metadata/Consumers/Wdtv/FindMetadataFileFixture.cs +++ b/src/NzbDrone.Core.Test/Metadata/Consumers/Wdtv/FindMetadataFileFixture.cs @@ -5,7 +5,7 @@ using NUnit.Framework; using NzbDrone.Core.Extras.Metadata; using NzbDrone.Core.Extras.Metadata.Consumers.Wdtv; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.Metadata.Consumers.Wdtv diff --git a/src/NzbDrone.Core.Test/MetadataSource/SearchSeriesComparerFixture.cs b/src/NzbDrone.Core.Test/MetadataSource/SearchMovieComparerFixture.cs similarity index 74% rename from src/NzbDrone.Core.Test/MetadataSource/SearchSeriesComparerFixture.cs rename to src/NzbDrone.Core.Test/MetadataSource/SearchMovieComparerFixture.cs index f7f9053dd..26a81f531 100644 --- a/src/NzbDrone.Core.Test/MetadataSource/SearchSeriesComparerFixture.cs +++ b/src/NzbDrone.Core.Test/MetadataSource/SearchMovieComparerFixture.cs @@ -1,27 +1,27 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.MetadataSource; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.MetadataSource { [TestFixture] - public class SearchSeriesComparerFixture : CoreTest + public class SearchMovieComparerFixture : CoreTest { - private List _series; + private List _series; [SetUp] public void Setup() { - _series = new List(); + _series = new List(); } private void WithSeries(string title) { - _series.Add(new Series { Title = title }); + _series.Add(new Movie { Title = title }); } [Test] @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.MetadataSource WithSeries("Talking Dead"); WithSeries("The Walking Dead"); - _series.Sort(new SearchSeriesComparer("the walking dead")); + _series.Sort(new SearchMovieComparer("the walking dead")); _series.First().Title.Should().Be("The Walking Dead"); } @@ -41,7 +41,7 @@ namespace NzbDrone.Core.Test.MetadataSource WithSeries("Talking Dead"); WithSeries("The Walking Dead"); - _series.Sort(new SearchSeriesComparer("walking dead")); + _series.Sort(new SearchMovieComparer("walking dead")); _series.First().Title.Should().Be("The Walking Dead"); } @@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.MetadataSource WithSeries("The Blacklist"); WithSeries("Blacklist"); - _series.Sort(new SearchSeriesComparer("blacklist")); + _series.Sort(new SearchMovieComparer("blacklist")); _series.First().Title.Should().Be("Blacklist"); } @@ -63,7 +63,7 @@ namespace NzbDrone.Core.Test.MetadataSource WithSeries("Blacklist"); WithSeries("The Blacklist"); - _series.Sort(new SearchSeriesComparer("the blacklist")); + _series.Sort(new SearchMovieComparer("the blacklist")); _series.First().Title.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 e6178c0d2..dff5b8895 100644 --- a/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxyFixture.cs +++ b/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxyFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using FluentAssertions; @@ -7,7 +7,7 @@ using NzbDrone.Core.Exceptions; using NzbDrone.Core.MediaCover; using NzbDrone.Core.MetadataSource.SkyHook; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common.Categories; namespace NzbDrone.Core.Test.MetadataSource.SkyHook @@ -25,85 +25,44 @@ namespace NzbDrone.Core.Test.MetadataSource.SkyHook [TestCase(75978, "Family Guy")] [TestCase(83462, "Castle (2009)")] [TestCase(266189, "The Blacklist")] - public void should_be_able_to_get_series_detail(int tvdbId, string title) + public void should_be_able_to_get_movie_detail(int tmdbId, string title) { - var details = Subject.GetSeriesInfo(tvdbId); + var details = Subject.GetMovieInfo(tmdbId); - ValidateSeries(details.Item1); - ValidateEpisodes(details.Item2); + ValidateMovie(details); - details.Item1.Title.Should().Be(title); + details.Title.Should().Be(title); } [Test] public void getting_details_of_invalid_series() { - Assert.Throws(() => Subject.GetSeriesInfo(int.MaxValue)); + Assert.Throws(() => Subject.GetMovieInfo(int.MaxValue)); } [Test] public void should_not_have_period_at_start_of_title_slug() { - var details = Subject.GetSeriesInfo(79099); + var details = Subject.GetMovieInfo(79099); - details.Item1.TitleSlug.Should().Be("dothack"); + details.TitleSlug.Should().Be("dothack"); } - private void ValidateSeries(Series series) + private void ValidateMovie(Movie movie) { - series.Should().NotBeNull(); - series.Title.Should().NotBeNullOrWhiteSpace(); - series.CleanTitle.Should().Be(Parser.Parser.CleanSeriesTitle(series.Title)); - series.SortTitle.Should().Be(SeriesTitleNormalizer.Normalize(series.Title, series.TvdbId)); - series.Overview.Should().NotBeNullOrWhiteSpace(); - series.AirTime.Should().NotBeNullOrWhiteSpace(); - series.FirstAired.Should().HaveValue(); - series.FirstAired.Value.Kind.Should().Be(DateTimeKind.Utc); - series.Images.Should().NotBeEmpty(); - series.ImdbId.Should().NotBeNullOrWhiteSpace(); - series.Network.Should().NotBeNullOrWhiteSpace(); - series.Runtime.Should().BeGreaterThan(0); - series.TitleSlug.Should().NotBeNullOrWhiteSpace(); + movie.Should().NotBeNull(); + movie.Title.Should().NotBeNullOrWhiteSpace(); + movie.CleanTitle.Should().Be(Parser.Parser.CleanSeriesTitle(movie.Title)); + movie.SortTitle.Should().Be(MovieTitleNormalizer.Normalize(movie.Title, movie.TmdbId)); + movie.Overview.Should().NotBeNullOrWhiteSpace(); + movie.PhysicalRelease.Should().HaveValue(); + movie.Images.Should().NotBeEmpty(); + movie.ImdbId.Should().NotBeNullOrWhiteSpace(); + movie.Studio.Should().NotBeNullOrWhiteSpace(); + movie.Runtime.Should().BeGreaterThan(0); + movie.TitleSlug.Should().NotBeNullOrWhiteSpace(); //series.TvRageId.Should().BeGreaterThan(0); - series.TvdbId.Should().BeGreaterThan(0); - } - - private void ValidateEpisodes(List episodes) - { - episodes.Should().NotBeEmpty(); - - var episodeGroup = episodes.GroupBy(e => e.SeasonNumber.ToString("000") + e.EpisodeNumber.ToString("000")); - episodeGroup.Should().OnlyContain(c => c.Count() == 1); - - episodes.Should().Contain(c => c.SeasonNumber > 0); - episodes.Should().Contain(c => !string.IsNullOrWhiteSpace(c.Overview)); - - foreach (var episode in episodes) - { - ValidateEpisode(episode); - - //if atleast one episdoe has title it means parse it working. - episodes.Should().Contain(c => !string.IsNullOrWhiteSpace(c.Title)); - } - } - - private void ValidateEpisode(Episode episode) - { - episode.Should().NotBeNull(); - - //TODO: Is there a better way to validate that episode number or season number is greater than zero? - (episode.EpisodeNumber + episode.SeasonNumber).Should().NotBe(0); - - episode.Should().NotBeNull(); - - if (episode.AirDateUtc.HasValue) - { - episode.AirDateUtc.Value.Kind.Should().Be(DateTimeKind.Utc); - } - - episode.Images.Any(i => i.CoverType == MediaCoverTypes.Screenshot && i.Url.Contains("-940.")) - .Should() - .BeFalse(); + movie.TmdbId.Should().BeGreaterThan(0); } } } diff --git a/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxySearchFixture.cs b/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxySearchFixture.cs index 2a34449ab..7233068d8 100644 --- a/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxySearchFixture.cs +++ b/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxySearchFixture.cs @@ -1,4 +1,4 @@ -using FluentAssertions; +using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.MetadataSource.SkyHook; using NzbDrone.Core.Test.Framework; @@ -25,12 +25,12 @@ namespace NzbDrone.Core.Test.MetadataSource.SkyHook //[TestCase("Rob & Big", "Rob & Big")] [TestCase("M*A*S*H", "M*A*S*H")] //[TestCase("imdb:tt0436992", "Doctor Who (2005)")] - [TestCase("tvdb:78804", "Doctor Who (2005)")] - [TestCase("tvdbid:78804", "Doctor Who (2005)")] - [TestCase("tvdbid: 78804 ", "Doctor Who (2005)")] + [TestCase("tmdb:78804", "Doctor Who (2005)")] + [TestCase("tmdbid:78804", "Doctor Who (2005)")] + [TestCase("tmdbid: 78804 ", "Doctor Who (2005)")] public void successful_search(string title, string expected) { - var result = Subject.SearchForNewSeries(title); + var result = Subject.SearchForNewMovie(title); result.Should().NotBeEmpty(); @@ -39,15 +39,15 @@ namespace NzbDrone.Core.Test.MetadataSource.SkyHook ExceptionVerification.IgnoreWarns(); } - [TestCase("tvdbid:")] - [TestCase("tvdbid: 99999999999999999999")] - [TestCase("tvdbid: 0")] - [TestCase("tvdbid: -12")] - [TestCase("tvdbid:289578")] + [TestCase("tmdbid:")] + [TestCase("tmdbid: 99999999999999999999")] + [TestCase("tmdbid: 0")] + [TestCase("tmdbid: -12")] + [TestCase("tmdbid:289578")] [TestCase("adjalkwdjkalwdjklawjdlKAJD;EF")] public void no_search_result(string term) { - var result = Subject.SearchForNewSeries(term); + var result = Subject.SearchForNewMovie(term); result.Should().BeEmpty(); ExceptionVerification.IgnoreWarns(); diff --git a/src/NzbDrone.Core.Test/TvTests/MoveSeriesServiceFixture.cs b/src/NzbDrone.Core.Test/MovieTests/MoveMovieServiceFixture.cs similarity index 52% rename from src/NzbDrone.Core.Test/TvTests/MoveSeriesServiceFixture.cs rename to src/NzbDrone.Core.Test/MovieTests/MoveMovieServiceFixture.cs index 528816c99..86b95a98d 100644 --- a/src/NzbDrone.Core.Test/TvTests/MoveSeriesServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MovieTests/MoveMovieServiceFixture.cs @@ -1,39 +1,39 @@ -using System.IO; +using System.IO; using FizzWare.NBuilder; using Moq; using NUnit.Framework; using NzbDrone.Common.Disk; using NzbDrone.Core.Organizer; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Tv.Commands; +using NzbDrone.Core.Movies; +using NzbDrone.Core.Movies.Commands; using NzbDrone.Test.Common; -namespace NzbDrone.Core.Test.TvTests +namespace NzbDrone.Core.Test.MovieTests { [TestFixture] - public class MoveSeriesServiceFixture : CoreTest + public class MoveMovieServiceFixture : CoreTest { - private Series _series; - private MoveSeriesCommand _command; + private Movie _movie; + private MoveMovieCommand _command; [SetUp] public void Setup() { - _series = Builder + _movie = Builder .CreateNew() .Build(); - _command = new MoveSeriesCommand + _command = new MoveMovieCommand { - SeriesId = 1, - SourcePath = @"C:\Test\TV\Series".AsOsAgnostic(), - DestinationPath = @"C:\Test\TV2\Series".AsOsAgnostic() + MovieId = 1, + SourcePath = @"C:\Test\Movies\Movie".AsOsAgnostic(), + DestinationPath = @"C:\Test\Movies2\Movie".AsOsAgnostic() }; - Mocker.GetMock() - .Setup(s => s.GetSeries(It.IsAny())) - .Returns(_series); + Mocker.GetMock() + .Setup(s => s.GetMovie(It.IsAny())) + .Returns(_movie); } private void GivenFailedMove() @@ -54,7 +54,7 @@ namespace NzbDrone.Core.Test.TvTests } [Test] - public void should_no_update_series_path_on_error() + public void should_no_update_movie_path_on_error() { GivenFailedMove(); @@ -62,26 +62,26 @@ namespace NzbDrone.Core.Test.TvTests ExceptionVerification.ExpectedErrors(1); - Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.IsAny()), Times.Never()); + Mocker.GetMock() + .Verify(v => v.UpdateMovie(It.IsAny()), Times.Never()); } [Test] public void should_build_new_path_when_root_folder_is_provided() { _command.DestinationPath = null; - _command.DestinationRootFolder = @"C:\Test\TV3".AsOsAgnostic(); + _command.DestinationRootFolder = @"C:\Test\Movie3".AsOsAgnostic(); var expectedPath = @"C:\Test\TV3\Series".AsOsAgnostic(); Mocker.GetMock() - .Setup(s => s.GetSeriesFolder(It.IsAny(), null)) - .Returns("Series"); + .Setup(s => s.GetMovieFolder(It.IsAny(), null)) + .Returns("Movie"); Subject.Execute(_command); - Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.Path == expectedPath)), Times.Once()); + Mocker.GetMock() + .Verify(v => v.UpdateMovie(It.Is(s => s.Path == expectedPath)), Times.Once()); } [Test] @@ -89,11 +89,11 @@ namespace NzbDrone.Core.Test.TvTests { Subject.Execute(_command); - Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.Path == _command.DestinationPath)), Times.Once()); + Mocker.GetMock() + .Verify(v => v.UpdateMovie(It.Is(s => s.Path == _command.DestinationPath)), Times.Once()); Mocker.GetMock() - .Verify(v => v.GetSeriesFolder(It.IsAny(), null), Times.Never()); + .Verify(v => v.GetMovieFolder(It.IsAny(), null), Times.Never()); } } } diff --git a/src/NzbDrone.Core.Test/TvTests/SeriesRepositoryTests/SeriesRepositoryFixture.cs b/src/NzbDrone.Core.Test/MovieTests/MovieRepositoryTests/MovieRepositoryFixture.cs similarity index 70% rename from src/NzbDrone.Core.Test/TvTests/SeriesRepositoryTests/SeriesRepositoryFixture.cs rename to src/NzbDrone.Core.Test/MovieTests/MovieRepositoryTests/MovieRepositoryFixture.cs index bbd18e7e1..c86e8559f 100644 --- a/src/NzbDrone.Core.Test/TvTests/SeriesRepositoryTests/SeriesRepositoryFixture.cs +++ b/src/NzbDrone.Core.Test/MovieTests/MovieRepositoryTests/MovieRepositoryFixture.cs @@ -4,13 +4,13 @@ using NUnit.Framework; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; -namespace NzbDrone.Core.Test.TvTests.SeriesRepositoryTests +namespace NzbDrone.Core.Test.MovieTests.MovieRepositoryTests { [TestFixture] - public class SeriesRepositoryFixture : DbTest + public class MovieRepositoryFixture : DbTest { [Test] public void should_lazyload_quality_profile() @@ -26,10 +26,10 @@ namespace NzbDrone.Core.Test.TvTests.SeriesRepositoryTests Mocker.Resolve().Insert(profile); - var series = Builder.CreateNew().BuildNew(); - series.ProfileId = profile.Id; + var movie = Builder.CreateNew().BuildNew(); + movie.ProfileId = profile.Id; - Subject.Insert(series); + Subject.Insert(movie); StoredModel.Profile.Should().NotBeNull(); @@ -37,4 +37,4 @@ namespace NzbDrone.Core.Test.TvTests.SeriesRepositoryTests } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core.Test/MovieTests/MovieServiceTests/AddMovieFixture.cs b/src/NzbDrone.Core.Test/MovieTests/MovieServiceTests/AddMovieFixture.cs new file mode 100644 index 000000000..9013c9776 --- /dev/null +++ b/src/NzbDrone.Core.Test/MovieTests/MovieServiceTests/AddMovieFixture.cs @@ -0,0 +1,39 @@ +using FizzWare.NBuilder; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.Organizer; +using NzbDrone.Core.Movies; +using NzbDrone.Core.Test.Framework; +using NzbDrone.Core.Movies.Events; + +namespace NzbDrone.Core.Test.MovieTests.MovieServiceTests +{ + [TestFixture] + public class AddMovieFixture : CoreTest + { + private Movie fakeMovie; + + [SetUp] + public void Setup() + { + fakeMovie = Builder.CreateNew().Build(); + } + + [Test] + public void movie_added_event_should_have_proper_path() + { + fakeMovie.Path = null; + fakeMovie.RootFolderPath = @"C:\Test\Movies"; + + Mocker.GetMock() + .Setup(s => s.GetMovieFolder(fakeMovie, null)) + .Returns(fakeMovie.Title); + + var series = Subject.AddMovie(fakeMovie); + + series.Path.Should().NotBeNull(); + + } + + } +} diff --git a/src/NzbDrone.Core.Test/MovieTests/MovieServiceTests/UpdateMovieFixture.cs b/src/NzbDrone.Core.Test/MovieTests/MovieServiceTests/UpdateMovieFixture.cs new file mode 100644 index 000000000..0560cd1f4 --- /dev/null +++ b/src/NzbDrone.Core.Test/MovieTests/MovieServiceTests/UpdateMovieFixture.cs @@ -0,0 +1,42 @@ +using System.Collections.Generic; +using System.Linq; +using FizzWare.NBuilder; +using Moq; +using NUnit.Framework; +using NzbDrone.Core.Movies; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.MovieTests.MovieServiceTests +{ + [TestFixture] + public class UpdateMovieFixture : CoreTest + { + private Movie _fakeMovie; + private Movie _existingMovie; + + [SetUp] + public void Setup() + { + _fakeMovie = Builder.CreateNew().Build(); + _existingMovie = Builder.CreateNew().Build(); + } + + private void GivenExistingSeries() + { + Mocker.GetMock() + .Setup(s => s.GetMovie(It.IsAny())) + .Returns(_existingMovie); + } + + [Test] + public void should_update_movie_when_it_changes() + { + GivenExistingSeries(); + + Subject.UpdateMovie(_fakeMovie); + + Mocker.GetMock() + .Verify(v => v.Update(_fakeMovie), Times.Once()); + } + } +} diff --git a/src/NzbDrone.Core.Test/TvTests/SeriesServiceTests/UpdateMultipleSeriesFixture.cs b/src/NzbDrone.Core.Test/MovieTests/MovieServiceTests/UpdateMultipleMoviesFixture.cs similarity index 52% rename from src/NzbDrone.Core.Test/TvTests/SeriesServiceTests/UpdateMultipleSeriesFixture.cs rename to src/NzbDrone.Core.Test/MovieTests/MovieServiceTests/UpdateMultipleMoviesFixture.cs index 0fa33a68f..e5606c670 100644 --- a/src/NzbDrone.Core.Test/TvTests/SeriesServiceTests/UpdateMultipleSeriesFixture.cs +++ b/src/NzbDrone.Core.Test/MovieTests/MovieServiceTests/UpdateMultipleMoviesFixture.cs @@ -1,73 +1,72 @@ -using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using Moq; -using NUnit.Framework; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Test.Common; - -namespace NzbDrone.Core.Test.TvTests.SeriesServiceTests -{ - [TestFixture] - public class UpdateMultipleSeriesFixture : CoreTest - { - private List _series; - - [SetUp] - public void Setup() - { - _series = Builder.CreateListOfSize(5) - .All() - .With(s => s.ProfileId = 1) - .With(s => s.Monitored) - .With(s => s.SeasonFolder) - .With(s => s.Path = @"C:\Test\name".AsOsAgnostic()) - .With(s => s.RootFolderPath = "") - .Build().ToList(); - } - - [Test] - public void should_call_repo_updateMany() - { - Subject.UpdateSeries(_series); - - Mocker.GetMock().Verify(v => v.UpdateMany(_series), Times.Once()); - } - - [Test] - public void should_update_path_when_rootFolderPath_is_supplied() - { - var newRoot = @"C:\Test\TV2".AsOsAgnostic(); - _series.ForEach(s => s.RootFolderPath = newRoot); - - Subject.UpdateSeries(_series).ForEach(s => s.Path.Should().StartWith(newRoot)); - } - - [Test] - public void should_not_update_path_when_rootFolderPath_is_empty() - { - Subject.UpdateSeries(_series).ForEach(s => - { - var expectedPath = _series.Single(ser => ser.Id == s.Id).Path; - s.Path.Should().Be(expectedPath); - }); - } - - [Test] - public void should_be_able_to_update_many_series() - { - var series = Builder.CreateListOfSize(50) - .All() - .With(s => s.Path = (@"C:\Test\TV\" + s.Path).AsOsAgnostic()) - .Build() - .ToList(); - - var newRoot = @"C:\Test\TV2".AsOsAgnostic(); - series.ForEach(s => s.RootFolderPath = newRoot); - - Subject.UpdateSeries(series); - } - } -} \ No newline at end of file +using System.Collections.Generic; +using System.Linq; +using FizzWare.NBuilder; +using FluentAssertions; +using Moq; +using NUnit.Framework; +using NzbDrone.Core.Movies; +using NzbDrone.Core.Test.Framework; +using NzbDrone.Test.Common; + +namespace NzbDrone.Core.Test.MovieTests.MovieServiceTests +{ + [TestFixture] + public class UpdateMultipleMoviesFixture : CoreTest + { + private List _movies; + + [SetUp] + public void Setup() + { + _movies = Builder.CreateListOfSize(5) + .All() + .With(s => s.ProfileId = 1) + .With(s => s.Monitored) + .With(s => s.Path = @"C:\Test\name".AsOsAgnostic()) + .With(s => s.RootFolderPath = "") + .Build().ToList(); + } + + [Test] + public void should_call_repo_updateMany() + { + Subject.UpdateMovie(_movies); + + Mocker.GetMock().Verify(v => v.UpdateMany(_movies), Times.Once()); + } + + [Test] + public void should_update_path_when_rootFolderPath_is_supplied() + { + var newRoot = @"C:\Test\TV2".AsOsAgnostic(); + _movies.ForEach(s => s.RootFolderPath = newRoot); + + Subject.UpdateMovie(_movies).ForEach(s => s.Path.Should().StartWith(newRoot)); + } + + [Test] + public void should_not_update_path_when_rootFolderPath_is_empty() + { + Subject.UpdateMovie(_movies).ForEach(s => + { + var expectedPath = _movies.Single(ser => ser.Id == s.Id).Path; + s.Path.Should().Be(expectedPath); + }); + } + + [Test] + public void should_be_able_to_update_many_movies() + { + var movies = Builder.CreateListOfSize(50) + .All() + .With(s => s.Path = (@"C:\Test\Movies\" + s.Path).AsOsAgnostic()) + .Build() + .ToList(); + + var newRoot = @"C:\Test\Movies2".AsOsAgnostic(); + movies.ForEach(s => s.RootFolderPath = newRoot); + + Subject.UpdateMovie(movies); + } + } +} diff --git a/src/NzbDrone.Core.Test/TvTests/SeriesTitleNormalizerFixture.cs b/src/NzbDrone.Core.Test/MovieTests/MovieTitleNormalizerFixture.cs similarity index 73% rename from src/NzbDrone.Core.Test/TvTests/SeriesTitleNormalizerFixture.cs rename to src/NzbDrone.Core.Test/MovieTests/MovieTitleNormalizerFixture.cs index 4355f77e0..47f3a6cce 100644 --- a/src/NzbDrone.Core.Test/TvTests/SeriesTitleNormalizerFixture.cs +++ b/src/NzbDrone.Core.Test/MovieTests/MovieTitleNormalizerFixture.cs @@ -1,17 +1,17 @@ -using FluentAssertions; +using FluentAssertions; using NUnit.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; -namespace NzbDrone.Core.Test.TvTests +namespace NzbDrone.Core.Test.MovieTests { [TestFixture] - public class SeriesTitleNormalizerFixture + public class MovieTitleNormalizerFixture { [TestCase("A to Z", 281588, "a to z")] [TestCase("A. D. - The Trials & Triumph of the Early Church", 266757, "ad trials triumph early church")] public void should_use_precomputed_title(string title, int tvdbId, string expected) { - SeriesTitleNormalizer.Normalize(title, tvdbId).Should().Be(expected); + MovieTitleNormalizer.Normalize(title, tvdbId).Should().Be(expected); } [TestCase("2 Broke Girls", "2 broke girls")] @@ -23,7 +23,7 @@ namespace NzbDrone.Core.Test.TvTests [TestCase("Special Agent Oso", "special agent oso")] public void should_normalize_title(string title, string expected) { - SeriesTitleNormalizer.Normalize(title, 0).Should().Be(expected); + MovieTitleNormalizer.Normalize(title, 0).Should().Be(expected); } } } diff --git a/src/NzbDrone.Core.Test/MovieTests/RefreshMovieServiceFixture.cs b/src/NzbDrone.Core.Test/MovieTests/RefreshMovieServiceFixture.cs new file mode 100644 index 000000000..060972250 --- /dev/null +++ b/src/NzbDrone.Core.Test/MovieTests/RefreshMovieServiceFixture.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using FizzWare.NBuilder; +using Moq; +using NUnit.Framework; +using NzbDrone.Common.Extensions; +using NzbDrone.Core.Exceptions; +using NzbDrone.Core.MetadataSource; +using NzbDrone.Core.Profiles; +using NzbDrone.Core.Test.Framework; +using NzbDrone.Core.Movies; +using NzbDrone.Core.Movies.Commands; +using NzbDrone.Test.Common; + +namespace NzbDrone.Core.Test.MovieTests +{ + [TestFixture] + public class RefreshMovieServiceFixture : CoreTest + { + private Movie _movie; + + [SetUp] + public void Setup() + { + _movie = Builder.CreateNew() + .Build(); + + Mocker.GetMock() + .Setup(s => s.GetMovie(_movie.Id)) + .Returns(_movie); + + Mocker.GetMock() + .Setup(s => s.GetMovieInfo(It.IsAny(), It.IsAny(), false)) + .Callback(p => { throw new MovieNotFoundException(p.ToString()); }); + } + + private void GivenNewMovieInfo(Movie movie) + { + Mocker.GetMock() + .Setup(s => s.GetMovieInfo(_movie.ImdbId)) + .Returns(movie); + } + + [Test] + public void should_update_tvrage_id_if_changed() + { + var newSeriesInfo = _movie.JsonClone(); + newSeriesInfo.ImdbId = _movie.ImdbId + 1; + + GivenNewMovieInfo(newSeriesInfo); + + Subject.Execute(new RefreshMovieCommand(_movie.Id)); + + Mocker.GetMock() + .Verify(v => v.UpdateMovie(It.Is(s => s.ImdbId == newSeriesInfo.ImdbId))); + } + + [Test] + public void should_log_error_if_tmdb_id_not_found() + { + Subject.Execute(new RefreshMovieCommand(_movie.Id)); + + Mocker.GetMock() + .Verify(v => v.UpdateMovie(It.IsAny()), Times.Never()); + + ExceptionVerification.ExpectedErrors(1); + } + + [Test] + public void should_update_if_tmdb_id_changed() + { + var newSeriesInfo = _movie.JsonClone(); + newSeriesInfo.TmdbId = _movie.TmdbId + 1; + + GivenNewMovieInfo(newSeriesInfo); + + Subject.Execute(new RefreshMovieCommand(_movie.Id)); + + Mocker.GetMock() + .Verify(v => v.UpdateMovie(It.Is(s => s.TmdbId == newSeriesInfo.TmdbId))); + + ExceptionVerification.ExpectedWarns(1); + } + } +} diff --git a/src/NzbDrone.Core.Test/MovieTests/ShouldRefreshMovieFixture.cs b/src/NzbDrone.Core.Test/MovieTests/ShouldRefreshMovieFixture.cs new file mode 100644 index 000000000..2847d21aa --- /dev/null +++ b/src/NzbDrone.Core.Test/MovieTests/ShouldRefreshMovieFixture.cs @@ -0,0 +1,125 @@ +using System; +using System.Linq; +using FizzWare.NBuilder; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.Movies; +using NzbDrone.Test.Common; + +namespace NzbDrone.Core.Test.MovieTests +{ + [TestFixture] + public class ShouldRefreshMovieFixture : TestBase + { + private Movie _movie; + + [SetUp] + public void Setup() + { + _movie = Builder.CreateNew() + .With(v => v.Status == MovieStatusType.InCinemas) + .With(m => m.PhysicalRelease = DateTime.Today.AddDays(-100)) + .Build(); + } + + private void GivenMovieIsAnnouced() + { + _movie.Status = MovieStatusType.Announced; + } + + private void GivenMovieIsReleased() + { + _movie.Status = MovieStatusType.Released; + } + + private void GivenMovieLastRefreshedMonthsAgo() + { + _movie.LastInfoSync = DateTime.UtcNow.AddDays(-90); + } + + private void GivenMovieLastRefreshedYesterday() + { + _movie.LastInfoSync = DateTime.UtcNow.AddDays(-1); + } + + private void GivenMovieLastRefreshedHalfADayAgo() + { + _movie.LastInfoSync = DateTime.UtcNow.AddHours(-12); + } + + private void GivenMovieLastRefreshedRecently() + { + _movie.LastInfoSync = DateTime.UtcNow.AddHours(-1); + } + + private void GivenRecentlyReleased() + { + _movie.PhysicalRelease = DateTime.Today.AddDays(-7); + } + + [Test] + public void should_return_true_if_in_cinemas_movie_last_refreshed_more_than_6_hours_ago() + { + GivenMovieLastRefreshedHalfADayAgo(); + + Subject.ShouldRefresh(_movie).Should().BeTrue(); + } + + [Test] + public void should_return_false_if_in_cinemas_movie_last_refreshed_less_than_6_hours_ago() + { + GivenMovieLastRefreshedRecently(); + + Subject.ShouldRefresh(_movie).Should().BeFalse(); + } + + [Test] + public void should_return_false_if_released_movie_last_refreshed_yesterday() + { + GivenMovieIsReleased(); + GivenMovieLastRefreshedYesterday(); + + Subject.ShouldRefresh(_movie).Should().BeFalse(); + } + + [Test] + public void should_return_true_if_movie_last_refreshed_more_than_30_days_ago() + { + GivenMovieIsReleased(); + GivenMovieLastRefreshedMonthsAgo(); + + Subject.ShouldRefresh(_movie).Should().BeTrue(); + } + + [Test] + public void should_return_true_if_episode_aired_in_last_30_days() + { + GivenMovieIsReleased(); + GivenMovieLastRefreshedYesterday(); + + GivenRecentlyReleased(); + + Subject.ShouldRefresh(_movie).Should().BeTrue(); + } + + [Test] + public void should_return_false_when_recently_refreshed_released_movie_released_30_days() + { + GivenMovieIsReleased(); + GivenMovieLastRefreshedYesterday(); + + Subject.ShouldRefresh(_movie).Should().BeFalse(); + } + + [Test] + public void should_return_false_when_recently_refreshed_ended_show_aired_in_last_30_days() + { + GivenMovieIsReleased(); + GivenMovieLastRefreshedRecently(); + + GivenRecentlyReleased(); + + Subject.ShouldRefresh(_movie).Should().BeFalse(); + } + } +} diff --git a/src/NzbDrone.Core.Test/NotificationTests/SynologyIndexerFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/SynologyIndexerFixture.cs index b80f35309..10f409804 100644 --- a/src/NzbDrone.Core.Test/NotificationTests/SynologyIndexerFixture.cs +++ b/src/NzbDrone.Core.Test/NotificationTests/SynologyIndexerFixture.cs @@ -5,7 +5,7 @@ using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Notifications; using NzbDrone.Core.Notifications.Synology; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.NotificationTests diff --git a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetMoviePathFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetMoviePathFixture.cs index f75a5dddf..d72e2c8f8 100644 --- a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetMoviePathFixture.cs +++ b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetMoviePathFixture.cs @@ -6,7 +6,7 @@ using NUnit.Framework; using NzbDrone.Core.Notifications.Xbmc; using NzbDrone.Core.Notifications.Xbmc.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json { diff --git a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/UpdateMovieFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/UpdateMovieFixture.cs index 3989646bf..9bc85faa0 100644 --- a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/UpdateMovieFixture.cs +++ b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/UpdateMovieFixture.cs @@ -6,7 +6,7 @@ using NUnit.Framework; using NzbDrone.Core.Notifications.Xbmc; using NzbDrone.Core.Notifications.Xbmc.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json { diff --git a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/OnDownloadFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/OnDownloadFixture.cs index f1676bace..12ae9883b 100644 --- a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/OnDownloadFixture.cs +++ b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/OnDownloadFixture.cs @@ -7,7 +7,7 @@ using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Notifications; using NzbDrone.Core.Notifications.Xbmc; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.NotificationTests.Xbmc { diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index d59ea9a1a..fdf73fc16 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -92,12 +92,8 @@ True - - - - @@ -116,9 +112,6 @@ - - - @@ -145,14 +138,12 @@ - - - + @@ -163,8 +154,7 @@ - - + @@ -234,8 +224,7 @@ - - + @@ -244,8 +233,6 @@ - - @@ -261,7 +248,6 @@ - @@ -279,30 +265,26 @@ - - - - - - - - - + + + + + + + + - + - - - @@ -312,7 +294,7 @@ - + @@ -322,28 +304,18 @@ - - - - - - - - - - + - @@ -360,28 +332,16 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + @@ -577,7 +537,6 @@ - @@ -593,11 +552,11 @@ - \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/OrganizerTests/BuildFilePathFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/BuildFilePathFixture.cs deleted file mode 100644 index e2fafaac7..000000000 --- a/src/NzbDrone.Core.Test/OrganizerTests/BuildFilePathFixture.cs +++ /dev/null @@ -1,64 +0,0 @@ -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Organizer; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Test.Common; - -namespace NzbDrone.Core.Test.OrganizerTests -{ - [TestFixture] - - public class BuildFilePathFixture : CoreTest - { - private NamingConfig namingConfig; - - [SetUp] - public void Setup() - { - namingConfig = NamingConfig.Default; - - Mocker.GetMock() - .Setup(c => c.GetConfig()).Returns(namingConfig); - } - - [Test] - [TestCase("30 Rock - S01E05 - Episode Title", 1, true, "Season {season:00}", @"C:\Test\30 Rock\Season 01\30 Rock - S01E05 - Episode Title.mkv")] - [TestCase("30 Rock - S01E05 - Episode Title", 1, true, "Season {season}", @"C:\Test\30 Rock\Season 1\30 Rock - S01E05 - Episode Title.mkv")] - [TestCase("30 Rock - S01E05 - Episode Title", 1, false, "Season {season:00}", @"C:\Test\30 Rock\30 Rock - S01E05 - Episode Title.mkv")] - [TestCase("30 Rock - S01E05 - Episode Title", 1, false, "Season {season}", @"C:\Test\30 Rock\30 Rock - S01E05 - Episode Title.mkv")] - [TestCase("30 Rock - S01E05 - Episode Title", 1, true, "ReallyUglySeasonFolder {season}", @"C:\Test\30 Rock\ReallyUglySeasonFolder 1\30 Rock - S01E05 - Episode Title.mkv")] - [TestCase("30 Rock - S00E05 - Episode Title", 0, true, "Season {season}", @"C:\Test\30 Rock\Specials\30 Rock - S00E05 - Episode Title.mkv")] - public void CalculateFilePath_SeasonFolder_SingleNumber(string filename, int seasonNumber, bool useSeasonFolder, string seasonFolderFormat, string expectedPath) - { - var fakeSeries = Builder.CreateNew() - .With(s => s.Title = "30 Rock") - .With(s => s.Path = @"C:\Test\30 Rock".AsOsAgnostic()) - .With(s => s.SeasonFolder = useSeasonFolder) - .Build(); - - namingConfig.SeasonFolderFormat = seasonFolderFormat; - - Subject.BuildFilePath(fakeSeries, seasonNumber, filename, ".mkv").Should().Be(expectedPath.AsOsAgnostic()); - } - - [Test] - public void should_clean_season_folder_when_it_contains_illegal_characters_in_series_title() - { - var filename = @"S01E05 - Episode Title"; - var seasonNumber = 1; - var expectedPath = @"C:\Test\NCIS Los Angeles\NCIS Los Angeles Season 1\S01E05 - Episode Title.mkv"; - - var fakeSeries = Builder.CreateNew() - .With(s => s.Title = "NCIS: Los Angeles") - .With(s => s.Path = @"C:\Test\NCIS Los Angeles".AsOsAgnostic()) - .With(s => s.SeasonFolder = true) - .Build(); - - namingConfig.SeasonFolderFormat = "{Series Title} Season {season:0}"; - - Subject.BuildFilePath(fakeSeries, seasonNumber, filename, ".mkv").Should().Be(expectedPath.AsOsAgnostic()); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/CleanTitleFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/CleanTitleFixture.cs index f6aabeb9d..e66edbe2b 100644 --- a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/CleanTitleFixture.cs +++ b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/CleanTitleFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using FizzWare.NBuilder; using FluentAssertions; @@ -7,34 +7,26 @@ using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Organizer; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests { [TestFixture] public class CleanTitleFixture : CoreTest { - private Series _series; - private Episode _episode; - private EpisodeFile _episodeFile; + private Movie _series; + private MovieFile _episodeFile; private NamingConfig _namingConfig; [SetUp] public void Setup() { - _series = Builder - .CreateNew() - .With(s => s.Title = "South Park") - .Build(); + _series = Builder + .CreateNew() + .With(s => s.Title = "South Park") + .Build(); - _episode = Builder.CreateNew() - .With(e => e.Title = "City Sushi") - .With(e => e.SeasonNumber = 15) - .With(e => e.EpisodeNumber = 6) - .With(e => e.AbsoluteEpisodeNumber = 100) - .Build(); - - _episodeFile = new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p), ReleaseGroup = "SonarrTest" }; + _episodeFile = new MovieFile { Quality = new QualityModel(Quality.HDTV720p), ReleaseGroup = "SonarrTest" }; _namingConfig = NamingConfig.Default; _namingConfig.RenameEpisodes = true; @@ -69,27 +61,10 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_get_expected_title_back(string title, string expected) { _series.Title = title; - _namingConfig.StandardEpisodeFormat = "{Series CleanTitle}"; + _namingConfig.StandardMovieFormat = "{Movie CleanTitle}"; - Subject.BuildFileName(new List { _episode }, _series, _episodeFile) + Subject.BuildFileName(_series, _episodeFile) .Should().Be(expected); } - - [Test] - public void should_use_and_as_separator_for_multiple_episodes() - { - var episodes = Builder.CreateListOfSize(2) - .TheFirst(1) - .With(e => e.Title = "Surrender Benson") - .TheNext(1) - .With(e => e.Title = "Imprisoned Lives") - .Build() - .ToList(); - - _namingConfig.StandardEpisodeFormat = "{Episode CleanTitle}"; - - Subject.BuildFileName(episodes, _series, _episodeFile) - .Should().Be(episodes.First().Title + " and " + episodes.Last().Title); - } } } diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/EpisodeTitleCollapseFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/EpisodeTitleCollapseFixture.cs deleted file mode 100644 index f4da13b5b..000000000 --- a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/EpisodeTitleCollapseFixture.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Organizer; -using NzbDrone.Core.Qualities; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests -{ - [TestFixture] - public class EpisodeTitleCollapseFixture : CoreTest - { - private Series _series; - private Episode _episode1; - private Episode _episode2; - private Episode _episode3; - private EpisodeFile _episodeFile; - private NamingConfig _namingConfig; - - [SetUp] - public void Setup() - { - _series = Builder - .CreateNew() - .With(s => s.Title = "South Park") - .Build(); - - - _namingConfig = NamingConfig.Default; - _namingConfig.RenameEpisodes = true; - - - Mocker.GetMock() - .Setup(c => c.GetConfig()).Returns(_namingConfig); - - _episode1 = Builder.CreateNew() - .With(e => e.Title = "City Sushi") - .With(e => e.SeasonNumber = 15) - .With(e => e.EpisodeNumber = 6) - .With(e => e.AbsoluteEpisodeNumber = 100) - .Build(); - - _episode2 = Builder.CreateNew() - .With(e => e.Title = "City Sushi") - .With(e => e.SeasonNumber = 15) - .With(e => e.EpisodeNumber = 7) - .With(e => e.AbsoluteEpisodeNumber = 101) - .Build(); - - _episode3 = Builder.CreateNew() - .With(e => e.Title = "City Sushi") - .With(e => e.SeasonNumber = 15) - .With(e => e.EpisodeNumber = 8) - .With(e => e.AbsoluteEpisodeNumber = 102) - .Build(); - - _episodeFile = new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p), ReleaseGroup = "SonarrTest" }; - - Mocker.GetMock() - .Setup(v => v.Get(Moq.It.IsAny())) - .Returns(v => Quality.DefaultQualityDefinitions.First(c => c.Quality == v)); - } - - - [TestCase("Hey, Baby, What's Wrong (1)", "Hey, Baby, What's Wrong (2)", "Hey, Baby, What's Wrong")] - [TestCase("Meet the Guys and Girls of Cycle 20 Part 1", "Meet the Guys and Girls of Cycle 20 Part 2", "Meet the Guys and Girls of Cycle 20")] - [TestCase("Meet the Guys and Girls of Cycle 20 Part1", "Meet the Guys and Girls of Cycle 20 Part2", "Meet the Guys and Girls of Cycle 20")] - [TestCase("Meet the Guys and Girls of Cycle 20 Part01", "Meet the Guys and Girls of Cycle 20 Part02", "Meet the Guys and Girls of Cycle 20")] - [TestCase("Meet the Guys and Girls of Cycle 20 Part 01", "Meet the Guys and Girls of Cycle 20 Part 02", "Meet the Guys and Girls of Cycle 20")] - [TestCase("Meet the Guys and Girls of Cycle 20 part 1", "Meet the Guys and Girls of Cycle 20 part 2", "Meet the Guys and Girls of Cycle 20")] - [TestCase("Meet the Guys and Girls of Cycle 20 pt 1", "Meet the Guys and Girls of Cycle 20 pt 2", "Meet the Guys and Girls of Cycle 20")] - [TestCase("Meet the Guys and Girls of Cycle 20 pt. 1", "Meet the Guys and Girls of Cycle 20 pt. 2", "Meet the Guys and Girls of Cycle 20")] - public void should_collapse_episode_titles_when_episode_titles_are_the_same(string title1, string title2, string expected) - { - _namingConfig.StandardEpisodeFormat = "{Episode Title}"; - - _episode1.Title = title1; - _episode2.Title = title2; - - Subject.BuildFileName(new List { _episode1, _episode2 }, _series, _episodeFile) - .Should().Be(expected); - } - - [Test] - public void should_not_collapse_episode_titles_when_episode_titles_are_not_the_same() - { - _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = 3; - - _episode1.Title = "Hello"; - _episode2.Title = "World"; - - Subject.BuildFileName(new List { _episode1, _episode2 }, _series, _episodeFile) - .Should().Be("South Park - S15E06-E07 - Hello + World"); - } - - [Test] - public void should_not_collaspe_when_result_is_empty() - { - _namingConfig.StandardEpisodeFormat = "{Episode Title}"; - - _episode1.Title = "Part 1"; - _episode2.Title = "Part 2"; - - Subject.BuildFileName(new List { _episode1, _episode2 }, _series, _episodeFile) - .Should().Be("Part 1 + Part 2"); - } - } -} diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/FileNameBuilderFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/FileNameBuilderFixture.cs index b5777716e..bc154e6b5 100644 --- a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/FileNameBuilderFixture.cs +++ b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/FileNameBuilderFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Linq; using FizzWare.NBuilder; @@ -8,7 +8,7 @@ using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Organizer; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests { @@ -16,15 +16,14 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public class FileNameBuilderFixture : CoreTest { - private Series _series; - private Episode _episode1; - private EpisodeFile _episodeFile; + private Movie _movie; + private MovieFile _movieFile; private NamingConfig _namingConfig; [SetUp] public void Setup() { - _series = Builder + _movie = Builder .CreateNew() .With(s => s.Title = "South Park") .Build(); @@ -37,14 +36,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests Mocker.GetMock() .Setup(c => c.GetConfig()).Returns(_namingConfig); - _episode1 = Builder.CreateNew() - .With(e => e.Title = "City Sushi") - .With(e => e.SeasonNumber = 15) - .With(e => e.EpisodeNumber = 6) - .With(e => e.AbsoluteEpisodeNumber = 100) - .Build(); - - _episodeFile = new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p), ReleaseGroup = "SonarrTest" }; + _movieFile = new MovieFile { Quality = new QualityModel(Quality.HDTV720p), ReleaseGroup = "SonarrTest" }; Mocker.GetMock() .Setup(v => v.Get(Moq.It.IsAny())) @@ -53,180 +45,125 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests private void GivenProper() { - _episodeFile.Quality.Revision.Version = 2; + _movieFile.Quality.Revision.Version = 2; } private void GivenReal() { - _episodeFile.Quality.Revision.Real = 1; + _movieFile.Quality.Revision.Real = 1; } [Test] - public void should_replace_Series_space_Title() + public void should_replace_Movie_space_Title() { - _namingConfig.StandardEpisodeFormat = "{Series Title}"; + _namingConfig.StandardMovieFormat = "{Movie Title}"; - Subject.BuildFileName(new List {_episode1}, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("South Park"); } [Test] - public void should_replace_Series_underscore_Title() + public void should_replace_Movie_underscore_Title() { - _namingConfig.StandardEpisodeFormat = "{Series_Title}"; + _namingConfig.StandardMovieFormat = "{Movie_Title}"; - Subject.BuildFileName(new List {_episode1}, _series, _episodeFile) + Subject.BuildFileName( _movie, _movieFile) .Should().Be("South_Park"); } [Test] - public void should_replace_Series_dot_Title() + public void should_replace_Movie_dot_Title() { - _namingConfig.StandardEpisodeFormat = "{Series.Title}"; + _namingConfig.StandardMovieFormat = "{Movie.Title}"; - Subject.BuildFileName(new List {_episode1}, _series, _episodeFile) + Subject.BuildFileName( _movie, _movieFile) .Should().Be("South.Park"); } [Test] - public void should_replace_Series_dash_Title() + public void should_replace_Movie_dash_Title() { - _namingConfig.StandardEpisodeFormat = "{Series-Title}"; + _namingConfig.StandardMovieFormat = "{Movie-Title}"; - Subject.BuildFileName(new List {_episode1}, _series, _episodeFile) + Subject.BuildFileName( _movie, _movieFile) .Should().Be("South-Park"); } [Test] public void should_replace_SERIES_TITLE_with_all_caps() { - _namingConfig.StandardEpisodeFormat = "{SERIES TITLE}"; + _namingConfig.StandardMovieFormat = "{SERIES TITLE}"; - Subject.BuildFileName(new List {_episode1}, _series, _episodeFile) + Subject.BuildFileName( _movie, _movieFile) .Should().Be("SOUTH PARK"); } [Test] public void should_replace_SERIES_TITLE_with_random_casing_should_keep_original_casing() { - _namingConfig.StandardEpisodeFormat = "{sErIES-tItLE}"; + _namingConfig.StandardMovieFormat = "{sErIES-tItLE}"; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be(_series.Title.Replace(' ', '-')); + Subject.BuildFileName(_movie, _movieFile) + .Should().Be(_movie.Title.Replace(' ', '-')); } [Test] public void should_replace_series_title_with_all_lower_case() { - _namingConfig.StandardEpisodeFormat = "{series title}"; + _namingConfig.StandardMovieFormat = "{series title}"; - Subject.BuildFileName(new List {_episode1}, _series, _episodeFile) + Subject.BuildFileName( _movie, _movieFile) .Should().Be("south park"); } [Test] - public void should_cleanup_Series_Title() + public void should_cleanup_Movie_Title() { - _namingConfig.StandardEpisodeFormat = "{Series.CleanTitle}"; - _series.Title = "South Park (1997)"; + _namingConfig.StandardMovieFormat = "{Movie.CleanTitle}"; + _movie.Title = "South Park (1997)"; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("South.Park.1997"); } - [Test] - public void should_replace_episode_title() - { - _namingConfig.StandardEpisodeFormat = "{Episode Title}"; - - Subject.BuildFileName(new List {_episode1}, _series, _episodeFile) - .Should().Be("City Sushi"); - } - - [Test] - public void should_replace_episode_title_if_pattern_has_random_casing() - { - _namingConfig.StandardEpisodeFormat = "{ePisOde-TitLe}"; - - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("City-Sushi"); - } - [Test] - public void should_replace_season_number_with_single_digit() - { - _episode1.SeasonNumber = 1; - _namingConfig.StandardEpisodeFormat = "{season}x{episode}"; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("1x6"); - } - - [Test] - public void should_replace_season00_number_with_two_digits() - { - _episode1.SeasonNumber = 1; - _namingConfig.StandardEpisodeFormat = "{season:00}x{episode}"; - - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("01x6"); - } - - [Test] - public void should_replace_episode_number_with_single_digit() - { - _episode1.SeasonNumber = 1; - _namingConfig.StandardEpisodeFormat = "{season}x{episode}"; - - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("1x6"); - } - - [Test] - public void should_replace_episode00_number_with_two_digits() - { - _episode1.SeasonNumber = 1; - _namingConfig.StandardEpisodeFormat = "{season}x{episode:00}"; - - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("1x06"); - } [Test] public void should_replace_quality_title() { - _namingConfig.StandardEpisodeFormat = "{Quality Title}"; + _namingConfig.StandardMovieFormat = "{Quality Title}"; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("HDTV-720p"); } [Test] public void should_replace_quality_proper_with_proper() { - _namingConfig.StandardEpisodeFormat = "{Quality Proper}"; + _namingConfig.StandardMovieFormat = "{Quality Proper}"; GivenProper(); - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("Proper"); } [Test] public void should_replace_quality_real_with_real() { - _namingConfig.StandardEpisodeFormat = "{Quality Real}"; + _namingConfig.StandardMovieFormat = "{Quality Real}"; GivenReal(); - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("REAL"); } [Test] public void should_replace_all_contents_in_pattern() { - _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title} [{Quality Title}]"; + _namingConfig.StandardMovieFormat = "{Movie Title} [{Quality Title}]"; - Subject.BuildFileName(new List {_episode1}, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("South Park - S15E06 - City Sushi [HDTV-720p]"); } @@ -234,260 +171,93 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void use_file_name_when_sceneName_is_null() { _namingConfig.RenameEpisodes = false; - _episodeFile.RelativePath = "30 Rock - S01E01 - Test"; + _movieFile.RelativePath = "30 Rock - S01E01 - Test"; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be(Path.GetFileNameWithoutExtension(_episodeFile.RelativePath)); + Subject.BuildFileName(_movie, _movieFile) + .Should().Be(Path.GetFileNameWithoutExtension(_movieFile.RelativePath)); } [Test] public void use_path_when_sceneName_and_relative_path_are_null() { _namingConfig.RenameEpisodes = false; - _episodeFile.RelativePath = null; - _episodeFile.Path = @"C:\Test\Unsorted\Series - S01E01 - Test"; + _movieFile.RelativePath = null; + _movieFile.Path = @"C:\Test\Unsorted\Movie - S01E01 - Test"; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be(Path.GetFileNameWithoutExtension(_episodeFile.Path)); + Subject.BuildFileName(_movie, _movieFile) + .Should().Be(Path.GetFileNameWithoutExtension(_movieFile.Path)); } [Test] public void use_file_name_when_sceneName_is_not_null() { _namingConfig.RenameEpisodes = false; - _episodeFile.SceneName = "30.Rock.S01E01.xvid-LOL"; - _episodeFile.RelativePath = "30 Rock - S01E01 - Test"; + _movieFile.SceneName = "30.Rock.S01E01.xvid-LOL"; + _movieFile.RelativePath = "30 Rock - S01E01 - Test"; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("30.Rock.S01E01.xvid-LOL"); } - [Test] - public void should_use_airDate_if_series_isDaily() - { - _namingConfig.DailyEpisodeFormat = "{Series Title} - {air-date} - {Episode Title}"; - _series.Title = "The Daily Show with Jon Stewart"; - _series.SeriesType = SeriesTypes.Daily; - _episode1.AirDate = "2012-12-13"; - _episode1.Title = "Kristen Stewart"; - - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("The Daily Show with Jon Stewart - 2012-12-13 - Kristen Stewart"); - } - - [Test] - public void should_set_airdate_to_unknown_if_not_available() - { - _namingConfig.DailyEpisodeFormat = "{Series Title} - {Air-Date} - {Episode Title}"; - - _series.Title = "The Daily Show with Jon Stewart"; - _series.SeriesType = SeriesTypes.Daily; - - _episode1.AirDate = null; - _episode1.Title = "Kristen Stewart"; - - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("The Daily Show with Jon Stewart - Unknown - Kristen Stewart"); - } - - [Test] - public void should_not_clean_episode_title_if_there_is_only_one() - { - var title = "City Sushi (1)"; - _episode1.Title = title; - - _namingConfig.StandardEpisodeFormat = "{Episode Title}"; - - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be(title); - } [Test] public void should_should_replace_release_group() { - _namingConfig.StandardEpisodeFormat = "{Release Group}"; + _namingConfig.StandardMovieFormat = "{Release Group}"; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be(_episodeFile.ReleaseGroup); + Subject.BuildFileName(_movie, _movieFile) + .Should().Be(_movieFile.ReleaseGroup); } [Test] public void should_be_able_to_use_original_title() { - _series.Title = "30 Rock"; - _namingConfig.StandardEpisodeFormat = "{Series Title} - {Original Title}"; + _movie.Title = "30 Rock"; + _namingConfig.StandardMovieFormat = "{Movie Title} - {Original Title}"; - _episodeFile.SceneName = "30.Rock.S01E01.xvid-LOL"; - _episodeFile.RelativePath = "30 Rock - S01E01 - Test"; + _movieFile.SceneName = "30.Rock.S01E01.xvid-LOL"; + _movieFile.RelativePath = "30 Rock - S01E01 - Test"; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("30 Rock - 30.Rock.S01E01.xvid-LOL"); } - [Test] - public void should_trim_periods_from_end_of_episode_title() - { - _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = 3; - - var episode = Builder.CreateNew() - .With(e => e.Title = "Part 1.") - .With(e => e.SeasonNumber = 6) - .With(e => e.EpisodeNumber = 6) - .Build(); - - - Subject.BuildFileName(new List { episode }, new Series { Title = "30 Rock" }, _episodeFile) - .Should().Be("30 Rock - S06E06 - Part 1"); - } - - [Test] - public void should_trim_question_marks_from_end_of_episode_title() - { - _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = 3; - - var episode = Builder.CreateNew() - .With(e => e.Title = "Part 1?") - .With(e => e.SeasonNumber = 6) - .With(e => e.EpisodeNumber = 6) - .Build(); - - - Subject.BuildFileName(new List { episode }, new Series { Title = "30 Rock" }, _episodeFile) - .Should().Be("30 Rock - S06E06 - Part 1"); - } [Test] public void should_replace_double_period_with_single_period() { - _namingConfig.StandardEpisodeFormat = "{Series.Title}.S{season:00}E{episode:00}.{Episode.Title}"; + _namingConfig.StandardMovieFormat = "{Movie.Title}."; - var episode = Builder.CreateNew() - .With(e => e.Title = "Part 1") - .With(e => e.SeasonNumber = 6) - .With(e => e.EpisodeNumber = 6) - .Build(); - - Subject.BuildFileName(new List { episode }, new Series { Title = "Chicago P.D." }, _episodeFile) + Subject.BuildFileName(new Movie { Title = "Chicago P.D." }, _movieFile) .Should().Be("Chicago.P.D.S06E06.Part.1"); } [Test] public void should_replace_triple_period_with_single_period() { - _namingConfig.StandardEpisodeFormat = "{Series.Title}.S{season:00}E{episode:00}.{Episode.Title}"; - - var episode = Builder.CreateNew() - .With(e => e.Title = "Part 1") - .With(e => e.SeasonNumber = 6) - .With(e => e.EpisodeNumber = 6) - .Build(); + _namingConfig.StandardMovieFormat = "{Movie.Title}.S{season:00}E{episode:00}.{Episode.Title}"; - Subject.BuildFileName(new List { episode }, new Series { Title = "Chicago P.D.." }, _episodeFile) + Subject.BuildFileName( new Movie { Title = "Chicago P.D.." }, _movieFile) .Should().Be("Chicago.P.D.S06E06.Part.1"); } - [Test] - public void should_not_replace_absolute_numbering_when_series_is_not_anime() - { - _namingConfig.StandardEpisodeFormat = "{Series.Title}.S{season:00}E{episode:00}.{absolute:00}.{Episode.Title}"; - - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("South.Park.S15E06.City.Sushi"); - } - - [Test] - public void should_replace_standard_and_absolute_numbering_when_series_is_anime() - { - _series.SeriesType = SeriesTypes.Anime; - _namingConfig.AnimeEpisodeFormat = "{Series.Title}.S{season:00}E{episode:00}.{absolute:00}.{Episode.Title}"; - - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("South.Park.S15E06.100.City.Sushi"); - } - - [Test] - public void should_replace_standard_numbering_when_series_is_anime() - { - _series.SeriesType = SeriesTypes.Anime; - _namingConfig.AnimeEpisodeFormat = "{Series.Title}.S{season:00}E{episode:00}.{Episode.Title}"; - - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("South.Park.S15E06.City.Sushi"); - } - - [Test] - public void should_replace_absolute_numbering_when_series_is_anime() - { - _series.SeriesType = SeriesTypes.Anime; - _namingConfig.AnimeEpisodeFormat = "{Series.Title}.{absolute:00}.{Episode.Title}"; - - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("South.Park.100.City.Sushi"); - } - - [Test] - public void should_replace_duplicate_numbering_individually() - { - _series.SeriesType = SeriesTypes.Anime; - _namingConfig.AnimeEpisodeFormat = "{Series.Title}.{season}x{episode:00}.{absolute:000}\\{Series.Title}.S{season:00}E{episode:00}.{absolute:00}.{Episode.Title}"; - - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("South.Park.15x06.100\\South.Park.S15E06.100.City.Sushi"); - } - - [Test] - public void should_replace_individual_season_episode_tokens() - { - _series.SeriesType = SeriesTypes.Anime; - _namingConfig.AnimeEpisodeFormat = "{Series Title} Season {season:0000} Episode {episode:0000}\\{Series.Title}.S{season:00}E{episode:00}.{absolute:00}.{Episode.Title}"; - - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("South Park Season 0015 Episode 0006\\South.Park.S15E06.100.City.Sushi"); - } - - [Test] - public void should_use_standard_naming_when_anime_episode_has_no_absolute_number() - { - _series.SeriesType = SeriesTypes.Anime; - _episode1.AbsoluteEpisodeNumber = null; - - _namingConfig.StandardEpisodeFormat = "{Series Title} - {season:0}x{episode:00} - {Episode Title}"; - _namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}"; - - Subject.BuildFileName(new List { _episode1, }, _series, _episodeFile) - .Should().Be("South Park - 15x06 - City Sushi"); - } - [Test] public void should_include_affixes_if_value_not_empty() { - _namingConfig.StandardEpisodeFormat = "{Series.Title}.S{season:00}E{episode:00}{_Episode.Title_}{Quality.Title}"; + _namingConfig.StandardMovieFormat = "{Movie.Title}.S{season:00}E{episode:00}{_Episode.Title_}{Quality.Title}"; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("South.Park.S15E06_City.Sushi_HDTV-720p"); } - [Test] - public void should_not_include_affixes_if_value_empty() - { - _namingConfig.StandardEpisodeFormat = "{Series.Title}.S{season:00}E{episode:00}{_Episode.Title_}"; - - _episode1.Title = ""; - - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("South.Park.S15E06"); - } - [Test] public void should_format_mediainfo_properly() { - _namingConfig.StandardEpisodeFormat = "{Series.Title}.S{season:00}E{episode:00}.{Episode.Title}.{MEDIAINFO.FULL}"; + _namingConfig.StandardMovieFormat = "{Movie.Title}.S{season:00}E{episode:00}.{Episode.Title}.{MEDIAINFO.FULL}"; - _episodeFile.MediaInfo = new Core.MediaFiles.MediaInfo.MediaInfoModel() + _movieFile.MediaInfo = new Core.MediaFiles.MediaInfo.MediaInfoModel() { VideoCodec = "AVC", AudioFormat = "DTS", @@ -495,16 +265,16 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests Subtitles = "English/Spanish/Italian" }; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("South.Park.S15E06.City.Sushi.X264.DTS[EN+ES].[EN+ES+IT]"); } [Test] public void should_exclude_english_in_mediainfo_audio_language() { - _namingConfig.StandardEpisodeFormat = "{Series.Title}.S{season:00}E{episode:00}.{Episode.Title}.{MEDIAINFO.FULL}"; + _namingConfig.StandardMovieFormat = "{Movie.Title}.S{season:00}E{episode:00}.{Episode.Title}.{MEDIAINFO.FULL}"; - _episodeFile.MediaInfo = new Core.MediaFiles.MediaInfo.MediaInfoModel() + _movieFile.MediaInfo = new Core.MediaFiles.MediaInfo.MediaInfoModel() { VideoCodec = "AVC", AudioFormat = "DTS", @@ -512,17 +282,17 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests Subtitles = "English/Spanish/Italian" }; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("South.Park.S15E06.City.Sushi.X264.DTS.[EN+ES+IT]"); } [Test] public void should_remove_duplicate_non_word_characters() { - _series.Title = "Venture Bros."; - _namingConfig.StandardEpisodeFormat = "{Series.Title}.{season}x{episode:00}"; + _movie.Title = "Venture Bros."; + _namingConfig.StandardMovieFormat = "{Movie.Title}.{season}x{episode:00}"; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("Venture.Bros.15x06"); } @@ -530,114 +300,86 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_use_existing_filename_when_scene_name_is_not_available() { _namingConfig.RenameEpisodes = true; - _namingConfig.StandardEpisodeFormat = "{Original Title}"; + _namingConfig.StandardMovieFormat = "{Original Title}"; - _episodeFile.SceneName = null; - _episodeFile.RelativePath = "existing.file.mkv"; + _movieFile.SceneName = null; + _movieFile.RelativePath = "existing.file.mkv"; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be(Path.GetFileNameWithoutExtension(_episodeFile.RelativePath)); + Subject.BuildFileName(_movie, _movieFile) + .Should().Be(Path.GetFileNameWithoutExtension(_movieFile.RelativePath)); } [Test] public void should_be_able_to_use_only_original_title() { - _series.Title = "30 Rock"; - _namingConfig.StandardEpisodeFormat = "{Original Title}"; + _movie.Title = "30 Rock"; + _namingConfig.StandardMovieFormat = "{Original Title}"; - _episodeFile.SceneName = "30.Rock.S01E01.xvid-LOL"; - _episodeFile.RelativePath = "30 Rock - S01E01 - Test"; + _movieFile.SceneName = "30.Rock.S01E01.xvid-LOL"; + _movieFile.RelativePath = "30 Rock - S01E01 - Test"; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("30.Rock.S01E01.xvid-LOL"); } - [Test] - public void should_allow_period_between_season_and_episode() - { - _namingConfig.StandardEpisodeFormat = "{Series.Title}.S{season:00}.E{episode:00}.{Episode.Title}"; - - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("South.Park.S15.E06.City.Sushi"); - } - - [Test] - public void should_allow_space_between_season_and_episode() - { - _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00} E{episode:00} - {Episode Title}"; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("South Park - S15 E06 - City Sushi"); - } - - [Test] - public void should_replace_quality_proper_with_v2_for_anime_v2() - { - _series.SeriesType = SeriesTypes.Anime; - _namingConfig.AnimeEpisodeFormat = "{Quality Proper}"; - - GivenProper(); - - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("v2"); - } [Test] public void should_not_include_quality_proper_when_release_is_not_a_proper() { - _namingConfig.StandardEpisodeFormat = "{Quality Title} {Quality Proper}"; + _namingConfig.StandardMovieFormat= "{Quality Title} {Quality Proper}"; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("HDTV-720p"); } [Test] public void should_wrap_proper_in_square_brackets() { - _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} [{Quality Title}] {[Quality Proper]}"; + _namingConfig.StandardMovieFormat= "{Movie Title} - S{season:00}E{episode:00} [{Quality Title}] {[Quality Proper]}"; GivenProper(); - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("South Park - S15E06 [HDTV-720p] [Proper]"); } [Test] public void should_not_wrap_proper_in_square_brackets_when_not_a_proper() { - _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} [{Quality Title}] {[Quality Proper]}"; + _namingConfig.StandardMovieFormat= "{Movie Title} - S{season:00}E{episode:00} [{Quality Title}] {[Quality Proper]}"; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("South Park - S15E06 [HDTV-720p]"); } [Test] public void should_replace_quality_full_with_quality_title_only_when_not_a_proper() { - _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} [{Quality Full}]"; + _namingConfig.StandardMovieFormat= "{Movie Title} - S{season:00}E{episode:00} [{Quality Full}]"; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("South Park - S15E06 [HDTV-720p]"); } [Test] public void should_replace_quality_full_with_quality_title_and_proper_only_when_a_proper() { - _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} [{Quality Full}]"; + _namingConfig.StandardMovieFormat= "{Movie Title} - S{season:00}E{episode:00} [{Quality Full}]"; GivenProper(); - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("South Park - S15E06 [HDTV-720p Proper]"); } [Test] public void should_replace_quality_full_with_quality_title_and_real_when_a_real() { - _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} [{Quality Full}]"; + _namingConfig.StandardMovieFormat= "{Movie Title} - S{season:00}E{episode:00} [{Quality Full}]"; GivenReal(); - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("South Park - S15E06 [HDTV-720p REAL]"); } @@ -647,9 +389,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.StandardEpisodeFormat = string.Format("{{Quality{0}Title}}{0}{{Quality{0}Proper}}", separator); + _namingConfig.StandardMovieFormat= string.Format("{{Quality{0}Title}}{0}{{Quality{0}Proper}}", separator); - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("HDTV-720p"); } @@ -659,55 +401,45 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests [TestCase('_')] public void should_trim_extra_separators_from_middle_when_quality_proper_is_not_included(char separator) { - _namingConfig.StandardEpisodeFormat = string.Format("{{Quality{0}Title}}{0}{{Quality{0}Proper}}{0}{{Episode{0}Title}}", separator); + _namingConfig.StandardMovieFormat= string.Format("{{Quality{0}Title}}{0}{{Quality{0}Proper}}{0}{{Episode{0}Title}}", separator); - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be(string.Format("HDTV-720p{0}City{0}Sushi", separator)); } - [Test] - public void should_not_require_a_separator_between_tokens() - { - _series.SeriesType = SeriesTypes.Anime; - _namingConfig.AnimeEpisodeFormat = "[{Release Group}]{Series.CleanTitle}.{absolute:000}"; - - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("[SonarrTest]South.Park.100"); - } - [Test] public void should_be_able_to_use_original_filename() { - _series.Title = "30 Rock"; - _namingConfig.StandardEpisodeFormat = "{Series Title} - {Original Filename}"; + _movie.Title = "30 Rock"; + _namingConfig.StandardMovieFormat= "{Movie Title} - {Original Filename}"; - _episodeFile.SceneName = "30.Rock.S01E01.xvid-LOL"; - _episodeFile.RelativePath = "30 Rock - S01E01 - Test"; + _movieFile.SceneName = "30.Rock.S01E01.xvid-LOL"; + _movieFile.RelativePath = "30 Rock - S01E01 - Test"; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("30 Rock - 30 Rock - S01E01 - Test"); } [Test] public void should_be_able_to_use_original_filename_only() { - _series.Title = "30 Rock"; - _namingConfig.StandardEpisodeFormat = "{Original Filename}"; + _movie.Title = "30 Rock"; + _namingConfig.StandardMovieFormat= "{Original Filename}"; - _episodeFile.SceneName = "30.Rock.S01E01.xvid-LOL"; - _episodeFile.RelativePath = "30 Rock - S01E01 - Test"; + _movieFile.SceneName = "30.Rock.S01E01.xvid-LOL"; + _movieFile.RelativePath = "30 Rock - S01E01 - Test"; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("30 Rock - S01E01 - Test"); } [Test] public void should_use_Sonarr_as_release_group_when_not_available() { - _episodeFile.ReleaseGroup = null; - _namingConfig.StandardEpisodeFormat = "{Release Group}"; + _movieFile.ReleaseGroup = null; + _namingConfig.StandardMovieFormat= "{Release Group}"; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be("Radarr"); } @@ -716,10 +448,10 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests [TestCase("{Episode Title}{ [Release Group]}", "City Sushi")] public void should_not_use_Sonarr_as_release_group_if_pattern_has_separator(string pattern, string expectedFileName) { - _episodeFile.ReleaseGroup = null; - _namingConfig.StandardEpisodeFormat = pattern; + _movieFile.ReleaseGroup = null; + _namingConfig.StandardMovieFormat= pattern; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be(expectedFileName); } @@ -728,10 +460,10 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests [TestCase("IMMERSE")] public void should_use_existing_casing_for_release_group(string releaseGroup) { - _episodeFile.ReleaseGroup = releaseGroup; - _namingConfig.StandardEpisodeFormat = "{Release Group}"; + _movieFile.ReleaseGroup = releaseGroup; + _namingConfig.StandardMovieFormat= "{Release Group}"; - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + Subject.BuildFileName(_movie, _movieFile) .Should().Be(releaseGroup); } diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/MultiEpisodeFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/MultiEpisodeFixture.cs deleted file mode 100644 index fd02cf413..000000000 --- a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/MultiEpisodeFixture.cs +++ /dev/null @@ -1,271 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Organizer; -using NzbDrone.Core.Qualities; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests -{ - [TestFixture] - - public class MultiEpisodeFixture : CoreTest - { - private Series _series; - private Episode _episode1; - private Episode _episode2; - private Episode _episode3; - private EpisodeFile _episodeFile; - private NamingConfig _namingConfig; - - [SetUp] - public void Setup() - { - _series = Builder - .CreateNew() - .With(s => s.Title = "South Park") - .Build(); - - - _namingConfig = NamingConfig.Default; - _namingConfig.RenameEpisodes = true; - - - Mocker.GetMock() - .Setup(c => c.GetConfig()).Returns(_namingConfig); - - _episode1 = Builder.CreateNew() - .With(e => e.Title = "City Sushi") - .With(e => e.SeasonNumber = 15) - .With(e => e.EpisodeNumber = 6) - .With(e => e.AbsoluteEpisodeNumber = 100) - .Build(); - - _episode2 = Builder.CreateNew() - .With(e => e.Title = "City Sushi") - .With(e => e.SeasonNumber = 15) - .With(e => e.EpisodeNumber = 7) - .With(e => e.AbsoluteEpisodeNumber = 101) - .Build(); - - _episode3 = Builder.CreateNew() - .With(e => e.Title = "City Sushi") - .With(e => e.SeasonNumber = 15) - .With(e => e.EpisodeNumber = 8) - .With(e => e.AbsoluteEpisodeNumber = 102) - .Build(); - - _episodeFile = new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p), ReleaseGroup = "SonarrTest" }; - - Mocker.GetMock() - .Setup(v => v.Get(Moq.It.IsAny())) - .Returns(v => Quality.DefaultQualityDefinitions.First(c => c.Quality == v)); - } - - private void GivenProper() - { - _episodeFile.Quality.Revision.Version = 2; - } - - [Test] - public void should_replace_Series_space_Title() - { - _namingConfig.StandardEpisodeFormat = "{Series Title}"; - - Subject.BuildFileName(new List {_episode1}, _series, _episodeFile) - .Should().Be("South Park"); - } - - [Test] - public void should_format_extend_multi_episode_properly() - { - _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = 0; - - Subject.BuildFileName(new List {_episode1, _episode2}, _series, _episodeFile) - .Should().Be("South Park - S15E06-07 - City Sushi"); - } - - [Test] - public void should_format_duplicate_multi_episode_properly() - { - _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = 1; - - Subject.BuildFileName(new List { _episode1, _episode2 }, _series, _episodeFile) - .Should().Be("South Park - S15E06 - S15E07 - City Sushi"); - } - - [Test] - public void should_format_repeat_multi_episode_properly() - { - _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = 2; - - Subject.BuildFileName(new List { _episode1, _episode2 }, _series, _episodeFile) - .Should().Be("South Park - S15E06E07 - City Sushi"); - } - - [Test] - public void should_format_scene_multi_episode_properly() - { - _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = 3; - - Subject.BuildFileName(new List { _episode1, _episode2 }, _series, _episodeFile) - .Should().Be("South Park - S15E06-E07 - City Sushi"); - } - - [Test] - public void should_use_dash_as_separator_when_multi_episode_style_is_extend_for_anime() - { - _series.SeriesType = SeriesTypes.Anime; - _namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}"; - - Subject.BuildFileName(new List { _episode1, _episode2 }, _series, _episodeFile) - .Should().Be("South Park - 100-101 - City Sushi"); - } - - [Test] - public void should_duplicate_absolute_pattern_when_multi_episode_style_is_duplicate() - { - _series.SeriesType = SeriesTypes.Anime; - _namingConfig.MultiEpisodeStyle = (int)MultiEpisodeStyle.Duplicate; - _namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}"; - - Subject.BuildFileName(new List { _episode1, _episode2, _episode3 }, _series, _episodeFile) - .Should().Be("South Park - 100 - 101 - 102 - City Sushi"); - } - - [Test] - public void should_get_proper_filename_when_multi_episode_is_duplicated_and_bracket_follows_pattern() - { - _namingConfig.StandardEpisodeFormat = - "{Series Title} - S{season:00}E{episode:00} - ({Quality Title}, {MediaInfo Full}, {Release Group}) - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = (int) MultiEpisodeStyle.Duplicate; - - Subject.BuildFileName(new List { _episode1, _episode2 }, _series, _episodeFile) - .Should().Be("South Park - S15E06 - S15E07 - (HDTV-720p, , SonarrTest) - City Sushi"); - } - - [Test] - public void should_format_range_multi_episode_properly() - { - _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = 4; - - Subject.BuildFileName(new List { _episode1, _episode2, _episode3 }, _series, _episodeFile) - .Should().Be("South Park - S15E06-08 - City Sushi"); - } - - [Test] - public void should_format_range_multi_episode_anime_properly() - { - _series.SeriesType = SeriesTypes.Anime; - _namingConfig.MultiEpisodeStyle = 4; - _namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}"; - - Subject.BuildFileName(new List { _episode1, _episode2, _episode3 }, _series, _episodeFile) - .Should().Be("South Park - 100-102 - City Sushi"); - } - - [Test] - public void should_format_repeat_multi_episode_anime_properly() - { - _series.SeriesType = SeriesTypes.Anime; - _namingConfig.MultiEpisodeStyle = 2; - _namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}"; - - Subject.BuildFileName(new List { _episode1, _episode2, _episode3 }, _series, _episodeFile) - .Should().Be("South Park - 100-101-102 - City Sushi"); - } - - [Test] - public void should_format_single_episode_with_range_multi_episode_properly() - { - _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = 4; - - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("South Park - S15E06 - City Sushi"); - } - - [Test] - public void should_format_single_anime_episode_with_range_multi_episode_properly() - { - _series.SeriesType = SeriesTypes.Anime; - _namingConfig.MultiEpisodeStyle = 4; - _namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}"; - - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("South Park - 100 - City Sushi"); - } - - [Test] - public void should_default_to_dash_when_serparator_is_not_set_for_absolute_number() - { - _series.SeriesType = SeriesTypes.Anime; - _namingConfig.MultiEpisodeStyle = (int)MultiEpisodeStyle.Duplicate; - _namingConfig.AnimeEpisodeFormat = "{Series Title} - {season}x{episode:00} - [{absolute:000}] - {Episode Title} - {Quality Title}"; - - Subject.BuildFileName(new List { _episode1, _episode2 }, _series, _episodeFile) - .Should().Be("South Park - 15x06 - 15x07 - [100-101] - City Sushi - HDTV-720p"); - } - - [Test] - public void should_format_prefixed_range_multi_episode_properly() - { - _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = 5; - - Subject.BuildFileName(new List { _episode1, _episode2, _episode3 }, _series, _episodeFile) - .Should().Be("South Park - S15E06-E08 - City Sushi"); - } - - [Test] - public void should_format_prefixed_range_multi_episode_anime_properly() - { - _series.SeriesType = SeriesTypes.Anime; - _namingConfig.MultiEpisodeStyle = 5; - _namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}"; - - Subject.BuildFileName(new List { _episode1, _episode2, _episode3 }, _series, _episodeFile) - .Should().Be("South Park - 100-102 - City Sushi"); - } - - [Test] - public void should_format_single_episode_with_prefixed_range_multi_episode_properly() - { - _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = 5; - - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("South Park - S15E06 - City Sushi"); - } - - [Test] - public void should_format_single_anime_episode_with_prefixed_range_multi_episode_properly() - { - _series.SeriesType = SeriesTypes.Anime; - _namingConfig.MultiEpisodeStyle = 5; - _namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}"; - - Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) - .Should().Be("South Park - 100 - City Sushi"); - } - - [Test] - public void should_format_prefixed_range_multi_episode_using_episode_separator() - { - _namingConfig.StandardEpisodeFormat = "{Series Title} - {season:0}x{episode:00} - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = 5; - - Subject.BuildFileName(new List { _episode1, _episode2, _episode3 }, _series, _episodeFile) - .Should().Be("South Park - 15x06-x08 - City Sushi"); - } - } -} diff --git a/src/NzbDrone.Core.Test/OrganizerTests/GetMovieFolderFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/GetMovieFolderFixture.cs index d609b34ff..1ff6aa87f 100644 --- a/src/NzbDrone.Core.Test/OrganizerTests/GetMovieFolderFixture.cs +++ b/src/NzbDrone.Core.Test/OrganizerTests/GetMovieFolderFixture.cs @@ -1,11 +1,11 @@ -using NUnit.Framework; +using NUnit.Framework; using NzbDrone.Core.Organizer; using NzbDrone.Core.Test.Framework; using System; using System.Collections.Generic; using System.Linq; using System.Text; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using FluentAssertions; namespace NzbDrone.Core.Test.OrganizerTests diff --git a/src/NzbDrone.Core.Test/OrganizerTests/GetSeasonFolderFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/GetSeasonFolderFixture.cs deleted file mode 100644 index 796a0881f..000000000 --- a/src/NzbDrone.Core.Test/OrganizerTests/GetSeasonFolderFixture.cs +++ /dev/null @@ -1,34 +0,0 @@ -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Organizer; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Test.OrganizerTests -{ - [TestFixture] - public class GetSeasonFolderFixture : CoreTest - { - private NamingConfig namingConfig; - - [SetUp] - public void Setup() - { - namingConfig = NamingConfig.Default; - - Mocker.GetMock() - .Setup(c => c.GetConfig()).Returns(namingConfig); - } - - [TestCase("Venture Bros.", 1, "{Series.Title}.{season:00}", "Venture.Bros.01")] - [TestCase("Venture Bros.", 1, "{Series Title} Season {season:00}", "Venture Bros. Season 01")] - public void should_use_seriesFolderFormat_to_build_folder_name(string seriesTitle, int seasonNumber, string format, string expected) - { - namingConfig.SeasonFolderFormat = format; - - var series = new Series { Title = seriesTitle }; - - Subject.GetSeasonFolder(series, seasonNumber, namingConfig).Should().Be(expected); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/OrganizerTests/GetSeriesFolderFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/GetSeriesFolderFixture.cs deleted file mode 100644 index 9cf0b5e01..000000000 --- a/src/NzbDrone.Core.Test/OrganizerTests/GetSeriesFolderFixture.cs +++ /dev/null @@ -1,39 +0,0 @@ -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Organizer; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Test.OrganizerTests -{ - [TestFixture] - - public class GetSeriesFolderFixture : CoreTest - { - private NamingConfig namingConfig; - - [SetUp] - public void Setup() - { - namingConfig = NamingConfig.Default; - - Mocker.GetMock() - .Setup(c => c.GetConfig()).Returns(namingConfig); - } - - [TestCase("30 Rock", "{Series Title}", "30 Rock")] - [TestCase("30 Rock", "{Series.Title}", "30.Rock")] - [TestCase("24/7 Road to the NHL Winter Classic", "{Series Title}", "24+7 Road to the NHL Winter Classic")] - [TestCase("Venture Bros.", "{Series.Title}", "Venture.Bros")] - [TestCase(".hack", "{Series.Title}", "hack")] - [TestCase("30 Rock", ".{Series.Title}.", "30.Rock")] - public void should_use_seriesFolderFormat_to_build_folder_name(string seriesTitle, string format, string expected) - { - namingConfig.SeriesFolderFormat = format; - - var series = new Series { Title = seriesTitle }; - - Subject.GetSeriesFolder(series).Should().Be(expected); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/ParserTests/AbsoluteEpisodeNumberParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/AbsoluteEpisodeNumberParserFixture.cs deleted file mode 100644 index 1365d0e66..000000000 --- a/src/NzbDrone.Core.Test/ParserTests/AbsoluteEpisodeNumberParserFixture.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.ParserTests -{ - - [TestFixture] - [Ignore("Series")] - public class AbsoluteEpisodeNumberParserFixture : CoreTest - { - [TestCase("[SubDESU]_High_School_DxD_07_(1280x720_x264-AAC)_[6B7FD717]", "High School DxD", 7, 0, 0)] - [TestCase("[Chihiro]_Working!!_-_06_[848x480_H.264_AAC][859EEAFA]", "Working!!", 6, 0, 0)] - [TestCase("[Commie]_Senki_Zesshou_Symphogear_-_11_[65F220B4]", "Senki Zesshou Symphogear", 11, 0, 0)] - [TestCase("[Underwater]_Rinne_no_Lagrange_-_12_(720p)_[5C7BC4F9]", "Rinne no Lagrange", 12, 0, 0)] - [TestCase("[Commie]_Rinne_no_Lagrange_-_15_[E76552EA]", "Rinne no Lagrange", 15, 0, 0)] - [TestCase("[HorribleSubs]_Hunter_X_Hunter_-_33_[720p]", "Hunter X Hunter", 33, 0, 0)] - [TestCase("[HorribleSubs]_Fairy_Tail_-_145_[720p]", "Fairy Tail", 145, 0, 0)] - [TestCase("[HorribleSubs] Tonari no Kaibutsu-kun - 13 [1080p].mkv", "Tonari no Kaibutsu-kun", 13, 0, 0)] - [TestCase("[Doremi].Yes.Pretty.Cure.5.Go.Go!.31.[1280x720].[C65D4B1F].mkv", "Yes Pretty Cure 5 Go Go!", 31, 0, 0)] - [TestCase("[K-F] One Piece 214", "One Piece", 214, 0, 0)] - [TestCase("[K-F] One Piece S10E14 214", "One Piece", 214, 10, 14)] - [TestCase("[K-F] One Piece 10x14 214", "One Piece", 214, 10, 14)] - [TestCase("[K-F] One Piece 214 10x14", "One Piece", 214, 10, 14)] -// [TestCase("One Piece S10E14 214", "One Piece", 214, 10, 14)] -// [TestCase("One Piece 10x14 214", "One Piece", 214, 10, 14)] -// [TestCase("One Piece 214 10x14", "One Piece", 214, 10, 14)] -// [TestCase("214 One Piece 10x14", "One Piece", 214, 10, 14)] - [TestCase("Bleach - 031 - The Resolution to Kill [Lunar].avi", "Bleach", 31, 0, 0)] - [TestCase("Bleach - 031 - The Resolution to Kill [Lunar]", "Bleach", 31, 0, 0)] - [TestCase("[ACX]Hack Sign 01 Role Play [Kosaka] [9C57891E].mkv", "Hack Sign", 1, 0, 0)] - [TestCase("[SFW-sage] Bakuman S3 - 12 [720p][D07C91FC]", "Bakuman S3", 12, 0, 0)] - [TestCase("ducktales_e66_time_is_money_part_one_marking_time", "ducktales", 66, 0, 0)] - [TestCase("[Underwater-FFF] No Game No Life - 01 (720p) [27AAA0A0].mkv", "No Game No Life", 1, 0, 0)] - [TestCase("[FroZen] Miyuki - 23 [DVD][7F6170E6]", "Miyuki", 23, 0, 0)] - [TestCase("[Commie] Yowamushi Pedal - 32 [0BA19D5B]", "Yowamushi Pedal", 32, 0, 0)] - [TestCase("[Doki] Mahouka Koukou no Rettousei - 07 (1280x720 Hi10P AAC) [80AF7DDE]", "Mahouka Koukou no Rettousei", 7, 0, 0)] - [TestCase("[HorribleSubs] Yowamushi Pedal - 32 [480p]", "Yowamushi Pedal", 32, 0, 0)] - [TestCase("[CR] Sailor Moon - 004 [480p][48CE2D0F]", "Sailor Moon", 4, 0, 0)] - [TestCase("[Chibiki] Puchimas!! - 42 [360p][7A4FC77B]", "Puchimas!!", 42, 0, 0)] - [TestCase("[HorribleSubs] Yowamushi Pedal - 32 [1080p]", "Yowamushi Pedal", 32, 0, 0)] - [TestCase("[HorribleSubs] Love Live! S2 - 07 [720p]", "Love Live! S2", 7, 0, 0)] - [TestCase("[DeadFish] Onee-chan ga Kita - 09v2 [720p][AAC]", "Onee-chan ga Kita", 9, 0, 0)] - [TestCase("[Underwater-FFF] No Game No Life - 01 (720p) [27AAA0A0]", "No Game No Life", 1, 0, 0)] - [TestCase("[S-T-D] Soul Eater Not! - 06 (1280x720 10bit AAC) [59B3F2EA].mkv", "Soul Eater Not!", 6, 0, 0)] - [TestCase("No Game No Life - 010 (720p) [27AAA0A0].mkv", "No Game No Life", 10, 0, 0)] - [TestCase("Initial D Fifth Stage - 01 DVD - Central Anime", "Initial D Fifth Stage", 1, 0, 0)] - [TestCase("Initial_D_Fifth_Stage_-_01(DVD)_-_(Central_Anime)[5AF6F1E4].mkv", "Initial D Fifth Stage", 1, 0, 0)] - [TestCase("Initial_D_Fifth_Stage_-_02(DVD)_-_(Central_Anime)[0CA65F00].mkv", "Initial D Fifth Stage", 2, 0, 0)] - [TestCase("Initial D Fifth Stage - 03 DVD - Central Anime", "Initial D Fifth Stage", 3, 0, 0)] - [TestCase("Initial_D_Fifth_Stage_-_03(DVD)_-_(Central_Anime)[629BD592].mkv", "Initial D Fifth Stage", 3, 0, 0)] - [TestCase("Initial D Fifth Stage - 14 DVD - Central Anime", "Initial D Fifth Stage", 14, 0, 0)] - [TestCase("Initial_D_Fifth_Stage_-_14(DVD)_-_(Central_Anime)[0183D922].mkv", "Initial D Fifth Stage", 14, 0, 0)] -// [TestCase("Initial D - 4th Stage Ep 01.mkv", "Initial D - 4th Stage", 1, 0, 0)] - [TestCase("[ChihiroDesuYo].No.Game.No.Life.-.09.1280x720.10bit.AAC.[24CCE81D]", "No Game No Life", 9, 0, 0)] - [TestCase("Fairy Tail - 001 - Fairy Tail", "Fairy Tail", 001, 0, 0)] - [TestCase("Fairy Tail - 049 - The Day of Fated Meeting", "Fairy Tail", 049, 0, 0)] - [TestCase("Fairy Tail - 050 - Special Request Watch Out for the Guy You Like!", "Fairy Tail", 050, 0, 0)] - [TestCase("Fairy Tail - 099 - Natsu vs. Gildarts", "Fairy Tail", 099, 0, 0)] - [TestCase("Fairy Tail - 100 - Mest", "Fairy Tail", 100, 0, 0)] -// [TestCase("Fairy Tail - 101 - Mest", "Fairy Tail", 101, 0, 0)] //This gets caught up in the 'see' numbering - [TestCase("[Exiled-Destiny] Angel Beats Ep01 (D2201EC5).mkv", "Angel Beats", 1, 0, 0)] - [TestCase("[Commie] Nobunaga the Fool - 23 [5396CA24].mkv", "Nobunaga the Fool", 23, 0, 0)] - [TestCase("[FFF] Seikoku no Dragonar - 01 [1FB538B5].mkv", "Seikoku no Dragonar", 1, 0, 0)] - [TestCase("[Hatsuyuki]Fate_Zero-01[1280x720][122E6EF8]", "Fate Zero", 1, 0, 0)] - [TestCase("[CBM]_Monster_-_11_-_511_Kinderheim_[6C70C4E4].mkv", "Monster", 11, 0, 0)] - [TestCase("[HorribleSubs] Log Horizon 2 - 05 [720p].mkv", "Log Horizon 2", 5, 0, 0)] - [TestCase("[Commie] Log Horizon 2 - 05 [FCE4D070].mkv", "Log Horizon 2", 5, 0, 0)] - [TestCase("[DRONE]Series.Title.100", "Series Title", 100, 0, 0)] - [TestCase("[RlsGrp]Series.Title.2010.S01E01.001.HDTV-720p.x264-DTS", "Series Title 2010", 1, 1, 1)] - [TestCase("Dragon Ball Kai - 130 - Found You, Gohan! Harsh Training in the Kaioshin Realm! [Baaro][720p][5A1AD35B].mkv", "Dragon Ball Kai", 130, 0, 0)] - [TestCase("Dragon Ball Kai - 131 - A Merged Super-Warrior Is Born, His Name Is Gotenks!! [Baaro][720p][32E03F96].mkv", "Dragon Ball Kai", 131, 0, 0)] - [TestCase("[HorribleSubs] Magic Kaito 1412 - 01 [1080p]", "Magic Kaito 1412", 1, 0, 0)] - [TestCase("[Jumonji-Giri]_[F-B]_Kagihime_Monogatari_Eikyuu_Alice_Rondo_Ep04_(0b0e2c10).mkv", "Kagihime Monogatari Eikyuu Alice Rondo", 4, 0, 0)] - [TestCase("[Jumonji-Giri]_[F-B]_Kagihime_Monogatari_Eikyuu_Alice_Rondo_Ep08_(8246e542).mkv", "Kagihime Monogatari Eikyuu Alice Rondo", 8, 0, 0)] - [TestCase("Knights of Sidonia - 01 [1080p 10b DTSHD-MA eng sub].mkv", "Knights of Sidonia", 1, 0, 0)] - [TestCase("Series Title (2010) {01} Episode Title (1).hdtv-720p", "Series Title (2010)", 1, 0, 0)] - [TestCase("[HorribleSubs] Shirobako - 20 [720p].mkv", "Shirobako", 20, 0, 0)] - [TestCase("[Hatsuyuki] Dragon Ball Kai (2014) - 017 (115) [1280x720][B2CFBC0F]", "Dragon Ball Kai (2014)", 17, 0, 0)] - [TestCase("[Hatsuyuki] Dragon Ball Kai (2014) - 018 (116) [1280x720][C4A3B16E]", "Dragon Ball Kai (2014)", 18, 0, 0)] - [TestCase("Dragon Ball Kai (2014) - 39 (137) [v2][720p.HDTV][Unison Fansub]", "Dragon Ball Kai (2014)", 39, 0, 0)] - [TestCase("[HorribleSubs] Eyeshield 21 - 101 [480p].mkv", "Eyeshield 21", 101, 0, 0)] - [TestCase("[Cthuyuu].Taimadou.Gakuen.35.Shiken.Shoutai.-.03.[720p.H264.AAC][8AD82C3A]", "Taimadou Gakuen 35 Shiken Shoutai", 3, 0, 0)] - //[TestCase("Taimadou.Gakuen.35.Shiken.Shoutai.-.03.(1280x720.HEVC.AAC)", "Taimadou Gakuen 35 Shiken Shoutai", 3, 0, 0)] - [TestCase("[Cthuyuu] Taimadou Gakuen 35 Shiken Shoutai - 03 [720p H264 AAC][8AD82C3A]", "Taimadou Gakuen 35 Shiken Shoutai", 3, 0, 0)] - [TestCase("Dragon Ball Super Episode 56 [VOSTFR V2][720p][AAC]-Mystic Z-Team", "Dragon Ball Super", 56, 0, 0)] - [TestCase("[Mystic Z-Team] Dragon Ball Super Episode 69 [VOSTFR_Finale][1080p][AAC].mp4", "Dragon Ball Super", 69, 0, 0)] - //[TestCase("", "", 0, 0, 0)] - public void should_parse_absolute_numbers(string postTitle, string title, int absoluteEpisodeNumber, int seasonNumber, int episodeNumber) - { - var result = Parser.Parser.ParseTitle(postTitle); - result.Should().NotBeNull(); - result.AbsoluteEpisodeNumbers.Single().Should().Be(absoluteEpisodeNumber); - result.SeasonNumber.Should().Be(seasonNumber); - result.EpisodeNumbers.SingleOrDefault().Should().Be(episodeNumber); - result.SeriesTitle.Should().Be(title); - result.FullSeason.Should().BeFalse(); - } - - [TestCase("[DeadFish] Kenzen Robo Daimidaler - 01 - Special [BD][720p][AAC]", "Kenzen Robo Daimidaler", 1)] - [TestCase("[DeadFish] Kenzen Robo Daimidaler - 01 - OVA [BD][720p][AAC]", "Kenzen Robo Daimidaler", 1)] - [TestCase("[DeadFish] Kenzen Robo Daimidaler - 01 - OVD [BD][720p][AAC]", "Kenzen Robo Daimidaler", 1)] - public void should_parse_absolute_specials(string postTitle, string title, int absoluteEpisodeNumber) - { - var result = Parser.Parser.ParseTitle(postTitle); - result.Should().NotBeNull(); - result.AbsoluteEpisodeNumbers.Single().Should().Be(absoluteEpisodeNumber); - result.SeasonNumber.Should().Be(0); - result.EpisodeNumbers.SingleOrDefault().Should().Be(0); - result.SeriesTitle.Should().Be(title); - result.FullSeason.Should().BeFalse(); - result.Special.Should().BeTrue(); - } - - [TestCase("[ANBU-AonE]_Naruto_26-27_[F224EF26].avi", "Naruto", new[] { 26, 27 })] - [TestCase("[Doutei] Recently, My Sister is Unusual - 01-12 [BD][720p-AAC]", "Recently, My Sister is Unusual", new [] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 })] - [TestCase("Series Title (2010) - 01-02-03 - Episode Title (1) HDTV-720p", "Series Title (2010)", new [] { 1, 2, 3 })] - [TestCase("[RlsGrp] Series Title (2010) - S01E01-02-03 - 001-002-003 - Episode Title HDTV-720p v2", "Series Title (2010)", new[] { 1, 2, 3 })] - [TestCase("[RlsGrp] Series Title (2010) - S01E01-02 - 001-002 - Episode Title HDTV-720p v2", "Series Title (2010)", new[] { 1, 2 })] - [TestCase("Series Title (2010) - S01E01-02 (001-002) - Episode Title (1) HDTV-720p v2 [RlsGrp]", "Series Title (2010)", new[] { 1, 2 })] - [TestCase("[HorribleSubs] Haikyuu!! (01-25) [1080p] (Batch)", "Haikyuu!!", new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 })] - public void should_parse_multi_episode_absolute_numbers(string postTitle, string title, int[] absoluteEpisodeNumbers) - { - var result = Parser.Parser.ParseTitle(postTitle); - result.Should().NotBeNull(); - result.AbsoluteEpisodeNumbers.Should().BeEquivalentTo(absoluteEpisodeNumbers); - result.SeriesTitle.Should().Be(title); - result.FullSeason.Should().BeFalse(); - } - } -} diff --git a/src/NzbDrone.Core.Test/ParserTests/AnimeMetadataParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/AnimeMetadataParserFixture.cs deleted file mode 100644 index 599da12aa..000000000 --- a/src/NzbDrone.Core.Test/ParserTests/AnimeMetadataParserFixture.cs +++ /dev/null @@ -1,34 +0,0 @@ -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.ParserTests -{ - - [TestFixture] - public class AnimeMetadataParserFixture : CoreTest - { - [TestCase("[SubDESU]_High_School_DxD_07_(1280x720_x264-AAC)_[6B7FD717]", "SubDESU", "6B7FD717")] - [TestCase("[Chihiro]_Working!!_-_06_[848x480_H.264_AAC][859EEAFA]", "Chihiro", "859EEAFA")] - [TestCase("[Underwater]_Rinne_no_Lagrange_-_12_(720p)_[5C7BC4F9]", "Underwater", "5C7BC4F9")] - [TestCase("[HorribleSubs]_Hunter_X_Hunter_-_33_[720p]", "HorribleSubs", "")] - [TestCase("[HorribleSubs] Tonari no Kaibutsu-kun - 13 [1080p].mkv", "HorribleSubs", "")] - [TestCase("[Doremi].Yes.Pretty.Cure.5.Go.Go!.31.[1280x720].[C65D4B1F].mkv", "Doremi", "C65D4B1F")] - [TestCase("[Doremi].Yes.Pretty.Cure.5.Go.Go!.31.[1280x720].[C65D4B1F]", "Doremi", "C65D4B1F")] - [TestCase("[Doremi].Yes.Pretty.Cure.5.Go.Go!.31.[1280x720].mkv", "Doremi", "")] - [TestCase("[K-F] One Piece 214", "K-F", "")] - [TestCase("[K-F] One Piece S10E14 214", "K-F", "")] - [TestCase("[K-F] One Piece 10x14 214", "K-F", "")] - [TestCase("[K-F] One Piece 214 10x14", "K-F", "")] - [TestCase("Bleach - 031 - The Resolution to Kill [Lunar].avi", "Lunar", "")] - [TestCase("[ACX]Hack Sign 01 Role Play [Kosaka] [9C57891E].mkv", "ACX", "9C57891E")] - [TestCase("[S-T-D] Soul Eater Not! - 06 (1280x720 10bit AAC) [59B3F2EA].mkv", "S-T-D", "59B3F2EA")] - public void should_parse_absolute_numbers(string postTitle, string subGroup, string hash) - { - var result = Parser.Parser.ParseTitle(postTitle); - result.Should().NotBeNull(); - result.ReleaseGroup.Should().Be(subGroup); - result.ReleaseHash.Should().Be(hash); - } - } -} diff --git a/src/NzbDrone.Core.Test/ParserTests/CrapParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/CrapParserFixture.cs index e678bf6a1..c86e19034 100644 --- a/src/NzbDrone.Core.Test/ParserTests/CrapParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/CrapParserFixture.cs @@ -33,7 +33,7 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("QZC4HDl7ncmzyUj9amucWe1ddKU1oFMZDd8r0dEDUsTd")] public void should_not_parse_crap(string title) { - Parser.Parser.ParseTitle(title).Should().BeNull(); + Parser.Parser.ParseMovieTitle(title, false).Should().BeNull(); ExceptionVerification.IgnoreWarns(); } @@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.ParserTests hash = BitConverter.ToString(hashData).Replace("-", ""); - if (Parser.Parser.ParseTitle(hash) == null) + if (Parser.Parser.ParseMovieTitle(hash, false) == null) success++; } @@ -78,7 +78,7 @@ namespace NzbDrone.Core.Test.ParserTests hash.Append(charset[hashAlgo.Next() % charset.Length]); } - if (Parser.Parser.ParseTitle(hash.ToString()) == null) + if (Parser.Parser.ParseMovieTitle(hash.ToString(), false) == null) success++; } @@ -88,7 +88,7 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("thebiggestloser1618finale")] public void should_not_parse_file_name_without_proper_spacing(string fileName) { - Parser.Parser.ParseTitle(fileName).Should().BeNull(); + Parser.Parser.ParseMovieTitle(fileName, false).Should().BeNull(); } } } diff --git a/src/NzbDrone.Core.Test/ParserTests/DailyEpisodeParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/DailyEpisodeParserFixture.cs deleted file mode 100644 index a6c53c783..000000000 --- a/src/NzbDrone.Core.Test/ParserTests/DailyEpisodeParserFixture.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Common.Expansive; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Test.ParserTests -{ - - [TestFixture] - [Ignore("Series")] - public class DailyEpisodeParserFixture : CoreTest - { - [TestCase("Conan 2011 04 18 Emma Roberts HDTV XviD BFF", "Conan", 2011, 04, 18)] - [TestCase("The Tonight Show With Jay Leno 2011 04 15 1080i HDTV DD5 1 MPEG2 TrollHD", "The Tonight Show With Jay Leno", 2011, 04, 15)] - [TestCase("The.Daily.Show.2010.10.11.Johnny.Knoxville.iTouch-MW", "The Daily Show", 2010, 10, 11)] - [TestCase("The Daily Show - 2011-04-12 - Gov. Deval Patrick", "The Daily Show", 2011, 04, 12)] - [TestCase("2011.01.10 - Denis Leary - HD TV.mkv", "", 2011, 1, 10)] - [TestCase("2011.03.13 - Denis Leary - HD TV.mkv", "", 2011, 3, 13)] - [TestCase("The Tonight Show with Jay Leno - 2011-06-16 - Larry David, \"Bachelorette\" Ashley Hebert, Pitbull with Ne-Yo", "The Tonight Show with Jay Leno", 2011, 6, 16)] - [TestCase("2020.NZ.2012.16.02.PDTV.XviD-C4TV", "2020 NZ", 2012, 2, 16)] - [TestCase("2020.NZ.2012.13.02.PDTV.XviD-C4TV", "2020 NZ", 2012, 2, 13)] - [TestCase("2020.NZ.2011.12.02.PDTV.XviD-C4TV", "2020 NZ", 2011, 12, 2)] - [TestCase("Series Title - 2013-10-30 - Episode Title (1) [HDTV-720p]", "Series Title", 2013, 10, 30)] - [TestCase("The_Voice_US_04.28.2014_hdtv.x264.Poke.mp4", "The Voice US", 2014, 4, 28)] - [TestCase("At.Midnight.140722.720p.HDTV.x264-YesTV", "At Midnight", 2014, 07, 22)] - [TestCase("At_Midnight_140722_720p_HDTV_x264-YesTV", "At Midnight", 2014, 07, 22)] - //[TestCase("Corrie.07.01.15", "Corrie", 2015, 1, 7)] - [TestCase("The Nightly Show with Larry Wilmore 2015 02 09 WEBRIP s01e13", "The Nightly Show with Larry Wilmore", 2015, 2, 9)] - //[TestCase("", "", 0, 0, 0)] - public void should_parse_daily_episode(string postTitle, string title, int year, int month, int day) - { - var result = Parser.Parser.ParseTitle(postTitle); - var airDate = new DateTime(year, month, day); - result.Should().NotBeNull(); - result.SeriesTitle.Should().Be(title); - result.AirDate.Should().Be(airDate.ToString(Episode.AIR_DATE_FORMAT)); - result.EpisodeNumbers.Should().BeEmpty(); - result.AbsoluteEpisodeNumbers.Should().BeEmpty(); - result.FullSeason.Should().BeFalse(); - } - - [TestCase("Conan {year} {month} {day} Emma Roberts HDTV XviD BFF")] - [TestCase("The Tonight Show With Jay Leno {year} {month} {day} 1080i HDTV DD5 1 MPEG2 TrollHD")] - [TestCase("The.Daily.Show.{year}.{month}.{day}.Johnny.Knoxville.iTouch-MW")] - [TestCase("The Daily Show - {year}-{month}-{day} - Gov. Deval Patrick")] - [TestCase("{year}.{month}.{day} - Denis Leary - HD TV.mkv")] - [TestCase("The Tonight Show with Jay Leno - {year}-{month}-{day} - Larry David, \"Bachelorette\" Ashley Hebert, Pitbull with Ne-Yo")] - [TestCase("2020.NZ.{year}.{month}.{day}.PDTV.XviD-C4TV")] - public void should_not_accept_ancient_daily_series(string title) - { - var yearTooLow = title.Expand(new { year = 1950, month = 10, day = 14 }); - Parser.Parser.ParseTitle(yearTooLow).Should().BeNull(); - } - - [TestCase("Conan {year} {month} {day} Emma Roberts HDTV XviD BFF")] - [TestCase("The Tonight Show With Jay Leno {year} {month} {day} 1080i HDTV DD5 1 MPEG2 TrollHD")] - [TestCase("The.Daily.Show.{year}.{month}.{day}.Johnny.Knoxville.iTouch-MW")] - [TestCase("The Daily Show - {year}-{month}-{day} - Gov. Deval Patrick")] - [TestCase("{year}.{month}.{day} - Denis Leary - HD TV.mkv")] - [TestCase("The Tonight Show with Jay Leno - {year}-{month}-{day} - Larry David, \"Bachelorette\" Ashley Hebert, Pitbull with Ne-Yo")] - [TestCase("2020.NZ.{year}.{month}.{day}.PDTV.XviD-C4TV")] - public void should_not_accept_future_dates(string title) - { - var twoDaysFromNow = DateTime.Now.AddDays(2); - - var validDate = title.Expand(new { year = twoDaysFromNow.Year, month = twoDaysFromNow.Month.ToString("00"), day = twoDaysFromNow.Day.ToString("00") }); - - Parser.Parser.ParseTitle(validDate).Should().BeNull(); - } - - [Test] - public void should_fail_if_episode_is_far_in_future() - { - var title = string.Format("{0:yyyy.MM.dd} - Denis Leary - HD TV.mkv", DateTime.Now.AddDays(2)); - - Parser.Parser.ParseTitle(title).Should().BeNull(); - } - } -} diff --git a/src/NzbDrone.Core.Test/ParserTests/HashedReleaseFixture.cs b/src/NzbDrone.Core.Test/ParserTests/HashedReleaseFixture.cs index 556a14fe8..2cd8dbc93 100644 --- a/src/NzbDrone.Core.Test/ParserTests/HashedReleaseFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/HashedReleaseFixture.cs @@ -1,4 +1,4 @@ -using FluentAssertions; +using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; @@ -86,8 +86,8 @@ namespace NzbDrone.Core.Test.ParserTests [Test, TestCaseSource("HashedReleaseParserCases")] public void should_properly_parse_hashed_releases(string path, string title, Quality quality, string releaseGroup) { - var result = Parser.Parser.ParsePath(path); - result.SeriesTitle.Should().Be(title); + var result = Parser.Parser.ParseMovieTitle(path, false); + result.MovieTitle.Should().Be(title); result.Quality.Quality.Should().Be(quality); result.ReleaseGroup.Should().Be(releaseGroup); } diff --git a/src/NzbDrone.Core.Test/ParserTests/IsPossibleSpecialEpisodeFixture.cs b/src/NzbDrone.Core.Test/ParserTests/IsPossibleSpecialEpisodeFixture.cs deleted file mode 100644 index 11f68da85..000000000 --- a/src/NzbDrone.Core.Test/ParserTests/IsPossibleSpecialEpisodeFixture.cs +++ /dev/null @@ -1,43 +0,0 @@ -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.Test.ParserTests -{ - [TestFixture] - public class IsPossibleSpecialEpisodeFixture - { - [Test] - public void should_not_treat_files_without_a_series_title_as_a_special() - { - var parsedEpisodeInfo = new ParsedEpisodeInfo - { - EpisodeNumbers = new[]{ 7 }, - SeasonNumber = 1, - SeriesTitle = "" - }; - - parsedEpisodeInfo.IsPossibleSpecialEpisode.Should().BeFalse(); - } - - [Test] - public void should_return_true_when_episode_numbers_is_empty() - { - var parsedEpisodeInfo = new ParsedEpisodeInfo - { - SeasonNumber = 1, - SeriesTitle = "" - }; - - parsedEpisodeInfo.IsPossibleSpecialEpisode.Should().BeTrue(); - } - - [TestCase("Under.the.Dome.S02.Special-Inside.Chesters.Mill.HDTV.x264-BAJSKORV")] - [TestCase("Under.the.Dome.S02.Special-Inside.Chesters.Mill.720p.HDTV.x264-BAJSKORV")] - [TestCase("Rookie.Blue.Behind.the.Badge.S05.Special.HDTV.x264-2HD")] - public void IsPossibleSpecialEpisode_should_be_true(string title) - { - Parser.Parser.ParseTitle(title).IsPossibleSpecialEpisode.Should().BeTrue(); - } - } -} diff --git a/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs index 73cdd74d7..878998f3c 100644 --- a/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs @@ -1,4 +1,4 @@ -using FluentAssertions; +using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.Parser; using NzbDrone.Core.Test.Framework; @@ -61,7 +61,7 @@ namespace NzbDrone.Core.Test.ParserTests var result = Parser.Parser.ParseMovieTitle(postTitle, true); if (result == null) { - Parser.Parser.ParseTitle(postTitle).Language.Should().Be(language); + Parser.Parser.ParseMovieTitle(postTitle, false).Language.Should().Be(language); return; } result.Language.Should().Be(language); diff --git a/src/NzbDrone.Core.Test/ParserTests/MiniSeriesEpisodeParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/MiniSeriesEpisodeParserFixture.cs deleted file mode 100644 index b61ea4803..000000000 --- a/src/NzbDrone.Core.Test/ParserTests/MiniSeriesEpisodeParserFixture.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.ParserTests -{ - - [TestFixture] - [Ignore("Series")] - public class MiniSeriesEpisodeParserFixture : CoreTest - { - [TestCase("The.Kennedys.Part.2.DSR.XviD-SYS", "The Kennedys", 2)] - [TestCase("the-pacific-e07-720p", "the-pacific", 7)] - [TestCase("Hatfields and McCoys 2012 Part 1 REPACK 720p HDTV x264 2HD", "Hatfields and McCoys 2012", 1)] - //[TestCase("Band.Of.Brothers.EP02.Day.Of.Days.DVDRiP.XviD-DEiTY", "Band.Of.Brothers", 2)] - //[TestCase("", "", 0, 0)] - [TestCase("Mars.2016.E04.Power.720p.WEB-DL.DD5.1.H.264-MARS", "Mars 2016", 4)] - public void should_parse_mini_series_episode(string postTitle, string title, int episodeNumber) - { - var result = Parser.Parser.ParseTitle(postTitle); - result.Should().NotBeNull(); - result.EpisodeNumbers.Should().HaveCount(1); - result.SeasonNumber.Should().Be(1); - result.EpisodeNumbers.First().Should().Be(episodeNumber); - result.SeriesTitle.Should().Be(title); - result.AbsoluteEpisodeNumbers.Should().BeEmpty(); - result.FullSeason.Should().BeFalse(); - } - } -} diff --git a/src/NzbDrone.Core.Test/ParserTests/MultiEpisodeParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/MultiEpisodeParserFixture.cs deleted file mode 100644 index 1ea101d57..000000000 --- a/src/NzbDrone.Core.Test/ParserTests/MultiEpisodeParserFixture.cs +++ /dev/null @@ -1,70 +0,0 @@ -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.ParserTests -{ - - [TestFixture] - [Ignore("Series")] - public class MultiEpisodeParserFixture : CoreTest - { - [TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", "WEEDS", 3, new[] { 1, 2, 3, 4, 5, 6 })] - [TestCase("Two.and.a.Half.Men.103.104.720p.HDTV.X264-DIMENSION", "Two and a Half Men", 1, new[] { 3, 4 })] - [TestCase("Weeds.S03E01.S03E02.720p.HDTV.X264-DIMENSION", "Weeds", 3, new[] { 1, 2 })] - [TestCase("The Borgias S01e01 e02 ShoHD On Demand 1080i DD5 1 ALANiS", "The Borgias", 1, new[] { 1, 2 })] - [TestCase("White.Collar.2x04.2x05.720p.BluRay-FUTV", "White Collar", 2, new[] { 4, 5 })] - [TestCase("Desperate.Housewives.S07E22E23.720p.HDTV.X264-DIMENSION", "Desperate Housewives", 7, new[] { 22, 23 })] - [TestCase("Desparate Housewives - S07E22 - S07E23 - And Lots of Security.. [HDTV-720p].mkv", "Desparate Housewives", 7, new[] { 22, 23 })] - [TestCase("S03E01.S03E02.720p.HDTV.X264-DIMENSION", "", 3, new[] { 1, 2 })] - [TestCase("Desparate Housewives - S07E22 - 7x23 - And Lots of Security.. [HDTV-720p].mkv", "Desparate Housewives", 7, new[] { 22, 23 })] - [TestCase("S07E22 - 7x23 - And Lots of Security.. [HDTV-720p].mkv", "", 7, new[] { 22, 23 })] - [TestCase("2x04x05.720p.BluRay-FUTV", "", 2, new[] { 4, 5 })] - [TestCase("S02E04E05.720p.BluRay-FUTV", "", 2, new[] { 4, 5 })] - [TestCase("S02E03-04-05.720p.BluRay-FUTV", "", 2, new[] { 3, 4, 5 })] - [TestCase("Breakout.Kings.S02E09-E10.HDTV.x264-ASAP", "Breakout Kings", 2, new[] { 9, 10 })] - [TestCase("Breakout Kings - 2x9-2x10 - Served Cold [SDTV] ", "Breakout Kings", 2, new[] { 9, 10 })] - [TestCase("Breakout Kings - 2x09-2x10 - Served Cold [SDTV] ", "Breakout Kings", 2, new[] { 9, 10 })] - [TestCase("Hell on Wheels S02E09 E10 HDTV x264 EVOLVE", "Hell on Wheels", 2, new[] { 9, 10 })] - [TestCase("Hell.on.Wheels.S02E09-E10.720p.HDTV.x264-EVOLVE", "Hell on Wheels", 2, new[] { 9, 10 })] - [TestCase("Grey's Anatomy - 8x01_02 - Free Falling", "Grey's Anatomy", 8, new [] { 1,2 })] - [TestCase("8x01_02 - Free Falling", "", 8, new[] { 1, 2 })] - [TestCase("Kaamelott.S01E91-E100", "Kaamelott", 1, new[] { 91, 92, 93, 94, 95, 96, 97, 98, 99, 100 })] - [TestCase("Neighbours.S29E161-E165.PDTV.x264-FQM", "Neighbours", 29, new[] { 161, 162, 163, 164, 165 })] - [TestCase("Shortland.Street.S22E5363-E5366.HDTV.x264-FiHTV", "Shortland Street", 22, new[] { 5363, 5364, 5365, 5366 })] - [TestCase("the.office.101.102.hdtv-lol", "the office", 1, new[] { 1, 2 })] - [TestCase("extant.10708.hdtv-lol.mp4", "extant", 1, new[] { 7, 8 })] - [TestCase("extant.10910.hdtv-lol.mp4", "extant", 1, new[] { 9, 10 })] - [TestCase("E.010910.HDTVx264REPACKLOL.mp4", "E", 1, new[] { 9, 10 })] - [TestCase("World Series of Poker - 2013x15 - 2013x16 - HD TV.mkv", "World Series of Poker", 2013, new[] { 15, 16 })] - [TestCase("The Librarians US S01E01-E02 720p HDTV x264", "The Librarians US", 1, new [] { 1, 2 })] - [TestCase("Series Title Season 01 Episode 05-06 720p", "Series Title", 1,new [] { 5, 6 })] - //[TestCase("My Name Is Earl - S03E01-E02 - My Name Is Inmate 28301-016 [SDTV]", "My Name Is Earl", 3, new[] { 1, 2 })] - //[TestCase("Adventure Time - 5x01 - x02 - Finn the Human (2) & Jake the Dog (3)", "Adventure Time", 5, new [] { 1, 2 })] - [TestCase("The Young And The Restless - S42 Ep10718 - Ep10722", "The Young And The Restless", 42, new[] { 10718, 10719, 10720, 10721, 10722 })] - [TestCase("The Young And The Restless - S42 Ep10688 - Ep10692", "The Young And The Restless", 42, new[] { 10688, 10689, 10690, 10691, 10692 })] - [TestCase("RWBY.S01E02E03.1080p.BluRay.x264-DeBTViD", "RWBY", 1, new [] { 2, 3 })] - [TestCase("grp-zoos01e11e12-1080p", "grp-zoo", 1, new [] { 11, 12 })] - [TestCase("grp-zoo-s01e11e12-1080p", "grp-zoo", 1, new [] { 11, 12 })] - [TestCase("Series Title.S6.E1.E2.Episode Name.1080p.WEB-DL", "Series Title", 6, new [] { 1, 2 })] - [TestCase("Series Title.S6E1-E2.Episode Name.1080p.WEB-DL", "Series Title", 6, new [] { 1, 2 })] - [TestCase("Series Title.S6E1-S6E2.Episode Name.1080p.WEB-DL", "Series Title", 6, new [] { 1, 2 })] - [TestCase("Series Title.S6E1E2.Episode Name.1080p.WEB-DL", "Series Title", 6, new [] { 1, 2 })] - [TestCase("Series Title.S6E1-E2-E3.Episode Name.1080p.WEB-DL", "Series Title", 6, new [] { 1, 2, 3})] - [TestCase("Series Title.S6.E1E3.Episode Name.1080p.WEB-DL", "Series Title", 6, new [] { 1, 2, 3 })] - [TestCase("Series Title.S6.E1-E2.Episode Name.1080p.WEB-DL", "Series Title", 6, new[] { 1, 2 })] - [TestCase("Series Title.S6.E1-S6E2.Episode Name.1080p.WEB-DL", "Series Title", 6, new[] { 1, 2 })] - [TestCase("Series Title.S6.E1E2.Episode Name.1080p.WEB-DL", "Series Title", 6, new[] { 1, 2 })] - [TestCase("Series Title.S6.E1-E2-E3.Episode Name.1080p.WEB-DL", "Series Title", 6, new[] { 1, 2, 3 })] - //[TestCase("", "", , new [] { })] - public void should_parse_multiple_episodes(string postTitle, string title, int season, int[] episodes) - { - var result = Parser.Parser.ParseTitle(postTitle); - result.SeasonNumber.Should().Be(season); - result.EpisodeNumbers.Should().BeEquivalentTo(episodes); - result.SeriesTitle.Should().Be(title); - result.AbsoluteEpisodeNumbers.Should().BeEmpty(); - result.FullSeason.Should().BeFalse(); - } - } -} diff --git a/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs index 40f78581e..03dddd7da 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs @@ -1,4 +1,4 @@ -using FluentAssertions; +using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.Parser; using NzbDrone.Core.Test.Framework; @@ -22,27 +22,6 @@ namespace NzbDrone.Core.Test.ParserTests * Constantine S1-E1-WEB-DL-1080p-NZBgeek */ - [TestCase("Chuck - 4x05 - Title", "Chuck")] - [TestCase("Law & Order - 4x05 - Title", "laworder")] - [TestCase("Bad Format", "badformat")] - [TestCase("Mad Men - Season 1 [Bluray720p]", "madmen")] - [TestCase("Mad Men - Season 1 [Bluray1080p]", "madmen")] - [TestCase("The Daily Show With Jon Stewart -", "thedailyshowwithjonstewart")] - [TestCase("The Venture Bros. (2004)", "theventurebros2004")] - [TestCase("Castle (2011)", "castle2011")] - [TestCase("Adventure Time S02 720p HDTV x264 CRON", "adventuretime")] - [TestCase("Hawaii Five 0", "hawaiifive0")] - [TestCase("Match of the Day", "matchday")] - [TestCase("Match of the Day 2", "matchday2")] - [TestCase("[ www.Torrenting.com ] - Revenge.S03E14.720p.HDTV.X264-DIMENSION", "Revenge")] - [TestCase("Seed S02E09 HDTV x264-2HD [eztv]-[rarbg.com]", "Seed")] - [TestCase("Reno.911.S01.DVDRip.DD2.0.x264-DEEP", "Reno 911")] - public void should_parse_series_name(string postTitle, string title) - { - var result = Parser.Parser.ParseSeriesName(postTitle).CleanSeriesTitle(); - result.Should().Be(title.CleanSeriesTitle()); - } - [Test] public void should_remove_accents_from_title() { @@ -54,13 +33,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.ParseTitle(postTitle); + Parser.Parser.ParseMovieTitle(postTitle, false); } [TestCase("[scnzbefnet][509103] 2.Broke.Girls.S03E18.720p.HDTV.X264-DIMENSION", "2 Broke Girls")] public void should_remove_request_info_from_title(string postTitle, string title) { - Parser.Parser.ParseTitle(postTitle).SeriesTitle.Should().Be(title); + Parser.Parser.ParseMovieTitle(postTitle, false).MovieTitle.Should().Be(title); } //Note: This assumes extended language parser is activated diff --git a/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetEpisodesFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetEpisodesFixture.cs deleted file mode 100644 index 3a5dc99f9..000000000 --- a/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetEpisodesFixture.cs +++ /dev/null @@ -1,346 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; -using Moq; -using NUnit.Framework; -using NzbDrone.Core.DataAugmentation.Scene; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Parser; -using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv; -using NzbDrone.Test.Common; - -namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests -{ - [TestFixture] - [Ignore("Series")] - public class GetEpisodesFixture : TestBase - { - private Series _series; - private List _episodes; - private ParsedEpisodeInfo _parsedEpisodeInfo; - private SingleEpisodeSearchCriteria _singleEpisodeSearchCriteria; - - [SetUp] - public void Setup() - { - _series = Builder.CreateNew() - .With(s => s.Title = "30 Rock") - .With(s => s.CleanTitle = "rock") - .Build(); - - _episodes = Builder.CreateListOfSize(1) - .All() - .With(e => e.AirDate = DateTime.Today.ToString(Episode.AIR_DATE_FORMAT)) - .Build() - .ToList(); - - _parsedEpisodeInfo = new ParsedEpisodeInfo - { - SeriesTitle = _series.Title, - SeasonNumber = 1, - EpisodeNumbers = new[] { 1 }, - AbsoluteEpisodeNumbers = new int[0] - }; - - _singleEpisodeSearchCriteria = new SingleEpisodeSearchCriteria - { - Series = _series, - EpisodeNumber = _episodes.First().EpisodeNumber, - SeasonNumber = _episodes.First().SeasonNumber, - Episodes = _episodes - }; - - Mocker.GetMock() - .Setup(s => s.FindByTitle(It.IsAny())) - .Returns(_series); - } - - private void GivenDailySeries() - { - _series.SeriesType = SeriesTypes.Daily; - } - - private void GivenDailyParseResult() - { - _parsedEpisodeInfo.AirDate = DateTime.Today.ToString(Episode.AIR_DATE_FORMAT); - } - - private void GivenSceneNumberingSeries() - { - _series.UseSceneNumbering = true; - } - - private void GivenAbsoluteNumberingSeries() - { - _parsedEpisodeInfo.AbsoluteEpisodeNumbers = new[] { 1 }; - } - - [Test] - public void should_get_daily_episode_episode_when_search_criteria_is_null() - { - GivenDailySeries(); - GivenDailyParseResult(); - - Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId); - - Mocker.GetMock() - .Verify(v => v.FindEpisode(It.IsAny(), It.IsAny()), Times.Once()); - } - - [Test] - public void should_use_search_criteria_episode_when_it_matches_daily() - { - GivenDailySeries(); - GivenDailyParseResult(); - - Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId, _singleEpisodeSearchCriteria); - - Mocker.GetMock() - .Verify(v => v.FindEpisode(It.IsAny(), It.IsAny()), Times.Never()); - } - - [Test] - public void should_fallback_to_daily_episode_lookup_when_search_criteria_episode_doesnt_match() - { - GivenDailySeries(); - _parsedEpisodeInfo.AirDate = DateTime.Today.AddDays(-5).ToString(Episode.AIR_DATE_FORMAT); ; - - Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId, _singleEpisodeSearchCriteria); - - Mocker.GetMock() - .Verify(v => v.FindEpisode(It.IsAny(), It.IsAny()), Times.Once()); - } - - [Test] - public void should_use_search_criteria_episode_when_it_matches_absolute() - { - GivenAbsoluteNumberingSeries(); - - Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId, _singleEpisodeSearchCriteria); - - Mocker.GetMock() - .Verify(v => v.FindEpisode(It.IsAny(), It.IsAny()), Times.Never()); - } - - [Test] - public void should_use_scene_numbering_when_series_uses_scene_numbering() - { - GivenSceneNumberingSeries(); - - Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId); - - Mocker.GetMock() - .Verify(v => v.FindEpisodesBySceneNumbering(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once()); - } - - [Test] - public void should_match_search_criteria_by_scene_numbering() - { - GivenSceneNumberingSeries(); - - Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId, _singleEpisodeSearchCriteria); - - Mocker.GetMock() - .Verify(v => v.FindEpisodesBySceneNumbering(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); - } - - [Test] - public void should_fallback_to_findEpisode_when_search_criteria_match_fails_for_scene_numbering() - { - GivenSceneNumberingSeries(); - _episodes.First().SceneEpisodeNumber = 10; - - Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId, _singleEpisodeSearchCriteria); - - Mocker.GetMock() - .Verify(v => v.FindEpisodesBySceneNumbering(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once()); - } - - [Test] - public void should_find_episode() - { - Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId); - - Mocker.GetMock() - .Verify(v => v.FindEpisode(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once()); - } - - [Test] - public void should_match_episode_with_search_criteria() - { - Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId, _singleEpisodeSearchCriteria); - - Mocker.GetMock() - .Verify(v => v.FindEpisode(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); - } - - [Test] - public void should_fallback_to_findEpisode_when_search_criteria_match_fails() - { - _episodes.First().EpisodeNumber = 10; - - Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId, _singleEpisodeSearchCriteria); - - Mocker.GetMock() - .Verify(v => v.FindEpisode(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once()); - } - - [Test] - public void should_look_for_episode_in_season_zero_if_absolute_special() - { - GivenAbsoluteNumberingSeries(); - - _parsedEpisodeInfo.Special = true; - - Subject.GetEpisodes(_parsedEpisodeInfo, _series, true, null); - - Mocker.GetMock() - .Verify(v => v.FindEpisodesBySceneNumbering(It.IsAny(), 0, It.IsAny()), Times.Never()); - - Mocker.GetMock() - .Verify(v => v.FindEpisode(It.IsAny(), 0, It.IsAny()), Times.Once()); - } - - [TestCase(0)] - [TestCase(1)] - [TestCase(2)] - public void should_use_scene_numbering_when_scene_season_number_has_value(int seasonNumber) - { - GivenAbsoluteNumberingSeries(); - - Mocker.GetMock() - .Setup(s => s.GetSceneSeasonNumber(_parsedEpisodeInfo.SeriesTitle)) - .Returns(seasonNumber); - - Mocker.GetMock() - .Setup(s => s.FindEpisodesBySceneNumbering(It.IsAny(), seasonNumber, It.IsAny())) - .Returns(new List()); - - Subject.GetEpisodes(_parsedEpisodeInfo, _series, true, null); - - Mocker.GetMock() - .Verify(v => v.FindEpisodesBySceneNumbering(It.IsAny(), seasonNumber, It.IsAny()), Times.Once()); - - Mocker.GetMock() - .Verify(v => v.FindEpisode(It.IsAny(), seasonNumber, It.IsAny()), Times.Once()); - } - - [TestCase(0)] - [TestCase(1)] - [TestCase(2)] - public void should_find_episode_by_season_and_scene_absolute_episode_number(int seasonNumber) - { - GivenAbsoluteNumberingSeries(); - - Mocker.GetMock() - .Setup(s => s.GetSceneSeasonNumber(_parsedEpisodeInfo.SeriesTitle)) - .Returns(seasonNumber); - - Mocker.GetMock() - .Setup(s => s.FindEpisodesBySceneNumbering(It.IsAny(), seasonNumber, It.IsAny())) - .Returns(new List { _episodes.First() }); - - Subject.GetEpisodes(_parsedEpisodeInfo, _series, true, null); - - Mocker.GetMock() - .Verify(v => v.FindEpisodesBySceneNumbering(It.IsAny(), seasonNumber, It.IsAny()), Times.Once()); - - Mocker.GetMock() - .Verify(v => v.FindEpisode(It.IsAny(), seasonNumber, It.IsAny()), Times.Never()); - } - - [TestCase(0)] - [TestCase(1)] - [TestCase(2)] - public void should_find_episode_by_season_and_absolute_episode_number_when_scene_absolute_episode_number_returns_multiple_results(int seasonNumber) - { - GivenAbsoluteNumberingSeries(); - - Mocker.GetMock() - .Setup(s => s.GetSceneSeasonNumber(_parsedEpisodeInfo.SeriesTitle)) - .Returns(seasonNumber); - - Mocker.GetMock() - .Setup(s => s.FindEpisodesBySceneNumbering(It.IsAny(), seasonNumber, It.IsAny())) - .Returns(Builder.CreateListOfSize(5).Build().ToList()); - - Subject.GetEpisodes(_parsedEpisodeInfo, _series, true, null); - - Mocker.GetMock() - .Verify(v => v.FindEpisodesBySceneNumbering(It.IsAny(), seasonNumber, It.IsAny()), Times.Once()); - - Mocker.GetMock() - .Verify(v => v.FindEpisode(It.IsAny(), seasonNumber, It.IsAny()), Times.Once()); - } - - [Test] - public void should_use_tvdb_season_number_when_available_and_a_scene_source() - { - const int tvdbSeasonNumber = 5; - - Mocker.GetMock() - .Setup(s => s.FindSceneMapping(_parsedEpisodeInfo.SeriesTitle)) - .Returns(new SceneMapping { SeasonNumber = tvdbSeasonNumber, SceneSeasonNumber = _parsedEpisodeInfo.SeasonNumber }); - - Subject.GetEpisodes(_parsedEpisodeInfo, _series, true, null); - - Mocker.GetMock() - .Verify(v => v.FindEpisode(_series.Id, _parsedEpisodeInfo.SeasonNumber, _parsedEpisodeInfo.EpisodeNumbers.First()), Times.Never()); - - Mocker.GetMock() - .Verify(v => v.FindEpisode(_series.Id, tvdbSeasonNumber, _parsedEpisodeInfo.EpisodeNumbers.First()), Times.Once()); - } - - [Test] - public void should_not_use_tvdb_season_number_when_available_for_a_different_season_and_a_scene_source() - { - const int tvdbSeasonNumber = 5; - - Mocker.GetMock() - .Setup(s => s.FindSceneMapping(_parsedEpisodeInfo.SeriesTitle)) - .Returns(new SceneMapping { SeasonNumber = tvdbSeasonNumber, SceneSeasonNumber = _parsedEpisodeInfo.SeasonNumber + 100 }); - - Subject.GetEpisodes(_parsedEpisodeInfo, _series, true, null); - - Mocker.GetMock() - .Verify(v => v.FindEpisode(_series.Id, tvdbSeasonNumber, _parsedEpisodeInfo.EpisodeNumbers.First()), Times.Never()); - - Mocker.GetMock() - .Verify(v => v.FindEpisode(_series.Id, _parsedEpisodeInfo.SeasonNumber, _parsedEpisodeInfo.EpisodeNumbers.First()), Times.Once()); - } - - [Test] - public void should_not_use_tvdb_season_when_not_a_scene_source() - { - const int tvdbSeasonNumber = 5; - - Subject.GetEpisodes(_parsedEpisodeInfo, _series, false, null); - - Mocker.GetMock() - .Verify(v => v.FindEpisode(_series.Id, tvdbSeasonNumber, _parsedEpisodeInfo.EpisodeNumbers.First()), Times.Never()); - - Mocker.GetMock() - .Verify(v => v.FindEpisode(_series.Id, _parsedEpisodeInfo.SeasonNumber, _parsedEpisodeInfo.EpisodeNumbers.First()), Times.Once()); - } - - [Test] - public void should_not_use_tvdb_season_when_tvdb_season_number_is_less_than_zero() - { - const int tvdbSeasonNumber = -1; - - Mocker.GetMock() - .Setup(s => s.FindSceneMapping(_parsedEpisodeInfo.SeriesTitle)) - .Returns(new SceneMapping { SeasonNumber = tvdbSeasonNumber, SceneSeasonNumber = _parsedEpisodeInfo.SeasonNumber }); - - Subject.GetEpisodes(_parsedEpisodeInfo, _series, true, null); - - Mocker.GetMock() - .Verify(v => v.FindEpisode(_series.Id, tvdbSeasonNumber, _parsedEpisodeInfo.EpisodeNumbers.First()), Times.Never()); - - Mocker.GetMock() - .Verify(v => v.FindEpisode(_series.Id, _parsedEpisodeInfo.SeasonNumber, _parsedEpisodeInfo.EpisodeNumbers.First()), Times.Once()); - } - } -} diff --git a/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetSeriesFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetMovieFixture.cs similarity index 54% rename from src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetSeriesFixture.cs rename to src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetMovieFixture.cs index bf4b399b5..a8646889a 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetSeriesFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetMovieFixture.cs @@ -1,22 +1,22 @@ -using Moq; +using Moq; using NUnit.Framework; using NzbDrone.Core.Parser; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests { [TestFixture] - public class GetSeriesFixture : CoreTest + public class GetMovieFixture : CoreTest { [Test] public void should_use_passed_in_title_when_it_cannot_be_parsed() { const string title = "30 Rock"; - Subject.GetSeries(title); + Subject.GetMovie(title); - Mocker.GetMock() + Mocker.GetMock() .Verify(s => s.FindByTitle(title), Times.Once()); } @@ -25,23 +25,23 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests { const string title = "30.Rock.S01E01.720p.hdtv"; - Subject.GetSeries(title); + Subject.GetMovie(title); - Mocker.GetMock() - .Verify(s => s.FindByTitle(Parser.Parser.ParseTitle(title).SeriesTitle), Times.Once()); + Mocker.GetMock() + .Verify(s => s.FindByTitle(Parser.Parser.ParseMovieTitle(title,false,false).MovieTitle), Times.Once()); } [Test] public void should_fallback_to_title_without_year_and_year_when_title_lookup_fails() { const string title = "House.2004.S01E01.720p.hdtv"; - var parsedEpisodeInfo = Parser.Parser.ParseTitle(title); + var parsedEpisodeInfo = Parser.Parser.ParseMovieTitle(title,false,false); - Subject.GetSeries(title); + Subject.GetMovie(title); - Mocker.GetMock() - .Verify(s => s.FindByTitle(parsedEpisodeInfo.SeriesTitleInfo.TitleWithoutYear, - parsedEpisodeInfo.SeriesTitleInfo.Year), Times.Once()); + Mocker.GetMock() + .Verify(s => s.FindByTitle(parsedEpisodeInfo.MovieTitleInfo.TitleWithoutYear, + parsedEpisodeInfo.MovieTitleInfo.Year), Times.Once()); } } } diff --git a/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/MapFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/MapFixture.cs index 4d3190aaf..d65bb83a8 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/MapFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/MapFixture.cs @@ -1,17 +1,16 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; -using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.Datastore; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Movies.AlternativeTitles; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests @@ -19,7 +18,6 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests [TestFixture] public class MapFixture : TestBase { - private Series _series; private Movie _movie; private ParsedMovieInfo _parsedMovieInfo; private ParsedMovieInfo _wrongYearInfo; @@ -29,17 +27,10 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests private ParsedMovieInfo _umlautInfo; private ParsedMovieInfo _umlautAltInfo; private MovieSearchCriteria _movieSearchCriteria; - private List _episodes; - private ParsedEpisodeInfo _parsedEpisodeInfo; - private SingleEpisodeSearchCriteria _singleEpisodeSearchCriteria; [SetUp] public void Setup() { - _series = Builder.CreateNew() - .With(s => s.Title = "30 Rock") - .With(s => s.CleanTitle = "rock") - .Build(); _movie = Builder.CreateNew() .With(m => m.Title = "Fack Ju Göthe 2") @@ -48,19 +39,6 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests .With(m => m.AlternativeTitles = new LazyList( new List {new AlternativeTitle("Fack Ju Göthe 2: Same same")})) .Build(); - _episodes = Builder.CreateListOfSize(1) - .All() - .With(e => e.AirDate = DateTime.Today.ToString(Episode.AIR_DATE_FORMAT)) - .Build() - .ToList(); - - _parsedEpisodeInfo = new ParsedEpisodeInfo - { - SeriesTitle = _series.Title, - SeasonNumber = 1, - EpisodeNumbers = new[] { 1 } - }; - _parsedMovieInfo = new ParsedMovieInfo { MovieTitle = _movie.Title, @@ -104,14 +82,6 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests Year = _movie.Year }; - _singleEpisodeSearchCriteria = new SingleEpisodeSearchCriteria - { - Series = _series, - EpisodeNumber = _episodes.First().EpisodeNumber, - SeasonNumber = _episodes.First().SeasonNumber, - Episodes = _episodes - }; - _movieSearchCriteria = new MovieSearchCriteria { Movie = _movie @@ -125,11 +95,6 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests .Returns(_movie); } - private void GivenParseResultSeriesDoesntMatchSearchCriteria() - { - _parsedEpisodeInfo.SeriesTitle = "Another Name"; - } - [Test] public void should_lookup_Movie_by_name() { diff --git a/src/NzbDrone.Core.Test/ParserTests/PathParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/PathParserFixture.cs index 9eaabc1e9..aad81ae23 100644 --- a/src/NzbDrone.Core.Test/ParserTests/PathParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/PathParserFixture.cs @@ -32,14 +32,10 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase(@"C:\Test\Series\Season 1\02 Honor Thy Father (1080p HD).m4v", 1, 2)] [TestCase(@"C:\Test\Series\Season 1\2 Honor Thy Father (1080p HD).m4v", 1, 2)] // [TestCase(@"C:\CSI.NY.S02E04.720p.WEB-DL.DD5.1.H.264\73696S02-04.mkv", 2, 4)] //Gets treated as S01E04 (because it gets parsed as anime) - public void should_parse_from_path(string path, int season, int episode) + public void should_parse_from_path(string path, string title) { - var result = Parser.Parser.ParsePath(path.AsOsAgnostic()); - result.EpisodeNumbers.Should().HaveCount(1); - result.SeasonNumber.Should().Be(season); - result.EpisodeNumbers[0].Should().Be(episode); - result.AbsoluteEpisodeNumbers.Should().BeEmpty(); - result.FullSeason.Should().BeFalse(); + var result = Parser.Parser.ParseMoviePath(path.AsOsAgnostic(), false); + result.MovieTitle.Should().Be(title); ExceptionVerification.IgnoreWarns(); } diff --git a/src/NzbDrone.Core.Test/ParserTests/ReleaseGroupParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ReleaseGroupParserFixture.cs index 18fd75856..ef8ba31da 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ReleaseGroupParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ReleaseGroupParserFixture.cs @@ -37,7 +37,7 @@ namespace NzbDrone.Core.Test.ParserTests { const string path = @"C:\Test\Doctor.Who.2005.s01e01.internal.bdrip.x264-archivist.mkv"; - Parser.Parser.ParsePath(path).ReleaseGroup.Should().Be("archivist"); + Parser.Parser.ParseMovieTitle(path, false).ReleaseGroup.Should().Be("archivist"); } [TestCase("Marvels.Daredevil.S02E04.720p.WEBRip.x264-SKGTV English", "SKGTV")] diff --git a/src/NzbDrone.Core.Test/ParserTests/SeasonParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/SeasonParserFixture.cs deleted file mode 100644 index d2924926b..000000000 --- a/src/NzbDrone.Core.Test/ParserTests/SeasonParserFixture.cs +++ /dev/null @@ -1,58 +0,0 @@ -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.ParserTests -{ - - [TestFixture] - [Ignore("Series")] - public class SeasonParserFixture : CoreTest - { - [TestCase("30.Rock.Season.04.HDTV.XviD-DIMENSION", "30 Rock", 4)] - [TestCase("Parks.and.Recreation.S02.720p.x264-DIMENSION", "Parks and Recreation", 2)] - [TestCase("The.Office.US.S03.720p.x264-DIMENSION", "The Office US", 3)] - [TestCase(@"Sons.of.Anarchy.S03.720p.BluRay-CLUE\REWARD", "Sons of Anarchy", 3)] - [TestCase("Adventure Time S02 720p HDTV x264 CRON", "Adventure Time", 2)] - [TestCase("Sealab.2021.S04.iNTERNAL.DVDRip.XviD-VCDVaULT", "Sealab 2021", 4)] - [TestCase("Hawaii Five 0 S01 720p WEB DL DD5 1 H 264 NT", "Hawaii Five 0", 1)] - [TestCase("30 Rock S03 WS PDTV XviD FUtV", "30 Rock", 3)] - [TestCase("The Office Season 4 WS PDTV XviD FUtV", "The Office", 4)] - [TestCase("Eureka Season 1 720p WEB DL DD 5 1 h264 TjHD", "Eureka", 1)] - [TestCase("The Office Season4 WS PDTV XviD FUtV", "The Office", 4)] - [TestCase("Eureka S 01 720p WEB DL DD 5 1 h264 TjHD", "Eureka", 1)] - [TestCase("Doctor Who Confidential Season 3", "Doctor Who Confidential", 3)] - [TestCase("Fleming.S01.720p.WEBDL.DD5.1.H.264-NTb", "Fleming", 1)] - [TestCase("Holmes.Makes.It.Right.S02.720p.HDTV.AAC5.1.x265-NOGRP", "Holmes Makes It Right", 2)] - [TestCase("My.Series.S2014.720p.HDTV.x264-ME", "My Series", 2014)] - public void should_parse_full_season_release(string postTitle, string title, int season) - { - var result = Parser.Parser.ParseTitle(postTitle); - result.SeasonNumber.Should().Be(season); - result.SeriesTitle.Should().Be(title); - result.EpisodeNumbers.Should().BeEmpty(); - result.AbsoluteEpisodeNumbers.Should().BeEmpty(); - result.FullSeason.Should().BeTrue(); - } - - [TestCase("Acropolis Now S05 EXTRAS DVDRip XviD RUNNER")] - [TestCase("Punky Brewster S01 EXTRAS DVDRip XviD RUNNER")] - [TestCase("Instant Star S03 EXTRAS DVDRip XviD OSiTV")] - public void should_parse_season_extras(string postTitle) - { - var result = Parser.Parser.ParseTitle(postTitle); - - result.Should().BeNull(); - } - - [TestCase("Lie.to.Me.S03.SUBPACK.DVDRip.XviD-REWARD")] - [TestCase("The.Middle.S02.SUBPACK.DVDRip.XviD-REWARD")] - [TestCase("CSI.S11.SUBPACK.DVDRip.XviD-REWARD")] - public void should_parse_season_subpack(string postTitle) - { - var result = Parser.Parser.ParseTitle(postTitle); - - result.Should().BeNull(); - } - } -} diff --git a/src/NzbDrone.Core.Test/ParserTests/SeriesTitleInfoFixture.cs b/src/NzbDrone.Core.Test/ParserTests/SeriesTitleInfoFixture.cs index e1340952f..aa6bbb047 100644 --- a/src/NzbDrone.Core.Test/ParserTests/SeriesTitleInfoFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/SeriesTitleInfoFixture.cs @@ -1,4 +1,4 @@ -using FluentAssertions; +using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.Test.Framework; @@ -13,7 +13,7 @@ namespace NzbDrone.Core.Test.ParserTests { const string title = "House.S01E01.pilot.720p.hdtv"; - var result = Parser.Parser.ParseTitle(title).SeriesTitleInfo; + var result = Parser.Parser.ParseMovieTitle(title, false).MovieTitleInfo; result.Year.Should().Be(0); } @@ -23,7 +23,7 @@ namespace NzbDrone.Core.Test.ParserTests { const string title = "House.S01E01.pilot.720p.hdtv"; - var result = Parser.Parser.ParseTitle(title).SeriesTitleInfo; + var result = Parser.Parser.ParseMovieTitle(title, false).MovieTitleInfo; result.Title.Should().Be(result.TitleWithoutYear); } @@ -33,7 +33,7 @@ namespace NzbDrone.Core.Test.ParserTests { const string title = "House.2004.S01E01.pilot.720p.hdtv"; - var result = Parser.Parser.ParseTitle(title).SeriesTitleInfo; + var result = Parser.Parser.ParseMovieTitle(title, false).MovieTitleInfo; result.Year.Should().Be(2004); } @@ -43,7 +43,7 @@ namespace NzbDrone.Core.Test.ParserTests { const string title = "House.2004.S01E01.pilot.720p.hdtv"; - var result = Parser.Parser.ParseTitle(title).SeriesTitleInfo; + var result = Parser.Parser.ParseMovieTitle(title, false).MovieTitleInfo; result.Title.Should().Be("House 2004"); } @@ -53,7 +53,7 @@ namespace NzbDrone.Core.Test.ParserTests { const string title = "House.2004.S01E01.pilot.720p.hdtv"; - var result = Parser.Parser.ParseTitle(title).SeriesTitleInfo; + var result = Parser.Parser.ParseMovieTitle(title, false).MovieTitleInfo; result.TitleWithoutYear.Should().Be("House"); } diff --git a/src/NzbDrone.Core.Test/ParserTests/SingleEpisodeParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/SingleEpisodeParserFixture.cs index 41e57dfda..02568cee9 100644 --- a/src/NzbDrone.Core.Test/ParserTests/SingleEpisodeParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/SingleEpisodeParserFixture.cs @@ -129,14 +129,9 @@ namespace NzbDrone.Core.Test.ParserTests //[TestCase("", "", 0, 0)] public void should_parse_single_episode(string postTitle, string title, int seasonNumber, int episodeNumber) { - var result = Parser.Parser.ParseTitle(postTitle); + var result = Parser.Parser.ParseMovieTitle(postTitle, false); result.Should().NotBeNull(); - result.EpisodeNumbers.Should().HaveCount(1); - result.SeasonNumber.Should().Be(seasonNumber); - result.EpisodeNumbers.First().Should().Be(episodeNumber); - result.SeriesTitle.Should().Be(title); - result.AbsoluteEpisodeNumbers.Should().BeEmpty(); - result.FullSeason.Should().BeFalse(); + result.MovieTitleInfo.Should().Be(title); } } } diff --git a/src/NzbDrone.Core.Test/Profiles/ProfileServiceFixture.cs b/src/NzbDrone.Core.Test/Profiles/ProfileServiceFixture.cs index b630bd418..437a2d576 100644 --- a/src/NzbDrone.Core.Test/Profiles/ProfileServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Profiles/ProfileServiceFixture.cs @@ -5,7 +5,7 @@ using NUnit.Framework; using NzbDrone.Core.Lifecycle; using NzbDrone.Core.Profiles; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.Profiles { diff --git a/src/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetVideoFilesFixture.cs b/src/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetVideoFilesFixture.cs index 3bf60fa96..28d34c001 100644 --- a/src/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetVideoFilesFixture.cs +++ b/src/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetVideoFilesFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Linq; using FizzWare.NBuilder; @@ -8,7 +8,7 @@ using NUnit.Framework; using NzbDrone.Common.Disk; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests { @@ -99,7 +99,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests var specialFiles = GetFiles(path, subFolder).ToList(); var allFiles = files.Concat(specialFiles); - var series = Builder.CreateNew() + var series = Builder.CreateNew() .With(s => s.Path = path) .Build(); @@ -108,4 +108,4 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests filteredFiles.Count.Should().BeGreaterThan(0); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core.Test/QueueTests/QueueServiceFixture.cs b/src/NzbDrone.Core.Test/QueueTests/QueueServiceFixture.cs index 81ca1e28d..81bc5e72f 100644 --- a/src/NzbDrone.Core.Test/QueueTests/QueueServiceFixture.cs +++ b/src/NzbDrone.Core.Test/QueueTests/QueueServiceFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using NUnit.Framework; @@ -7,7 +7,7 @@ using NzbDrone.Core.Queue; using NzbDrone.Core.Test.Framework; using FizzWare.NBuilder; using FluentAssertions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.Test.QueueTests @@ -24,24 +24,18 @@ namespace NzbDrone.Core.Test.QueueTests .With(v => v.RemainingTime = TimeSpan.FromSeconds(10)) .Build(); - var series = Builder.CreateNew() + var series = Builder.CreateNew() .Build(); - - var episodes = Builder.CreateListOfSize(3) - .All() - .With(e => e.SeriesId = series.Id) - .Build(); - var remoteEpisode = Builder.CreateNew() - .With(r => r.Series = series) - .With(r => r.Episodes = new List(episodes)) - .With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo()) + var remoteEpisode = Builder.CreateNew() + .With(r => r.Movie = series) + .With(r => r.ParsedMovieInfo = new ParsedMovieInfo()) .Build(); _trackedDownloads = Builder.CreateListOfSize(1) .All() .With(v => v.DownloadItem = downloadItem) - .With(v => v.RemoteEpisode = remoteEpisode) + .With(v => v.RemoteMovie = remoteEpisode) .Build() .ToList(); } diff --git a/src/NzbDrone.Core.Test/RootFolderTests/RootFolderServiceFixture.cs b/src/NzbDrone.Core.Test/RootFolderTests/RootFolderServiceFixture.cs index b559e02a6..a564c76c6 100644 --- a/src/NzbDrone.Core.Test/RootFolderTests/RootFolderServiceFixture.cs +++ b/src/NzbDrone.Core.Test/RootFolderTests/RootFolderServiceFixture.cs @@ -10,7 +10,7 @@ using NzbDrone.Common.Disk; using NzbDrone.Core.Configuration; using NzbDrone.Core.RootFolders; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Test.Common; using NzbDrone.Common.EnvironmentInfo; diff --git a/src/NzbDrone.Core.Test/SeriesStatsTests/SeriesStatisticsFixture.cs b/src/NzbDrone.Core.Test/SeriesStatsTests/SeriesStatisticsFixture.cs deleted file mode 100644 index c8a321bc6..000000000 --- a/src/NzbDrone.Core.Test/SeriesStatsTests/SeriesStatisticsFixture.cs +++ /dev/null @@ -1,182 +0,0 @@ -using System; -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Qualities; -using NzbDrone.Core.SeriesStats; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Test.SeriesStatsTests -{ - [TestFixture] - public class SeriesStatisticsFixture : DbTest - { - private Series _series; - private Episode _episode; - private EpisodeFile _episodeFile; - - [SetUp] - public void Setup() - { - _series = Builder.CreateNew() - .With(s => s.Runtime = 30) - .BuildNew(); - - _series.Id = Db.Insert(_series).Id; - - _episode = Builder.CreateNew() - .With(e => e.EpisodeFileId = 0) - .With(e => e.Monitored = false) - .With(e => e.SeriesId = _series.Id) - .With(e => e.AirDateUtc = DateTime.Today.AddDays(5)) - .BuildNew(); - - _episodeFile = Builder.CreateNew() - .With(e => e.SeriesId = _series.Id) - .With(e => e.Quality = new QualityModel(Quality.HDTV720p)) - .BuildNew(); - - } - - private void GivenEpisodeWithFile() - { - _episode.EpisodeFileId = 1; - } - - private void GivenOldEpisode() - { - _episode.AirDateUtc = DateTime.Now.AddSeconds(-10); - } - - private void GivenMonitoredEpisode() - { - _episode.Monitored = true; - } - - private void GivenEpisode() - { - Db.Insert(_episode); - } - - private void GivenEpisodeFile() - { - Db.Insert(_episodeFile); - } - - [Test] - public void should_get_stats_for_series() - { - GivenMonitoredEpisode(); - GivenEpisode(); - - var stats = Subject.SeriesStatistics(); - - stats.Should().HaveCount(1); - stats.First().NextAiring.Should().Be(_episode.AirDateUtc); - stats.First().PreviousAiring.Should().NotHaveValue(); - } - - [Test] - public void should_not_have_next_airing_for_episode_with_file() - { - GivenEpisodeWithFile(); - GivenEpisode(); - - var stats = Subject.SeriesStatistics(); - - stats.Should().HaveCount(1); - stats.First().NextAiring.Should().NotHaveValue(); - } - - [Test] - public void should_have_previous_airing_for_old_episode_with_file() - { - GivenEpisodeWithFile(); - GivenOldEpisode(); - GivenEpisode(); - - var stats = Subject.SeriesStatistics(); - - stats.Should().HaveCount(1); - stats.First().NextAiring.Should().NotHaveValue(); - stats.First().PreviousAiring.Should().Be(_episode.AirDateUtc); - } - - [Test] - public void should_have_previous_airing_for_old_episode_without_file_monitored() - { - GivenMonitoredEpisode(); - GivenOldEpisode(); - GivenEpisode(); - - var stats = Subject.SeriesStatistics(); - - stats.Should().HaveCount(1); - stats.First().NextAiring.Should().NotHaveValue(); - stats.First().PreviousAiring.Should().Be(_episode.AirDateUtc); - } - - [Test] - public void should_not_have_previous_airing_for_old_episode_without_file_unmonitored() - { - GivenOldEpisode(); - GivenEpisode(); - - var stats = Subject.SeriesStatistics(); - - stats.Should().HaveCount(1); - stats.First().NextAiring.Should().NotHaveValue(); - stats.First().PreviousAiring.Should().NotHaveValue(); - } - - [Test] - public void should_not_include_unmonitored_episode_in_episode_count() - { - GivenEpisode(); - - var stats = Subject.SeriesStatistics(); - - stats.Should().HaveCount(1); - stats.First().EpisodeCount.Should().Be(0); - } - - [Test] - public void should_include_unmonitored_episode_with_file_in_episode_count() - { - GivenEpisodeWithFile(); - GivenEpisode(); - - var stats = Subject.SeriesStatistics(); - - stats.Should().HaveCount(1); - stats.First().EpisodeCount.Should().Be(1); - } - - [Test] - public void should_have_size_on_disk_of_zero_when_no_episode_file() - { - GivenEpisode(); - - var stats = Subject.SeriesStatistics(); - - stats.Should().HaveCount(1); - stats.First().SizeOnDisk.Should().Be(0); - } - - [Test] - public void should_have_size_on_disk_when_episode_file_exists() - { - GivenEpisode(); - GivenEpisodeFile(); - - var stats = Subject.SeriesStatistics(); - - stats.Should().HaveCount(1); - stats.First().SizeOnDisk.Should().Be(_episodeFile.Size); - } - - } -} diff --git a/src/NzbDrone.Core.Test/TvTests/EpisodeMonitoredServiceTests/SetEpisodeMontitoredFixture.cs b/src/NzbDrone.Core.Test/TvTests/EpisodeMonitoredServiceTests/SetEpisodeMontitoredFixture.cs deleted file mode 100644 index 058a09b86..000000000 --- a/src/NzbDrone.Core.Test/TvTests/EpisodeMonitoredServiceTests/SetEpisodeMontitoredFixture.cs +++ /dev/null @@ -1,221 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; -using Moq; -using NUnit.Framework; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Test.TvTests.EpisodeMonitoredServiceTests -{ - [TestFixture] - public class SetEpisodeMontitoredFixture : CoreTest - { - private Series _series; - private List _episodes; - - [SetUp] - public void Setup() - { - var seasons = 4; - - _series = Builder.CreateNew() - .With(s => s.Seasons = Builder.CreateListOfSize(seasons) - .All() - .With(n => n.Monitored = true) - .Build() - .ToList()) - .Build(); - - _episodes = Builder.CreateListOfSize(seasons) - .All() - .With(e => e.Monitored = true) - .With(e => e.AirDateUtc = DateTime.UtcNow.AddDays(-7)) - //Missing - .TheFirst(1) - .With(e => e.EpisodeFileId = 0) - //Has File - .TheNext(1) - .With(e => e.EpisodeFileId = 1) - //Future - .TheNext(1) - .With(e => e.EpisodeFileId = 0) - .With(e => e.AirDateUtc = DateTime.UtcNow.AddDays(7)) - //Future/TBA - .TheNext(1) - .With(e => e.EpisodeFileId = 0) - .With(e => e.AirDateUtc = null) - .Build() - .ToList(); - - Mocker.GetMock() - .Setup(s => s.GetEpisodeBySeries(It.IsAny())) - .Returns(_episodes); - } - - private void GivenSpecials() - { - foreach (var episode in _episodes) - { - episode.SeasonNumber = 0; - } - - _series.Seasons = new List{new Season { Monitored = false, SeasonNumber = 0 }}; - } - - [Test] - public void should_be_able_to_monitor_series_without_changing_episodes() - { - Subject.SetEpisodeMonitoredStatus(_series, null); - - Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.IsAny()), Times.Once()); - - Mocker.GetMock() - .Verify(v => v.UpdateEpisodes(It.IsAny>()), Times.Never()); - } - - [Test] - public void should_be_able_to_monitor_all_episodes() - { - Subject.SetEpisodeMonitoredStatus(_series, new MonitoringOptions()); - - Mocker.GetMock() - .Verify(v => v.UpdateEpisodes(It.Is>(l => l.All(e => e.Monitored)))); - } - - [Test] - public void should_be_able_to_monitor_missing_episodes_only() - { - var monitoringOptions = new MonitoringOptions - { - IgnoreEpisodesWithFiles = true, - IgnoreEpisodesWithoutFiles = false - }; - - Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions); - - VerifyMonitored(e => !e.HasFile); - VerifyNotMonitored(e => e.HasFile); - } - - [Test] - public void should_be_able_to_monitor_new_episodes_only() - { - var monitoringOptions = new MonitoringOptions - { - IgnoreEpisodesWithFiles = true, - IgnoreEpisodesWithoutFiles = true - }; - - Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions); - - VerifyMonitored(e => e.AirDateUtc.HasValue && e.AirDateUtc.Value.After(DateTime.UtcNow)); - VerifyMonitored(e => !e.AirDateUtc.HasValue); - VerifyNotMonitored(e => e.AirDateUtc.HasValue && e.AirDateUtc.Value.Before(DateTime.UtcNow)); - } - - [Test] - public void should_not_monitor_missing_specials() - { - GivenSpecials(); - - var monitoringOptions = new MonitoringOptions - { - IgnoreEpisodesWithFiles = true, - IgnoreEpisodesWithoutFiles = false - }; - - Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions); - - VerifyNotMonitored(e => e.SeasonNumber == 0); - } - - [Test] - public void should_not_monitor_new_specials() - { - GivenSpecials(); - - var monitoringOptions = new MonitoringOptions - { - IgnoreEpisodesWithFiles = true, - IgnoreEpisodesWithoutFiles = true - }; - - Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions); - - VerifyNotMonitored(e => e.SeasonNumber == 0); - } - - [Test] - public void should_not_monitor_season_when_all_episodes_are_monitored_except_latest_season() - { - _series.Seasons = Builder.CreateListOfSize(2) - .All() - .With(n => n.Monitored = true) - .Build() - .ToList(); - - _episodes = Builder.CreateListOfSize(5) - .All() - .With(e => e.SeasonNumber = 1) - .With(e => e.EpisodeFileId = 0) - .With(e => e.AirDateUtc = DateTime.UtcNow.AddDays(-5)) - .TheLast(1) - .With(e => e.SeasonNumber = 2) - .Build() - .ToList(); - - Mocker.GetMock() - .Setup(s => s.GetEpisodeBySeries(It.IsAny())) - .Returns(_episodes); - - var monitoringOptions = new MonitoringOptions - { - IgnoreEpisodesWithoutFiles = true - }; - - Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions); - - VerifySeasonMonitored(n => n.SeasonNumber == 2); - VerifySeasonNotMonitored(n => n.SeasonNumber == 1); - } - - [Test] - public void should_ignore_episodes_when_season_is_not_monitored() - { - _series.Seasons.ForEach(s => s.Monitored = false); - - Subject.SetEpisodeMonitoredStatus(_series, new MonitoringOptions()); - - Mocker.GetMock() - .Verify(v => v.UpdateEpisodes(It.Is>(l => l.All(e => !e.Monitored)))); - } - - private void VerifyMonitored(Func predicate) - { - Mocker.GetMock() - .Verify(v => v.UpdateEpisodes(It.Is>(l => l.Where(predicate).All(e => e.Monitored)))); - } - - private void VerifyNotMonitored(Func predicate) - { - Mocker.GetMock() - .Verify(v => v.UpdateEpisodes(It.Is>(l => l.Where(predicate).All(e => !e.Monitored)))); - } - - private void VerifySeasonMonitored(Func predicate) - { - Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Where(predicate).All(n => n.Monitored)))); - } - - private void VerifySeasonNotMonitored(Func predicate) - { - Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Where(predicate).All(n => !n.Monitored)))); - } - } -} diff --git a/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/ByAirDateFixture.cs b/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/ByAirDateFixture.cs deleted file mode 100644 index 2f6c0cef5..000000000 --- a/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/ByAirDateFixture.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests -{ - [TestFixture] - public class ByAirDateFixture : DbTest - { - private const int SERIES_ID = 1; - private const string AIR_DATE = "2014-04-02"; - - private void GivenEpisode(int seasonNumber) - { - var episode = Builder.CreateNew() - .With(e => e.SeriesId = 1) - .With(e => e.SeasonNumber = seasonNumber) - .With(e => e.AirDate = AIR_DATE) - .BuildNew(); - - Db.Insert(episode); - } - - [Test] - public void should_throw_when_multiple_regular_episodes_are_found() - { - GivenEpisode(1); - GivenEpisode(2); - - Assert.Throws(() => Subject.Get(SERIES_ID, AIR_DATE)); - Assert.Throws(() => Subject.Find(SERIES_ID, AIR_DATE)); - } - - [Test] - public void should_throw_when_get_finds_no_episode() - { - Assert.Throws(() => Subject.Get(SERIES_ID, AIR_DATE)); - } - - [Test] - public void should_get_episode_when_single_episode_exists_for_air_date() - { - GivenEpisode(1); - - Subject.Get(SERIES_ID, AIR_DATE).Should().NotBeNull(); - Subject.Find(SERIES_ID, AIR_DATE).Should().NotBeNull(); - } - - [Test] - public void should_get_episode_when_regular_episode_and_special_share_the_same_air_date() - { - GivenEpisode(1); - GivenEpisode(0); - - Subject.Get(SERIES_ID, AIR_DATE).Should().NotBeNull(); - Subject.Find(SERIES_ID, AIR_DATE).Should().NotBeNull(); - } - - [Test] - public void should_get_special_when_its_the_only_episode_for_the_date_provided() - { - GivenEpisode(0); - - Subject.Get(SERIES_ID, AIR_DATE).Should().NotBeNull(); - Subject.Find(SERIES_ID, AIR_DATE).Should().NotBeNull(); - } - } -} diff --git a/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesBetweenDatesFixture.cs b/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesBetweenDatesFixture.cs deleted file mode 100644 index 10cb1393f..000000000 --- a/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesBetweenDatesFixture.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests -{ - [TestFixture] - public class EpisodesBetweenDatesFixture : DbTest - { - [SetUp] - public void Setup() - { - var series = Builder.CreateNew() - .With(s => s.Id = 0) - .With(s => s.Runtime = 30) - .With(s => s.Monitored = true) - .Build(); - - series.Id = Db.Insert(series).Id; - - var episode = Builder.CreateNew() - .With(e => e.Id = 0) - .With(e => e.SeriesId = series.Id) - .With(e => e.Monitored = true) - .Build(); - - Db.Insert(episode); - } - - [Test] - public void should_get_episodes() - { - var episodes = Subject.EpisodesBetweenDates(DateTime.Today.AddDays(-1), DateTime.Today.AddDays(3), false); - episodes.Should().HaveCount(1); - } - } -} diff --git a/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesRepositoryReadFixture.cs b/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesRepositoryReadFixture.cs deleted file mode 100644 index 07a43b9ca..000000000 --- a/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesRepositoryReadFixture.cs +++ /dev/null @@ -1,47 +0,0 @@ -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Qualities; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests -{ - [TestFixture] - public class EpisodesRepositoryReadFixture : DbTest - { - private Series series; - - [SetUp] - public void Setup() - { - series = Builder.CreateNew() - .With(s => s.Runtime = 30) - .BuildNew(); - - Db.Insert(series); - } - - [Test] - public void should_get_episodes_by_file() - { - var episodeFile = Builder.CreateNew() - .With(h => h.Quality = new QualityModel()) - .BuildNew(); - - Db.Insert(episodeFile); - - var episode = Builder.CreateListOfSize(2) - .All() - .With(e => e.SeriesId = series.Id) - .With(e => e.EpisodeFileId = episodeFile.Id) - .BuildListOfNew(); - - Db.InsertMany(episode); - - var episodes = Subject.GetEpisodeByFileId(episodeFile.Id); - episodes.Should().HaveCount(2); - } - } -} diff --git a/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWhereCutoffUnmetFixture.cs b/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWhereCutoffUnmetFixture.cs deleted file mode 100644 index 04c1c60d2..000000000 --- a/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWhereCutoffUnmetFixture.cs +++ /dev/null @@ -1,184 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Datastore; -using NzbDrone.Core.Profiles; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Qualities; -using NzbDrone.Core.MediaFiles; - -namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests -{ - [TestFixture] - [Ignore("For now. We need to update this whole part for movies and all other TvTest.")] - public class EpisodesWhereCutoffUnmetFixture : DbTest - { - private Series _monitoredSeries; - private Series _unmonitoredSeries; - private PagingSpec _pagingSpec; - private List _qualitiesBelowCutoff; - private List _unairedEpisodes; - - [SetUp] - public void Setup() - { - var profile = new Profile - { - Id = 1, - Cutoff = Quality.WEBDL480p, - Items = new List - { - new ProfileQualityItem { Allowed = true, Quality = Quality.SDTV }, - new ProfileQualityItem { Allowed = true, Quality = Quality.WEBDL480p }, - //new ProfileQualityItem { Allowed = true, Quality = Quality.RAWHD } - } - }; - - _monitoredSeries = Builder.CreateNew() - .With(s => s.TvRageId = RandomNumber) - .With(s => s.Runtime = 30) - .With(s => s.Monitored = true) - .With(s => s.TitleSlug = "Title3") - .With(s => s.Id = profile.Id) - .BuildNew(); - - _unmonitoredSeries = Builder.CreateNew() - .With(s => s.TvdbId = RandomNumber) - .With(s => s.Runtime = 30) - .With(s => s.Monitored = false) - .With(s => s.TitleSlug = "Title2") - .With(s => s.Id = profile.Id) - .BuildNew(); - - _monitoredSeries.Id = Db.Insert(_monitoredSeries).Id; - _unmonitoredSeries.Id = Db.Insert(_unmonitoredSeries).Id; - - _pagingSpec = new PagingSpec - { - Page = 1, - PageSize = 10, - SortKey = "AirDate", - SortDirection = SortDirection.Ascending - }; - - _qualitiesBelowCutoff = new List - { - new QualitiesBelowCutoff(profile.Id, new[] {Quality.SDTV.Id}) - }; - - var qualityMet = new EpisodeFile { RelativePath = "a", Quality = new QualityModel { Quality = Quality.WEBDL480p } }; - var qualityUnmet = new EpisodeFile { RelativePath = "b", Quality = new QualityModel { Quality = Quality.SDTV } }; - //var qualityRawHD = new EpisodeFile { RelativePath = "c", Quality = new QualityModel { Quality = Quality.RAWHD } }; - - MediaFileRepository fileRepository = Mocker.Resolve(); - - qualityMet = fileRepository.Insert(qualityMet); - qualityUnmet = fileRepository.Insert(qualityUnmet); - //qualityRawHD = fileRepository.Insert(qualityRawHD); - - var monitoredSeriesEpisodes = Builder.CreateListOfSize(4) - .All() - .With(e => e.Id = 0) - .With(e => e.SeriesId = _monitoredSeries.Id) - .With(e => e.AirDateUtc = DateTime.Now.AddDays(-5)) - .With(e => e.Monitored = true) - .With(e => e.EpisodeFileId = qualityUnmet.Id) - .TheFirst(1) - .With(e => e.Monitored = false) - .With(e => e.EpisodeFileId = qualityMet.Id) - .TheNext(1) - //.With(e => e.EpisodeFileId = qualityRawHD.Id) - //.TheLast(1) - .With(e => e.SeasonNumber = 0) - .Build(); - - var unmonitoredSeriesEpisodes = Builder.CreateListOfSize(3) - .All() - .With(e => e.Id = 0) - .With(e => e.SeriesId = _unmonitoredSeries.Id) - .With(e => e.AirDateUtc = DateTime.Now.AddDays(-5)) - .With(e => e.Monitored = true) - .With(e => e.EpisodeFileId = qualityUnmet.Id) - .TheFirst(1) - .With(e => e.Monitored = false) - .With(e => e.EpisodeFileId = qualityMet.Id) - .TheLast(1) - .With(e => e.SeasonNumber = 0) - .Build(); - - - _unairedEpisodes = Builder.CreateListOfSize(1) - .All() - .With(e => e.Id = 0) - .With(e => e.SeriesId = _monitoredSeries.Id) - .With(e => e.AirDateUtc = DateTime.Now.AddDays(5)) - .With(e => e.Monitored = true) - .With(e => e.EpisodeFileId = qualityUnmet.Id) - .Build() - .ToList(); - - Db.InsertMany(monitoredSeriesEpisodes); - Db.InsertMany(unmonitoredSeriesEpisodes); - } - - private void GivenMonitoredFilterExpression() - { - _pagingSpec.FilterExpression = e => e.Monitored == true && e.Series.Monitored == true; - } - - private void GivenUnmonitoredFilterExpression() - { - _pagingSpec.FilterExpression = e => e.Monitored == false || e.Series.Monitored == false; - } - - [Test] - public void should_include_episodes_where_cutoff_has_not_be_met() - { - GivenMonitoredFilterExpression(); - - var spec = Subject.EpisodesWhereCutoffUnmet(_pagingSpec, _qualitiesBelowCutoff, false); - - spec.Records.Should().HaveCount(1); - spec.Records.Should().OnlyContain(e => e.EpisodeFile.Value.Quality.Quality == Quality.SDTV); - } - - [Test] - public void should_only_contain_monitored_episodes() - { - GivenMonitoredFilterExpression(); - - var spec = Subject.EpisodesWhereCutoffUnmet(_pagingSpec, _qualitiesBelowCutoff, false); - - spec.Records.Should().HaveCount(1); - spec.Records.Should().OnlyContain(e => e.Monitored); - } - - [Test] - public void should_only_contain_episode_with_monitored_series() - { - GivenMonitoredFilterExpression(); - - var spec = Subject.EpisodesWhereCutoffUnmet(_pagingSpec, _qualitiesBelowCutoff, false); - - spec.Records.Should().HaveCount(1); - spec.Records.Should().OnlyContain(e => e.Series.Monitored); - } - - [Test] - public void should_contain_unaired_episodes_if_file_does_not_meet_cutoff() - { - Db.InsertMany(_unairedEpisodes); - - GivenMonitoredFilterExpression(); - - var spec = Subject.EpisodesWhereCutoffUnmet(_pagingSpec, _qualitiesBelowCutoff, false); - - spec.Records.Should().HaveCount(2); - spec.Records.Should().OnlyContain(e => e.Series.Monitored); - } - } -} diff --git a/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWithFilesFixture.cs b/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWithFilesFixture.cs deleted file mode 100644 index e12a8b1c0..000000000 --- a/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWithFilesFixture.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Qualities; - -namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests -{ - [TestFixture] - public class EpisodesWithFilesFixture : DbTest - { - private const int SERIES_ID = 1; - private List _episodes; - private List _episodeFiles; - - [SetUp] - public void Setup() - { - _episodeFiles = Builder.CreateListOfSize(5) - .All() - .With(c => c.Quality = new QualityModel()) - .BuildListOfNew(); - - Db.InsertMany(_episodeFiles); - - _episodes = Builder.CreateListOfSize(10) - .All() - .With(e => e.EpisodeFileId = 0) - .With(e => e.SeriesId = SERIES_ID) - .BuildListOfNew() - .ToList(); - - for (int i = 0; i < _episodeFiles.Count; i++) - { - _episodes[i].EpisodeFileId = _episodeFiles[i].Id; - } - - Db.InsertMany(_episodes); - } - - - [Test] - public void should_only_get_files_that_have_episode_files() - { - var result = Subject.EpisodesWithFiles(SERIES_ID); - - result.Should().OnlyContain(e => e.EpisodeFileId > 0); - result.Should().HaveCount(_episodeFiles.Count); - } - - [Test] - public void should_only_contain_episodes_for_the_given_series() - { - var episodeFile = Builder.CreateNew() - .With(f => f.RelativePath = "another path") - .With(c => c.Quality = new QualityModel()) - .BuildNew(); - - Db.Insert(episodeFile); - - var episode = Builder.CreateNew() - .With(e => e.SeriesId = SERIES_ID + 10) - .With(e => e.EpisodeFileId = episodeFile.Id) - .BuildNew(); - - Db.Insert(episode); - - Subject.EpisodesWithFiles(episode.SeriesId).Should().OnlyContain(e => e.SeriesId == episode.SeriesId); - } - - [Test] - public void should_have_episode_file_loaded() - { - Subject.EpisodesWithFiles(SERIES_ID).Should().OnlyContain(e => e.EpisodeFile.IsLoaded); - } - } -} diff --git a/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWithoutFilesFixture.cs b/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWithoutFilesFixture.cs deleted file mode 100644 index 4f8f9eb23..000000000 --- a/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWithoutFilesFixture.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System; -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Datastore; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests -{ - [TestFixture] - public class EpisodesWithoutFilesFixture : DbTest - { - private Series _monitoredSeries; - private Series _unmonitoredSeries; - private PagingSpec _pagingSpec; - - [SetUp] - public void Setup() - { - _monitoredSeries = Builder.CreateNew() - .With(s => s.Id = 0) - .With(s => s.TvRageId = RandomNumber) - .With(s => s.Runtime = 30) - .With(s => s.Monitored = true) - .With(s => s.TitleSlug = "Title3") - .Build(); - - _unmonitoredSeries = Builder.CreateNew() - .With(s => s.Id = 0) - .With(s => s.TvdbId = RandomNumber) - .With(s => s.Runtime = 30) - .With(s => s.Monitored = false) - .With(s => s.TitleSlug = "Title2") - .Build(); - - _monitoredSeries.Id = Db.Insert(_monitoredSeries).Id; - _unmonitoredSeries.Id = Db.Insert(_unmonitoredSeries).Id; - - _pagingSpec = new PagingSpec - { - Page = 1, - PageSize = 10, - SortKey = "AirDate", - SortDirection = SortDirection.Ascending - }; - - var monitoredSeriesEpisodes = Builder.CreateListOfSize(3) - .All() - .With(e => e.Id = 0) - .With(e => e.SeriesId = _monitoredSeries.Id) - .With(e => e.EpisodeFileId = 0) - .With(e => e.AirDateUtc = DateTime.Now.AddDays(-5)) - .With(e => e.Monitored = true) - .TheFirst(1) - .With(e => e.Monitored = false) - .TheLast(1) - .With(e => e.SeasonNumber = 0) - .Build(); - - var unmonitoredSeriesEpisodes = Builder.CreateListOfSize(3) - .All() - .With(e => e.Id = 0) - .With(e => e.SeriesId = _unmonitoredSeries.Id) - .With(e => e.EpisodeFileId = 0) - .With(e => e.AirDateUtc = DateTime.Now.AddDays(-5)) - .With(e => e.Monitored = true) - .TheFirst(1) - .With(e => e.Monitored = false) - .TheLast(1) - .With(e => e.SeasonNumber = 0) - .Build(); - - - var unairedEpisodes = Builder.CreateListOfSize(1) - .All() - .With(e => e.Id = 0) - .With(e => e.SeriesId = _monitoredSeries.Id) - .With(e => e.EpisodeFileId = 0) - .With(e => e.AirDateUtc = DateTime.Now.AddDays(5)) - .With(e => e.Monitored = true) - .Build(); - - - Db.InsertMany(monitoredSeriesEpisodes); - Db.InsertMany(unmonitoredSeriesEpisodes); - Db.InsertMany(unairedEpisodes); - } - - private void GivenMonitoredFilterExpression() - { - _pagingSpec.FilterExpression = e => e.Monitored == true && e.Series.Monitored == true; - } - - private void GivenUnmonitoredFilterExpression() - { - _pagingSpec.FilterExpression = e => e.Monitored == false || e.Series.Monitored == false; - } - - [Test] - public void should_get_monitored_episodes() - { - GivenMonitoredFilterExpression(); - - var episodes = Subject.EpisodesWithoutFiles(_pagingSpec, false); - - episodes.Records.Should().HaveCount(1); - } - - [Test] - [Ignore("Specials not implemented")] - public void should_get_episode_including_specials() - { - var episodes = Subject.EpisodesWithoutFiles(_pagingSpec, true); - - episodes.Records.Should().HaveCount(2); - } - - [Test] - public void should_not_include_unmonitored_episodes() - { - GivenMonitoredFilterExpression(); - - var episodes = Subject.EpisodesWithoutFiles(_pagingSpec, false); - - episodes.Records.Should().NotContain(e => e.Monitored == false); - } - - [Test] - public void should_not_contain_unmonitored_series() - { - GivenMonitoredFilterExpression(); - - var episodes = Subject.EpisodesWithoutFiles(_pagingSpec, false); - - episodes.Records.Should().NotContain(e => e.SeriesId == _unmonitoredSeries.Id); - } - - [Test] - public void should_not_return_unaired() - { - var episodes = Subject.EpisodesWithoutFiles(_pagingSpec, false); - - episodes.TotalRecords.Should().Be(4); - } - - [Test] - public void should_not_return_episodes_on_air() - { - var onAirEpisode = Builder.CreateNew() - .With(e => e.Id = 0) - .With(e => e.SeriesId = _monitoredSeries.Id) - .With(e => e.EpisodeFileId = 0) - .With(e => e.AirDateUtc = DateTime.Now.AddMinutes(-15)) - .With(e => e.Monitored = true) - .Build(); - - Db.Insert(onAirEpisode); - - var episodes = Subject.EpisodesWithoutFiles(_pagingSpec, false); - - episodes.TotalRecords.Should().Be(4); - episodes.Records.Where(e => e.Id == onAirEpisode.Id).Should().BeEmpty(); - } - } -} diff --git a/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/FindEpisodeFixture.cs b/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/FindEpisodeFixture.cs deleted file mode 100644 index 29730bb60..000000000 --- a/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/FindEpisodeFixture.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests -{ - [TestFixture] - public class FindEpisodeFixture : DbTest - { - private Episode _episode1; - private Episode _episode2; - - [SetUp] - public void Setup() - { - _episode1 = Builder.CreateNew() - .With(e => e.SeriesId = 1) - .With(e => e.SeasonNumber = 1) - .With(e => e.SceneSeasonNumber = 2) - .With(e => e.EpisodeNumber = 3) - .With(e => e.AbsoluteEpisodeNumber = 3) - .With(e => e.SceneEpisodeNumber = 4) - .BuildNew(); - - _episode2 = Builder.CreateNew() - .With(e => e.SeriesId = 1) - .With(e => e.SeasonNumber = 1) - .With(e => e.SceneSeasonNumber = 2) - .With(e => e.EpisodeNumber = 4) - .With(e => e.SceneEpisodeNumber = 4) - .BuildNew(); - - _episode1 = Db.Insert(_episode1); - } - - [Test] - public void should_find_episode_by_scene_numbering() - { - Subject.FindEpisodesBySceneNumbering(_episode1.SeriesId, _episode1.SceneSeasonNumber.Value, _episode1.SceneEpisodeNumber.Value) - .First() - .Id - .Should() - .Be(_episode1.Id); - } - - [Test] - public void should_find_episode_by_standard_numbering() - { - Subject.Find(_episode1.SeriesId, _episode1.SeasonNumber, _episode1.EpisodeNumber) - .Id - .Should() - .Be(_episode1.Id); - } - - [Test] - public void should_not_find_episode_that_does_not_exist() - { - Subject.Find(_episode1.SeriesId, _episode1.SeasonNumber + 1, _episode1.EpisodeNumber) - .Should() - .BeNull(); - } - - [Test] - public void should_find_episode_by_absolute_numbering() - { - Subject.Find(_episode1.SeriesId, _episode1.AbsoluteEpisodeNumber.Value) - .Id - .Should() - .Be(_episode1.Id); - } - - [Test] - public void should_return_multiple_episode_if_multiple_match_by_scene_numbering() - { - _episode2 = Db.Insert(_episode2); - - Subject.FindEpisodesBySceneNumbering(_episode1.SeriesId, _episode1.SceneSeasonNumber.Value, _episode1.SceneEpisodeNumber.Value) - .Should() - .HaveCount(2); - } - } -} diff --git a/src/NzbDrone.Core.Test/TvTests/EpisodeServiceTests/FindEpisodeByTitleFixture.cs b/src/NzbDrone.Core.Test/TvTests/EpisodeServiceTests/FindEpisodeByTitleFixture.cs deleted file mode 100644 index 46fafec3c..000000000 --- a/src/NzbDrone.Core.Test/TvTests/EpisodeServiceTests/FindEpisodeByTitleFixture.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using Moq; -using NUnit.Framework; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Test.TvTests.EpisodeServiceTests -{ - [TestFixture] - public class FindEpisodeByTitleFixture : CoreTest - { - private List _episodes; - - [SetUp] - public void Setup() - { - _episodes = Builder.CreateListOfSize(5) - .Build() - .ToList(); - } - - private void GivenEpisodesWithTitles(params string[] titles) - { - for (int i = 0; i < titles.Count(); i++) - { - _episodes[i].Title = titles[i]; - } - - Mocker.GetMock() - .Setup(s => s.GetEpisodes(It.IsAny(), It.IsAny())) - .Returns(_episodes); - } - - [Test] - public void should_find_episode_by_title() - { - const string expectedTitle = "A Journey to the Highlands"; - GivenEpisodesWithTitles(expectedTitle); - - Subject.FindEpisodeByTitle(1, 1, "Downton.Abbey.A.Journey.To.The.Highlands.720p.BluRay.x264-aAF") - .Title - .Should() - .Be(expectedTitle); - } - - [Test] - public void should_prefer_longer_match() - { - const string expectedTitle = "Inside The Walking Dead: Walker University"; - GivenEpisodesWithTitles("Inside The Walking Dead", expectedTitle); - - Subject.FindEpisodeByTitle(1, 1, "The.Walking.Dead.S04.Special.Inside.The.Walking.Dead.Walker.University.720p.HDTV.x264-W4F") - .Title - .Should() - .Be(expectedTitle); - } - - [Test] - public void should_return_null_when_no_match_is_found() - { - GivenEpisodesWithTitles(); - - Subject.FindEpisodeByTitle(1, 1, "The.Walking.Dead.S04.Special.Inside.The.Walking.Dead.Walker.University.720p.HDTV.x264-W4F") - .Should() - .BeNull(); - } - } -} diff --git a/src/NzbDrone.Core.Test/TvTests/EpisodeServiceTests/HandleEpisodeFileDeletedFixture.cs b/src/NzbDrone.Core.Test/TvTests/EpisodeServiceTests/HandleEpisodeFileDeletedFixture.cs deleted file mode 100644 index 96b5002ff..000000000 --- a/src/NzbDrone.Core.Test/TvTests/EpisodeServiceTests/HandleEpisodeFileDeletedFixture.cs +++ /dev/null @@ -1,123 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; -using Moq; -using NUnit.Framework; -using NzbDrone.Core.Configuration; -using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.MediaFiles.Events; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Test.TvTests.EpisodeServiceTests -{ - [TestFixture] - public class HandleEpisodeFileDeletedFixture : CoreTest - { - private EpisodeFile _episodeFile; - private List _episodes; - - [SetUp] - public void Setup() - { - _episodeFile = Builder - .CreateNew() - .Build(); - } - - private void GivenSingleEpisodeFile() - { - _episodes = Builder - .CreateListOfSize(1) - .All() - .With(e => e.Monitored = true) - .Build() - .ToList(); - - Mocker.GetMock() - .Setup(s => s.GetEpisodeByFileId(_episodeFile.Id)) - .Returns(_episodes); - } - - private void GivenMultiEpisodeFile() - { - _episodes = Builder - .CreateListOfSize(2) - .All() - .With(e => e.Monitored = true) - .Build() - .ToList(); - - Mocker.GetMock() - .Setup(s => s.GetEpisodeByFileId(_episodeFile.Id)) - .Returns(_episodes); - } - - [Test] - public void should_set_EpisodeFileId_to_zero() - { - GivenSingleEpisodeFile(); - - Subject.Handle(new EpisodeFileDeletedEvent(_episodeFile, DeleteMediaFileReason.MissingFromDisk)); - - Mocker.GetMock() - .Verify(v => v.Update(It.Is(e => e.EpisodeFileId == 0)), Times.Once()); - } - - [Test] - public void should_update_each_episode_for_file() - { - GivenMultiEpisodeFile(); - - Subject.Handle(new EpisodeFileDeletedEvent(_episodeFile, DeleteMediaFileReason.MissingFromDisk)); - - Mocker.GetMock() - .Verify(v => v.Update(It.Is(e => e.EpisodeFileId == 0)), Times.Exactly(2)); - } - - [Test] - public void should_set_monitored_to_false_if_autoUnmonitor_is_true_and_is_not_for_an_upgrade() - { - GivenSingleEpisodeFile(); - - Mocker.GetMock() - .SetupGet(s => s.AutoUnmonitorPreviouslyDownloadedEpisodes) - .Returns(true); - - Subject.Handle(new EpisodeFileDeletedEvent(_episodeFile, DeleteMediaFileReason.MissingFromDisk)); - - Mocker.GetMock() - .Verify(v => v.Update(It.Is(e => e.Monitored == false)), Times.Once()); - } - - [Test] - public void should_leave_monitored_to_true_if_autoUnmonitor_is_false() - { - GivenSingleEpisodeFile(); - - Mocker.GetMock() - .SetupGet(s => s.AutoUnmonitorPreviouslyDownloadedEpisodes) - .Returns(false); - - Subject.Handle(new EpisodeFileDeletedEvent(_episodeFile, DeleteMediaFileReason.Upgrade)); - - Mocker.GetMock() - .Verify(v => v.Update(It.Is(e => e.Monitored == true)), Times.Once()); - } - - [Test] - public void should_leave_monitored_to_true_if_autoUnmonitor_is_true_and_is_for_an_upgrade() - { - GivenSingleEpisodeFile(); - - Mocker.GetMock() - .SetupGet(s => s.AutoUnmonitorPreviouslyDownloadedEpisodes) - .Returns(true); - - Subject.Handle(new EpisodeFileDeletedEvent(_episodeFile, DeleteMediaFileReason.Upgrade)); - - Mocker.GetMock() - .Verify(v => v.Update(It.Is(e => e.Monitored == true)), Times.Once()); - } - } -} diff --git a/src/NzbDrone.Core.Test/TvTests/RefreshEpisodeServiceFixture.cs b/src/NzbDrone.Core.Test/TvTests/RefreshEpisodeServiceFixture.cs deleted file mode 100644 index 592b56dc3..000000000 --- a/src/NzbDrone.Core.Test/TvTests/RefreshEpisodeServiceFixture.cs +++ /dev/null @@ -1,397 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using Moq; -using NUnit.Framework; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.MetadataSource.SkyHook; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.TvTests -{ - [TestFixture] - public class RefreshEpisodeServiceFixture : CoreTest - { - private List _insertedEpisodes; - private List _updatedEpisodes; - private List _deletedEpisodes; - private Tuple> _gameOfThrones; - - [TestFixtureSetUp] - public void TestFixture() - { - UseRealHttp(); - - _gameOfThrones = Mocker.Resolve().GetSeriesInfo(121361);//Game of thrones - - // Remove specials. - _gameOfThrones.Item2.RemoveAll(v => v.SeasonNumber == 0); - } - - private List GetEpisodes() - { - return _gameOfThrones.Item2.JsonClone(); - } - - private Series GetSeries() - { - var series = _gameOfThrones.Item1.JsonClone(); - series.Seasons = new List(); - - return series; - } - - private Series GetAnimeSeries() - { - var series = Builder.CreateNew().Build(); - series.SeriesType = SeriesTypes.Anime; - series.Seasons = new List(); - - return series; - } - - [SetUp] - public void Setup() - { - _insertedEpisodes = new List(); - _updatedEpisodes = new List(); - _deletedEpisodes = new List(); - - Mocker.GetMock().Setup(c => c.InsertMany(It.IsAny>())) - .Callback>(e => _insertedEpisodes = e); - - - Mocker.GetMock().Setup(c => c.UpdateMany(It.IsAny>())) - .Callback>(e => _updatedEpisodes = e); - - - Mocker.GetMock().Setup(c => c.DeleteMany(It.IsAny>())) - .Callback>(e => _deletedEpisodes = e); - } - - [Test] - public void should_create_all_when_no_existing_episodes() - { - Mocker.GetMock().Setup(c => c.GetEpisodeBySeries(It.IsAny())) - .Returns(new List()); - - Subject.RefreshEpisodeInfo(GetSeries(), GetEpisodes()); - - _insertedEpisodes.Should().HaveSameCount(GetEpisodes()); - _updatedEpisodes.Should().BeEmpty(); - _deletedEpisodes.Should().BeEmpty(); - } - - [Test] - public void should_update_all_when_all_existing_episodes() - { - Mocker.GetMock().Setup(c => c.GetEpisodeBySeries(It.IsAny())) - .Returns(GetEpisodes()); - - Subject.RefreshEpisodeInfo(GetSeries(), GetEpisodes()); - - _insertedEpisodes.Should().BeEmpty(); - _updatedEpisodes.Should().HaveSameCount(GetEpisodes()); - _deletedEpisodes.Should().BeEmpty(); - } - - [Test] - public void should_delete_all_when_all_existing_episodes_are_gone_from_datasource() - { - Mocker.GetMock().Setup(c => c.GetEpisodeBySeries(It.IsAny())) - .Returns(GetEpisodes()); - - Subject.RefreshEpisodeInfo(GetSeries(), new List()); - - _insertedEpisodes.Should().BeEmpty(); - _updatedEpisodes.Should().BeEmpty(); - _deletedEpisodes.Should().HaveSameCount(GetEpisodes()); - } - - [Test] - public void should_delete_duplicated_episodes_based_on_season_episode_number() - { - var duplicateEpisodes = GetEpisodes().Skip(5).Take(2).ToList(); - - Mocker.GetMock().Setup(c => c.GetEpisodeBySeries(It.IsAny())) - .Returns(GetEpisodes().Union(duplicateEpisodes).ToList()); - - Subject.RefreshEpisodeInfo(GetSeries(), GetEpisodes()); - - _insertedEpisodes.Should().BeEmpty(); - _updatedEpisodes.Should().HaveSameCount(GetEpisodes()); - _deletedEpisodes.Should().HaveSameCount(duplicateEpisodes); - } - - [Test] - public void should_not_change_monitored_status_for_existing_episodes() - { - var series = GetSeries(); - series.Seasons = new List(); - series.Seasons.Add(new Season { SeasonNumber = 1, Monitored = false }); - - var episodes = GetEpisodes(); - - episodes.ForEach(e => e.Monitored = true); - - Mocker.GetMock().Setup(c => c.GetEpisodeBySeries(It.IsAny())) - .Returns(episodes); - - Subject.RefreshEpisodeInfo(series, GetEpisodes()); - - _updatedEpisodes.Should().HaveSameCount(GetEpisodes()); - _updatedEpisodes.Should().OnlyContain(e => e.Monitored == true); - } - - [Test] - public void should_remove_duplicate_remote_episodes_before_processing() - { - Mocker.GetMock().Setup(c => c.GetEpisodeBySeries(It.IsAny())) - .Returns(new List()); - - var episodes = Builder.CreateListOfSize(5) - .TheFirst(2) - .With(e => e.SeasonNumber = 1) - .With(e => e.EpisodeNumber = 1) - .Build() - .ToList(); - - Subject.RefreshEpisodeInfo(GetSeries(), episodes); - - _insertedEpisodes.Should().HaveCount(episodes.Count - 1); - _updatedEpisodes.Should().BeEmpty(); - _deletedEpisodes.Should().BeEmpty(); - } - - [Test] - public void should_set_absolute_episode_number_for_anime() - { - var episodes = Builder.CreateListOfSize(3).Build().ToList(); - - Mocker.GetMock().Setup(c => c.GetEpisodeBySeries(It.IsAny())) - .Returns(new List()); - - Subject.RefreshEpisodeInfo(GetAnimeSeries(), episodes); - - _insertedEpisodes.All(e => e.AbsoluteEpisodeNumber.HasValue).Should().BeTrue(); - _updatedEpisodes.Should().BeEmpty(); - _deletedEpisodes.Should().BeEmpty(); - } - - [Test] - public void should_set_absolute_episode_number_even_if_not_previously_set_for_anime() - { - var episodes = Builder.CreateListOfSize(3).Build().ToList(); - - var existingEpisodes = episodes.JsonClone(); - existingEpisodes.ForEach(e => e.AbsoluteEpisodeNumber = null); - - Mocker.GetMock().Setup(c => c.GetEpisodeBySeries(It.IsAny())) - .Returns(existingEpisodes); - - Subject.RefreshEpisodeInfo(GetAnimeSeries(), episodes); - - _insertedEpisodes.Should().BeEmpty(); - _updatedEpisodes.All(e => e.AbsoluteEpisodeNumber.HasValue).Should().BeTrue(); - _deletedEpisodes.Should().BeEmpty(); - } - - [Test] - public void should_get_new_season_and_episode_numbers_when_absolute_episode_number_match_found() - { - const int expectedSeasonNumber = 10; - const int expectedEpisodeNumber = 5; - const int expectedAbsoluteNumber = 3; - - var episode = Builder.CreateNew() - .With(e => e.SeasonNumber = expectedSeasonNumber) - .With(e => e.EpisodeNumber = expectedEpisodeNumber) - .With(e => e.AbsoluteEpisodeNumber = expectedAbsoluteNumber) - .Build(); - - var existingEpisode = episode.JsonClone(); - existingEpisode.SeasonNumber = 1; - existingEpisode.EpisodeNumber = 1; - existingEpisode.AbsoluteEpisodeNumber = expectedAbsoluteNumber; - - Mocker.GetMock().Setup(c => c.GetEpisodeBySeries(It.IsAny())) - .Returns(new List{ existingEpisode }); - - Subject.RefreshEpisodeInfo(GetAnimeSeries(), new List { episode }); - - _insertedEpisodes.Should().BeEmpty(); - _deletedEpisodes.Should().BeEmpty(); - - _updatedEpisodes.First().SeasonNumber.Should().Be(expectedSeasonNumber); - _updatedEpisodes.First().EpisodeNumber.Should().Be(expectedEpisodeNumber); - _updatedEpisodes.First().AbsoluteEpisodeNumber.Should().Be(expectedAbsoluteNumber); - } - - [Test] - public void should_prefer_absolute_match_over_season_and_epsiode_match() - { - var episodes = Builder.CreateListOfSize(2) - .Build() - .ToList(); - - episodes[0].AbsoluteEpisodeNumber = null; - episodes[0].SeasonNumber.Should().NotBe(episodes[1].SeasonNumber); - episodes[0].EpisodeNumber.Should().NotBe(episodes[1].EpisodeNumber); - - var existingEpisode = new Episode - { - SeasonNumber = episodes[0].SeasonNumber, - EpisodeNumber = episodes[0].EpisodeNumber, - AbsoluteEpisodeNumber = episodes[1].AbsoluteEpisodeNumber - }; - - Mocker.GetMock().Setup(c => c.GetEpisodeBySeries(It.IsAny())) - .Returns(new List { existingEpisode }); - - Subject.RefreshEpisodeInfo(GetAnimeSeries(), episodes); - - _updatedEpisodes.First().SeasonNumber.Should().Be(episodes[1].SeasonNumber); - _updatedEpisodes.First().EpisodeNumber.Should().Be(episodes[1].EpisodeNumber); - _updatedEpisodes.First().AbsoluteEpisodeNumber.Should().Be(episodes[1].AbsoluteEpisodeNumber); - } - - [Test] - public void should_ignore_episodes_with_no_absolute_episode_in_distinct_by_absolute() - { - var episodes = Builder.CreateListOfSize(10) - .Build() - .ToList(); - - episodes[0].AbsoluteEpisodeNumber = null; - episodes[1].AbsoluteEpisodeNumber = null; - episodes[2].AbsoluteEpisodeNumber = null; - episodes[3].AbsoluteEpisodeNumber = null; - episodes[4].AbsoluteEpisodeNumber = null; - - Mocker.GetMock().Setup(c => c.GetEpisodeBySeries(It.IsAny())) - .Returns(new List()); - - Subject.RefreshEpisodeInfo(GetAnimeSeries(), episodes); - - _insertedEpisodes.Should().HaveCount(episodes.Count); - - } - - [Test] - public void should_override_empty_airdate_for_direct_to_dvd() - { - var series = GetSeries(); - series.Status = SeriesStatusType.Ended; - - var episodes = Builder.CreateListOfSize(10) - .All() - .With(v => v.AirDateUtc = null) - .BuildListOfNew(); - - Mocker.GetMock().Setup(c => c.GetEpisodeBySeries(It.IsAny())) - .Returns(new List()); - - List updateEpisodes = null; - Mocker.GetMock().Setup(c => c.InsertMany(It.IsAny>())) - .Callback>(c => updateEpisodes = c); - - Subject.RefreshEpisodeInfo(series, episodes); - - updateEpisodes.Should().NotBeNull(); - updateEpisodes.Should().NotBeEmpty(); - updateEpisodes.All(v => v.AirDateUtc.HasValue).Should().BeTrue(); - } - - [Test] - public void should_use_tba_for_episode_title_when_null() - { - Mocker.GetMock().Setup(c => c.GetEpisodeBySeries(It.IsAny())) - .Returns(new List()); - - var episodes = Builder.CreateListOfSize(1) - .All() - .With(e => e.Title = null) - .Build() - .ToList(); - - Subject.RefreshEpisodeInfo(GetSeries(), episodes); - - _insertedEpisodes.First().Title.Should().Be("TBA"); - } - - [Test] - public void should_update_air_date_when_multiple_episodes_air_on_the_same_day() - { - Mocker.GetMock().Setup(c => c.GetEpisodeBySeries(It.IsAny())) - .Returns(new List()); - - var series = GetSeries(); - - var episodes = Builder.CreateListOfSize(2) - .All() - .With(e => e.SeasonNumber = 1) - .With(e => e.AirDate = DateTime.Now.ToShortDateString()) - .With(e => e.AirDateUtc = DateTime.UtcNow) - .Build() - .ToList(); - - Subject.RefreshEpisodeInfo(series, episodes); - - _insertedEpisodes.First().AirDateUtc.Value.ToString("s").Should().Be(episodes.First().AirDateUtc.Value.ToString("s")); - _insertedEpisodes.Last().AirDateUtc.Value.ToString("s").Should().Be(episodes.First().AirDateUtc.Value.AddMinutes(series.Runtime).ToString("s")); - } - - [Test] - public void should_not_update_air_date_when_multiple_episodes_air_on_the_same_day_for_netflix() - { - Mocker.GetMock().Setup(c => c.GetEpisodeBySeries(It.IsAny())) - .Returns(new List()); - - var series = GetSeries(); - series.Network = "Netflix"; - - var episodes = Builder.CreateListOfSize(2) - .All() - .With(e => e.SeasonNumber = 1) - .With(e => e.AirDate = DateTime.Now.ToShortDateString()) - .With(e => e.AirDateUtc = DateTime.UtcNow) - .Build() - .ToList(); - - Subject.RefreshEpisodeInfo(series, episodes); - - _insertedEpisodes.Should().OnlyContain(e => e.AirDateUtc.Value.ToString("s") == episodes.First().AirDateUtc.Value.ToString("s")); - } - - [Test] - public void should_prefer_regular_season_when_absolute_numbers_conflict() - { - var episodes = Builder.CreateListOfSize(2) - .Build() - .ToList(); - - episodes[0].AbsoluteEpisodeNumber = episodes[1].AbsoluteEpisodeNumber; - episodes[0].SeasonNumber = 0; - episodes[0].EpisodeNumber.Should().NotBe(episodes[1].EpisodeNumber); - - var existingEpisode = new Episode - { - SeasonNumber = episodes[0].SeasonNumber, - EpisodeNumber = episodes[0].EpisodeNumber, - AbsoluteEpisodeNumber = episodes[1].AbsoluteEpisodeNumber - }; - - Mocker.GetMock().Setup(c => c.GetEpisodeBySeries(It.IsAny())) - .Returns(new List { existingEpisode }); - - Subject.RefreshEpisodeInfo(GetAnimeSeries(), episodes); - - _updatedEpisodes.First().SeasonNumber.Should().Be(episodes[1].SeasonNumber); - _updatedEpisodes.First().EpisodeNumber.Should().Be(episodes[1].EpisodeNumber); - _updatedEpisodes.First().AbsoluteEpisodeNumber.Should().Be(episodes[1].AbsoluteEpisodeNumber); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/TvTests/RefreshSeriesServiceFixture.cs b/src/NzbDrone.Core.Test/TvTests/RefreshSeriesServiceFixture.cs deleted file mode 100644 index f441496cd..000000000 --- a/src/NzbDrone.Core.Test/TvTests/RefreshSeriesServiceFixture.cs +++ /dev/null @@ -1,184 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; -using Moq; -using NUnit.Framework; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Exceptions; -using NzbDrone.Core.MetadataSource; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Tv.Commands; -using NzbDrone.Test.Common; - -namespace NzbDrone.Core.Test.TvTests -{ - [TestFixture] - public class RefreshSeriesServiceFixture : CoreTest - { - private Series _series; - - [SetUp] - public void Setup() - { - var season1 = Builder.CreateNew() - .With(s => s.SeasonNumber = 1) - .Build(); - - _series = Builder.CreateNew() - .With(s => s.Seasons = new List - { - season1 - }) - .Build(); - - Mocker.GetMock() - .Setup(s => s.GetSeries(_series.Id)) - .Returns(_series); - - Mocker.GetMock() - .Setup(s => s.GetSeriesInfo(It.IsAny())) - .Callback(p => { throw new SeriesNotFoundException(p); }); - } - - private void GivenNewSeriesInfo(Series series) - { - Mocker.GetMock() - .Setup(s => s.GetSeriesInfo(_series.TvdbId)) - .Returns(new Tuple>(series, new List())); - } - - [Test] - public void should_monitor_new_seasons_automatically() - { - var newSeriesInfo = _series.JsonClone(); - newSeriesInfo.Seasons.Add(Builder.CreateNew() - .With(s => s.SeasonNumber = 2) - .Build()); - - GivenNewSeriesInfo(newSeriesInfo); - - Subject.Execute(new RefreshSeriesCommand(_series.Id)); - - Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Count == 2 && s.Seasons.Single(season => season.SeasonNumber == 2).Monitored == true))); - } - - [Test] - public void should_not_monitor_new_special_season_automatically() - { - var series = _series.JsonClone(); - series.Seasons.Add(Builder.CreateNew() - .With(s => s.SeasonNumber = 0) - .Build()); - - GivenNewSeriesInfo(series); - - Subject.Execute(new RefreshSeriesCommand(_series.Id)); - - Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Count == 2 && s.Seasons.Single(season => season.SeasonNumber == 0).Monitored == false))); - } - - [Test] - public void should_update_tvrage_id_if_changed() - { - var newSeriesInfo = _series.JsonClone(); - newSeriesInfo.TvRageId = _series.TvRageId + 1; - - GivenNewSeriesInfo(newSeriesInfo); - - Subject.Execute(new RefreshSeriesCommand(_series.Id)); - - Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.TvRageId == newSeriesInfo.TvRageId))); - } - - [Test] - public void should_update_tvmaze_id_if_changed() - { - var newSeriesInfo = _series.JsonClone(); - newSeriesInfo.TvMazeId = _series.TvMazeId + 1; - - GivenNewSeriesInfo(newSeriesInfo); - - Subject.Execute(new RefreshSeriesCommand(_series.Id)); - - Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.TvMazeId == newSeriesInfo.TvMazeId))); - } - - [Test] - public void should_log_error_if_tvdb_id_not_found() - { - Subject.Execute(new RefreshSeriesCommand(_series.Id)); - - Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.IsAny()), Times.Never()); - - ExceptionVerification.ExpectedErrors(1); - } - - [Test] - public void should_update_if_tvdb_id_changed() - { - var newSeriesInfo = _series.JsonClone(); - newSeriesInfo.TvdbId = _series.TvdbId + 1; - - GivenNewSeriesInfo(newSeriesInfo); - - Subject.Execute(new RefreshSeriesCommand(_series.Id)); - - Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.TvdbId == newSeriesInfo.TvdbId))); - - ExceptionVerification.ExpectedWarns(1); - } - - [Test] - public void should_not_throw_if_duplicate_season_is_in_existing_info() - { - var newSeriesInfo = _series.JsonClone(); - newSeriesInfo.Seasons.Add(Builder.CreateNew() - .With(s => s.SeasonNumber = 2) - .Build()); - - _series.Seasons.Add(Builder.CreateNew() - .With(s => s.SeasonNumber = 2) - .Build()); - - _series.Seasons.Add(Builder.CreateNew() - .With(s => s.SeasonNumber = 2) - .Build()); - - GivenNewSeriesInfo(newSeriesInfo); - - Subject.Execute(new RefreshSeriesCommand(_series.Id)); - - Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Count == 2))); - } - - [Test] - public void should_filter_duplicate_seasons() - { - var newSeriesInfo = _series.JsonClone(); - newSeriesInfo.Seasons.Add(Builder.CreateNew() - .With(s => s.SeasonNumber = 2) - .Build()); - - newSeriesInfo.Seasons.Add(Builder.CreateNew() - .With(s => s.SeasonNumber = 2) - .Build()); - - GivenNewSeriesInfo(newSeriesInfo); - - Subject.Execute(new RefreshSeriesCommand(_series.Id)); - - Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Count == 2))); - - } - } -} diff --git a/src/NzbDrone.Core.Test/TvTests/SeriesServiceTests/AddSeriesFixture.cs b/src/NzbDrone.Core.Test/TvTests/SeriesServiceTests/AddSeriesFixture.cs deleted file mode 100644 index c1b542d2f..000000000 --- a/src/NzbDrone.Core.Test/TvTests/SeriesServiceTests/AddSeriesFixture.cs +++ /dev/null @@ -1,39 +0,0 @@ -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Organizer; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv.Events; - -namespace NzbDrone.Core.Test.TvTests.SeriesServiceTests -{ - [TestFixture] - public class AddSeriesFixture : CoreTest - { - private Series fakeSeries; - - [SetUp] - public void Setup() - { - fakeSeries = Builder.CreateNew().Build(); - } - - [Test] - public void series_added_event_should_have_proper_path() - { - fakeSeries.Path = null; - fakeSeries.RootFolderPath = @"C:\Test\TV"; - - Mocker.GetMock() - .Setup(s => s.GetSeriesFolder(fakeSeries, null)) - .Returns(fakeSeries.Title); - - var series = Subject.AddSeries(fakeSeries); - - series.Path.Should().NotBeNull(); - - } - - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/TvTests/SeriesServiceTests/UpdateSeriesFixture.cs b/src/NzbDrone.Core.Test/TvTests/SeriesServiceTests/UpdateSeriesFixture.cs deleted file mode 100644 index 23f77223c..000000000 --- a/src/NzbDrone.Core.Test/TvTests/SeriesServiceTests/UpdateSeriesFixture.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; -using Moq; -using NUnit.Framework; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.TvTests.SeriesServiceTests -{ - [TestFixture] - public class UpdateSeriesFixture : CoreTest - { - private Series _fakeSeries; - private Series _existingSeries; - - [SetUp] - public void Setup() - { - _fakeSeries = Builder.CreateNew().Build(); - _existingSeries = Builder.CreateNew().Build(); - - _fakeSeries.Seasons = new List - { - new Season{ SeasonNumber = 1, Monitored = true }, - new Season{ SeasonNumber = 2, Monitored = true } - }; - - _existingSeries.Seasons = new List - { - new Season{ SeasonNumber = 1, Monitored = true }, - new Season{ SeasonNumber = 2, Monitored = true } - }; - } - - private void GivenExistingSeries() - { - Mocker.GetMock() - .Setup(s => s.Get(It.IsAny())) - .Returns(_existingSeries); - } - - [Test] - public void should_not_update_episodes_if_season_hasnt_changed() - { - GivenExistingSeries(); - - Subject.UpdateSeries(_fakeSeries); - - Mocker.GetMock() - .Verify(v => v.SetEpisodeMonitoredBySeason(_fakeSeries.Id, It.IsAny(), It.IsAny()), Times.Never()); - } - - [Test] - public void should_update_series_when_it_changes() - { - GivenExistingSeries(); - var seasonNumber = 1; - var monitored = false; - - _fakeSeries.Seasons.Single(s => s.SeasonNumber == seasonNumber).Monitored = monitored; - - Subject.UpdateSeries(_fakeSeries); - - Mocker.GetMock() - .Verify(v => v.SetEpisodeMonitoredBySeason(_fakeSeries.Id, seasonNumber, monitored), Times.Once()); - - Mocker.GetMock() - .Verify(v => v.SetEpisodeMonitoredBySeason(_fakeSeries.Id, It.IsAny(), It.IsAny()), Times.Once()); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/TvTests/ShouldRefreshSeriesFixture.cs b/src/NzbDrone.Core.Test/TvTests/ShouldRefreshSeriesFixture.cs deleted file mode 100644 index 6fb44c09a..000000000 --- a/src/NzbDrone.Core.Test/TvTests/ShouldRefreshSeriesFixture.cs +++ /dev/null @@ -1,135 +0,0 @@ -using System; -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Tv; -using NzbDrone.Test.Common; - -namespace NzbDrone.Core.Test.TvTests -{ - [TestFixture] - public class ShouldRefreshSeriesFixture : TestBase - { - private Series _series; - - [SetUp] - public void Setup() - { - _series = Builder.CreateNew() - .With(v => v.Status == SeriesStatusType.Continuing) - .Build(); - - Mocker.GetMock() - .Setup(s => s.GetEpisodeBySeries(_series.Id)) - .Returns(Builder.CreateListOfSize(2) - .All() - .With(e => e.AirDateUtc = DateTime.Today.AddDays(-100)) - .Build() - .ToList()); - } - - private void GivenSeriesIsEnded() - { - _series.Status = SeriesStatusType.Ended; - } - - private void GivenSeriesLastRefreshedMonthsAgo() - { - _series.LastInfoSync = DateTime.UtcNow.AddDays(-90); - } - - private void GivenSeriesLastRefreshedYesterday() - { - _series.LastInfoSync = DateTime.UtcNow.AddDays(-1); - } - - private void GivenSeriesLastRefreshedHalfADayAgo() - { - _series.LastInfoSync = DateTime.UtcNow.AddHours(-12); - } - - private void GivenSeriesLastRefreshedRecently() - { - _series.LastInfoSync = DateTime.UtcNow.AddHours(-1); - } - - private void GivenRecentlyAired() - { - Mocker.GetMock() - .Setup(s => s.GetEpisodeBySeries(_series.Id)) - .Returns(Builder.CreateListOfSize(2) - .TheFirst(1) - .With(e => e.AirDateUtc = DateTime.Today.AddDays(-7)) - .TheLast(1) - .With(e => e.AirDateUtc = DateTime.Today.AddDays(-100)) - .Build() - .ToList()); - } - - [Test] - public void should_return_true_if_running_series_last_refreshed_more_than_6_hours_ago() - { - GivenSeriesLastRefreshedHalfADayAgo(); - - Subject.ShouldRefresh(_series).Should().BeTrue(); - } - - [Test] - public void should_return_false_if_running_series_last_refreshed_less_than_6_hours_ago() - { - GivenSeriesLastRefreshedRecently(); - - Subject.ShouldRefresh(_series).Should().BeFalse(); - } - - [Test] - public void should_return_false_if_ended_series_last_refreshed_yesterday() - { - GivenSeriesIsEnded(); - GivenSeriesLastRefreshedYesterday(); - - Subject.ShouldRefresh(_series).Should().BeFalse(); - } - - [Test] - public void should_return_true_if_series_last_refreshed_more_than_30_days_ago() - { - GivenSeriesIsEnded(); - GivenSeriesLastRefreshedMonthsAgo(); - - Subject.ShouldRefresh(_series).Should().BeTrue(); - } - - [Test] - public void should_return_true_if_episode_aired_in_last_30_days() - { - GivenSeriesIsEnded(); - GivenSeriesLastRefreshedYesterday(); - - GivenRecentlyAired(); - - Subject.ShouldRefresh(_series).Should().BeTrue(); - } - - [Test] - public void should_return_false_when_recently_refreshed_ended_show_has_not_aired_for_30_days() - { - GivenSeriesIsEnded(); - GivenSeriesLastRefreshedYesterday(); - - Subject.ShouldRefresh(_series).Should().BeFalse(); - } - - [Test] - public void should_return_false_when_recently_refreshed_ended_show_aired_in_last_30_days() - { - GivenSeriesIsEnded(); - GivenSeriesLastRefreshedRecently(); - - GivenRecentlyAired(); - - Subject.ShouldRefresh(_series).Should().BeFalse(); - } - } -} diff --git a/src/NzbDrone.Core/Blacklisting/Blacklist.cs b/src/NzbDrone.Core/Blacklisting/Blacklist.cs index 18f4f9de2..6f30cf553 100644 --- a/src/NzbDrone.Core/Blacklisting/Blacklist.cs +++ b/src/NzbDrone.Core/Blacklisting/Blacklist.cs @@ -1,19 +1,16 @@ -using System; +using System; using System.Collections.Generic; using NzbDrone.Core.Datastore; using NzbDrone.Core.Indexers; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Blacklisting { public class Blacklist : ModelBase { - public int SeriesId { get; set; } - public Series Series { get; set; } public int MovieId { get; set; } public Movie Movie { get; set; } - public List EpisodeIds { get; set; } public string SourceTitle { get; set; } public QualityModel Quality { get; set; } public DateTime Date { get; set; } diff --git a/src/NzbDrone.Core/Blacklisting/BlacklistRepository.cs b/src/NzbDrone.Core/Blacklisting/BlacklistRepository.cs index 4094c1519..168e495c5 100644 --- a/src/NzbDrone.Core/Blacklisting/BlacklistRepository.cs +++ b/src/NzbDrone.Core/Blacklisting/BlacklistRepository.cs @@ -1,16 +1,16 @@ -using System.Collections.Generic; +using System.Collections.Generic; using NzbDrone.Core.Datastore; using NzbDrone.Core.Messaging.Events; using Marr.Data.QGen; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Blacklisting { public interface IBlacklistRepository : IBasicRepository { - List BlacklistedByTitle(int seriesId, string sourceTitle); - List BlacklistedByTorrentInfoHash(int seriesId, string torrentInfoHash); - List BlacklistedByMovie(int seriesId); + List BlacklistedByTitle(int movieId, string sourceTitle); + List BlacklistedByTorrentInfoHash(int movieId, string torrentInfoHash); + List BlacklistedByMovie(int movieId); } public class BlacklistRepository : BasicRepository, IBlacklistRepository @@ -32,11 +32,6 @@ namespace NzbDrone.Core.Blacklisting .AndWhere(e => e.TorrentInfoHash.Contains(torrentInfoHash)); } - public List BlacklistedBySeries(int seriesId) - { - return Query.Where(b => b.SeriesId == seriesId); - } - public List BlacklistedByMovie(int movieId) { return Query.Where(b => b.MovieId == movieId); diff --git a/src/NzbDrone.Core/Blacklisting/BlacklistService.cs b/src/NzbDrone.Core/Blacklisting/BlacklistService.cs index ded3a573f..bb9fbc7ec 100644 --- a/src/NzbDrone.Core/Blacklisting/BlacklistService.cs +++ b/src/NzbDrone.Core/Blacklisting/BlacklistService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using NzbDrone.Common.Extensions; using NzbDrone.Core.Datastore; @@ -7,13 +7,13 @@ using NzbDrone.Core.Indexers; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv.Events; +using NzbDrone.Core.Movies.Events; namespace NzbDrone.Core.Blacklisting { public interface IBlacklistService { - bool Blacklisted(int seriesId, ReleaseInfo release); + bool Blacklisted(int movieId, ReleaseInfo release); PagingSpec Paged(PagingSpec pagingSpec); void Delete(int id); } @@ -30,9 +30,9 @@ namespace NzbDrone.Core.Blacklisting _blacklistRepository = blacklistRepository; } - public bool Blacklisted(int seriesId, ReleaseInfo release) + public bool Blacklisted(int movieId, ReleaseInfo release) { - var blacklistedByTitle = _blacklistRepository.BlacklistedByTitle(seriesId, release.Title); + var blacklistedByTitle = _blacklistRepository.BlacklistedByTitle(movieId, release.Title); if (release.DownloadProtocol == DownloadProtocol.Torrent) { @@ -46,7 +46,7 @@ namespace NzbDrone.Core.Blacklisting .Any(b => SameTorrent(b, torrentInfo)); } - var blacklistedByTorrentInfohash = _blacklistRepository.BlacklistedByTorrentInfoHash(seriesId, torrentInfo.InfoHash); + var blacklistedByTorrentInfohash = _blacklistRepository.BlacklistedByTorrentInfoHash(movieId, torrentInfo.InfoHash); return blacklistedByTorrentInfohash.Any(b => SameTorrent(b, torrentInfo)); } @@ -128,8 +128,6 @@ namespace NzbDrone.Core.Blacklisting { var blacklist = new Blacklist { - SeriesId = 0, - EpisodeIds = null, MovieId = message.MovieId, SourceTitle = message.SourceTitle, Quality = message.Quality, diff --git a/src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeries.cs b/src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeries.cs deleted file mode 100644 index 829ce6a24..000000000 --- a/src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeries.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace NzbDrone.Core.DataAugmentation.DailySeries -{ - public class DailySeries - { - public int TvdbId { get; set; } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesDataProxy.cs b/src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesDataProxy.cs deleted file mode 100644 index 6d1778bdc..000000000 --- a/src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesDataProxy.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using NLog; -using NzbDrone.Common.Cloud; -using NzbDrone.Common.Http; - -namespace NzbDrone.Core.DataAugmentation.DailySeries -{ - public interface IDailySeriesDataProxy - { - IEnumerable GetDailySeriesIds(); - } - - public class DailySeriesDataProxy : IDailySeriesDataProxy - { - private readonly IHttpClient _httpClient; - private readonly IHttpRequestBuilderFactory _requestBuilder; - private readonly Logger _logger; - - public DailySeriesDataProxy(IHttpClient httpClient, ISonarrCloudRequestBuilder requestBuilder, Logger logger) - { - _httpClient = httpClient; - _requestBuilder = requestBuilder.Services; - _logger = logger; - } - - public IEnumerable GetDailySeriesIds() - { - try - { - var dailySeriesRequest = _requestBuilder.Create() - .Resource("/dailyseries") - .Build(); - - var response = _httpClient.Get>(dailySeriesRequest); - return response.Resource.Select(c => c.TvdbId); - } - catch (Exception ex) - { - _logger.Warn(ex, "Failed to get Daily Series"); - return new List(); - } - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesService.cs b/src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesService.cs deleted file mode 100644 index 6eb5f874a..000000000 --- a/src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesService.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using NzbDrone.Common.Cache; - -namespace NzbDrone.Core.DataAugmentation.DailySeries -{ - public interface IDailySeriesService - { - bool IsDailySeries(int tvdbid); - } - - public class DailySeriesService : IDailySeriesService - { - private readonly IDailySeriesDataProxy _proxy; - private readonly ICached> _cache; - - public DailySeriesService(IDailySeriesDataProxy proxy, ICacheManager cacheManager) - { - _proxy = proxy; - _cache = cacheManager.GetCache>(GetType()); - } - - public bool IsDailySeries(int tvdbid) - { - var dailySeries = _cache.Get("all", () => _proxy.GetDailySeriesIds().ToList(), TimeSpan.FromHours(1)); - return dailySeries.Any(i => i == tvdbid); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/DataAugmentation/Scene/ISceneMappingProvider.cs b/src/NzbDrone.Core/DataAugmentation/Scene/ISceneMappingProvider.cs deleted file mode 100644 index 58b69f2b9..000000000 --- a/src/NzbDrone.Core/DataAugmentation/Scene/ISceneMappingProvider.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Collections.Generic; - -namespace NzbDrone.Core.DataAugmentation.Scene -{ - public interface ISceneMappingProvider - { - List GetSceneMappings(); - } -} diff --git a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMapping.cs b/src/NzbDrone.Core/DataAugmentation/Scene/SceneMapping.cs deleted file mode 100644 index b992aa029..000000000 --- a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMapping.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Newtonsoft.Json; -using NzbDrone.Core.Datastore; - -namespace NzbDrone.Core.DataAugmentation.Scene -{ - public class SceneMapping : ModelBase - { - public string Title { get; set; } - public string ParseTerm { get; set; } - - [JsonProperty("searchTitle")] - public string SearchTerm { get; set; } - - public int TvdbId { get; set; } - - [JsonProperty("season")] - public int? SeasonNumber { get; set; } - - public int? SceneSeasonNumber { get; set; } - public string Type { get; set; } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingProxy.cs b/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingProxy.cs deleted file mode 100644 index 735af870b..000000000 --- a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingProxy.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections.Generic; -using NzbDrone.Common.Cloud; -using NzbDrone.Common.Http; - -namespace NzbDrone.Core.DataAugmentation.Scene -{ - public interface ISceneMappingProxy - { - List Fetch(); - } - - public class SceneMappingProxy : ISceneMappingProxy - { - private readonly IHttpClient _httpClient; - private readonly IHttpRequestBuilderFactory _requestBuilder; - - public SceneMappingProxy(IHttpClient httpClient, ISonarrCloudRequestBuilder requestBuilder) - { - _httpClient = httpClient; - _requestBuilder = requestBuilder.Services; - } - - public List Fetch() - { - var request = _requestBuilder.Create() - .Resource("/scenemapping") - .Build(); - - return _httpClient.Get>(request).Resource; - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingRepository.cs b/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingRepository.cs deleted file mode 100644 index ce86916ec..000000000 --- a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingRepository.cs +++ /dev/null @@ -1,31 +0,0 @@ -using NzbDrone.Core.Datastore; -using NzbDrone.Core.Messaging.Events; -using System.Collections.Generic; - - -namespace NzbDrone.Core.DataAugmentation.Scene -{ - public interface ISceneMappingRepository : IBasicRepository - { - List FindByTvdbid(int tvdbId); - void Clear(string type); - } - - public class SceneMappingRepository : BasicRepository, ISceneMappingRepository - { - public SceneMappingRepository(IMainDatabase database, IEventAggregator eventAggregator) - : base(database, eventAggregator) - { - } - - public List FindByTvdbid(int tvdbId) - { - return Query.Where(x => x.TvdbId == tvdbId); - } - - public void Clear(string type) - { - Delete(s => s.Type == type); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs b/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs deleted file mode 100644 index caa04ae42..000000000 --- a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs +++ /dev/null @@ -1,253 +0,0 @@ -using System; -using System.Linq; -using NLog; -using NzbDrone.Common.Cache; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Messaging.Commands; -using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Parser; -using System.Collections.Generic; -using NzbDrone.Core.Tv.Events; - -namespace NzbDrone.Core.DataAugmentation.Scene -{ - public interface ISceneMappingService - { - List GetSceneNames(int tvdbId, List seasonNumbers, List sceneSeasonNumbers); - int? FindTvdbId(string title); - List FindByTvdbId(int tvdbId); - SceneMapping FindSceneMapping(string title); - int? GetSceneSeasonNumber(string title); - int? GetTvdbSeasonNumber(string title); - int? GetSceneSeasonNumber(int tvdbId, int seasonNumber); - } - - public class SceneMappingService : ISceneMappingService, - IHandle, - IExecute - { - private readonly ISceneMappingRepository _repository; - private readonly IEnumerable _sceneMappingProviders; - private readonly IEventAggregator _eventAggregator; - private readonly Logger _logger; - private readonly ICachedDictionary> _getTvdbIdCache; - private readonly ICachedDictionary> _findByTvdbIdCache; - - public SceneMappingService(ISceneMappingRepository repository, - ICacheManager cacheManager, - IEnumerable sceneMappingProviders, - IEventAggregator eventAggregator, - Logger logger) - { - _repository = repository; - _sceneMappingProviders = sceneMappingProviders; - _eventAggregator = eventAggregator; - _logger = logger; - - _getTvdbIdCache = cacheManager.GetCacheDictionary>(GetType(), "tvdb_id"); - _findByTvdbIdCache = cacheManager.GetCacheDictionary>(GetType(), "find_tvdb_id"); - } - - public List GetSceneNames(int tvdbId, List seasonNumbers, List sceneSeasonNumbers) - { - var mappings = FindByTvdbId(tvdbId); - - if (mappings == null) - { - return new List(); - } - - var names = mappings.Where(n => n.SeasonNumber.HasValue && seasonNumbers.Contains(n.SeasonNumber.Value) || - n.SceneSeasonNumber.HasValue && sceneSeasonNumbers.Contains(n.SceneSeasonNumber.Value) || - (n.SeasonNumber ?? -1) == -1 && (n.SceneSeasonNumber ?? -1) == -1) - .Select(n => n.SearchTerm).Distinct().ToList(); - - return FilterNonEnglish(names); - } - - public int? FindTvdbId(string title) - { - var mapping = FindMapping(title); - - if (mapping == null) - return null; - - return mapping.TvdbId; - } - - public List FindByTvdbId(int tvdbId) - { - if (_findByTvdbIdCache.Count == 0) - { - RefreshCache(); - } - - var mappings = _findByTvdbIdCache.Find(tvdbId.ToString()); - - if (mappings == null) - { - return new List(); - } - - return mappings; - } - - public SceneMapping FindSceneMapping(string title) - { - return FindMapping(title); - } - - public int? GetSceneSeasonNumber(string title) - { - var mapping = FindMapping(title); - - if (mapping == null) - { - return null; - } - - return mapping.SceneSeasonNumber; - } - - public int? GetTvdbSeasonNumber(string title) - { - var mapping = FindMapping(title); - - if (mapping == null) - { - return null; - } - - return mapping.SeasonNumber; - } - - public int? GetSceneSeasonNumber(int tvdbId, int seasonNumber) - { - var mappings = FindByTvdbId(tvdbId); - - if (mappings == null) - { - return null; - } - - var mapping = mappings.FirstOrDefault(e => e.SeasonNumber == seasonNumber && e.SceneSeasonNumber.HasValue); - - if (mapping == null) - { - return null; - } - - return mapping.SceneSeasonNumber; - } - - private void UpdateMappings() - { - _logger.Info("Updating Scene mappings"); - - foreach (var sceneMappingProvider in _sceneMappingProviders) - { - try - { - var mappings = sceneMappingProvider.GetSceneMappings(); - - if (mappings.Any()) - { - _repository.Clear(sceneMappingProvider.GetType().Name); - - mappings.RemoveAll(sceneMapping => - { - if (sceneMapping.Title.IsNullOrWhiteSpace() || - sceneMapping.SearchTerm.IsNullOrWhiteSpace()) - { - _logger.Warn("Invalid scene mapping found for: {0}, skipping", sceneMapping.TvdbId); - return true; - } - - return false; - }); - - foreach (var sceneMapping in mappings) - { - sceneMapping.ParseTerm = sceneMapping.Title.CleanSeriesTitle(); - sceneMapping.Type = sceneMappingProvider.GetType().Name; - } - - _repository.InsertMany(mappings.ToList()); - } - else - { - _logger.Warn("Received empty list of mapping. will not update."); - } - } - catch (Exception ex) - { - _logger.Error(ex, "Failed to Update Scene Mappings:"); - } - } - - RefreshCache(); - - _eventAggregator.PublishEvent(new SceneMappingsUpdatedEvent()); - } - - private SceneMapping FindMapping(string title) - { - if (_getTvdbIdCache.Count == 0) - { - RefreshCache(); - } - - var candidates = _getTvdbIdCache.Find(title.CleanSeriesTitle()); - - if (candidates == null) - { - return null; - } - - if (candidates.Count == 1) - { - return candidates.First(); - } - - var exactMatch = candidates.OrderByDescending(v => v.SeasonNumber) - .FirstOrDefault(v => v.Title == title); - - if (exactMatch != null) - { - return exactMatch; - } - - var closestMatch = candidates.OrderBy(v => title.LevenshteinDistance(v.Title, 10, 1, 10)) - .ThenByDescending(v => v.SeasonNumber) - .First(); - - return closestMatch; - } - - private void RefreshCache() - { - var mappings = _repository.All().ToList(); - - _getTvdbIdCache.Update(mappings.GroupBy(v => v.ParseTerm).ToDictionary(v => v.Key, v => v.ToList())); - _findByTvdbIdCache.Update(mappings.GroupBy(v => v.TvdbId).ToDictionary(v => v.Key.ToString(), v => v.ToList())); - } - - private List FilterNonEnglish(List titles) - { - return titles.Where(title => title.All(c => c <= 255)).ToList(); - } - - public void Handle(SeriesRefreshStartingEvent message) - { - if (message.ManualTrigger && _findByTvdbIdCache.IsExpired(TimeSpan.FromMinutes(1))) - { - UpdateMappings(); - } - } - - public void Execute(UpdateSceneMappingCommand message) - { - UpdateMappings(); - } - } -} diff --git a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingsUpdatedEvent.cs b/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingsUpdatedEvent.cs deleted file mode 100644 index 06f6d4a3f..000000000 --- a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingsUpdatedEvent.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NzbDrone.Common.Messaging; - -namespace NzbDrone.Core.DataAugmentation.Scene -{ - public class SceneMappingsUpdatedEvent : IEvent - { - } -} diff --git a/src/NzbDrone.Core/DataAugmentation/Scene/ServicesProvider.cs b/src/NzbDrone.Core/DataAugmentation/Scene/ServicesProvider.cs deleted file mode 100644 index 605488cf9..000000000 --- a/src/NzbDrone.Core/DataAugmentation/Scene/ServicesProvider.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections.Generic; - -namespace NzbDrone.Core.DataAugmentation.Scene -{ - public class ServicesProvider : ISceneMappingProvider - { - private readonly ISceneMappingProxy _sceneMappingProxy; - - public ServicesProvider(ISceneMappingProxy sceneMappingProxy) - { - _sceneMappingProxy = sceneMappingProxy; - } - - public List GetSceneMappings() - { - return _sceneMappingProxy.Fetch(); - } - } -} diff --git a/src/NzbDrone.Core/DataAugmentation/Scene/UpdateSceneMappingCommand.cs b/src/NzbDrone.Core/DataAugmentation/Scene/UpdateSceneMappingCommand.cs deleted file mode 100644 index 215f8e033..000000000 --- a/src/NzbDrone.Core/DataAugmentation/Scene/UpdateSceneMappingCommand.cs +++ /dev/null @@ -1,9 +0,0 @@ -using NzbDrone.Core.Messaging.Commands; - -namespace NzbDrone.Core.DataAugmentation.Scene -{ - public class UpdateSceneMappingCommand : Command - { - - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Datastore/Migration/104_add_moviefiles_table.cs b/src/NzbDrone.Core/Datastore/Migration/104_add_moviefiles_table.cs index 34a455683..bd74367d6 100644 --- a/src/NzbDrone.Core/Datastore/Migration/104_add_moviefiles_table.cs +++ b/src/NzbDrone.Core/Datastore/Migration/104_add_moviefiles_table.cs @@ -1,7 +1,7 @@ using FluentMigrator; using Marr.Data.Mapping; using NzbDrone.Core.Datastore.Migration.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Datastore.Extensions; diff --git a/src/NzbDrone.Core/Datastore/Migration/133_add_minimumavailability.cs b/src/NzbDrone.Core/Datastore/Migration/133_add_minimumavailability.cs index b260ea0b8..7c85f54ad 100644 --- a/src/NzbDrone.Core/Datastore/Migration/133_add_minimumavailability.cs +++ b/src/NzbDrone.Core/Datastore/Migration/133_add_minimumavailability.cs @@ -1,7 +1,7 @@ using FluentMigrator; //using FluentMigrator.Expressions; using NzbDrone.Core.Datastore.Migration.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Datastore.Migration { diff --git a/src/NzbDrone.Core/Datastore/Migration/136_add_pathstate_to_movies.cs b/src/NzbDrone.Core/Datastore/Migration/136_add_pathstate_to_movies.cs index 004bd1b16..2b205ff27 100644 --- a/src/NzbDrone.Core/Datastore/Migration/136_add_pathstate_to_movies.cs +++ b/src/NzbDrone.Core/Datastore/Migration/136_add_pathstate_to_movies.cs @@ -1,7 +1,7 @@ using System.Data; using FluentMigrator; using NzbDrone.Core.Datastore.Migration.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Datastore.Migration { diff --git a/src/NzbDrone.Core/Datastore/Migration/138_add_physical_release_note.cs b/src/NzbDrone.Core/Datastore/Migration/138_add_physical_release_note.cs index f24c8dcf9..42bc11aef 100644 --- a/src/NzbDrone.Core/Datastore/Migration/138_add_physical_release_note.cs +++ b/src/NzbDrone.Core/Datastore/Migration/138_add_physical_release_note.cs @@ -1,7 +1,7 @@ using System.Data; using FluentMigrator; using NzbDrone.Core.Datastore.Migration.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Datastore.Migration { diff --git a/src/NzbDrone.Core/Datastore/Migration/143_clean_core_tv.cs b/src/NzbDrone.Core/Datastore/Migration/143_clean_core_tv.cs new file mode 100644 index 000000000..b2b9729a2 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/143_clean_core_tv.cs @@ -0,0 +1,36 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(143)] + public class clean_core_tv : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Delete.Table("Episodes"); + Delete.Table("EpisodeFiles"); + Delete.Table("Series"); + Delete.Table("SceneMappings"); + + Delete.Column("SeriesId") + .Column("EpisodeIds") + .FromTable("Blacklist"); + + Delete.Column("SeriesId") + .Column("EpisodeId") + .FromTable("History"); + + Delete.Column("StandardEpisodeFormat") + .Column("DailyEpisodeFormat") + .Column("AnimeEpisodeFormat") + .Column("SeasonFolderFormat") + .Column("SeriesFolderFormat") + .FromTable("NamingConfig"); + + Delete.Column("SeriesId") + .Column("ParsedEpisodeInfo") + .FromTable("PendingReleases"); + } + } +} diff --git a/src/NzbDrone.Core/Datastore/TableMapping.cs b/src/NzbDrone.Core/Datastore/TableMapping.cs index fe9333a4e..05bda27ac 100644 --- a/src/NzbDrone.Core/Datastore/TableMapping.cs +++ b/src/NzbDrone.Core/Datastore/TableMapping.cs @@ -5,7 +5,6 @@ using Marr.Data.Mapping; using NzbDrone.Common.Reflection; using NzbDrone.Core.Blacklisting; using NzbDrone.Core.Configuration; -using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.Datastore.Converters; using NzbDrone.Core.Datastore.Extensions; using NzbDrone.Core.Download; @@ -23,10 +22,9 @@ using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; using NzbDrone.Core.Restrictions; using NzbDrone.Core.RootFolders; -using NzbDrone.Core.SeriesStats; using NzbDrone.Core.Tags; using NzbDrone.Core.ThingiProvider; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Common.Disk; using NzbDrone.Core.Authentication; using NzbDrone.Core.Extras.Metadata; @@ -78,27 +76,10 @@ namespace NzbDrone.Core.Datastore Mapper.Entity().RegisterDefinition("DownloadClients") .Ignore(d => d.Protocol); - Mapper.Entity().RegisterModel("SceneMappings"); - Mapper.Entity().RegisterModel("History") .AutoMapChildModels(); - Mapper.Entity().RegisterModel("Series") - .Ignore(s => s.RootFolderPath) - .Relationship() - .HasOne(s => s.Profile, s => s.ProfileId); - - - - Mapper.Entity().RegisterModel("EpisodeFiles") - .Ignore(f => f.Path) - .Relationships.AutoMapICollectionOrComplexProperties() - .For("Episodes") - .LazyLoad(condition: parent => parent.Id > 0, - query: (db, parent) => db.Query().Where(c => c.EpisodeFileId == parent.Id).ToList()) - .HasOne(file => file.Series, file => file.SeriesId); - - Mapper.Entity().RegisterModel("MovieFiles") + Mapper.Entity().RegisterModel("MovieFiles") .Ignore(f => f.Path) .Relationships.AutoMapICollectionOrComplexProperties() .For("Movie") @@ -124,28 +105,19 @@ namespace NzbDrone.Core.Datastore Mapper.Entity().RegisterModel("ImportExclusions"); - - Mapper.Entity().RegisterModel("Episodes") - .Ignore(e => e.SeriesTitle) - .Ignore(e => e.Series) - .Ignore(e => e.HasFile) - .Relationship() - .HasOne(episode => episode.EpisodeFile, episode => episode.EpisodeFileId); - Mapper.Entity().RegisterModel("QualityDefinitions") .Ignore(d => d.Weight); Mapper.Entity().RegisterModel("Profiles"); Mapper.Entity().RegisterModel("Logs"); Mapper.Entity().RegisterModel("NamingConfig"); - Mapper.Entity().MapResultSet(); Mapper.Entity().RegisterModel("Blacklist"); Mapper.Entity().RegisterModel("MetadataFiles"); Mapper.Entity().RegisterModel("SubtitleFiles"); Mapper.Entity().RegisterModel("ExtraFiles"); Mapper.Entity().RegisterModel("PendingReleases") - .Ignore(e => e.RemoteEpisode); + .Ignore(e => e.RemoteMovie); Mapper.Entity().RegisterModel("RemotePathMappings"); Mapper.Entity().RegisterModel("Tags"); @@ -176,7 +148,6 @@ namespace NzbDrone.Core.Datastore MapRepository.Instance.RegisterTypeConverter(typeof(Dictionary), new EmbeddedDocumentConverter()); MapRepository.Instance.RegisterTypeConverter(typeof(List), new EmbeddedDocumentConverter()); MapRepository.Instance.RegisterTypeConverter(typeof(List), new EmbeddedDocumentConverter()); - MapRepository.Instance.RegisterTypeConverter(typeof(ParsedEpisodeInfo), new EmbeddedDocumentConverter()); MapRepository.Instance.RegisterTypeConverter(typeof(ParsedMovieInfo), new EmbeddedDocumentConverter()); MapRepository.Instance.RegisterTypeConverter(typeof(ReleaseInfo), new EmbeddedDocumentConverter()); MapRepository.Instance.RegisterTypeConverter(typeof(HashSet), new EmbeddedDocumentConverter()); diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecision.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecision.cs index d3e1412c0..0d570806f 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecision.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecision.cs @@ -6,11 +6,8 @@ namespace NzbDrone.Core.DecisionEngine { public class DownloadDecision { - public RemoteEpisode RemoteEpisode { get; private set; } - public RemoteMovie RemoteMovie { get; private set; } - - public bool IsForMovie = true; + public IEnumerable Rejections { get; private set; } public bool Approved => !Rejections.Any(); @@ -31,29 +28,9 @@ namespace NzbDrone.Core.DecisionEngine } } - public DownloadDecision(RemoteEpisode episode, params Rejection[] rejections) - { - RemoteEpisode = episode; - RemoteMovie = new RemoteMovie - { - Release = episode.Release, - ParsedEpisodeInfo = episode.ParsedEpisodeInfo - }; - Rejections = rejections.ToList(); - } - public DownloadDecision(RemoteMovie movie, params Rejection[] rejections) { RemoteMovie = movie; - if (movie != null) - { - RemoteEpisode = new RemoteEpisode - { - Release = movie.Release, - ParsedEpisodeInfo = new ParsedEpisodeInfo() - }; - } - IsForMovie = true; Rejections = rejections.ToList(); } @@ -61,10 +38,10 @@ namespace NzbDrone.Core.DecisionEngine { if (Approved) { - return "[OK] " + RemoteEpisode; + return "[OK] " + RemoteMovie; } - return "[Rejected " + Rejections.Count() + "]" + RemoteEpisode; + return "[Rejected " + Rejections.Count() + "]" + RemoteMovie; } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionComparer.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionComparer.cs index f965caa05..dea75885d 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionComparer.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionComparer.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using NzbDrone.Core.Indexers; @@ -49,7 +49,7 @@ namespace NzbDrone.Core.DecisionEngine private int CompareByReverse(TSubject left, TSubject right, Func funcValue) where TValue : IComparable { - return CompareBy(left, right, funcValue)*-1; + return CompareBy(left, right, funcValue) * -1; } private int CompareAll(params int[] comparers) @@ -59,15 +59,9 @@ namespace NzbDrone.Core.DecisionEngine private int CompareQuality(DownloadDecision x, DownloadDecision y) { - if (x.IsForMovie && y.IsForMovie) - { - return CompareAll(CompareBy(x.RemoteMovie, y.RemoteMovie, remoteEpisode => remoteEpisode.Movie.Profile.Value.Items.FindIndex(v => v.Quality == remoteEpisode.ParsedMovieInfo.Quality.Quality)), - CompareBy(x.RemoteMovie, y.RemoteMovie, remoteEpisode => remoteEpisode.ParsedMovieInfo.Quality.Revision.Real), - CompareBy(x.RemoteMovie, y.RemoteMovie, remoteEpisode => remoteEpisode.ParsedMovieInfo.Quality.Revision.Version)); - } - return CompareAll(CompareBy(x.RemoteEpisode, y.RemoteEpisode, remoteEpisode => remoteEpisode.Series.Profile.Value.Items.FindIndex(v => v.Quality == remoteEpisode.ParsedEpisodeInfo.Quality.Quality)), - CompareBy(x.RemoteEpisode, y.RemoteEpisode, remoteEpisode => remoteEpisode.ParsedEpisodeInfo.Quality.Revision.Real), - CompareBy(x.RemoteEpisode, y.RemoteEpisode, remoteEpisode => remoteEpisode.ParsedEpisodeInfo.Quality.Revision.Version)); + return CompareAll(CompareBy(x.RemoteMovie, y.RemoteMovie, remoteMovie => remoteMovie.Movie.Profile.Value.Items.FindIndex(v => v.Quality == remoteMovie.ParsedMovieInfo.Quality.Quality)), + CompareBy(x.RemoteMovie, y.RemoteMovie, remoteMovie => remoteMovie.ParsedMovieInfo.Quality.Revision.Real), + CompareBy(x.RemoteMovie, y.RemoteMovie, remoteMovie => remoteMovie.ParsedMovieInfo.Quality.Revision.Version)); } private int ComparePreferredWords(DownloadDecision x, DownloadDecision y) @@ -89,7 +83,7 @@ namespace NzbDrone.Core.DecisionEngine }); } - + private int CompareIndexerFlags(DownloadDecision x, DownloadDecision y) { var releaseX = x.RemoteMovie.Release; @@ -107,44 +101,20 @@ namespace NzbDrone.Core.DecisionEngine private int CompareProtocol(DownloadDecision x, DownloadDecision y) { - - - if (x.IsForMovie) - { - return CompareBy(x.RemoteMovie, y.RemoteMovie, remoteEpisode => - { - var delayProfile = _delayProfileService.BestForTags(remoteEpisode.Movie.Tags); - var downloadProtocol = remoteEpisode.Release.DownloadProtocol; - return downloadProtocol == delayProfile.PreferredProtocol; - }); - } - - var result = CompareBy(x.RemoteEpisode, y.RemoteEpisode, remoteEpisode => + var result = CompareBy(x.RemoteMovie, y.RemoteMovie, remoteEpisode => { - var delayProfile = _delayProfileService.BestForTags(remoteEpisode.Series.Tags); + var delayProfile = _delayProfileService.BestForTags(remoteEpisode.Movie.Tags); var downloadProtocol = remoteEpisode.Release.DownloadProtocol; return downloadProtocol == delayProfile.PreferredProtocol; }); - - return result; } - private int CompareEpisodeCount(DownloadDecision x, DownloadDecision y) - { - return 0; - } - - private int CompareEpisodeNumber(DownloadDecision x, DownloadDecision y) - { - return CompareByReverse(x.RemoteEpisode, y.RemoteEpisode, remoteEpisode => remoteEpisode.Episodes.Select(e => e.EpisodeNumber).MinOrDefault()); - } - 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 + // since we're dealing with the same movie in our comparisions if (x.RemoteMovie.Release.DownloadProtocol != DownloadProtocol.Torrent || y.RemoteMovie.Release.DownloadProtocol != DownloadProtocol.Torrent) { diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs index b5c8726cc..9dbba0a4f 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using NLog; @@ -41,12 +41,7 @@ namespace NzbDrone.Core.DecisionEngine public List GetSearchDecision(List reports, SearchCriteriaBase searchCriteriaBase) { - if (searchCriteriaBase.Movie != null) - { - return GetMovieDecisions(reports, searchCriteriaBase).ToList(); - } - - return GetDecisions(reports, searchCriteriaBase).ToList(); + return GetMovieDecisions(reports, searchCriteriaBase).ToList(); } private IEnumerable GetMovieDecisions(List reports, SearchCriteriaBase searchCriteria = null) @@ -179,125 +174,12 @@ namespace NzbDrone.Core.DecisionEngine } } - private IEnumerable GetDecisions(List reports, SearchCriteriaBase searchCriteria = null) + private DownloadDecision GetDecisionForReport(RemoteMovie remoteMovie, SearchCriteriaBase searchCriteria = null) { - if (reports.Any()) - { - _logger.ProgressInfo("Processing {0} releases", reports.Count); - } - - else - { - _logger.ProgressInfo("No results found"); - } - - var reportNumber = 1; - - foreach (var report in reports) - { - DownloadDecision decision = null; - _logger.ProgressTrace("Processing release {0}/{1}", reportNumber, reports.Count); - - try - { - var parsedEpisodeInfo = Parser.Parser.ParseTitle(report.Title); - - if (parsedEpisodeInfo == null || parsedEpisodeInfo.IsPossibleSpecialEpisode) - { - var specialEpisodeInfo = _parsingService.ParseSpecialEpisodeTitle(report.Title, report.TvdbId, report.TvRageId, searchCriteria); - - if (specialEpisodeInfo != null) - { - parsedEpisodeInfo = specialEpisodeInfo; - } - } - - if (parsedEpisodeInfo != null && !parsedEpisodeInfo.SeriesTitle.IsNullOrWhiteSpace()) - { - var remoteEpisode = _parsingService.Map(parsedEpisodeInfo, report.TvdbId, report.TvRageId, searchCriteria); - remoteEpisode.Release = report; - - if (remoteEpisode.Series == null) - { - //remoteEpisode.DownloadAllowed = true; //Fuck you :) - //decision = GetDecisionForReport(remoteEpisode, searchCriteria); - decision = new DownloadDecision(remoteEpisode, new Rejection("Unknown release. Series not Found.")); - } - else if (remoteEpisode.Episodes.Empty()) - { - decision = new DownloadDecision(remoteEpisode, new Rejection("Unable to parse episodes from release name")); - } - else - { - remoteEpisode.DownloadAllowed = remoteEpisode.Episodes.Any(); - decision = GetDecisionForReport(remoteEpisode, searchCriteria); - } - } - } - catch (Exception e) - { - _logger.Error(e, "Couldn't process release."); - - var remoteEpisode = new RemoteEpisode { Release = report }; - decision = new DownloadDecision(remoteEpisode, new Rejection("Unexpected error processing release")); - } - - reportNumber++; - - if (decision != null) - { - if (decision.Rejections.Any()) - { - _logger.Debug("Release rejected for the following reasons: {0}", string.Join(", ", decision.Rejections)); - } - - else - { - _logger.Debug("Release accepted"); - } - - yield return decision; - } - } - } - - private DownloadDecision GetDecisionForReport(RemoteMovie remoteEpisode, SearchCriteriaBase searchCriteria = null) - { - var reasons = _specifications.Select(c => EvaluateSpec(c, remoteEpisode, searchCriteria)) + var reasons = _specifications.Select(c => EvaluateSpec(c, remoteMovie, searchCriteria)) .Where(c => c != null); - return new DownloadDecision(remoteEpisode, reasons.ToArray()); - } - - private DownloadDecision GetDecisionForReport(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria = null) - { - var reasons = _specifications.Select(c => EvaluateSpec(c, remoteEpisode, searchCriteria)) - .Where(c => c != null); - - return new DownloadDecision(remoteEpisode, reasons.ToArray()); - } - - private Rejection EvaluateSpec(IDecisionEngineSpecification spec, RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteriaBase = null) - { - try - { - var result = spec.IsSatisfiedBy(remoteEpisode, searchCriteriaBase); - - if (!result.Accepted) - { - return new Rejection(result.Reason, spec.Type); - } - } - catch (Exception e) - { - e.Data.Add("report", remoteEpisode.Release.ToJson()); - e.Data.Add("parsed", remoteEpisode.ParsedEpisodeInfo.ToJson()); - _logger.Error(e, "Couldn't evaluate decision on " + remoteEpisode.Release.Title + ", with spec: " + spec.GetType().Name); - //return new Rejection(string.Format("{0}: {1}", spec.GetType().Name, e.Message));//TODO UPDATE SPECS! - //return null; - } - - return null; + return new DownloadDecision(remoteMovie, reasons.ToArray()); } private Rejection EvaluateSpec(IDecisionEngineSpecification spec, RemoteMovie remoteMovie, SearchCriteriaBase searchCriteriaBase = null) diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionPriorizationService.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionPriorizationService.cs index 568641b3a..9d78f2244 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionPriorizationService.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionPriorizationService.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using System.Collections.Generic; using NzbDrone.Core.Profiles.Delay; using NzbDrone.Core.Configuration; @@ -8,7 +8,6 @@ namespace NzbDrone.Core.DecisionEngine { public interface IPrioritizeDownloadDecision { - List PrioritizeDecisions(List decisions); List PrioritizeDecisionsForMovies(List decisions); } @@ -23,18 +22,6 @@ namespace NzbDrone.Core.DecisionEngine _configService = configService; } - public List PrioritizeDecisions(List decisions) - { - return decisions.Where(c => c.RemoteEpisode.Series != null) - .GroupBy(c => c.RemoteEpisode.Series.Id, (seriesId, downloadDecisions) => - { - return downloadDecisions.OrderByDescending(decision => decision, new DownloadDecisionComparer(_delayProfileService, _configService)); - }) - .SelectMany(c => c) - .Union(decisions.Where(c => c.RemoteEpisode.Series == null)) - .ToList(); - } - public List PrioritizeDecisionsForMovies(List decisions) { return decisions.Where(c => c.RemoteMovie.MappingResult == MappingResultType.Success || c.RemoteMovie.MappingResult == MappingResultType.SuccessLenientMapping) diff --git a/src/NzbDrone.Core/DecisionEngine/IDecisionEngineSpecification.cs b/src/NzbDrone.Core/DecisionEngine/IDecisionEngineSpecification.cs index e98a6977f..172d433fc 100644 --- a/src/NzbDrone.Core/DecisionEngine/IDecisionEngineSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/IDecisionEngineSpecification.cs @@ -6,9 +6,7 @@ namespace NzbDrone.Core.DecisionEngine public interface IDecisionEngineSpecification { RejectionType Type { get; } - - Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria); - + Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria); } } diff --git a/src/NzbDrone.Core/DecisionEngine/SameEpisodesSpecification.cs b/src/NzbDrone.Core/DecisionEngine/SameEpisodesSpecification.cs deleted file mode 100644 index 65bf4f1ec..000000000 --- a/src/NzbDrone.Core/DecisionEngine/SameEpisodesSpecification.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.DecisionEngine -{ - public class SameEpisodesSpecification - { - private readonly IEpisodeService _episodeService; - - public SameEpisodesSpecification(IEpisodeService episodeService) - { - _episodeService = episodeService; - } - - public bool IsSatisfiedBy(List episodes) - { - var episodeIds = episodes.SelectList(e => e.Id); - var episodeFileIds = episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFileId).Distinct(); - - foreach (var episodeFileId in episodeFileIds) - { - var episodesInFile = _episodeService.GetEpisodesByFileId(episodeFileId); - - if (episodesInFile.Select(e => e.Id).Except(episodeIds).Any()) - { - return false; - } - } - - return true; - } - } -} diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/AcceptableSizeSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/AcceptableSizeSpecification.cs index bb50eef6c..d5467238d 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/AcceptableSizeSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/AcceptableSizeSpecification.cs @@ -1,10 +1,10 @@ -using System.Linq; +using System.Linq; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using System.Collections.Generic; namespace NzbDrone.Core.DecisionEngine.Specifications @@ -12,102 +12,16 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public class AcceptableSizeSpecification : IDecisionEngineSpecification { private readonly IQualityDefinitionService _qualityDefinitionService; - private readonly IEpisodeService _episodeService; private readonly Logger _logger; - public AcceptableSizeSpecification(IQualityDefinitionService qualityDefinitionService, IEpisodeService episodeService, Logger logger) + public AcceptableSizeSpecification(IQualityDefinitionService qualityDefinitionService, Logger logger) { _qualityDefinitionService = qualityDefinitionService; - _episodeService = episodeService; _logger = logger; } public RejectionType Type => RejectionType.Permanent; - public Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - _logger.Debug("Beginning size check for: {0}", subject); - - var quality = subject.ParsedEpisodeInfo.Quality.Quality; - - if (subject.ParsedEpisodeInfo.Special) - { - _logger.Debug("Special release found, skipping size check."); - return Decision.Accept(); - } - - if (subject.Release.Size == 0) - { - _logger.Debug("Release has unknown size, skipping size check."); - return Decision.Accept(); - } - - var qualityDefinition = _qualityDefinitionService.Get(quality); - if (qualityDefinition.MinSize.HasValue) - { - var minSize = qualityDefinition.MinSize.Value.Megabytes(); - - //Multiply maxSize by Series.Runtime - minSize = minSize * subject.Series.Runtime * subject.Episodes.Count; - - //If the parsed size is smaller than minSize we don't want it - if (subject.Release.Size < minSize) - { - var runtimeMessage = subject.Episodes.Count == 1 ? $"{subject.Series.Runtime}min" : $"{subject.Episodes.Count}x {subject.Series.Runtime}min"; - - _logger.Debug("Item: {0}, Size: {1} is smaller than minimum allowed size ({2} bytes for {3}), rejecting.", subject, subject.Release.Size, minSize, runtimeMessage); - return Decision.Reject("{0} is smaller than minimum allowed {1} (for {2})", subject.Release.Size.SizeSuffix(), minSize.SizeSuffix(), runtimeMessage); - } - } - if (!qualityDefinition.MaxSize.HasValue || qualityDefinition.MaxSize.Value == 0) - { - _logger.Debug("Max size is unlimited - skipping check."); - } - else - { - var maxSize = qualityDefinition.MaxSize.Value.Megabytes(); - - //Multiply maxSize by Series.Runtime - maxSize = maxSize * subject.Series.Runtime * subject.Episodes.Count; - - if (subject.Episodes.Count == 1) - { - Episode episode = subject.Episodes.First(); - List seasonEpisodes; - - var seasonSearchCriteria = searchCriteria as SeasonSearchCriteria; - if (seasonSearchCriteria != null && !seasonSearchCriteria.Series.UseSceneNumbering && seasonSearchCriteria.Episodes.Any(v => v.Id == episode.Id)) - { - seasonEpisodes = (searchCriteria as SeasonSearchCriteria).Episodes; - } - else - { - seasonEpisodes = _episodeService.GetEpisodesBySeason(episode.SeriesId, episode.SeasonNumber); - } - - //Ensure that this is either the first episode - //or is the last episode in a season that has 10 or more episodes - if (seasonEpisodes.First().Id == episode.Id || (seasonEpisodes.Count() >= 10 && seasonEpisodes.Last().Id == episode.Id)) - { - _logger.Debug("Possible double episode, doubling allowed size."); - maxSize = maxSize * 2; - } - } - - //If the parsed size is greater than maxSize we don't want it - if (subject.Release.Size > maxSize) - { - var runtimeMessage = subject.Episodes.Count == 1 ? $"{subject.Series.Runtime}min" : $"{subject.Episodes.Count}x {subject.Series.Runtime}min"; - - _logger.Debug("Item: {0}, Size: {1} is greater than maximum allowed size ({2} for {3}), rejecting.", subject, subject.Release.Size, maxSize, runtimeMessage); - return Decision.Reject("{0} is larger than maximum allowed {1} (for {2})", subject.Release.Size.SizeSuffix(), maxSize.SizeSuffix(), runtimeMessage); - } - } - - _logger.Debug("Item: {0}, meets size constraints.", subject); - return Decision.Accept(); - } - public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) { _logger.Debug("Beginning size check for: {0}", subject); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/AnimeVersionUpgradeSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/AnimeVersionUpgradeSpecification.cs index 33f6cff9f..db58ea37e 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/AnimeVersionUpgradeSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/AnimeVersionUpgradeSpecification.cs @@ -4,7 +4,7 @@ using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.DecisionEngine.Specifications { @@ -21,42 +21,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - var releaseGroup = subject.ParsedEpisodeInfo.ReleaseGroup; - - if (subject.Series.SeriesType != SeriesTypes.Anime) - { - return Decision.Accept(); - } - - foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value)) - { - if (_qualityUpgradableSpecification.IsRevisionUpgrade(file.Quality, subject.ParsedEpisodeInfo.Quality)) - { - if (file.ReleaseGroup.IsNullOrWhiteSpace()) - { - _logger.Debug("Unable to compare release group, existing file's release group is unknown"); - return Decision.Reject("Existing release group is unknown"); - } - - if (releaseGroup.IsNullOrWhiteSpace()) - { - _logger.Debug("Unable to compare release group, release's release group is unknown"); - return Decision.Reject("Release group is unknown"); - } - - if (file.ReleaseGroup != releaseGroup) - { - _logger.Debug("Existing Release group is: {0} - release's release group is: {1}", file.ReleaseGroup, releaseGroup); - return Decision.Reject("{0} does not match existing release group {1}", releaseGroup, file.ReleaseGroup); - } - } - } - - return Decision.Accept(); - } - public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) { throw new NotImplementedException(); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/BlacklistSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/BlacklistSpecification.cs index 043b1aa3a..5eeff719c 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/BlacklistSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/BlacklistSpecification.cs @@ -19,17 +19,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public RejectionType Type => RejectionType.Permanent; - public Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - if (_blacklistService.Blacklisted(subject.Series.Id, subject.Release)) - { - _logger.Debug("{0} is blacklisted, rejecting.", subject.Release.Title); - return Decision.Reject("Release is blacklisted"); - } - - return Decision.Accept(); - } - public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) { diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/CutoffSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/CutoffSpecification.cs index 6eb191c68..48dbbaa80 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/CutoffSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/CutoffSpecification.cs @@ -19,23 +19,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value)) - { - _logger.Debug("Comparing file quality with report. Existing file is {0}", file.Quality); - - - if (!_qualityUpgradableSpecification.CutoffNotMet(subject.Series.Profile, file.Quality, subject.ParsedEpisodeInfo.Quality)) - { - _logger.Debug("Cutoff already met, rejecting."); - return Decision.Reject("Existing file meets cutoff: {0}", subject.Series.Profile.Value.Cutoff); - } - } - - return Decision.Accept(); - } - public virtual Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) { if (subject.Movie.MovieFile != null) diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/FullSeasonSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/FullSeasonSpecification.cs deleted file mode 100644 index 7d2f89d26..000000000 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/FullSeasonSpecification.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using NLog; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Parser.Model; -using NzbDrone.Common.Extensions; -using System.Linq; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.DecisionEngine.Specifications -{ - public class FullSeasonSpecification : IDecisionEngineSpecification - { - private readonly Logger _logger; - private readonly IEpisodeService _episodeService; - - public FullSeasonSpecification(Logger logger, IEpisodeService episodeService) - { - _logger = logger; - _episodeService = episodeService; - } - - public RejectionType Type => RejectionType.Permanent; - - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - if (subject.ParsedEpisodeInfo.FullSeason) - { - _logger.Debug("Checking if all episodes in full season release have aired. {0}", subject.Release.Title); - - if (subject.Episodes.Any(e => !e.AirDateUtc.HasValue || e.AirDateUtc.Value.After(DateTime.UtcNow))) - { - _logger.Debug("Full season release {0} rejected. All episodes haven't aired yet.", subject.Release.Title); - //return Decision.Reject("Full season release rejected. All episodes haven't aired yet."); - } - } - - return Decision.Accept(); - } - - public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) - { - throw new NotImplementedException(); - } - } -} diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/LanguageSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/LanguageSpecification.cs index fe244d057..f46b8e5a3 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/LanguageSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/LanguageSpecification.cs @@ -15,21 +15,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - var wantedLanguage = subject.Series.Profile.Value.Language; - - _logger.Debug("Checking if report meets language requirements. {0}", subject.ParsedEpisodeInfo.Language); - - if (subject.ParsedEpisodeInfo.Language != wantedLanguage) - { - _logger.Debug("Report Language: {0} rejected because it is not wanted, wanted {1}", subject.ParsedEpisodeInfo.Language, wantedLanguage); - return Decision.Reject("{0} is wanted, but found {1}", wantedLanguage, subject.ParsedEpisodeInfo.Language); - } - - return Decision.Accept(); - } - public virtual Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) { var wantedLanguage = subject.Movie.Profile.Value.Language; diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/MinimumAgeSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/MinimumAgeSpecification.cs index bcec8d6cd..a2ae1b54f 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/MinimumAgeSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/MinimumAgeSpecification.cs @@ -1,4 +1,4 @@ -using NLog; +using NLog; using NzbDrone.Core.Configuration; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; @@ -18,37 +18,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public RejectionType Type => RejectionType.Temporary; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - if (subject.Release.DownloadProtocol != Indexers.DownloadProtocol.Usenet) - { - _logger.Debug("Not checking minimum age requirement for non-usenet report"); - return Decision.Accept(); - } - - var age = subject.Release.AgeMinutes; - var minimumAge = _configService.MinimumAge; - - if (minimumAge == 0) - { - _logger.Debug("Minimum age is not set."); - return Decision.Accept(); - } - - - _logger.Debug("Checking if report meets minimum age requirements. {0}", age); - - if (age < minimumAge) - { - _logger.Debug("Only {0} minutes old, minimum age is {1} minutes", age, minimumAge); - return Decision.Reject("Only {0} minutes old, minimum age is {1} minutes", age, minimumAge); - } - - _logger.Debug("Release is {0} minutes old, greater than minimum age of {1} minutes", age, minimumAge); - - return Decision.Accept(); - } - public virtual Decision IsSatisfiedBy(RemoteMovie 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 eba2566e2..02d6f3c60 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/NotSampleSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/NotSampleSpecification.cs @@ -1,4 +1,4 @@ -using System; +using System; using NLog; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; @@ -16,17 +16,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications _logger = logger; } - public Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - if (subject.Release.Title.ToLower().Contains("sample") && subject.Release.Size < 70.Megabytes()) - { - _logger.Debug("Sample release, rejecting."); - return Decision.Reject("Sample"); - } - - return Decision.Accept(); - } - public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) { if (subject.Release.Title.ToLower().Contains("sample") && subject.Release.Size < 70.Megabytes()) diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/ProtocolSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/ProtocolSpecification.cs index 93846789c..0a7f6352e 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/ProtocolSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/ProtocolSpecification.cs @@ -20,39 +20,20 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - var delayProfile = _delayProfileService.BestForTags(subject.Series.Tags); - - if (subject.Release.DownloadProtocol == DownloadProtocol.Usenet && !delayProfile.EnableUsenet) - { - _logger.Debug("[{0}] Usenet is not enabled for this series", subject.Release.Title); - return Decision.Reject("Usenet is not enabled for this series"); - } - - if (subject.Release.DownloadProtocol == DownloadProtocol.Torrent && !delayProfile.EnableTorrent) - { - _logger.Debug("[{0}] Torrent is not enabled for this series", subject.Release.Title); - return Decision.Reject("Torrent is not enabled for this series"); - } - - return Decision.Accept(); - } - public virtual Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) { var delayProfile = _delayProfileService.BestForTags(subject.Movie.Tags); if (subject.Release.DownloadProtocol == DownloadProtocol.Usenet && !delayProfile.EnableUsenet) { - _logger.Debug("[{0}] Usenet is not enabled for this series", subject.Release.Title); - return Decision.Reject("Usenet is not enabled for this series"); + _logger.Debug("[{0}] Usenet is not enabled for this movie", subject.Release.Title); + return Decision.Reject("Usenet is not enabled for this movie"); } if (subject.Release.DownloadProtocol == DownloadProtocol.Torrent && !delayProfile.EnableTorrent) { - _logger.Debug("[{0}] Torrent is not enabled for this series", subject.Release.Title); - return Decision.Reject("Torrent is not enabled for this series"); + _logger.Debug("[{0}] Torrent is not enabled for this movie", subject.Release.Title); + return Decision.Reject("Torrent is not enabled for this movie"); } return Decision.Accept(); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/QualityAllowedByProfileSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/QualityAllowedByProfileSpecification.cs index dcba1ef41..09ba82207 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/QualityAllowedByProfileSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/QualityAllowedByProfileSpecification.cs @@ -15,18 +15,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - _logger.Debug("Checking if report meets quality requirements. {0}", subject.ParsedEpisodeInfo.Quality); - if (!subject.Series.Profile.Value.Items.Exists(v => v.Allowed && v.Quality == subject.ParsedEpisodeInfo.Quality.Quality)) - { - _logger.Debug("Quality {0} rejected by Series' quality profile", subject.ParsedEpisodeInfo.Quality); - return Decision.Reject("{0} is not wanted in profile", subject.ParsedEpisodeInfo.Quality.Quality); - } - - return Decision.Accept(); - } - public virtual Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) { _logger.Debug("Checking if report meets quality requirements. {0}", subject.ParsedMovieInfo.Quality); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/QueueSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/QueueSpecification.cs index 08995e4d2..fb9886145 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/QueueSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/QueueSpecification.cs @@ -23,34 +23,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public RejectionType Type => RejectionType.Permanent; - public Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - var queue = _queueService.GetQueue() - .Select(q => q.RemoteEpisode).ToList(); - - var matchingSeries = queue.Where(q => q.Series.Id == subject.Series.Id); - var matchingEpisode = matchingSeries.Where(q => q.Episodes.Select(e => e.Id).Intersect(subject.Episodes.Select(e => e.Id)).Any()); - - foreach (var remoteEpisode in matchingEpisode) - { - _logger.Debug("Checking if existing release in queue meets cutoff. Queued quality is: {0}", remoteEpisode.ParsedEpisodeInfo.Quality); - - if (!_qualityUpgradableSpecification.CutoffNotMet(subject.Series.Profile, remoteEpisode.ParsedEpisodeInfo.Quality, subject.ParsedEpisodeInfo.Quality)) - { - return Decision.Reject("Quality for release in queue already meets cutoff: {0}", remoteEpisode.ParsedEpisodeInfo.Quality); - } - - _logger.Debug("Checking if release is higher quality than queued release. Queued quality is: {0}", remoteEpisode.ParsedEpisodeInfo.Quality); - - if (!_qualityUpgradableSpecification.IsUpgradable(subject.Series.Profile, remoteEpisode.ParsedEpisodeInfo.Quality, subject.ParsedEpisodeInfo.Quality)) - { - return Decision.Reject("Quality for release in queue is of equal or higher preference: {0}", remoteEpisode.ParsedEpisodeInfo.Quality); - } - } - - return Decision.Accept(); - } - public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) { var queue = _queueService.GetQueue() diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RawDiskSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RawDiskSpecification.cs index 7a11bacfe..423a3b6aa 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RawDiskSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RawDiskSpecification.cs @@ -21,28 +21,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - if (subject.Release == null || subject.Release.Container.IsNullOrWhiteSpace()) - { - return Decision.Accept(); - } - - if (_dvdContainerTypes.Contains(subject.Release.Container.ToLower())) - { - _logger.Debug("Release contains raw DVD, rejecting."); - return Decision.Reject("Raw DVD release"); - } - - if (_blurayContainerTypes.Contains(subject.Release.Container.ToLower())) - { - _logger.Debug("Release contains raw Bluray, rejecting."); - return Decision.Reject("Raw Bluray release"); - } - - return Decision.Accept(); - } - public virtual Decision IsSatisfiedBy(RemoteMovie 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 42735995f..a824aa13d 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/ReleaseRestrictionsSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/ReleaseRestrictionsSpecification.cs @@ -22,46 +22,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - _logger.Debug("Checking if release meets restrictions: {0}", subject); - - var title = subject.Release.Title; - var restrictions = _restrictionService.AllForTags(subject.Series.Tags); - - var required = restrictions.Where(r => r.Required.IsNotNullOrWhiteSpace()); - var ignored = restrictions.Where(r => r.Ignored.IsNotNullOrWhiteSpace()); - - foreach (var r in required) - { - var requiredTerms = r.Required.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).ToList(); - - var foundTerms = ContainsAny(requiredTerms, title); - if (foundTerms.Empty()) - { - var terms = string.Join(", ", requiredTerms); - _logger.Debug("[{0}] does not contain one of the required terms: {1}", title, terms); - return Decision.Reject("Does not contain one of the required terms: {0}", terms); - } - } - - foreach (var r in ignored) - { - var ignoredTerms = r.Ignored.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); - - var foundTerms = ContainsAny(ignoredTerms, title); - if (foundTerms.Any()) - { - var terms = string.Join(", ", foundTerms); - _logger.Debug("[{0}] contains these ignored terms: {1}", title, terms); - return Decision.Reject("Contains these ignored terms: {0}", terms); - } - } - - _logger.Debug("[{0}] No restrictions apply, allowing", subject); - return Decision.Accept(); - } - public virtual Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) { _logger.Debug("Checking if release meets restrictions: {0}", subject); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RequiredIndexerFlagsSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RequiredIndexerFlagsSpecification.cs index 5e788eb2b..b880314b3 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RequiredIndexerFlagsSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RequiredIndexerFlagsSpecification.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using NLog; using NzbDrone.Core.Datastore; using NzbDrone.Core.Indexers; @@ -21,47 +21,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search //public SpecificationPriority Priority => SpecificationPriority.Default; public RejectionType Type => RejectionType.Permanent; - - public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria) - { - var torrentInfo = remoteEpisode.Release as TorrentInfo; - - if (torrentInfo == null || torrentInfo.IndexerId == 0) - { - return Decision.Accept(); - } - - IndexerDefinition indexer; - try - { - indexer = _indexerFactory.Get(torrentInfo.IndexerId); - } - catch (ModelNotFoundException) - { - _logger.Debug("Indexer with id {0} does not exist, skipping seeders check", torrentInfo.IndexerId); - return Decision.Accept(); - } - - var torrentIndexerSettings = indexer.Settings as ITorrentIndexerSettings; - - if (torrentIndexerSettings != null) - { - var minimumSeeders = torrentIndexerSettings.MinimumSeeders; - - if (torrentInfo.Seeders.HasValue && torrentInfo.Seeders.Value < minimumSeeders) - { - _logger.Debug("Not enough seeders: {0}. Minimum seeders: {1}", torrentInfo.Seeders, minimumSeeders); - return Decision.Reject("Not enough seeders: {0}. Minimum seeders: {1}", torrentInfo.Seeders, minimumSeeders); - } - } - - return Decision.Accept(); - } - - public Decision IsSatisfiedBy(RemoteMovie remoteEpisode, SearchCriteriaBase searchCriteria) + public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) { - var torrentInfo = remoteEpisode.Release; - + var torrentInfo = subject.Release; if (torrentInfo == null || torrentInfo.IndexerId == 0) { diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RetentionSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RetentionSpecification.cs index 7663c3fb1..a30003262 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RetentionSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RetentionSpecification.cs @@ -1,4 +1,4 @@ -using NLog; +using NLog; using NzbDrone.Core.Configuration; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; @@ -18,27 +18,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - if (subject.Release.DownloadProtocol != Indexers.DownloadProtocol.Usenet) - { - _logger.Debug("Not checking retention requirement for non-usenet report"); - return Decision.Accept(); - } - - var age = subject.Release.Age; - var retention = _configService.Retention; - - _logger.Debug("Checking if report meets retention requirements. {0}", age); - if (retention > 0 && age > retention) - { - _logger.Debug("Report age: {0} rejected by user's retention limit", age); - return Decision.Reject("Older than configured retention"); - } - - return Decision.Accept(); - } - public virtual Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) { if (subject.Release.DownloadProtocol != Indexers.DownloadProtocol.Usenet) diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/AvailabilitySpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/AvailabilitySpecification.cs index d94201613..93336c502 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/AvailabilitySpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/AvailabilitySpecification.cs @@ -3,7 +3,7 @@ using System.Linq; using NLog; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Configuration; namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync @@ -38,32 +38,5 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync return Decision.Accept(); } - - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - if (searchCriteria != null) - { - if (!searchCriteria.MonitoredEpisodesOnly) - { - _logger.Debug("Skipping availability check during search"); - return Decision.Accept(); - } - } - - /*if (subject.Series.Status != MovieStatusType.Released) - { - _logger.Debug("{0} is present in the DB but not yet available. skipping.", subject.Series); - return Decision.Reject("Series is not yet available"); - } - - /*var monitoredCount = subject.Episodes.Count(episode => episode.Monitored); - if (monitoredCount == subject.Episodes.Count) - { - return Decision.Accept(); - } - - _logger.Debug("Only {0}/{1} episodes are monitored. skipping.", monitoredCount, subject.Episodes.Count);*/ - return Decision.Reject("Episode is not yet available"); - } } } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DelaySpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DelaySpecification.cs index c1f08b606..e1169e760 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DelaySpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DelaySpecification.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using NLog; using NzbDrone.Core.Download.Pending; using NzbDrone.Core.IndexerSearch.Definitions; @@ -107,73 +107,5 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync return Decision.Accept(); } - - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - if (searchCriteria != null && searchCriteria.UserInvokedSearch) - { - _logger.Debug("Ignoring delay for user invoked search"); - return Decision.Accept(); - } - - var profile = subject.Series.Profile.Value; - var delayProfile = _delayProfileService.BestForTags(subject.Series.Tags); - var delay = delayProfile.GetProtocolDelay(subject.Release.DownloadProtocol); - var isPreferredProtocol = subject.Release.DownloadProtocol == delayProfile.PreferredProtocol; - - if (delay == 0) - { - _logger.Debug("Profile does not require a waiting period before download for {0}.", subject.Release.DownloadProtocol); - return Decision.Accept(); - } - - var comparer = new QualityModelComparer(profile); - - if (isPreferredProtocol) - { - foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value)) - { - var upgradable = _qualityUpgradableSpecification.IsUpgradable(profile, file.Quality, subject.ParsedEpisodeInfo.Quality); - - if (upgradable) - { - var revisionUpgrade = _qualityUpgradableSpecification.IsRevisionUpgrade(file.Quality, subject.ParsedEpisodeInfo.Quality); - - if (revisionUpgrade) - { - _logger.Debug("New quality is a better revision for existing quality, skipping delay"); - return Decision.Accept(); - } - } - } - } - - // If quality meets or exceeds the best allowed quality in the profile accept it immediately - var bestQualityInProfile = new QualityModel(profile.LastAllowedQuality()); - var isBestInProfile = comparer.Compare(subject.ParsedEpisodeInfo.Quality, bestQualityInProfile) >= 0; - - if (isBestInProfile && isPreferredProtocol) - { - _logger.Debug("Quality is highest in profile for preferred protocol, will not delay"); - return Decision.Accept(); - } - - // var episodeIds = subject.Episodes.Select(e => e.Id); - - //var oldest = _pendingReleaseService.OldestPendingRelease(subject.Series.Id, episodeIds); - - //if (oldest != null && oldest.Release.AgeMinutes > delay) - //{ - // return Decision.Accept(); - //} - - if (subject.Release.AgeMinutes < delay) - { - _logger.Debug("Waiting for better quality release, There is a {0} minute delay on {1}", delay, subject.Release.DownloadProtocol); - return Decision.Reject("Waiting for better quality release"); - } - - return Decision.Accept(); - } } } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/HistorySpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/HistorySpecification.cs index e8fb7719f..d5bb236f1 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/HistorySpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/HistorySpecification.cs @@ -39,7 +39,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync var cdhEnabled = _configService.EnableCompletedDownloadHandling; _logger.Debug("Performing history status check on report"); - _logger.Debug("Checking current status of episode [{0}] in history", subject.Movie.Id); + _logger.Debug("Checking current status of movie [{0}] in history", subject.Movie.Id); var mostRecent = _historyService.MostRecentForMovie(subject.Movie.Id); if (mostRecent != null && mostRecent.EventType == HistoryEventType.Grabbed) @@ -77,10 +77,5 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync return Decision.Accept(); } - - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - throw new NotImplementedException(); - } } } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredEpisodeSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredEpisodeSpecification.cs deleted file mode 100644 index fe03e89a0..000000000 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredEpisodeSpecification.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Linq; -using NLog; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync -{ - public class MonitoredEpisodeSpecification : IDecisionEngineSpecification - { - private readonly Logger _logger; - - public MonitoredEpisodeSpecification(Logger logger) - { - _logger = logger; - } - - public RejectionType Type => RejectionType.Permanent; - - public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) - { - if (searchCriteria != null) - { - if (searchCriteria.UserInvokedSearch) - { - _logger.Debug("Skipping monitored check during search"); - return Decision.Accept(); - } - } - - if (!subject.Movie.Monitored) - { - return Decision.Reject("Movie is not monitored"); - } - - return Decision.Accept(); - } - - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - if (searchCriteria != null) - { - if (!searchCriteria.MonitoredEpisodesOnly) - { - _logger.Debug("Skipping monitored check during search"); - return Decision.Accept(); - } - } - - if (!subject.Series.Monitored) - { - _logger.Debug("{0} is present in the DB but not tracked. skipping.", subject.Series); - return Decision.Reject("Series is not monitored"); - } - - var monitoredCount = subject.Episodes.Count(episode => episode.Monitored); - if (monitoredCount == subject.Episodes.Count) - { - return Decision.Accept(); - } - - _logger.Debug("Only {0}/{1} episodes are monitored. skipping.", monitoredCount, subject.Episodes.Count); - return Decision.Reject("Episode is not monitored"); - } - } -} diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredMovieSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredMovieSpecification.cs new file mode 100644 index 000000000..970cfb802 --- /dev/null +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredMovieSpecification.cs @@ -0,0 +1,39 @@ +using System; +using System.Linq; +using NLog; +using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Parser.Model; + +namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync +{ + public class MonitoredMovieSpecification : IDecisionEngineSpecification + { + private readonly Logger _logger; + + public MonitoredMovieSpecification(Logger logger) + { + _logger = logger; + } + + public RejectionType Type => RejectionType.Permanent; + + public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) + { + if (searchCriteria != null) + { + if (searchCriteria.UserInvokedSearch) + { + _logger.Debug("Skipping monitored check during search"); + return Decision.Accept(); + } + } + + if (!subject.Movie.Monitored) + { + return Decision.Reject("Movie is not monitored"); + } + + return Decision.Accept(); + } + } +} diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/ProperSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/ProperSpecification.cs index 15f7f6ae7..1d5d1ac74 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/ProperSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/ProperSpecification.cs @@ -22,34 +22,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - if (searchCriteria != null) - { - return Decision.Accept(); - } - - foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value)) - { - if (_qualityUpgradableSpecification.IsRevisionUpgrade(file.Quality, subject.ParsedEpisodeInfo.Quality)) - { - if (file.DateAdded < DateTime.Today.AddDays(-7)) - { - _logger.Debug("Proper for old file, rejecting: {0}", subject); - return Decision.Reject("Proper for old file"); - } - - if (!_configService.AutoDownloadPropers) - { - _logger.Debug("Auto downloading of propers is disabled"); - return Decision.Reject("Proper downloading is disabled"); - } - } - } - - return Decision.Accept(); - } - public virtual Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) { if (searchCriteria != null) diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/SameEpisodesGrabSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/SameEpisodesGrabSpecification.cs deleted file mode 100644 index bd3c2f908..000000000 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/SameEpisodesGrabSpecification.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using NLog; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.DecisionEngine.Specifications -{ - public class SameEpisodesGrabSpecification : IDecisionEngineSpecification - { - private readonly SameEpisodesSpecification _sameEpisodesSpecification; - private readonly Logger _logger; - - public SameEpisodesGrabSpecification(SameEpisodesSpecification sameEpisodesSpecification, Logger logger) - { - _sameEpisodesSpecification = sameEpisodesSpecification; - _logger = logger; - } - - public RejectionType Type => RejectionType.Permanent; - - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - if (_sameEpisodesSpecification.IsSatisfiedBy(subject.Episodes)) - { - return Decision.Accept(); - } - - _logger.Debug("Episode file on disk contains more episodes than this release contains"); - return Decision.Reject("Episode file on disk contains more episodes than this release contains"); - } - - public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) - { - throw new NotImplementedException(); - } - } -} diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/DailyEpisodeMatchSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/DailyEpisodeMatchSpecification.cs index 285dc5b5e..a634208cf 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/DailyEpisodeMatchSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/DailyEpisodeMatchSpecification.cs @@ -2,48 +2,24 @@ using System; using NLog; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.DecisionEngine.Specifications.Search { public class DailyEpisodeMatchSpecification : IDecisionEngineSpecification { private readonly Logger _logger; - private readonly IEpisodeService _episodeService; - public DailyEpisodeMatchSpecification(Logger logger, IEpisodeService episodeService) + public DailyEpisodeMatchSpecification(Logger logger) { _logger = logger; - _episodeService = episodeService; } public RejectionType Type => RejectionType.Permanent; - public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria) - { - if (searchCriteria == null) - { - return Decision.Accept(); - } - - var dailySearchSpec = searchCriteria as DailyEpisodeSearchCriteria; - - if (dailySearchSpec == null) return Decision.Accept(); - - var episode = _episodeService.GetEpisode(dailySearchSpec.Series.Id, dailySearchSpec.AirDate.ToString(Episode.AIR_DATE_FORMAT)); - - if (!remoteEpisode.ParsedEpisodeInfo.IsDaily || remoteEpisode.ParsedEpisodeInfo.AirDate != episode.AirDate) - { - _logger.Debug("Episode AirDate does not match searched episode number, skipping."); - return Decision.Reject("Episode does not match"); - } - - return Decision.Accept(); - } - public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) { throw new NotImplementedException(); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/EpisodeRequestedSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/EpisodeRequestedSpecification.cs deleted file mode 100644 index d8c0065a5..000000000 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/EpisodeRequestedSpecification.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Linq; -using NLog; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Parser.Model; - - -namespace NzbDrone.Core.DecisionEngine.Specifications.Search -{ - public class EpisodeRequestedSpecification : IDecisionEngineSpecification - { - private readonly Logger _logger; - - public EpisodeRequestedSpecification(Logger logger) - { - _logger = logger; - } - - public RejectionType Type => RejectionType.Permanent; - - public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) - { - throw new NotImplementedException(); - } - - public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria) - { - if (searchCriteria == null) - { - return Decision.Accept(); - } - - var criteriaEpisodes = searchCriteria.Episodes.Select(v => v.Id).ToList(); - var remoteEpisodes = remoteEpisode.Episodes.Select(v => v.Id).ToList(); - - if (!criteriaEpisodes.Intersect(remoteEpisodes).Any()) - { - _logger.Debug("Release rejected since the episode wasn't requested: {0}", remoteEpisode.ParsedEpisodeInfo); - return Decision.Reject("Episode wasn't requested"); - } - - return Decision.Accept(); - } - } -} diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/MovieSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/MovieSpecification.cs new file mode 100644 index 000000000..44d037a39 --- /dev/null +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/MovieSpecification.cs @@ -0,0 +1,36 @@ +using NLog; +using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Parser.Model; + +namespace NzbDrone.Core.DecisionEngine.Specifications.Search +{ + public class MovieSpecification : IDecisionEngineSpecification + { + private readonly Logger _logger; + + public MovieSpecification(Logger logger) + { + _logger = logger; + } + + public RejectionType Type => RejectionType.Permanent; + + public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) + { + if (searchCriteria == null) + { + return Decision.Accept(); + } + + _logger.Debug("Checking if movie matches searched movie"); + + if (subject.Movie.Id != searchCriteria.Movie.Id) + { + _logger.Debug("Movie {0} does not match {1}", subject.Movie, searchCriteria.Movie); + return Decision.Reject("Wrong movie"); + } + + return Decision.Accept(); + } + } +} diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SeasonMatchSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SeasonMatchSpecification.cs deleted file mode 100644 index c7f96303d..000000000 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SeasonMatchSpecification.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using NLog; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.DecisionEngine.Specifications.Search -{ - public class SeasonMatchSpecification : IDecisionEngineSpecification - { - private readonly Logger _logger; - - public SeasonMatchSpecification(Logger logger) - { - _logger = logger; - } - - public RejectionType Type => RejectionType.Permanent; - - public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) - { - throw new NotImplementedException(); - } - - public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria) - { - if (searchCriteria == null) - { - return Decision.Accept(); - } - - var singleEpisodeSpec = searchCriteria as SeasonSearchCriteria; - if (singleEpisodeSpec == null) return Decision.Accept(); - - if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber) - { - _logger.Debug("Season number does not match searched season number, skipping."); - //return Decision.Reject("Wrong season"); - //Unnecessary for Movies - } - - return Decision.Accept(); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SeriesSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SeriesSpecification.cs deleted file mode 100644 index dde54155f..000000000 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SeriesSpecification.cs +++ /dev/null @@ -1,54 +0,0 @@ -using NLog; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.DecisionEngine.Specifications.Search -{ - public class SeriesSpecification : IDecisionEngineSpecification - { - private readonly Logger _logger; - - public SeriesSpecification(Logger logger) - { - _logger = logger; - } - - public RejectionType Type => RejectionType.Permanent; - - public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria) - { - if (searchCriteria == null) - { - return Decision.Accept(); - } - - _logger.Debug("Checking if series matches searched series"); - - if (remoteEpisode.Series.Id != searchCriteria.Series.Id) - { - _logger.Debug("Series {0} does not match {1}", remoteEpisode.Series, searchCriteria.Series); - return Decision.Reject("Wrong series"); - } - - return Decision.Accept(); - } - - public Decision IsSatisfiedBy(RemoteMovie remoteEpisode, SearchCriteriaBase searchCriteria) - { - if (searchCriteria == null) - { - return Decision.Accept(); - } - - _logger.Debug("Checking if movie matches searched movie"); - - if (remoteEpisode.Movie.Id != searchCriteria.Movie.Id) - { - _logger.Debug("Series {0} does not match {1}", remoteEpisode.Movie, searchCriteria.Series); - return Decision.Reject("Wrong movie"); - } - - return Decision.Accept(); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleEpisodeMatchSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleEpisodeMatchSpecification.cs deleted file mode 100644 index 2a8495492..000000000 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleEpisodeMatchSpecification.cs +++ /dev/null @@ -1,45 +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 SingleEpisodeMatchSpecification : IDecisionEngineSpecification - { - private readonly Logger _logger; - - public SingleEpisodeMatchSpecification(Logger logger) - { - _logger = logger; - } - - public string RejectionReason - { - get - { - return "Episode doesn't match"; - } - } - - public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchDefinitionBase searchDefinitionBase) - { - var singleEpisodeSpec = searchDefinitionBase as SingleEpisodeSearchDefinition; - if (singleEpisodeSpec == null) return true; - - if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber) - { - _logger.Trace("Season number does not match searched season number, skipping."); - return false; - } - - if (!remoteEpisode.Episodes.Select(c => c.EpisodeNumber).Contains(singleEpisodeSpec.EpisodeNumber)) - { - _logger.Trace("Episode number does not match searched episode number, skipping."); - return false; - } - - return true; - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleEpisodeSearchMatchSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleEpisodeSearchMatchSpecification.cs deleted file mode 100644 index 18162d3f5..000000000 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleEpisodeSearchMatchSpecification.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Linq; -using NLog; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.DecisionEngine.Specifications.Search -{ - public class SingleEpisodeSearchMatchSpecification : IDecisionEngineSpecification - { - private readonly Logger _logger; - - public SingleEpisodeSearchMatchSpecification(Logger logger) - { - _logger = logger; - } - - public RejectionType Type => RejectionType.Permanent; - - public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) - { - throw new NotImplementedException(); - } - - public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria) - { - if (searchCriteria == null) - { - return Decision.Accept(); - } - - var singleEpisodeSpec = searchCriteria as SingleEpisodeSearchCriteria; - if (singleEpisodeSpec == null) return Decision.Accept(); - - if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber) - { - _logger.Debug("Season number does not match searched season number, skipping."); - //return Decision.Reject("Wrong season"); - } - - if (!remoteEpisode.ParsedEpisodeInfo.EpisodeNumbers.Any()) - { - _logger.Debug("Full season result during single episode search, skipping."); - //return Decision.Reject("Full season pack"); - } - - if (!remoteEpisode.ParsedEpisodeInfo.EpisodeNumbers.Contains(singleEpisodeSpec.EpisodeNumber)) - { - _logger.Debug("Episode number does not match searched episode number, skipping."); - //return Decision.Reject("Wrong episode"); - } - - return Decision.Accept(); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/TorrentSeedingSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/TorrentSeedingSpecification.cs index 58a15158e..ea4a23c35 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/TorrentSeedingSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/TorrentSeedingSpecification.cs @@ -1,4 +1,4 @@ -using NLog; +using NLog; using NzbDrone.Core.Datastore; using NzbDrone.Core.Indexers; using NzbDrone.Core.IndexerSearch.Definitions; @@ -19,47 +19,10 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search //public SpecificationPriority Priority => SpecificationPriority.Default; public RejectionType Type => RejectionType.Permanent; - - - public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria) - { - var torrentInfo = remoteEpisode.Release as TorrentInfo; - - if (torrentInfo == null || torrentInfo.IndexerId == 0) - { - return Decision.Accept(); - } - - IndexerDefinition indexer; - try - { - indexer = _indexerFactory.Get(torrentInfo.IndexerId); - } - catch (ModelNotFoundException) - { - _logger.Debug("Indexer with id {0} does not exist, skipping seeders check", torrentInfo.IndexerId); - return Decision.Accept(); - } - - var torrentIndexerSettings = indexer.Settings as ITorrentIndexerSettings; - - if (torrentIndexerSettings != null) - { - var minimumSeeders = torrentIndexerSettings.MinimumSeeders; - - if (torrentInfo.Seeders.HasValue && torrentInfo.Seeders.Value < minimumSeeders) - { - _logger.Debug("Not enough seeders: {0}. Minimum seeders: {1}", torrentInfo.Seeders, minimumSeeders); - return Decision.Reject("Not enough seeders: {0}. Minimum seeders: {1}", torrentInfo.Seeders, minimumSeeders); - } - } - - return Decision.Accept(); - } - - public Decision IsSatisfiedBy(RemoteMovie remoteEpisode, SearchCriteriaBase searchCriteria) + + public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) { - var torrentInfo = remoteEpisode.Release as TorrentInfo; + var torrentInfo = subject.Release as TorrentInfo; if (torrentInfo == null || torrentInfo.IndexerId == 0) { diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradeDiskSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradeDiskSpecification.cs index 2c5b028d3..f7823d60f 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradeDiskSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradeDiskSpecification.cs @@ -18,21 +18,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value)) - { - _logger.Debug("Comparing file quality with report. Existing file is {0}", file.Quality); - - if (!_qualityUpgradableSpecification.IsUpgradable(subject.Series.Profile, file.Quality, subject.ParsedEpisodeInfo.Quality)) - { - return Decision.Reject("Quality for existing file on disk is of equal or higher preference: {0}", file.Quality); - } - } - - return Decision.Accept(); - } - public virtual Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) { if (subject.Movie.MovieFile == null) diff --git a/src/NzbDrone.Core/DiskSpace/DiskSpaceService.cs b/src/NzbDrone.Core/DiskSpace/DiskSpaceService.cs index 32b318085..ee5065f81 100644 --- a/src/NzbDrone.Core/DiskSpace/DiskSpaceService.cs +++ b/src/NzbDrone.Core/DiskSpace/DiskSpaceService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Collections.Generic; using System.Linq; @@ -6,7 +6,7 @@ using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; using NzbDrone.Core.Configuration; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.DiskSpace { @@ -17,14 +17,14 @@ namespace NzbDrone.Core.DiskSpace public class DiskSpaceService : IDiskSpaceService { - private readonly ISeriesService _seriesService; + private readonly IMovieService _movieService; private readonly IConfigService _configService; private readonly IDiskProvider _diskProvider; private readonly Logger _logger; - public DiskSpaceService(ISeriesService seriesService, IConfigService configService, IDiskProvider diskProvider, Logger logger) + public DiskSpaceService(IMovieService movieService, IConfigService configService, IDiskProvider diskProvider, Logger logger) { - _seriesService = seriesService; + _movieService = movieService; _configService = configService; _diskProvider = diskProvider; _logger = logger; @@ -33,18 +33,18 @@ namespace NzbDrone.Core.DiskSpace public List GetFreeSpace() { var diskSpace = new List(); - diskSpace.AddRange(GetSeriesFreeSpace()); + diskSpace.AddRange(GetMovieFreeSpace()); diskSpace.AddRange(GetDroneFactoryFreeSpace()); diskSpace.AddRange(GetFixedDisksFreeSpace()); return diskSpace.DistinctBy(d => d.Path).ToList(); } - private IEnumerable GetSeriesFreeSpace() + private IEnumerable GetMovieFreeSpace() { - var seriesRootPaths = _seriesService.GetAllSeries().Select(s => _diskProvider.GetPathRoot(s.Path)).Distinct(); + var movieRootPaths = _movieService.GetAllMovies().Select(s => _diskProvider.GetPathRoot(s.Path)).Distinct(); - return GetDiskSpace(seriesRootPaths); + return GetDiskSpace(movieRootPaths); } private IEnumerable GetDroneFactoryFreeSpace() diff --git a/src/NzbDrone.Core/Download/Clients/Blackhole/TorrentBlackhole.cs b/src/NzbDrone.Core/Download/Clients/Blackhole/TorrentBlackhole.cs index 5e29aaf19..7b0505f8e 100644 --- a/src/NzbDrone.Core/Download/Clients/Blackhole/TorrentBlackhole.cs +++ b/src/NzbDrone.Core/Download/Clients/Blackhole/TorrentBlackhole.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Text; @@ -38,17 +38,6 @@ namespace NzbDrone.Core.Download.Clients.Blackhole ScanGracePeriod = TimeSpan.FromSeconds(30); } - protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - - protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - - protected override string AddFromMagnetLink(RemoteMovie remoteMovie, string hash, string magnetLink) { if (!Settings.SaveMagnetFiles) diff --git a/src/NzbDrone.Core/Download/Clients/Blackhole/UsenetBlackhole.cs b/src/NzbDrone.Core/Download/Clients/Blackhole/UsenetBlackhole.cs index 1a5dde9d4..ba0896787 100644 --- a/src/NzbDrone.Core/Download/Clients/Blackhole/UsenetBlackhole.cs +++ b/src/NzbDrone.Core/Download/Clients/Blackhole/UsenetBlackhole.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using FluentValidation.Results; @@ -32,11 +32,6 @@ namespace NzbDrone.Core.Download.Clients.Blackhole ScanGracePeriod = TimeSpan.FromSeconds(30); } - protected override string AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContents) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - protected override string AddFromNzbFile(RemoteMovie remoteMovie, string filename, byte[] fileContents) { var title = remoteMovie.Release.Title; diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs index b46922d7f..69b9a5c32 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Collections.Generic; using NzbDrone.Common.Disk; @@ -59,16 +59,6 @@ namespace NzbDrone.Core.Download.Clients.Deluge return actualHash.ToUpper(); } - protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - - protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - public override string Name => "Deluge"; public override IEnumerable GetItems() diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs index 4d954c7d4..a4291b7f1 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs @@ -146,17 +146,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation return finalPath; } - protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - - protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - - protected override string AddFromMagnetLink(RemoteMovie remoteEpisode, string hash, string magnetLink) + protected override string AddFromMagnetLink(RemoteMovie remoteMovie, string hash, string magnetLink) { var hashedSerialNumber = _serialNumberProvider.GetSerialNumber(Settings); @@ -166,7 +156,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation if (item != null) { - _logger.Debug("{0} added correctly", remoteEpisode); + _logger.Debug("{0} added correctly", remoteMovie); return CreateDownloadId(item.Id, hashedSerialNumber); } @@ -175,7 +165,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation throw new DownloadClientException("Failed to add magnet task to Download Station"); } - protected override string AddFromTorrentFile(RemoteMovie remoteEpisode, string hash, string filename, byte[] fileContent) + protected override string AddFromTorrentFile(RemoteMovie remoteMovie, string hash, string filename, byte[] fileContent) { var hashedSerialNumber = _serialNumberProvider.GetSerialNumber(Settings); @@ -187,7 +177,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation if (item != null) { - _logger.Debug("{0} added correctly", remoteEpisode); + _logger.Debug("{0} added correctly", remoteMovie); return CreateDownloadId(item.Id, hashedSerialNumber); } diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs index df5d3cf22..5c07c7c07 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs @@ -160,12 +160,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation _logger.Debug("{0} removed correctly", downloadId); } - protected override string AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContent) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - - protected override string AddFromNzbFile(RemoteMovie remoteEpisode, string filename, byte[] fileContent) + protected override string AddFromNzbFile(RemoteMovie remoteMovie, string filename, byte[] fileContent) { var hashedSerialNumber = _serialNumberProvider.GetSerialNumber(Settings); @@ -177,7 +172,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation if (item != null) { - _logger.Debug("{0} added correctly", remoteEpisode); + _logger.Debug("{0} added correctly", remoteMovie); return CreateDownloadId(item.Id, hashedSerialNumber); } diff --git a/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs b/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs index 5418f702d..3f364c5cf 100644 --- a/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs +++ b/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using FluentValidation.Results; @@ -149,16 +149,6 @@ namespace NzbDrone.Core.Download.Clients.Hadouken failures.AddIfNotNull(TestGetTorrents()); } - protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - - protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - protected override string AddFromMagnetLink(RemoteMovie remoteMovie, string hash, string magnetLink) { _proxy.AddTorrentUri(Settings, magnetLink); diff --git a/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs b/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs index 5753b4c67..a33f21d84 100644 --- a/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs +++ b/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -29,11 +29,6 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex _proxy = proxy; } - protected override string AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContents) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - protected override string AddFromNzbFile(RemoteMovie remoteMovie, string filename, byte[] fileContents) { var priority = Settings.RecentTvPriority; @@ -261,4 +256,4 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex return new OsPath(Path.Combine(outputPath.FullPath, filesResponse.First().FileName)); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs index ba98e789f..a090760ac 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs @@ -31,11 +31,6 @@ namespace NzbDrone.Core.Download.Clients.Nzbget _proxy = proxy; } - protected override string AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContents) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - protected override string AddFromNzbFile(RemoteMovie remoteMovie, string filename, byte[] fileContents) { var category = Settings.MovieCategory; diff --git a/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs b/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs index 3cb100862..3ef1e5951 100644 --- a/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs +++ b/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using FluentValidation.Results; @@ -32,20 +32,16 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic public override DownloadProtocol Protocol => DownloadProtocol.Usenet; - public override string Download(RemoteEpisode remoteEpisode) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - public override string Download(RemoteMovie remoteMovie) { var url = remoteMovie.Release.DownloadUrl; var title = remoteMovie.Release.Title; - if (remoteMovie.ParsedEpisodeInfo.FullSeason) - { - throw new NotSupportedException("Full season releases are not supported with Pneumatic."); - } + // We don't have full seasons in movies. + //if (remoteMovie.ParsedEpisodeInfo.FullSeason) + //{ + // throw new NotSupportedException("Full season releases are not supported with Pneumatic."); + //} title = FileNameBuilder.CleanFileName(title); diff --git a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs index d7cdab109..a82b4f897 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs @@ -31,16 +31,6 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent _proxy = proxy; } - protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - - protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, Byte[] fileContent) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - protected override string AddFromMagnetLink(RemoteMovie remoteMovie, string hash, string magnetLink) { _proxy.AddTorrentFromUrl(magnetLink, Settings); diff --git a/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs b/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs index bc0997e2e..bcfb368c2 100644 --- a/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs +++ b/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs @@ -32,11 +32,6 @@ 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(RemoteEpisode remoteEpisode, string filename, byte[] fileContents) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - protected override string AddFromNzbFile(RemoteMovie remoteMovie, string filename, byte[] fileContents) { var category = Settings.MovieCategory; diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs index 1e6dc38a4..01e069849 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs @@ -136,16 +136,6 @@ namespace NzbDrone.Core.Download.Clients.Transmission }; } - protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - - protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - protected override string AddFromMagnetLink(RemoteMovie remoteMovie, string hash, string magnetLink) { _proxy.AddTorrentFromUrl(magnetLink, GetDownloadDirectory(), Settings); @@ -239,4 +229,4 @@ namespace NzbDrone.Core.Download.Clients.Transmission return null; } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs index 0a7e1b757..aa4db546a 100644 --- a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Collections.Generic; using System.Threading; @@ -37,16 +37,6 @@ namespace NzbDrone.Core.Download.Clients.RTorrent _rTorrentDirectoryValidator = rTorrentDirectoryValidator; } - protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - - protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - protected override string AddFromMagnetLink(RemoteMovie remoteMovie, string hash, string magnetLink) { _proxy.AddTorrentFromUrl(magnetLink, Settings.MovieCategory, RTorrentPriority.Normal, Settings.MovieDirectory, Settings); diff --git a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs index d868ed597..f6ab66d53 100644 --- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs @@ -36,16 +36,6 @@ namespace NzbDrone.Core.Download.Clients.UTorrent _torrentCache = cacheManager.GetCache(GetType(), "differentialTorrents"); } - protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - - protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) - { - throw new DownloadClientException("Episodes are not working with Radarr"); - } - protected override string AddFromMagnetLink(RemoteMovie remoteMovie, string hash, string magnetLink) { _proxy.AddTorrentFromUrl(magnetLink, Settings); diff --git a/src/NzbDrone.Core/Download/CompletedDownloadService.cs b/src/NzbDrone.Core/Download/CompletedDownloadService.cs index 291f413a7..88401eecf 100644 --- a/src/NzbDrone.Core/Download/CompletedDownloadService.cs +++ b/src/NzbDrone.Core/Download/CompletedDownloadService.cs @@ -9,10 +9,10 @@ using NzbDrone.Core.Configuration; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.History; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.MediaFiles.EpisodeImport; +using NzbDrone.Core.MediaFiles.MovieImport; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Download { diff --git a/src/NzbDrone.Core/Download/DownloadClientBase.cs b/src/NzbDrone.Core/Download/DownloadClientBase.cs index e7ccef71f..9db311c53 100644 --- a/src/NzbDrone.Core/Download/DownloadClientBase.cs +++ b/src/NzbDrone.Core/Download/DownloadClientBase.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Collections.Generic; using FluentValidation.Results; @@ -60,8 +60,7 @@ namespace NzbDrone.Core.Download get; } - - public abstract string Download(RemoteEpisode remoteEpisode); + public abstract string Download(RemoteMovie remoteMovie); public abstract IEnumerable GetItems(); public abstract void RemoveItem(string downloadId, bool deleteData); public abstract DownloadClientStatus GetStatus(); @@ -152,6 +151,6 @@ namespace NzbDrone.Core.Download return null; } - public abstract string Download(RemoteMovie remoteMovie); + } } diff --git a/src/NzbDrone.Core/Download/DownloadFailedEvent.cs b/src/NzbDrone.Core/Download/DownloadFailedEvent.cs index 57b423b14..63c642def 100644 --- a/src/NzbDrone.Core/Download/DownloadFailedEvent.cs +++ b/src/NzbDrone.Core/Download/DownloadFailedEvent.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using NzbDrone.Common.Messaging; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.Qualities; @@ -11,10 +11,8 @@ namespace NzbDrone.Core.Download { Data = new Dictionary(); } - - public int SeriesId { get; set; } + public int MovieId { get; set; } - public List EpisodeIds { get; set; } public QualityModel Quality { get; set; } public string SourceTitle { get; set; } public string DownloadClient { get; set; } @@ -23,4 +21,4 @@ namespace NzbDrone.Core.Download public Dictionary Data { get; set; } public TrackedDownload TrackedDownload { get; set; } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/Download/DownloadService.cs b/src/NzbDrone.Core/Download/DownloadService.cs index a0b6df3e9..d3d46128a 100644 --- a/src/NzbDrone.Core/Download/DownloadService.cs +++ b/src/NzbDrone.Core/Download/DownloadService.cs @@ -1,4 +1,4 @@ -using System; +using System; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; @@ -13,11 +13,9 @@ namespace NzbDrone.Core.Download { public interface IDownloadService { - void DownloadReport(RemoteEpisode remoteEpisode); void DownloadReport(RemoteMovie remoteMovie, bool forceDownload); } - public class DownloadService : IDownloadService { private readonly IProvideDownloadClient _downloadClientProvider; @@ -39,59 +37,6 @@ namespace NzbDrone.Core.Download _logger = logger; } - public void DownloadReport(RemoteEpisode remoteEpisode) - { - //Ensure.That(remoteEpisode.Series, () => remoteEpisode.Series).IsNotNull(); - //Ensure.That(remoteEpisode.Episodes, () => remoteEpisode.Episodes).HasItems(); TODO update this shit - - var downloadTitle = remoteEpisode.Release.Title; - var downloadClient = _downloadClientProvider.GetDownloadClient(remoteEpisode.Release.DownloadProtocol); - - if (downloadClient == null) - { - _logger.Warn("{0} Download client isn't configured yet.", remoteEpisode.Release.DownloadProtocol); - return; - } - - // Limit grabs to 2 per second. - if (remoteEpisode.Release.DownloadUrl.IsNotNullOrWhiteSpace() && !remoteEpisode.Release.DownloadUrl.StartsWith("magnet:")) - { - var url = new HttpUri(remoteEpisode.Release.DownloadUrl); - _rateLimitService.WaitAndPulse(url.Host, TimeSpan.FromSeconds(2)); - } - - string downloadClientId; - try - { - downloadClientId = downloadClient.Download(remoteEpisode); - _indexerStatusService.RecordSuccess(remoteEpisode.Release.IndexerId); - } - catch (ReleaseDownloadException ex) - { - var http429 = ex.InnerException as TooManyRequestsException; - if (http429 != null) - { - _indexerStatusService.RecordFailure(remoteEpisode.Release.IndexerId, http429.RetryAfter); - } - else - { - _indexerStatusService.RecordFailure(remoteEpisode.Release.IndexerId); - } - throw; - } - - var episodeGrabbedEvent = new EpisodeGrabbedEvent(remoteEpisode); - episodeGrabbedEvent.DownloadClient = downloadClient.GetType().Name; - - if (!string.IsNullOrWhiteSpace(downloadClientId)) - { - episodeGrabbedEvent.DownloadId = downloadClientId; - } - - _logger.ProgressInfo("Report sent to {0}. {1}", downloadClient.Definition.Name, downloadTitle); - _eventAggregator.PublishEvent(episodeGrabbedEvent); - } - public void DownloadReport(RemoteMovie remoteMovie, bool foceDownload = false) { //Ensure.That(remoteEpisode.Series, () => remoteEpisode.Series).IsNotNull(); @@ -149,4 +94,4 @@ namespace NzbDrone.Core.Download _eventAggregator.PublishEvent(movieGrabbedEvent); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/Download/EpisodeGrabbedEvent.cs b/src/NzbDrone.Core/Download/EpisodeGrabbedEvent.cs deleted file mode 100644 index b7861b8d7..000000000 --- a/src/NzbDrone.Core/Download/EpisodeGrabbedEvent.cs +++ /dev/null @@ -1,17 +0,0 @@ -using NzbDrone.Common.Messaging; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.Download -{ - public class EpisodeGrabbedEvent : IEvent - { - public RemoteEpisode Episode { get; private set; } - public string DownloadClient { get; set; } - public string DownloadId { get; set; } - - public EpisodeGrabbedEvent(RemoteEpisode episode) - { - Episode = episode; - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Download/FailedDownloadService.cs b/src/NzbDrone.Core/Download/FailedDownloadService.cs index 45e83439e..7f7fa2a5d 100644 --- a/src/NzbDrone.Core/Download/FailedDownloadService.cs +++ b/src/NzbDrone.Core/Download/FailedDownloadService.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using NzbDrone.Common.Extensions; using NzbDrone.Core.Download.TrackedDownloads; @@ -87,9 +87,7 @@ namespace NzbDrone.Core.Download var downloadFailedEvent = new DownloadFailedEvent { - SeriesId = 0, MovieId = historyItem.MovieId, - EpisodeIds = null, Quality = historyItem.Quality, SourceTitle = historyItem.SourceTitle, DownloadClient = historyItem.Data.GetValueOrDefault(History.History.DOWNLOAD_CLIENT), diff --git a/src/NzbDrone.Core/Download/IDownloadClient.cs b/src/NzbDrone.Core/Download/IDownloadClient.cs index ecf76844e..9d82cab1a 100644 --- a/src/NzbDrone.Core/Download/IDownloadClient.cs +++ b/src/NzbDrone.Core/Download/IDownloadClient.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using NzbDrone.Core.Indexers; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.ThingiProvider; @@ -8,8 +8,7 @@ namespace NzbDrone.Core.Download public interface IDownloadClient : IProvider { DownloadProtocol Protocol { get; } - - string Download(RemoteEpisode remoteEpisode); + string Download(RemoteMovie remoteMovie); IEnumerable GetItems(); void RemoveItem(string downloadId, bool deleteData); diff --git a/src/NzbDrone.Core/Download/Pending/PendingRelease.cs b/src/NzbDrone.Core/Download/Pending/PendingRelease.cs index 4994a3cfe..f9002541f 100644 --- a/src/NzbDrone.Core/Download/Pending/PendingRelease.cs +++ b/src/NzbDrone.Core/Download/Pending/PendingRelease.cs @@ -1,4 +1,4 @@ -using System; +using System; using NzbDrone.Core.Datastore; using NzbDrone.Core.Parser.Model; @@ -6,16 +6,13 @@ namespace NzbDrone.Core.Download.Pending { public class PendingRelease : ModelBase { - public int SeriesId { get; set; } public int MovieId { get; set; } public string Title { get; set; } public DateTime Added { get; set; } - public ParsedEpisodeInfo ParsedEpisodeInfo { get; set; } public ParsedMovieInfo ParsedMovieInfo { get; set; } public ReleaseInfo Release { get; set; } //Not persisted - public RemoteEpisode RemoteEpisode { get; set; } public RemoteMovie RemoteMovie { get; set; } } } diff --git a/src/NzbDrone.Core/Download/Pending/PendingReleaseRepository.cs b/src/NzbDrone.Core/Download/Pending/PendingReleaseRepository.cs index 162aa76c4..ddcf41769 100644 --- a/src/NzbDrone.Core/Download/Pending/PendingReleaseRepository.cs +++ b/src/NzbDrone.Core/Download/Pending/PendingReleaseRepository.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using NzbDrone.Core.Datastore; using NzbDrone.Core.Messaging.Events; @@ -6,8 +6,6 @@ namespace NzbDrone.Core.Download.Pending { public interface IPendingReleaseRepository : IBasicRepository { - void DeleteBySeriesId(int seriesId); - List AllBySeriesId(int seriesId); void DeleteByMovieId(int movieId); List AllByMovieId(int movieId); } @@ -19,16 +17,6 @@ namespace NzbDrone.Core.Download.Pending { } - public void DeleteBySeriesId(int seriesId) - { - Delete(r => r.SeriesId == seriesId); - } - - public List AllBySeriesId(int seriesId) - { - return Query.Where(p => p.SeriesId == seriesId); - } - public void DeleteByMovieId(int movieId) { Delete(r => r.MovieId == movieId); @@ -39,4 +27,4 @@ namespace NzbDrone.Core.Download.Pending return Query.Where(p => p.MovieId == movieId); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs index 502a9fd32..91775b480 100644 --- a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs +++ b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using NLog; @@ -13,8 +13,8 @@ using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Delay; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Tv.Events; +using NzbDrone.Core.Movies; +using NzbDrone.Core.Movies.Events; namespace NzbDrone.Core.Download.Pending { @@ -131,8 +131,6 @@ namespace NzbDrone.Core.Download.Pending var queue = new Queue.Queue { Id = GetQueueId(pendingRelease, pendingRelease.RemoteMovie.Movie), - Series = null, - Episode = null, Movie = pendingRelease.RemoteMovie.Movie, Quality = pendingRelease.RemoteMovie.ParsedMovieInfo?.Quality ?? new QualityModel(), Title = pendingRelease.Title, @@ -148,7 +146,7 @@ namespace NzbDrone.Core.Download.Pending queued.Add(queue); } - //Return best quality release for each episode + //Return best quality release for each movie var deduped = queued.GroupBy(q => q.Movie.Id).Select(g => { var movies = g.First().Movie; @@ -203,7 +201,7 @@ namespace NzbDrone.Core.Download.Pending { var movie = _movieService.GetMovie(release.MovieId); - //Just in case the series was removed, but wasn't cleaned up yet (housekeeper will clean it up) + //Just in case the movie was removed, but wasn't cleaned up yet (housekeeper will clean it up) if (movie == null) return null; // var episodes = _parsingService.GetMovie(release.ParsedMovieInfo.MovieTitle); diff --git a/src/NzbDrone.Core/Download/ProcessDownloadDecisions.cs b/src/NzbDrone.Core/Download/ProcessDownloadDecisions.cs index 64a7a58f5..38fd09d38 100644 --- a/src/NzbDrone.Core/Download/ProcessDownloadDecisions.cs +++ b/src/NzbDrone.Core/Download/ProcessDownloadDecisions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using NLog; @@ -39,114 +39,62 @@ namespace NzbDrone.Core.Download foreach (var report in prioritizedDecisions) { + var remoteMovie = report.RemoteMovie; - if (report.IsForMovie) + if (remoteMovie == null || remoteMovie.Movie == null) { - var remoteMovie = report.RemoteMovie; - - if (remoteMovie == null || remoteMovie.Movie == null) - { - continue; - } - - List movieIds = new List { remoteMovie.Movie.Id }; - - - //Skip if already grabbed - if (grabbed.Select(r => r.RemoteMovie.Movie) - .Select(e => e.Id) - .ToList() - .Intersect(movieIds) - .Any()) - { - continue; - } - - if (report.TemporarilyRejected) - { - _pendingReleaseService.Add(report); - pending.Add(report); - continue; - } - - if (report.Rejections.Any()) - { - _logger.Debug("Rejecting release {0} because {1}", report.ToString(), report.Rejections.First().Reason); - continue; - } - - - - if (pending.Select(r => r.RemoteMovie.Movie) - .Select(e => e.Id) - .ToList() - .Intersect(movieIds) - .Any()) - { - continue; - } - - try - { - _downloadService.DownloadReport(remoteMovie, false); - grabbed.Add(report); - } - catch (Exception e) - { - //TODO: support for store & forward - //We'll need to differentiate between a download client error and an indexer error - _logger.Warn(e, "Couldn't add report to download queue. " + remoteMovie); - } + continue; } - else + + List movieIds = new List { remoteMovie.Movie.Id }; + + + //Skip if already grabbed + if (grabbed.Select(r => r.RemoteMovie.Movie) + .Select(e => e.Id) + .ToList() + .Intersect(movieIds) + .Any()) + { + continue; + } + + if (report.TemporarilyRejected) + { + _pendingReleaseService.Add(report); + pending.Add(report); + continue; + } + + if (report.Rejections.Any()) + { + _logger.Debug("Rejecting release {0} because {1}", report.ToString(), report.Rejections.First().Reason); + continue; + } + + + + if (pending.Select(r => r.RemoteMovie.Movie) + .Select(e => e.Id) + .ToList() + .Intersect(movieIds) + .Any()) + { + continue; + } + + try { - var remoteEpisode = report.RemoteEpisode; - - if (remoteEpisode == null || remoteEpisode.Episodes == null) - { - continue; - } - - var episodeIds = remoteEpisode.Episodes.Select(e => e.Id).ToList(); - - //Skip if already grabbed - if (grabbed.SelectMany(r => r.RemoteEpisode.Episodes) - .Select(e => e.Id) - .ToList() - .Intersect(episodeIds) - .Any()) - { - continue; - } - - if (report.TemporarilyRejected) - { - _pendingReleaseService.Add(report); - pending.Add(report); - continue; - } - - if (pending.SelectMany(r => r.RemoteEpisode.Episodes) - .Select(e => e.Id) - .ToList() - .Intersect(episodeIds) - .Any()) - { - continue; - } - - try - { - _downloadService.DownloadReport(remoteEpisode); - grabbed.Add(report); - } - catch (Exception e) - { - //TODO: support for store & forward - //We'll need to differentiate between a download client error and an indexer error - _logger.Warn(e, "Couldn't add report to download queue. " + remoteEpisode); - } + _downloadService.DownloadReport(remoteMovie, false); + grabbed.Add(report); } + catch (Exception e) + { + //TODO: support for store & forward + //We'll need to differentiate between a download client error and an indexer error + _logger.Warn(e, "Couldn't add report to download queue. " + remoteMovie); + } + } return new ProcessedDecisions(grabbed, pending, decisions.Where(d => d.Rejected).ToList()); diff --git a/src/NzbDrone.Core/Download/RedownloadFailedDownloadService.cs b/src/NzbDrone.Core/Download/RedownloadFailedDownloadService.cs index 2784d35c0..d21f61023 100644 --- a/src/NzbDrone.Core/Download/RedownloadFailedDownloadService.cs +++ b/src/NzbDrone.Core/Download/RedownloadFailedDownloadService.cs @@ -1,10 +1,10 @@ -using System.Linq; +using System.Linq; using NLog; using NzbDrone.Core.Configuration; using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using System.Collections.Generic; namespace NzbDrone.Core.Download @@ -31,7 +31,7 @@ namespace NzbDrone.Core.Download { if (!_configService.AutoRedownloadFailed) { - _logger.Debug("Auto redownloading failed episodes is disabled"); + _logger.Debug("Auto redownloading failed movies is disabled"); return; } diff --git a/src/NzbDrone.Core/Download/TorrentClientBase.cs b/src/NzbDrone.Core/Download/TorrentClientBase.cs index 9ad0e0bda..52415d552 100644 --- a/src/NzbDrone.Core/Download/TorrentClientBase.cs +++ b/src/NzbDrone.Core/Download/TorrentClientBase.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Net; using MonoTorrent; using NzbDrone.Common.Disk; @@ -37,17 +37,9 @@ namespace NzbDrone.Core.Download public override DownloadProtocol Protocol => DownloadProtocol.Torrent; public virtual bool PreferTorrentFile => false; - - protected abstract string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink); - protected abstract string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent); - protected virtual string AddFromMagnetLink(RemoteMovie remoteMovie, string hash, string magnetLink) - { - throw new NotImplementedException(); - } - protected virtual string AddFromTorrentFile(RemoteMovie remoteMovie, string hash, string filename, byte[] fileContent) - { - throw new NotImplementedException(); - } + + protected abstract string AddFromMagnetLink(RemoteMovie remoteMovie, string hash, string magnetLink); + protected abstract string AddFromTorrentFile(RemoteMovie remoteMovie, string hash, string filename, byte[] fileContent); public override string Download(RemoteMovie remoteMovie) { @@ -129,189 +121,7 @@ namespace NzbDrone.Core.Download return null; } - public override string Download(RemoteEpisode remoteMovie) - { - var torrentInfo = remoteMovie.Release as TorrentInfo; - - string magnetUrl = null; - string torrentUrl = null; - - if (remoteMovie.Release.DownloadUrl.IsNotNullOrWhiteSpace() && remoteMovie.Release.DownloadUrl.StartsWith("magnet:")) - { - magnetUrl = remoteMovie.Release.DownloadUrl; - } - else - { - torrentUrl = remoteMovie.Release.DownloadUrl; - } - - if (torrentInfo != null && !torrentInfo.MagnetUrl.IsNullOrWhiteSpace()) - { - magnetUrl = torrentInfo.MagnetUrl; - } - - if (PreferTorrentFile) - { - if (torrentUrl.IsNotNullOrWhiteSpace()) - { - try - { - return DownloadFromWebUrl(remoteMovie, torrentUrl); - } - catch (Exception ex) - { - if (!magnetUrl.IsNullOrWhiteSpace()) - { - throw; - } - - _logger.Debug("Torrent download failed, trying magnet. ({0})", ex.Message); - } - } - - if (magnetUrl.IsNotNullOrWhiteSpace()) - { - try - { - return DownloadFromMagnetUrl(remoteMovie, magnetUrl); - } - catch (NotSupportedException ex) - { - throw new ReleaseDownloadException(remoteMovie.Release, "Magnet not supported by download client. ({0})", ex.Message); - } - } - } - else - { - if (magnetUrl.IsNotNullOrWhiteSpace()) - { - try - { - return DownloadFromMagnetUrl(remoteMovie, magnetUrl); - } - catch (NotSupportedException ex) - { - if (torrentUrl.IsNullOrWhiteSpace()) - { - throw new ReleaseDownloadException(remoteMovie.Release, "Magnet not supported by download client. ({0})", ex.Message); - } - - _logger.Debug("Magnet not supported by download client, trying torrent. ({0})", ex.Message); - } - } - - if (torrentUrl.IsNotNullOrWhiteSpace()) - { - return DownloadFromWebUrl(remoteMovie, torrentUrl); - } - } - - return null; - } - - private string DownloadFromWebUrl(RemoteMovie remoteEpisode, string torrentUrl) - { - byte[] torrentFile = null; - - try - { - var request = new HttpRequest(torrentUrl); - request.Headers.Accept = "application/x-bittorrent"; - request.AllowAutoRedirect = false; - - var response = _httpClient.Get(request); - - if (response.StatusCode == HttpStatusCode.MovedPermanently || - response.StatusCode == HttpStatusCode.Found || - response.StatusCode == HttpStatusCode.SeeOther) - { - var locationHeader = response.Headers.GetSingleValue("Location"); - - _logger.Trace("Torrent request is being redirected to: {0}", locationHeader); - - if (locationHeader != null) - { - if (locationHeader.StartsWith("magnet:")) - { - return DownloadFromMagnetUrl(remoteEpisode, locationHeader); - } - - return DownloadFromWebUrl(remoteEpisode, locationHeader); - } - - throw new WebException("Remote website tried to redirect without providing a location."); - } - - torrentFile = response.ResponseData; - - _logger.Debug("Downloading torrent for episode '{0}' finished ({1} bytes from {2})", remoteEpisode.Release.Title, torrentFile.Length, torrentUrl); - } - catch (HttpException ex) - { - if ((int)ex.Response.StatusCode == 429) - { - _logger.Error("API Grab Limit reached for {0}", torrentUrl); - } - else - { - _logger.Error(ex, "Downloading torrent file for episode '{0}' failed ({1})", remoteEpisode.Release.Title, torrentUrl); - } - - throw new ReleaseDownloadException(remoteEpisode.Release, "Downloading torrent failed", ex); - } - catch (WebException ex) - { - _logger.Error(ex, "Downloading torrent file for episode '{0}' failed ({1})", remoteEpisode.Release.Title, torrentUrl); - - throw new ReleaseDownloadException(remoteEpisode.Release, "Downloading torrent failed", ex); - } - - var filename = string.Format("{0}.torrent", FileNameBuilder.CleanFileName(remoteEpisode.Release.Title)); - var hash = _torrentFileInfoReader.GetHashFromTorrentFile(torrentFile); - var actualHash = AddFromTorrentFile(remoteEpisode, hash, filename, torrentFile); - - if (actualHash.IsNotNullOrWhiteSpace() && hash != actualHash) - { - _logger.Debug( - "{0} did not return the expected InfoHash for '{1}', Radarr could potentially lose track of the download in progress.", - Definition.Implementation, remoteEpisode.Release.DownloadUrl); - } - - return actualHash; - } - - private string DownloadFromMagnetUrl(RemoteMovie remoteEpisode, string magnetUrl) - { - string hash = null; - string actualHash = null; - - try - { - hash = new MagnetLink(magnetUrl).InfoHash.ToHex(); - } - catch (FormatException ex) - { - _logger.Error(ex, "Failed to parse magnetlink for episode '{0}': '{1}'", remoteEpisode.Release.Title, magnetUrl); - - return null; - } - - if (hash != null) - { - actualHash = AddFromMagnetLink(remoteEpisode, hash, magnetUrl); - } - - if (actualHash.IsNotNullOrWhiteSpace() && hash != actualHash) - { - _logger.Debug( - "{0} did not return the expected InfoHash for '{1}', Radarr could potentially lose track of the download in progress.", - Definition.Implementation, remoteEpisode.Release.DownloadUrl); - } - - return actualHash; - } - - private string DownloadFromWebUrl(RemoteEpisode remoteEpisode, string torrentUrl) + private string DownloadFromWebUrl(RemoteMovie remoteMovie, string torrentUrl) { byte[] torrentFile = null; @@ -335,10 +145,10 @@ namespace NzbDrone.Core.Download { if (locationHeader.StartsWith("magnet:")) { - return DownloadFromMagnetUrl(remoteEpisode, locationHeader); + return DownloadFromMagnetUrl(remoteMovie, locationHeader); } - return DownloadFromWebUrl(remoteEpisode, locationHeader); + return DownloadFromWebUrl(remoteMovie, locationHeader); } throw new WebException("Remote website tried to redirect without providing a location."); @@ -346,7 +156,7 @@ namespace NzbDrone.Core.Download torrentFile = response.ResponseData; - _logger.Debug("Downloading torrent for episode '{0}' finished ({1} bytes from {2})", remoteEpisode.Release.Title, torrentFile.Length, torrentUrl); + _logger.Debug("Downloading torrent for movie '{0}' finished ({1} bytes from {2})", remoteMovie.Release.Title, torrentFile.Length, torrentUrl); } catch (HttpException ex) { @@ -356,33 +166,33 @@ namespace NzbDrone.Core.Download } else { - _logger.Error(ex, "Downloading torrent file for episode '{0}' failed ({1})", remoteEpisode.Release.Title, torrentUrl); + _logger.Error(ex, "Downloading torrent file for movie '{0}' failed ({1})", remoteMovie.Release.Title, torrentUrl); } - throw new ReleaseDownloadException(remoteEpisode.Release, "Downloading torrent failed", ex); + throw new ReleaseDownloadException(remoteMovie.Release, "Downloading torrent failed", ex); } catch (WebException ex) { - _logger.Error(ex, "Downloading torrent file for episode '{0}' failed ({1})", remoteEpisode.Release.Title, torrentUrl); + _logger.Error(ex, "Downloading torrent file for movie '{0}' failed ({1})", remoteMovie.Release.Title, torrentUrl); - throw new ReleaseDownloadException(remoteEpisode.Release, "Downloading torrent failed", ex); + throw new ReleaseDownloadException(remoteMovie.Release, "Downloading torrent failed", ex); } - var filename = string.Format("{0}.torrent", FileNameBuilder.CleanFileName(remoteEpisode.Release.Title)); + var filename = string.Format("{0}.torrent", FileNameBuilder.CleanFileName(remoteMovie.Release.Title)); var hash = _torrentFileInfoReader.GetHashFromTorrentFile(torrentFile); - var actualHash = AddFromTorrentFile(remoteEpisode, hash, filename, torrentFile); + var actualHash = AddFromTorrentFile(remoteMovie, hash, filename, torrentFile); if (actualHash.IsNotNullOrWhiteSpace() && hash != actualHash) { _logger.Debug( "{0} did not return the expected InfoHash for '{1}', Radarr could potentially lose track of the download in progress.", - Definition.Implementation, remoteEpisode.Release.DownloadUrl); + Definition.Implementation, remoteMovie.Release.DownloadUrl); } return actualHash; } - private string DownloadFromMagnetUrl(RemoteEpisode remoteEpisode, string magnetUrl) + private string DownloadFromMagnetUrl(RemoteMovie remoteMovie, string magnetUrl) { string hash = null; string actualHash = null; @@ -393,21 +203,21 @@ namespace NzbDrone.Core.Download } catch (FormatException ex) { - _logger.Error(ex, "Failed to parse magnetlink for episode '{0}': '{1}'", remoteEpisode.Release.Title, magnetUrl); + _logger.Error(ex, "Failed to parse magnetlink for movie '{0}': '{1}'", remoteMovie.Release.Title, magnetUrl); return null; } if (hash != null) { - actualHash = AddFromMagnetLink(remoteEpisode, hash, magnetUrl); + actualHash = AddFromMagnetLink(remoteMovie, hash, magnetUrl); } if (actualHash.IsNotNullOrWhiteSpace() && hash != actualHash) { _logger.Debug( "{0} did not return the expected InfoHash for '{1}', Radarr could potentially lose track of the download in progress.", - Definition.Implementation, remoteEpisode.Release.DownloadUrl); + Definition.Implementation, remoteMovie.Release.DownloadUrl); } return actualHash; diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs b/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs index 7a88f1713..c4e887a14 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using NLog; @@ -12,8 +12,8 @@ using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Download.TrackedDownloads { public class DownloadMonitoringService : IExecute, - IHandle, - IHandle + IHandle, + IHandle { private readonly IProvideDownloadClient _downloadClientProvider; private readonly IEventAggregator _eventAggregator; @@ -163,12 +163,12 @@ namespace NzbDrone.Core.Download.TrackedDownloads Refresh(); } - public void Handle(EpisodeGrabbedEvent message) + public void Handle(MovieGrabbedEvent message) { _refreshDebounce.Execute(); } - public void Handle(EpisodeImportedEvent message) + public void Handle(MovieImportedEvent message) { _refreshDebounce.Execute(); } diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs index 57ce35578..aaefcce14 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs @@ -1,4 +1,4 @@ -using NzbDrone.Core.Indexers; +using NzbDrone.Core.Indexers; using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.Download.TrackedDownloads @@ -9,7 +9,6 @@ namespace NzbDrone.Core.Download.TrackedDownloads public DownloadClientItem DownloadItem { get; set; } public TrackedDownloadStage State { get; set; } public TrackedDownloadStatus Status { get; private set; } - public RemoteEpisode RemoteEpisode { get; set; } public RemoteMovie RemoteMovie { get; set; } public TrackedDownloadStatusMessage[] StatusMessages { get; private set; } public DownloadProtocol Protocol { get; set; } diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs index 0a737f1d2..252b806f2 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs @@ -93,7 +93,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads } catch (Exception e) { - _logger.Debug(e, "Failed to find episode for " + downloadItem.Title); + _logger.Debug(e, "Failed to find movie for " + downloadItem.Title); return null; } diff --git a/src/NzbDrone.Core/Download/UsenetClientBase.cs b/src/NzbDrone.Core/Download/UsenetClientBase.cs index 0f2ea47de..24b178d36 100644 --- a/src/NzbDrone.Core/Download/UsenetClientBase.cs +++ b/src/NzbDrone.Core/Download/UsenetClientBase.cs @@ -1,4 +1,4 @@ -using System.Net; +using System.Net; using System; using NzbDrone.Common.Disk; using NzbDrone.Common.Http; @@ -30,51 +30,12 @@ namespace NzbDrone.Core.Download public override DownloadProtocol Protocol => DownloadProtocol.Usenet; - protected abstract string AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContents); - protected abstract string AddFromNzbFile(RemoteMovie remoteMovie, string filename, byte[] fileContents); - public override string Download(RemoteEpisode remoteEpisode) - { - var url = remoteEpisode.Release.DownloadUrl; - var filename = FileNameBuilder.CleanFileName(remoteEpisode.Release.Title) + ".nzb"; - - byte[] nzbData; - - try - { - nzbData = _httpClient.Get(new HttpRequest(url)).ResponseData; - - _logger.Debug("Downloaded nzb for episode '{0}' finished ({1} bytes from {2})", remoteEpisode.Release.Title, nzbData.Length, url); - } - catch (HttpException ex) - { - if ((int)ex.Response.StatusCode == 429) - { - _logger.Error("API Grab Limit reached for {0}", url); - } - else - { - _logger.Error(ex, "Downloading nzb for episode '{0}' failed ({1})", remoteEpisode.Release.Title, url); - } - - throw new ReleaseDownloadException(remoteEpisode.Release, "Downloading nzb failed", ex); - } - catch (WebException ex) - { - _logger.Error(ex, "Downloading nzb for episode '{0}' failed ({1})", remoteEpisode.Release.Title, url); - - throw new ReleaseDownloadException(remoteEpisode.Release, "Downloading nzb failed", ex); - } - - _logger.Info("Adding report [{0}] to the queue.", remoteEpisode.Release.Title); - return AddFromNzbFile(remoteEpisode, filename, nzbData); - } - - public override string Download(RemoteMovie remoteEpisode) + public override string Download(RemoteMovie remoteMovie) { - var url = remoteEpisode.Release.DownloadUrl; - var filename = FileNameBuilder.CleanFileName(remoteEpisode.Release.Title) + ".nzb"; + var url = remoteMovie.Release.DownloadUrl; + var filename = FileNameBuilder.CleanFileName(remoteMovie.Release.Title) + ".nzb"; byte[] nzbData; @@ -82,7 +43,7 @@ namespace NzbDrone.Core.Download { nzbData = _httpClient.Get(new HttpRequest(url)).ResponseData; - _logger.Debug("Downloaded nzb for episode '{0}' finished ({1} bytes from {2})", remoteEpisode.Release.Title, nzbData.Length, url); + _logger.Debug("Downloaded nzb for movie '{0}' finished ({1} bytes from {2})", remoteMovie.Release.Title, nzbData.Length, url); } catch (HttpException ex) { @@ -92,20 +53,20 @@ namespace NzbDrone.Core.Download } else { - _logger.Error(ex, "Downloading nzb for episode '{0}' failed ({1})", remoteEpisode.Release.Title, url); + _logger.Error(ex, "Downloading nzb for movie '{0}' failed ({1})", remoteMovie.Release.Title, url); } - throw new ReleaseDownloadException(remoteEpisode.Release, "Downloading nzb failed", ex); + throw new ReleaseDownloadException(remoteMovie.Release, "Downloading nzb failed", ex); } catch (WebException ex) { - _logger.Error(ex, "Downloading nzb for episode '{0}' failed ({1})", remoteEpisode.Release.Title, url); + _logger.Error(ex, "Downloading nzb for movie '{0}' failed ({1})", remoteMovie.Release.Title, url); - throw new ReleaseDownloadException(remoteEpisode.Release, "Downloading nzb failed", ex); + throw new ReleaseDownloadException(remoteMovie.Release, "Downloading nzb failed", ex); } - _logger.Info("Adding report [{0}] to the queue.", remoteEpisode.Release.Title); - return AddFromNzbFile(remoteEpisode, filename, nzbData); + _logger.Info("Adding report [{0}] to the queue.", remoteMovie.Release.Title); + return AddFromNzbFile(remoteMovie, filename, nzbData); } } } diff --git a/src/NzbDrone.Core/Exceptions/SeriesNotFoundException.cs b/src/NzbDrone.Core/Exceptions/SeriesNotFoundException.cs deleted file mode 100644 index b329bde8d..000000000 --- a/src/NzbDrone.Core/Exceptions/SeriesNotFoundException.cs +++ /dev/null @@ -1,27 +0,0 @@ -using NzbDrone.Common.Exceptions; - -namespace NzbDrone.Core.Exceptions -{ - public class SeriesNotFoundException : NzbDroneException - { - public int TvdbSeriesId { get; set; } - - public SeriesNotFoundException(int tvdbSeriesId) - : base(string.Format("Series with tvdbid {0} was not found, it may have been removed from TheTVDB.", tvdbSeriesId)) - { - TvdbSeriesId = tvdbSeriesId; - } - - public SeriesNotFoundException(int tvdbSeriesId, string message, params object[] args) - : base(message, args) - { - TvdbSeriesId = tvdbSeriesId; - } - - public SeriesNotFoundException(int tvdbSeriesId, string message) - : base(message) - { - TvdbSeriesId = tvdbSeriesId; - } - } -} diff --git a/src/NzbDrone.Core/Extras/ExtraService.cs b/src/NzbDrone.Core/Extras/ExtraService.cs index d45ec6b52..90743d93a 100644 --- a/src/NzbDrone.Core/Extras/ExtraService.cs +++ b/src/NzbDrone.Core/Extras/ExtraService.cs @@ -13,7 +13,7 @@ using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Extras { diff --git a/src/NzbDrone.Core/Extras/Files/ExtraFileManager.cs b/src/NzbDrone.Core/Extras/Files/ExtraFileManager.cs index 13b2dd222..f210ca2bc 100644 --- a/src/NzbDrone.Core/Extras/Files/ExtraFileManager.cs +++ b/src/NzbDrone.Core/Extras/Files/ExtraFileManager.cs @@ -7,7 +7,7 @@ using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; using NzbDrone.Core.Configuration; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Extras.Files { diff --git a/src/NzbDrone.Core/Extras/Files/ExtraFileService.cs b/src/NzbDrone.Core/Extras/Files/ExtraFileService.cs index ad314b1f1..5eec2addb 100644 --- a/src/NzbDrone.Core/Extras/Files/ExtraFileService.cs +++ b/src/NzbDrone.Core/Extras/Files/ExtraFileService.cs @@ -7,8 +7,8 @@ using NzbDrone.Common.Disk; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Tv.Events; +using NzbDrone.Core.Movies; +using NzbDrone.Core.Movies.Events; namespace NzbDrone.Core.Extras.Files { diff --git a/src/NzbDrone.Core/Extras/IImportExistingExtraFiles.cs b/src/NzbDrone.Core/Extras/IImportExistingExtraFiles.cs index d638125de..b81a8bb90 100644 --- a/src/NzbDrone.Core/Extras/IImportExistingExtraFiles.cs +++ b/src/NzbDrone.Core/Extras/IImportExistingExtraFiles.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using NzbDrone.Core.Extras.Files; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Extras { diff --git a/src/NzbDrone.Core/Extras/ImportExistingExtraFilesBase.cs b/src/NzbDrone.Core/Extras/ImportExistingExtraFilesBase.cs index 1b96e5a8b..d5fc47936 100644 --- a/src/NzbDrone.Core/Extras/ImportExistingExtraFilesBase.cs +++ b/src/NzbDrone.Core/Extras/ImportExistingExtraFilesBase.cs @@ -4,7 +4,7 @@ using System.Linq; using NzbDrone.Common; using NzbDrone.Common.Extensions; using NzbDrone.Core.Extras.Files; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Extras { diff --git a/src/NzbDrone.Core/Extras/Metadata/Consumers/MediaBrowser/MediaBrowserMetadata.cs b/src/NzbDrone.Core/Extras/Metadata/Consumers/MediaBrowser/MediaBrowserMetadata.cs index 6f910aa3a..82d078adf 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Consumers/MediaBrowser/MediaBrowserMetadata.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Consumers/MediaBrowser/MediaBrowserMetadata.cs @@ -9,7 +9,7 @@ using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Core.Extras.Metadata.Files; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Extras.Metadata.Consumers.MediaBrowser { diff --git a/src/NzbDrone.Core/Extras/Metadata/Consumers/Roksbox/RoksboxMetadata.cs b/src/NzbDrone.Core/Extras/Metadata/Consumers/Roksbox/RoksboxMetadata.cs index 2984f265d..594649c3f 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Consumers/Roksbox/RoksboxMetadata.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Consumers/Roksbox/RoksboxMetadata.cs @@ -12,7 +12,7 @@ using NzbDrone.Common.Extensions; using NzbDrone.Core.Extras.Metadata.Files; using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Extras.Metadata.Consumers.Roksbox { diff --git a/src/NzbDrone.Core/Extras/Metadata/Consumers/Wdtv/WdtvMetadata.cs b/src/NzbDrone.Core/Extras/Metadata/Consumers/Wdtv/WdtvMetadata.cs index 877cc0cf2..d9e383a1e 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Consumers/Wdtv/WdtvMetadata.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Consumers/Wdtv/WdtvMetadata.cs @@ -12,7 +12,7 @@ using NzbDrone.Common.Extensions; using NzbDrone.Core.Extras.Metadata.Files; using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Extras.Metadata.Consumers.Wdtv { diff --git a/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs b/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs index 9bcfda13a..56349a2c9 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs @@ -11,7 +11,7 @@ using NzbDrone.Common.Extensions; using NzbDrone.Core.Extras.Metadata.Files; using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc { diff --git a/src/NzbDrone.Core/Extras/Metadata/ExistingMetadataImporter.cs b/src/NzbDrone.Core/Extras/Metadata/ExistingMetadataImporter.cs index 0b29f89c1..39cf94544 100644 --- a/src/NzbDrone.Core/Extras/Metadata/ExistingMetadataImporter.cs +++ b/src/NzbDrone.Core/Extras/Metadata/ExistingMetadataImporter.cs @@ -7,7 +7,7 @@ using NzbDrone.Core.Extras.Files; using NzbDrone.Core.Extras.Metadata.Files; using NzbDrone.Core.Extras.Subtitles; using NzbDrone.Core.Parser; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Extras.Metadata { diff --git a/src/NzbDrone.Core/Extras/Metadata/Files/CleanMetadataFileService.cs b/src/NzbDrone.Core/Extras/Metadata/Files/CleanMetadataFileService.cs index e731c781c..176938f0b 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Files/CleanMetadataFileService.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Files/CleanMetadataFileService.cs @@ -1,7 +1,7 @@ using System.IO; using NLog; using NzbDrone.Common.Disk; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Extras.Metadata.Files { diff --git a/src/NzbDrone.Core/Extras/Metadata/Files/MetadataFileService.cs b/src/NzbDrone.Core/Extras/Metadata/Files/MetadataFileService.cs index c0dfdb52c..509962e9d 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Files/MetadataFileService.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Files/MetadataFileService.cs @@ -2,7 +2,7 @@ using NLog; using NzbDrone.Common.Disk; using NzbDrone.Core.Extras.Files; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Extras.Metadata.Files { diff --git a/src/NzbDrone.Core/Extras/Metadata/IMetadata.cs b/src/NzbDrone.Core/Extras/Metadata/IMetadata.cs index 3fa89b7ed..aa4038525 100644 --- a/src/NzbDrone.Core/Extras/Metadata/IMetadata.cs +++ b/src/NzbDrone.Core/Extras/Metadata/IMetadata.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using NzbDrone.Core.Extras.Metadata.Files; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.ThingiProvider; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Extras.Metadata { diff --git a/src/NzbDrone.Core/Extras/Metadata/MetadataBase.cs b/src/NzbDrone.Core/Extras/Metadata/MetadataBase.cs index 76049c886..eec70833a 100644 --- a/src/NzbDrone.Core/Extras/Metadata/MetadataBase.cs +++ b/src/NzbDrone.Core/Extras/Metadata/MetadataBase.cs @@ -5,7 +5,7 @@ using FluentValidation.Results; using NzbDrone.Core.Extras.Metadata.Files; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.ThingiProvider; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Extras.Metadata { diff --git a/src/NzbDrone.Core/Extras/Metadata/MetadataService.cs b/src/NzbDrone.Core/Extras/Metadata/MetadataService.cs index f3ebf0593..5e8a8838a 100644 --- a/src/NzbDrone.Core/Extras/Metadata/MetadataService.cs +++ b/src/NzbDrone.Core/Extras/Metadata/MetadataService.cs @@ -11,7 +11,7 @@ using NzbDrone.Core.Configuration; using NzbDrone.Core.Extras.Files; using NzbDrone.Core.Extras.Metadata.Files; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Extras.Metadata { @@ -66,10 +66,10 @@ namespace NzbDrone.Core.Extras.Metadata { var consumerFiles = GetMetadataFilesForConsumer(consumer, metadataFiles); - foreach (var episodeFile in movieFiles) + foreach (var movieFile in movieFiles) { - files.AddIfNotNull(ProcessMovieMetadata(consumer, movie, episodeFile, consumerFiles)); - files.AddRange(ProcessMovieImages(consumer, movie, episodeFile, consumerFiles)); + files.AddIfNotNull(ProcessMovieMetadata(consumer, movie, movieFile, consumerFiles)); + files.AddRange(ProcessMovieImages(consumer, movie, movieFile, consumerFiles)); } } diff --git a/src/NzbDrone.Core/Extras/Others/ExistingOtherExtraImporter.cs b/src/NzbDrone.Core/Extras/Others/ExistingOtherExtraImporter.cs index 908ea5063..695299c0e 100644 --- a/src/NzbDrone.Core/Extras/Others/ExistingOtherExtraImporter.cs +++ b/src/NzbDrone.Core/Extras/Others/ExistingOtherExtraImporter.cs @@ -5,7 +5,7 @@ using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Core.Extras.Files; using NzbDrone.Core.Parser; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Extras.Others { diff --git a/src/NzbDrone.Core/Extras/Others/OtherExtraFileService.cs b/src/NzbDrone.Core/Extras/Others/OtherExtraFileService.cs index f54913df3..642cd567a 100644 --- a/src/NzbDrone.Core/Extras/Others/OtherExtraFileService.cs +++ b/src/NzbDrone.Core/Extras/Others/OtherExtraFileService.cs @@ -2,7 +2,7 @@ using NLog; using NzbDrone.Common.Disk; using NzbDrone.Core.Extras.Files; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Extras.Others { diff --git a/src/NzbDrone.Core/Extras/Others/OtherExtraService.cs b/src/NzbDrone.Core/Extras/Others/OtherExtraService.cs index 8e7dbdc59..421aa737b 100644 --- a/src/NzbDrone.Core/Extras/Others/OtherExtraService.cs +++ b/src/NzbDrone.Core/Extras/Others/OtherExtraService.cs @@ -8,7 +8,7 @@ using NzbDrone.Common.Extensions; using NzbDrone.Core.Configuration; using NzbDrone.Core.Extras.Files; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Extras.Others { diff --git a/src/NzbDrone.Core/Extras/Subtitles/ExistingSubtitleImporter.cs b/src/NzbDrone.Core/Extras/Subtitles/ExistingSubtitleImporter.cs index 73a36e8c8..cb351d9cb 100644 --- a/src/NzbDrone.Core/Extras/Subtitles/ExistingSubtitleImporter.cs +++ b/src/NzbDrone.Core/Extras/Subtitles/ExistingSubtitleImporter.cs @@ -5,7 +5,7 @@ using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Core.Extras.Files; using NzbDrone.Core.Parser; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Extras.Subtitles { diff --git a/src/NzbDrone.Core/Extras/Subtitles/SubtitleFileService.cs b/src/NzbDrone.Core/Extras/Subtitles/SubtitleFileService.cs index 47fc550ae..c5cf3b12d 100644 --- a/src/NzbDrone.Core/Extras/Subtitles/SubtitleFileService.cs +++ b/src/NzbDrone.Core/Extras/Subtitles/SubtitleFileService.cs @@ -2,7 +2,7 @@ using NLog; using NzbDrone.Common.Disk; using NzbDrone.Core.Extras.Files; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Extras.Subtitles { diff --git a/src/NzbDrone.Core/Extras/Subtitles/SubtitleService.cs b/src/NzbDrone.Core/Extras/Subtitles/SubtitleService.cs index 23b63a145..33cc8e98f 100644 --- a/src/NzbDrone.Core/Extras/Subtitles/SubtitleService.cs +++ b/src/NzbDrone.Core/Extras/Subtitles/SubtitleService.cs @@ -10,7 +10,7 @@ using NzbDrone.Core.Configuration; using NzbDrone.Core.Extras.Files; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Parser; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Extras.Subtitles { diff --git a/src/NzbDrone.Core/HealthCheck/Checks/RootFolderCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/RootFolderCheck.cs index d7cb3f7d1..22631dd2b 100644 --- a/src/NzbDrone.Core/HealthCheck/Checks/RootFolderCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/Checks/RootFolderCheck.cs @@ -1,23 +1,23 @@ -using System.Linq; +using System.Linq; using NzbDrone.Common.Disk; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.HealthCheck.Checks { public class RootFolderCheck : HealthCheckBase { - private readonly ISeriesService _seriesService; + private readonly IMovieService _movieService; private readonly IDiskProvider _diskProvider; - public RootFolderCheck(ISeriesService seriesService, IDiskProvider diskProvider) + public RootFolderCheck(IMovieService movieService, IDiskProvider diskProvider) { - _seriesService = seriesService; + _movieService = movieService; _diskProvider = diskProvider; } public override HealthCheck Check() { - var missingRootFolders = _seriesService.GetAllSeries() + var missingRootFolders = _movieService.GetAllMovies() .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 b0e21d28e..2b3045e29 100644 --- a/src/NzbDrone.Core/History/History.cs +++ b/src/NzbDrone.Core/History/History.cs @@ -1,8 +1,8 @@ -using System; +using System; using System.Collections.Generic; using NzbDrone.Core.Datastore; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.History { @@ -15,15 +15,11 @@ namespace NzbDrone.Core.History Data = new Dictionary(); } - public int EpisodeId { get; set; } - public int SeriesId { get; set; } public int MovieId { get; set; } public string SourceTitle { get; set; } public QualityModel Quality { get; set; } public DateTime Date { get; set; } public Movie Movie { get; set; } - public Episode Episode { get; set; } - public Series Series { get; set; } public HistoryEventType EventType { get; set; } public Dictionary Data { get; set; } @@ -42,4 +38,4 @@ namespace NzbDrone.Core.History MovieFileDeleted = 6, MovieFolderImported = 7, // not used yet } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/History/HistoryRepository.cs b/src/NzbDrone.Core/History/HistoryRepository.cs index 7ece4ea15..6f433c528 100644 --- a/src/NzbDrone.Core/History/HistoryRepository.cs +++ b/src/NzbDrone.Core/History/HistoryRepository.cs @@ -5,7 +5,7 @@ using Marr.Data.QGen; using NzbDrone.Core.Datastore; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.History { @@ -64,11 +64,7 @@ namespace NzbDrone.Core.History protected override SortBuilder GetPagedQuery(QueryBuilder query, PagingSpec pagingSpec) { - var baseQuery = query/*.Join(JoinType.Inner, h => h.Series, (h, s) => h.SeriesId == s.Id) - .Join(JoinType.Inner, h => h.Episode, (h, e) => h.EpisodeId == e.Id)*/ - .Join(JoinType.Inner, h => h.Movie, (h, e) => h.MovieId == e.Id); - - + var baseQuery = query.Join(JoinType.Inner, h => h.Movie, (h, e) => h.MovieId == e.Id); return base.GetPagedQuery(baseQuery, pagingSpec); } diff --git a/src/NzbDrone.Core/History/HistoryService.cs b/src/NzbDrone.Core/History/HistoryService.cs index d18fa328a..b6d11da06 100644 --- a/src/NzbDrone.Core/History/HistoryService.cs +++ b/src/NzbDrone.Core/History/HistoryService.cs @@ -12,13 +12,13 @@ using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv.Events; +using NzbDrone.Core.Movies.Events; namespace NzbDrone.Core.History { public interface IHistoryService { - QualityModel GetBestQualityInHistory(Profile profile, int episodeId); + QualityModel GetBestQualityInHistory(Profile profile, int movieId); PagingSpec Paged(PagingSpec pagingSpec); History MostRecentForMovie(int movieId); History MostRecentForDownloadId(string downloadId); @@ -73,10 +73,10 @@ namespace NzbDrone.Core.History return _historyRepository.FindByDownloadId(downloadId); } - public QualityModel GetBestQualityInHistory(Profile profile, int episodeId) + public QualityModel GetBestQualityInHistory(Profile profile, int movieId) { var comparer = new QualityModelComparer(profile); - return _historyRepository.GetBestQualityInHistory(episodeId) + return _historyRepository.GetBestQualityInHistory(movieId) .OrderByDescending(q => q, comparer) .FirstOrDefault(); } @@ -89,8 +89,6 @@ namespace NzbDrone.Core.History Date = DateTime.UtcNow, Quality = message.Movie.ParsedMovieInfo.Quality, SourceTitle = message.Movie.Release.Title, - SeriesId = 0, - EpisodeId = 0, DownloadId = message.DownloadId, MovieId = message.Movie.Movie.Id }; @@ -146,8 +144,6 @@ namespace NzbDrone.Core.History Date = DateTime.UtcNow, Quality = message.MovieInfo.Quality, SourceTitle = movie.Title, - SeriesId = 0, - EpisodeId = 0, DownloadId = downloadId, MovieId = movie.Id, }; @@ -175,8 +171,6 @@ namespace NzbDrone.Core.History Date = DateTime.UtcNow, Quality = message.MovieFile.Quality, SourceTitle = message.MovieFile.Path, - SeriesId = 0, - EpisodeId = 0, MovieId = message.MovieFile.MovieId }; @@ -240,8 +234,6 @@ namespace NzbDrone.Core.History Date = DateTime.UtcNow, Quality = message.Quality, SourceTitle = message.SourceTitle, - SeriesId = 0, - EpisodeId = 0, MovieId = message.MovieId, DownloadId = message.DownloadId }; diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedEpisodes.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedEpisodes.cs deleted file mode 100644 index 6d9d208c9..000000000 --- a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedEpisodes.cs +++ /dev/null @@ -1,26 +0,0 @@ -using NzbDrone.Core.Datastore; - -namespace NzbDrone.Core.Housekeeping.Housekeepers -{ - public class CleanupOrphanedEpisodes : IHousekeepingTask - { - private readonly IMainDatabase _database; - - public CleanupOrphanedEpisodes(IMainDatabase database) - { - _database = database; - } - - public void Clean() - { - var mapper = _database.GetDataMapper(); - - mapper.ExecuteNonQuery(@"DELETE FROM Episodes - WHERE Id IN ( - SELECT Episodes.Id FROM Episodes - LEFT OUTER JOIN Series - ON Episodes.SeriesId = Series.Id - WHERE Series.Id IS NULL)"); - } - } -} diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedHistoryItems.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedHistoryItems.cs index e8ee88d68..617bb2abc 100644 --- a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedHistoryItems.cs +++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedHistoryItems.cs @@ -1,4 +1,4 @@ -using NzbDrone.Core.Datastore; +using NzbDrone.Core.Datastore; namespace NzbDrone.Core.Housekeeping.Housekeepers { @@ -13,23 +13,9 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers public void Clean() { - //CleanupOrphanedBySeries(); - //CleanupOrphanedByEpisode(); CleanupOrphanedByMovie(); } - private void CleanupOrphanedBySeries() - { - var mapper = _database.GetDataMapper(); - - mapper.ExecuteNonQuery(@"DELETE FROM History - WHERE Id IN ( - SELECT History.Id FROM History - LEFT OUTER JOIN Series - ON History.SeriesId = Series.Id - WHERE Series.Id IS NULL)"); - } - private void CleanupOrphanedByMovie() { var mapper = _database.GetDataMapper(); @@ -41,17 +27,5 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers ON History.MovieId = Movies.Id WHERE Movies.Id IS NULL)"); } - - private void CleanupOrphanedByEpisode() - { - var mapper = _database.GetDataMapper(); - - mapper.ExecuteNonQuery(@"DELETE FROM History - WHERE Id IN ( - SELECT History.Id FROM History - LEFT OUTER JOIN Episodes - ON History.EpisodeId = Episodes.Id - WHERE Episodes.Id IS NULL)"); - } } } diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedEpisodeFiles.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedMovieFiles.cs similarity index 80% rename from src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedEpisodeFiles.cs rename to src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedMovieFiles.cs index a5cc3887c..d62c5988d 100644 --- a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedEpisodeFiles.cs +++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedMovieFiles.cs @@ -1,12 +1,12 @@ -using NzbDrone.Core.Datastore; +using NzbDrone.Core.Datastore; namespace NzbDrone.Core.Housekeeping.Housekeepers { - public class CleanupOrphanedEpisodeFiles : IHousekeepingTask + public class CleanupOrphanedMovieFiles : IHousekeepingTask { private readonly IMainDatabase _database; - public CleanupOrphanedEpisodeFiles(IMainDatabase database) + public CleanupOrphanedMovieFiles(IMainDatabase database) { _database = database; } diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupUnusedTags.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupUnusedTags.cs index fb913e0a0..a9a0bea0e 100644 --- a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupUnusedTags.cs +++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupUnusedTags.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using Marr.Data; using NzbDrone.Common.Serializer; @@ -19,7 +19,7 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers { var mapper = _database.GetDataMapper(); - var usedTags = new[] { "Movies", "Series", "Notifications", "DelayProfiles", "Restrictions" } + var usedTags = new[] { "Movies", "Notifications", "DelayProfiles", "Restrictions" } .SelectMany(v => GetUsedTags(v, mapper)) .Distinct() .ToArray(); diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/DeleteBadMediaCovers.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/DeleteBadMediaCovers.cs index ccec4d7ff..cc1b13f4c 100644 --- a/src/NzbDrone.Core/Housekeeping/Housekeepers/DeleteBadMediaCovers.cs +++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/DeleteBadMediaCovers.cs @@ -5,7 +5,7 @@ using NLog; using NzbDrone.Common.Disk; using NzbDrone.Core.Configuration; using NzbDrone.Core.Extras.Metadata.Files; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Housekeeping.Housekeepers { diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForSeries.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForMovies.cs similarity index 74% rename from src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForSeries.cs rename to src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForMovies.cs index 907d61817..d94850d01 100644 --- a/src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForSeries.cs +++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForMovies.cs @@ -1,14 +1,14 @@ -using System.Linq; +using System.Linq; using NzbDrone.Core.Parser; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Housekeeping.Housekeepers { - public class UpdateCleanTitleForSeries : IHousekeepingTask + public class UpdateCleanTitleForMovies : IHousekeepingTask { private readonly IMovieRepository _movieRepository; - public UpdateCleanTitleForSeries(IMovieRepository movieRepository) + public UpdateCleanTitleForMovies(IMovieRepository movieRepository) { _movieRepository = movieRepository; } diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/AnimeEpisodeSearchCriteria.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/AnimeEpisodeSearchCriteria.cs deleted file mode 100644 index a7cd8b9d2..000000000 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/AnimeEpisodeSearchCriteria.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace NzbDrone.Core.IndexerSearch.Definitions -{ - public class AnimeEpisodeSearchCriteria : SearchCriteriaBase - { - public int AbsoluteEpisodeNumber { get; set; } - - public override string ToString() - { - return string.Format("[{0} : {1:00}]", Series.Title, AbsoluteEpisodeNumber); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/DailyEpisodeSearchCriteria.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/DailyEpisodeSearchCriteria.cs deleted file mode 100644 index d5eeb15b7..000000000 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/DailyEpisodeSearchCriteria.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace NzbDrone.Core.IndexerSearch.Definitions -{ - public class DailyEpisodeSearchCriteria : SearchCriteriaBase - { - public DateTime AirDate { get; set; } - - public override string ToString() - { - return string.Format("[{0} : {1:yyyy-MM-dd}", Series.Title, AirDate); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs index 937b27880..63b3e94c9 100644 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs +++ b/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs @@ -3,7 +3,7 @@ using System.Linq; using System.Text.RegularExpressions; using NzbDrone.Common.EnsureThat; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.IndexerSearch.Definitions { @@ -13,11 +13,8 @@ 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 Series Series { get; set; } - public Movie Movie { get; set; } public List SceneTitles { get; set; } - public List Episodes { get; set; } public virtual bool MonitoredEpisodesOnly { get; set; } public virtual bool UserInvokedSearch { get; set; } @@ -39,4 +36,4 @@ namespace NzbDrone.Core.IndexerSearch.Definitions return cleanTitle.Trim('+', ' '); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/SeasonSearchCriteria.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/SeasonSearchCriteria.cs deleted file mode 100644 index 122df795d..000000000 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/SeasonSearchCriteria.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace NzbDrone.Core.IndexerSearch.Definitions -{ - public class SeasonSearchCriteria : SearchCriteriaBase - { - public int SeasonNumber { get; set; } - - public override bool MonitoredEpisodesOnly => true; - - public override string ToString() - { - return string.Format("[{0} : S{1:00}]", Series.Title, SeasonNumber); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/SingleEpisodeSearchCriteria.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/SingleEpisodeSearchCriteria.cs deleted file mode 100644 index 797482846..000000000 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/SingleEpisodeSearchCriteria.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace NzbDrone.Core.IndexerSearch.Definitions -{ - public class SingleEpisodeSearchCriteria : SearchCriteriaBase - { - public int EpisodeNumber { get; set; } - public int SeasonNumber { get; set; } - - public override string ToString() - { - return string.Format("[{0} : S{1:00}E{2:00}]", Series.Title, SeasonNumber, EpisodeNumber); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/SpecialEpisodeSearchCriteria.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/SpecialEpisodeSearchCriteria.cs deleted file mode 100644 index 2b5c0bc0c..000000000 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/SpecialEpisodeSearchCriteria.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Linq; - -namespace NzbDrone.Core.IndexerSearch.Definitions -{ - public class SpecialEpisodeSearchCriteria : SearchCriteriaBase - { - public string[] EpisodeQueryTitles { get; set; } - - public override string ToString() - { - var episodeTitles = EpisodeQueryTitles.ToList(); - - if (episodeTitles.Count > 0) - { - return string.Format("[{0}] Specials", Series.Title); - } - - return string.Format("[{0} : {1}]", Series.Title, string.Join(",", EpisodeQueryTitles)); - } - } -} diff --git a/src/NzbDrone.Core/IndexerSearch/EpisodeSearchCommand.cs b/src/NzbDrone.Core/IndexerSearch/EpisodeSearchCommand.cs deleted file mode 100644 index af0cbf1cc..000000000 --- a/src/NzbDrone.Core/IndexerSearch/EpisodeSearchCommand.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections.Generic; -using NzbDrone.Core.Messaging.Commands; - -namespace NzbDrone.Core.IndexerSearch -{ - public class EpisodeSearchCommand : Command - { - public List EpisodeIds { get; set; } - - public override bool SendUpdatesToClient => true; - - public EpisodeSearchCommand() - { - } - - public EpisodeSearchCommand(List episodeIds) - { - EpisodeIds = episodeIds; - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/IndexerSearch/EpisodeSearchService.cs b/src/NzbDrone.Core/IndexerSearch/EpisodeSearchService.cs deleted file mode 100644 index 4ae7418a8..000000000 --- a/src/NzbDrone.Core/IndexerSearch/EpisodeSearchService.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using NLog; -using NzbDrone.Common.Extensions; -using NzbDrone.Common.Instrumentation.Extensions; -using NzbDrone.Core.Datastore; -using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Download; -using NzbDrone.Core.Messaging.Commands; -using NzbDrone.Core.Queue; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.IndexerSearch -{ - public class EpisodeSearchService : IExecute, IExecute - { - private readonly ISearchForNzb _nzbSearchService; - private readonly IProcessDownloadDecisions _processDownloadDecisions; - private readonly IEpisodeService _episodeService; - private readonly IQueueService _queueService; - private readonly Logger _logger; - - public EpisodeSearchService(ISearchForNzb nzbSearchService, - IProcessDownloadDecisions processDownloadDecisions, - IEpisodeService episodeService, - IQueueService queueService, - Logger logger) - { - _nzbSearchService = nzbSearchService; - _processDownloadDecisions = processDownloadDecisions; - _episodeService = episodeService; - _queueService = queueService; - _logger = logger; - } - - private void SearchForMissingEpisodes(List episodes, bool userInvokedSearch) - { - _logger.ProgressInfo("Performing missing search for {0} episodes", episodes.Count); - var downloadedCount = 0; - - foreach (var series in episodes.GroupBy(e => e.SeriesId)) - { - foreach (var season in series.Select(e => e).GroupBy(e => e.SeasonNumber)) - { - List decisions; - - if (season.Count() > 1) - { - try - { - decisions = _nzbSearchService.SeasonSearch(series.Key, season.Key, true, userInvokedSearch); - } - catch (Exception ex) - { - var message = String.Format("Unable to search for missing episodes in season {0} of [{1}]", season.Key, series.Key); - _logger.Error(ex, message); - continue; - } - } - - else - { - try - { - decisions = _nzbSearchService.EpisodeSearch(season.First(), userInvokedSearch); - } - catch (Exception ex) - { - var message = String.Format("Unable to search for missing episode: [{0}]", season.First()); - _logger.Error(ex, message); - continue; - } - } - - var processed = _processDownloadDecisions.ProcessDecisions(decisions); - - downloadedCount += processed.Grabbed.Count; - } - } - - _logger.ProgressInfo("Completed missing search for {0} episodes. {1} reports downloaded.", episodes.Count, downloadedCount); - } - - public void Execute(EpisodeSearchCommand message) - { - foreach (var episodeId in message.EpisodeIds) - { - var decisions = _nzbSearchService.EpisodeSearch(episodeId, message.Trigger == CommandTrigger.Manual); - var processed = _processDownloadDecisions.ProcessDecisions(decisions); - - _logger.ProgressInfo("Episode search completed. {0} reports downloaded.", processed.Grabbed.Count); - } - } - - public void Execute(MissingEpisodeSearchCommand message) - { - List episodes; - - if (message.SeriesId.HasValue) - { - episodes = _episodeService.GetEpisodeBySeries(message.SeriesId.Value) - .Where(e => e.Monitored && - !e.HasFile && - e.AirDateUtc.HasValue && - e.AirDateUtc.Value.Before(DateTime.UtcNow)) - .ToList(); - } - - else - { - episodes = _episodeService.EpisodesWithoutFiles(new PagingSpec - { - Page = 1, - PageSize = 100000, - SortDirection = SortDirection.Ascending, - SortKey = "Id", - FilterExpression = - v => - v.Monitored == true && - v.Series.Monitored == true - }).Records.ToList(); - } - - var queue = _queueService.GetQueue().Select(q => q.Episode.Id); - var missing = episodes.Where(e => !queue.Contains(e.Id)).ToList(); - - SearchForMissingEpisodes(missing, message.Trigger == CommandTrigger.Manual); - } - } -} diff --git a/src/NzbDrone.Core/IndexerSearch/MissingEpisodeSearchCommand.cs b/src/NzbDrone.Core/IndexerSearch/MissingEpisodeSearchCommand.cs deleted file mode 100644 index 3e2097be3..000000000 --- a/src/NzbDrone.Core/IndexerSearch/MissingEpisodeSearchCommand.cs +++ /dev/null @@ -1,20 +0,0 @@ -using NzbDrone.Core.Messaging.Commands; - -namespace NzbDrone.Core.IndexerSearch -{ - public class MissingEpisodeSearchCommand : Command - { - public int? SeriesId { get; set; } - - public override bool SendUpdatesToClient => true; - - public MissingEpisodeSearchCommand() - { - } - - public MissingEpisodeSearchCommand(int seriesId) - { - SeriesId = seriesId; - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/IndexerSearch/MoviesSearchService.cs b/src/NzbDrone.Core/IndexerSearch/MoviesSearchService.cs index 27f4940f3..597817ac6 100644 --- a/src/NzbDrone.Core/IndexerSearch/MoviesSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/MoviesSearchService.cs @@ -5,7 +5,7 @@ using NLog; using NzbDrone.Common.Instrumentation.Extensions; using NzbDrone.Core.Download; using NzbDrone.Core.Messaging.Commands; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Datastore; using NzbDrone.Core.Queue; using NzbDrone.Core.DecisionEngine; diff --git a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs index 98865538e..24b12a5ea 100644 --- a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs @@ -1,15 +1,14 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.Threading.Tasks; using NLog; using NzbDrone.Common.Instrumentation.Extensions; -using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Indexers; using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using System.Linq; using NzbDrone.Common.TPL; @@ -17,47 +16,28 @@ namespace NzbDrone.Core.IndexerSearch { public interface ISearchForNzb { - List EpisodeSearch(int episodeId, bool userInvokedSearch); - List EpisodeSearch(Episode episode, bool userInvokedSearch); List MovieSearch(int movieId, bool userInvokedSearch); List MovieSearch(Movie movie, bool userInvokedSearch); - List SeasonSearch(int seriesId, int seasonNumber, bool missingOnly, bool userInvokedSearch); } public class NzbSearchService : ISearchForNzb { private readonly IIndexerFactory _indexerFactory; - private readonly ISceneMappingService _sceneMapping; - private readonly ISeriesService _seriesService; - private readonly IEpisodeService _episodeService; private readonly IMakeDownloadDecision _makeDownloadDecision; private readonly IMovieService _movieService; private readonly Logger _logger; public NzbSearchService(IIndexerFactory indexerFactory, - ISceneMappingService sceneMapping, - ISeriesService seriesService, - IEpisodeService episodeService, IMakeDownloadDecision makeDownloadDecision, IMovieService movieService, Logger logger) { _indexerFactory = indexerFactory; - _sceneMapping = sceneMapping; - _seriesService = seriesService; - _episodeService = episodeService; _makeDownloadDecision = makeDownloadDecision; _movieService = movieService; _logger = logger; } - public List EpisodeSearch(int episodeId, bool userInvokedSearch) - { - var episode = _episodeService.GetEpisode(episodeId); - - return EpisodeSearch(episode, userInvokedSearch); - } - public List MovieSearch(int movieId, bool userInvokedSearch) { var movie = _movieService.GetMovie(movieId); @@ -72,210 +52,12 @@ namespace NzbDrone.Core.IndexerSearch return Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec); } - public List EpisodeSearch(Episode episode, bool userInvokedSearch) - { - var series = _seriesService.GetSeries(episode.SeriesId); - - if (series.SeriesType == SeriesTypes.Daily) - { - if (string.IsNullOrWhiteSpace(episode.AirDate)) - { - throw new InvalidOperationException("Daily episode is missing AirDate. Try to refresh series info."); - } - - return SearchDaily(series, episode, userInvokedSearch); - } - if (series.SeriesType == SeriesTypes.Anime) - { - return SearchAnime(series, episode, userInvokedSearch); - } - - if (episode.SeasonNumber == 0) - { - // search for special episodes in season 0 - return SearchSpecial(series, new List { episode }, userInvokedSearch); - } - - return SearchSingle(series, episode, userInvokedSearch); - } - - public List SeasonSearch(int seriesId, int seasonNumber, bool missingOnly, bool userInvokedSearch) - { - var series = _seriesService.GetSeries(seriesId); - var episodes = _episodeService.GetEpisodesBySeason(seriesId, seasonNumber); - - if (missingOnly) - { - episodes = episodes.Where(e => e.Monitored && !e.HasFile).ToList(); - } - - if (series.SeriesType == SeriesTypes.Anime) - { - return SearchAnimeSeason(series, episodes, userInvokedSearch); - } - - if (seasonNumber == 0) - { - // search for special episodes in season 0 - return SearchSpecial(series, episodes, userInvokedSearch); - } - - var downloadDecisions = new List(); - - if (series.UseSceneNumbering) - { - var sceneSeasonGroups = episodes.GroupBy(v => - { - if (v.SceneSeasonNumber.HasValue && v.SceneEpisodeNumber.HasValue) - { - return v.SceneSeasonNumber.Value; - } - return v.SeasonNumber; - }).Distinct(); - - foreach (var sceneSeasonEpisodes in sceneSeasonGroups) - { - if (sceneSeasonEpisodes.Count() == 1) - { - var episode = sceneSeasonEpisodes.First(); - var searchSpec = Get(series, sceneSeasonEpisodes.ToList(), userInvokedSearch); - - searchSpec.SeasonNumber = sceneSeasonEpisodes.Key; - searchSpec.MonitoredEpisodesOnly = true; - - if (episode.SceneSeasonNumber.HasValue && episode.SceneEpisodeNumber.HasValue) - { - searchSpec.EpisodeNumber = episode.SceneEpisodeNumber.Value; - } - else - { - searchSpec.EpisodeNumber = episode.EpisodeNumber; - } - - var decisions = Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec); - downloadDecisions.AddRange(decisions); - } - else - { - var searchSpec = Get(series, sceneSeasonEpisodes.ToList(), userInvokedSearch); - searchSpec.SeasonNumber = sceneSeasonEpisodes.Key; - - var decisions = Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec); - downloadDecisions.AddRange(decisions); - } - } - } - else - { - var searchSpec = Get(series, episodes, userInvokedSearch); - searchSpec.SeasonNumber = seasonNumber; - - var decisions = Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec); - downloadDecisions.AddRange(decisions); - } - - return downloadDecisions; - } - - private List SearchSingle(Series series, Episode episode, bool userInvokedSearch) - { - var searchSpec = Get(series, new List{episode}, userInvokedSearch); - - if (series.UseSceneNumbering && episode.SceneSeasonNumber.HasValue && episode.SceneEpisodeNumber.HasValue) - { - searchSpec.EpisodeNumber = episode.SceneEpisodeNumber.Value; - searchSpec.SeasonNumber = episode.SceneSeasonNumber.Value; - } - else - { - searchSpec.EpisodeNumber = episode.EpisodeNumber; - searchSpec.SeasonNumber = episode.SeasonNumber; - } - - return Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec); - } - - private List SearchDaily(Series series, Episode episode, bool userInvokedSearch) - { - var airDate = DateTime.ParseExact(episode.AirDate, Episode.AIR_DATE_FORMAT, CultureInfo.InvariantCulture); - var searchSpec = Get(series, new List{ episode }, userInvokedSearch); - searchSpec.AirDate = airDate; - - return Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec); - } - - private List SearchAnime(Series series, Episode episode, bool userInvokedSearch) - { - var searchSpec = Get(series, new List { episode }, userInvokedSearch); - - if (episode.SceneAbsoluteEpisodeNumber.HasValue) - { - searchSpec.AbsoluteEpisodeNumber = episode.SceneAbsoluteEpisodeNumber.Value; - } - else if (episode.AbsoluteEpisodeNumber.HasValue) - { - searchSpec.AbsoluteEpisodeNumber = episode.AbsoluteEpisodeNumber.Value; - } - else - { - throw new ArgumentOutOfRangeException("AbsoluteEpisodeNumber", "Can not search for an episode without an absolute episode number"); - } - - return Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec); - } - - private List SearchSpecial(Series series, List episodes, bool userInvokedSearch) - { - var searchSpec = Get(series, episodes, userInvokedSearch); - // build list of queries for each episode in the form: " " - searchSpec.EpisodeQueryTitles = episodes.Where(e => !string.IsNullOrWhiteSpace(e.Title)) - .SelectMany(e => searchSpec.QueryTitles.Select(title => title + " " + SearchCriteriaBase.GetQueryTitle(e.Title))) - .ToArray(); - - return Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec); - } - - private List SearchAnimeSeason(Series series, List episodes, bool userInvokedSearch) - { - var downloadDecisions = new List(); - - foreach (var episode in episodes.Where(e => e.Monitored)) - { - downloadDecisions.AddRange(SearchAnime(series, episode, userInvokedSearch)); - } - - return downloadDecisions; - } - - private TSpec Get(Series series, List episodes, bool userInvokedSearch) where TSpec : SearchCriteriaBase, new() - { - var spec = new TSpec() - { - Series = series, - SceneTitles = _sceneMapping.GetSceneNames(series.TvdbId, - episodes.Select(e => e.SeasonNumber).Distinct().ToList(), - episodes.Select(e => e.SceneSeasonNumber ?? e.SeasonNumber).Distinct().ToList()), - - Episodes = episodes - }; - spec.SceneTitles.Add(series.Title); - spec.UserInvokedSearch = userInvokedSearch; - - return spec; - } - private TSpec Get(Movie movie, bool userInvokedSearch) where TSpec : SearchCriteriaBase, new() { var spec = new TSpec() { Movie = movie, - /*spec.SceneTitles = _sceneMapping.GetSceneNames(series.TvdbId, - episodes.Select(e => e.SeasonNumber).Distinct().ToList(), - episodes.Select(e => e.SceneSeasonNumber ?? e.SeasonNumber).Distinct().ToList()); - - spec.Episodes = episodes; - spec.SceneTitles.Add(series.Title);*/ UserInvokedSearch = userInvokedSearch }; return spec; diff --git a/src/NzbDrone.Core/IndexerSearch/SeasonSearchCommand.cs b/src/NzbDrone.Core/IndexerSearch/SeasonSearchCommand.cs deleted file mode 100644 index 2ac6cd439..000000000 --- a/src/NzbDrone.Core/IndexerSearch/SeasonSearchCommand.cs +++ /dev/null @@ -1,12 +0,0 @@ -using NzbDrone.Core.Messaging.Commands; - -namespace NzbDrone.Core.IndexerSearch -{ - public class SeasonSearchCommand : Command - { - public int SeriesId { get; set; } - public int SeasonNumber { get; set; } - - public override bool SendUpdatesToClient => true; - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/IndexerSearch/SeasonSearchService.cs b/src/NzbDrone.Core/IndexerSearch/SeasonSearchService.cs deleted file mode 100644 index 84c38c07d..000000000 --- a/src/NzbDrone.Core/IndexerSearch/SeasonSearchService.cs +++ /dev/null @@ -1,31 +0,0 @@ -using NLog; -using NzbDrone.Common.Instrumentation.Extensions; -using NzbDrone.Core.Download; -using NzbDrone.Core.Messaging.Commands; - -namespace NzbDrone.Core.IndexerSearch -{ - public class SeasonSearchService : IExecute - { - private readonly ISearchForNzb _nzbSearchService; - private readonly IProcessDownloadDecisions _processDownloadDecisions; - private readonly Logger _logger; - - public SeasonSearchService(ISearchForNzb nzbSearchService, - IProcessDownloadDecisions processDownloadDecisions, - Logger logger) - { - _nzbSearchService = nzbSearchService; - _processDownloadDecisions = processDownloadDecisions; - _logger = logger; - } - - public void Execute(SeasonSearchCommand message) - { - var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, message.SeasonNumber, false, message.Trigger == CommandTrigger.Manual); - var processed = _processDownloadDecisions.ProcessDecisions(decisions); - - _logger.ProgressInfo("Season search completed. {0} reports downloaded.", processed.Grabbed.Count); - } - } -} diff --git a/src/NzbDrone.Core/IndexerSearch/SeriesSearchCommand.cs b/src/NzbDrone.Core/IndexerSearch/SeriesSearchCommand.cs deleted file mode 100644 index bc1a0a51a..000000000 --- a/src/NzbDrone.Core/IndexerSearch/SeriesSearchCommand.cs +++ /dev/null @@ -1,11 +0,0 @@ -using NzbDrone.Core.Messaging.Commands; - -namespace NzbDrone.Core.IndexerSearch -{ - public class SeriesSearchCommand : Command - { - public int SeriesId { get; set; } - - public override bool SendUpdatesToClient => true; - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/IndexerSearch/SeriesSearchService.cs b/src/NzbDrone.Core/IndexerSearch/SeriesSearchService.cs deleted file mode 100644 index 388dadfd8..000000000 --- a/src/NzbDrone.Core/IndexerSearch/SeriesSearchService.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System.Linq; -using NLog; -using NzbDrone.Common.Instrumentation.Extensions; -using NzbDrone.Core.Download; -using NzbDrone.Core.Messaging.Commands; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.IndexerSearch -{ - public class SeriesSearchService : IExecute - { - private readonly ISeriesService _seriesService; - private readonly ISearchForNzb _nzbSearchService; - private readonly IProcessDownloadDecisions _processDownloadDecisions; - private readonly Logger _logger; - - public SeriesSearchService(ISeriesService seriesService, - ISearchForNzb nzbSearchService, - IProcessDownloadDecisions processDownloadDecisions, - Logger logger) - { - _seriesService = seriesService; - _nzbSearchService = nzbSearchService; - _processDownloadDecisions = processDownloadDecisions; - _logger = logger; - } - - public void Execute(SeriesSearchCommand message) - { - var series = _seriesService.GetSeries(message.SeriesId); - - var downloadedCount = 0; - - foreach (var season in series.Seasons.OrderBy(s => s.SeasonNumber)) - { - if (!season.Monitored) - { - _logger.Debug("Season {0} of {1} is not monitored, skipping search", season.SeasonNumber, series.Title); - continue; - } - - var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, season.SeasonNumber, false, message.Trigger == CommandTrigger.Manual); - downloadedCount += _processDownloadDecisions.ProcessDecisions(decisions).Grabbed.Count; - } - - _logger.ProgressInfo("Series search completed. {0} reports downloaded.", downloadedCount); - } - } -} diff --git a/src/NzbDrone.Core/Indexers/AwesomeHD/AwesomeHDRequestGenerator.cs b/src/NzbDrone.Core/Indexers/AwesomeHD/AwesomeHDRequestGenerator.cs index 7343cadc6..4b60f4875 100644 --- a/src/NzbDrone.Core/Indexers/AwesomeHD/AwesomeHDRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/AwesomeHD/AwesomeHDRequestGenerator.cs @@ -37,30 +37,5 @@ namespace NzbDrone.Core.Indexers.AwesomeHD } } - - public virtual IndexerPageableRequestChain GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(AnimeEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(SpecialEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(SeasonSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } } } diff --git a/src/NzbDrone.Core/Indexers/HDBits/HDBitsRequestGenerator.cs b/src/NzbDrone.Core/Indexers/HDBits/HDBitsRequestGenerator.cs index ef1e453d4..789cf0285 100644 --- a/src/NzbDrone.Core/Indexers/HDBits/HDBitsRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/HDBits/HDBitsRequestGenerator.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using NzbDrone.Common.Http; using NzbDrone.Common.Serializer; @@ -67,30 +67,5 @@ namespace NzbDrone.Core.Indexers.HDBits yield return new IndexerRequest(request); } - - public virtual IndexerPageableRequestChain GetSearchRequests(AnimeEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(SpecialEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(SeasonSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs index a29e9a9b8..aab7af4cf 100644 --- a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs +++ b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Net; @@ -51,66 +51,6 @@ namespace NzbDrone.Core.Indexers return FetchReleases(generator.GetRecentRequests(), true); } - public override IList Fetch(SingleEpisodeSearchCriteria searchCriteria) - { - if (!SupportsSearch) - { - return new List(); - } - - var generator = GetRequestGenerator(); - - return FetchReleases(generator.GetSearchRequests(searchCriteria)); - } - - public override IList Fetch(SeasonSearchCriteria searchCriteria) - { - if (!SupportsSearch) - { - return new List(); - } - - var generator = GetRequestGenerator(); - - return FetchReleases(generator.GetSearchRequests(searchCriteria)); - } - - public override IList Fetch(DailyEpisodeSearchCriteria searchCriteria) - { - if (!SupportsSearch) - { - return new List(); - } - - var generator = GetRequestGenerator(); - - return FetchReleases(generator.GetSearchRequests(searchCriteria)); - } - - public override IList Fetch(AnimeEpisodeSearchCriteria searchCriteria) - { - if (!SupportsSearch) - { - return new List(); - } - - var generator = GetRequestGenerator(); - - return FetchReleases(generator.GetSearchRequests(searchCriteria)); - } - - public override IList Fetch(SpecialEpisodeSearchCriteria searchCriteria) - { - if (!SupportsSearch) - { - return new List(); - } - - var generator = GetRequestGenerator(); - - return FetchReleases(generator.GetSearchRequests(searchCriteria)); - } - public override IList Fetch(MovieSearchCriteria searchCriteria) { if (!SupportsSearch) diff --git a/src/NzbDrone.Core/Indexers/IIndexer.cs b/src/NzbDrone.Core/Indexers/IIndexer.cs index f83bc3162..9db79f361 100644 --- a/src/NzbDrone.Core/Indexers/IIndexer.cs +++ b/src/NzbDrone.Core/Indexers/IIndexer.cs @@ -12,11 +12,6 @@ namespace NzbDrone.Core.Indexers DownloadProtocol Protocol { get; } IList FetchRecent(); - IList Fetch(SeasonSearchCriteria searchCriteria); - IList Fetch(SingleEpisodeSearchCriteria searchCriteria); - IList Fetch(DailyEpisodeSearchCriteria searchCriteria); - IList Fetch(AnimeEpisodeSearchCriteria searchCriteria); - IList Fetch(SpecialEpisodeSearchCriteria searchCriteria); IList Fetch(MovieSearchCriteria searchCriteria); } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/Indexers/IIndexerRequestGenerator.cs b/src/NzbDrone.Core/Indexers/IIndexerRequestGenerator.cs index f321dacd7..372125582 100644 --- a/src/NzbDrone.Core/Indexers/IIndexerRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/IIndexerRequestGenerator.cs @@ -1,15 +1,10 @@ -using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.IndexerSearch.Definitions; namespace NzbDrone.Core.Indexers { public interface IIndexerRequestGenerator { IndexerPageableRequestChain GetRecentRequests(); - IndexerPageableRequestChain GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria); - IndexerPageableRequestChain GetSearchRequests(SeasonSearchCriteria searchCriteria); - IndexerPageableRequestChain GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria); - IndexerPageableRequestChain GetSearchRequests(AnimeEpisodeSearchCriteria searchCriteria); - IndexerPageableRequestChain GetSearchRequests(SpecialEpisodeSearchCriteria searchCriteria); IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria); } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/Indexers/IPTorrents/IPTorrentsRequestGenerator.cs b/src/NzbDrone.Core/Indexers/IPTorrents/IPTorrentsRequestGenerator.cs index 8537f51a6..339f9471d 100644 --- a/src/NzbDrone.Core/Indexers/IPTorrents/IPTorrentsRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/IPTorrents/IPTorrentsRequestGenerator.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using NzbDrone.Common.Http; using NzbDrone.Core.IndexerSearch.Definitions; @@ -17,37 +17,12 @@ namespace NzbDrone.Core.Indexers.IPTorrents return pageableRequests; } - - public virtual IndexerPageableRequestChain GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - + public IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria) { return new IndexerPageableRequestChain(); } - public virtual IndexerPageableRequestChain GetSearchRequests(SeasonSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(AnimeEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(SpecialEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - private IEnumerable GetRssRequests() { yield return new IndexerRequest(Settings.BaseUrl, HttpAccept.Rss); diff --git a/src/NzbDrone.Core/Indexers/IndexerBase.cs b/src/NzbDrone.Core/Indexers/IndexerBase.cs index 8cd1c68e0..28dde1ca6 100644 --- a/src/NzbDrone.Core/Indexers/IndexerBase.cs +++ b/src/NzbDrone.Core/Indexers/IndexerBase.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using FluentValidation.Results; @@ -59,11 +59,6 @@ namespace NzbDrone.Core.Indexers protected TSettings Settings => (TSettings)Definition.Settings; public abstract IList FetchRecent(); - public abstract IList Fetch(SeasonSearchCriteria searchCriteria); - public abstract IList Fetch(SingleEpisodeSearchCriteria searchCriteria); - public abstract IList Fetch(DailyEpisodeSearchCriteria searchCriteria); - public abstract IList Fetch(AnimeEpisodeSearchCriteria searchCriteria); - public abstract IList Fetch(SpecialEpisodeSearchCriteria searchCriteria); public abstract IList Fetch(MovieSearchCriteria searchCriteria); protected virtual IList CleanupReleases(IEnumerable releases) diff --git a/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs index 0b8f199e0..06a681ac5 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Net; @@ -109,31 +109,5 @@ namespace NzbDrone.Core.Indexers.Newznab } } } - - - public virtual IndexerPageableRequestChain GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(SeasonSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(AnimeEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(SpecialEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } } } diff --git a/src/NzbDrone.Core/Indexers/Nyaa/NyaaRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Nyaa/NyaaRequestGenerator.cs index 6eac44084..0a4553f3a 100644 --- a/src/NzbDrone.Core/Indexers/Nyaa/NyaaRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Nyaa/NyaaRequestGenerator.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using NzbDrone.Common.Http; using NzbDrone.Core.IndexerSearch.Definitions; @@ -27,54 +27,6 @@ namespace NzbDrone.Core.Indexers.Nyaa return pageableRequests; } - public virtual IndexerPageableRequestChain GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(SeasonSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(AnimeEpisodeSearchCriteria searchCriteria) - { - var pageableRequests = new IndexerPageableRequestChain(); - - foreach (var queryTitle in searchCriteria.QueryTitles) - { - var searchTitle = PrepareQuery(queryTitle); - - pageableRequests.Add(GetPagedRequests(MaxPages, $"{searchTitle}+{searchCriteria.AbsoluteEpisodeNumber:0}")); - - if (searchCriteria.AbsoluteEpisodeNumber < 10) - { - pageableRequests.Add(GetPagedRequests(MaxPages, $"{searchTitle}+{searchCriteria.AbsoluteEpisodeNumber:00}")); - } - } - - return pageableRequests; - } - - public virtual IndexerPageableRequestChain GetSearchRequests(SpecialEpisodeSearchCriteria searchCriteria) - { - var pageableRequests = new IndexerPageableRequestChain(); - - foreach (var queryTitle in searchCriteria.EpisodeQueryTitles) - { - pageableRequests.Add(GetPagedRequests(MaxPages, - string.Format("&term={0}", - PrepareQuery(queryTitle)))); - } - - return pageableRequests; - } - private IEnumerable GetPagedRequests(int maxPages, string term) { var baseUrl = string.Format("{0}/?page=rss{1}", Settings.BaseUrl.TrimEnd('/'), Settings.AdditionalParameters); diff --git a/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs index a0b81decd..16e310190 100644 --- a/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; using NzbDrone.Common.Extensions; @@ -26,69 +26,6 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs return pageableRequests; } - public virtual IndexerPageableRequestChain GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria) - { - var pageableRequests = new IndexerPageableRequestChain(); - - foreach (var queryTitle in searchCriteria.QueryTitles) - { - pageableRequests.Add(GetPagedRequests(string.Format("{0}+S{1:00}E{2:00}", - queryTitle, - searchCriteria.SeasonNumber, - searchCriteria.EpisodeNumber))); - } - - return pageableRequests; - } - - public virtual IndexerPageableRequestChain GetSearchRequests(SeasonSearchCriteria searchCriteria) - { - var pageableRequests = new IndexerPageableRequestChain(); - - foreach (var queryTitle in searchCriteria.QueryTitles) - { - pageableRequests.Add(GetPagedRequests(string.Format("{0}+S{1:00}", - queryTitle, - searchCriteria.SeasonNumber))); - } - - return pageableRequests; - } - - public virtual IndexerPageableRequestChain GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria) - { - var pageableRequests = new IndexerPageableRequestChain(); - - foreach (var queryTitle in searchCriteria.QueryTitles) - { - pageableRequests.Add(GetPagedRequests(string.Format("{0}+{1:yyyy MM dd}", - queryTitle, - searchCriteria.AirDate))); - } - - return pageableRequests; - } - - public virtual IndexerPageableRequestChain GetSearchRequests(AnimeEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(SpecialEpisodeSearchCriteria searchCriteria) - { - var pageableRequests = new IndexerPageableRequestChain(); - - foreach (var queryTitle in searchCriteria.EpisodeQueryTitles) - { - var query = queryTitle.Replace('+', ' '); - query = System.Web.HttpUtility.UrlEncode(query); - - pageableRequests.Add(GetPagedRequests(query)); - } - - return pageableRequests; - } - private IEnumerable GetPagedRequests(string query) { var url = new StringBuilder(); diff --git a/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornRequestGenerator.cs b/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornRequestGenerator.cs index 5f177477a..01133f1a3 100644 --- a/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornRequestGenerator.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using NzbDrone.Common.Http; using NzbDrone.Core.IndexerSearch.Definitions; @@ -105,32 +105,5 @@ namespace NzbDrone.Core.Indexers.PassThePopcorn requestBuilder.SetCookies(cookies); } } - - public virtual IndexerPageableRequestChain GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(AnimeEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(SpecialEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(SeasonSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - } } diff --git a/src/NzbDrone.Core/Indexers/Rarbg/RarbgParser.cs b/src/NzbDrone.Core/Indexers/Rarbg/RarbgParser.cs index 15cd05c4a..223446ffb 100644 --- a/src/NzbDrone.Core/Indexers/Rarbg/RarbgParser.cs +++ b/src/NzbDrone.Core/Indexers/Rarbg/RarbgParser.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Net; using System.Text.RegularExpressions; using NzbDrone.Common.Http; @@ -57,16 +57,16 @@ namespace NzbDrone.Core.Indexers.Rarbg torrentInfo.Seeders = torrent.seeders; torrentInfo.Peers = torrent.leechers + torrent.seeders; - if (torrent.episode_info != null) + if (torrent.movie_info != null) { - if (torrent.episode_info.tvdb != null) + if (torrent.movie_info.tvdb != null) { - torrentInfo.TvdbId = torrent.episode_info.tvdb.Value; + torrentInfo.TvdbId = torrent.movie_info.tvdb.Value; } - if (torrent.episode_info.tvrage != null) + if (torrent.movie_info.tvrage != null) { - torrentInfo.TvRageId = torrent.episode_info.tvrage.Value; + torrentInfo.TvRageId = torrent.movie_info.tvrage.Value; } } diff --git a/src/NzbDrone.Core/Indexers/Rarbg/RarbgRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Rarbg/RarbgRequestGenerator.cs index 359ec411d..59caed890 100644 --- a/src/NzbDrone.Core/Indexers/Rarbg/RarbgRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Rarbg/RarbgRequestGenerator.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; using NzbDrone.Core.IndexerSearch.Definitions; @@ -105,30 +105,5 @@ namespace NzbDrone.Core.Indexers.Rarbg yield return new IndexerRequest(requestBuilder.Build()); } - - public virtual IndexerPageableRequestChain GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(SeasonSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(AnimeEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(SpecialEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } } } diff --git a/src/NzbDrone.Core/Indexers/Rarbg/RarbgResponse.cs b/src/NzbDrone.Core/Indexers/Rarbg/RarbgResponse.cs index 51c2e8350..2ba32d32b 100644 --- a/src/NzbDrone.Core/Indexers/Rarbg/RarbgResponse.cs +++ b/src/NzbDrone.Core/Indexers/Rarbg/RarbgResponse.cs @@ -19,7 +19,7 @@ namespace NzbDrone.Core.Indexers.Rarbg public int? leechers { get; set; } public long size { get; set; } public DateTime pubdate { get; set; } - public RarbgTorrentInfo episode_info { get; set; } + public RarbgTorrentInfo movie_info { get; set; } public int? ranked { get; set; } public string info_page { get; set; } } diff --git a/src/NzbDrone.Core/Indexers/RssIndexerRequestGenerator.cs b/src/NzbDrone.Core/Indexers/RssIndexerRequestGenerator.cs index bac3efd51..40cbaaaac 100644 --- a/src/NzbDrone.Core/Indexers/RssIndexerRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/RssIndexerRequestGenerator.cs @@ -1,4 +1,4 @@ -using System; +using System; using NzbDrone.Common.Http; using NzbDrone.Core.IndexerSearch.Definitions; @@ -27,30 +27,5 @@ namespace NzbDrone.Core.Indexers { return new IndexerPageableRequestChain(); } - - public virtual IndexerPageableRequestChain GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(SeasonSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(AnimeEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(SpecialEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } } } diff --git a/src/NzbDrone.Core/Indexers/TorrentPotato/TorrentPotatoRequestGenerator.cs b/src/NzbDrone.Core/Indexers/TorrentPotato/TorrentPotatoRequestGenerator.cs index ae6378049..e4409d368 100644 --- a/src/NzbDrone.Core/Indexers/TorrentPotato/TorrentPotatoRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/TorrentPotato/TorrentPotatoRequestGenerator.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; @@ -25,31 +25,6 @@ namespace NzbDrone.Core.Indexers.TorrentPotato return pageableRequests; } - public virtual IndexerPageableRequestChain GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(SeasonSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(AnimeEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(SpecialEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - private IEnumerable GetPagedRequests(string mode, int? tvdbId, string query, params object[] args) { var requestBuilder = new HttpRequestBuilder(Settings.BaseUrl) diff --git a/src/NzbDrone.Core/Indexers/TorrentRss/TorrentRssIndexerRequestGenerator.cs b/src/NzbDrone.Core/Indexers/TorrentRss/TorrentRssIndexerRequestGenerator.cs index 1a77709cd..f5843311b 100644 --- a/src/NzbDrone.Core/Indexers/TorrentRss/TorrentRssIndexerRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/TorrentRss/TorrentRssIndexerRequestGenerator.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; @@ -19,36 +19,11 @@ namespace NzbDrone.Core.Indexers.TorrentRss return pageableRequests; } - public virtual IndexerPageableRequestChain GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - public IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria) { return new IndexerPageableRequestChain(); } - public virtual IndexerPageableRequestChain GetSearchRequests(SeasonSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(AnimeEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public virtual IndexerPageableRequestChain GetSearchRequests(SpecialEpisodeSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - private IEnumerable GetRssRequests(string searchParameters) { var request = new IndexerRequest(Settings.BaseUrl.Trim().TrimEnd('/'), HttpAccept.Rss); diff --git a/src/NzbDrone.Core/Jobs/TaskManager.cs b/src/NzbDrone.Core/Jobs/TaskManager.cs index 717fff6de..4ad1b65df 100644 --- a/src/NzbDrone.Core/Jobs/TaskManager.cs +++ b/src/NzbDrone.Core/Jobs/TaskManager.cs @@ -1,11 +1,10 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using NLog; using NzbDrone.Core.Backup; using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration.Events; -using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.Download; using NzbDrone.Core.HealthCheck; using NzbDrone.Core.Housekeeping; @@ -15,7 +14,7 @@ using NzbDrone.Core.MediaFiles.Commands; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.NetImport; -using NzbDrone.Core.Tv.Commands; +using NzbDrone.Core.Movies.Commands; using NzbDrone.Core.Update.Commands; using NzbDrone.Core.MetadataSource.PreDB; @@ -97,7 +96,6 @@ namespace NzbDrone.Core.Jobs new ScheduledTask { Interval = _configService.DownloadedMoviesScanInterval, - //TypeName = typeof(DownloadedEpisodesScanCommand).FullName TypeName = typeof(DownloadedMoviesScanCommand).FullName }, }; diff --git a/src/NzbDrone.Core/MediaCover/MediaCoverService.cs b/src/NzbDrone.Core/MediaCover/MediaCoverService.cs index d78e7a499..b4bc2aed2 100644 --- a/src/NzbDrone.Core/MediaCover/MediaCoverService.cs +++ b/src/NzbDrone.Core/MediaCover/MediaCoverService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Net; @@ -9,22 +9,21 @@ using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Tv.Events; +using NzbDrone.Core.Movies; +using NzbDrone.Core.Movies.Events; namespace NzbDrone.Core.MediaCover { public interface IMapCoversToLocal { - void ConvertToLocalUrls(int seriesId, IEnumerable covers); - string GetCoverPath(int seriesId, MediaCoverTypes mediaCoverTypes, int? height = null); + void ConvertToLocalUrls(int movieId, IEnumerable covers); + string GetCoverPath(int movieId, MediaCoverTypes mediaCoverTypes, int? height = null); } public class MediaCoverService : - IHandleAsync, IHandleAsync, IHandleAsync, - IHandleAsync, + IHandleAsync, IMapCoversToLocal { private readonly IImageResizer _resizer; @@ -57,20 +56,20 @@ namespace NzbDrone.Core.MediaCover _coverRootFolder = appFolderInfo.GetMediaCoverPath(); } - public string GetCoverPath(int seriesId, MediaCoverTypes coverTypes, int? height = null) + public string GetCoverPath(int movieId, MediaCoverTypes coverTypes, int? height = null) { var heightSuffix = height.HasValue ? "-" + height.ToString() : ""; - return Path.Combine(GetSeriesCoverPath(seriesId), coverTypes.ToString().ToLower() + heightSuffix + ".jpg"); + return Path.Combine(GetMovieCoverPath(movieId), coverTypes.ToString().ToLower() + heightSuffix + ".jpg"); } - public void ConvertToLocalUrls(int seriesId, IEnumerable covers) + public void ConvertToLocalUrls(int movieId, IEnumerable covers) { foreach (var mediaCover in covers) { - var filePath = GetCoverPath(seriesId, mediaCover.CoverType); + var filePath = GetCoverPath(movieId, mediaCover.CoverType); - mediaCover.Url = _configFileProvider.UrlBase + @"/MediaCover/" + seriesId + "/" + mediaCover.CoverType.ToString().ToLower() + ".jpg"; + mediaCover.Url = _configFileProvider.UrlBase + @"/MediaCover/" + movieId + "/" + mediaCover.CoverType.ToString().ToLower() + ".jpg"; /*if (_diskProvider.FileExists(filePath)) { @@ -80,38 +79,9 @@ namespace NzbDrone.Core.MediaCover } } - private string GetSeriesCoverPath(int seriesId) + private string GetMovieCoverPath(int movieId) { - return Path.Combine(_coverRootFolder, seriesId.ToString()); - } - - - - private void EnsureCovers(Series series) - { - foreach (var cover in series.Images) - { - var fileName = GetCoverPath(series.Id, cover.CoverType); - var alreadyExists = false; - try - { - alreadyExists = _coverExistsSpecification.AlreadyExists(cover.Url, fileName); - if (!alreadyExists) - { - DownloadCover(series, cover); - } - } - catch (WebException e) - { - _logger.Warn(string.Format("Couldn't download media cover for {0}. {1}", series, e.Message)); - } - catch (Exception e) - { - _logger.Error(e, "Couldn't download media cover for " + series); - } - - EnsureResizedCovers(series, cover, !alreadyExists); - } + return Path.Combine(_coverRootFolder, movieId.ToString()); } private void EnsureCovers(Movie movie, int retried = 0) @@ -159,68 +129,15 @@ namespace NzbDrone.Core.MediaCover } } - private void DownloadCover(Series series, MediaCover cover) - { - var fileName = GetCoverPath(series.Id, cover.CoverType); - - _logger.Info("Downloading {0} for {1} {2}", cover.CoverType, series, cover.Url); - _httpClient.DownloadFile(cover.Url, fileName); - } - - private void DownloadCover(Movie series, MediaCover cover) + private void DownloadCover(Movie movie, MediaCover cover) { - var fileName = GetCoverPath(series.Id, cover.CoverType); + var fileName = GetCoverPath(movie.Id, cover.CoverType); - _logger.Info("Downloading {0} for {1} {2}", cover.CoverType, series, cover.Url); + _logger.Info("Downloading {0} for {1} {2}", cover.CoverType, movie, cover.Url); _httpClient.DownloadFile(cover.Url, fileName); } - private void EnsureResizedCovers(Series series, MediaCover cover, bool forceResize) - { - int[] heights; - - switch (cover.CoverType) - { - default: - return; - - case MediaCoverTypes.Poster: - case MediaCoverTypes.Headshot: - heights = new[] { 500, 250 }; - break; - - case MediaCoverTypes.Banner: - heights = new[] { 70, 35 }; - break; - - case MediaCoverTypes.Fanart: - case MediaCoverTypes.Screenshot: - heights = new[] { 360, 180 }; - break; - } - - foreach (var height in heights) - { - var mainFileName = GetCoverPath(series.Id, cover.CoverType); - var resizeFileName = GetCoverPath(series.Id, cover.CoverType, height); - - if (forceResize || !_diskProvider.FileExists(resizeFileName) || _diskProvider.GetFileSize(resizeFileName) == 0) - { - _logger.Debug("Resizing {0}-{1} for {2}", cover.CoverType, height, series); - - try - { - _resizer.Resize(mainFileName, resizeFileName, height); - } - catch - { - _logger.Debug("Couldn't resize media cover {0}-{1} for {2}, using full size image instead.", cover.CoverType, height, series); - } - } - } - } - - private void EnsureResizedCovers(Movie series, MediaCover cover, bool forceResize) + private void EnsureResizedCovers(Movie movie, MediaCover cover, bool forceResize) { int[] heights; @@ -246,12 +163,12 @@ namespace NzbDrone.Core.MediaCover foreach (var height in heights) { - var mainFileName = GetCoverPath(series.Id, cover.CoverType); - var resizeFileName = GetCoverPath(series.Id, cover.CoverType, height); + var mainFileName = GetCoverPath(movie.Id, cover.CoverType); + var resizeFileName = GetCoverPath(movie.Id, cover.CoverType, height); if (forceResize || !_diskProvider.FileExists(resizeFileName) || _diskProvider.GetFileSize(resizeFileName) == 0) { - _logger.Debug("Resizing {0}-{1} for {2}", cover.CoverType, height, series); + _logger.Debug("Resizing {0}-{1} for {2}", cover.CoverType, height, movie); try { @@ -259,18 +176,12 @@ namespace NzbDrone.Core.MediaCover } catch { - _logger.Debug("Couldn't resize media cover {0}-{1} for {2}, using full size image instead.", cover.CoverType, height, series); + _logger.Debug("Couldn't resize media cover {0}-{1} for {2}, using full size image instead.", cover.CoverType, height, movie); } } } } - public void HandleAsync(SeriesUpdatedEvent message) - { - EnsureCovers(message.Series); - _eventAggregator.PublishEvent(new MediaCoversUpdatedEvent(message.Series)); - } - public void HandleAsync(MovieUpdatedEvent message) { EnsureCovers(message.Movie); @@ -283,9 +194,9 @@ namespace NzbDrone.Core.MediaCover _eventAggregator.PublishEvent(new MediaCoversUpdatedEvent(message.Movie)); } - public void HandleAsync(SeriesDeletedEvent message) + public void HandleAsync(MovieDeletedEvent message) { - var path = GetSeriesCoverPath(message.Series.Id); + var path = GetMovieCoverPath(message.Movie.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 2f56e7cb0..3dc1832f9 100644 --- a/src/NzbDrone.Core/MediaCover/MediaCoversUpdatedEvent.cs +++ b/src/NzbDrone.Core/MediaCover/MediaCoversUpdatedEvent.cs @@ -1,19 +1,12 @@ -using NzbDrone.Common.Messaging; -using NzbDrone.Core.Tv; +using NzbDrone.Common.Messaging; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.MediaCover { public class MediaCoversUpdatedEvent : IEvent { - public Series Series { get; set; } - public Movie Movie { get; set; } - public MediaCoversUpdatedEvent(Series series) - { - Series = series; - } - public MediaCoversUpdatedEvent(Movie movie) { Movie = movie; diff --git a/src/NzbDrone.Core/MediaFiles/Commands/DownloadedEpisodesScanCommand.cs b/src/NzbDrone.Core/MediaFiles/Commands/DownloadedEpisodesScanCommand.cs deleted file mode 100644 index ab2f80480..000000000 --- a/src/NzbDrone.Core/MediaFiles/Commands/DownloadedEpisodesScanCommand.cs +++ /dev/null @@ -1,17 +0,0 @@ -using NzbDrone.Core.MediaFiles.EpisodeImport; -using NzbDrone.Core.Messaging.Commands; - -namespace NzbDrone.Core.MediaFiles.Commands -{ - public class DownloadedEpisodesScanCommand : Command - { - public override bool SendUpdatesToClient => SendUpdates; - - public bool SendUpdates { get; set; } - - // Properties used by third-party apps, do not modify. - public string Path { get; set; } - public string DownloadClientId { get; set; } - public ImportMode ImportMode { get; set; } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/Commands/DownloadedMovieScanCommand.cs b/src/NzbDrone.Core/MediaFiles/Commands/DownloadedMovieScanCommand.cs index 7f46f0430..1598efecd 100644 --- a/src/NzbDrone.Core/MediaFiles/Commands/DownloadedMovieScanCommand.cs +++ b/src/NzbDrone.Core/MediaFiles/Commands/DownloadedMovieScanCommand.cs @@ -1,4 +1,4 @@ -using NzbDrone.Core.MediaFiles.EpisodeImport; +using NzbDrone.Core.MediaFiles.MovieImport; using NzbDrone.Core.Messaging.Commands; namespace NzbDrone.Core.MediaFiles.Commands diff --git a/src/NzbDrone.Core/MediaFiles/Commands/RenameFilesCommand.cs b/src/NzbDrone.Core/MediaFiles/Commands/RenameFilesCommand.cs index 5cbbe7dfb..aceaaeae5 100644 --- a/src/NzbDrone.Core/MediaFiles/Commands/RenameFilesCommand.cs +++ b/src/NzbDrone.Core/MediaFiles/Commands/RenameFilesCommand.cs @@ -1,11 +1,11 @@ -using System.Collections.Generic; +using System.Collections.Generic; using NzbDrone.Core.Messaging.Commands; namespace NzbDrone.Core.MediaFiles.Commands { public class RenameFilesCommand : Command { - public int SeriesId { get; set; } + public int MovieId { get; set; } public List Files { get; set; } public override bool SendUpdatesToClient => true; @@ -14,10 +14,10 @@ namespace NzbDrone.Core.MediaFiles.Commands { } - public RenameFilesCommand(int seriesId, List files) + public RenameFilesCommand(int movieId, List files) { - SeriesId = seriesId; + MovieId = movieId; Files = files; } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/MediaFiles/Commands/RenameSeriesCommand.cs b/src/NzbDrone.Core/MediaFiles/Commands/RenameSeriesCommand.cs deleted file mode 100644 index a2bcda88c..000000000 --- a/src/NzbDrone.Core/MediaFiles/Commands/RenameSeriesCommand.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections.Generic; -using NzbDrone.Core.Messaging.Commands; - -namespace NzbDrone.Core.MediaFiles.Commands -{ - public class RenameSeriesCommand : Command - { - public List SeriesIds { get; set; } - - public override bool SendUpdatesToClient => true; - - public RenameSeriesCommand() - { - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/MediaFiles/Commands/RescanSeriesCommand.cs b/src/NzbDrone.Core/MediaFiles/Commands/RescanSeriesCommand.cs deleted file mode 100644 index 6330574ab..000000000 --- a/src/NzbDrone.Core/MediaFiles/Commands/RescanSeriesCommand.cs +++ /dev/null @@ -1,20 +0,0 @@ -using NzbDrone.Core.Messaging.Commands; - -namespace NzbDrone.Core.MediaFiles.Commands -{ - public class RescanSeriesCommand : Command - { - public int? SeriesId { get; set; } - - public override bool SendUpdatesToClient => true; - - public RescanSeriesCommand() - { - } - - public RescanSeriesCommand(int seriesId) - { - SeriesId = seriesId; - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/MediaFiles/DiskScanService.cs b/src/NzbDrone.Core/MediaFiles/DiskScanService.cs index 82b97e482..d1427299c 100644 --- a/src/NzbDrone.Core/MediaFiles/DiskScanService.cs +++ b/src/NzbDrone.Core/MediaFiles/DiskScanService.cs @@ -10,64 +10,54 @@ using NzbDrone.Common.Extensions; using NzbDrone.Common.Instrumentation.Extensions; using NzbDrone.Core.Configuration; using NzbDrone.Core.MediaFiles.Commands; -using NzbDrone.Core.MediaFiles.EpisodeImport; +using NzbDrone.Core.MediaFiles.MovieImport; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Tv.Events; +using NzbDrone.Core.Movies; +using NzbDrone.Core.Movies.Events; namespace NzbDrone.Core.MediaFiles { public interface IDiskScanService { - void Scan(Series series); void Scan(Movie movie); string[] GetVideoFiles(string path, bool allDirectories = true); string[] GetNonVideoFiles(string path, bool allDirectories = true); - List FilterFiles(Series series, IEnumerable files); - List FilterFiles(Movie series, IEnumerable files); + List FilterFiles(Movie movie, IEnumerable files); } public class DiskScanService : IDiskScanService, - IHandle, IHandle, - IExecute, - IExecute + IExecute { private readonly IDiskProvider _diskProvider; private readonly IMakeImportDecision _importDecisionMaker; - private readonly IImportApprovedEpisodes _importApprovedEpisodes; private readonly IImportApprovedMovie _importApprovedMovies; private readonly IConfigService _configService; - private readonly ISeriesService _seriesService; private readonly IMediaFileTableCleanupService _mediaFileTableCleanupService; private readonly IEventAggregator _eventAggregator; private readonly IMovieService _movieService; - private readonly IMovieFileRepository _movieFileRepository; - private readonly IRenameMovieFileService _renameMovieFiles; + private readonly IMediaFileService _movieFileRepository; + private readonly IRenameMovieFileService _renameMovieFiles; private readonly Logger _logger; public DiskScanService(IDiskProvider diskProvider, IMakeImportDecision importDecisionMaker, - IImportApprovedEpisodes importApprovedEpisodes, IImportApprovedMovie importApprovedMovies, IConfigService configService, - ISeriesService seriesService, IMediaFileTableCleanupService mediaFileTableCleanupService, IEventAggregator eventAggregator, IMovieService movieService, - IMovieFileRepository movieFileRepository, - IRenameMovieFileService renameMovieFiles, + IMediaFileService movieFileRepository, + IRenameMovieFileService renameMovieFiles, Logger logger) { _diskProvider = diskProvider; _importDecisionMaker = importDecisionMaker; - _importApprovedEpisodes = importApprovedEpisodes; _importApprovedMovies = importApprovedMovies; _configService = configService; - _seriesService = seriesService; _mediaFileTableCleanupService = mediaFileTableCleanupService; _eventAggregator = eventAggregator; _movieService = movieService; @@ -79,64 +69,6 @@ namespace NzbDrone.Core.MediaFiles private static readonly Regex ExcludedSubFoldersRegex = new Regex(@"(?:\\|\/|^)(extras|@eadir|extrafanart|plex\sversions|\..+)(?:\\|\/)", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex ExcludedFilesRegex = new Regex(@"^\._|Thumbs\.db", RegexOptions.Compiled | RegexOptions.IgnoreCase); - public void Scan(Series series) - { - var rootFolder = _diskProvider.GetParentFolder(series.Path); - - if (!_diskProvider.FolderExists(rootFolder)) - { - _logger.Warn("Series' root folder ({0}) doesn't exist.", rootFolder); - _eventAggregator.PublishEvent(new SeriesScanSkippedEvent(series, SeriesScanSkippedReason.RootFolderDoesNotExist)); - return; - } - - if (_diskProvider.GetDirectories(rootFolder).Empty()) - { - _logger.Warn("Series' root folder ({0}) is empty.", rootFolder); - _eventAggregator.PublishEvent(new SeriesScanSkippedEvent(series, SeriesScanSkippedReason.RootFolderIsEmpty)); - return; - } - - _logger.ProgressInfo("Scanning disk for {0}", series.Title); - - if (!_diskProvider.FolderExists(series.Path)) - { - if (_configService.CreateEmptySeriesFolders && - _diskProvider.FolderExists(rootFolder)) - { - _logger.Debug("Creating missing series folder: {0}", series.Path); - _diskProvider.CreateFolder(series.Path); - SetPermissions(series.Path); - } - else - { - _logger.Debug("Series folder doesn't exist: {0}", series.Path); - } - - _eventAggregator.PublishEvent(new SeriesScanSkippedEvent(series, SeriesScanSkippedReason.SeriesFolderDoesNotExist)); - return; - } - - var videoFilesStopwatch = Stopwatch.StartNew(); - var mediaFileList = FilterFiles(series, GetVideoFiles(series.Path)).ToList(); - - videoFilesStopwatch.Stop(); - _logger.Trace("Finished getting episode files for: {0} [{1}]", series, videoFilesStopwatch.Elapsed); - - _logger.Debug("{0} Cleaning up media files in DB", series); - _mediaFileTableCleanupService.Clean(series, mediaFileList); - - var decisionsStopwatch = Stopwatch.StartNew(); - var decisions = _importDecisionMaker.GetImportDecisions(mediaFileList, series); - decisionsStopwatch.Stop(); - _logger.Trace("Import decisions complete for: {0} [{1}]", series, decisionsStopwatch.Elapsed); - - _importApprovedEpisodes.Import(decisions, false); - - _logger.Info("Completed scanning disk for {0}", series.Title); - _eventAggregator.PublishEvent(new SeriesScannedEvent(series)); - } - public void Scan(Movie movie) { //Try renaming the movie path in case anything changed such as year, title or something else. @@ -176,6 +108,10 @@ namespace NzbDrone.Core.MediaFiles _diskProvider.CreateFolder(movie.Path); SetPermissions(movie.Path); } + else + { + _logger.Debug("Movies folder doesn't exist: {0}", movie.Path); + } _eventAggregator.PublishEvent(new MovieScanSkippedEvent(movie, MovieScanSkippedReason.MovieFolderDoesNotExist)); return; @@ -185,7 +121,7 @@ namespace NzbDrone.Core.MediaFiles var mediaFileList = FilterFiles(movie, GetVideoFiles(movie.Path)).ToList(); videoFilesStopwatch.Stop(); - _logger.Trace("Finished getting episode files for: {0} [{1}]", movie, videoFilesStopwatch.Elapsed); + _logger.Trace("Finished getting movie files for: {0} [{1}]", movie, videoFilesStopwatch.Elapsed); _logger.Debug("{0} Cleaning up media files in DB", movie); _mediaFileTableCleanupService.Clean(movie, mediaFileList); @@ -194,8 +130,7 @@ namespace NzbDrone.Core.MediaFiles var decisions = _importDecisionMaker.GetImportDecisions(mediaFileList, movie, true); decisionsStopwatch.Stop(); _logger.Trace("Import decisions complete for: {0} [{1}]", movie, decisionsStopwatch.Elapsed); - - //_importApprovedEpisodes.Import(decisions, false); + _importApprovedMovies.Import(decisions, false); _logger.Info("Completed scanning disk for {0}", movie.Title); @@ -230,13 +165,6 @@ namespace NzbDrone.Core.MediaFiles return mediaFileList.ToArray(); } - public List FilterFiles(Series series, IEnumerable files) - { - return files.Where(file => !ExcludedSubFoldersRegex.IsMatch(series.Path.GetRelativePath(file))) - .Where(file => !ExcludedFilesRegex.IsMatch(Path.GetFileName(file))) - .ToList(); - } - public List FilterFiles(Movie movie, IEnumerable files) { return files.Where(file => !ExcludedSubFoldersRegex.IsMatch(movie.Path.GetRelativePath(file))) @@ -265,11 +193,6 @@ namespace NzbDrone.Core.MediaFiles } } - public void Handle(SeriesUpdatedEvent message) - { - Scan(message.Series); - } - public void Handle(MovieUpdatedEvent message) { Scan(message.Movie); @@ -292,24 +215,5 @@ namespace NzbDrone.Core.MediaFiles } } } - - public void Execute(RescanSeriesCommand message) - { - if (message.SeriesId.HasValue) - { - var series = _seriesService.GetSeries(message.SeriesId.Value); - Scan(series); - } - - else - { - var allSeries = _seriesService.GetAllSeries(); - - foreach (var series in allSeries) - { - Scan(series); - } - } - } } } diff --git a/src/NzbDrone.Core/MediaFiles/DownloadedEpisodesCommandService.cs b/src/NzbDrone.Core/MediaFiles/DownloadedEpisodesCommandService.cs deleted file mode 100644 index 2f5e19a41..000000000 --- a/src/NzbDrone.Core/MediaFiles/DownloadedEpisodesCommandService.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Linq; -using NLog; -using NzbDrone.Common.Disk; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Configuration; -using NzbDrone.Core.Download.TrackedDownloads; -using NzbDrone.Core.MediaFiles.Commands; -using NzbDrone.Core.MediaFiles.EpisodeImport; -using NzbDrone.Core.Messaging.Commands; - -namespace NzbDrone.Core.MediaFiles -{ - public class DownloadedEpisodesCommandService : IExecute - { - private readonly IDownloadedEpisodesImportService _downloadedEpisodesImportService; - private readonly ITrackedDownloadService _trackedDownloadService; - private readonly IDiskProvider _diskProvider; - private readonly IConfigService _configService; - private readonly Logger _logger; - - public DownloadedEpisodesCommandService(IDownloadedEpisodesImportService downloadedEpisodesImportService, - ITrackedDownloadService trackedDownloadService, - IDiskProvider diskProvider, - IConfigService configService, - Logger logger) - { - _downloadedEpisodesImportService = downloadedEpisodesImportService; - _trackedDownloadService = trackedDownloadService; - _diskProvider = diskProvider; - _configService = configService; - _logger = logger; - } - - private List ProcessDroneFactoryFolder() - { - var downloadedEpisodesFolder = _configService.DownloadedEpisodesFolder; - - if (string.IsNullOrEmpty(downloadedEpisodesFolder)) - { - _logger.Trace("Drone Factory folder is not configured"); - return new List(); - } - - if (!_diskProvider.FolderExists(downloadedEpisodesFolder)) - { - _logger.Warn("Drone Factory folder [{0}] doesn't exist.", downloadedEpisodesFolder); - return new List(); - } - - return _downloadedEpisodesImportService.ProcessRootFolder(new DirectoryInfo(downloadedEpisodesFolder)); - } - - private List ProcessPath(DownloadedEpisodesScanCommand message) - { - if (!_diskProvider.FolderExists(message.Path) && !_diskProvider.FileExists(message.Path)) - { - _logger.Warn("Folder/File specified for import scan [{0}] doesn't exist.", message.Path); - return new List(); - } - - if (message.DownloadClientId.IsNotNullOrWhiteSpace()) - { - var trackedDownload = _trackedDownloadService.Find(message.DownloadClientId); - - if (trackedDownload != null) - { - _logger.Debug("External directory scan request for known download {0}. [{1}]", message.DownloadClientId, message.Path); - - return _downloadedEpisodesImportService.ProcessPath(message.Path, message.ImportMode, trackedDownload.RemoteEpisode.Series, trackedDownload.DownloadItem); - } - else - { - _logger.Warn("External directory scan request for unknown download {0}, attempting normal import. [{1}]", message.DownloadClientId, message.Path); - - return _downloadedEpisodesImportService.ProcessPath(message.Path, message.ImportMode); - } - } - - return _downloadedEpisodesImportService.ProcessPath(message.Path, message.ImportMode); - } - - public void Execute(DownloadedEpisodesScanCommand message) - { - List importResults; - - if (message.Path.IsNotNullOrWhiteSpace()) - { - importResults = ProcessPath(message); - } - else - { - importResults = ProcessDroneFactoryFolder(); - } - - if (importResults == null || importResults.All(v => v.Result != ImportResultType.Imported)) - { - // Atm we don't report it as a command failure, coz that would cause the download to be failed. - // Changing the message won't do a thing either, coz it will get set to 'Completed' a msec later. - //message.SetMessage("Failed to import"); - } - } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs b/src/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs deleted file mode 100644 index c2ea60748..000000000 --- a/src/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs +++ /dev/null @@ -1,265 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Linq; -using NLog; -using NzbDrone.Common.Disk; -using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.MediaFiles.EpisodeImport; -using NzbDrone.Core.Parser; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Download; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.MediaFiles -{ - public interface IDownloadedEpisodesImportService - { - List ProcessRootFolder(DirectoryInfo directoryInfo); - List ProcessPath(string path, ImportMode importMode = ImportMode.Auto, Series series = null, DownloadClientItem downloadClientItem = null); - bool ShouldDeleteFolder(DirectoryInfo directoryInfo, Series series); - } - - public class DownloadedEpisodesImportService : IDownloadedEpisodesImportService - { - private readonly IDiskProvider _diskProvider; - private readonly IDiskScanService _diskScanService; - private readonly ISeriesService _seriesService; - private readonly IParsingService _parsingService; - private readonly IMakeImportDecision _importDecisionMaker; - private readonly IImportApprovedEpisodes _importApprovedEpisodes; - private readonly IDetectSample _detectSample; - private readonly Logger _logger; - - public DownloadedEpisodesImportService(IDiskProvider diskProvider, - IDiskScanService diskScanService, - ISeriesService seriesService, - IParsingService parsingService, - IMakeImportDecision importDecisionMaker, - IImportApprovedEpisodes importApprovedEpisodes, - IDetectSample detectSample, - Logger logger) - { - _diskProvider = diskProvider; - _diskScanService = diskScanService; - _seriesService = seriesService; - _parsingService = parsingService; - _importDecisionMaker = importDecisionMaker; - _importApprovedEpisodes = importApprovedEpisodes; - _detectSample = detectSample; - _logger = logger; - } - - public List ProcessRootFolder(DirectoryInfo directoryInfo) - { - var results = new List(); - - foreach (var subFolder in _diskProvider.GetDirectories(directoryInfo.FullName)) - { - var folderResults = ProcessFolder(new DirectoryInfo(subFolder), ImportMode.Auto, null); - results.AddRange(folderResults); - } - - foreach (var videoFile in _diskScanService.GetVideoFiles(directoryInfo.FullName, false)) - { - var fileResults = ProcessFile(new FileInfo(videoFile), ImportMode.Auto, null); - results.AddRange(fileResults); - } - - return results; - } - - public List ProcessPath(string path, ImportMode importMode = ImportMode.Auto, Series series = null, DownloadClientItem downloadClientItem = null) - { - if (_diskProvider.FolderExists(path)) - { - var directoryInfo = new DirectoryInfo(path); - - if (series == null) - { - return ProcessFolder(directoryInfo, importMode, downloadClientItem); - } - - return ProcessFolder(directoryInfo, importMode, series, downloadClientItem); - } - - if (_diskProvider.FileExists(path)) - { - var fileInfo = new FileInfo(path); - - if (series == null) - { - return ProcessFile(fileInfo, importMode, downloadClientItem); - } - - return ProcessFile(fileInfo, importMode, series, downloadClientItem); - } - - _logger.Error("Import failed, path does not exist or is not accessible by Radarr: {0}", path); - return new List(); - } - - public bool ShouldDeleteFolder(DirectoryInfo directoryInfo, Series series) - { - var videoFiles = _diskScanService.GetVideoFiles(directoryInfo.FullName); - var rarFiles = _diskProvider.GetFiles(directoryInfo.FullName, SearchOption.AllDirectories).Where(f => Path.GetExtension(f) == ".rar"); - - foreach (var videoFile in videoFiles) - { - var episodeParseResult = Parser.Parser.ParseTitle(Path.GetFileName(videoFile)); - - if (episodeParseResult == null) - { - _logger.Warn("Unable to parse file on import: [{0}]", videoFile); - return false; - } - - var size = _diskProvider.GetFileSize(videoFile); - var quality = QualityParser.ParseQuality(videoFile); - - if (!_detectSample.IsSample(series, quality, videoFile, size, episodeParseResult.IsPossibleSpecialEpisode)) - { - _logger.Warn("Non-sample file detected: [{0}]", videoFile); - return false; - } - } - - if (rarFiles.Any(f => _diskProvider.GetFileSize(f) > 10.Megabytes())) - { - _logger.Warn("RAR file detected, will require manual cleanup"); - return false; - } - - return true; - } - - private List ProcessFolder(DirectoryInfo directoryInfo, ImportMode importMode, DownloadClientItem downloadClientItem) - { - var cleanedUpName = GetCleanedUpFolderName(directoryInfo.Name); - var series = _parsingService.GetSeries(cleanedUpName); - - if (series == null) - { - _logger.Debug("Unknown Series {0}", cleanedUpName); - - return new List - { - UnknownSeriesResult("Unknown Series") - }; - } - - return ProcessFolder(directoryInfo, importMode, series, downloadClientItem); - } - - private List ProcessFolder(DirectoryInfo directoryInfo, ImportMode importMode, Series series, DownloadClientItem downloadClientItem) - { - if (_seriesService.SeriesPathExists(directoryInfo.FullName)) - { - _logger.Warn("Unable to process folder that is mapped to an existing show"); - return new List(); - } - - var cleanedUpName = GetCleanedUpFolderName(directoryInfo.Name); - var folderInfo = Parser.Parser.ParseTitle(directoryInfo.Name); - - if (folderInfo != null) - { - _logger.Debug("{0} folder quality: {1}", cleanedUpName, folderInfo.Quality); - } - - var videoFiles = _diskScanService.GetVideoFiles(directoryInfo.FullName); - - if (downloadClientItem == null) - { - foreach (var videoFile in videoFiles) - { - if (_diskProvider.IsFileLocked(videoFile)) - { - return new List - { - FileIsLockedResult(videoFile) - }; - } - } - } - - var decisions = _importDecisionMaker.GetImportDecisions(videoFiles.ToList(), series, folderInfo, true); - var importResults = _importApprovedEpisodes.Import(decisions, true, downloadClientItem, importMode); - - if ((downloadClientItem == null || !downloadClientItem.IsReadOnly) && - importResults.Any(i => i.Result == ImportResultType.Imported) && - ShouldDeleteFolder(directoryInfo, series)) - { - _logger.Debug("Deleting folder after importing valid files"); - _diskProvider.DeleteFolder(directoryInfo.FullName, true); - } - - return importResults; - } - - private List ProcessFile(FileInfo fileInfo, ImportMode importMode, DownloadClientItem downloadClientItem) - { - var series = _parsingService.GetSeries(Path.GetFileNameWithoutExtension(fileInfo.Name)); - - if (series == null) - { - _logger.Debug("Unknown Series for file: {0}", fileInfo.Name); - - return new List - { - UnknownSeriesResult(string.Format("Unknown Series for file: {0}", fileInfo.Name), fileInfo.FullName) - }; - } - - return ProcessFile(fileInfo, importMode, series, downloadClientItem); - } - - private List ProcessFile(FileInfo fileInfo, ImportMode importMode, Series series, DownloadClientItem downloadClientItem) - { - if (Path.GetFileNameWithoutExtension(fileInfo.Name).StartsWith("._")) - { - _logger.Debug("[{0}] starts with '._', skipping", fileInfo.FullName); - - return new List - { - new ImportResult(new ImportDecision(new LocalEpisode { Path = fileInfo.FullName }, new Rejection("Invalid video file, filename starts with '._'")), "Invalid video file, filename starts with '._'") - }; - } - - if (downloadClientItem == null) - { - if (_diskProvider.IsFileLocked(fileInfo.FullName)) - { - return new List - { - FileIsLockedResult(fileInfo.FullName) - }; - } - } - - var decisions = _importDecisionMaker.GetImportDecisions(new List() { fileInfo.FullName }, series, null, true); - - return _importApprovedEpisodes.Import(decisions, true, downloadClientItem, importMode); - } - - private string GetCleanedUpFolderName(string folder) - { - folder = folder.Replace("_UNPACK_", "") - .Replace("_FAILED_", ""); - - return folder; - } - - private ImportResult FileIsLockedResult(string videoFile) - { - _logger.Debug("[{0}] is currently locked by another process, skipping", videoFile); - return new ImportResult(new ImportDecision(new LocalEpisode { Path = videoFile }, new Rejection("Locked file, try again later")), "Locked file, try again later"); - } - - private ImportResult UnknownSeriesResult(string message, string videoFile = null) - { - var localEpisode = videoFile == null ? null : new LocalEpisode { Path = videoFile }; - - return new ImportResult(new ImportDecision(localEpisode, new Rejection("Unknown Series")), message); - } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/DownloadedMovieCommandService.cs b/src/NzbDrone.Core/MediaFiles/DownloadedMovieCommandService.cs index 383c5e0eb..0f916c6b7 100644 --- a/src/NzbDrone.Core/MediaFiles/DownloadedMovieCommandService.cs +++ b/src/NzbDrone.Core/MediaFiles/DownloadedMovieCommandService.cs @@ -4,7 +4,7 @@ using NzbDrone.Common.Extensions; using NzbDrone.Core.Configuration; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.MediaFiles.Commands; -using NzbDrone.Core.MediaFiles.EpisodeImport; +using NzbDrone.Core.MediaFiles.MovieImport; using NzbDrone.Core.Messaging.Commands; using System; using System.Collections.Generic; diff --git a/src/NzbDrone.Core/MediaFiles/DownloadedMovieImportService.cs b/src/NzbDrone.Core/MediaFiles/DownloadedMovieImportService.cs index 35f3451e1..4b39ca459 100644 --- a/src/NzbDrone.Core/MediaFiles/DownloadedMovieImportService.cs +++ b/src/NzbDrone.Core/MediaFiles/DownloadedMovieImportService.cs @@ -6,9 +6,9 @@ using NLog; using NzbDrone.Common.Disk; using NzbDrone.Core.Configuration; using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.MediaFiles.EpisodeImport; +using NzbDrone.Core.MediaFiles.MovieImport; using NzbDrone.Core.Parser; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Download; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.MediaFiles.Commands; @@ -111,7 +111,7 @@ namespace NzbDrone.Core.MediaFiles foreach (var videoFile in videoFiles) { - var episodeParseResult = Parser.Parser.ParseTitle(Path.GetFileName(videoFile)); + var episodeParseResult = Parser.Parser.ParseMovieTitle(Path.GetFileName(videoFile), false); if (episodeParseResult == null) { @@ -122,7 +122,7 @@ namespace NzbDrone.Core.MediaFiles var size = _diskProvider.GetFileSize(videoFile); var quality = QualityParser.ParseQuality(videoFile); - if (!_detectSample.IsSample(movie, quality, videoFile, size, episodeParseResult.IsPossibleSpecialEpisode)) + if (!_detectSample.IsSample(movie, quality, videoFile, size, false)) { _logger.Warn("Non-sample file detected: [{0}]", videoFile); return false; @@ -227,7 +227,7 @@ namespace NzbDrone.Core.MediaFiles return new List { - new ImportResult(new ImportDecision(new LocalEpisode { Path = fileInfo.FullName }, new Rejection("Invalid video file, filename starts with '._'")), "Invalid video file, filename starts with '._'") + new ImportResult(new ImportDecision(new LocalMovie { Path = fileInfo.FullName }, new Rejection("Invalid video file, filename starts with '._'")), "Invalid video file, filename starts with '._'") }; } @@ -258,14 +258,14 @@ namespace NzbDrone.Core.MediaFiles private ImportResult FileIsLockedResult(string videoFile) { _logger.Debug("[{0}] is currently locked by another process, skipping", videoFile); - return new ImportResult(new ImportDecision(new LocalEpisode { Path = videoFile }, new Rejection("Locked file, try again later")), "Locked file, try again later"); + return new ImportResult(new ImportDecision(new LocalMovie { Path = videoFile }, new Rejection("Locked file, try again later")), "Locked file, try again later"); } private ImportResult UnknownMovieResult(string message, string videoFile = null) { - var localEpisode = videoFile == null ? null : new LocalMovie { Path = videoFile }; + var localMovie = videoFile == null ? null : new LocalMovie { Path = videoFile }; - return new ImportResult(new ImportDecision(localEpisode, new Rejection("Unknown Movie")), message); + return new ImportResult(new ImportDecision(localMovie, new Rejection("Unknown Movie")), message); } } } diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeFile.cs b/src/NzbDrone.Core/MediaFiles/EpisodeFile.cs deleted file mode 100644 index ecce449b4..000000000 --- a/src/NzbDrone.Core/MediaFiles/EpisodeFile.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using Marr.Data; -using NzbDrone.Core.Datastore; -using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; -using NzbDrone.Core.MediaFiles.MediaInfo; - -namespace NzbDrone.Core.MediaFiles -{ - public class EpisodeFile : ModelBase - { - public int SeriesId { get; set; } - public int SeasonNumber { get; set; } - public string RelativePath { get; set; } - public string Path { get; set; } - public long Size { get; set; } - public DateTime DateAdded { get; set; } - public string SceneName { get; set; } - public string ReleaseGroup { get; set; } - public QualityModel Quality { get; set; } - public MediaInfoModel MediaInfo { get; set; } - public LazyLoaded> Episodes { get; set; } - public LazyLoaded Series { get; set; } - - public override string ToString() - { - return string.Format("[{0}] {1}", Id, RelativePath); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeFileMoveResult.cs b/src/NzbDrone.Core/MediaFiles/EpisodeFileMoveResult.cs deleted file mode 100644 index e88a10d29..000000000 --- a/src/NzbDrone.Core/MediaFiles/EpisodeFileMoveResult.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; - -namespace NzbDrone.Core.MediaFiles -{ - public class EpisodeFileMoveResult - { - public EpisodeFileMoveResult() - { - OldFiles = new List(); - } - - public EpisodeFile EpisodeFile { get; set; } - public List OldFiles { get; set; } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs b/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs deleted file mode 100644 index 774ac202c..000000000 --- a/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs +++ /dev/null @@ -1,215 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -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.Messaging.Events; -using NzbDrone.Core.Organizer; -using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.MediaFiles -{ - public interface IMoveEpisodeFiles - { - EpisodeFile MoveEpisodeFile(EpisodeFile episodeFile, Series series); - EpisodeFile MoveEpisodeFile(EpisodeFile episodeFile, LocalEpisode localEpisode); - EpisodeFile CopyEpisodeFile(EpisodeFile episodeFile, LocalEpisode localEpisode); - } - - public class EpisodeFileMovingService : IMoveEpisodeFiles - { - private readonly IEpisodeService _episodeService; - private readonly IUpdateEpisodeFileService _updateEpisodeFileService; - private readonly IBuildFileNames _buildFileNames; - private readonly IDiskTransferService _diskTransferService; - private readonly IDiskProvider _diskProvider; - private readonly IMediaFileAttributeService _mediaFileAttributeService; - private readonly IEventAggregator _eventAggregator; - private readonly IConfigService _configService; - private readonly Logger _logger; - - public EpisodeFileMovingService(IEpisodeService episodeService, - IUpdateEpisodeFileService updateEpisodeFileService, - IBuildFileNames buildFileNames, - IDiskTransferService diskTransferService, - IDiskProvider diskProvider, - IMediaFileAttributeService mediaFileAttributeService, - IEventAggregator eventAggregator, - IConfigService configService, - Logger logger) - { - _episodeService = episodeService; - _updateEpisodeFileService = updateEpisodeFileService; - _buildFileNames = buildFileNames; - _diskTransferService = diskTransferService; - _diskProvider = diskProvider; - _mediaFileAttributeService = mediaFileAttributeService; - _eventAggregator = eventAggregator; - _configService = configService; - _logger = logger; - } - - public EpisodeFile MoveEpisodeFile(EpisodeFile episodeFile, Series series) - { - var episodes = _episodeService.GetEpisodesByFileId(episodeFile.Id); - var newFileName = _buildFileNames.BuildFileName(episodes, series, episodeFile); - var filePath = _buildFileNames.BuildFilePath(series, episodes.First().SeasonNumber, newFileName, Path.GetExtension(episodeFile.RelativePath)); - - EnsureEpisodeFolder(episodeFile, series, episodes.Select(v => v.SeasonNumber).First(), filePath); - - _logger.Debug("Renaming episode file: {0} to {1}", episodeFile, filePath); - - return TransferFile(episodeFile, series, episodes, filePath, TransferMode.Move); - } - - public EpisodeFile MoveEpisodeFile(EpisodeFile episodeFile, LocalEpisode localEpisode) - { - var newFileName = _buildFileNames.BuildFileName(localEpisode.Episodes, localEpisode.Series, episodeFile); - var filePath = _buildFileNames.BuildFilePath(localEpisode.Series, localEpisode.SeasonNumber, newFileName, Path.GetExtension(localEpisode.Path)); - - EnsureEpisodeFolder(episodeFile, localEpisode, filePath); - - _logger.Debug("Moving episode file: {0} to {1}", episodeFile.Path, filePath); - - return TransferFile(episodeFile, localEpisode.Series, localEpisode.Episodes, filePath, TransferMode.Move); - } - - public EpisodeFile CopyEpisodeFile(EpisodeFile episodeFile, LocalEpisode localEpisode) - { - var newFileName = _buildFileNames.BuildFileName(localEpisode.Episodes, localEpisode.Series, episodeFile); - var filePath = _buildFileNames.BuildFilePath(localEpisode.Series, localEpisode.SeasonNumber, newFileName, Path.GetExtension(localEpisode.Path)); - - EnsureEpisodeFolder(episodeFile, localEpisode, filePath); - - if (_configService.CopyUsingHardlinks) - { - _logger.Debug("Hardlinking episode file: {0} to {1}", episodeFile.Path, filePath); - return TransferFile(episodeFile, localEpisode.Series, localEpisode.Episodes, filePath, TransferMode.HardLinkOrCopy); - } - - _logger.Debug("Copying episode file: {0} to {1}", episodeFile.Path, filePath); - return TransferFile(episodeFile, localEpisode.Series, localEpisode.Episodes, filePath, TransferMode.Copy); - } - - private EpisodeFile TransferFile(EpisodeFile episodeFile, Series series, List episodes, string destinationFilePath, TransferMode mode) - { - Ensure.That(episodeFile, () => episodeFile).IsNotNull(); - Ensure.That(series,() => series).IsNotNull(); - Ensure.That(destinationFilePath, () => destinationFilePath).IsValidPath(); - - var episodeFilePath = episodeFile.Path ?? Path.Combine(series.Path, episodeFile.RelativePath); - - if (!_diskProvider.FileExists(episodeFilePath)) - { - throw new FileNotFoundException("Episode file path does not exist", episodeFilePath); - } - - if (episodeFilePath == destinationFilePath) - { - throw new SameFilenameException("File not moved, source and destination are the same", episodeFilePath); - } - - _diskTransferService.TransferFile(episodeFilePath, destinationFilePath, mode); - - episodeFile.RelativePath = series.Path.GetRelativePath(destinationFilePath); - - _updateEpisodeFileService.ChangeFileDateForFile(episodeFile, series, episodes); - - try - { - _mediaFileAttributeService.SetFolderLastWriteTime(series.Path, episodeFile.DateAdded); - - if (series.SeasonFolder) - { - var seasonFolder = Path.GetDirectoryName(destinationFilePath); - - _mediaFileAttributeService.SetFolderLastWriteTime(seasonFolder, episodeFile.DateAdded); - } - } - - catch (Exception ex) - { - _logger.Warn(ex, "Unable to set last write time"); - } - - _mediaFileAttributeService.SetFilePermissions(destinationFilePath); - - return episodeFile; - } - - private void EnsureEpisodeFolder(EpisodeFile episodeFile, LocalEpisode localEpisode, string filePath) - { - EnsureEpisodeFolder(episodeFile, localEpisode.Series, localEpisode.SeasonNumber, filePath); - } - - private void EnsureEpisodeFolder(EpisodeFile episodeFile, Series series, int seasonNumber, string filePath) - { - var episodeFolder = Path.GetDirectoryName(filePath); - var seasonFolder = _buildFileNames.BuildSeasonPath(series, seasonNumber); - var seriesFolder = series.Path; - var rootFolder = new OsPath(seriesFolder).Directory.FullPath; - - if (!_diskProvider.FolderExists(rootFolder)) - { - throw new DirectoryNotFoundException(string.Format("Root folder '{0}' was not found.", rootFolder)); - } - - var changed = false; - var newEvent = new EpisodeFolderCreatedEvent(series, episodeFile); - - if (!_diskProvider.FolderExists(seriesFolder)) - { - CreateFolder(seriesFolder); - newEvent.SeriesFolder = seriesFolder; - changed = true; - } - - if (seriesFolder != seasonFolder && !_diskProvider.FolderExists(seasonFolder)) - { - CreateFolder(seasonFolder); - newEvent.SeasonFolder = seasonFolder; - changed = true; - } - - if (seasonFolder != episodeFolder && !_diskProvider.FolderExists(episodeFolder)) - { - CreateFolder(episodeFolder); - newEvent.EpisodeFolder = episodeFolder; - 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: " + directoryName); - } - - _mediaFileAttributeService.SetFolderPermissions(directoryName); - } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs deleted file mode 100644 index 6c9a435f6..000000000 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs +++ /dev/null @@ -1,175 +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.Core.MediaFiles.Events; -using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Parser; -using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Qualities; -using NzbDrone.Core.Download; -using NzbDrone.Core.Extras; - - -namespace NzbDrone.Core.MediaFiles.EpisodeImport -{ - public interface IImportApprovedEpisodes - { - List Import(List decisions, bool newDownload, DownloadClientItem downloadClientItem = null, ImportMode importMode = ImportMode.Auto); - } - - public class ImportApprovedEpisodes : IImportApprovedEpisodes - { - private readonly IUpgradeMediaFiles _episodeFileUpgrader; - private readonly IMediaFileService _mediaFileService; - private readonly IExtraService _extraService; - private readonly IDiskProvider _diskProvider; - private readonly IEventAggregator _eventAggregator; - private readonly Logger _logger; - - public ImportApprovedEpisodes(IUpgradeMediaFiles episodeFileUpgrader, - IMediaFileService mediaFileService, - IExtraService extraService, - IDiskProvider diskProvider, - IEventAggregator eventAggregator, - Logger logger) - { - _episodeFileUpgrader = episodeFileUpgrader; - _mediaFileService = mediaFileService; - _extraService = extraService; - _diskProvider = diskProvider; - _eventAggregator = eventAggregator; - _logger = logger; - } - - public List Import(List decisions, bool newDownload, DownloadClientItem downloadClientItem = null, ImportMode importMode = ImportMode.Auto) - { - var qualifiedImports = decisions.Where(c => c.Approved) - .GroupBy(c => c.LocalEpisode.Series.Id, (i, s) => s - .OrderByDescending(c => c.LocalEpisode.Quality, new QualityModelComparer(s.First().LocalEpisode.Series.Profile)) - .ThenByDescending(c => c.LocalEpisode.Size)) - .SelectMany(c => c) - .ToList(); - - var importResults = new List(); - - foreach (var importDecision in qualifiedImports.OrderBy(e => e.LocalEpisode.Episodes.Select(episode => episode.EpisodeNumber).MinOrDefault()) - .ThenByDescending(e => e.LocalEpisode.Size)) - { - var localEpisode = importDecision.LocalEpisode; - var oldFiles = new List(); - - try - { - //check if already imported - if (importResults.SelectMany(r => r.ImportDecision.LocalEpisode.Episodes) - .Select(e => e.Id) - .Intersect(localEpisode.Episodes.Select(e => e.Id)) - .Any()) - { - importResults.Add(new ImportResult(importDecision, "Episode has already been imported")); - continue; - } - - var episodeFile = new EpisodeFile(); - episodeFile.DateAdded = DateTime.UtcNow; - episodeFile.SeriesId = localEpisode.Series.Id; - episodeFile.Path = localEpisode.Path.CleanFilePath(); - episodeFile.Size = _diskProvider.GetFileSize(localEpisode.Path); - episodeFile.Quality = localEpisode.Quality; - episodeFile.MediaInfo = localEpisode.MediaInfo; - episodeFile.SeasonNumber = localEpisode.SeasonNumber; - episodeFile.Episodes = localEpisode.Episodes; - episodeFile.ReleaseGroup = localEpisode.ParsedEpisodeInfo.ReleaseGroup; - - bool copyOnly; - switch (importMode) - { - default: - case ImportMode.Auto: - copyOnly = downloadClientItem != null && downloadClientItem.IsReadOnly; - break; - case ImportMode.Move: - copyOnly = false; - break; - case ImportMode.Copy: - copyOnly = true; - break; - } - - if (newDownload) - { - episodeFile.SceneName = GetSceneName(downloadClientItem, localEpisode); - - var moveResult = _episodeFileUpgrader.UpgradeEpisodeFile(episodeFile, localEpisode, copyOnly); - oldFiles = moveResult.OldFiles; - } - else - { - episodeFile.RelativePath = localEpisode.Series.Path.GetRelativePath(episodeFile.Path); - } - - _mediaFileService.Add(episodeFile); - importResults.Add(new ImportResult(importDecision)); - - if (newDownload) - { - // _extraService.ImportExtraFiles(localEpisode, episodeFile, copyOnly); - } - - if (downloadClientItem != null) - { - _eventAggregator.PublishEvent(new EpisodeImportedEvent(localEpisode, episodeFile, newDownload, downloadClientItem.DownloadClient, downloadClientItem.DownloadId, downloadClientItem.IsReadOnly)); - } - else - { - _eventAggregator.PublishEvent(new EpisodeImportedEvent(localEpisode, episodeFile, newDownload)); - } - - if (newDownload) - { - _eventAggregator.PublishEvent(new EpisodeDownloadedEvent(localEpisode, episodeFile, oldFiles)); - } - } - catch (Exception e) - { - _logger.Warn(e, "Couldn't import episode " + localEpisode); - importResults.Add(new ImportResult(importDecision, "Failed to import episode")); - } - } - - //Adding all the rejected decisions - importResults.AddRange(decisions.Where(c => !c.Approved) - .Select(d => new ImportResult(d, d.Rejections.Select(r => r.Reason).ToArray()))); - - return importResults; - } - - private string GetSceneName(DownloadClientItem downloadClientItem, LocalEpisode localEpisode) - { - if (downloadClientItem != null) - { - var title = Parser.Parser.RemoveFileExtension(downloadClientItem.Title); - - var parsedTitle = Parser.Parser.ParseTitle(title); - - if (parsedTitle != null && !parsedTitle.FullSeason) - { - return title; - } - } - - var fileName = Path.GetFileNameWithoutExtension(localEpisode.Path.CleanFilePath()); - - if (SceneChecker.IsSceneTitle(fileName)) - { - return fileName; - } - - return null; - } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FullSeasonSpecification.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FullSeasonSpecification.cs deleted file mode 100644 index 9b0bb2094..000000000 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FullSeasonSpecification.cs +++ /dev/null @@ -1,33 +0,0 @@ -using NLog; -using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Download; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications -{ - public class FullSeasonSpecification : IImportDecisionEngineSpecification - { - private readonly Logger _logger; - - public FullSeasonSpecification(Logger logger) - { - _logger = logger; - } - - public Decision IsSatisfiedBy(LocalEpisode localEpisode) - { - if (localEpisode.ParsedEpisodeInfo.FullSeason) - { - _logger.Debug("Single episode file detected as containing all episodes in the season"); //Not needed for Movies mwhahahahah - return Decision.Reject("Single episode file contains all episodes in seasons"); - } - - return Decision.Accept(); - } - - public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem) - { - return Decision.Accept(); - } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecification.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecification.cs deleted file mode 100644 index da7f57607..000000000 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecification.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using NLog; -using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Download; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications -{ - public class MatchesFolderSpecification : IImportDecisionEngineSpecification - { - private readonly Logger _logger; - - public MatchesFolderSpecification(Logger logger) - { - _logger = logger; - } - - public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem) - { - if (localMovie.ExistingFile) - { - return Decision.Accept(); - } - - var dirInfo = new FileInfo(localMovie.Path).Directory; - - if (dirInfo == null) - { - return Decision.Accept(); - } - - var folderInfo = Parser.Parser.ParseTitle(dirInfo.Name); - - if (folderInfo == null) - { - return Decision.Accept(); - } - - if (folderInfo.FullSeason) - { - return Decision.Accept(); - } - - return Decision.Accept(); - } - - - public Decision IsSatisfiedBy(LocalEpisode localEpisode) - { - if (localEpisode.ExistingFile) - { - return Decision.Accept(); - } - - var dirInfo = new FileInfo(localEpisode.Path).Directory; - - if (dirInfo == null) - { - return Decision.Accept(); - } - - var folderInfo = Parser.Parser.ParseTitle(dirInfo.Name); - - if (folderInfo == null) - { - return Decision.Accept(); - } - - if (!folderInfo.EpisodeNumbers.Any()) - { - return Decision.Accept(); - } - - if (folderInfo.FullSeason) - { - return Decision.Accept(); - } - - var unexpected = localEpisode.ParsedEpisodeInfo.EpisodeNumbers.Where(f => !folderInfo.EpisodeNumbers.Contains(f)).ToList(); - - if (unexpected.Any()) - { - _logger.Debug("Unexpected episode number(s) in file: {0}", string.Join(", ", unexpected)); - - if (unexpected.Count == 1) - { - return Decision.Reject("Episode Number {0} was unexpected considering the {1} folder name", unexpected.First(), dirInfo.Name); - } - - return Decision.Reject("Episode Numbers {0} were unexpected considering the {1} folder name", string.Join(", ", unexpected), dirInfo.Name); - } - - return Decision.Accept(); - } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotUnpackingSpecification.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotUnpackingSpecification.cs deleted file mode 100644 index 152195a1b..000000000 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotUnpackingSpecification.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System; -using System.IO; -using NLog; -using NzbDrone.Common.Disk; -using NzbDrone.Common.EnvironmentInfo; -using NzbDrone.Core.Configuration; -using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Download; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications -{ - public class NotUnpackingSpecification : IImportDecisionEngineSpecification - { - private readonly IDiskProvider _diskProvider; - private readonly IConfigService _configService; - private readonly Logger _logger; - - public NotUnpackingSpecification(IDiskProvider diskProvider, IConfigService configService, Logger logger) - { - _diskProvider = diskProvider; - _configService = configService; - _logger = logger; - } - - public Decision IsSatisfiedBy(LocalEpisode localEpisode) - { - if (localEpisode.ExistingFile) - { - _logger.Debug("{0} is in series folder, skipping unpacking check", localEpisode.Path); - return Decision.Accept(); - } - - foreach (var workingFolder in _configService.DownloadClientWorkingFolders.Split('|')) - { - DirectoryInfo parent = Directory.GetParent(localEpisode.Path); - while (parent != null) - { - if (parent.Name.StartsWith(workingFolder)) - { - if (OsInfo.IsNotWindows) - { - _logger.Debug("{0} is still being unpacked", localEpisode.Path); - return Decision.Reject("File is still being unpacked"); - } - - if (_diskProvider.FileGetLastWrite(localEpisode.Path) > DateTime.UtcNow.AddMinutes(-5)) - { - _logger.Debug("{0} appears to be unpacking still", localEpisode.Path); - return Decision.Reject("File is still being unpacked"); - } - } - - parent = parent.Parent; - } - } - - return Decision.Accept(); - } - - public Decision IsSatisfiedBy(LocalMovie localEpisode, DownloadClientItem downloadClientItem) - { - if (localEpisode.ExistingFile) - { - _logger.Debug("{0} is in series folder, skipping unpacking check", localEpisode.Path); - return Decision.Accept(); - } - - foreach (var workingFolder in _configService.DownloadClientWorkingFolders.Split('|')) - { - DirectoryInfo parent = Directory.GetParent(localEpisode.Path); - while (parent != null) - { - if (parent.Name.StartsWith(workingFolder)) - { - if (OsInfo.IsNotWindows) - { - _logger.Debug("{0} is still being unpacked", localEpisode.Path); - return Decision.Reject("File is still being unpacked"); - } - - if (_diskProvider.FileGetLastWrite(localEpisode.Path) > DateTime.UtcNow.AddMinutes(-5)) - { - _logger.Debug("{0} appears to be unpacking still", localEpisode.Path); - return Decision.Reject("File is still being unpacked"); - } - } - - parent = parent.Parent; - } - } - - return Decision.Accept(); - } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/SameEpisodesImportSpecification.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/SameEpisodesImportSpecification.cs deleted file mode 100644 index 306f9f43b..000000000 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/SameEpisodesImportSpecification.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using NLog; -using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Download; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications -{ - public class SameEpisodesImportSpecification : IImportDecisionEngineSpecification - { - private readonly SameEpisodesSpecification _sameEpisodesSpecification; - private readonly Logger _logger; - - public SameEpisodesImportSpecification(SameEpisodesSpecification sameEpisodesSpecification, Logger logger) - { - _sameEpisodesSpecification = sameEpisodesSpecification; - _logger = logger; - } - - public RejectionType Type => RejectionType.Permanent; - - public Decision IsSatisfiedBy(LocalEpisode localEpisode) - { - if (_sameEpisodesSpecification.IsSatisfiedBy(localEpisode.Episodes)) - { - return Decision.Accept(); - } - - _logger.Debug("Episode file on disk contains more episodes than this file contains"); - return Decision.Reject("Episode file on disk contains more episodes than this file contains"); - } - - public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem) - { - return Decision.Accept(); - } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/UnverifiedSceneNumberingSpecification.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/UnverifiedSceneNumberingSpecification.cs deleted file mode 100644 index 1c025432b..000000000 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/UnverifiedSceneNumberingSpecification.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Linq; -using NLog; -using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Download; -using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications -{ - public class UnverifiedSceneNumberingSpecification : IImportDecisionEngineSpecification - { - private readonly Logger _logger; - - public UnverifiedSceneNumberingSpecification(Logger logger) - { - _logger = logger; - } - - public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem) - { - return Decision.Accept(); - } - - public Decision IsSatisfiedBy(LocalEpisode localEpisode) - { - if (localEpisode.ExistingFile) - { - _logger.Debug("Skipping scene numbering check for existing episode"); - return Decision.Accept(); - } - - if (localEpisode.Episodes.Any(v => v.UnverifiedSceneNumbering)) - { - _logger.Debug("This file uses unverified scene numbers, will not auto-import until numbering is confirmed on TheXEM. Skipping {0}", localEpisode.Path); - return Decision.Reject("This show has individual episode mappings on TheXEM but the mapping for this episode has not been confirmed yet by their administrators. TheXEM needs manual input."); - } - - return Decision.Accept(); - } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/UpgradeSpecification.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/UpgradeSpecification.cs deleted file mode 100644 index cab30cdca..000000000 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/UpgradeSpecification.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Linq; -using NLog; -using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Download; -using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Qualities; - -namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications -{ - public class UpgradeSpecification : IImportDecisionEngineSpecification - { - private readonly Logger _logger; - - public UpgradeSpecification(Logger logger) - { - _logger = logger; - } - - public Decision IsSatisfiedBy(LocalEpisode localEpisode) - { - var qualityComparer = new QualityModelComparer(localEpisode.Series.Profile); - if (localEpisode.Episodes.Any(e => e.EpisodeFileId != 0 && qualityComparer.Compare(e.EpisodeFile.Value.Quality, localEpisode.Quality) > 0)) - { - _logger.Debug("This file isn't an upgrade for all episodes. Skipping {0}", localEpisode.Path); - return Decision.Reject("Not an upgrade for existing episode file(s)"); - } - - return Decision.Accept(); - } - - public Decision IsSatisfiedBy(LocalMovie localEpisode, DownloadClientItem downloadClientItem) - { - return Decision.Accept(); - } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/Events/EpisodeDownloadedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/EpisodeDownloadedEvent.cs deleted file mode 100644 index af22b63fb..000000000 --- a/src/NzbDrone.Core/MediaFiles/Events/EpisodeDownloadedEvent.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; -using NzbDrone.Common.Messaging; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.MediaFiles.Events -{ - public class EpisodeDownloadedEvent : IEvent - { - public LocalEpisode Episode { get; private set; } - public EpisodeFile EpisodeFile { get; private set; } - public List OldFiles { get; private set; } - - public EpisodeDownloadedEvent(LocalEpisode episode, EpisodeFile episodeFile, List oldFiles) - { - Episode = episode; - EpisodeFile = episodeFile; - OldFiles = oldFiles; - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/MediaFiles/Events/EpisodeFileAddedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/EpisodeFileAddedEvent.cs deleted file mode 100644 index 83ea2a908..000000000 --- a/src/NzbDrone.Core/MediaFiles/Events/EpisodeFileAddedEvent.cs +++ /dev/null @@ -1,14 +0,0 @@ -using NzbDrone.Common.Messaging; - -namespace NzbDrone.Core.MediaFiles.Events -{ - public class EpisodeFileAddedEvent : IEvent - { - public EpisodeFile EpisodeFile { get; private set; } - - public EpisodeFileAddedEvent(EpisodeFile episodeFile) - { - EpisodeFile = episodeFile; - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/MediaFiles/Events/EpisodeFileDeletedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/EpisodeFileDeletedEvent.cs deleted file mode 100644 index 2cbc177a2..000000000 --- a/src/NzbDrone.Core/MediaFiles/Events/EpisodeFileDeletedEvent.cs +++ /dev/null @@ -1,16 +0,0 @@ -using NzbDrone.Common.Messaging; - -namespace NzbDrone.Core.MediaFiles.Events -{ - public class EpisodeFileDeletedEvent : IEvent - { - public EpisodeFile EpisodeFile { get; private set; } - public DeleteMediaFileReason Reason { get; private set; } - - public EpisodeFileDeletedEvent(EpisodeFile episodeFile, DeleteMediaFileReason reason) - { - EpisodeFile = episodeFile; - Reason = reason; - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/MediaFiles/Events/EpisodeFolderCreatedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/EpisodeFolderCreatedEvent.cs deleted file mode 100644 index 126b21222..000000000 --- a/src/NzbDrone.Core/MediaFiles/Events/EpisodeFolderCreatedEvent.cs +++ /dev/null @@ -1,20 +0,0 @@ -using NzbDrone.Common.Messaging; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.MediaFiles.Events -{ - public class EpisodeFolderCreatedEvent : IEvent - { - public Series Series { get; private set; } - public EpisodeFile EpisodeFile { get; private set; } - public string SeriesFolder { get; set; } - public string SeasonFolder { get; set; } - public string EpisodeFolder { get; set; } - - public EpisodeFolderCreatedEvent(Series series, EpisodeFile episodeFile) - { - Series = series; - EpisodeFile = episodeFile; - } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/Events/EpisodeImportedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/EpisodeImportedEvent.cs deleted file mode 100644 index 518132857..000000000 --- a/src/NzbDrone.Core/MediaFiles/Events/EpisodeImportedEvent.cs +++ /dev/null @@ -1,32 +0,0 @@ -using NzbDrone.Common.Messaging; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.MediaFiles.Events -{ - public class EpisodeImportedEvent : IEvent - { - public LocalEpisode EpisodeInfo { get; private set; } - public EpisodeFile ImportedEpisode { get; private set; } - public bool NewDownload { get; private set; } - public string DownloadClient { get; private set; } - public string DownloadId { get; private set; } - public bool IsReadOnly { get; set; } - - public EpisodeImportedEvent(LocalEpisode episodeInfo, EpisodeFile importedEpisode, bool newDownload) - { - EpisodeInfo = episodeInfo; - ImportedEpisode = importedEpisode; - NewDownload = newDownload; - } - - public EpisodeImportedEvent(LocalEpisode episodeInfo, EpisodeFile importedEpisode, bool newDownload, string downloadClient, string downloadId, bool isReadOnly) - { - EpisodeInfo = episodeInfo; - ImportedEpisode = importedEpisode; - NewDownload = newDownload; - DownloadClient = downloadClient; - DownloadId = downloadId; - IsReadOnly = isReadOnly; - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/MediaFiles/Events/MovieDownloadedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/MovieDownloadedEvent.cs index a9af4b8df..d5d98b24b 100644 --- a/src/NzbDrone.Core/MediaFiles/Events/MovieDownloadedEvent.cs +++ b/src/NzbDrone.Core/MediaFiles/Events/MovieDownloadedEvent.cs @@ -12,10 +12,10 @@ namespace NzbDrone.Core.MediaFiles.Events public List OldFiles { get; private set; } public string DownloadId { get; private set; } - public MovieDownloadedEvent(LocalMovie episode, MovieFile episodeFile, List oldFiles, DownloadClientItem downloadClientItem) + public MovieDownloadedEvent(LocalMovie movie, MovieFile movieFile, List oldFiles, DownloadClientItem downloadClientItem) { - Movie = episode; - MovieFile = episodeFile; + Movie = movie; + MovieFile = movieFile; OldFiles = oldFiles; if (downloadClientItem != null) { diff --git a/src/NzbDrone.Core/MediaFiles/Events/MovieFileAddedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/MovieFileAddedEvent.cs index 17f93dc0b..48ea06079 100644 --- a/src/NzbDrone.Core/MediaFiles/Events/MovieFileAddedEvent.cs +++ b/src/NzbDrone.Core/MediaFiles/Events/MovieFileAddedEvent.cs @@ -1,4 +1,4 @@ -using NzbDrone.Common.Messaging; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.MediaFiles.Events { @@ -6,9 +6,9 @@ namespace NzbDrone.Core.MediaFiles.Events { public MovieFile MovieFile { get; private set; } - public MovieFileAddedEvent(MovieFile episodeFile) + public MovieFileAddedEvent(MovieFile movieFile) { - MovieFile = episodeFile; + MovieFile = movieFile; } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/MediaFiles/Events/MovieFileDeletedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/MovieFileDeletedEvent.cs index 232f1686f..69cbc60c6 100644 --- a/src/NzbDrone.Core/MediaFiles/Events/MovieFileDeletedEvent.cs +++ b/src/NzbDrone.Core/MediaFiles/Events/MovieFileDeletedEvent.cs @@ -1,4 +1,4 @@ -using NzbDrone.Common.Messaging; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.MediaFiles.Events { @@ -7,10 +7,10 @@ namespace NzbDrone.Core.MediaFiles.Events public MovieFile MovieFile { get; private set; } public DeleteMediaFileReason Reason { get; private set; } - public MovieFileDeletedEvent(MovieFile episodeFile, DeleteMediaFileReason reason) + public MovieFileDeletedEvent(MovieFile movieFile, DeleteMediaFileReason reason) { - MovieFile = episodeFile; + MovieFile = movieFile; Reason = reason; } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/MediaFiles/Events/MovieFolderCreatedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/MovieFolderCreatedEvent.cs index a26031413..71e91cbc5 100644 --- a/src/NzbDrone.Core/MediaFiles/Events/MovieFolderCreatedEvent.cs +++ b/src/NzbDrone.Core/MediaFiles/Events/MovieFolderCreatedEvent.cs @@ -1,5 +1,5 @@ using NzbDrone.Common.Messaging; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.MediaFiles.Events { @@ -11,10 +11,10 @@ namespace NzbDrone.Core.MediaFiles.Events public string SeasonFolder { get; set; } public string MovieFolder { get; set; } - public MovieFolderCreatedEvent(Movie movie, MovieFile episodeFile) + public MovieFolderCreatedEvent(Movie movie, MovieFile movieFile) { Movie = movie; - MovieFile = episodeFile; + MovieFile = movieFile; } } } diff --git a/src/NzbDrone.Core/MediaFiles/Events/MovieImportedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/MovieImportedEvent.cs index 91df27e3c..bc26e83fa 100644 --- a/src/NzbDrone.Core/MediaFiles/Events/MovieImportedEvent.cs +++ b/src/NzbDrone.Core/MediaFiles/Events/MovieImportedEvent.cs @@ -1,4 +1,4 @@ -using NzbDrone.Common.Messaging; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.MediaFiles.Events @@ -12,16 +12,16 @@ namespace NzbDrone.Core.MediaFiles.Events public string DownloadId { get; private set; } public bool IsReadOnly { get; set; } - public MovieImportedEvent(LocalMovie episodeInfo, MovieFile importedMovie, bool newDownload) + public MovieImportedEvent(LocalMovie movieInfo, MovieFile importedMovie, bool newDownload) { - MovieInfo = episodeInfo; + MovieInfo = movieInfo; ImportedMovie = importedMovie; NewDownload = newDownload; } - public MovieImportedEvent(LocalMovie episodeInfo, MovieFile importedMovie, bool newDownload, string downloadClient, string downloadId, bool isReadOnly) + public MovieImportedEvent(LocalMovie movieInfo, MovieFile importedMovie, bool newDownload, string downloadClient, string downloadId, bool isReadOnly) { - MovieInfo = episodeInfo; + MovieInfo = movieInfo; ImportedMovie = importedMovie; NewDownload = newDownload; DownloadClient = downloadClient; @@ -29,4 +29,4 @@ namespace NzbDrone.Core.MediaFiles.Events IsReadOnly = isReadOnly; } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/MediaFiles/Events/MovieRenamedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/MovieRenamedEvent.cs index d7e264fa3..77a7646e3 100644 --- a/src/NzbDrone.Core/MediaFiles/Events/MovieRenamedEvent.cs +++ b/src/NzbDrone.Core/MediaFiles/Events/MovieRenamedEvent.cs @@ -1,5 +1,5 @@ using NzbDrone.Common.Messaging; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.MediaFiles.Events { diff --git a/src/NzbDrone.Core/MediaFiles/Events/MovieScanSkippedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/MovieScanSkippedEvent.cs index ecca0436d..1483c909e 100644 --- a/src/NzbDrone.Core/MediaFiles/Events/MovieScanSkippedEvent.cs +++ b/src/NzbDrone.Core/MediaFiles/Events/MovieScanSkippedEvent.cs @@ -1,5 +1,5 @@ using NzbDrone.Common.Messaging; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.MediaFiles.Events { diff --git a/src/NzbDrone.Core/MediaFiles/Events/MovieScannedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/MovieScannedEvent.cs index a0299d408..01f5df468 100644 --- a/src/NzbDrone.Core/MediaFiles/Events/MovieScannedEvent.cs +++ b/src/NzbDrone.Core/MediaFiles/Events/MovieScannedEvent.cs @@ -1,5 +1,5 @@ using NzbDrone.Common.Messaging; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.MediaFiles.Events { diff --git a/src/NzbDrone.Core/MediaFiles/Events/SeriesRenamedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/SeriesRenamedEvent.cs deleted file mode 100644 index 8cfe96b89..000000000 --- a/src/NzbDrone.Core/MediaFiles/Events/SeriesRenamedEvent.cs +++ /dev/null @@ -1,15 +0,0 @@ -using NzbDrone.Common.Messaging; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.MediaFiles.Events -{ - public class SeriesRenamedEvent : IEvent - { - public Series Series { get; private set; } - - public SeriesRenamedEvent(Series series) - { - Series = series; - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/MediaFiles/Events/SeriesScanSkippedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/SeriesScanSkippedEvent.cs deleted file mode 100644 index 47e8976c5..000000000 --- a/src/NzbDrone.Core/MediaFiles/Events/SeriesScanSkippedEvent.cs +++ /dev/null @@ -1,24 +0,0 @@ -using NzbDrone.Common.Messaging; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.MediaFiles.Events -{ - public class SeriesScanSkippedEvent : IEvent - { - public Series Series { get; private set; } - public SeriesScanSkippedReason Reason { get; set; } - - public SeriesScanSkippedEvent(Series series, SeriesScanSkippedReason reason) - { - Series = series; - Reason = reason; - } - } - - public enum SeriesScanSkippedReason - { - RootFolderDoesNotExist, - RootFolderIsEmpty, - SeriesFolderDoesNotExist - } -} diff --git a/src/NzbDrone.Core/MediaFiles/Events/SeriesScannedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/SeriesScannedEvent.cs deleted file mode 100644 index f82de5214..000000000 --- a/src/NzbDrone.Core/MediaFiles/Events/SeriesScannedEvent.cs +++ /dev/null @@ -1,15 +0,0 @@ -using NzbDrone.Common.Messaging; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.MediaFiles.Events -{ - public class SeriesScannedEvent : IEvent - { - public Series Series { get; private set; } - - public SeriesScannedEvent(Series series) - { - Series = series; - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/MediaFiles/MediaFileAttributeService.cs b/src/NzbDrone.Core/MediaFiles/MediaFileAttributeService.cs index a76c43abd..920e9a701 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaFileAttributeService.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaFileAttributeService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using NLog; using NzbDrone.Common.Disk; @@ -71,7 +71,7 @@ namespace NzbDrone.Core.MediaFiles { if (OsInfo.IsWindows) { - _logger.Debug("Setting last write time on series folder: {0}", path); + _logger.Debug("Setting last write time on movie folder: {0}", path); _diskProvider.FolderSetLastWriteTime(path, time); } } diff --git a/src/NzbDrone.Core/MediaFiles/MediaFileRepository.cs b/src/NzbDrone.Core/MediaFiles/MediaFileRepository.cs index 3cc90af0f..6ef40f409 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaFileRepository.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaFileRepository.cs @@ -1,40 +1,32 @@ -using System.Collections.Generic; +using System.Collections.Generic; using NzbDrone.Core.Datastore; using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.MediaFiles { - public interface IMediaFileRepository : IBasicRepository + public interface IMediaFileRepository : IBasicRepository { - List GetFilesBySeries(int seriesId); - List GetFilesBySeason(int seriesId, int seasonNumber); - List GetFilesWithoutMediaInfo(); + List GetFilesByMovie(int movieId); + List GetFilesWithoutMediaInfo(); } - public class MediaFileRepository : BasicRepository, IMediaFileRepository + public class MediaFileRepository : BasicRepository, IMediaFileRepository { public MediaFileRepository(IMainDatabase database, IEventAggregator eventAggregator) : base(database, eventAggregator) { } - public List GetFilesBySeries(int seriesId) + public List GetFilesByMovie(int movieId) { - return Query.Where(c => c.SeriesId == seriesId).ToList(); + return Query.Where(c => c.MovieId == movieId).ToList(); } - public List GetFilesBySeason(int seriesId, int seasonNumber) - { - return Query.Where(c => c.SeriesId == seriesId) - .AndWhere(c => c.SeasonNumber == seasonNumber) - .ToList(); - } - - public List GetFilesWithoutMediaInfo() + public List GetFilesWithoutMediaInfo() { return Query.Where(c => c.MediaInfo == null).ToList(); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/MediaFiles/MediaFileService.cs b/src/NzbDrone.Core/MediaFiles/MediaFileService.cs index a6622e85b..4ead8a15f 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaFileService.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaFileService.cs @@ -1,11 +1,11 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Linq; using NLog; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Tv.Events; +using NzbDrone.Core.Movies; +using NzbDrone.Core.Movies.Events; using NzbDrone.Common; using System; @@ -16,103 +16,68 @@ namespace NzbDrone.Core.MediaFiles MovieFile Add(MovieFile movieFile); void Update(MovieFile movieFile); void Delete(MovieFile movieFile, DeleteMediaFileReason reason); - EpisodeFile Add(EpisodeFile episodeFile); - void Update(EpisodeFile episodeFile); - void Delete(EpisodeFile episodeFile, DeleteMediaFileReason reason); - List GetFilesBySeries(int seriesId); List GetFilesByMovie(int movieId); - List GetFilesBySeason(int seriesId, int seasonNumber); - List GetFilesWithoutMediaInfo(); - List FilterExistingFiles(List files, Series series); + List GetFilesWithoutMediaInfo(); List FilterExistingFiles(List files, Movie movie); - EpisodeFile Get(int id); MovieFile GetMovie(int id); - List Get(IEnumerable ids); List GetMovies(IEnumerable ids); - - //List Get(IEnumerable ids); } - public class MediaFileService : IMediaFileService, IHandleAsync, - IHandleAsync + public class MediaFileService : IMediaFileService, IHandleAsync { private readonly IEventAggregator _eventAggregator; private readonly IMediaFileRepository _mediaFileRepository; - private readonly IMovieFileRepository _movieFileRepository; - private readonly IMovieService _movieService; + private readonly IMovieService _movieService; private readonly Logger _logger; - public MediaFileService(IMediaFileRepository mediaFileRepository, IMovieFileRepository movieFileRepository, IMovieService movieService, - IEventAggregator eventAggregator, Logger logger) + public MediaFileService(IMediaFileRepository mediaFileRepository, IMovieService movieService, + IEventAggregator eventAggregator, Logger logger) { _mediaFileRepository = mediaFileRepository; _eventAggregator = eventAggregator; - _movieService = movieService; - _movieFileRepository = movieFileRepository; + _movieService = movieService; _logger = logger; } - public EpisodeFile Add(EpisodeFile episodeFile) + public MovieFile Add(MovieFile movieFile) { - var addedFile = _mediaFileRepository.Insert(episodeFile); - _eventAggregator.PublishEvent(new EpisodeFileAddedEvent(addedFile)); - return addedFile; - } + var addedFile = _mediaFileRepository.Insert(movieFile); + addedFile.Movie.LazyLoad(); + if (addedFile.Movie == null || addedFile.Movie.Value == null) + { + _logger.Error("Movie is null for the file {0}. Please run the houskeeping command to ensure movies and files are linked correctly."); + } + //_movieService.SetFileId(addedFile.Movie.Value, addedFile); //Should not be necessary, but sometimes below fails? + _eventAggregator.PublishEvent(new MovieFileAddedEvent(addedFile)); - public void Update(EpisodeFile episodeFile) - { - _mediaFileRepository.Update(episodeFile); + return addedFile; } - public void Delete(EpisodeFile episodeFile, DeleteMediaFileReason reason) + public void Update(MovieFile movieFile) { - //Little hack so we have the episodes and series attached for the event consumers - episodeFile.Episodes.LazyLoad(); - episodeFile.Path = Path.Combine(episodeFile.Series.Value.Path, episodeFile.RelativePath); - - _mediaFileRepository.Delete(episodeFile); - _eventAggregator.PublishEvent(new EpisodeFileDeletedEvent(episodeFile, reason)); + _mediaFileRepository.Update(movieFile); } public void Delete(MovieFile movieFile, DeleteMediaFileReason reason) { - //Little hack so we have the episodes and series attached for the event consumers + //Little hack so we have the movie attached for the event consumers movieFile.Movie.LazyLoad(); movieFile.Path = Path.Combine(movieFile.Movie.Value.Path, movieFile.RelativePath); - _movieFileRepository.Delete(movieFile); + _mediaFileRepository.Delete(movieFile); _eventAggregator.PublishEvent(new MovieFileDeletedEvent(movieFile, reason)); } - public List GetFilesBySeries(int seriesId) - { - return _mediaFileRepository.GetFilesBySeries(seriesId); - } - public List GetFilesByMovie(int movieId) { - return _movieFileRepository.GetFilesByMovie(movieId); //TODO: Update implementation for movie files. + return _mediaFileRepository.GetFilesByMovie(movieId); } - public List GetFilesBySeason(int seriesId, int seasonNumber) - { - return _mediaFileRepository.GetFilesBySeason(seriesId, seasonNumber); - } - - public List GetFilesWithoutMediaInfo() + public List GetFilesWithoutMediaInfo() { return _mediaFileRepository.GetFilesWithoutMediaInfo(); } - public List FilterExistingFiles(List files, Series series) - { - var seriesFiles = GetFilesBySeries(series.Id).Select(f => Path.Combine(series.Path, f.RelativePath)).ToList(); - - if (!seriesFiles.Any()) return files; - - return files.Except(seriesFiles, PathEqualityComparer.Instance).ToList(); - } - public List FilterExistingFiles(List files, Movie movie) { var movieFiles = GetFilesByMovie(movie.Id).Select(f => Path.Combine(movie.Path, f.RelativePath)).ToList(); @@ -122,58 +87,22 @@ namespace NzbDrone.Core.MediaFiles return files.Except(movieFiles, PathEqualityComparer.Instance).ToList(); } - public EpisodeFile Get(int id) - { - return _mediaFileRepository.Get(id); - } - - public List Get(IEnumerable ids) - { - return _mediaFileRepository.Get(ids).ToList(); - } - public List GetMovies(IEnumerable ids) { - return _movieFileRepository.Get(ids).ToList(); + return _mediaFileRepository.Get(ids).ToList(); } - public void HandleAsync(SeriesDeletedEvent message) + public MovieFile GetMovie(int id) { - var files = GetFilesBySeries(message.Series.Id); - _mediaFileRepository.DeleteMany(files); + return _mediaFileRepository.Get(id); } - public MovieFile Add(MovieFile episodeFile) + public void HandleAsync(MovieDeletedEvent message) { - var addedFile = _movieFileRepository.Insert(episodeFile); - addedFile.Movie.LazyLoad(); - if (addedFile.Movie == null || addedFile.Movie.Value == null) - { - _logger.Error("Movie is null for the file {0}. Please run the houskeeping command to ensure movies and files are linked correctly."); - } - //_movieService.SetFileId(addedFile.Movie.Value, addedFile); //Should not be necessary, but sometimes below fails? - _eventAggregator.PublishEvent(new MovieFileAddedEvent(addedFile)); - return addedFile; - } - - public void Update(MovieFile movieFile) - { - _movieFileRepository.Update(movieFile); - } + var files = GetFilesByMovie(message.Movie.Id); + _mediaFileRepository.DeleteMany(files); - public MovieFile GetMovie(int id) - { - return _movieFileRepository.Get(id); } - - public void HandleAsync(MovieDeletedEvent message) - { - if (message.DeleteFiles == true) - { - var files = GetFilesByMovie(message.Movie.Id); - _movieFileRepository.DeleteMany(files); - } - } - } + } } diff --git a/src/NzbDrone.Core/MediaFiles/MediaFileTableCleanupService.cs b/src/NzbDrone.Core/MediaFiles/MediaFileTableCleanupService.cs index 3c57b3feb..4c01bc790 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaFileTableCleanupService.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaFileTableCleanupService.cs @@ -1,17 +1,15 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using NLog; using NzbDrone.Common; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.MediaFiles { public interface IMediaFileTableCleanupService { - void Clean(Series series, List filesOnDisk); - void Clean(Movie movie, List filesOnDisk); } @@ -19,77 +17,17 @@ namespace NzbDrone.Core.MediaFiles { private readonly IMediaFileService _mediaFileService; private readonly IMovieService _movieService; - private readonly IEpisodeService _episodeService; private readonly Logger _logger; public MediaFileTableCleanupService(IMediaFileService mediaFileService, IMovieService movieService, - IEpisodeService episodeService, Logger logger) { _mediaFileService = mediaFileService; _movieService = movieService; - _episodeService = episodeService; _logger = logger; } - public void Clean(Series series, List filesOnDisk) - { - var seriesFiles = _mediaFileService.GetFilesBySeries(series.Id); - var episodes = _episodeService.GetEpisodeBySeries(series.Id); - - var filesOnDiskKeys = new HashSet(filesOnDisk, PathEqualityComparer.Instance); - - foreach (var seriesFile in seriesFiles) - { - var episodeFile = seriesFile; - var episodeFilePath = Path.Combine(series.Path, episodeFile.RelativePath); - - try - { - if (!filesOnDiskKeys.Contains(episodeFilePath)) - { - _logger.Debug("File [{0}] no longer exists on disk, removing from db", episodeFilePath); - _mediaFileService.Delete(seriesFile, DeleteMediaFileReason.MissingFromDisk); - continue; - } - - if (episodes.None(e => e.EpisodeFileId == episodeFile.Id)) - { - _logger.Debug("File [{0}] is not assigned to any episodes, removing from db", episodeFilePath); - _mediaFileService.Delete(episodeFile, DeleteMediaFileReason.NoLinkedEpisodes); - continue; - } - -// var localEpsiode = _parsingService.GetLocalEpisode(episodeFile.Path, series); -// -// if (localEpsiode == null || episodes.Count != localEpsiode.Episodes.Count) -// { -// _logger.Debug("File [{0}] parsed episodes has changed, removing from db", episodeFile.Path); -// _mediaFileService.Delete(episodeFile); -// continue; -// } - } - - catch (Exception ex) - { - var errorMessage = string.Format("Unable to cleanup EpisodeFile in DB: {0}", episodeFile.Id); - _logger.Error(ex, errorMessage); - } - } - - foreach (var e in episodes) - { - var episode = e; - - if (episode.EpisodeFileId > 0 && seriesFiles.None(f => f.Id == episode.EpisodeFileId)) - { - episode.EpisodeFileId = 0; - _episodeService.UpdateEpisode(episode); - } - } - } - public void Clean(Movie movie, List filesOnDisk) { var movieFiles = _mediaFileService.GetFilesByMovie(movie.Id); @@ -127,4 +65,4 @@ namespace NzbDrone.Core.MediaFiles } } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/MediaFiles/MediaInfo/UpdateMediaInfoService.cs b/src/NzbDrone.Core/MediaFiles/MediaInfo/UpdateMediaInfoService.cs index cbe505c79..e1ab325d9 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaInfo/UpdateMediaInfoService.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaInfo/UpdateMediaInfoService.cs @@ -1,9 +1,9 @@ -using System.IO; +using System.IO; using NLog; using NzbDrone.Common.Disk; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using System.Collections.Generic; using System.Linq; using NzbDrone.Core.Configuration; @@ -33,11 +33,11 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo _logger = logger; } - private void UpdateMediaInfo(Movie series, List mediaFiles) + private void UpdateMediaInfo(Movie movie, List mediaFiles) { foreach (var mediaFile in mediaFiles) { - var path = Path.Combine(series.Path, mediaFile.RelativePath); + var path = Path.Combine(movie.Path, mediaFile.RelativePath); if (!_diskProvider.FileExists(path)) { diff --git a/src/NzbDrone.Core/MediaFiles/MovieFile.cs b/src/NzbDrone.Core/MediaFiles/MovieFile.cs index 9bb0f1ddd..8250c4c25 100644 --- a/src/NzbDrone.Core/MediaFiles/MovieFile.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieFile.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using Marr.Data; using NzbDrone.Core.Datastore; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.MediaFiles.MediaInfo; namespace NzbDrone.Core.MediaFiles diff --git a/src/NzbDrone.Core/MediaFiles/MovieFileMovingService.cs b/src/NzbDrone.Core/MediaFiles/MovieFileMovingService.cs index e5d0e1305..38f44d5e3 100644 --- a/src/NzbDrone.Core/MediaFiles/MovieFileMovingService.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieFileMovingService.cs @@ -11,7 +11,7 @@ using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Organizer; using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.MediaFiles { diff --git a/src/NzbDrone.Core/MediaFiles/MovieFileRepository.cs b/src/NzbDrone.Core/MediaFiles/MovieFileRepository.cs deleted file mode 100644 index 9ed89b85f..000000000 --- a/src/NzbDrone.Core/MediaFiles/MovieFileRepository.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections.Generic; -using NzbDrone.Core.Datastore; -using NzbDrone.Core.Messaging.Events; - - -namespace NzbDrone.Core.MediaFiles -{ - public interface IMovieFileRepository : IBasicRepository - { - List GetFilesByMovie(int movieId); - List GetFilesWithoutMediaInfo(); - } - - - public class MovieFileRepository : BasicRepository, IMovieFileRepository - { - public MovieFileRepository(IMainDatabase database, IEventAggregator eventAggregator) - : base(database, eventAggregator) - { - } - - public List GetFilesByMovie(int movieId) - { - return Query.Where(c => c.MovieId == movieId).ToList(); - } - - public List GetFilesWithoutMediaInfo() - { - return Query.Where(c => c.MediaInfo == null).ToList(); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/DetectSample.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/DetectSample.cs similarity index 58% rename from src/NzbDrone.Core/MediaFiles/EpisodeImport/DetectSample.cs rename to src/NzbDrone.Core/MediaFiles/MovieImport/DetectSample.cs index 309c72b9d..aed192303 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/DetectSample.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/DetectSample.cs @@ -1,16 +1,15 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using NLog; using NzbDrone.Core.MediaFiles.MediaInfo; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; -namespace NzbDrone.Core.MediaFiles.EpisodeImport +namespace NzbDrone.Core.MediaFiles.MovieImport { public interface IDetectSample { - bool IsSample(Series series, QualityModel quality, string path, long size, bool isSpecial); bool IsSample(Movie movie, QualityModel quality, string path, long size, bool isSpecial); } @@ -29,57 +28,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport public static long SampleSizeLimit => 70.Megabytes(); - public bool IsSample(Series series, QualityModel quality, string path, long size, bool isSpecial) - { - if (isSpecial) - { - _logger.Debug("Special, skipping sample check"); - return false; - } - - var extension = Path.GetExtension(path); - - if (extension != null && extension.Equals(".flv", StringComparison.InvariantCultureIgnoreCase)) - { - _logger.Debug("Skipping sample check for .flv file"); - return false; - } - - if (extension != null && extension.Equals(".strm", StringComparison.InvariantCultureIgnoreCase)) - { - _logger.Debug("Skipping sample check for .strm file"); - return false; - } - - try - { - var runTime = _videoFileInfoReader.GetRunTime(path); - var minimumRuntime = GetMinimumAllowedRuntime(series); - - if (runTime.TotalMinutes.Equals(0)) - { - _logger.Error("[{0}] has a runtime of 0, is it a valid video file?", path); - return true; - } - - if (runTime.TotalSeconds < minimumRuntime) - { - _logger.Debug("[{0}] appears to be a sample. Runtime: {1} seconds. Expected at least: {2} seconds", path, runTime, minimumRuntime); - return true; - } - } - - catch (DllNotFoundException) - { - _logger.Debug("Falling back to file size detection"); - - return CheckSize(size, quality); - } - - _logger.Debug("Runtime is over 90 seconds"); - return false; - } - public bool IsSample(Movie movie, QualityModel quality, string path, long size, bool isSpecial) { if (isSpecial) @@ -160,23 +108,5 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport return movie.Runtime / 5 * 60; } - - private int GetMinimumAllowedRuntime(Series series) - { - //Webisodes - 90 seconds - if (series.Runtime <= 10) - { - return 90; - } - - //30 minute episodes - 5 minutes - if (series.Runtime <= 30) - { - return 300; - } - - //60 minute episodes - 10 minutes - return 600; - } } } diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/IImportDecisionEngineSpecification.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/IImportDecisionEngineSpecification.cs similarity index 60% rename from src/NzbDrone.Core/MediaFiles/EpisodeImport/IImportDecisionEngineSpecification.cs rename to src/NzbDrone.Core/MediaFiles/MovieImport/IImportDecisionEngineSpecification.cs index 268f504a9..9d6fe6f0a 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/IImportDecisionEngineSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/IImportDecisionEngineSpecification.cs @@ -1,13 +1,11 @@ -using NzbDrone.Core.DecisionEngine; +using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.MediaFiles.EpisodeImport +namespace NzbDrone.Core.MediaFiles.MovieImport { public interface IImportDecisionEngineSpecification { - Decision IsSatisfiedBy(LocalEpisode localEpisode); - Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem); } } diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedMovie.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs similarity index 94% rename from src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedMovie.cs rename to src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs index 266e72069..0ee443b89 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedMovie.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs @@ -14,7 +14,7 @@ using NzbDrone.Core.Download; using NzbDrone.Core.Extras; -namespace NzbDrone.Core.MediaFiles.EpisodeImport +namespace NzbDrone.Core.MediaFiles.MovieImport { public interface IImportApprovedMovie { @@ -23,21 +23,21 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport public class ImportApprovedMovie : IImportApprovedMovie { - private readonly IUpgradeMediaFiles _episodeFileUpgrader; + private readonly IUpgradeMediaFiles _movieFileUpgrader; private readonly IMediaFileService _mediaFileService; private readonly IExtraService _extraService; private readonly IDiskProvider _diskProvider; private readonly IEventAggregator _eventAggregator; private readonly Logger _logger; - public ImportApprovedMovie(IUpgradeMediaFiles episodeFileUpgrader, + public ImportApprovedMovie(IUpgradeMediaFiles movieFileUpgrader, IMediaFileService mediaFileService, IExtraService extraService, IDiskProvider diskProvider, IEventAggregator eventAggregator, Logger logger) { - _episodeFileUpgrader = episodeFileUpgrader; + _movieFileUpgrader = movieFileUpgrader; _mediaFileService = mediaFileService; _extraService = extraService; _diskProvider = diskProvider; @@ -107,7 +107,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport { movieFile.SceneName = GetSceneName(downloadClientItem, localMovie); - var moveResult = _episodeFileUpgrader.UpgradeMovieFile(movieFile, localMovie, copyOnly); //TODO: Check if this works + var moveResult = _movieFileUpgrader.UpgradeMovieFile(movieFile, localMovie, copyOnly); //TODO: Check if this works oldFiles = moveResult.OldFiles; } else diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecision.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportDecision.cs similarity index 72% rename from src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecision.cs rename to src/NzbDrone.Core/MediaFiles/MovieImport/ImportDecision.cs index 406866b65..618294b78 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecision.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportDecision.cs @@ -1,25 +1,18 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using NzbDrone.Common.Extensions; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.MediaFiles.EpisodeImport +namespace NzbDrone.Core.MediaFiles.MovieImport { public class ImportDecision { - public LocalEpisode LocalEpisode { get; private set; } public LocalMovie LocalMovie { get; private set; } public IEnumerable Rejections { get; private set; } public bool Approved => Rejections.Empty(); - public ImportDecision(LocalEpisode localEpisode, params Rejection[] rejections) - { - LocalEpisode = localEpisode; - Rejections = rejections.ToList(); - } - public ImportDecision(LocalMovie localMovie, params Rejection[] rejections) { LocalMovie = localMovie; diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportDecisionMaker.cs similarity index 73% rename from src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs rename to src/NzbDrone.Core/MediaFiles/MovieImport/ImportDecisionMaker.cs index 091d79ec6..2504d16dd 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportDecisionMaker.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -10,20 +10,18 @@ using NzbDrone.Core.Download; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.MediaFiles.MediaInfo; -namespace NzbDrone.Core.MediaFiles.EpisodeImport +namespace NzbDrone.Core.MediaFiles.MovieImport { public interface IMakeImportDecision { - List GetImportDecisions(List videoFiles, Series series); List GetImportDecisions(List videoFiles, Movie movie); List GetImportDecisions(List videoFiles, Movie movie, bool shouldCheckQuality); List GetImportDecisions(List videoFiles, Movie movie, DownloadClientItem downloadClientItem, ParsedMovieInfo folderInfo, bool sceneSource, bool shouldCheckQuality); List GetImportDecisions(List videoFiles, Movie movie, DownloadClientItem downloadClientItem, ParsedMovieInfo folderInfo, bool sceneSource); - List GetImportDecisions(List videoFiles, Series series, ParsedEpisodeInfo folderInfo, bool sceneSource); } public class ImportDecisionMaker : IMakeImportDecision @@ -56,11 +54,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport _logger = logger; } - public List GetImportDecisions(List videoFiles, Series series) - { - return GetImportDecisions(videoFiles, series, null, false); - } - public List GetImportDecisions(List videoFiles, Movie movie) { return GetImportDecisions(videoFiles, movie, null, null, true, false); @@ -71,23 +64,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport return GetImportDecisions(videoFiles, movie, null, null, true, shouldCheckQuality); } - public List GetImportDecisions(List videoFiles, Series series, ParsedEpisodeInfo folderInfo, bool sceneSource) - { - var newFiles = _mediaFileService.FilterExistingFiles(videoFiles.ToList(), series); - - _logger.Debug("Analyzing {0}/{1} files.", newFiles.Count, videoFiles.Count()); - - var shouldUseFolderName = ShouldUseFolderName(videoFiles, series, folderInfo); - var decisions = new List(); - - foreach (var file in newFiles) - { - decisions.AddIfNotNull(GetDecision(file, series, folderInfo, sceneSource, shouldUseFolderName)); - } - - return decisions; - } - public List GetImportDecisions(List videoFiles, Movie movie, DownloadClientItem downloadClientItem, ParsedMovieInfo folderInfo, bool sceneSource) { var newFiles = _mediaFileService.FilterExistingFiles(videoFiles.ToList(), movie); @@ -138,7 +114,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport _logger.Debug("Size: {0}", localMovie.Size); var current = localMovie.Quality; localMovie.MediaInfo = _videoFileInfoReader.GetMediaInfo(file); - //TODO: make it so media info doesn't ruin the import process of a new series + //TODO: make it so media info doesn't ruin the import process of a new movie if (sceneSource && ShouldCheckQualityForParsedQuality(current.Quality)) { @@ -323,69 +299,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport return new ImportDecision(localMovie, reasons.ToArray()); } - private ImportDecision GetDecision(string file, Series series, ParsedEpisodeInfo folderInfo, bool sceneSource, bool shouldUseFolderName) - { - ImportDecision decision = null; - - try - { - var localEpisode = _parsingService.GetLocalEpisode(file, series, shouldUseFolderName ? folderInfo : null, sceneSource); - - if (localEpisode != null) - { - localEpisode.Quality = GetQuality(folderInfo, localEpisode.Quality, series); - localEpisode.Size = _diskProvider.GetFileSize(file); - - _logger.Debug("Size: {0}", localEpisode.Size); - - //TODO: make it so media info doesn't ruin the import process of a new series - if (sceneSource) - { - localEpisode.MediaInfo = _videoFileInfoReader.GetMediaInfo(file); - } - - if (localEpisode.Episodes.Empty()) - { - decision = new ImportDecision(localEpisode, new Rejection("Invalid season or episode")); - } - else - { - decision = GetDecision(localEpisode); - } - } - - else - { - localEpisode = new LocalEpisode(); - localEpisode.Path = file; - - decision = new ImportDecision(localEpisode, new Rejection("Unable to parse file")); - } - } - catch (Exception e) - { - _logger.Error(e, "Couldn't import file. " + file); - - var localEpisode = new LocalEpisode { Path = file }; - decision = new ImportDecision(localEpisode, new Rejection("Unexpected error processing file")); - } - - if (decision == null) - { - _logger.Error("Unable to make a decision on {0}", file); - } - - return decision; - } - - private ImportDecision GetDecision(LocalEpisode localEpisode) - { - var reasons = _specifications.Select(c => EvaluateSpec(c, localEpisode)) - .Where(c => c != null); - - return new ImportDecision(localEpisode, reasons.ToArray()); - } - private Rejection EvaluateSpec(IImportDecisionEngineSpecification spec, LocalMovie localMovie, DownloadClientItem downloadClientItem) { try @@ -413,60 +326,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport return null; } - private Rejection EvaluateSpec(IImportDecisionEngineSpecification spec, LocalEpisode localEpisode) - { - try - { - var result = spec.IsSatisfiedBy(localEpisode); - - if (!result.Accepted) - { - return new Rejection(result.Reason); - } - } - catch (Exception e) - { - //e.Data.Add("report", remoteEpisode.Report.ToJson()); - //e.Data.Add("parsed", remoteEpisode.ParsedEpisodeInfo.ToJson()); - _logger.Error(e, "Couldn't evaluate decision on " + localEpisode.Path); - return new Rejection(string.Format("{0}: {1}", spec.GetType().Name, e.Message)); - } - - return null; - } - - private bool ShouldUseFolderName(List videoFiles, Series series, ParsedEpisodeInfo folderInfo) - { - if (folderInfo == null) - { - return false; - } - - if (folderInfo.FullSeason) - { - return false; - } - - return videoFiles.Count(file => - { - var size = _diskProvider.GetFileSize(file); - var fileQuality = QualityParser.ParseQuality(file); - var sample = _detectSample.IsSample(series, GetQuality(folderInfo, fileQuality, series), file, size, folderInfo.IsPossibleSpecialEpisode); - - if (sample) - { - return false; - } - - if (SceneChecker.IsSceneTitle(Path.GetFileName(file))) - { - return false; - } - - return true; - }) == 1; - } - private bool ShouldUseFolderName(List videoFiles, Movie movie, ParsedMovieInfo folderInfo) { if (folderInfo == null) @@ -512,17 +371,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport return fileQuality; } - private QualityModel GetQuality(ParsedEpisodeInfo folderInfo, QualityModel fileQuality, Series series) - { - if (UseFolderQuality(folderInfo, fileQuality, series)) - { - _logger.Debug("Using quality from folder: {0}", folderInfo.Quality); - return folderInfo.Quality; - } - - return fileQuality; - } - private bool UseFolderQuality(ParsedMovieInfo folderInfo, QualityModel fileQuality, Movie movie) { if (folderInfo == null) @@ -545,31 +393,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport return true; } - return false; - } - - private bool UseFolderQuality(ParsedEpisodeInfo folderInfo, QualityModel fileQuality, Series series) - { - if (folderInfo == null) - { - return false; - } - - if (folderInfo.Quality.Quality == Quality.Unknown) - { - return false; - } - - if (fileQuality.QualitySource == QualitySource.Extension) - { - return true; - } - - if (new QualityModelComparer(series.Profile).Compare(folderInfo.Quality, fileQuality) > 0) - { - return true; - } - return false; } diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportMode.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportMode.cs similarity index 66% rename from src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportMode.cs rename to src/NzbDrone.Core/MediaFiles/MovieImport/ImportMode.cs index ffdf7eed8..6deddf8b8 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportMode.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportMode.cs @@ -1,4 +1,4 @@ -namespace NzbDrone.Core.MediaFiles.EpisodeImport +namespace NzbDrone.Core.MediaFiles.MovieImport { public enum ImportMode { diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportResult.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportResult.cs similarity index 95% rename from src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportResult.cs rename to src/NzbDrone.Core/MediaFiles/MovieImport/ImportResult.cs index a0d989335..4ceaef58e 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportResult.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportResult.cs @@ -2,7 +2,7 @@ using System.Linq; using NzbDrone.Common.EnsureThat; -namespace NzbDrone.Core.MediaFiles.EpisodeImport +namespace NzbDrone.Core.MediaFiles.MovieImport { public class ImportResult { diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportResultType.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportResultType.cs similarity index 66% rename from src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportResultType.cs rename to src/NzbDrone.Core/MediaFiles/MovieImport/ImportResultType.cs index 7c43332de..f94a03997 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportResultType.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportResultType.cs @@ -1,4 +1,4 @@ -namespace NzbDrone.Core.MediaFiles.EpisodeImport +namespace NzbDrone.Core.MediaFiles.MovieImport { public enum ImportResultType { diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportCommand.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportCommand.cs similarity index 84% rename from src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportCommand.cs rename to src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportCommand.cs index 38ed485b7..a204d2230 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportCommand.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportCommand.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using NzbDrone.Core.Messaging.Commands; -namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual +namespace NzbDrone.Core.MediaFiles.MovieImport.Manual { public class ManualImportCommand : Command { diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportFile.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportFile.cs similarity index 87% rename from src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportFile.cs rename to src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportFile.cs index d9f089179..d8d7ef81f 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportFile.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportFile.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using NzbDrone.Core.Qualities; -namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual +namespace NzbDrone.Core.MediaFiles.MovieImport.Manual { public class ManualImportFile { diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportItem.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportItem.cs similarity index 65% rename from src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportItem.cs rename to src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportItem.cs index ecca2739c..bc38e75f9 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportItem.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportItem.cs @@ -1,9 +1,9 @@ -using System.Collections.Generic; +using System.Collections.Generic; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; -namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual +namespace NzbDrone.Core.MediaFiles.MovieImport.Manual { public class ManualImportItem { @@ -11,9 +11,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual public string RelativePath { get; set; } public string Name { get; set; } public long Size { get; set; } - public Series Series { get; set; } - public int? SeasonNumber { get; set; } - public List Episodes { get; set; } public QualityModel Quality { get; set; } public string DownloadId { get; set; } public IEnumerable Rejections { get; set; } diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportService.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs similarity index 61% rename from src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportService.cs rename to src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs index 7cc815a5b..f22949885 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportService.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -15,9 +15,9 @@ using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; -namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual +namespace NzbDrone.Core.MediaFiles.MovieImport.Manual { public interface IManualImportService { @@ -30,11 +30,8 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual private readonly IParsingService _parsingService; private readonly IDiskScanService _diskScanService; private readonly IMakeImportDecision _importDecisionMaker; - private readonly ISeriesService _seriesService; private readonly IMovieService _movieService; - private readonly IEpisodeService _episodeService; private readonly IVideoFileInfoReader _videoFileInfoReader; - private readonly IImportApprovedEpisodes _importApprovedEpisodes; private readonly IImportApprovedMovie _importApprovedMovie; private readonly ITrackedDownloadService _trackedDownloadService; private readonly IDownloadedMovieImportService _downloadedMovieImportService; @@ -46,11 +43,8 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual IParsingService parsingService, IDiskScanService diskScanService, IMakeImportDecision importDecisionMaker, - ISeriesService seriesService, IMovieService movieService, - IEpisodeService episodeService, IVideoFileInfoReader videoFileInfoReader, - IImportApprovedEpisodes importApprovedEpisodes, IImportApprovedMovie importApprovedMovie, ITrackedDownloadService trackedDownloadService, IDownloadedMovieImportService downloadedMovieImportService, @@ -62,11 +56,8 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual _parsingService = parsingService; _diskScanService = diskScanService; _importDecisionMaker = importDecisionMaker; - _seriesService = seriesService; _movieService = movieService; - _episodeService = episodeService; _videoFileInfoReader = videoFileInfoReader; - _importApprovedEpisodes = importApprovedEpisodes; _importApprovedMovie = importApprovedMovie; _trackedDownloadService = trackedDownloadService; _downloadedMovieImportService = downloadedMovieImportService; @@ -106,20 +97,20 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual { DownloadClientItem downloadClientItem = null; var directoryInfo = new DirectoryInfo(folder); - var series = _parsingService.GetMovie(directoryInfo.Name); + var movie = _parsingService.GetMovie(directoryInfo.Name); if (downloadId.IsNotNullOrWhiteSpace()) { var trackedDownload = _trackedDownloadService.Find(downloadId); downloadClientItem = trackedDownload.DownloadItem; - if (series == null) + if (movie == null) { - series = trackedDownload.RemoteMovie.Movie; + movie = trackedDownload.RemoteMovie.Movie; } } - if (series == null) + if (movie == null) { var files = _diskScanService.GetVideoFiles(folder); @@ -127,8 +118,8 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual } var folderInfo = Parser.Parser.ParseMovieTitle(directoryInfo.Name, _config.ParsingLeniency > 0); - var seriesFiles = _diskScanService.GetVideoFiles(folder).ToList(); - var decisions = _importDecisionMaker.GetImportDecisions(seriesFiles, series, downloadClientItem, folderInfo, SceneSource(series, folder), false); + var movieFiles = _diskScanService.GetVideoFiles(folder).ToList(); + var decisions = _importDecisionMaker.GetImportDecisions(movieFiles, movie, downloadClientItem, folderInfo, SceneSource(movie, folder), false); return decisions.Select(decision => MapItem(decision, folder, downloadId)).ToList(); } @@ -189,81 +180,11 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual }; } - //private ManualImportItem ProcessFile(string file, string downloadId, string folder = null) - //{ - // if (folder.IsNullOrWhiteSpace()) - // { - // folder = new FileInfo(file).Directory.FullName; - // } - - // var relativeFile = folder.GetRelativePath(file); - - // var series = _parsingService.GetSeries(relativeFile.Split('\\', '/')[0]); - - // if (series == null) - // { - // series = _parsingService.GetSeries(relativeFile); - // } - - // if (series == null && downloadId.IsNotNullOrWhiteSpace()) - // { - // var trackedDownload = _trackedDownloadService.Find(downloadId); - // series = trackedDownload.RemoteEpisode.Series; - // } - - // if (series == null) - // { - // var localEpisode = new LocalEpisode(); - // localEpisode.Path = file; - // localEpisode.Quality = QualityParser.ParseQuality(file); - // localEpisode.Size = _diskProvider.GetFileSize(file); - - // return MapItem(new ImportDecision(localEpisode, new Rejection("Unknown Series")), folder, downloadId); - // } - - // var importDecisions = _importDecisionMaker.GetImportDecisions(new List {file}, - // series, null, SceneSource(series, folder)); - - // return importDecisions.Any() ? MapItem(importDecisions.First(), folder, downloadId) : null; - //} - - private bool SceneSource(Series series, string folder) - { - return !(series.Path.PathEquals(folder) || series.Path.IsParentPath(folder)); - } - private bool SceneSource(Movie movie, string folder) { return !(movie.Path.PathEquals(folder) || movie.Path.IsParentPath(folder)); } - //private ManualImportItem MapItem(ImportDecision decision, string folder, string downloadId) - //{ - // var item = new ManualImportItem(); - - // item.Path = decision.LocalEpisode.Path; - // item.RelativePath = folder.GetRelativePath(decision.LocalEpisode.Path); - // item.Name = Path.GetFileNameWithoutExtension(decision.LocalEpisode.Path); - // item.DownloadId = downloadId; - - // if (decision.LocalEpisode.Series != null) - // { - // item.Series = decision.LocalEpisode.Series; - // } - - // if (decision.LocalEpisode.Episodes.Any()) - // { - // item.SeasonNumber = decision.LocalEpisode.SeasonNumber; - // item.Episodes = decision.LocalEpisode.Episodes; - // } - - // item.Quality = decision.LocalEpisode.Quality; - // item.Size = _diskProvider.GetFileSize(decision.LocalEpisode.Path); - // item.Rejections = decision.Rejections; - - // return item; - //} - private ManualImportItem MapItem(ImportDecision decision, string folder, string downloadId) { var item = new ManualImportItem(); @@ -360,83 +281,5 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual } } } - - //public void Execute(ManualImportCommand message) - //{ - // _logger.ProgressTrace("Manually importing {0} files using mode {1}", message.Files.Count, message.ImportMode); - - // var imported = new List(); - // var importedTrackedDownload = new List(); - - // for (int i = 0; i < message.Files.Count; i++) - // { - // _logger.ProgressTrace("Processing file {0} of {1}", i + 1, message.Files.Count); - - // var file = message.Files[i]; - // var series = _seriesService.GetSeries(file.SeriesId); - // var episodes = _episodeService.GetEpisodes(file.EpisodeIds); - // var parsedEpisodeInfo = Parser.Parser.ParsePath(file.Path) ?? new ParsedEpisodeInfo(); - // var mediaInfo = _videoFileInfoReader.GetMediaInfo(file.Path); - // var existingFile = series.Path.IsParentPath(file.Path); - - // var localEpisode = new LocalEpisode - // { - // ExistingFile = false, - // Episodes = episodes, - // MediaInfo = mediaInfo, - // ParsedEpisodeInfo = parsedEpisodeInfo, - // Path = file.Path, - // Quality = file.Quality, - // Series = series, - // Size = 0 - // }; - - // //TODO: Cleanup non-tracked downloads - - // var importDecision = new ImportDecision(localEpisode); - - // if (file.DownloadId.IsNullOrWhiteSpace()) - // { - // imported.AddRange(_importApprovedEpisodes.Import(new List { importDecision }, !existingFile, null, message.ImportMode)); - // } - - // else - // { - // var trackedDownload = _trackedDownloadService.Find(file.DownloadId); - // var importResult = _importApprovedEpisodes.Import(new List { importDecision }, true, trackedDownload.DownloadItem, message.ImportMode).First(); - - // imported.Add(importResult); - - // importedTrackedDownload.Add(new ManuallyImportedFile - // { - // TrackedDownload = trackedDownload, - // ImportResult = importResult - // }); - // } - // } - - // _logger.ProgressTrace("Manually imported {0} files", imported.Count); - - // foreach (var groupedTrackedDownload in importedTrackedDownload.GroupBy(i => i.TrackedDownload.DownloadItem.DownloadId).ToList()) - // { - // var trackedDownload = groupedTrackedDownload.First().TrackedDownload; - - // if (_diskProvider.FolderExists(trackedDownload.DownloadItem.OutputPath.FullPath)) - // { - // if (_downloadedEpisodesImportService.ShouldDeleteFolder( - // new DirectoryInfo(trackedDownload.DownloadItem.OutputPath.FullPath), - // trackedDownload.RemoteEpisode.Series) && !trackedDownload.DownloadItem.IsReadOnly) - // { - // _diskProvider.DeleteFolder(trackedDownload.DownloadItem.OutputPath.FullPath, true); - // } - // } - - // if (groupedTrackedDownload.Select(c => c.ImportResult).Count(c => c.Result == ImportResultType.Imported) >= Math.Max(1, trackedDownload.RemoteEpisode.Episodes.Count)) - // { - // trackedDownload.State = TrackedDownloadStage.Imported; - // _eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload)); - // } - // } - //} } } diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManuallyImportedFile.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManuallyImportedFile.cs similarity index 79% rename from src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManuallyImportedFile.cs rename to src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManuallyImportedFile.cs index 32f904e4d..a6925ecb6 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManuallyImportedFile.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManuallyImportedFile.cs @@ -1,6 +1,6 @@ using NzbDrone.Core.Download.TrackedDownloads; -namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual +namespace NzbDrone.Core.MediaFiles.MovieImport.Manual { public class ManuallyImportedFile { diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecification.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/FreeSpaceSpecification.cs similarity index 57% rename from src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecification.cs rename to src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/FreeSpaceSpecification.cs index 7db4624ee..6b484c4c3 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/FreeSpaceSpecification.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using NLog; using NzbDrone.Common.Disk; @@ -7,7 +7,7 @@ using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications +namespace NzbDrone.Core.MediaFiles.MovieImport.Specifications { public class FreeSpaceSpecification : IImportDecisionEngineSpecification { @@ -22,49 +22,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications _logger = logger; } - public Decision IsSatisfiedBy(LocalEpisode localEpisode) - { - if (_configService.SkipFreeSpaceCheckWhenImporting) - { - _logger.Debug("Skipping free space check when importing"); - return Decision.Accept(); - } - - try - { - if (localEpisode.ExistingFile) - { - _logger.Debug("Skipping free space check for existing episode"); - return Decision.Accept(); - } - - var path = Directory.GetParent(localEpisode.Series.Path); - var freeSpace = _diskProvider.GetAvailableSpace(path.FullName); - - if (!freeSpace.HasValue) - { - _logger.Debug("Free space check returned an invalid result for: {0}", path); - return Decision.Accept(); - } - - if (freeSpace < localEpisode.Size + 100.Megabytes()) - { - _logger.Warn("Not enough free space ({0}) to import: {1} ({2})", freeSpace, localEpisode, localEpisode.Size); - return Decision.Reject("Not enough free space"); - } - } - catch (DirectoryNotFoundException ex) - { - _logger.Error("Unable to check free disk space while importing. " + ex.Message); - } - catch (Exception ex) - { - _logger.Error(ex, "Unable to check free disk space while importing: " + localEpisode.Path); - } - - return Decision.Accept(); - } - public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem) { if (_configService.SkipFreeSpaceCheckWhenImporting) @@ -77,7 +34,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications { if (localMovie.ExistingFile) { - _logger.Debug("Skipping free space check for existing episode"); + _logger.Debug("Skipping free space check for existing movie"); return Decision.Accept(); } diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/GrabbedReleaseQualitySpecification.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/GrabbedReleaseQualitySpecification.cs similarity index 58% rename from src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/GrabbedReleaseQualitySpecification.cs rename to src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/GrabbedReleaseQualitySpecification.cs index 73f282e30..9e496bed3 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/GrabbedReleaseQualitySpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/GrabbedReleaseQualitySpecification.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Core.DecisionEngine; @@ -7,7 +7,7 @@ using NzbDrone.Core.History; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; -namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications +namespace NzbDrone.Core.MediaFiles.MovieImport.Specifications { public class GrabbedReleaseQualitySpecification : IImportDecisionEngineSpecification { @@ -20,19 +20,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications _historyService = historyService; } - public Decision IsSatisfiedBy(LocalEpisode localEpisode) - { - var qualityComparer = new QualityModelComparer(localEpisode.Series.Profile); - if (localEpisode.Episodes.Any(e => e.EpisodeFileId != 0 && qualityComparer.Compare(e.EpisodeFile.Value.Quality, localEpisode.Quality) > 0)) - { - _logger.Debug("This file isn't an upgrade for all episodes. Skipping {0}", localEpisode.Path); - return Decision.Reject("Not an upgrade for existing episode file(s)"); - } - - return Decision.Accept(); - } - - public Decision IsSatisfiedBy(LocalMovie localEpisode, DownloadClientItem downloadClientItem) + public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem) { if (downloadClientItem == null) { @@ -50,19 +38,13 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications return Decision.Accept(); } - var parsedReleaseName = Parser.Parser.ParseTitle(grabbedHistory.First().SourceTitle); - - if (parsedReleaseName != null && parsedReleaseName.FullSeason) - { - _logger.Debug("File is part of a season pack, skipping."); - return Decision.Accept(); - } + var parsedReleaseName = Parser.Parser.ParseMovieTitle(grabbedHistory.First().SourceTitle,false); foreach (var item in grabbedHistory) { - if (item.Quality.Quality != Quality.Unknown && item.Quality != localEpisode.Quality) + if (item.Quality.Quality != Quality.Unknown && item.Quality != localMovie.Quality) { - _logger.Debug("Quality for grabbed release ({0}) does not match the quality of the file ({1})", item.Quality, localEpisode.Quality); + _logger.Debug("Quality for grabbed release ({0}) does not match the quality of the file ({1})", item.Quality, localMovie.Quality); return Decision.Reject("File quality does not match quality of the grabbed release"); } } diff --git a/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/MatchesFolderSpecification.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/MatchesFolderSpecification.cs new file mode 100644 index 000000000..59e9eb1a3 --- /dev/null +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/MatchesFolderSpecification.cs @@ -0,0 +1,44 @@ +using System; +using System.IO; +using System.Linq; +using NLog; +using NzbDrone.Core.DecisionEngine; +using NzbDrone.Core.Download; +using NzbDrone.Core.Parser.Model; + +namespace NzbDrone.Core.MediaFiles.MovieImport.Specifications +{ + public class MatchesFolderSpecification : IImportDecisionEngineSpecification + { + private readonly Logger _logger; + + public MatchesFolderSpecification(Logger logger) + { + _logger = logger; + } + + public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem) + { + if (localMovie.ExistingFile) + { + return Decision.Accept(); + } + + var dirInfo = new FileInfo(localMovie.Path).Directory; + + if (dirInfo == null) + { + return Decision.Accept(); + } + + var folderInfo = Parser.Parser.ParseMovieTitle(dirInfo.Name, false); + + if (folderInfo == null) + { + return Decision.Accept(); + } + + return Decision.Accept(); + } + } +} diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotSampleSpecification.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/NotSampleSpecification.cs similarity index 56% rename from src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotSampleSpecification.cs rename to src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/NotSampleSpecification.cs index 4846f4421..eee42c7e7 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotSampleSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/NotSampleSpecification.cs @@ -1,9 +1,9 @@ -using NLog; +using NLog; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications +namespace NzbDrone.Core.MediaFiles.MovieImport.Specifications { public class NotSampleSpecification : IImportDecisionEngineSpecification { @@ -17,28 +17,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications _logger = logger; } - public Decision IsSatisfiedBy(LocalEpisode localEpisode) - { - if (localEpisode.ExistingFile) - { - _logger.Debug("Existing file, skipping sample check"); - return Decision.Accept(); - } - - var sample = _detectSample.IsSample(localEpisode.Series, - localEpisode.Quality, - localEpisode.Path, - localEpisode.Size, - localEpisode.IsSpecial); - - if (sample) - { - return Decision.Reject("Sample"); - } - - return Decision.Accept(); - } - public Decision IsSatisfiedBy(LocalMovie localEpisode, DownloadClientItem downloadClientItem) { var sample = _detectSample.IsSample(localEpisode.Movie, diff --git a/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/NotUnpackingSpecification.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/NotUnpackingSpecification.cs new file mode 100644 index 000000000..92921f530 --- /dev/null +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/NotUnpackingSpecification.cs @@ -0,0 +1,61 @@ +using System; +using System.IO; +using NLog; +using NzbDrone.Common.Disk; +using NzbDrone.Common.EnvironmentInfo; +using NzbDrone.Core.Configuration; +using NzbDrone.Core.DecisionEngine; +using NzbDrone.Core.Download; +using NzbDrone.Core.Parser.Model; + +namespace NzbDrone.Core.MediaFiles.MovieImport.Specifications +{ + public class NotUnpackingSpecification : IImportDecisionEngineSpecification + { + private readonly IDiskProvider _diskProvider; + private readonly IConfigService _configService; + private readonly Logger _logger; + + public NotUnpackingSpecification(IDiskProvider diskProvider, IConfigService configService, Logger logger) + { + _diskProvider = diskProvider; + _configService = configService; + _logger = logger; + } + + public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem) + { + if (localMovie.ExistingFile) + { + _logger.Debug("{0} is in movie folder, skipping unpacking check", localMovie.Path); + return Decision.Accept(); + } + + foreach (var workingFolder in _configService.DownloadClientWorkingFolders.Split('|')) + { + DirectoryInfo parent = Directory.GetParent(localMovie.Path); + while (parent != null) + { + if (parent.Name.StartsWith(workingFolder)) + { + if (OsInfo.IsNotWindows) + { + _logger.Debug("{0} is still being unpacked", localMovie.Path); + return Decision.Reject("File is still being unpacked"); + } + + if (_diskProvider.FileGetLastWrite(localMovie.Path) > DateTime.UtcNow.AddMinutes(-5)) + { + _logger.Debug("{0} appears to be unpacking still", localMovie.Path); + return Decision.Reject("File is still being unpacked"); + } + } + + parent = parent.Parent; + } + } + + return Decision.Accept(); + } + } +} diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/SameFileSpecification.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/SameFileSpecification.cs similarity index 84% rename from src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/SameFileSpecification.cs rename to src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/SameFileSpecification.cs index 7eeb93684..fdcba98de 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/SameFileSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/SameFileSpecification.cs @@ -4,7 +4,7 @@ using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications +namespace NzbDrone.Core.MediaFiles.MovieImport.Specifications { public class SameFileSpecification : IImportDecisionEngineSpecification { @@ -15,11 +15,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications _logger = logger; } - public Decision IsSatisfiedBy(LocalEpisode localEpisode) - { - return Decision.Accept(); - } - public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem) { var movieFile = localMovie.Movie.MovieFile; diff --git a/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/UnverifiedSceneNumberingSpecification.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/UnverifiedSceneNumberingSpecification.cs new file mode 100644 index 000000000..dc3c22b53 --- /dev/null +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/UnverifiedSceneNumberingSpecification.cs @@ -0,0 +1,23 @@ +using System; +using System.Linq; +using NLog; +using NzbDrone.Core.DecisionEngine; +using NzbDrone.Core.Download; +using NzbDrone.Core.Parser.Model; +namespace NzbDrone.Core.MediaFiles.MovieImport.Specifications +{ + public class UnverifiedSceneNumberingSpecification : IImportDecisionEngineSpecification + { + private readonly Logger _logger; + + public UnverifiedSceneNumberingSpecification(Logger logger) + { + _logger = logger; + } + + public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem) + { + return Decision.Accept(); + } + } +} diff --git a/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/UpgradeSpecification.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/UpgradeSpecification.cs new file mode 100644 index 000000000..00ed8d649 --- /dev/null +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/UpgradeSpecification.cs @@ -0,0 +1,24 @@ +using System.Linq; +using NLog; +using NzbDrone.Core.DecisionEngine; +using NzbDrone.Core.Download; +using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Qualities; + +namespace NzbDrone.Core.MediaFiles.MovieImport.Specifications +{ + public class UpgradeSpecification : IImportDecisionEngineSpecification + { + private readonly Logger _logger; + + public UpgradeSpecification(Logger logger) + { + _logger = logger; + } + + public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem) + { + return Decision.Accept(); + } + } +} diff --git a/src/NzbDrone.Core/MediaFiles/RecycleBinProvider.cs b/src/NzbDrone.Core/MediaFiles/RecycleBinProvider.cs index c30069e04..3dc174115 100644 --- a/src/NzbDrone.Core/MediaFiles/RecycleBinProvider.cs +++ b/src/NzbDrone.Core/MediaFiles/RecycleBinProvider.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using NLog; using NzbDrone.Common.Disk; @@ -8,7 +8,7 @@ using NzbDrone.Core.Configuration; using NzbDrone.Core.MediaFiles.Commands; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Tv.Events; +using NzbDrone.Core.Movies.Events; namespace NzbDrone.Core.MediaFiles { @@ -20,7 +20,7 @@ namespace NzbDrone.Core.MediaFiles void Cleanup(); } - public class RecycleBinProvider : IHandleAsync, IExecute, IRecycleBinProvider, IHandleAsync + public class RecycleBinProvider : IExecute, IRecycleBinProvider, IHandleAsync { private readonly IDiskTransferService _diskTransferService; private readonly IDiskProvider _diskProvider; @@ -190,17 +190,6 @@ namespace NzbDrone.Core.MediaFiles _logger.Debug("Recycling Bin has been cleaned up."); } - public void HandleAsync(SeriesDeletedEvent message) - { - if (message.DeleteFiles) - { - if (_diskProvider.FolderExists(message.Series.Path)) - { - DeleteFolder(message.Series.Path); - } - } - } - public void HandleAsync(MovieDeletedEvent message) { if (message.DeleteFiles) diff --git a/src/NzbDrone.Core/MediaFiles/RenameEpisodeFilePreview.cs b/src/NzbDrone.Core/MediaFiles/RenameEpisodeFilePreview.cs deleted file mode 100644 index 72ba4b247..000000000 --- a/src/NzbDrone.Core/MediaFiles/RenameEpisodeFilePreview.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Collections.Generic; - -namespace NzbDrone.Core.MediaFiles -{ - public class RenameEpisodeFilePreview - { - public int SeriesId { get; set; } - public int SeasonNumber { get; set; } - public List EpisodeNumbers { get; set; } - public int EpisodeFileId { get; set; } - public string ExistingPath { get; set; } - public string NewPath { get; set; } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/RenameEpisodeFileService.cs b/src/NzbDrone.Core/MediaFiles/RenameEpisodeFileService.cs deleted file mode 100644 index 5bde0cab6..000000000 --- a/src/NzbDrone.Core/MediaFiles/RenameEpisodeFileService.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.Organizer; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.MediaFiles -{ - public interface IRenameEpisodeFileService - { - List GetRenamePreviews(int seriesId); - List GetRenamePreviews(int seriesId, int seasonNumber); - } - - public class RenameEpisodeFileService : IRenameEpisodeFileService, - IExecute, - IExecute - { - private readonly ISeriesService _seriesService; - private readonly IMediaFileService _mediaFileService; - private readonly IMoveEpisodeFiles _episodeFileMover; - private readonly IEventAggregator _eventAggregator; - private readonly IEpisodeService _episodeService; - private readonly IBuildFileNames _filenameBuilder; - private readonly IDiskProvider _diskProvider; - private readonly Logger _logger; - - public RenameEpisodeFileService(ISeriesService seriesService, - IMediaFileService mediaFileService, - IMoveEpisodeFiles episodeFileMover, - IEventAggregator eventAggregator, - IEpisodeService episodeService, - IBuildFileNames filenameBuilder, - IDiskProvider diskProvider, - Logger logger) - { - _seriesService = seriesService; - _mediaFileService = mediaFileService; - _episodeFileMover = episodeFileMover; - _eventAggregator = eventAggregator; - _episodeService = episodeService; - _filenameBuilder = filenameBuilder; - _diskProvider = diskProvider; - _logger = logger; - } - - public List GetRenamePreviews(int seriesId) - { - var series = _seriesService.GetSeries(seriesId); - var episodes = _episodeService.GetEpisodeBySeries(seriesId); - var files = _mediaFileService.GetFilesBySeries(seriesId); - - return GetPreviews(series, episodes, files) - .OrderByDescending(e => e.SeasonNumber) - .ThenByDescending(e => e.EpisodeNumbers.First()) - .ToList(); - } - - public List GetRenamePreviews(int seriesId, int seasonNumber) - { - var series = _seriesService.GetSeries(seriesId); - var episodes = _episodeService.GetEpisodesBySeason(seriesId, seasonNumber); - var files = _mediaFileService.GetFilesBySeason(seriesId, seasonNumber); - - return GetPreviews(series, episodes, files) - .OrderByDescending(e => e.EpisodeNumbers.First()).ToList(); - } - - private IEnumerable GetPreviews(Series series, List episodes, List files) - { - foreach (var f in files) - { - var file = f; - var episodesInFile = episodes.Where(e => e.EpisodeFileId == file.Id).ToList(); - var episodeFilePath = Path.Combine(series.Path, file.RelativePath); - - if (!episodesInFile.Any()) - { - _logger.Warn("File ({0}) is not linked to any episodes", episodeFilePath); - continue; - } - - var seasonNumber = episodesInFile.First().SeasonNumber; - var newName = _filenameBuilder.BuildFileName(episodesInFile, series, file); - var newPath = _filenameBuilder.BuildFilePath(series, seasonNumber, newName, Path.GetExtension(episodeFilePath)); - - if (!episodeFilePath.PathEquals(newPath, StringComparison.Ordinal)) - { - yield return new RenameEpisodeFilePreview - { - SeriesId = series.Id, - SeasonNumber = seasonNumber, - EpisodeNumbers = episodesInFile.Select(e => e.EpisodeNumber).ToList(), - EpisodeFileId = file.Id, - ExistingPath = file.RelativePath, - NewPath = series.Path.GetRelativePath(newPath) - }; - } - } - } - - private void RenameFiles(List episodeFiles, Series series) - { - var renamed = new List(); - - foreach (var episodeFile in episodeFiles) - { - var episodeFilePath = Path.Combine(series.Path, episodeFile.RelativePath); - - try - { - _logger.Debug("Renaming episode file: {0}", episodeFile); - _episodeFileMover.MoveEpisodeFile(episodeFile, series); - - _mediaFileService.Update(episodeFile); - renamed.Add(episodeFile); - - _logger.Debug("Renamed episode file: {0}", episodeFile); - } - 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: " + episodeFilePath); - } - } - - if (renamed.Any()) - { - _diskProvider.RemoveEmptySubfolders(series.Path); - - _eventAggregator.PublishEvent(new SeriesRenamedEvent(series)); - } - } - - public void Execute(RenameFilesCommand message) - { - var series = _seriesService.GetSeries(message.SeriesId); - var episodeFiles = _mediaFileService.Get(message.Files); - - _logger.ProgressInfo("Renaming {0} files for {1}", episodeFiles.Count, series.Title); - RenameFiles(episodeFiles, series); - _logger.ProgressInfo("Selected episode files renamed for {0}", series.Title); - } - - public void Execute(RenameSeriesCommand message) - { - _logger.Debug("Renaming all files for selected series"); - var seriesToRename = _seriesService.GetSeries(message.SeriesIds); - - foreach (var series in seriesToRename) - { - var episodeFiles = _mediaFileService.GetFilesBySeries(series.Id); - _logger.ProgressInfo("Renaming all files in series: {0}", series.Title); - RenameFiles(episodeFiles, series); - _logger.ProgressInfo("All episode files renamed for {0}", series.Title); - } - } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/RenameMovieFileService.cs b/src/NzbDrone.Core/MediaFiles/RenameMovieFileService.cs index c32df8487..ed9050f04 100644 --- a/src/NzbDrone.Core/MediaFiles/RenameMovieFileService.cs +++ b/src/NzbDrone.Core/MediaFiles/RenameMovieFileService.cs @@ -13,7 +13,7 @@ using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; using NzbDrone.Common.Instrumentation.Extensions; using NzbDrone.Core.Organizer; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Configuration; namespace NzbDrone.Core.MediaFiles diff --git a/src/NzbDrone.Core/MediaFiles/UpdateEpisodeFileService.cs b/src/NzbDrone.Core/MediaFiles/UpdateEpisodeFileService.cs deleted file mode 100644 index f6589f554..000000000 --- a/src/NzbDrone.Core/MediaFiles/UpdateEpisodeFileService.cs +++ /dev/null @@ -1,175 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using NLog; -using NzbDrone.Common.Disk; -using NzbDrone.Common.Exceptron; -using NzbDrone.Common.Extensions; -using NzbDrone.Common.Instrumentation.Extensions; -using NzbDrone.Core.Configuration; -using NzbDrone.Core.MediaFiles.Events; -using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.MediaFiles -{ - public interface IUpdateEpisodeFileService - { - void ChangeFileDateForFile(EpisodeFile episodeFile, Series series, List episodes); - } - - public class UpdateEpisodeFileService : IUpdateEpisodeFileService, - IHandle - { - private readonly IDiskProvider _diskProvider; - private readonly IConfigService _configService; - private readonly IEpisodeService _episodeService; - private readonly Logger _logger; - - public UpdateEpisodeFileService(IDiskProvider diskProvider, - IConfigService configService, - IEpisodeService episodeService, - Logger logger) - { - _diskProvider = diskProvider; - _configService = configService; - _episodeService = episodeService; - _logger = logger; - } - - public void ChangeFileDateForFile(EpisodeFile episodeFile, Series series, List episodes) - { - ChangeFileDate(episodeFile, series, episodes); - } - - private bool ChangeFileDate(EpisodeFile episodeFile, Series series, List episodes) - { - var episodeFilePath = Path.Combine(series.Path, episodeFile.RelativePath); - - switch (_configService.FileDate) - { - case FileDateType.Release: - { - var airDate = episodes.First().AirDate; - var airTime = series.AirTime; - - if (airDate.IsNullOrWhiteSpace() || airTime.IsNullOrWhiteSpace()) - { - return false; - } - - return ChangeFileDateToLocalAirDate(episodeFilePath, airDate, airTime); - } - - case FileDateType.Cinemas: - { - var airDateUtc = episodes.First().AirDateUtc; - - if (!airDateUtc.HasValue) - { - return false; - } - - return ChangeFileDateToUtcAirDate(episodeFilePath, airDateUtc.Value); - } - } - - return false; - } - - public void Handle(SeriesScannedEvent message) - { - if (_configService.FileDate == FileDateType.None) - { - return; - } - - var episodes = _episodeService.EpisodesWithFiles(message.Series.Id); - - var episodeFiles = new List(); - var updated = new List(); - - foreach (var group in episodes.GroupBy(e => e.EpisodeFileId)) - { - var episodesInFile = group.Select(e => e).ToList(); - var episodeFile = episodesInFile.First().EpisodeFile; - - episodeFiles.Add(episodeFile); - - if (ChangeFileDate(episodeFile, message.Series, episodesInFile)) - { - updated.Add(episodeFile); - } - } - - if (updated.Any()) - { - _logger.ProgressDebug("Changed file date for {0} files of {1} in {2}", updated.Count, episodeFiles.Count, message.Series.Title); - } - - else - { - _logger.ProgressDebug("No file dates changed for {0}", message.Series.Title); - } - } - - private bool ChangeFileDateToLocalAirDate(string filePath, string fileDate, string fileTime) - { - DateTime airDate; - - if (DateTime.TryParse(fileDate + ' ' + fileTime, out airDate)) - { - // avoiding false +ve checks and set date skewing by not using UTC (Windows) - DateTime oldDateTime = _diskProvider.FileGetLastWrite(filePath); - - if (!DateTime.Equals(airDate, oldDateTime)) - { - try - { - _diskProvider.FileSetLastWriteTime(filePath, airDate); - _logger.Debug("Date of file [{0}] changed from '{1}' to '{2}'", filePath, oldDateTime, airDate); - - return true; - } - - catch (Exception ex) - { - _logger.Warn(ex, "Unable to set date of file [" + filePath + "]"); - } - } - } - - else - { - _logger.Debug("Could not create valid date to change file [{0}]", filePath); - } - - return false; - } - - private bool ChangeFileDateToUtcAirDate(string filePath, DateTime airDateUtc) - { - DateTime oldLastWrite = _diskProvider.FileGetLastWrite(filePath); - - if (!DateTime.Equals(airDateUtc, oldLastWrite)) - { - try - { - _diskProvider.FileSetLastWriteTime(filePath, airDateUtc); - _logger.Debug("Date of file [{0}] changed from '{1}' to '{2}'", filePath, oldLastWrite, airDateUtc); - - return true; - } - - catch (Exception ex) - { - ex.ExceptronIgnoreOnMono(); - _logger.Warn(ex, "Unable to set date of file [" + filePath + "]"); - } - } - - return false; - } - } -} diff --git a/src/NzbDrone.Core/MediaFiles/UpdateMovieFileService.cs b/src/NzbDrone.Core/MediaFiles/UpdateMovieFileService.cs index a75679a31..b7b9c7d00 100644 --- a/src/NzbDrone.Core/MediaFiles/UpdateMovieFileService.cs +++ b/src/NzbDrone.Core/MediaFiles/UpdateMovieFileService.cs @@ -10,7 +10,7 @@ using NzbDrone.Common.Instrumentation.Extensions; using NzbDrone.Core.Configuration; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.MediaFiles { diff --git a/src/NzbDrone.Core/MediaFiles/UpgradeMediaFileService.cs b/src/NzbDrone.Core/MediaFiles/UpgradeMediaFileService.cs index 4944b1f5f..c9969deb7 100644 --- a/src/NzbDrone.Core/MediaFiles/UpgradeMediaFileService.cs +++ b/src/NzbDrone.Core/MediaFiles/UpgradeMediaFileService.cs @@ -1,4 +1,4 @@ -using System.IO; +using System.IO; using System.Linq; using NLog; using NzbDrone.Common.Disk; @@ -8,7 +8,6 @@ namespace NzbDrone.Core.MediaFiles { public interface IUpgradeMediaFiles { - EpisodeFileMoveResult UpgradeEpisodeFile(EpisodeFile episodeFile, LocalEpisode localEpisode, bool copyOnly = false); MovieFileMoveResult UpgradeMovieFile(MovieFile movieFile, LocalMovie localMovie, bool copyOnly = false); } @@ -16,7 +15,6 @@ namespace NzbDrone.Core.MediaFiles { private readonly IRecycleBinProvider _recycleBinProvider; private readonly IMediaFileService _mediaFileService; - private readonly IMoveEpisodeFiles _episodeFileMover; private readonly IMoveMovieFiles _movieFileMover; private readonly IRenameMovieFileService _movieFileRenamer; private readonly IDiskProvider _diskProvider; @@ -24,18 +22,16 @@ namespace NzbDrone.Core.MediaFiles public UpgradeMediaFileService(IRecycleBinProvider recycleBinProvider, IMediaFileService mediaFileService, - IMoveEpisodeFiles episodeFileMover, IMoveMovieFiles movieFileMover, IDiskProvider diskProvider, - IRenameMovieFileService movieFileRenamer, + IRenameMovieFileService movieFileRenamer, Logger logger) { _recycleBinProvider = recycleBinProvider; _mediaFileService = mediaFileService; - _episodeFileMover = episodeFileMover; _movieFileMover = movieFileMover; _diskProvider = diskProvider; - _movieFileRenamer = movieFileRenamer; + _movieFileRenamer = movieFileRenamer; _logger = logger; } @@ -77,40 +73,5 @@ namespace NzbDrone.Core.MediaFiles return moveFileResult; } - - public EpisodeFileMoveResult UpgradeEpisodeFile(EpisodeFile episodeFile, LocalEpisode localEpisode, bool copyOnly = false) - { - var moveFileResult = new EpisodeFileMoveResult(); - var existingFiles = localEpisode.Episodes - .Where(e => e.EpisodeFileId > 0) - .Select(e => e.EpisodeFile.Value) - .GroupBy(e => e.Id); - - foreach (var existingFile in existingFiles) - { - var file = existingFile.First(); - var episodeFilePath = Path.Combine(localEpisode.Series.Path, file.RelativePath); - - if (_diskProvider.FileExists(episodeFilePath)) - { - _logger.Debug("Removing existing episode file: {0}", file); - _recycleBinProvider.DeleteFile(episodeFilePath); - } - - moveFileResult.OldFiles.Add(file); - _mediaFileService.Delete(file, DeleteMediaFileReason.Upgrade); - } - - if (copyOnly) - { - moveFileResult.EpisodeFile = _episodeFileMover.CopyEpisodeFile(episodeFile, localEpisode); - } - else - { - moveFileResult.EpisodeFile = _episodeFileMover.MoveEpisodeFile(episodeFile, localEpisode); - } - - return moveFileResult; - } } } diff --git a/src/NzbDrone.Core/MetadataSource/IDiscoverNewMovies.cs b/src/NzbDrone.Core/MetadataSource/IDiscoverNewMovies.cs index 108d8e1a4..46e4398f5 100644 --- a/src/NzbDrone.Core/MetadataSource/IDiscoverNewMovies.cs +++ b/src/NzbDrone.Core/MetadataSource/IDiscoverNewMovies.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.MetadataSource { diff --git a/src/NzbDrone.Core/MetadataSource/IProvideMovieInfo.cs b/src/NzbDrone.Core/MetadataSource/IProvideMovieInfo.cs index a1077f696..51727c6bf 100644 --- a/src/NzbDrone.Core/MetadataSource/IProvideMovieInfo.cs +++ b/src/NzbDrone.Core/MetadataSource/IProvideMovieInfo.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using NzbDrone.Core.Profiles; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.MetadataSource { diff --git a/src/NzbDrone.Core/MetadataSource/IProvideSeriesInfo.cs b/src/NzbDrone.Core/MetadataSource/IProvideSeriesInfo.cs deleted file mode 100644 index f2ab03336..000000000 --- a/src/NzbDrone.Core/MetadataSource/IProvideSeriesInfo.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.MetadataSource -{ - public interface IProvideSeriesInfo - { - Tuple> GetSeriesInfo(int tvdbSeriesId); - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/MetadataSource/ISearchForNewMovie.cs b/src/NzbDrone.Core/MetadataSource/ISearchForNewMovie.cs index 2a16b88af..0575ee175 100644 --- a/src/NzbDrone.Core/MetadataSource/ISearchForNewMovie.cs +++ b/src/NzbDrone.Core/MetadataSource/ISearchForNewMovie.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.MetadataSource { diff --git a/src/NzbDrone.Core/MetadataSource/ISearchForNewSeries.cs b/src/NzbDrone.Core/MetadataSource/ISearchForNewSeries.cs deleted file mode 100644 index 5abd02bcc..000000000 --- a/src/NzbDrone.Core/MetadataSource/ISearchForNewSeries.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Collections.Generic; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.MetadataSource -{ - public interface ISearchForNewSeries - { - List SearchForNewSeries(string title); - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/MetadataSource/PreDB/PreDBService.cs b/src/NzbDrone.Core/MetadataSource/PreDB/PreDBService.cs index 76b2a77b5..244430144 100644 --- a/src/NzbDrone.Core/MetadataSource/PreDB/PreDBService.cs +++ b/src/NzbDrone.Core/MetadataSource/PreDB/PreDBService.cs @@ -12,7 +12,7 @@ using NzbDrone.Core.Indexers; using System.ServiceModel.Syndication; using System.Xml; using NzbDrone.Common.Http; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using System; using System.IO; using NzbDrone.Core.Parser; diff --git a/src/NzbDrone.Core/MetadataSource/PreDB/PreDBSyncEvent.cs b/src/NzbDrone.Core/MetadataSource/PreDB/PreDBSyncEvent.cs index 09fbe759a..a6f7e2c2e 100644 --- a/src/NzbDrone.Core/MetadataSource/PreDB/PreDBSyncEvent.cs +++ b/src/NzbDrone.Core/MetadataSource/PreDB/PreDBSyncEvent.cs @@ -3,7 +3,7 @@ using NzbDrone.Core.Download; using System; using System.Linq; using System.Collections.Generic; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.MetadataSource.PreDB { diff --git a/src/NzbDrone.Core/MetadataSource/SearchSeriesComparer.cs b/src/NzbDrone.Core/MetadataSource/SearchMovieComparer.cs similarity index 89% rename from src/NzbDrone.Core/MetadataSource/SearchSeriesComparer.cs rename to src/NzbDrone.Core/MetadataSource/SearchMovieComparer.cs index 05d9a1223..c5a6085c4 100644 --- a/src/NzbDrone.Core/MetadataSource/SearchSeriesComparer.cs +++ b/src/NzbDrone.Core/MetadataSource/SearchMovieComparer.cs @@ -1,12 +1,12 @@ -using System; +using System; using System.Collections.Generic; using System.Text.RegularExpressions; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.MetadataSource { - public class SearchSeriesComparer : IComparer + public class SearchMovieComparer : IComparer { 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 SearchSeriesComparer(string searchQuery) + public SearchMovieComparer(string searchQuery) { SearchQuery = searchQuery; @@ -33,7 +33,7 @@ namespace NzbDrone.Core.MetadataSource } } - public int Compare(Series x, Series y) + public int Compare(Movie x, Movie y) { int result = 0; @@ -60,7 +60,7 @@ namespace NzbDrone.Core.MetadataSource return Compare(x, y, s => SearchQuery.LevenshteinDistanceClean(s.Title) - GetYearFactor(s)); } - public int Compare(Series x, Series y, Func keySelector) + public int Compare(Movie x, Movie y, Func keySelector) where T : IComparable { var keyX = keySelector(x); @@ -69,7 +69,7 @@ namespace NzbDrone.Core.MetadataSource return keyX.CompareTo(keyY); } - public int CompareWithYear(Series x, Series y, Predicate canMatch) + public int CompareWithYear(Movie x, Movie y, Predicate canMatch) { var matchX = canMatch(x); var matchY = canMatch(y); @@ -110,11 +110,11 @@ namespace NzbDrone.Core.MetadataSource return title.Trim().ToLowerInvariant(); } - private int GetYearFactor(Series series) + private int GetYearFactor(Movie movie) { if (_year.HasValue) { - var offset = Math.Abs(series.Year - _year.Value); + var offset = Math.Abs(movie.Year - _year.Value); if (offset <= 1) { return 20 - 10 * offset; diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index aca197e75..dc0ad51f6 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Net; @@ -12,7 +12,7 @@ using NzbDrone.Core.MediaCover; using NzbDrone.Core.MetadataSource.SkyHook.Resource; using NzbDrone.Core.MetadataSource; using NzbDrone.Core.MetadataSource.PreDB; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using System.Threading; using NzbDrone.Core.Parser; using NzbDrone.Core.Profiles; @@ -24,7 +24,7 @@ using NzbDrone.Core.MetadataSource.RadarrAPI; namespace NzbDrone.Core.MetadataSource.SkyHook { - public class SkyHookProxy : IProvideSeriesInfo, ISearchForNewSeries, IProvideMovieInfo, ISearchForNewMovie, IDiscoverNewMovies + public class SkyHookProxy : IProvideMovieInfo, ISearchForNewMovie, IDiscoverNewMovies { private readonly IHttpClient _httpClient; private readonly Logger _logger; @@ -56,36 +56,6 @@ namespace NzbDrone.Core.MetadataSource.SkyHook _logger = logger; } - public Tuple> GetSeriesInfo(int tvdbSeriesId) - { - var httpRequest = _requestBuilder.Create() - .SetSegment("route", "shows") - .Resource(tvdbSeriesId.ToString()) - .Build(); - - httpRequest.AllowAutoRedirect = true; - httpRequest.SuppressHttpError = true; - - var httpResponse = _httpClient.Get(httpRequest); - - if (httpResponse.HasHttpError) - { - if (httpResponse.StatusCode == HttpStatusCode.NotFound) - { - throw new SeriesNotFoundException(tvdbSeriesId); - } - else - { - throw new HttpException(httpRequest, httpResponse); - } - } - - var episodes = httpResponse.Resource.Episodes.Select(MapEpisode); - var series = MapSeries(httpResponse.Resource); - - return new Tuple>(series, episodes.ToList()); - } - public Movie GetMovieInfo(int TmdbId, Profile profile = null, bool hasPreDBEntry = false) { var langCode = profile != null ? IsoLanguages.Get(profile.Language).TwoLetterCode : "en"; @@ -463,7 +433,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook { return new List { GetMovieInfo(imdbid) }; } - catch (SeriesNotFoundException) + catch (MovieNotFoundException) { return new List(); } @@ -508,57 +478,6 @@ namespace NzbDrone.Core.MetadataSource.SkyHook return movieResults.SelectList(MapMovie); } - public List SearchForNewSeries(string title) - { - try - { - var lowerTitle = title.ToLowerInvariant(); - - if (lowerTitle.StartsWith("tvdb:") || lowerTitle.StartsWith("tvdbid:")) - { - var slug = lowerTitle.Split(':')[1].Trim(); - - int tvdbId; - - if (slug.IsNullOrWhiteSpace() || slug.Any(char.IsWhiteSpace) || !int.TryParse(slug, out tvdbId) || tvdbId <= 0) - { - return new List(); - } - - try - { - return new List { GetSeriesInfo(tvdbId).Item1 }; - } - catch (SeriesNotFoundException) - { - return new List(); - } - } - - - - var httpRequest = _requestBuilder.Create() - .SetSegment("route", "search") - .AddQueryParam("term", title.ToLower().Trim()) - .Build(); - - - - var httpResponse = _httpClient.Get>(httpRequest); - - return httpResponse.Resource.SelectList(MapSeries); - } - catch (HttpException) - { - throw new SkyHookException("Search for '{0}' failed. Unable to communicate with SkyHook.", title); - } - catch (Exception ex) - { - _logger.Warn(ex, ex.Message); - throw new SkyHookException("Search for '{0}' failed. Invalid response received from SkyHook.", title); - } - } - public Movie MapMovie(MovieResult result) { var imdbMovie = new Movie(); @@ -661,63 +580,6 @@ namespace NzbDrone.Core.MetadataSource.SkyHook return null; } - private static Series MapSeries(ShowResource show) - { - var series = new Series(); - series.TvdbId = show.TvdbId; - - if (show.TvRageId.HasValue) - { - series.TvRageId = show.TvRageId.Value; - } - - if (show.TvMazeId.HasValue) - { - series.TvMazeId = show.TvMazeId.Value; - } - - series.ImdbId = show.ImdbId; - series.Title = show.Title; - series.CleanTitle = Parser.Parser.CleanSeriesTitle(show.Title); - series.SortTitle = SeriesTitleNormalizer.Normalize(show.Title, show.TvdbId); - - if (show.FirstAired != null) - { - series.FirstAired = DateTime.Parse(show.FirstAired).ToUniversalTime(); - series.Year = series.FirstAired.Value.Year; - } - - series.Overview = show.Overview; - - if (show.Runtime != null) - { - series.Runtime = show.Runtime.Value; - } - - series.Network = show.Network; - - if (show.TimeOfDay != null) - { - series.AirTime = string.Format("{0:00}:{1:00}", show.TimeOfDay.Hours, show.TimeOfDay.Minutes); - } - - series.TitleSlug = show.Slug; - series.Status = MapSeriesStatus(show.Status); - series.Ratings = MapRatings(show.Rating); - series.Genres = show.Genres; - - if (show.ContentRating.IsNotNullOrWhiteSpace()) - { - series.Certification = show.ContentRating.ToUpper(); - } - - series.Actors = show.Actors.Select(MapActors).ToList(); - series.Seasons = show.Seasons.Select(MapSeason).ToList(); - series.Images = show.Images.Select(MapImage).ToList(); - - return series; - } - private static Actor MapActors(ActorResource arg) { var newActor = new Actor @@ -737,48 +599,6 @@ namespace NzbDrone.Core.MetadataSource.SkyHook return newActor; } - private static Episode MapEpisode(EpisodeResource oracleEpisode) - { - var episode = new Episode(); - episode.Overview = oracleEpisode.Overview; - episode.SeasonNumber = oracleEpisode.SeasonNumber; - episode.EpisodeNumber = oracleEpisode.EpisodeNumber; - episode.AbsoluteEpisodeNumber = oracleEpisode.AbsoluteEpisodeNumber; - episode.Title = oracleEpisode.Title; - - episode.AirDate = oracleEpisode.AirDate; - episode.AirDateUtc = oracleEpisode.AirDateUtc; - - episode.Ratings = MapRatings(oracleEpisode.Rating); - - //Don't include series fanart images as episode screenshot - if (oracleEpisode.Image != null) - { - episode.Images.Add(new MediaCover.MediaCover(MediaCoverTypes.Screenshot, oracleEpisode.Image)); - } - - return episode; - } - - private static Season MapSeason(SeasonResource seasonResource) - { - return new Season - { - SeasonNumber = seasonResource.SeasonNumber, - Images = seasonResource.Images.Select(MapImage).ToList() - }; - } - - private static SeriesStatusType MapSeriesStatus(string status) - { - if (status.Equals("ended", StringComparison.InvariantCultureIgnoreCase)) - { - return SeriesStatusType.Ended; - } - - return SeriesStatusType.Continuing; - } - private static Ratings MapRatings(RatingResource rating) { if (rating == null) diff --git a/src/NzbDrone.Core/MovieStats/MovieStatistics.cs b/src/NzbDrone.Core/MovieStats/MovieStatistics.cs deleted file mode 100644 index 7ea4dabdb..000000000 --- a/src/NzbDrone.Core/MovieStats/MovieStatistics.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections.Generic; -using NzbDrone.Core.Datastore; - -namespace NzbDrone.Core.MovieStats -{ - public class MovieStatistics : ResultSet - { - public int MovieId { get; set; } - public string NextAiringString { get; set; } - public string PreviousAiringString { get; set; } - public int EpisodeFileCount { get; set; } - public int EpisodeCount { get; set; } - public int TotalEpisodeCount { get; set; } - public long SizeOnDisk { get; set; } - public List SeasonStatistics { get; set; } - - public DateTime? NextAiring - { - get - { - DateTime nextAiring; - - if (!DateTime.TryParse(NextAiringString, out nextAiring)) return null; - - return nextAiring; - } - } - - public DateTime? PreviousAiring - { - get - { - DateTime previousAiring; - - if (!DateTime.TryParse(PreviousAiringString, out previousAiring)) return null; - - return previousAiring; - } - } - } -} diff --git a/src/NzbDrone.Core/MovieStats/MovieStatisticsRepository.cs b/src/NzbDrone.Core/MovieStats/MovieStatisticsRepository.cs deleted file mode 100644 index 32950944d..000000000 --- a/src/NzbDrone.Core/MovieStats/MovieStatisticsRepository.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using NzbDrone.Core.Datastore; - -namespace NzbDrone.Core.MovieStats -{ - public interface IMovieStatisticsRepository - { - List MovieStatistics(); - List MovieStatistics(int movieId); - } - - public class MovieStatisticsRepository : IMovieStatisticsRepository - { - private readonly IMainDatabase _database; - - public MovieStatisticsRepository(IMainDatabase database) - { - _database = database; - } - - public List MovieStatistics() - { - var mapper = _database.GetDataMapper(); - - mapper.AddParameter("currentDate", DateTime.UtcNow); - - var sb = new StringBuilder(); - sb.AppendLine(GetSelectClause()); - sb.AppendLine(GetEpisodeFilesJoin()); - sb.AppendLine(GetGroupByClause()); - var queryText = sb.ToString(); - - return new List(); - - return mapper.Query(queryText); - } - - public List MovieStatistics(int movieId) - { - var mapper = _database.GetDataMapper(); - - mapper.AddParameter("currentDate", DateTime.UtcNow); - mapper.AddParameter("movieId", movieId); - - var sb = new StringBuilder(); - sb.AppendLine(GetSelectClause()); - sb.AppendLine(GetEpisodeFilesJoin()); - sb.AppendLine("WHERE Episodes.MovieId = @movieId"); - sb.AppendLine(GetGroupByClause()); - var queryText = sb.ToString(); - - return new List(); - - return mapper.Query(queryText); - } - - private string GetSelectClause() - { - return @"SELECT Episodes.*, SUM(EpisodeFiles.Size) as SizeOnDisk FROM - (SELECT - Episodes.MovieId, - Episodes.SeasonNumber, - SUM(CASE WHEN AirdateUtc <= @currentDate OR EpisodeFileId > 0 THEN 1 ELSE 0 END) AS TotalEpisodeCount, - SUM(CASE WHEN (Monitored = 1 AND AirdateUtc <= @currentDate) OR EpisodeFileId > 0 THEN 1 ELSE 0 END) AS EpisodeCount, - SUM(CASE WHEN EpisodeFileId > 0 THEN 1 ELSE 0 END) AS EpisodeFileCount, - MIN(CASE WHEN AirDateUtc < @currentDate OR EpisodeFileId > 0 OR Monitored = 0 THEN NULL ELSE AirDateUtc END) AS NextAiringString, - MAX(CASE WHEN AirDateUtc >= @currentDate OR EpisodeFileId = 0 AND Monitored = 0 THEN NULL ELSE AirDateUtc END) AS PreviousAiringString - FROM Episodes - GROUP BY Episodes.MovieId, Episodes.SeasonNumber) as Episodes"; - } - - private string GetGroupByClause() - { - return "GROUP BY Episodes.MovieId, Episodes.SeasonNumber"; - } - - private string GetEpisodeFilesJoin() - { - return @"LEFT OUTER JOIN EpisodeFiles - ON EpisodeFiles.MovieId = Episodes.MovieId - AND EpisodeFiles.SeasonNumber = Episodes.SeasonNumber"; - } - } -} diff --git a/src/NzbDrone.Core/MovieStats/MovieStatisticsService.cs b/src/NzbDrone.Core/MovieStats/MovieStatisticsService.cs deleted file mode 100644 index 68dabd609..000000000 --- a/src/NzbDrone.Core/MovieStats/MovieStatisticsService.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System.Collections.Generic; -using System.Linq; - -namespace NzbDrone.Core.MovieStats -{ - public interface IMovieStatisticsService - { - List MovieStatistics(); - MovieStatistics MovieStatistics(int movieId); - } - - public class MovieStatisticsService : IMovieStatisticsService - { - private readonly IMovieStatisticsRepository _movieStatisticsRepository; - - public MovieStatisticsService(IMovieStatisticsRepository movieStatisticsRepository) - { - _movieStatisticsRepository = movieStatisticsRepository; - } - - public List MovieStatistics() - { - var seasonStatistics = _movieStatisticsRepository.MovieStatistics(); - - return seasonStatistics.GroupBy(s => s.MovieId).Select(s => MapMovieStatistics(s.ToList())).ToList(); - } - - public MovieStatistics MovieStatistics(int movieId) - { - var stats = _movieStatisticsRepository.MovieStatistics(movieId); - - if (stats == null || stats.Count == 0) return new MovieStatistics(); - - return MapMovieStatistics(stats); - } - - private MovieStatistics MapMovieStatistics(List seasonStatistics) - { - var movieStatistics = new MovieStatistics - { - SeasonStatistics = seasonStatistics, - MovieId = seasonStatistics.First().MovieId, - EpisodeFileCount = seasonStatistics.Sum(s => s.EpisodeFileCount), - EpisodeCount = seasonStatistics.Sum(s => s.EpisodeCount), - TotalEpisodeCount = seasonStatistics.Sum(s => s.TotalEpisodeCount), - SizeOnDisk = seasonStatistics.Sum(s => s.SizeOnDisk) - }; - - var nextAiring = seasonStatistics.Where(s => s.NextAiring != null) - .OrderBy(s => s.NextAiring) - .FirstOrDefault(); - - var previousAiring = seasonStatistics.Where(s => s.PreviousAiring != null) - .OrderBy(s => s.PreviousAiring) - .LastOrDefault(); - - movieStatistics.NextAiringString = nextAiring != null ? nextAiring.NextAiringString : null; - movieStatistics.PreviousAiringString = previousAiring != null ? previousAiring.PreviousAiringString : null; - - return movieStatistics; - } - } -} diff --git a/src/NzbDrone.Core/MovieStats/SeasonStatistics.cs b/src/NzbDrone.Core/MovieStats/SeasonStatistics.cs deleted file mode 100644 index 05da073db..000000000 --- a/src/NzbDrone.Core/MovieStats/SeasonStatistics.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using NzbDrone.Core.Datastore; - -namespace NzbDrone.Core.MovieStats -{ - public class SeasonStatistics : ResultSet - { - public int MovieId { get; set; } - public int SeasonNumber { get; set; } - public string NextAiringString { get; set; } - public string PreviousAiringString { get; set; } - public int EpisodeFileCount { get; set; } - public int EpisodeCount { get; set; } - public int TotalEpisodeCount { get; set; } - public long SizeOnDisk { get; set; } - - public DateTime? NextAiring - { - get - { - DateTime nextAiring; - - if (!DateTime.TryParse(NextAiringString, out nextAiring)) return null; - - return nextAiring; - } - } - - public DateTime? PreviousAiring - { - get - { - DateTime previousAiring; - - if (!DateTime.TryParse(PreviousAiringString, out previousAiring)) return null; - - return previousAiring; - } - } - } -} diff --git a/src/NzbDrone.Core/Tv/Actor.cs b/src/NzbDrone.Core/Movies/Actor.cs similarity index 84% rename from src/NzbDrone.Core/Tv/Actor.cs rename to src/NzbDrone.Core/Movies/Actor.cs index cfc8a0bbd..c86805927 100644 --- a/src/NzbDrone.Core/Tv/Actor.cs +++ b/src/NzbDrone.Core/Movies/Actor.cs @@ -1,7 +1,7 @@ -using System.Collections.Generic; +using System.Collections.Generic; using NzbDrone.Core.Datastore; -namespace NzbDrone.Core.Tv +namespace NzbDrone.Core.Movies { public class Actor : IEmbeddedDocument { diff --git a/src/NzbDrone.Core/Movies/AddMovieOptions.cs b/src/NzbDrone.Core/Movies/AddMovieOptions.cs new file mode 100644 index 000000000..29f52abc1 --- /dev/null +++ b/src/NzbDrone.Core/Movies/AddMovieOptions.cs @@ -0,0 +1,7 @@ +namespace NzbDrone.Core.Movies +{ + public class AddMovieOptions : MonitoringOptions + { + public bool SearchForMovie { get; set; } + } +} diff --git a/src/NzbDrone.Core/Movies/AlternativeTitles/AlternativeTitle.cs b/src/NzbDrone.Core/Movies/AlternativeTitles/AlternativeTitle.cs index 75088d5d9..dea7e1388 100644 --- a/src/NzbDrone.Core/Movies/AlternativeTitles/AlternativeTitle.cs +++ b/src/NzbDrone.Core/Movies/AlternativeTitles/AlternativeTitle.cs @@ -2,7 +2,7 @@ using Marr.Data; using NzbDrone.Core.Datastore; using NzbDrone.Core.Parser; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Movies.AlternativeTitles { diff --git a/src/NzbDrone.Core/Movies/AlternativeTitles/AlternativeTitleService.cs b/src/NzbDrone.Core/Movies/AlternativeTitles/AlternativeTitleService.cs index c19b42af6..cab0522dd 100644 --- a/src/NzbDrone.Core/Movies/AlternativeTitles/AlternativeTitleService.cs +++ b/src/NzbDrone.Core/Movies/AlternativeTitles/AlternativeTitleService.cs @@ -1,15 +1,14 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; using NLog; using NzbDrone.Common.EnsureThat; using NzbDrone.Common.Extensions; -using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Organizer; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Tv.Events; +using NzbDrone.Core.Movies; +using NzbDrone.Core.Movies.Events; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Datastore; diff --git a/src/NzbDrone.Core/Tv/Commands/MoveSeriesCommand.cs b/src/NzbDrone.Core/Movies/Commands/MoveMovieCommand.cs similarity index 51% rename from src/NzbDrone.Core/Tv/Commands/MoveSeriesCommand.cs rename to src/NzbDrone.Core/Movies/Commands/MoveMovieCommand.cs index 1a283e80d..01f93283a 100644 --- a/src/NzbDrone.Core/Tv/Commands/MoveSeriesCommand.cs +++ b/src/NzbDrone.Core/Movies/Commands/MoveMovieCommand.cs @@ -1,10 +1,10 @@ -using NzbDrone.Core.Messaging.Commands; +using NzbDrone.Core.Messaging.Commands; -namespace NzbDrone.Core.Tv.Commands +namespace NzbDrone.Core.Movies.Commands { - public class MoveSeriesCommand : Command + public class MoveMovieCommand : Command { - public int SeriesId { get; set; } + public int MovieId { get; set; } public string SourcePath { get; set; } public string DestinationPath { get; set; } public string DestinationRootFolder { get; set; } diff --git a/src/NzbDrone.Core/Tv/Commands/RefreshMovieCommand.cs b/src/NzbDrone.Core/Movies/Commands/RefreshMovieCommand.cs similarity index 91% rename from src/NzbDrone.Core/Tv/Commands/RefreshMovieCommand.cs rename to src/NzbDrone.Core/Movies/Commands/RefreshMovieCommand.cs index 08c7b2e72..33a8f8a30 100644 --- a/src/NzbDrone.Core/Tv/Commands/RefreshMovieCommand.cs +++ b/src/NzbDrone.Core/Movies/Commands/RefreshMovieCommand.cs @@ -1,6 +1,6 @@ using NzbDrone.Core.Messaging.Commands; -namespace NzbDrone.Core.Tv.Commands +namespace NzbDrone.Core.Movies.Commands { public class RefreshMovieCommand : Command { diff --git a/src/NzbDrone.Core/Tv/Events/MovieAddedEvent.cs b/src/NzbDrone.Core/Movies/Events/MovieAddedEvent.cs similarity index 86% rename from src/NzbDrone.Core/Tv/Events/MovieAddedEvent.cs rename to src/NzbDrone.Core/Movies/Events/MovieAddedEvent.cs index 1559d3716..855ff43f8 100644 --- a/src/NzbDrone.Core/Tv/Events/MovieAddedEvent.cs +++ b/src/NzbDrone.Core/Movies/Events/MovieAddedEvent.cs @@ -1,6 +1,6 @@ using NzbDrone.Common.Messaging; -namespace NzbDrone.Core.Tv.Events +namespace NzbDrone.Core.Movies.Events { public class MovieAddedEvent : IEvent { diff --git a/src/NzbDrone.Core/Tv/Events/MovieDeletedEvent.cs b/src/NzbDrone.Core/Movies/Events/MovieDeletedEvent.cs similarity index 89% rename from src/NzbDrone.Core/Tv/Events/MovieDeletedEvent.cs rename to src/NzbDrone.Core/Movies/Events/MovieDeletedEvent.cs index 6c56ef1d2..3a30199c3 100644 --- a/src/NzbDrone.Core/Tv/Events/MovieDeletedEvent.cs +++ b/src/NzbDrone.Core/Movies/Events/MovieDeletedEvent.cs @@ -1,6 +1,6 @@ using NzbDrone.Common.Messaging; -namespace NzbDrone.Core.Tv.Events +namespace NzbDrone.Core.Movies.Events { public class MovieDeletedEvent : IEvent { diff --git a/src/NzbDrone.Core/Tv/Events/MovieEditedEvent.cs b/src/NzbDrone.Core/Movies/Events/MovieEditedEvent.cs similarity index 89% rename from src/NzbDrone.Core/Tv/Events/MovieEditedEvent.cs rename to src/NzbDrone.Core/Movies/Events/MovieEditedEvent.cs index 8b4b5c5f3..b42bff466 100644 --- a/src/NzbDrone.Core/Tv/Events/MovieEditedEvent.cs +++ b/src/NzbDrone.Core/Movies/Events/MovieEditedEvent.cs @@ -1,6 +1,6 @@ using NzbDrone.Common.Messaging; -namespace NzbDrone.Core.Tv.Events +namespace NzbDrone.Core.Movies.Events { public class MovieEditedEvent : IEvent { diff --git a/src/NzbDrone.Core/Movies/Events/MovieMovedEvent.cs b/src/NzbDrone.Core/Movies/Events/MovieMovedEvent.cs new file mode 100644 index 000000000..8d28a6cdd --- /dev/null +++ b/src/NzbDrone.Core/Movies/Events/MovieMovedEvent.cs @@ -0,0 +1,18 @@ +using NzbDrone.Common.Messaging; + +namespace NzbDrone.Core.Movies.Events +{ + public class MovieMovedEvent : IEvent + { + public Movie Movie { get; set; } + public string SourcePath { get; set; } + public string DestinationPath { get; set; } + + public MovieMovedEvent(Movie movie, string sourcePath, string destinationPath) + { + Movie = movie; + SourcePath = sourcePath; + DestinationPath = destinationPath; + } + } +} diff --git a/src/NzbDrone.Core/Tv/Events/MovieRefreshStartingEvent.cs b/src/NzbDrone.Core/Movies/Events/MovieRefreshStartingEvent.cs similarity index 87% rename from src/NzbDrone.Core/Tv/Events/MovieRefreshStartingEvent.cs rename to src/NzbDrone.Core/Movies/Events/MovieRefreshStartingEvent.cs index 201b5f9bb..1f0094395 100644 --- a/src/NzbDrone.Core/Tv/Events/MovieRefreshStartingEvent.cs +++ b/src/NzbDrone.Core/Movies/Events/MovieRefreshStartingEvent.cs @@ -1,6 +1,6 @@ using NzbDrone.Common.Messaging; -namespace NzbDrone.Core.Tv.Events +namespace NzbDrone.Core.Movies.Events { public class MovieRefreshStartingEvent : IEvent { diff --git a/src/NzbDrone.Core/Tv/Events/MovieUpdateEvent.cs b/src/NzbDrone.Core/Movies/Events/MovieUpdateEvent.cs similarity index 85% rename from src/NzbDrone.Core/Tv/Events/MovieUpdateEvent.cs rename to src/NzbDrone.Core/Movies/Events/MovieUpdateEvent.cs index bae4d3e1d..06bc79b96 100644 --- a/src/NzbDrone.Core/Tv/Events/MovieUpdateEvent.cs +++ b/src/NzbDrone.Core/Movies/Events/MovieUpdateEvent.cs @@ -1,6 +1,6 @@ using NzbDrone.Common.Messaging; -namespace NzbDrone.Core.Tv.Events +namespace NzbDrone.Core.Movies.Events { public class MovieUpdatedEvent : IEvent { diff --git a/src/NzbDrone.Core/Tv/MonitoringOptions.cs b/src/NzbDrone.Core/Movies/MonitoringOptions.cs similarity index 87% rename from src/NzbDrone.Core/Tv/MonitoringOptions.cs rename to src/NzbDrone.Core/Movies/MonitoringOptions.cs index 2cda68b1c..e6145184d 100644 --- a/src/NzbDrone.Core/Tv/MonitoringOptions.cs +++ b/src/NzbDrone.Core/Movies/MonitoringOptions.cs @@ -1,6 +1,6 @@ using NzbDrone.Core.Datastore; -namespace NzbDrone.Core.Tv +namespace NzbDrone.Core.Movies { public class MonitoringOptions : IEmbeddedDocument { diff --git a/src/NzbDrone.Core/Tv/MoveSeriesService.cs b/src/NzbDrone.Core/Movies/MoveMovieService.cs similarity index 65% rename from src/NzbDrone.Core/Tv/MoveSeriesService.cs rename to src/NzbDrone.Core/Movies/MoveMovieService.cs index 30abcb487..731907dc1 100644 --- a/src/NzbDrone.Core/Tv/MoveSeriesService.cs +++ b/src/NzbDrone.Core/Movies/MoveMovieService.cs @@ -1,50 +1,50 @@ -using System.IO; +using System.IO; using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; using NzbDrone.Common.Instrumentation.Extensions; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; +using NzbDrone.Core.Movies.Commands; +using NzbDrone.Core.Movies.Events; using NzbDrone.Core.Organizer; -using NzbDrone.Core.Tv.Commands; -using NzbDrone.Core.Tv.Events; -namespace NzbDrone.Core.Tv +namespace NzbDrone.Core.Movies { - public class MoveSeriesService : IExecute + public class MoveMovieService : IExecute { - private readonly ISeriesService _seriesService; + private readonly IMovieService _movieService; private readonly IBuildFileNames _filenameBuilder; private readonly IDiskTransferService _diskTransferService; private readonly IEventAggregator _eventAggregator; private readonly Logger _logger; - public MoveSeriesService(ISeriesService seriesService, + public MoveMovieService(IMovieService movieService, IBuildFileNames filenameBuilder, IDiskTransferService diskTransferService, IEventAggregator eventAggregator, Logger logger) { - _seriesService = seriesService; + _movieService = movieService; _filenameBuilder = filenameBuilder; _diskTransferService = diskTransferService; _eventAggregator = eventAggregator; _logger = logger; } - public void Execute(MoveSeriesCommand message) + public void Execute(MoveMovieCommand message) { - var series = _seriesService.GetSeries(message.SeriesId); + var movie = _movieService.GetMovie(message.MovieId); var source = message.SourcePath; var destination = message.DestinationPath; if (!message.DestinationRootFolder.IsNullOrWhiteSpace()) { - _logger.Debug("Buiding destination path using root folder: {0} and the series title", message.DestinationRootFolder); - destination = Path.Combine(message.DestinationRootFolder, _filenameBuilder.GetSeriesFolder(series)); + _logger.Debug("Buiding destination path using root folder: {0} and the movie title", message.DestinationRootFolder); + destination = Path.Combine(message.DestinationRootFolder, _filenameBuilder.GetMovieFolder(movie)); } - _logger.ProgressInfo("Moving {0} from '{1}' to '{2}'", series.Title, source, destination); + _logger.ProgressInfo("Moving {0} from '{1}' to '{2}'", movie.Title, source, destination); //TODO: Move to transactional disk operations try @@ -53,19 +53,19 @@ namespace NzbDrone.Core.Tv } catch (IOException ex) { - var errorMessage = string.Format("Unable to move series from '{0}' to '{1}'", source, destination); + var errorMessage = string.Format("Unable to move movie from '{0}' to '{1}'", source, destination); _logger.Error(ex, errorMessage); throw; } - _logger.ProgressInfo("{0} moved successfully to {1}", series.Title, series.Path); + _logger.ProgressInfo("{0} moved successfully to {1}", movie.Title, movie.Path); - //Update the series path to the new path - series.Path = destination; - series = _seriesService.UpdateSeries(series); + //Update the movie path to the new path + movie.Path = destination; + movie = _movieService.UpdateMovie(movie); - _eventAggregator.PublishEvent(new SeriesMovedEvent(series, source, destination)); + _eventAggregator.PublishEvent(new MovieMovedEvent(movie, source, destination)); } } } diff --git a/src/NzbDrone.Core/Tv/Movie.cs b/src/NzbDrone.Core/Movies/Movie.cs similarity index 96% rename from src/NzbDrone.Core/Tv/Movie.cs rename to src/NzbDrone.Core/Movies/Movie.cs index 5fd882664..ccc0a2981 100644 --- a/src/NzbDrone.Core/Tv/Movie.cs +++ b/src/NzbDrone.Core/Movies/Movie.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using Marr.Data; using NzbDrone.Common.Extensions; @@ -9,7 +9,7 @@ using System.IO; using NzbDrone.Core.Movies; using NzbDrone.Core.Movies.AlternativeTitles; -namespace NzbDrone.Core.Tv +namespace NzbDrone.Core.Movies { public class Movie : ModelBase { @@ -126,11 +126,6 @@ namespace NzbDrone.Core.Tv } } - public class AddMovieOptions : MonitoringOptions - { - public bool SearchForMovie { get; set; } - } - public enum MoviePathState { Dynamic, diff --git a/src/NzbDrone.Core/Tv/MovieAddedHandler.cs b/src/NzbDrone.Core/Movies/MovieAddedHandler.cs similarity index 83% rename from src/NzbDrone.Core/Tv/MovieAddedHandler.cs rename to src/NzbDrone.Core/Movies/MovieAddedHandler.cs index 765446ee1..e72e67f9c 100644 --- a/src/NzbDrone.Core/Tv/MovieAddedHandler.cs +++ b/src/NzbDrone.Core/Movies/MovieAddedHandler.cs @@ -1,9 +1,9 @@ using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Tv.Commands; -using NzbDrone.Core.Tv.Events; +using NzbDrone.Core.Movies.Commands; +using NzbDrone.Core.Movies.Events; -namespace NzbDrone.Core.Tv +namespace NzbDrone.Core.Movies { public class MovieAddedHandler : IHandle { diff --git a/src/NzbDrone.Core/Tv/MovieCutoffService.cs b/src/NzbDrone.Core/Movies/MovieCutoffService.cs similarity index 98% rename from src/NzbDrone.Core/Tv/MovieCutoffService.cs rename to src/NzbDrone.Core/Movies/MovieCutoffService.cs index 7d55257cd..2651492ea 100644 --- a/src/NzbDrone.Core/Tv/MovieCutoffService.cs +++ b/src/NzbDrone.Core/Movies/MovieCutoffService.cs @@ -5,7 +5,7 @@ using NzbDrone.Core.Datastore; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; -namespace NzbDrone.Core.Tv +namespace NzbDrone.Core.Movies { public interface IMovieCutoffService { diff --git a/src/NzbDrone.Core/Tv/MovieEditedService.cs b/src/NzbDrone.Core/Movies/MovieEditedService.cs similarity index 87% rename from src/NzbDrone.Core/Tv/MovieEditedService.cs rename to src/NzbDrone.Core/Movies/MovieEditedService.cs index 5f011c5ba..fcfc04361 100644 --- a/src/NzbDrone.Core/Tv/MovieEditedService.cs +++ b/src/NzbDrone.Core/Movies/MovieEditedService.cs @@ -1,9 +1,9 @@ using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Tv.Commands; -using NzbDrone.Core.Tv.Events; +using NzbDrone.Core.Movies.Commands; +using NzbDrone.Core.Movies.Events; -namespace NzbDrone.Core.Tv +namespace NzbDrone.Core.Movies { public class MovieEditedService : IHandle { diff --git a/src/NzbDrone.Core/Tv/MovieRepository.cs b/src/NzbDrone.Core/Movies/MovieRepository.cs similarity index 98% rename from src/NzbDrone.Core/Tv/MovieRepository.cs rename to src/NzbDrone.Core/Movies/MovieRepository.cs index 0ad6fb48e..c22ff9bfc 100644 --- a/src/NzbDrone.Core/Tv/MovieRepository.cs +++ b/src/NzbDrone.Core/Movies/MovieRepository.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Collections.Generic; using NzbDrone.Core.Datastore; @@ -11,7 +11,7 @@ using NzbDrone.Core.Parser.RomanNumerals; using NzbDrone.Core.Qualities; using CoreParser = NzbDrone.Core.Parser.Parser; -namespace NzbDrone.Core.Tv +namespace NzbDrone.Core.Movies { public interface IMovieRepository : IBasicRepository { @@ -65,9 +65,9 @@ namespace NzbDrone.Core.Tv return Query.Where(m => m.MovieFileId == fileId).ToList(); } - public void SetFileId(int fileId, int episodeId) + public void SetFileId(int fileId, int movieId) { - SetFields(new Movie { Id = episodeId, MovieFileId = fileId }, movie => movie.MovieFileId); + SetFields(new Movie { Id = movieId, MovieFileId = fileId }, movie => movie.MovieFileId); } public Movie FindByTitleSlug(string slug) diff --git a/src/NzbDrone.Core/Tv/MovieScannedHandler.cs b/src/NzbDrone.Core/Movies/MovieScannedHandler.cs similarity index 98% rename from src/NzbDrone.Core/Tv/MovieScannedHandler.cs rename to src/NzbDrone.Core/Movies/MovieScannedHandler.cs index 2eba01239..643268170 100644 --- a/src/NzbDrone.Core/Tv/MovieScannedHandler.cs +++ b/src/NzbDrone.Core/Movies/MovieScannedHandler.cs @@ -5,7 +5,7 @@ using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; using System.Collections.Generic; -namespace NzbDrone.Core.Tv +namespace NzbDrone.Core.Movies { public class MovieScannedHandler : IHandle, IHandle diff --git a/src/NzbDrone.Core/Tv/MovieService.cs b/src/NzbDrone.Core/Movies/MovieService.cs similarity index 95% rename from src/NzbDrone.Core/Tv/MovieService.cs rename to src/NzbDrone.Core/Movies/MovieService.cs index adf5386ff..54c2ef6b6 100644 --- a/src/NzbDrone.Core/Tv/MovieService.cs +++ b/src/NzbDrone.Core/Movies/MovieService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.IO; @@ -6,18 +6,17 @@ using System.Linq; using NLog; using NzbDrone.Common.EnsureThat; using NzbDrone.Common.Extensions; -using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Organizer; using NzbDrone.Core.Parser; -using NzbDrone.Core.Tv.Events; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Datastore; using NzbDrone.Core.Configuration; +using NzbDrone.Core.Movies.Events; using NzbDrone.Core.NetImport.ImportExclusions; -namespace NzbDrone.Core.Tv +namespace NzbDrone.Core.Movies { public interface IMovieService { @@ -44,7 +43,7 @@ namespace NzbDrone.Core.Tv bool MoviePathExists(string folder); void RemoveAddOptions(Movie movie); List MoviesWithFiles(int movieId); - System.Linq.Expressions.Expression> ConstructFilterExpression(string FilterKey, string FilterValue, string filterType = null); + System.Linq.Expressions.Expression> ConstructFilterExpression(string FilterKey, string FilterValue, string filterType = null); } public class MovieService : IMovieService, IHandle, @@ -60,8 +59,6 @@ namespace NzbDrone.Core.Tv public MovieService(IMovieRepository movieRepository, IEventAggregator eventAggregator, - ISceneMappingService sceneMappingService, - IEpisodeService episodeService, IBuildFileNames fileNameBuilder, IConfigService configService, IImportExclusionsService exclusionService, @@ -76,7 +73,7 @@ namespace NzbDrone.Core.Tv } - public System.Linq.Expressions.Expression> ConstructFilterExpression(string FilterKey, string FilterValue, string FilterType = null) + public System.Linq.Expressions.Expression> ConstructFilterExpression(string FilterKey, string FilterValue, string FilterType = null) { //if (FilterKey == "all" && FilterValue == "all") //{ @@ -399,9 +396,9 @@ namespace NzbDrone.Core.Tv public List GetMoviesBetweenDates(DateTime start, DateTime end, bool includeUnmonitored) { - var episodes = _movieRepository.MoviesBetweenDates(start.ToUniversalTime(), end.ToUniversalTime(), includeUnmonitored); + var movies = _movieRepository.MoviesBetweenDates(start.ToUniversalTime(), end.ToUniversalTime(), includeUnmonitored); - return episodes; + return movies; } public List MoviesWithFiles(int movieId) diff --git a/src/NzbDrone.Core/Tv/MovieStatusType.cs b/src/NzbDrone.Core/Movies/MovieStatusType.cs similarity index 94% rename from src/NzbDrone.Core/Tv/MovieStatusType.cs rename to src/NzbDrone.Core/Movies/MovieStatusType.cs index b925e26c4..f45ecb5f0 100644 --- a/src/NzbDrone.Core/Tv/MovieStatusType.cs +++ b/src/NzbDrone.Core/Movies/MovieStatusType.cs @@ -1,4 +1,4 @@ -namespace NzbDrone.Core.Tv +namespace NzbDrone.Core.Movies { public enum MovieStatusType { diff --git a/src/NzbDrone.Core/Tv/MovieTitleNormalizer.cs b/src/NzbDrone.Core/Movies/MovieTitleNormalizer.cs similarity index 95% rename from src/NzbDrone.Core/Tv/MovieTitleNormalizer.cs rename to src/NzbDrone.Core/Movies/MovieTitleNormalizer.cs index c82dd014d..c5ca9edaf 100644 --- a/src/NzbDrone.Core/Tv/MovieTitleNormalizer.cs +++ b/src/NzbDrone.Core/Movies/MovieTitleNormalizer.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace NzbDrone.Core.Tv +namespace NzbDrone.Core.Movies { public static class MovieTitleNormalizer { diff --git a/src/NzbDrone.Core/Tv/QueryExtensions.cs b/src/NzbDrone.Core/Movies/QueryExtensions.cs similarity index 97% rename from src/NzbDrone.Core/Tv/QueryExtensions.cs rename to src/NzbDrone.Core/Movies/QueryExtensions.cs index 07bbe4acb..db961f532 100644 --- a/src/NzbDrone.Core/Tv/QueryExtensions.cs +++ b/src/NzbDrone.Core/Movies/QueryExtensions.cs @@ -8,7 +8,7 @@ using Marr.Data.QGen; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Parser.RomanNumerals; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using CoreParser = NzbDrone.Core.Parser.Parser; namespace NzbDrone.Core { diff --git a/src/NzbDrone.Core/Tv/Ratings.cs b/src/NzbDrone.Core/Movies/Ratings.cs similarity index 85% rename from src/NzbDrone.Core/Tv/Ratings.cs rename to src/NzbDrone.Core/Movies/Ratings.cs index 6c66fbb7e..568485dff 100644 --- a/src/NzbDrone.Core/Tv/Ratings.cs +++ b/src/NzbDrone.Core/Movies/Ratings.cs @@ -1,6 +1,6 @@ using NzbDrone.Core.Datastore; -namespace NzbDrone.Core.Tv +namespace NzbDrone.Core.Movies { public class Ratings : IEmbeddedDocument { diff --git a/src/NzbDrone.Core/Tv/RefreshMovieService.cs b/src/NzbDrone.Core/Movies/RefreshMovieService.cs similarity index 98% rename from src/NzbDrone.Core/Tv/RefreshMovieService.cs rename to src/NzbDrone.Core/Movies/RefreshMovieService.cs index 707ae7eae..762cbd243 100644 --- a/src/NzbDrone.Core/Tv/RefreshMovieService.cs +++ b/src/NzbDrone.Core/Movies/RefreshMovieService.cs @@ -11,13 +11,13 @@ using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.MetadataSource; -using NzbDrone.Core.Tv.Commands; -using NzbDrone.Core.Tv.Events; using NzbDrone.Core.MediaFiles.Commands; using NzbDrone.Core.MetadataSource.RadarrAPI; using NzbDrone.Core.Movies.AlternativeTitles; +using NzbDrone.Core.Movies.Commands; +using NzbDrone.Core.Movies.Events; -namespace NzbDrone.Core.Tv +namespace NzbDrone.Core.Movies { public class RefreshMovieService : IExecute { diff --git a/src/NzbDrone.Core/Tv/ShouldRefreshMovie.cs b/src/NzbDrone.Core/Movies/ShouldRefreshMovie.cs similarity index 87% rename from src/NzbDrone.Core/Tv/ShouldRefreshMovie.cs rename to src/NzbDrone.Core/Movies/ShouldRefreshMovie.cs index 6c7cc91cb..817d407ad 100644 --- a/src/NzbDrone.Core/Tv/ShouldRefreshMovie.cs +++ b/src/NzbDrone.Core/Movies/ShouldRefreshMovie.cs @@ -1,8 +1,8 @@ -using System; +using System; using System.Linq; using NLog; -namespace NzbDrone.Core.Tv +namespace NzbDrone.Core.Movies { public interface ICheckIfMovieShouldBeRefreshed { @@ -11,12 +11,10 @@ namespace NzbDrone.Core.Tv public class ShouldRefreshMovie : ICheckIfMovieShouldBeRefreshed { - private readonly IEpisodeService _episodeService; private readonly Logger _logger; - public ShouldRefreshMovie(IEpisodeService episodeService, Logger logger) + public ShouldRefreshMovie(Logger logger) { - _episodeService = episodeService; _logger = logger; } diff --git a/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoParser.cs b/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoParser.cs index d71dcf2ba..40812ee3f 100644 --- a/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoParser.cs +++ b/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoParser.cs @@ -20,11 +20,11 @@ namespace NzbDrone.Core.NetImport.CouchPotato _settings = settings; } - public IList ParseResponse(NetImportResponse importResponse) + public IList ParseResponse(NetImportResponse importResponse) { _importResponse = importResponse; - var movies = new List(); + var movies = new List(); if (!PreProcess(_importResponse)) { @@ -51,7 +51,7 @@ namespace NzbDrone.Core.NetImport.CouchPotato // if there are no releases at all the movie wasn't found on CP, so return movies if (!item.releases.Any() && item.type == "movie") { - movies.AddIfNotNull(new Tv.Movie() + movies.AddIfNotNull(new Movies.Movie() { Title = item.title, ImdbId = item.info.imdb, @@ -65,7 +65,7 @@ namespace NzbDrone.Core.NetImport.CouchPotato bool isCompleted = item.releases.Any(rel => (rel.status == "done" || rel.status == "seeding")); if (!isCompleted) { - movies.AddIfNotNull(new Tv.Movie() + movies.AddIfNotNull(new Movies.Movie() { Title = item.title, ImdbId = item.info.imdb, diff --git a/src/NzbDrone.Core/NetImport/HttpNetImportBase.cs b/src/NzbDrone.Core/NetImport/HttpNetImportBase.cs index 82cc96f3b..92e53b994 100644 --- a/src/NzbDrone.Core/NetImport/HttpNetImportBase.cs +++ b/src/NzbDrone.Core/NetImport/HttpNetImportBase.cs @@ -10,7 +10,7 @@ using NzbDrone.Core.Configuration; using NzbDrone.Core.NetImport.Exceptions; using NzbDrone.Core.Parser; using NzbDrone.Core.ThingiProvider; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.NetImport { diff --git a/src/NzbDrone.Core/NetImport/INetImport.cs b/src/NzbDrone.Core/NetImport/INetImport.cs index d024cf495..31b945d63 100644 --- a/src/NzbDrone.Core/NetImport/INetImport.cs +++ b/src/NzbDrone.Core/NetImport/INetImport.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using NzbDrone.Core.ThingiProvider; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.NetImport { diff --git a/src/NzbDrone.Core/NetImport/IProcessNetImportResponse.cs b/src/NzbDrone.Core/NetImport/IProcessNetImportResponse.cs index 8c1aa655f..c5663b9d3 100644 --- a/src/NzbDrone.Core/NetImport/IProcessNetImportResponse.cs +++ b/src/NzbDrone.Core/NetImport/IProcessNetImportResponse.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.NetImport { diff --git a/src/NzbDrone.Core/NetImport/ImportExclusions/ImportExclusionsService.cs b/src/NzbDrone.Core/NetImport/ImportExclusions/ImportExclusionsService.cs index db289f344..a552c71ce 100644 --- a/src/NzbDrone.Core/NetImport/ImportExclusions/ImportExclusionsService.cs +++ b/src/NzbDrone.Core/NetImport/ImportExclusions/ImportExclusionsService.cs @@ -1,15 +1,14 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; using NLog; using NzbDrone.Common.EnsureThat; using NzbDrone.Common.Extensions; -using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Organizer; using NzbDrone.Core.Parser; -using NzbDrone.Core.Tv.Events; +using NzbDrone.Core.Movies.Events; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Datastore; diff --git a/src/NzbDrone.Core/NetImport/NetImportBase.cs b/src/NzbDrone.Core/NetImport/NetImportBase.cs index b01cce2ed..92b49778e 100644 --- a/src/NzbDrone.Core/NetImport/NetImportBase.cs +++ b/src/NzbDrone.Core/NetImport/NetImportBase.cs @@ -5,7 +5,7 @@ using NLog; using NzbDrone.Core.Configuration; using NzbDrone.Core.Parser; using NzbDrone.Core.ThingiProvider; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.NetImport { diff --git a/src/NzbDrone.Core/NetImport/NetImportDefinition.cs b/src/NzbDrone.Core/NetImport/NetImportDefinition.cs index b38e49fd6..6462fb008 100644 --- a/src/NzbDrone.Core/NetImport/NetImportDefinition.cs +++ b/src/NzbDrone.Core/NetImport/NetImportDefinition.cs @@ -1,7 +1,7 @@ using Marr.Data; using NzbDrone.Core.Profiles; using NzbDrone.Core.ThingiProvider; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.NetImport { diff --git a/src/NzbDrone.Core/NetImport/NetImportSearchService.cs b/src/NzbDrone.Core/NetImport/NetImportSearchService.cs index 7a1f1cfe6..4f549b56c 100644 --- a/src/NzbDrone.Core/NetImport/NetImportSearchService.cs +++ b/src/NzbDrone.Core/NetImport/NetImportSearchService.cs @@ -6,7 +6,7 @@ using NLog; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.MetadataSource; using NzbDrone.Core.RootFolders; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Configuration; using NzbDrone.Common.Extensions; using NzbDrone.Common.Instrumentation.Extensions; diff --git a/src/NzbDrone.Core/NetImport/RSSImport/RSSImportParser.cs b/src/NzbDrone.Core/NetImport/RSSImport/RSSImportParser.cs index e6dee4a25..6dd0dadf4 100644 --- a/src/NzbDrone.Core/NetImport/RSSImport/RSSImportParser.cs +++ b/src/NzbDrone.Core/NetImport/RSSImport/RSSImportParser.cs @@ -1,5 +1,5 @@ using NzbDrone.Core.NetImport.Exceptions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using System; using System.Collections.Generic; using System.IO; diff --git a/src/NzbDrone.Core/NetImport/Radarr/RadarrParser.cs b/src/NzbDrone.Core/NetImport/Radarr/RadarrParser.cs index 18cbdd1af..8d8924e5d 100644 --- a/src/NzbDrone.Core/NetImport/Radarr/RadarrParser.cs +++ b/src/NzbDrone.Core/NetImport/Radarr/RadarrParser.cs @@ -25,11 +25,11 @@ namespace NzbDrone.Core.NetImport.Radarr _settings = settings; } - public IList ParseResponse(NetImportResponse importResponse) + public IList ParseResponse(NetImportResponse importResponse) { _importResponse = importResponse; - var movies = new List(); + var movies = new List(); if (!PreProcess(_importResponse)) { diff --git a/src/NzbDrone.Core/NetImport/StevenLu/StevenLuParser.cs b/src/NzbDrone.Core/NetImport/StevenLu/StevenLuParser.cs index 5715c576b..e719056e9 100644 --- a/src/NzbDrone.Core/NetImport/StevenLu/StevenLuParser.cs +++ b/src/NzbDrone.Core/NetImport/StevenLu/StevenLuParser.cs @@ -18,11 +18,11 @@ namespace NzbDrone.Core.NetImport.StevenLu _settings = settings; } - public IList ParseResponse(NetImportResponse importResponse) + public IList ParseResponse(NetImportResponse importResponse) { _importResponse = importResponse; - var movies = new List(); + var movies = new List(); if (!PreProcess(_importResponse)) { @@ -39,7 +39,7 @@ namespace NzbDrone.Core.NetImport.StevenLu foreach (var item in jsonResponse) { - movies.AddIfNotNull(new Tv.Movie() + movies.AddIfNotNull(new Movies.Movie() { Title = item.title, ImdbId = item.imdb_id, diff --git a/src/NzbDrone.Core/NetImport/TMDb/TMDbParser.cs b/src/NzbDrone.Core/NetImport/TMDb/TMDbParser.cs index 59ed165e5..c103f18f1 100644 --- a/src/NzbDrone.Core/NetImport/TMDb/TMDbParser.cs +++ b/src/NzbDrone.Core/NetImport/TMDb/TMDbParser.cs @@ -24,11 +24,11 @@ namespace NzbDrone.Core.NetImport.TMDb _settings = settings; } - public IList ParseResponse(NetImportResponse importResponse) + public IList ParseResponse(NetImportResponse importResponse) { _importResponse = importResponse; - var movies = new List(); + var movies = new List(); if (!PreProcess(_importResponse)) { diff --git a/src/NzbDrone.Core/NetImport/Trakt/TraktParser.cs b/src/NzbDrone.Core/NetImport/Trakt/TraktParser.cs index 933b8a1c2..0918e61ba 100644 --- a/src/NzbDrone.Core/NetImport/Trakt/TraktParser.cs +++ b/src/NzbDrone.Core/NetImport/Trakt/TraktParser.cs @@ -18,11 +18,11 @@ namespace NzbDrone.Core.NetImport.Trakt _settings = settings; } - public IList ParseResponse(NetImportResponse importResponse) + public IList ParseResponse(NetImportResponse importResponse) { _importResponse = importResponse; - var movies = new List(); + var movies = new List(); if (!PreProcess(_importResponse)) { @@ -35,7 +35,7 @@ namespace NzbDrone.Core.NetImport.Trakt foreach (var movie in jsonResponse) { - movies.AddIfNotNull(new Tv.Movie() + movies.AddIfNotNull(new Movies.Movie() { Title = movie.title, ImdbId = movie.ids.imdb, @@ -56,7 +56,7 @@ namespace NzbDrone.Core.NetImport.Trakt foreach (var movie in jsonResponse) { - movies.AddIfNotNull(new Tv.Movie() + movies.AddIfNotNull(new Movies.Movie() { Title = movie.movie.title, ImdbId = movie.movie.ids.imdb, diff --git a/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs b/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs index 222597904..2ded585d0 100644 --- a/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs +++ b/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Boxcar { diff --git a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs index 314a83ce3..87e00e78b 100755 --- a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs +++ b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs @@ -7,7 +7,7 @@ using FluentValidation.Results; using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.Processes; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Validation; namespace NzbDrone.Core.Notifications.CustomScript diff --git a/src/NzbDrone.Core/Notifications/DownloadMessage.cs b/src/NzbDrone.Core/Notifications/DownloadMessage.cs index 75a163bad..563fb9f2c 100644 --- a/src/NzbDrone.Core/Notifications/DownloadMessage.cs +++ b/src/NzbDrone.Core/Notifications/DownloadMessage.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications { diff --git a/src/NzbDrone.Core/Notifications/Email/Email.cs b/src/NzbDrone.Core/Notifications/Email/Email.cs index 754f8ee1a..4dce95c2a 100644 --- a/src/NzbDrone.Core/Notifications/Email/Email.cs +++ b/src/NzbDrone.Core/Notifications/Email/Email.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Email { diff --git a/src/NzbDrone.Core/Notifications/GrabMessage.cs b/src/NzbDrone.Core/Notifications/GrabMessage.cs index a412e26ab..25c34dac7 100644 --- a/src/NzbDrone.Core/Notifications/GrabMessage.cs +++ b/src/NzbDrone.Core/Notifications/GrabMessage.cs @@ -1,6 +1,6 @@ using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications { diff --git a/src/NzbDrone.Core/Notifications/Growl/Growl.cs b/src/NzbDrone.Core/Notifications/Growl/Growl.cs index 6917b2777..e580fff04 100644 --- a/src/NzbDrone.Core/Notifications/Growl/Growl.cs +++ b/src/NzbDrone.Core/Notifications/Growl/Growl.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Growl { diff --git a/src/NzbDrone.Core/Notifications/INotification.cs b/src/NzbDrone.Core/Notifications/INotification.cs index 05468ae3c..1d29532f7 100644 --- a/src/NzbDrone.Core/Notifications/INotification.cs +++ b/src/NzbDrone.Core/Notifications/INotification.cs @@ -1,5 +1,5 @@ using NzbDrone.Core.ThingiProvider; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications { diff --git a/src/NzbDrone.Core/Notifications/Join/Join.cs b/src/NzbDrone.Core/Notifications/Join/Join.cs index 9ec70d66b..4c07f9738 100644 --- a/src/NzbDrone.Core/Notifications/Join/Join.cs +++ b/src/NzbDrone.Core/Notifications/Join/Join.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Join { diff --git a/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowser.cs b/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowser.cs index 5d8915c4f..19a023d41 100644 --- a/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowser.cs +++ b/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowser.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.MediaBrowser { diff --git a/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserService.cs b/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserService.cs index 7d050e90d..9d39ff57f 100644 --- a/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserService.cs +++ b/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserService.cs @@ -3,7 +3,7 @@ using System.Net; using FluentValidation.Results; using NLog; using NzbDrone.Core.Rest; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.MediaBrowser { diff --git a/src/NzbDrone.Core/Notifications/NotificationBase.cs b/src/NzbDrone.Core/Notifications/NotificationBase.cs index 27dee4b37..89ddb889a 100644 --- a/src/NzbDrone.Core/Notifications/NotificationBase.cs +++ b/src/NzbDrone.Core/Notifications/NotificationBase.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Core.ThingiProvider; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications { diff --git a/src/NzbDrone.Core/Notifications/NotificationService.cs b/src/NzbDrone.Core/Notifications/NotificationService.cs index 63149acc7..1a36e375f 100644 --- a/src/NzbDrone.Core/Notifications/NotificationService.cs +++ b/src/NzbDrone.Core/Notifications/NotificationService.cs @@ -8,15 +8,12 @@ using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Qualities; using NzbDrone.Core.ThingiProvider; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications { public class NotificationService - : IHandle, - IHandle, - IHandle, - IHandle, + : IHandle, IHandle, IHandle @@ -68,11 +65,6 @@ namespace NzbDrone.Core.Notifications return false; } - public void Handle(EpisodeGrabbedEvent message) - { - throw new NotImplementedException("Remove Series/Season/Episode"); - } - public void Handle(MovieGrabbedEvent message) { var grabMessage = new GrabMessage @@ -98,11 +90,6 @@ namespace NzbDrone.Core.Notifications } } - public void Handle(EpisodeDownloadedEvent message) - { - throw new NotImplementedException("Remove Series/Season/Episode"); - } - public void Handle(MovieDownloadedEvent message) { var downloadMessage = new DownloadMessage(); @@ -133,11 +120,6 @@ namespace NzbDrone.Core.Notifications } } - public void Handle(SeriesRenamedEvent message) - { - throw new NotImplementedException("Remove Series/Season/Episode"); - } - public void Handle(MovieRenamedEvent message) { foreach (var notification in _notificationFactory.OnRenameEnabled()) diff --git a/src/NzbDrone.Core/Notifications/NotifyMyAndroid/NotifyMyAndroid.cs b/src/NzbDrone.Core/Notifications/NotifyMyAndroid/NotifyMyAndroid.cs index ad328faf6..2ac7a04a6 100644 --- a/src/NzbDrone.Core/Notifications/NotifyMyAndroid/NotifyMyAndroid.cs +++ b/src/NzbDrone.Core/Notifications/NotifyMyAndroid/NotifyMyAndroid.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.NotifyMyAndroid { diff --git a/src/NzbDrone.Core/Notifications/Plex/PlexClient.cs b/src/NzbDrone.Core/Notifications/Plex/PlexClient.cs index 10c3bb237..923be565e 100644 --- a/src/NzbDrone.Core/Notifications/Plex/PlexClient.cs +++ b/src/NzbDrone.Core/Notifications/Plex/PlexClient.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Plex { diff --git a/src/NzbDrone.Core/Notifications/Plex/PlexHomeTheater.cs b/src/NzbDrone.Core/Notifications/Plex/PlexHomeTheater.cs index 32c180d87..78cfa3c52 100644 --- a/src/NzbDrone.Core/Notifications/Plex/PlexHomeTheater.cs +++ b/src/NzbDrone.Core/Notifications/Plex/PlexHomeTheater.cs @@ -4,7 +4,7 @@ using FluentValidation.Results; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Core.Notifications.Xbmc; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Plex { diff --git a/src/NzbDrone.Core/Notifications/Plex/PlexServer.cs b/src/NzbDrone.Core/Notifications/Plex/PlexServer.cs index fe7f26758..a9b7e7fa0 100644 --- a/src/NzbDrone.Core/Notifications/Plex/PlexServer.cs +++ b/src/NzbDrone.Core/Notifications/Plex/PlexServer.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Plex { diff --git a/src/NzbDrone.Core/Notifications/Plex/PlexServerService.cs b/src/NzbDrone.Core/Notifications/Plex/PlexServerService.cs index 7b5b07c64..dff45d224 100644 --- a/src/NzbDrone.Core/Notifications/Plex/PlexServerService.cs +++ b/src/NzbDrone.Core/Notifications/Plex/PlexServerService.cs @@ -7,7 +7,7 @@ using NLog; using NzbDrone.Common.Cache; using NzbDrone.Common.Extensions; using NzbDrone.Core.Notifications.Plex.Models; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Plex { diff --git a/src/NzbDrone.Core/Notifications/Prowl/Prowl.cs b/src/NzbDrone.Core/Notifications/Prowl/Prowl.cs index 2231a974c..66e0c1030 100644 --- a/src/NzbDrone.Core/Notifications/Prowl/Prowl.cs +++ b/src/NzbDrone.Core/Notifications/Prowl/Prowl.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using Prowlin; namespace NzbDrone.Core.Notifications.Prowl diff --git a/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs b/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs index 5381af2ef..0c04e36d3 100644 --- a/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs +++ b/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.PushBullet { diff --git a/src/NzbDrone.Core/Notifications/Pushalot/Pushalot.cs b/src/NzbDrone.Core/Notifications/Pushalot/Pushalot.cs index af853a086..97f3d6df6 100644 --- a/src/NzbDrone.Core/Notifications/Pushalot/Pushalot.cs +++ b/src/NzbDrone.Core/Notifications/Pushalot/Pushalot.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Pushalot { diff --git a/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs b/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs index 504d27076..f881a2d69 100644 --- a/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs +++ b/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Pushover { diff --git a/src/NzbDrone.Core/Notifications/Slack/Slack.cs b/src/NzbDrone.Core/Notifications/Slack/Slack.cs index 3e1459087..64765d92b 100644 --- a/src/NzbDrone.Core/Notifications/Slack/Slack.cs +++ b/src/NzbDrone.Core/Notifications/Slack/Slack.cs @@ -7,7 +7,7 @@ using NzbDrone.Common.Http; using NzbDrone.Common.Serializer; using NzbDrone.Core.Notifications.Slack.Payloads; using NzbDrone.Core.Rest; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Validation; using RestSharp; diff --git a/src/NzbDrone.Core/Notifications/Synology/SynologyIndexer.cs b/src/NzbDrone.Core/Notifications/Synology/SynologyIndexer.cs index a7289151a..cf46b6a3f 100644 --- a/src/NzbDrone.Core/Notifications/Synology/SynologyIndexer.cs +++ b/src/NzbDrone.Core/Notifications/Synology/SynologyIndexer.cs @@ -3,7 +3,7 @@ using System.IO; using FluentValidation.Results; using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Synology { diff --git a/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs b/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs index d1b080ef2..e8fb100cb 100644 --- a/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs +++ b/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Telegram { diff --git a/src/NzbDrone.Core/Notifications/Twitter/Twitter.cs b/src/NzbDrone.Core/Notifications/Twitter/Twitter.cs index 2ba5f81f0..22f8a54b1 100644 --- a/src/NzbDrone.Core/Notifications/Twitter/Twitter.cs +++ b/src/NzbDrone.Core/Notifications/Twitter/Twitter.cs @@ -2,7 +2,7 @@ using FluentValidation.Results; using NzbDrone.Common.Extensions; using NzbDrone.Core.Exceptions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Validation; namespace NzbDrone.Core.Notifications.Twitter diff --git a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs index 4b02821ef..1c90c54b8 100755 --- a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; using FluentValidation.Results; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Common.Extensions; using NzbDrone.Core.Validation; diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookMovie.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookMovie.cs index ef13c8d20..459743f1d 100755 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookMovie.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookMovie.cs @@ -1,5 +1,5 @@ -using System.IO; -using NzbDrone.Core.Tv; +using System.IO; + using NzbDrone.Core.Movies; using NzbDrone.Core.MediaFiles; namespace NzbDrone.Core.Notifications.Webhook diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookRemoteMovie.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookRemoteMovie.cs index 5b32fc30c..cc8279290 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookRemoteMovie.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookRemoteMovie.cs @@ -1,4 +1,4 @@ -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.Notifications.Webhook diff --git a/src/NzbDrone.Core/Notifications/Xbmc/IApiProvider.cs b/src/NzbDrone.Core/Notifications/Xbmc/IApiProvider.cs index 93ef1f30a..37fb9b5ff 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/IApiProvider.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/IApiProvider.cs @@ -1,5 +1,5 @@ using NzbDrone.Core.Notifications.Xbmc.Model; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Xbmc { diff --git a/src/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs b/src/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs index 5b98342f2..b253cad5e 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using NLog; using NzbDrone.Core.Notifications.Xbmc.Model; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Xbmc { diff --git a/src/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs b/src/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs index 25f995e33..2710ac8ed 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs @@ -4,7 +4,7 @@ using System.Net.Sockets; using FluentValidation.Results; using NLog; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Xbmc { diff --git a/src/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs b/src/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs index 51a0ccaaf..d3c2bbbea 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs @@ -7,7 +7,7 @@ using NLog; using NzbDrone.Common.Cache; using NzbDrone.Common.Serializer; using NzbDrone.Core.Notifications.Xbmc.Model; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Xbmc { diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index f9e94cd45..6ae70e38b 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -95,13 +95,11 @@ True - - @@ -126,13 +124,14 @@ + - - + + @@ -204,17 +203,6 @@ - - - - - - - - - - - @@ -391,11 +379,9 @@ - - @@ -407,16 +393,12 @@ - + - - - - + - @@ -588,7 +570,6 @@ - @@ -602,7 +583,6 @@ - @@ -657,8 +637,7 @@ - - + @@ -667,7 +646,7 @@ - + @@ -767,20 +746,8 @@ - - - - - - - - - - - - @@ -819,52 +786,35 @@ - - - + + - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - @@ -878,13 +828,10 @@ - - - @@ -926,7 +873,7 @@ - + @@ -947,8 +894,6 @@ - - @@ -1130,10 +1075,7 @@ - - - @@ -1174,14 +1116,6 @@ - - - - - - - - @@ -1199,60 +1133,30 @@ - - - - - - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -1283,9 +1187,6 @@ - - - @@ -1293,7 +1194,7 @@ - + @@ -1387,11 +1288,11 @@ - \ No newline at end of file diff --git a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs index 25cdccce6..8bbdd639f 100644 --- a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs +++ b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.IO; @@ -10,21 +10,16 @@ using NzbDrone.Common.EnsureThat; using NzbDrone.Common.Extensions; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Organizer { public interface IBuildFileNames { - string BuildFileName(List episodes, Series series, EpisodeFile episodeFile, NamingConfig namingConfig = null); string BuildFileName(Movie movie, MovieFile movieFile, NamingConfig namingConfig = null); string BuildFilePath(Movie movie, string fileName, string extension); - string BuildFilePath(Series series, int seasonNumber, string fileName, string extension); string BuildMoviePath(Movie movie, NamingConfig namingConfig = null); - string BuildSeasonPath(Series series, int seasonNumber); BasicNamingConfig GetBasicNamingConfig(NamingConfig nameSpec); - string GetSeriesFolder(Series series, NamingConfig namingConfig = null); - string GetSeasonFolder(Series series, int seasonNumber, NamingConfig namingConfig = null); string GetMovieFolder(Movie movie, NamingConfig namingConfig = null); } @@ -89,64 +84,6 @@ namespace NzbDrone.Core.Organizer _logger = logger; } - public string BuildFileName(List episodes, Series series, EpisodeFile episodeFile, NamingConfig namingConfig = null) - { - if (namingConfig == null) - { - namingConfig = _namingConfigService.GetConfig(); - } - - if (!namingConfig.RenameEpisodes) - { - return GetOriginalTitle(episodeFile); - } - - if (namingConfig.StandardEpisodeFormat.IsNullOrWhiteSpace() && series.SeriesType == SeriesTypes.Standard) - { - throw new NamingFormatException("Standard episode format cannot be empty"); - } - - if (namingConfig.DailyEpisodeFormat.IsNullOrWhiteSpace() && series.SeriesType == SeriesTypes.Daily) - { - throw new NamingFormatException("Daily episode format cannot be empty"); - } - - if (namingConfig.AnimeEpisodeFormat.IsNullOrWhiteSpace() && series.SeriesType == SeriesTypes.Anime) - { - throw new NamingFormatException("Anime episode format cannot be empty"); - } - - var pattern = namingConfig.StandardEpisodeFormat; - var tokenHandlers = new Dictionary>(FileNameBuilderTokenEqualityComparer.Instance); - - episodes = episodes.OrderBy(e => e.SeasonNumber).ThenBy(e => e.EpisodeNumber).ToList(); - - if (series.SeriesType == SeriesTypes.Daily) - { - pattern = namingConfig.DailyEpisodeFormat; - } - - if (series.SeriesType == SeriesTypes.Anime && episodes.All(e => e.AbsoluteEpisodeNumber.HasValue)) - { - pattern = namingConfig.AnimeEpisodeFormat; - } - - pattern = AddSeasonEpisodeNumberingTokens(pattern, tokenHandlers, episodes, namingConfig); - pattern = AddAbsoluteNumberingTokens(pattern, tokenHandlers, series, episodes, namingConfig); - - AddSeriesTokens(tokenHandlers, series); - AddEpisodeTokens(tokenHandlers, episodes); - AddEpisodeFileTokens(tokenHandlers, episodeFile); - AddQualityTokens(tokenHandlers, series, episodeFile); - AddMediaInfoTokens(tokenHandlers, episodeFile); - - var fileName = ReplaceTokens(pattern, tokenHandlers, namingConfig).Trim(); - fileName = FileNameCleanupRegex.Replace(fileName, match => match.Captures[0].Value[0].ToString()); - fileName = TrimSeparatorsRegex.Replace(fileName, string.Empty); - - return fileName; - } - public string BuildFileName(Movie movie, MovieFile movieFile, NamingConfig namingConfig = null) { if (namingConfig == null) @@ -177,15 +114,6 @@ namespace NzbDrone.Core.Organizer return fileName; } - public string BuildFilePath(Series series, int seasonNumber, string fileName, string extension) - { - Ensure.That(extension, () => extension).IsNotNullOrWhiteSpace(); - - var path = BuildSeasonPath(series, seasonNumber); - - return Path.Combine(path, fileName + extension); - } - public string BuildFilePath(Movie movie, string fileName, string extension) { Ensure.That(extension, () => extension).IsNotNullOrWhiteSpace(); @@ -245,104 +173,52 @@ namespace NzbDrone.Core.Organizer return Path.Combine(parentDirectoryPath, directoryName); } - public string BuildSeasonPath(Series series, int seasonNumber) - { - var path = series.Path; - - if (series.SeasonFolder) - { - if (seasonNumber == 0) - { - path = Path.Combine(path, "Specials"); - } - else - { - var seasonFolder = GetSeasonFolder(series, seasonNumber); - - seasonFolder = CleanFileName(seasonFolder); - - path = Path.Combine(path, seasonFolder); - } - } - - return path; - } - public BasicNamingConfig GetBasicNamingConfig(NamingConfig nameSpec) { return new BasicNamingConfig(); //For now let's be lazy - var episodeFormat = GetEpisodeFormat(nameSpec.StandardEpisodeFormat).LastOrDefault(); - - if (episodeFormat == null) - { - return new BasicNamingConfig(); - } - - var basicNamingConfig = new BasicNamingConfig - { - Separator = episodeFormat.Separator, - NumberStyle = episodeFormat.SeasonEpisodePattern - }; + //var episodeFormat = GetEpisodeFormat(nameSpec.StandardMovieFormat).LastOrDefault(); - var titleTokens = TitleRegex.Matches(nameSpec.StandardEpisodeFormat); + //if (episodeFormat == null) + //{ + // return new BasicNamingConfig(); + //} - foreach (Match match in titleTokens) - { - var separator = match.Groups["separator"].Value; - var token = match.Groups["token"].Value; - - if (!separator.Equals(" ")) - { - basicNamingConfig.ReplaceSpaces = true; - } - - if (token.StartsWith("{Series", StringComparison.InvariantCultureIgnoreCase)) - { - basicNamingConfig.IncludeSeriesTitle = true; - } - - if (token.StartsWith("{Episode", StringComparison.InvariantCultureIgnoreCase)) - { - basicNamingConfig.IncludeEpisodeTitle = true; - } - - if (token.StartsWith("{Quality", StringComparison.InvariantCultureIgnoreCase)) - { - basicNamingConfig.IncludeQuality = true; - } - } - - return basicNamingConfig; - } - - public string GetSeriesFolder(Series series, NamingConfig namingConfig = null) - { - if (namingConfig == null) - { - namingConfig = _namingConfigService.GetConfig(); - } + //var basicNamingConfig = new BasicNamingConfig + //{ + // Separator = episodeFormat.Separator, + // NumberStyle = episodeFormat.SeasonEpisodePattern + //}; - var tokenHandlers = new Dictionary>(FileNameBuilderTokenEqualityComparer.Instance); + //var titleTokens = TitleRegex.Matches(nameSpec.StandardMovieFormat); - AddSeriesTokens(tokenHandlers, series); + //foreach (Match match in titleTokens) + //{ + // var separator = match.Groups["separator"].Value; + // var token = match.Groups["token"].Value; - return CleanFolderName(ReplaceTokens(namingConfig.SeriesFolderFormat, tokenHandlers, namingConfig)); - } + // if (!separator.Equals(" ")) + // { + // basicNamingConfig.ReplaceSpaces = true; + // } - public string GetSeasonFolder(Series series, int seasonNumber, NamingConfig namingConfig = null) - { - if (namingConfig == null) - { - namingConfig = _namingConfigService.GetConfig(); - } + // if (token.StartsWith("{Series", StringComparison.InvariantCultureIgnoreCase)) + // { + // basicNamingConfig.IncludeSeriesTitle = true; + // } - var tokenHandlers = new Dictionary>(FileNameBuilderTokenEqualityComparer.Instance); + // if (token.StartsWith("{Episode", StringComparison.InvariantCultureIgnoreCase)) + // { + // basicNamingConfig.IncludeEpisodeTitle = true; + // } - AddSeriesTokens(tokenHandlers, series); - AddSeasonTokens(tokenHandlers, seasonNumber); + // if (token.StartsWith("{Quality", StringComparison.InvariantCultureIgnoreCase)) + // { + // basicNamingConfig.IncludeQuality = true; + // } + //} - return CleanFolderName(ReplaceTokens(namingConfig.SeasonFolderFormat, tokenHandlers, namingConfig)); + //return basicNamingConfig; } public string GetMovieFolder(Movie movie, NamingConfig namingConfig = null) @@ -429,136 +305,6 @@ namespace NzbDrone.Core.Organizer return CleanFileName(name); } - private void AddSeriesTokens(Dictionary> tokenHandlers, Series series) - { - tokenHandlers["{Series Title}"] = m => series.Title; - tokenHandlers["{Series CleanTitle}"] = m => CleanTitle(series.Title); - } - - private string AddSeasonEpisodeNumberingTokens(string pattern, Dictionary> tokenHandlers, List episodes, NamingConfig namingConfig) - { - var episodeFormats = GetEpisodeFormat(pattern).DistinctBy(v => v.SeasonEpisodePattern).ToList(); - - int index = 1; - foreach (var episodeFormat in episodeFormats) - { - var seasonEpisodePattern = episodeFormat.SeasonEpisodePattern; - string formatPattern; - - switch ((MultiEpisodeStyle)namingConfig.MultiEpisodeStyle) - { - case MultiEpisodeStyle.Duplicate: - formatPattern = episodeFormat.Separator + episodeFormat.SeasonEpisodePattern; - seasonEpisodePattern = FormatNumberTokens(seasonEpisodePattern, formatPattern, episodes); - break; - - case MultiEpisodeStyle.Repeat: - formatPattern = episodeFormat.EpisodeSeparator + episodeFormat.EpisodePattern; - seasonEpisodePattern = FormatNumberTokens(seasonEpisodePattern, formatPattern, episodes); - break; - - case MultiEpisodeStyle.Scene: - formatPattern = "-" + episodeFormat.EpisodeSeparator + episodeFormat.EpisodePattern; - seasonEpisodePattern = FormatNumberTokens(seasonEpisodePattern, formatPattern, episodes); - break; - - case MultiEpisodeStyle.Range: - formatPattern = "-" + episodeFormat.EpisodePattern; - seasonEpisodePattern = FormatRangeNumberTokens(seasonEpisodePattern, formatPattern, episodes); - break; - - case MultiEpisodeStyle.PrefixedRange: - formatPattern = "-" + episodeFormat.EpisodeSeparator + episodeFormat.EpisodePattern; - seasonEpisodePattern = FormatRangeNumberTokens(seasonEpisodePattern, formatPattern, episodes); - break; - - //MultiEpisodeStyle.Extend - default: - formatPattern = "-" + episodeFormat.EpisodePattern; - seasonEpisodePattern = FormatNumberTokens(seasonEpisodePattern, formatPattern, episodes); - break; - } - - var token = string.Format("{{Season Episode{0}}}", index++); - pattern = pattern.Replace(episodeFormat.SeasonEpisodePattern, token); - tokenHandlers[token] = m => seasonEpisodePattern; - } - - AddSeasonTokens(tokenHandlers, episodes.First().SeasonNumber); - - if (episodes.Count > 1) - { - tokenHandlers["{Episode}"] = m => episodes.First().EpisodeNumber.ToString(m.CustomFormat) + "-" + episodes.Last().EpisodeNumber.ToString(m.CustomFormat); - } - else - { - tokenHandlers["{Episode}"] = m => episodes.First().EpisodeNumber.ToString(m.CustomFormat); - } - - return pattern; - } - - private string AddAbsoluteNumberingTokens(string pattern, Dictionary> tokenHandlers, Series series, List episodes, NamingConfig namingConfig) - { - var absoluteEpisodeFormats = GetAbsoluteFormat(pattern).DistinctBy(v => v.AbsoluteEpisodePattern).ToList(); - - int index = 1; - foreach (var absoluteEpisodeFormat in absoluteEpisodeFormats) - { - if (series.SeriesType != SeriesTypes.Anime) - { - pattern = pattern.Replace(absoluteEpisodeFormat.AbsoluteEpisodePattern, ""); - continue; - } - - var absoluteEpisodePattern = absoluteEpisodeFormat.AbsoluteEpisodePattern; - string formatPattern; - - switch ((MultiEpisodeStyle)namingConfig.MultiEpisodeStyle) - { - - case MultiEpisodeStyle.Duplicate: - formatPattern = absoluteEpisodeFormat.Separator + absoluteEpisodeFormat.AbsoluteEpisodePattern; - absoluteEpisodePattern = FormatAbsoluteNumberTokens(absoluteEpisodePattern, formatPattern, episodes); - break; - - case MultiEpisodeStyle.Repeat: - var repeatSeparator = absoluteEpisodeFormat.Separator.Trim().IsNullOrWhiteSpace() ? " " : absoluteEpisodeFormat.Separator.Trim(); - - formatPattern = repeatSeparator + absoluteEpisodeFormat.AbsoluteEpisodePattern; - absoluteEpisodePattern = FormatAbsoluteNumberTokens(absoluteEpisodePattern, formatPattern, episodes); - break; - - case MultiEpisodeStyle.Scene: - formatPattern = "-" + absoluteEpisodeFormat.AbsoluteEpisodePattern; - absoluteEpisodePattern = FormatAbsoluteNumberTokens(absoluteEpisodePattern, formatPattern, episodes); - break; - - case MultiEpisodeStyle.Range: - case MultiEpisodeStyle.PrefixedRange: - formatPattern = "-" + absoluteEpisodeFormat.AbsoluteEpisodePattern; - var eps = new List { episodes.First() }; - - if (episodes.Count > 1) eps.Add(episodes.Last()); - - absoluteEpisodePattern = FormatAbsoluteNumberTokens(absoluteEpisodePattern, formatPattern, eps); - break; - - //MultiEpisodeStyle.Extend - default: - formatPattern = "-" + absoluteEpisodeFormat.AbsoluteEpisodePattern; - absoluteEpisodePattern = FormatAbsoluteNumberTokens(absoluteEpisodePattern, formatPattern, episodes); - break; - } - - var token = string.Format("{{Absolute Pattern{0}}}", index++); - pattern = pattern.Replace(absoluteEpisodeFormat.AbsoluteEpisodePattern, token); - tokenHandlers[token] = m => absoluteEpisodePattern; - } - - return pattern; - } - private void AddMovieTokens(Dictionary> tokenHandlers, Movie movie) { tokenHandlers["{Movie Title}"] = m => movie.Title; @@ -584,33 +330,6 @@ namespace NzbDrone.Core.Organizer tokenHandlers["{IMDb Id}"] = m => $"{imdbId}"; } - private void AddSeasonTokens(Dictionary> tokenHandlers, int seasonNumber) - { - tokenHandlers["{Season}"] = m => seasonNumber.ToString(m.CustomFormat); - } - - private void AddEpisodeTokens(Dictionary> tokenHandlers, List episodes) - { - if (!episodes.First().AirDate.IsNullOrWhiteSpace()) - { - tokenHandlers["{Air Date}"] = m => episodes.First().AirDate.Replace('-', ' '); - } - else - { - tokenHandlers["{Air Date}"] = m => "Unknown"; - } - - tokenHandlers["{Episode Title}"] = m => GetEpisodeTitle(episodes, "+"); - tokenHandlers["{Episode CleanTitle}"] = m => CleanTitle(GetEpisodeTitle(episodes, "and")); - } - - private void AddEpisodeFileTokens(Dictionary> tokenHandlers, EpisodeFile episodeFile) - { - tokenHandlers["{Original Title}"] = m => GetOriginalTitle(episodeFile); - tokenHandlers["{Original Filename}"] = m => GetOriginalFileName(episodeFile); - tokenHandlers["{Release Group}"] = m => episodeFile.ReleaseGroup ?? m.DefaultValue("Radarr"); - } - private void AddMovieFileTokens(Dictionary> tokenHandlers, MovieFile episodeFile) { tokenHandlers["{Original Title}"] = m => GetOriginalTitle(episodeFile); @@ -619,18 +338,6 @@ namespace NzbDrone.Core.Organizer tokenHandlers["{Release Group}"] = m => episodeFile.ReleaseGroup ?? m.DefaultValue("Radarr"); } - private void AddQualityTokens(Dictionary> tokenHandlers, Series series, EpisodeFile episodeFile) - { - var qualityTitle = _qualityDefinitionService.Get(episodeFile.Quality.Quality).Title; - var qualityProper = GetQualityProper(series, episodeFile.Quality); - var qualityReal = GetQualityReal(series, episodeFile.Quality); - - tokenHandlers["{Quality Full}"] = m => String.Format("{0} {1} {2}", qualityTitle, qualityProper, qualityReal); - tokenHandlers["{Quality Title}"] = m => qualityTitle; - tokenHandlers["{Quality Proper}"] = m => qualityProper; - tokenHandlers["{Quality Real}"] = m => qualityReal; - } - private void AddQualityTokens(Dictionary> tokenHandlers, Movie movie, MovieFile movieFile) { if (movieFile?.Quality?.Quality == null) @@ -652,110 +359,6 @@ namespace NzbDrone.Core.Organizer tokenHandlers["{Quality Real}"] = m => qualityReal; } - private void AddMediaInfoTokens(Dictionary> tokenHandlers, EpisodeFile episodeFile) - { - if (episodeFile.MediaInfo == null) return; - - string videoCodec; - switch (episodeFile.MediaInfo.VideoCodec) - { - case "AVC": - if (episodeFile.SceneName.IsNotNullOrWhiteSpace() && Path.GetFileNameWithoutExtension(episodeFile.SceneName).Contains("h264")) - { - videoCodec = "h264"; - } - else - { - videoCodec = "x264"; - } - break; - - case "V_MPEGH/ISO/HEVC": - if (episodeFile.SceneName.IsNotNullOrWhiteSpace() && Path.GetFileNameWithoutExtension(episodeFile.SceneName).Contains("h265")) - { - videoCodec = "h265"; - } - else - { - videoCodec = "x265"; - } - break; - - case "MPEG-2 Video": - videoCodec = "MPEG2"; - break; - - default: - videoCodec = episodeFile.MediaInfo.VideoCodec; - break; - } - - string audioCodec; - switch (episodeFile.MediaInfo.AudioFormat) - { - case "AC-3": - audioCodec = "AC3"; - break; - - case "E-AC-3": - audioCodec = "EAC3"; - break; - - case "MPEG Audio": - if (episodeFile.MediaInfo.AudioProfile == "Layer 3") - { - audioCodec = "MP3"; - } - else - { - audioCodec = episodeFile.MediaInfo.AudioFormat; - } - break; - - case "DTS": - audioCodec = episodeFile.MediaInfo.AudioFormat; - break; - - default: - audioCodec = episodeFile.MediaInfo.AudioFormat; - break; - } - - var mediaInfoAudioLanguages = GetLanguagesToken(episodeFile.MediaInfo.AudioLanguages); - if (!mediaInfoAudioLanguages.IsNullOrWhiteSpace()) - { - mediaInfoAudioLanguages = string.Format("[{0}]", mediaInfoAudioLanguages); - } - - if (mediaInfoAudioLanguages == "[EN]") - { - mediaInfoAudioLanguages = string.Empty; - } - - var mediaInfoSubtitleLanguages = GetLanguagesToken(episodeFile.MediaInfo.Subtitles); - if (!mediaInfoSubtitleLanguages.IsNullOrWhiteSpace()) - { - mediaInfoSubtitleLanguages = string.Format("[{0}]", mediaInfoSubtitleLanguages); - } - - var videoBitDepth = episodeFile.MediaInfo.VideoBitDepth > 0 ? episodeFile.MediaInfo.VideoBitDepth.ToString() : string.Empty; - var audioChannels = episodeFile.MediaInfo.FormattedAudioChannels > 0 ? - episodeFile.MediaInfo.FormattedAudioChannels.ToString("F1", CultureInfo.InvariantCulture) : - string.Empty; - - tokenHandlers["{MediaInfo Video}"] = m => videoCodec; - tokenHandlers["{MediaInfo VideoCodec}"] = m => videoCodec; - tokenHandlers["{MediaInfo VideoBitDepth}"] = m => videoBitDepth; - - tokenHandlers["{MediaInfo Audio}"] = m => audioCodec; - tokenHandlers["{MediaInfo AudioCodec}"] = m => audioCodec; - tokenHandlers["{MediaInfo AudioChannels}"] = m => audioChannels; - - tokenHandlers["{MediaInfo Simple}"] = m => string.Format("{0} {1}", videoCodec, audioCodec); - - tokenHandlers["{MediaInfo Full}"] = m => string.Format("{0} {1}{2} {3}", videoCodec, audioCodec, mediaInfoAudioLanguages, mediaInfoSubtitleLanguages); - } - private void AddMediaInfoTokens(Dictionary> tokenHandlers, MovieFile movieFile) { if (movieFile.MediaInfo == null) return; @@ -964,48 +567,6 @@ namespace NzbDrone.Core.Organizer return replacementText; } - private string FormatNumberTokens(string basePattern, string formatPattern, List episodes) - { - var pattern = string.Empty; - - for (int i = 0; i < episodes.Count; i++) - { - var patternToReplace = i == 0 ? basePattern : formatPattern; - - pattern += EpisodeRegex.Replace(patternToReplace, match => ReplaceNumberToken(match.Groups["episode"].Value, episodes[i].EpisodeNumber)); - } - - return ReplaceSeasonTokens(pattern, episodes.First().SeasonNumber); - } - - private string FormatAbsoluteNumberTokens(string basePattern, string formatPattern, List episodes) - { - var pattern = string.Empty; - - for (int i = 0; i < episodes.Count; i++) - { - var patternToReplace = i == 0 ? basePattern : formatPattern; - - pattern += AbsoluteEpisodeRegex.Replace(patternToReplace, match => ReplaceNumberToken(match.Groups["absolute"].Value, episodes[i].AbsoluteEpisodeNumber.Value)); - } - - return ReplaceSeasonTokens(pattern, episodes.First().SeasonNumber); - } - - private string FormatRangeNumberTokens(string seasonEpisodePattern, string formatPattern, List episodes) - { - var eps = new List { episodes.First() }; - - if (episodes.Count > 1) eps.Add(episodes.Last()); - - return FormatNumberTokens(seasonEpisodePattern, formatPattern, eps); - } - - private string ReplaceSeasonTokens(string pattern, int seasonNumber) - { - return SeasonRegex.Replace(pattern, match => ReplaceNumberToken(match.Groups["season"].Value, seasonNumber)); - } - private string ReplaceNumberToken(string token, int value) { var split = token.Trim('{', '}').Split(':'); @@ -1026,46 +587,6 @@ namespace NzbDrone.Core.Organizer }).ToArray()); } - private AbsoluteEpisodeFormat[] GetAbsoluteFormat(string pattern) - { - return _absoluteEpisodeFormatCache.Get(pattern, () => AbsoluteEpisodePatternRegex.Matches(pattern).OfType() - .Select(match => new AbsoluteEpisodeFormat - { - Separator = match.Groups["separator"].Value.IsNotNullOrWhiteSpace() ? match.Groups["separator"].Value : "-", - AbsoluteEpisodePattern = match.Groups["absolute"].Value - }).ToArray()); - } - - private string GetEpisodeTitle(List episodes, string separator) - { - separator = string.Format(" {0} ", separator.Trim()); - - if (episodes.Count == 1) - { - return episodes.First().Title.TrimEnd(EpisodeTitleTrimCharacters); - } - - var titles = episodes.Select(c => c.Title.TrimEnd(EpisodeTitleTrimCharacters)) - .Select(CleanupEpisodeTitle) - .Distinct() - .ToList(); - - if (titles.All(t => t.IsNullOrWhiteSpace())) - { - titles = episodes.Select(c => c.Title.TrimEnd(EpisodeTitleTrimCharacters)) - .Distinct() - .ToList(); - } - - return string.Join(separator, titles); - } - - private string CleanupEpisodeTitle(string title) - { - //this will remove (1),(2) from the end of multi part episodes. - return MultiPartCleanupRegex.Replace(title, string.Empty).Trim(); - } - private string GetQualityProper(Movie movie, QualityModel quality) { if (quality.Revision.Version > 1) @@ -1076,31 +597,6 @@ namespace NzbDrone.Core.Organizer return String.Empty; } - private string GetQualityProper(Series series, QualityModel quality) - { - if (quality.Revision.Version > 1) - { - if (series.SeriesType == SeriesTypes.Anime) - { - return "v" + quality.Revision.Version; - } - - return "Proper"; - } - - return String.Empty; - } - - private string GetQualityReal(Series series, QualityModel quality) - { - if (quality.Revision.Real > 0) - { - return "REAL"; - } - - return string.Empty; - } - private string GetQualityReal(Movie movie, QualityModel quality) { if (quality.Revision.Real > 0) @@ -1111,26 +607,6 @@ namespace NzbDrone.Core.Organizer return string.Empty; } - private string GetOriginalTitle(EpisodeFile episodeFile) - { - if (episodeFile.SceneName.IsNullOrWhiteSpace()) - { - return GetOriginalFileName(episodeFile); - } - - return episodeFile.SceneName; - } - - private string GetOriginalFileName(EpisodeFile episodeFile) - { - if (episodeFile.RelativePath.IsNullOrWhiteSpace()) - { - return Path.GetFileNameWithoutExtension(episodeFile.Path); - } - - return Path.GetFileNameWithoutExtension(episodeFile.RelativePath); - } - private string GetOriginalTitle(MovieFile episodeFile) { if (episodeFile.SceneName.IsNullOrWhiteSpace()) @@ -1183,4 +659,4 @@ namespace NzbDrone.Core.Organizer Range = 4, PrefixedRange = 5 } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/Organizer/FileNameSampleService.cs b/src/NzbDrone.Core/Organizer/FileNameSampleService.cs index f48c49701..58d785b98 100644 --- a/src/NzbDrone.Core/Organizer/FileNameSampleService.cs +++ b/src/NzbDrone.Core/Organizer/FileNameSampleService.cs @@ -1,7 +1,7 @@ -using System.Collections.Generic; +using System.Collections.Generic; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.MediaFiles.MediaInfo; using System; @@ -9,33 +9,13 @@ namespace NzbDrone.Core.Organizer { public interface IFilenameSampleService { - SampleResult GetStandardSample(NamingConfig nameSpec); - SampleResult GetMultiEpisodeSample(NamingConfig nameSpec); - SampleResult GetDailySample(NamingConfig nameSpec); - SampleResult GetAnimeSample(NamingConfig nameSpec); - SampleResult GetAnimeMultiEpisodeSample(NamingConfig nameSpec); SampleResult GetMovieSample(NamingConfig nameSpec); - string GetSeriesFolderSample(NamingConfig nameSpec); - string GetSeasonFolderSample(NamingConfig nameSpec); string GetMovieFolderSample(NamingConfig nameSpec); } public class FileNameSampleService : IFilenameSampleService { private readonly IBuildFileNames _buildFileNames; - private static Series _standardSeries; - private static Series _dailySeries; - private static Series _animeSeries; - private static Episode _episode1; - private static Episode _episode2; - private static Episode _episode3; - private static List _singleEpisode; - private static List _multiEpisodes; - private static EpisodeFile _singleEpisodeFile; - private static EpisodeFile _multiEpisodeFile; - private static EpisodeFile _dailyEpisodeFile; - private static EpisodeFile _animeEpisodeFile; - private static EpisodeFile _animeMultiEpisodeFile; private static MovieFile _movieFile; private static Movie _movie; @@ -44,52 +24,6 @@ namespace NzbDrone.Core.Organizer { _buildFileNames = buildFileNames; - _standardSeries = new Series - { - SeriesType = SeriesTypes.Standard, - Title = "Series Title (2010)" - }; - - _dailySeries = new Series - { - SeriesType = SeriesTypes.Daily, - Title = "Series Title (2010)" - }; - - _animeSeries = new Series - { - SeriesType = SeriesTypes.Anime, - Title = "Series Title (2010)" - }; - - _episode1 = new Episode - { - SeasonNumber = 1, - EpisodeNumber = 1, - Title = "Episode Title (1)", - AirDate = "2013-10-30", - AbsoluteEpisodeNumber = 1, - }; - - _episode2 = new Episode - { - SeasonNumber = 1, - EpisodeNumber = 2, - Title = "Episode Title (2)", - AbsoluteEpisodeNumber = 2 - }; - - _episode3 = new Episode - { - SeasonNumber = 1, - EpisodeNumber = 3, - Title = "Episode Title (3)", - AbsoluteEpisodeNumber = 3 - }; - - _singleEpisode = new List { _episode1 }; - _multiEpisodes = new List { _episode1, _episode2, _episode3 }; - var mediaInfo = new MediaInfoModel() { VideoCodec = "AVC", @@ -130,116 +64,6 @@ namespace NzbDrone.Core.Organizer MovieFile = _movieFile, MovieFileId = 1, }; - - _singleEpisodeFile = new EpisodeFile - { - Quality = new QualityModel(Quality.HDTV720p, new Revision(2)), - RelativePath = "Series.Title.S01E01.720p.HDTV.x264-EVOLVE.mkv", - SceneName = "Series.Title.S01E01.720p.HDTV.x264-EVOLVE", - ReleaseGroup = "RlsGrp", - MediaInfo = mediaInfo - }; - - _multiEpisodeFile = new EpisodeFile - { - Quality = new QualityModel(Quality.HDTV720p, new Revision(2)), - RelativePath = "Series.Title.S01E01-E03.720p.HDTV.x264-EVOLVE.mkv", - SceneName = "Series.Title.S01E01-E03.720p.HDTV.x264-EVOLVE", - ReleaseGroup = "RlsGrp", - MediaInfo = mediaInfo, - }; - - _dailyEpisodeFile = new EpisodeFile - { - Quality = new QualityModel(Quality.HDTV720p, new Revision(2)), - RelativePath = "Series.Title.2013.10.30.HDTV.x264-EVOLVE.mkv", - SceneName = "Series.Title.2013.10.30.HDTV.x264-EVOLVE", - ReleaseGroup = "RlsGrp", - MediaInfo = mediaInfo - }; - - _animeEpisodeFile = new EpisodeFile - { - Quality = new QualityModel(Quality.HDTV720p, new Revision(2)), - RelativePath = "[RlsGroup] Series Title - 001 [720p].mkv", - SceneName = "[RlsGroup] Series Title - 001 [720p]", - ReleaseGroup = "RlsGrp", - MediaInfo = mediaInfoAnime - }; - - _animeMultiEpisodeFile = new EpisodeFile - { - Quality = new QualityModel(Quality.HDTV720p, new Revision(2)), - RelativePath = "[RlsGroup] Series Title - 001 - 103 [720p].mkv", - SceneName = "[RlsGroup] Series Title - 001 - 103 [720p]", - ReleaseGroup = "RlsGrp", - MediaInfo = mediaInfoAnime - }; - } - - public SampleResult GetStandardSample(NamingConfig nameSpec) - { - var result = new SampleResult - { - FileName = BuildSample(_singleEpisode, _standardSeries, _singleEpisodeFile, nameSpec), - Series = _standardSeries, - Episodes = _singleEpisode, - EpisodeFile = _singleEpisodeFile - }; - - return result; - } - - public SampleResult GetMultiEpisodeSample(NamingConfig nameSpec) - { - var result = new SampleResult - { - FileName = BuildSample(_multiEpisodes, _standardSeries, _multiEpisodeFile, nameSpec), - Series = _standardSeries, - Episodes = _multiEpisodes, - EpisodeFile = _multiEpisodeFile - }; - - return result; - } - - public SampleResult GetDailySample(NamingConfig nameSpec) - { - var result = new SampleResult - { - FileName = BuildSample(_singleEpisode, _dailySeries, _dailyEpisodeFile, nameSpec), - Series = _dailySeries, - Episodes = _singleEpisode, - EpisodeFile = _dailyEpisodeFile - }; - - return result; - } - - public SampleResult GetAnimeSample(NamingConfig nameSpec) - { - var result = new SampleResult - { - FileName = BuildSample(_singleEpisode, _animeSeries, _animeEpisodeFile, nameSpec), - Series = _animeSeries, - Episodes = _singleEpisode, - EpisodeFile = _animeEpisodeFile - }; - - return result; - } - - public SampleResult GetAnimeMultiEpisodeSample(NamingConfig nameSpec) - { - var result = new SampleResult - { - FileName = BuildSample(_multiEpisodes, _animeSeries, _animeMultiEpisodeFile, nameSpec), - Series = _animeSeries, - Episodes = _multiEpisodes, - EpisodeFile = _animeMultiEpisodeFile - }; - - return result; } public SampleResult GetMovieSample(NamingConfig nameSpec) @@ -252,33 +76,11 @@ namespace NzbDrone.Core.Organizer return result; } - public string GetSeriesFolderSample(NamingConfig nameSpec) - { - return _buildFileNames.GetSeriesFolder(_standardSeries, nameSpec); - } - - public string GetSeasonFolderSample(NamingConfig nameSpec) - { - return _buildFileNames.GetSeasonFolder(_standardSeries, _episode1.SeasonNumber, nameSpec); - } - public string GetMovieFolderSample(NamingConfig nameSpec) { return _buildFileNames.GetMovieFolder(_movie, nameSpec); } - private string BuildSample(List episodes, Series series, EpisodeFile episodeFile, NamingConfig nameSpec) - { - try - { - return _buildFileNames.BuildFileName(episodes, series, episodeFile, nameSpec); - } - catch (NamingFormatException) - { - return string.Empty; - } - } - private string BuildSample(Movie movie, MovieFile movieFile, NamingConfig nameSpec) { try diff --git a/src/NzbDrone.Core/Organizer/FileNameValidation.cs b/src/NzbDrone.Core/Organizer/FileNameValidation.cs index 9ecfa6b42..414776818 100644 --- a/src/NzbDrone.Core/Organizer/FileNameValidation.cs +++ b/src/NzbDrone.Core/Organizer/FileNameValidation.cs @@ -33,7 +33,7 @@ namespace NzbDrone.Core.Organizer public static IRuleBuilderOptions ValidSeriesFolderFormat(this IRuleBuilder ruleBuilder) { ruleBuilder.SetValidator(new NotEmptyValidator(null)); - return ruleBuilder.SetValidator(new RegularExpressionValidator(FileNameBuilder.SeriesTitleRegex)).WithMessage("Must contain series title"); + return ruleBuilder.SetValidator(new RegularExpressionValidator(FileNameBuilder.SeriesTitleRegex)).WithMessage("Must contain movie title"); } public static IRuleBuilderOptions ValidSeasonFolderFormat(this IRuleBuilder ruleBuilder) diff --git a/src/NzbDrone.Core/Organizer/FileNameValidationService.cs b/src/NzbDrone.Core/Organizer/FileNameValidationService.cs index ef2230c45..878306283 100644 --- a/src/NzbDrone.Core/Organizer/FileNameValidationService.cs +++ b/src/NzbDrone.Core/Organizer/FileNameValidationService.cs @@ -1,17 +1,14 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using FluentValidation.Results; using NzbDrone.Core.Configuration; using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Organizer { public interface IFilenameValidationService { - ValidationFailure ValidateStandardFilename(SampleResult sampleResult); - ValidationFailure ValidateDailyFilename(SampleResult sampleResult); - ValidationFailure ValidateAnimeFilename(SampleResult sampleResult); ValidationFailure ValidateMovieFilename(SampleResult sampleResult); } @@ -31,90 +28,5 @@ namespace NzbDrone.Core.Organizer return null; } - - public ValidationFailure ValidateStandardFilename(SampleResult sampleResult) - { - var validationFailure = new ValidationFailure("StandardEpisodeFormat", ERROR_MESSAGE); - var parsedEpisodeInfo = Parser.Parser.ParseTitle(sampleResult.FileName); - - if (parsedEpisodeInfo == null) - { - return validationFailure; - } - - if (!ValidateSeasonAndEpisodeNumbers(sampleResult.Episodes, parsedEpisodeInfo)) - { - return validationFailure; - } - - return null; - } - - public ValidationFailure ValidateDailyFilename(SampleResult sampleResult) - { - var validationFailure = new ValidationFailure("DailyEpisodeFormat", ERROR_MESSAGE); - var parsedEpisodeInfo = Parser.Parser.ParseTitle(sampleResult.FileName); - - if (parsedEpisodeInfo == null) - { - return validationFailure; - } - - if (parsedEpisodeInfo.IsDaily) - { - if (!parsedEpisodeInfo.AirDate.Equals(sampleResult.Episodes.Single().AirDate)) - { - return validationFailure; - } - - return null; - } - - if (!ValidateSeasonAndEpisodeNumbers(sampleResult.Episodes, parsedEpisodeInfo)) - { - return validationFailure; - } - - return null; - } - - public ValidationFailure ValidateAnimeFilename(SampleResult sampleResult) - { - var validationFailure = new ValidationFailure("AnimeEpisodeFormat", ERROR_MESSAGE); - var parsedEpisodeInfo = Parser.Parser.ParseTitle(sampleResult.FileName); - - if (parsedEpisodeInfo == null) - { - return validationFailure; - } - - if (parsedEpisodeInfo.AbsoluteEpisodeNumbers.Any()) - { - if (!parsedEpisodeInfo.AbsoluteEpisodeNumbers.First().Equals(sampleResult.Episodes.First().AbsoluteEpisodeNumber)) - { - return validationFailure; - } - - return null; - } - - if (!ValidateSeasonAndEpisodeNumbers(sampleResult.Episodes, parsedEpisodeInfo)) - { - return validationFailure; - } - - return null; - } - - private bool ValidateSeasonAndEpisodeNumbers(List episodes, ParsedEpisodeInfo parsedEpisodeInfo) - { - if (parsedEpisodeInfo.SeasonNumber != episodes.First().SeasonNumber || - !parsedEpisodeInfo.EpisodeNumbers.OrderBy(e => e).SequenceEqual(episodes.Select(e => e.EpisodeNumber).OrderBy(e => e))) - { - return false; - } - - return true; - } } } diff --git a/src/NzbDrone.Core/Organizer/NamingConfig.cs b/src/NzbDrone.Core/Organizer/NamingConfig.cs index a617d5e61..5ce8324b2 100644 --- a/src/NzbDrone.Core/Organizer/NamingConfig.cs +++ b/src/NzbDrone.Core/Organizer/NamingConfig.cs @@ -1,4 +1,4 @@ -using NzbDrone.Core.Datastore; +using NzbDrone.Core.Datastore; namespace NzbDrone.Core.Organizer { @@ -9,11 +9,6 @@ namespace NzbDrone.Core.Organizer RenameEpisodes = false, ReplaceIllegalCharacters = true, MultiEpisodeStyle = 0, - StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title} {Quality Full}", - DailyEpisodeFormat = "{Series Title} - {Air-Date} - {Episode Title} {Quality Full}", - AnimeEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title} {Quality Full}", - SeriesFolderFormat = "{Series Title}", - SeasonFolderFormat = "Season {season}", MovieFolderFormat = "{Movie Title} ({Release Year})", StandardMovieFormat = "{Movie Title} ({Release Year}) {Quality Full}", }; @@ -21,11 +16,6 @@ namespace NzbDrone.Core.Organizer public bool RenameEpisodes { get; set; } public bool ReplaceIllegalCharacters { get; set; } public int MultiEpisodeStyle { get; set; } - public string StandardEpisodeFormat { get; set; } - public string DailyEpisodeFormat { get; set; } - public string AnimeEpisodeFormat { get; set; } - public string SeriesFolderFormat { get; set; } - public string SeasonFolderFormat { get; set; } public string StandardMovieFormat { get; set; } public string MovieFolderFormat { get; set; } } diff --git a/src/NzbDrone.Core/Organizer/SampleResult.cs b/src/NzbDrone.Core/Organizer/SampleResult.cs index 0f3885a1b..2c29ed98e 100644 --- a/src/NzbDrone.Core/Organizer/SampleResult.cs +++ b/src/NzbDrone.Core/Organizer/SampleResult.cs @@ -1,14 +1,13 @@ -using System.Collections.Generic; +using System.Collections.Generic; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Organizer { public class SampleResult { public string FileName { get; set; } - public Series Series { get; set; } - public List Episodes { get; set; } - public EpisodeFile EpisodeFile { get; set; } + public Movie Movie { get; set; } + public MovieFile MovieFile { get; set; } } } diff --git a/src/NzbDrone.Core/Parser/Model/LocalEpisode.cs b/src/NzbDrone.Core/Parser/Model/LocalEpisode.cs deleted file mode 100644 index 67ec2d873..000000000 --- a/src/NzbDrone.Core/Parser/Model/LocalEpisode.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Linq; -using System.Collections.Generic; -using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; -using NzbDrone.Core.MediaFiles.MediaInfo; - -namespace NzbDrone.Core.Parser.Model -{ - public class LocalEpisode - { - public LocalEpisode() - { - Episodes = new List(); - } - - public string Path { get; set; } - public long Size { get; set; } - public ParsedEpisodeInfo ParsedEpisodeInfo { get; set; } - public Series Series { get; set; } - public List Episodes { get; set; } - public QualityModel Quality { get; set; } - public MediaInfoModel MediaInfo { get; set; } - public bool ExistingFile { get; set; } - - public int SeasonNumber - { - get - { - return Episodes.Select(c => c.SeasonNumber).Distinct().Single(); - } - } - - public bool IsSpecial => SeasonNumber == 0; - - public override string ToString() - { - return Path; - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Parser/Model/LocalMovie.cs b/src/NzbDrone.Core/Parser/Model/LocalMovie.cs index 5ae9c481d..ff20c5a71 100644 --- a/src/NzbDrone.Core/Parser/Model/LocalMovie.cs +++ b/src/NzbDrone.Core/Parser/Model/LocalMovie.cs @@ -1,7 +1,7 @@ using System.Linq; using System.Collections.Generic; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using NzbDrone.Core.MediaFiles.MediaInfo; namespace NzbDrone.Core.Parser.Model diff --git a/src/NzbDrone.Core/Parser/Model/ParsedEpisodeInfo.cs b/src/NzbDrone.Core/Parser/Model/ParsedEpisodeInfo.cs deleted file mode 100644 index 256269c36..000000000 --- a/src/NzbDrone.Core/Parser/Model/ParsedEpisodeInfo.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System.Linq; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Qualities; - -namespace NzbDrone.Core.Parser.Model -{ - public class ParsedEpisodeInfo - { - public string SeriesTitle { get; set; } - public SeriesTitleInfo SeriesTitleInfo { get; set; } - public QualityModel Quality { get; set; } - public int SeasonNumber { get; set; } - public int[] EpisodeNumbers { get; set; } - public int[] AbsoluteEpisodeNumbers { get; set; } - public string AirDate { get; set; } - public Language Language { get; set; } - public bool FullSeason { get; set; } - public bool Special { get; set; } - public string ReleaseGroup { get; set; } - public string ReleaseHash { get; set; } - - public ParsedEpisodeInfo() - { - EpisodeNumbers = new int[0]; - AbsoluteEpisodeNumbers = new int[0]; - } - - public bool IsDaily - { - get - { - return !string.IsNullOrWhiteSpace(AirDate); - } - - //This prevents manually downloading a release from blowing up in mono - //TODO: Is there a better way? - private set { } - } - - public bool IsAbsoluteNumbering - { - get - { - return AbsoluteEpisodeNumbers.Any(); - } - - //This prevents manually downloading a release from blowing up in mono - //TODO: Is there a better way? - private set { } - } - - public bool IsPossibleSpecialEpisode - { - get - { - // if we don't have eny episode numbers we are likely a special episode and need to do a search by episode title - return (AirDate.IsNullOrWhiteSpace() && - SeriesTitle.IsNullOrWhiteSpace() && - (EpisodeNumbers.Length == 0 || SeasonNumber == 0) || - !SeriesTitle.IsNullOrWhiteSpace() && Special); - } - - //This prevents manually downloading a release from blowing up in mono - //TODO: Is there a better way? - private set {} - } - - public override string ToString() - { - string episodeString = "[Unknown Episode]"; - - if (IsDaily && EpisodeNumbers.Empty()) - { - episodeString = string.Format("{0}", AirDate); - } - else if (FullSeason) - { - episodeString = string.Format("Season {0:00}", SeasonNumber); - } - else if (EpisodeNumbers != null && EpisodeNumbers.Any()) - { - episodeString = string.Format("S{0:00}E{1}", SeasonNumber, string.Join("-", EpisodeNumbers.Select(c => c.ToString("00")))); - } - else if (AbsoluteEpisodeNumbers != null && AbsoluteEpisodeNumbers.Any()) - { - episodeString = string.Format("{0}", string.Join("-", AbsoluteEpisodeNumbers.Select(c => c.ToString("000")))); - } - - return string.Format("{0} - {1} {2}", SeriesTitle, episodeString, Quality); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Parser/Model/RemoteEpisode.cs b/src/NzbDrone.Core/Parser/Model/RemoteEpisode.cs deleted file mode 100644 index 319606781..000000000 --- a/src/NzbDrone.Core/Parser/Model/RemoteEpisode.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Parser.Model -{ - public class RemoteEpisode - { - public ReleaseInfo Release { get; set; } - public ParsedEpisodeInfo ParsedEpisodeInfo { get; set; } - public Series Series { get; set; } - public List Episodes { get; set; } - public bool DownloadAllowed { get; set; } - - public bool IsRecentEpisode() - { - return Episodes.Any(e => e.AirDateUtc >= DateTime.UtcNow.Date.AddDays(-14)); - } - - public override string ToString() - { - return Release.Title; - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Parser/Model/RemoteMovie.cs b/src/NzbDrone.Core/Parser/Model/RemoteMovie.cs index 8a2145b06..b7efbde68 100644 --- a/src/NzbDrone.Core/Parser/Model/RemoteMovie.cs +++ b/src/NzbDrone.Core/Parser/Model/RemoteMovie.cs @@ -1,14 +1,13 @@ using System; using System.Collections.Generic; using System.Linq; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Parser.Model { public class RemoteMovie { public ReleaseInfo Release { get; set; } - public ParsedEpisodeInfo ParsedEpisodeInfo { get; set; } //TODO: Change to ParsedMovieInfo, for now though ParsedEpisodeInfo will do. public ParsedMovieInfo ParsedMovieInfo { get; set; } public Movie Movie { get; set; } public MappingResultType MappingResult { get; set; } @@ -18,4 +17,4 @@ namespace NzbDrone.Core.Parser.Model return Release.Title; } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index 2265734f6..af5f0740c 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -9,7 +9,7 @@ using NzbDrone.Common.Extensions; using NzbDrone.Common.Instrumentation; using NzbDrone.Core.Configuration; using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; using TinyIoC; namespace NzbDrone.Core.Parser @@ -59,196 +59,6 @@ namespace NzbDrone.Core.Parser }; - private static readonly Regex[] ReportTitleRegex = new[] - { - //Anime - Absolute Episode Number + Title + Season+Episode - //Todo: This currently breaks series that start with numbers -// new Regex(@"^(?:(?\d{2,3})(?:_|-|\s|\.)+)+(?.+?)(?:\W|_)+(?:S?(?<season>(?<!\d+)\d{1,2}(?!\d+))(?:(?:\-|[ex]|\W[ex]){1,2}(?<episode>\d{2}(?!\d+)))+)", -// RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Multi-Part episodes without a title (S01E05.S01E06) - new Regex(@"^(?:\W*S?(?<season>(?<!\d+)(?:\d{1,2}|\d{4})(?!\d+))(?:(?:[ex]){1,2}(?<episode>\d{1,3}(?!\d+)))+){2,}", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Matches Movie name with AirYear - new Regex(@"^(?<title>.+?)?(?:(?:[-_\W](?<![()\[!]))*(?<year>(?<!e|x)\d{4}(?!p|i|\d+|\)|\]|\W\d+)))+(\W+|_|$)(?!\\)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Episodes without a title, Single (S01E05, 1x05) AND Multi (S01E04E05, 1x04x05, etc) - new Regex(@"^(?:S?(?<season>(?<!\d+)(?:\d{1,2}|\d{4})(?!\d+))(?:(?:\-|[ex]|\W[ex]|_){1,2}(?<episode>\d{2,3}(?!\d+)))+)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Anime - [SubGroup] Title Episode Absolute Episode Number ([SubGroup] Series Title Episode 01) - new Regex(@"^(?:\[(?<subgroup>.+?)\][-_. ]?)(?<title>.+?)[-_. ](?:Episode)(?:[-_. ]+(?<absoluteepisode>(?<!\d+)\d{2,3}(?!\d+)))+(?:_|-|\s|\.)*?(?<hash>\[.{8}\])?(?:$|\.)?", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Anime - [SubGroup] Title Absolute Episode Number + Season+Episode - new Regex(@"^(?:\[(?<subgroup>.+?)\](?:_|-|\s|\.)?)(?<title>.+?)(?:(?:[-_\W](?<![()\[!]))+(?<absoluteepisode>\d{2,3}))+(?:_|-|\s|\.)+(?:S?(?<season>(?<!\d+)\d{1,2}(?!\d+))(?:(?:\-|[ex]|\W[ex]){1,2}(?<episode>\d{2}(?!\d+)))+).*?(?<hash>[(\[]\w{8}[)\]])?(?:$|\.)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Anime - [SubGroup] Title Season+Episode + Absolute Episode Number - new Regex(@"^(?:\[(?<subgroup>.+?)\](?:_|-|\s|\.)?)(?<title>.+?)(?:[-_\W](?<![()\[!]))+(?:S?(?<season>(?<!\d+)\d{1,2}(?!\d+))(?:(?:\-|[ex]|\W[ex]){1,2}(?<episode>\d{2}(?!\d+)))+)(?:(?:_|-|\s|\.)+(?<absoluteepisode>(?<!\d+)\d{2,3}(?!\d+)))+.*?(?<hash>\[\w{8}\])?(?:$|\.)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Anime - [SubGroup] Title Season+Episode - new Regex(@"^(?:\[(?<subgroup>.+?)\](?:_|-|\s|\.)?)(?<title>.+?)(?:[-_\W](?<![()\[!]))+(?:S?(?<season>(?<!\d+)\d{1,2}(?!\d+))(?:(?:[ex]|\W[ex]){1,2}(?<episode>\d{2}(?!\d+)))+)(?:\s|\.).*?(?<hash>\[\w{8}\])?(?:$|\.)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Anime - [SubGroup] Title with trailing number Absolute Episode Number - new Regex(@"^\[(?<subgroup>.+?)\][-_. ]?(?<title>[^-]+?\d+?)[-_. ]+(?:[-_. ]?(?<absoluteepisode>\d{3}(?!\d+)))+(?:[-_. ]+(?<special>special|ova|ovd))?.*?(?<hash>\[\w{8}\])?(?:$|\.mkv)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Anime - [SubGroup] Title - Absolute Episode Number - new Regex(@"^\[(?<subgroup>.+?)\][-_. ]?(?<title>.+?)(?:[. ]-[. ](?<absoluteepisode>\d{2,3}(?!\d+|[-])))+(?:[-_. ]+(?<special>special|ova|ovd))?.*?(?<hash>\[\w{8}\])?(?:$|\.mkv)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Anime - [SubGroup] Title Absolute Episode Number - new Regex(@"^\[(?<subgroup>.+?)\][-_. ]?(?<title>.+?)[-_. ]+\(?(?:[-_. ]?(?<absoluteepisode>\d{2,3}(?!\d+)))+\)?(?:[-_. ]+(?<special>special|ova|ovd))?.*?(?<hash>\[\w{8}\])?(?:$|\.mkv)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Anime - Title Season EpisodeNumber + Absolute Episode Number [SubGroup] - new Regex(@"^(?<title>.+?)(?:[-_\W](?<![()\[!]))+(?:S?(?<season>(?<!\d+)\d{1,2}(?!\d+))(?:(?:[ex]|\W[ex]){1,2}(?<episode>(?<!\d+)\d{2}(?!\d+)))+).+?(?:[-_. ]?(?<absoluteepisode>(?<!\d+)\d{3}(?!\d+)))+.+?\[(?<subgroup>.+?)\](?:$|\.mkv)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Anime - Title Absolute Episode Number [SubGroup] - new Regex(@"^(?<title>.+?)(?:(?:_|-|\s|\.)+(?<absoluteepisode>\d{3}(?!\d+)))+(?:.+?)\[(?<subgroup>.+?)\].*?(?<hash>\[\w{8}\])?(?:$|\.)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Anime - Title Absolute Episode Number [Hash] - new Regex(@"^(?<title>.+?)(?:(?:_|-|\s|\.)+(?<absoluteepisode>\d{2,3}(?!\d+)))+(?:[-_. ]+(?<special>special|ova|ovd))?[-_. ]+.*?(?<hash>\[\w{8}\])(?:$|\.)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Episodes with airdate AND season/episode number, capture season/epsiode only - new Regex(@"^(?<title>.+?)?\W*(?<airdate>\d{4}\W+[0-1][0-9]\W+[0-3][0-9])(?!\W+[0-3][0-9])[-_. ](?:s?(?<season>(?<!\d+)(?:\d{1,2})(?!\d+)))(?:[ex](?<episode>(?<!\d+)(?:\d{1,3})(?!\d+)))", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Episodes with airdate AND season/episode number - new Regex(@"^(?<title>.+?)?\W*(?<airyear>\d{4})\W+(?<airmonth>[0-1][0-9])\W+(?<airday>[0-3][0-9])(?!\W+[0-3][0-9]).+?(?:s?(?<season>(?<!\d+)(?:\d{1,2})(?!\d+)))(?:[ex](?<episode>(?<!\d+)(?:\d{1,3})(?!\d+)))", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Multi-episode Repeated (S01E05 - S01E06, 1x05 - 1x06, etc) - new Regex(@"^(?<title>.+?)(?:(?:[-_\W](?<![()\[!]))+S?(?<season>(?<!\d+)(?:\d{1,2}|\d{4})(?!\d+))(?:(?:[ex]|[-_. ]e){1,2}(?<episode>\d{1,3}(?!\d+)))+){2,}", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Episodes with a title, Single episodes (S01E05, 1x05, etc) & Multi-episode (S01E05E06, S01E05-06, S01E05 E06, etc) - new Regex(@"^(?<title>.+?)(?:(?:[-_\W](?<![()\[!]))+S?(?<season>(?<!\d+)(?:\d{1,2})(?!\d+))(?:[ex]|\W[ex]|_){1,2}(?<episode>\d{2,3}(?!\d+))(?:(?:\-|[ex]|\W[ex]|_){1,2}(?<episode>\d{2,3}(?!\d+)))*)\W?(?!\\)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Episodes with a title, 4 digit season number, Single episodes (S2016E05, etc) & Multi-episode (S2016E05E06, S2016E05-06, S2016E05 E06, etc) - new Regex(@"^(?<title>.+?)(?:(?:[-_\W](?<![()\[!]))+S(?<season>(?<!\d+)(?:\d{4})(?!\d+))(?:[ex]|\W[ex]|_){1,2}(?<episode>\d{2,3}(?!\d+))(?:(?:\-|[ex]|\W[ex]|_){1,2}(?<episode>\d{2,3}(?!\d+)))*)\W?(?!\\)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Mini-Series with year in title, treated as season 1, episodes are labelled as Part01, Part 01, Part.1 - new Regex(@"^(?<title>.+?\d{4})(?:\W+(?:(?:Part\W?|e)(?<episode>\d{1,2}(?!\d+)))+)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Mini-Series, treated as season 1, episodes are labelled as Part01, Part 01, Part.1 - new Regex(@"^(?<title>.+?)(?:\W+(?:(?:Part\W?|(?<!\d+\W+)e)(?<episode>\d{1,2}(?!\d+)))+)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Mini-Series, treated as season 1, episodes are labelled as Part One/Two/Three/...Nine, Part.One, Part_One - new Regex(@"^(?<title>.+?)(?:\W+(?:Part[-._ ](?<episode>One|Two|Three|Four|Five|Six|Seven|Eight|Nine)(?>[-._ ])))", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Mini-Series, treated as season 1, episodes are labelled as XofY - new Regex(@"^(?<title>.+?)(?:\W+(?:(?<episode>(?<!\d+)\d{1,2}(?!\d+))of\d+)+)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Supports Season 01 Episode 03 - new Regex(@"(?:.*(?:\""|^))(?<title>.*?)(?:[-_\W](?<![()\[]))+(?:\W?Season\W?)(?<season>(?<!\d+)\d{1,2}(?!\d+))(?:\W|_)+(?:Episode\W)(?:[-_. ]?(?<episode>(?<!\d+)\d{1,2}(?!\d+)))+", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Multi-episode release with no space between series title and season (S01E11E12) - new Regex(@"(?:.*(?:^))(?<title>.*?)(?:\W?|_)S(?<season>(?<!\d+)\d{2}(?!\d+))(?:E(?<episode>(?<!\d+)\d{2}(?!\d+)))+", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Multi-episode with single episode numbers (S6.E1-E2, S6.E1E2, S6E1E2, etc) - new Regex(@"^(?<title>.+?)[-_. ]S(?<season>(?<!\d+)(?:\d{1,2}|\d{4})(?!\d+))(?:[-_. ]?[ex]?(?<episode>(?<!\d+)\d{1,2}(?!\d+)))+", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Single episode season or episode S1E1 or S1-E1 - new Regex(@"(?:.*(?:\""|^))(?<title>.*?)(?:\W?|_)S(?<season>(?<!\d+)\d{1,2}(?!\d+))(?:\W|_)?E(?<episode>(?<!\d+)\d{1,2}(?!\d+))", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //3 digit season S010E05 - new Regex(@"(?:.*(?:\""|^))(?<title>.*?)(?:\W?|_)S(?<season>(?<!\d+)\d{3}(?!\d+))(?:\W|_)?E(?<episode>(?<!\d+)\d{1,2}(?!\d+))", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //5 digit episode number with a title - new Regex(@"^(?:(?<title>.+?)(?:_|-|\s|\.)+)(?:S?(?<season>(?<!\d+)\d{1,2}(?!\d+)))(?:(?:\-|[ex]|\W[ex]|_){1,2}(?<episode>(?<!\d+)\d{5}(?!\d+)))", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //5 digit multi-episode with a title - new Regex(@"^(?:(?<title>.+?)(?:_|-|\s|\.)+)(?:S?(?<season>(?<!\d+)\d{1,2}(?!\d+)))(?:(?:[-_. ]{1,3}ep){1,2}(?<episode>(?<!\d+)\d{5}(?!\d+)))+", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - // Separated season and episode numbers S01 - E01 - new Regex(@"^(?<title>.+?)(?:_|-|\s|\.)+S(?<season>\d{2}(?!\d+))(\W-\W)E(?<episode>(?<!\d+)\d{2}(?!\d+))(?!\\)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Season only releases - new Regex(@"^(?<title>.+?)\W(?:S|Season)\W?(?<season>\d{1,2}(?!\d+))(\W+|_|$)(?<extras>EXTRAS|SUBPACK)?(?!\\)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //4 digit season only releases - new Regex(@"^(?<title>.+?)\W(?:S|Season)\W?(?<season>\d{4}(?!\d+))(\W+|_|$)(?<extras>EXTRAS|SUBPACK)?(?!\\)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Episodes with a title and season/episode in square brackets - new Regex(@"^(?<title>.+?)(?:(?:[-_\W](?<![()\[!]))+\[S?(?<season>(?<!\d+)\d{1,2}(?!\d+))(?:(?:\-|[ex]|\W[ex]|_){1,2}(?<episode>(?<!\d+)\d{2}(?!\d+|i|p)))+\])\W?(?!\\)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Supports 103/113 naming - new Regex(@"^(?<title>.+?)?(?:(?:[-_\W](?<![()\[!]))+(?<season>(?<!\d+)[1-9])(?<episode>[1-9][0-9]|[0][1-9])(?![a-z]|\d+))+", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Episodes with airdate - new Regex(@"^(?<title>.+?)?\W*(?<airyear>\d{4})\W+(?<airmonth>[0-1][0-9])\W+(?<airday>[0-3][0-9])(?!\W+[0-3][0-9])", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Supports 1103/1113 naming - new Regex(@"^(?<title>.+?)?(?:(?:[-_\W](?<![()\[!]))*(?<season>(?<!\d+|\(|\[|e|x)\d{2})(?<episode>(?<!e|x)\d{2}(?!p|i|\d+|\)|\]|\W\d+)))+(\W+|_|$)(?!\\)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //4 digit episode number - //Episodes without a title, Single (S01E05, 1x05) AND Multi (S01E04E05, 1x04x05, etc) - new Regex(@"^(?:S?(?<season>(?<!\d+)\d{1,2}(?!\d+))(?:(?:\-|[ex]|\W[ex]|_){1,2}(?<episode>\d{4}(?!\d+|i|p)))+)(\W+|_|$)(?!\\)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //4 digit episode number - //Episodes with a title, Single episodes (S01E05, 1x05, etc) & Multi-episode (S01E05E06, S01E05-06, S01E05 E06, etc) - new Regex(@"^(?<title>.+?)(?:(?:[-_\W](?<![()\[!]))+S?(?<season>(?<!\d+)\d{1,2}(?!\d+))(?:(?:\-|[ex]|\W[ex]|_){1,2}(?<episode>\d{4}(?!\d+|i|p)))+)\W?(?!\\)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Episodes with single digit episode number (S01E1, S01E5E6, etc) - new Regex(@"^(?<title>.*?)(?:(?:[-_\W](?<![()\[!]))+S?(?<season>(?<!\d+)\d{1,2}(?!\d+))(?:(?:\-|[ex]){1,2}(?<episode>\d{1}))+)+(\W+|_|$)(?!\\)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //iTunes Season 1\05 Title (Quality).ext - new Regex(@"^(?:Season(?:_|-|\s|\.)(?<season>(?<!\d+)\d{1,2}(?!\d+)))(?:_|-|\s|\.)(?<episode>(?<!\d+)\d{1,2}(?!\d+))", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Anime - Title Absolute Episode Number (e66) - new Regex(@"^(?:\[(?<subgroup>.+?)\][-_. ]?)?(?<title>.+?)(?:(?:_|-|\s|\.)+(?:e|ep)(?<absoluteepisode>\d{2,3}))+.*?(?<hash>\[\w{8}\])?(?:$|\.)", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Anime - Title Episode Absolute Episode Number (Series Title Episode 01) - new Regex(@"^(?<title>.+?)[-_. ](?:Episode)(?:[-_. ]+(?<absoluteepisode>(?<!\d+)\d{2,3}(?!\d+)))+(?:_|-|\s|\.)*?(?<hash>\[.{8}\])?(?:$|\.)?", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Anime - Title Absolute Episode Number - new Regex(@"^(?:\[(?<subgroup>.+?)\][-_. ]?)?(?<title>.+?)(?:[-_. ]+(?<absoluteepisode>(?<!\d+)\d{2,3}(?!\d+)))+(?:_|-|\s|\.)*?(?<hash>\[.{8}\])?(?:$|\.)?", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Anime - Title {Absolute Episode Number} - new Regex(@"^(?:\[(?<subgroup>.+?)\][-_. ]?)?(?<title>.+?)(?:(?:[-_\W](?<![()\[!]))+(?<absoluteepisode>(?<!\d+)\d{2,3}(?!\d+)))+(?:_|-|\s|\.)*?(?<hash>\[.{8}\])?(?:$|\.)?", - RegexOptions.IgnoreCase | RegexOptions.Compiled), - - //Extant, terrible multi-episode naming (extant.10708.hdtv-lol.mp4) - new Regex(@"^(?<title>.+?)[-_. ](?<season>[0]?\d?)(?:(?<episode>\d{2}){2}(?!\d+))[-_. ]", - RegexOptions.IgnoreCase | RegexOptions.Compiled) - }; - private static readonly Regex[] RejectHashedReleasesRegex = new Regex[] { // Generic match for md5 and mixed-case hashes. @@ -334,27 +144,6 @@ namespace NzbDrone.Core.Parser {"ü", "ue"}, }; - public static ParsedEpisodeInfo ParsePath(string path) - { - var fileInfo = new FileInfo(path); - - var result = ParseTitle(fileInfo.Name); - - if (result == null) - { - Logger.Debug("Attempting to parse episode 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 episode info using directory name. {0}", fileInfo.Directory.Name); - result = ParseTitle(fileInfo.Directory.Name + fileInfo.Extension); - } - - return result; - } - public static ParsedMovieInfo ParseMoviePath(string path, bool isLenient) { var fileInfo = new FileInfo(path); @@ -363,13 +152,13 @@ namespace NzbDrone.Core.Parser if (result == null) { - Logger.Debug("Attempting to parse episode info using directory and file names. {0}", fileInfo.Directory.Name); + Logger.Debug("Attempting to parse movie info using directory and file names. {0}", fileInfo.Directory.Name); result = ParseMovieTitle(fileInfo.Directory.Name + " " + fileInfo.Name, isLenient); } if (result == null) { - Logger.Debug("Attempting to parse episode info using directory name. {0}", fileInfo.Directory.Name); + Logger.Debug("Attempting to parse movie info using directory name. {0}", fileInfo.Directory.Name); result = ParseMovieTitle(fileInfo.Directory.Name + fileInfo.Extension, isLenient); } @@ -568,122 +357,6 @@ namespace NzbDrone.Core.Parser return ""; } - public static ParsedEpisodeInfo ParseTitle(string title) - { - - ParsedEpisodeInfo realResult = null; - try - { - if (!ValidateBeforeParsing(title)) return null; - - Logger.Debug("Parsing string '{0}'", title); - - if (ReversedTitleRegex.IsMatch(title)) - { - var titleWithoutExtension = RemoveFileExtension(title).ToCharArray(); - Array.Reverse(titleWithoutExtension); - - title = new string(titleWithoutExtension) + title.Substring(titleWithoutExtension.Length); - - Logger.Debug("Reversed name detected. Converted to '{0}'", title); - } - - var simpleTitle = SimpleTitleRegex.Replace(title, string.Empty); - - simpleTitle = RemoveFileExtension(simpleTitle); - - // TODO: Quick fix stripping [url] - prefixes. - simpleTitle = WebsitePrefixRegex.Replace(simpleTitle, string.Empty); - - simpleTitle = CleanTorrentSuffixRegex.Replace(simpleTitle, string.Empty); - - var airDateMatch = AirDateRegex.Match(simpleTitle); - if (airDateMatch.Success) - { - simpleTitle = airDateMatch.Groups[1].Value + airDateMatch.Groups["airyear"].Value + "." + airDateMatch.Groups["airmonth"].Value + "." + airDateMatch.Groups["airday"].Value; - } - - var sixDigitAirDateMatch = SixDigitAirDateRegex.Match(simpleTitle); - if (sixDigitAirDateMatch.Success) - { - var airYear = sixDigitAirDateMatch.Groups["airyear"].Value; - var airMonth = sixDigitAirDateMatch.Groups["airmonth"].Value; - var airDay = sixDigitAirDateMatch.Groups["airday"].Value; - - if (airMonth != "00" || airDay != "00") - { - var fixedDate = string.Format("20{0}.{1}.{2}", airYear, airMonth, airDay); - - simpleTitle = simpleTitle.Replace(sixDigitAirDateMatch.Groups["airdate"].Value, fixedDate); - } - } - - - - foreach (var regex in ReportTitleRegex) - { - var match = regex.Matches(simpleTitle); - - if (match.Count != 0) - { - Logger.Trace(regex); - try - { - var result = ParseMatchCollection(match); - - if (result != null) - { - if (result.FullSeason && title.ContainsIgnoreCase("Special")) - { - result.FullSeason = false; - result.Special = true; - } - - result.Language = LanguageParser.ParseLanguage(title); - Logger.Debug("Language parsed: {0}", result.Language); - - result.Quality = QualityParser.ParseQuality(title); - Logger.Debug("Quality parsed: {0}", result.Quality); - - result.ReleaseGroup = ParseReleaseGroup(title); - - var subGroup = GetSubGroup(match); - if (!subGroup.IsNullOrWhiteSpace()) - { - result.ReleaseGroup = subGroup; - } - - Logger.Debug("Release Group parsed: {0}", result.ReleaseGroup); - - result.ReleaseHash = GetReleaseHash(match); - if (!result.ReleaseHash.IsNullOrWhiteSpace()) - { - Logger.Debug("Release Hash parsed: {0}", result.ReleaseHash); - } - - realResult = result; - - return result; - } - } - catch (InvalidDateException ex) - { - Logger.Debug(ex, ex.Message); - break; - } - } - } - } - catch (Exception e) - { - if (!title.ToLower().Contains("password") && !title.ToLower().Contains("yenc")) - Logger.Error(e, "An error has occurred while trying to parse " + title); - } - - Logger.Debug("Unable to parse {0}", title); - return realResult; - } - public static string ReplaceGermanUmlauts(string s) { var t = s; @@ -731,20 +404,6 @@ namespace NzbDrone.Core.Parser return value; } - public static string ParseSeriesName(string title) - { - Logger.Debug("Parsing string '{0}'", title); - - var parseResult = ParseTitle(title); - - if (parseResult == null) - { - return CleanSeriesTitle(title); - } - - return parseResult.SeriesTitle; - } - public static string CleanSeriesTitle(this string title) { long number = 0; @@ -854,11 +513,11 @@ namespace NzbDrone.Core.Parser } - var seriesName = matchCollection[0].Groups["title"].Value./*Replace('.', ' ').*/Replace('_', ' '); - seriesName = RequestInfoRegex.Replace(seriesName, "").Trim(' '); + var movieName = matchCollection[0].Groups["title"].Value./*Replace('.', ' ').*/Replace('_', ' '); + movieName = RequestInfoRegex.Replace(movieName, "").Trim(' '); - var parts = seriesName.Split('.'); - seriesName = ""; + var parts = movieName.Split('.'); + movieName = ""; int n = 0; bool previousAcronym = false; string nextPart = ""; @@ -870,27 +529,27 @@ namespace NzbDrone.Core.Parser } if (part.Length == 1 && part.ToLower() != "a" && !int.TryParse(part, out n)) { - seriesName += part + "."; + movieName += part + "."; previousAcronym = true; } else if (part.ToLower() == "a" && (previousAcronym == true || nextPart.Length == 1)) { - seriesName += part + "."; + movieName += part + "."; previousAcronym = true; } else { if (previousAcronym) { - seriesName += " "; + movieName += " "; previousAcronym = false; } - seriesName += part + " "; + movieName += part + " "; } n++; } - seriesName = seriesName.Trim(' '); + movieName = movieName.Trim(' '); int airYear; int.TryParse(matchCollection[0].Groups["year"].Value, out airYear); @@ -904,7 +563,7 @@ namespace NzbDrone.Core.Parser result.Edition = matchCollection[0].Groups["edition"].Value.Replace(".", " "); } - result.MovieTitle = seriesName; + result.MovieTitle = movieName; result.MovieTitleInfo = GetSeriesTitleInfo(result.MovieTitle); Logger.Debug("Movie Parsed. {0}", result); @@ -912,141 +571,6 @@ namespace NzbDrone.Core.Parser return result; } - private static ParsedEpisodeInfo ParseMatchCollection(MatchCollection matchCollection) - { - var seriesName = matchCollection[0].Groups["title"].Value.Replace('.', ' ').Replace('_', ' '); - seriesName = RequestInfoRegex.Replace(seriesName, "").Trim(' '); - - int airYear; - int.TryParse(matchCollection[0].Groups["airyear"].Value, out airYear); - //int.TryParse(matchCollection[0].Groups["year"].Value, out airYear); - - ParsedEpisodeInfo result; - - if (airYear < 1900) - { - var seasons = new List<int>(); - - foreach (Capture seasonCapture in matchCollection[0].Groups["season"].Captures) - { - int parsedSeason; - if (int.TryParse(seasonCapture.Value, out parsedSeason)) - seasons.Add(parsedSeason); - } - - //If no season was found it should be treated as a mini series and season 1 - if (seasons.Count == 0) seasons.Add(1); - - //If more than 1 season was parsed go to the next REGEX (A multi-season release is unlikely) - if (seasons.Distinct().Count() > 1) return null; - - result = new ParsedEpisodeInfo - { - SeasonNumber = seasons.First(), - EpisodeNumbers = new int[0], - AbsoluteEpisodeNumbers = new int[0] - }; - - foreach (Match matchGroup in matchCollection) - { - var episodeCaptures = matchGroup.Groups["episode"].Captures.Cast<Capture>().ToList(); - var absoluteEpisodeCaptures = matchGroup.Groups["absoluteepisode"].Captures.Cast<Capture>().ToList(); - - //Allows use to return a list of 0 episodes (We can handle that as a full season release) - if (episodeCaptures.Any()) - { - var first = ParseNumber(episodeCaptures.First().Value); - var last = ParseNumber(episodeCaptures.Last().Value); - - if (first > last) - { - return null; - } - - var count = last - first + 1; - result.EpisodeNumbers = Enumerable.Range(first, count).ToArray(); - } - - if (absoluteEpisodeCaptures.Any()) - { - var first = Convert.ToInt32(absoluteEpisodeCaptures.First().Value); - var last = Convert.ToInt32(absoluteEpisodeCaptures.Last().Value); - - if (first > last) - { - return null; - } - - var count = last - first + 1; - result.AbsoluteEpisodeNumbers = Enumerable.Range(first, count).ToArray(); - - if (matchGroup.Groups["special"].Success) - { - result.Special = true; - } - } - - if (!episodeCaptures.Any() && !absoluteEpisodeCaptures.Any()) - { - //Check to see if this is an "Extras" or "SUBPACK" release, if it is, return NULL - //Todo: Set a "Extras" flag in EpisodeParseResult if we want to download them ever - if (!matchCollection[0].Groups["extras"].Value.IsNullOrWhiteSpace()) return null; - - result.FullSeason = true; - } - } - - if (result.AbsoluteEpisodeNumbers.Any() && !result.EpisodeNumbers.Any()) - { - result.SeasonNumber = 0; - } - } - - else - { - //Try to Parse as a daily show - var airmonth = Convert.ToInt32(matchCollection[0].Groups["airmonth"].Value); - var airday = Convert.ToInt32(matchCollection[0].Groups["airday"].Value); - - //Swap day and month if month is bigger than 12 (scene fail) - if (airmonth > 12) - { - var tempDay = airday; - airday = airmonth; - airmonth = tempDay; - } - - DateTime airDate; - - try - { - airDate = new DateTime(airYear, airmonth, airday); - } - catch (Exception) - { - throw new InvalidDateException("Invalid date found: {0}-{1}-{2}", airYear, airmonth, airday); - } - - //Check if episode is in the future (most likely a parse error) - if (airDate > DateTime.Now.AddDays(1).Date || airDate < new DateTime(1970, 1, 1)) - { - throw new InvalidDateException("Invalid date found: {0}", airDate); - } - - result = new ParsedEpisodeInfo - { - AirDate = airDate.ToString(Episode.AIR_DATE_FORMAT), - }; - } - - result.SeriesTitle = seriesName; - result.SeriesTitleInfo = GetSeriesTitleInfo(result.SeriesTitle); - - Logger.Debug("Episode Parsed. {0}", result); - - return result; - } - private static bool ValidateBeforeParsing(string title) { if (title.ToLower().Contains("password") && title.ToLower().Contains("yenc")) diff --git a/src/NzbDrone.Core/Parser/ParsingService.cs b/src/NzbDrone.Core/Parser/ParsingService.cs index 83ebf29a3..9562b7105 100644 --- a/src/NzbDrone.Core/Parser/ParsingService.cs +++ b/src/NzbDrone.Core/Parser/ParsingService.cs @@ -1,57 +1,41 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Core.Configuration; -using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Movies.AlternativeTitles; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.RomanNumerals; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Parser { public interface IParsingService { - LocalEpisode GetLocalEpisode(string filename, Series series); - LocalEpisode GetLocalEpisode(string filename, Series series, ParsedEpisodeInfo folderInfo, bool sceneSource); LocalMovie GetLocalMovie(string filename, Movie movie); LocalMovie GetLocalMovie(string filename, Movie movie, ParsedMovieInfo folderInfo, bool sceneSource); - Series GetSeries(string title); Movie GetMovie(string title); - RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria = null); - RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, int seriesId, IEnumerable<int> episodeIds); MappingResult Map(ParsedMovieInfo parsedMovieInfo, string imdbId, SearchCriteriaBase searchCriteria = null); - List<Episode> GetEpisodes(ParsedEpisodeInfo parsedEpisodeInfo, Series series, bool sceneSource, SearchCriteriaBase searchCriteria = null); - ParsedEpisodeInfo ParseSpecialEpisodeTitle(string title, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria = null); } public class ParsingService : IParsingService { - private readonly IEpisodeService _episodeService; - private readonly ISeriesService _seriesService; - private readonly ISceneMappingService _sceneMappingService; private readonly IMovieService _movieService; private readonly IConfigService _config; private readonly Logger _logger; private static HashSet<ArabicRomanNumeral> _arabicRomanNumeralMappings; - public ParsingService(IEpisodeService episodeService, - ISeriesService seriesService, - ISceneMappingService sceneMappingService, + public ParsingService( IMovieService movieService, IConfigService configService, Logger logger) { - _episodeService = episodeService; - _seriesService = seriesService; - _sceneMappingService = sceneMappingService; _movieService = movieService; _config = configService; _logger = logger; @@ -62,60 +46,6 @@ namespace NzbDrone.Core.Parser } } - public LocalEpisode GetLocalEpisode(string filename, Series series) - { - return GetLocalEpisode(filename, series, null, false); - } - - public LocalEpisode GetLocalEpisode(string filename, Series series, ParsedEpisodeInfo folderInfo, bool sceneSource) - { - ParsedEpisodeInfo parsedEpisodeInfo; - - if (folderInfo != null) - { - parsedEpisodeInfo = folderInfo.JsonClone(); - parsedEpisodeInfo.Quality = QualityParser.ParseQuality(Path.GetFileName(filename)); - } - - else - { - parsedEpisodeInfo = Parser.ParsePath(filename); - } - - if (parsedEpisodeInfo == null || parsedEpisodeInfo.IsPossibleSpecialEpisode) - { - var title = Path.GetFileNameWithoutExtension(filename); - var specialEpisodeInfo = ParseSpecialEpisodeTitle(title, series); - - if (specialEpisodeInfo != null) - { - parsedEpisodeInfo = specialEpisodeInfo; - } - } - - if (parsedEpisodeInfo == null) - { - if (MediaFileExtensions.Extensions.Contains(Path.GetExtension(filename))) - { - _logger.Warn("Unable to parse episode info from path {0}", filename); - } - - return null; - } - - var episodes = GetEpisodes(parsedEpisodeInfo, series, sceneSource); - - return new LocalEpisode - { - Series = series, - Quality = parsedEpisodeInfo.Quality, - Episodes = episodes, - Path = filename, - ParsedEpisodeInfo = parsedEpisodeInfo, - ExistingFile = series.Path.IsParentPath(filename) - }; - } - public LocalMovie GetLocalMovie(string filename, Movie movie) { return GetLocalMovie(filename, movie, null, false); @@ -156,26 +86,6 @@ namespace NzbDrone.Core.Parser }; } - public Series GetSeries(string title) - { - var parsedEpisodeInfo = Parser.ParseTitle(title); - - if (parsedEpisodeInfo == null) - { - return _seriesService.FindByTitle(title); - } - - var series = _seriesService.FindByTitle(parsedEpisodeInfo.SeriesTitle); - - if (series == null) - { - series = _seriesService.FindByTitle(parsedEpisodeInfo.SeriesTitleInfo.TitleWithoutYear, - parsedEpisodeInfo.SeriesTitleInfo.Year); - } - - return series; - } - public Movie GetMovie(string title) { var parsedMovieInfo = Parser.ParseMovieTitle(title, _config.ParsingLeniency > 0); @@ -200,26 +110,6 @@ namespace NzbDrone.Core.Parser return movies; } - public RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria = null) - { - var remoteEpisode = new RemoteEpisode - { - ParsedEpisodeInfo = parsedEpisodeInfo, - }; - - var series = GetSeries(parsedEpisodeInfo, tvdbId, tvRageId, searchCriteria); - - if (series == null) - { - return remoteEpisode; - } - - remoteEpisode.Series = series; - remoteEpisode.Episodes = GetEpisodes(parsedEpisodeInfo, series, true, searchCriteria); - - return remoteEpisode; - } - public MappingResult Map(ParsedMovieInfo parsedMovieInfo, string imdbId, SearchCriteriaBase searchCriteria = null) { var result = GetMovie(parsedMovieInfo, imdbId, searchCriteria); @@ -234,120 +124,6 @@ namespace NzbDrone.Core.Parser return result; } - public RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, int seriesId, IEnumerable<int> episodeIds) - { - return new RemoteEpisode - { - ParsedEpisodeInfo = parsedEpisodeInfo, - Series = _seriesService.GetSeries(seriesId), - Episodes = _episodeService.GetEpisodes(episodeIds) - }; - } - - public List<Episode> GetEpisodes(ParsedEpisodeInfo parsedEpisodeInfo, Series series, bool sceneSource, SearchCriteriaBase searchCriteria = null) - { - if (parsedEpisodeInfo.FullSeason) - { - return _episodeService.GetEpisodesBySeason(series.Id, parsedEpisodeInfo.SeasonNumber); - } - - if (parsedEpisodeInfo.IsDaily) - { - if (series.SeriesType == SeriesTypes.Standard) - { - _logger.Warn("Found daily-style episode for non-daily series: {0}.", series); - return new List<Episode>(); - } - - var episodeInfo = GetDailyEpisode(series, parsedEpisodeInfo.AirDate, searchCriteria); - - if (episodeInfo != null) - { - return new List<Episode> { episodeInfo }; - } - - return new List<Episode>(); - } - - if (parsedEpisodeInfo.IsAbsoluteNumbering) - { - return GetAnimeEpisodes(series, parsedEpisodeInfo, sceneSource); - } - - return GetStandardEpisodes(series, parsedEpisodeInfo, sceneSource, searchCriteria); - } - - public ParsedEpisodeInfo ParseSpecialEpisodeTitle(string title, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria = null) - { - if (searchCriteria != null) - { - if (tvdbId == 0) - tvdbId = _sceneMappingService.FindTvdbId(title) ?? 0; - - if (tvdbId != 0 && tvdbId == searchCriteria.Series.TvdbId) - { - return ParseSpecialEpisodeTitle(title, searchCriteria.Series); - } - - if (tvRageId != 0 && tvRageId == searchCriteria.Series.TvRageId) - { - return ParseSpecialEpisodeTitle(title, searchCriteria.Series); - } - } - - var series = GetSeries(title); - - if (series == null) - { - series = _seriesService.FindByTitleInexact(title); - } - - if (series == null && tvdbId > 0) - { - series = _seriesService.FindByTvdbId(tvdbId); - } - - if (series == null && tvRageId > 0) - { - series = _seriesService.FindByTvRageId(tvRageId); - } - - if (series == null) - { - _logger.Debug("No matching series {0}", title); - return null; - } - - return ParseSpecialEpisodeTitle(title, series); - } - - private ParsedEpisodeInfo ParseSpecialEpisodeTitle(string title, Series series) - { - // find special episode in series season 0 - var episode = _episodeService.FindEpisodeByTitle(series.Id, 0, title); - - if (episode != null) - { - // create parsed info from tv episode - var info = new ParsedEpisodeInfo(); - info.SeriesTitle = series.Title; - info.SeriesTitleInfo = new SeriesTitleInfo(); - info.SeriesTitleInfo.Title = info.SeriesTitle; - info.SeasonNumber = episode.SeasonNumber; - info.EpisodeNumbers = new int[1] { episode.EpisodeNumber }; - info.FullSeason = false; - info.Quality = QualityParser.ParseQuality(title); - info.ReleaseGroup = Parser.ParseReleaseGroup(title); - info.Language = LanguageParser.ParseLanguage(title); - info.Special = true; - - _logger.Debug("Found special episode {0} for title '{1}'", info, title); - return info; - } - - return null; - } - private MappingResult GetMovie(ParsedMovieInfo parsedMovieInfo, string imdbId, SearchCriteriaBase searchCriteria) { // TODO: Answer me this: Wouldn't it be smarter to start out looking for a movie if we have an ImDb Id? @@ -531,230 +307,7 @@ namespace NzbDrone.Core.Parser return false; } - - private Series GetSeries(ParsedEpisodeInfo parsedEpisodeInfo, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria) - { - Series series = null; - - /*var localEpisode = _seriesService.FindByTitle(parsedEpisodeInfo.SeriesTitle); - - var sceneMappingTvdbId = _sceneMappingService.FindTvdbId(parsedEpisodeInfo.SeriesTitle); - if (localEpisode != null) - { - if (searchCriteria != null && searchCriteria.Series.TvdbId == localEpisode.TvdbId) - { - return searchCriteria.Series; - } - - series = _seriesService.FindByTvdbId(sceneMappingTvdbId.Value); - - if (series == null) - { - _logger.Debug("No matching series {0}", parsedEpisodeInfo.SeriesTitle); - return null; - } - - return series; - }*/ //This is only to find scene mapping should not be necessary for movies. - - if (searchCriteria != null) - { - if (searchCriteria.Series.CleanTitle == parsedEpisodeInfo.SeriesTitle.CleanSeriesTitle()) - { - return searchCriteria.Series; - } - - if (tvdbId > 0 && tvdbId == searchCriteria.Series.TvdbId) - { - //TODO: If series is found by TvdbId, we should report it as a scene naming exception, since it will fail to import - return searchCriteria.Series; - } - - if (tvRageId > 0 && tvRageId == searchCriteria.Series.TvRageId) - { - //TODO: If series is found by TvRageId, we should report it as a scene naming exception, since it will fail to import - return searchCriteria.Series; - } - } - - series = _seriesService.FindByTitle(parsedEpisodeInfo.SeriesTitle); - - if (series == null && tvdbId > 0) - { - //TODO: If series is found by TvdbId, we should report it as a scene naming exception, since it will fail to import - series = _seriesService.FindByTvdbId(tvdbId); - } - - if (series == null && tvRageId > 0) - { - //TODO: If series is found by TvRageId, we should report it as a scene naming exception, since it will fail to import - series = _seriesService.FindByTvRageId(tvRageId); - } - - if (series == null) - { - _logger.Debug("No matching series {0}", parsedEpisodeInfo.SeriesTitle); - return null; - } - - return series; - } - - private Episode GetDailyEpisode(Series series, string airDate, SearchCriteriaBase searchCriteria) - { - Episode episodeInfo = null; - - if (searchCriteria != null) - { - episodeInfo = searchCriteria.Episodes.SingleOrDefault( - e => e.AirDate == airDate); - } - - if (episodeInfo == null) - { - episodeInfo = _episodeService.FindEpisode(series.Id, airDate); - } - - return episodeInfo; - } - - private List<Episode> GetAnimeEpisodes(Series series, ParsedEpisodeInfo parsedEpisodeInfo, bool sceneSource) - { - var result = new List<Episode>(); - - var sceneSeasonNumber = _sceneMappingService.GetSceneSeasonNumber(parsedEpisodeInfo.SeriesTitle); - - foreach (var absoluteEpisodeNumber in parsedEpisodeInfo.AbsoluteEpisodeNumbers) - { - Episode episode = null; - - if (parsedEpisodeInfo.Special) - { - episode = _episodeService.FindEpisode(series.Id, 0, absoluteEpisodeNumber); - } - - else if (sceneSource) - { - // Is there a reason why we excluded season 1 from this handling before? - // Might have something to do with the scene name to season number check - // If this needs to be reverted tests will need to be added - if (sceneSeasonNumber.HasValue) - { - var episodes = _episodeService.FindEpisodesBySceneNumbering(series.Id, sceneSeasonNumber.Value, absoluteEpisodeNumber); - - if (episodes.Count == 1) - { - episode = episodes.First(); - } - - if (episode == null) - { - episode = _episodeService.FindEpisode(series.Id, sceneSeasonNumber.Value, absoluteEpisodeNumber); - } - } - - else - { - episode = _episodeService.FindEpisodeBySceneNumbering(series.Id, absoluteEpisodeNumber); - } - } - - if (episode == null) - { - episode = _episodeService.FindEpisode(series.Id, absoluteEpisodeNumber); - } - - if (episode != null) - { - _logger.Debug("Using absolute episode number {0} for: {1} - TVDB: {2}x{3:00}", - absoluteEpisodeNumber, - series.Title, - episode.SeasonNumber, - episode.EpisodeNumber); - - result.Add(episode); - } - } - - return result; - } - - private List<Episode> GetStandardEpisodes(Series series, ParsedEpisodeInfo parsedEpisodeInfo, bool sceneSource, SearchCriteriaBase searchCriteria) - { - var result = new List<Episode>(); - var seasonNumber = parsedEpisodeInfo.SeasonNumber; - - if (sceneSource) - { - var sceneMapping = _sceneMappingService.FindSceneMapping(parsedEpisodeInfo.SeriesTitle); - - if (sceneMapping != null && sceneMapping.SeasonNumber.HasValue && sceneMapping.SeasonNumber.Value >= 0 && - sceneMapping.SceneSeasonNumber == seasonNumber) - { - seasonNumber = sceneMapping.SeasonNumber.Value; - } - } - - if (parsedEpisodeInfo.EpisodeNumbers == null) - { - return new List<Episode>(); - } - - foreach (var episodeNumber in parsedEpisodeInfo.EpisodeNumbers) - { - if (series.UseSceneNumbering && sceneSource) - { - List<Episode> episodes = new List<Episode>(); - - if (searchCriteria != null) - { - episodes = searchCriteria.Episodes.Where(e => e.SceneSeasonNumber == parsedEpisodeInfo.SeasonNumber && - e.SceneEpisodeNumber == episodeNumber).ToList(); - } - - if (!episodes.Any()) - { - episodes = _episodeService.FindEpisodesBySceneNumbering(series.Id, seasonNumber, episodeNumber); - } - - if (episodes != null && episodes.Any()) - { - _logger.Debug("Using Scene to TVDB Mapping for: {0} - Scene: {1}x{2:00} - TVDB: {3}", - series.Title, - episodes.First().SceneSeasonNumber, - episodes.First().SceneEpisodeNumber, - string.Join(", ", episodes.Select(e => string.Format("{0}x{1:00}", e.SeasonNumber, e.EpisodeNumber)))); - - result.AddRange(episodes); - continue; - } - } - - Episode episodeInfo = null; - - if (searchCriteria != null) - { - episodeInfo = searchCriteria.Episodes.SingleOrDefault(e => e.SeasonNumber == seasonNumber && e.EpisodeNumber == episodeNumber); - } - - if (episodeInfo == null) - { - episodeInfo = _episodeService.FindEpisode(series.Id, seasonNumber, episodeNumber); - } - - if (episodeInfo != null) - { - result.Add(episodeInfo); - } - - else - { - _logger.Debug("Unable to find {0}", parsedEpisodeInfo); - } - } - - return result; - } + } @@ -839,4 +392,4 @@ namespace NzbDrone.Core.Parser TitleNotFound = 4, NotParsable = 5, } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/Profiles/ProfileService.cs b/src/NzbDrone.Core/Profiles/ProfileService.cs index ff3841287..69421e5c4 100644 --- a/src/NzbDrone.Core/Profiles/ProfileService.cs +++ b/src/NzbDrone.Core/Profiles/ProfileService.cs @@ -5,7 +5,7 @@ using NzbDrone.Core.Lifecycle; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Profiles { diff --git a/src/NzbDrone.Core/Queue/Queue.cs b/src/NzbDrone.Core/Queue/Queue.cs index 851c404e2..6a2b2b0bd 100644 --- a/src/NzbDrone.Core/Queue/Queue.cs +++ b/src/NzbDrone.Core/Queue/Queue.cs @@ -1,18 +1,16 @@ -using System; +using System; using System.Collections.Generic; using NzbDrone.Core.Datastore; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.Indexers; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Queue { public class Queue : ModelBase { - public Series Series { get; set; } - public Episode Episode { get; set; } public Movie Movie { get; set; } public QualityModel Quality { get; set; } public decimal Size { get; set; } @@ -24,7 +22,6 @@ namespace NzbDrone.Core.Queue public string TrackedDownloadStatus { get; set; } public List<TrackedDownloadStatusMessage> StatusMessages { get; set; } public string DownloadId { get; set; } - public RemoteEpisode RemoteEpisode { get; set; } public RemoteMovie RemoteMovie { get; set; } public DownloadProtocol Protocol { get; set; } } diff --git a/src/NzbDrone.Core/Queue/QueueService.cs b/src/NzbDrone.Core/Queue/QueueService.cs index f7390ee6b..76bfbab07 100644 --- a/src/NzbDrone.Core/Queue/QueueService.cs +++ b/src/NzbDrone.Core/Queue/QueueService.cs @@ -1,10 +1,10 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using NzbDrone.Common.Crypto; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Queue { @@ -44,14 +44,7 @@ namespace NzbDrone.Core.Queue private IEnumerable<Queue> MapQueue(TrackedDownload trackedDownload) { - if (trackedDownload.RemoteEpisode != null && trackedDownload.RemoteEpisode.Episodes != null && trackedDownload.RemoteEpisode.Episodes.Any()) - { - foreach (var episode in trackedDownload.RemoteEpisode.Episodes) - { - yield return MapEpisode(trackedDownload, episode); - } - } - else if (trackedDownload.RemoteMovie != null && trackedDownload.RemoteMovie.Movie != null) + if (trackedDownload.RemoteMovie != null && trackedDownload.RemoteMovie.Movie != null) { yield return MapMovie(trackedDownload, trackedDownload.RemoteMovie.Movie); } @@ -62,8 +55,6 @@ namespace NzbDrone.Core.Queue var queue = new Queue { Id = HashConverter.GetHashInt31(string.Format("trackedDownload-{0}", trackedDownload.DownloadItem.DownloadId)), - Series = null, - Episode = null, Quality = trackedDownload.RemoteMovie.ParsedMovieInfo.Quality, Title = trackedDownload.DownloadItem.Title, Size = trackedDownload.DownloadItem.TotalSize, @@ -72,7 +63,6 @@ namespace NzbDrone.Core.Queue Status = trackedDownload.DownloadItem.Status.ToString(), TrackedDownloadStatus = trackedDownload.Status.ToString(), StatusMessages = trackedDownload.StatusMessages.ToList(), - RemoteEpisode = trackedDownload.RemoteEpisode, RemoteMovie = trackedDownload.RemoteMovie, DownloadId = trackedDownload.DownloadItem.DownloadId, Protocol = trackedDownload.Protocol, @@ -86,33 +76,5 @@ namespace NzbDrone.Core.Queue return queue; } - - private Queue MapEpisode(TrackedDownload trackedDownload, Episode episode) - { - var queue = new Queue - { - Id = HashConverter.GetHashInt31(string.Format("trackedDownload-{0}-ep{1}", trackedDownload.DownloadItem.DownloadId, episode.Id)), - Series = trackedDownload.RemoteEpisode.Series, - Episode = episode, - Quality = trackedDownload.RemoteEpisode.ParsedEpisodeInfo.Quality, - Title = trackedDownload.DownloadItem.Title, - Size = trackedDownload.DownloadItem.TotalSize, - Sizeleft = trackedDownload.DownloadItem.RemainingSize, - Timeleft = trackedDownload.DownloadItem.RemainingTime, - Status = trackedDownload.DownloadItem.Status.ToString(), - TrackedDownloadStatus = trackedDownload.Status.ToString(), - StatusMessages = trackedDownload.StatusMessages.ToList(), - RemoteEpisode = trackedDownload.RemoteEpisode, - DownloadId = trackedDownload.DownloadItem.DownloadId, - Protocol = trackedDownload.Protocol - }; - - if (queue.Timeleft.HasValue) - { - queue.EstimatedCompletionTime = DateTime.UtcNow.Add(queue.Timeleft.Value); - } - - return queue; - } } } diff --git a/src/NzbDrone.Core/RootFolders/RootFolderService.cs b/src/NzbDrone.Core/RootFolders/RootFolderService.cs index b97107a89..229c5f8ba 100644 --- a/src/NzbDrone.Core/RootFolders/RootFolderService.cs +++ b/src/NzbDrone.Core/RootFolders/RootFolderService.cs @@ -7,7 +7,7 @@ using NzbDrone.Common; using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; using NzbDrone.Core.Configuration; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.RootFolders { @@ -24,7 +24,6 @@ namespace NzbDrone.Core.RootFolders { private readonly IRootFolderRepository _rootFolderRepository; private readonly IDiskProvider _diskProvider; - private readonly ISeriesRepository _seriesRepository; private readonly IMovieRepository _movieRepository; private readonly IConfigService _configService; private readonly Logger _logger; @@ -45,14 +44,12 @@ namespace NzbDrone.Core.RootFolders public RootFolderService(IRootFolderRepository rootFolderRepository, IDiskProvider diskProvider, - ISeriesRepository seriesRepository, IMovieRepository movieRepository, IConfigService configService, Logger logger) { _rootFolderRepository = rootFolderRepository; _diskProvider = diskProvider; - _seriesRepository = seriesRepository; _movieRepository = movieRepository; _configService = configService; _logger = logger; @@ -133,41 +130,6 @@ namespace NzbDrone.Core.RootFolders _rootFolderRepository.Delete(id); } - //private List<UnmappedFolder> GetUnmappedFolders(string path) - //{ - // _logger.Debug("Generating list of unmapped folders"); - // if (string.IsNullOrEmpty(path)) - // throw new ArgumentException("Invalid path provided", "path"); - - // var results = new List<UnmappedFolder>(); - // var series = _seriesRepository.All().ToList(); - - // if (!_diskProvider.FolderExists(path)) - // { - // _logger.Debug("Path supplied does not exist: {0}", path); - // return results; - // } - - // var seriesFolders = _diskProvider.GetDirectories(path).ToList(); - // var unmappedFolders = seriesFolders.Except(series.Select(s => s.Path), PathEqualityComparer.Instance).ToList(); - - // foreach (string unmappedFolder in unmappedFolders) - // { - // var di = new DirectoryInfo(unmappedFolder.Normalize()); - // if (!di.Attributes.HasFlag(FileAttributes.System) && !di.Attributes.HasFlag(FileAttributes.Hidden)) - // { - // results.Add(new UnmappedFolder { Name = di.Name, Path = di.FullName }); - // } - - // } - - // var setToRemove = SpecialFolders; - // results.RemoveAll(x => setToRemove.Contains(new DirectoryInfo(x.Path.ToLowerInvariant()).Name)); - - // _logger.Debug("{0} unmapped folders detected.", results.Count); - // return results; - //} - private List<UnmappedFolder> GetUnmappedFolders(string path) { _logger.Debug("Generating list of unmapped folders"); diff --git a/src/NzbDrone.Core/SeriesStats/SeasonStatistics.cs b/src/NzbDrone.Core/SeriesStats/SeasonStatistics.cs deleted file mode 100644 index 3b3731ed5..000000000 --- a/src/NzbDrone.Core/SeriesStats/SeasonStatistics.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using NzbDrone.Core.Datastore; - -namespace NzbDrone.Core.SeriesStats -{ - public class SeasonStatistics : ResultSet - { - public int SeriesId { get; set; } - public int SeasonNumber { get; set; } - public string NextAiringString { get; set; } - public string PreviousAiringString { get; set; } - public int EpisodeFileCount { get; set; } - public int EpisodeCount { get; set; } - public int TotalEpisodeCount { get; set; } - public long SizeOnDisk { get; set; } - - public DateTime? NextAiring - { - get - { - DateTime nextAiring; - - if (!DateTime.TryParse(NextAiringString, out nextAiring)) return null; - - return nextAiring; - } - } - - public DateTime? PreviousAiring - { - get - { - DateTime previousAiring; - - if (!DateTime.TryParse(PreviousAiringString, out previousAiring)) return null; - - return previousAiring; - } - } - } -} diff --git a/src/NzbDrone.Core/SeriesStats/SeriesStatistics.cs b/src/NzbDrone.Core/SeriesStats/SeriesStatistics.cs deleted file mode 100644 index 25a82d68f..000000000 --- a/src/NzbDrone.Core/SeriesStats/SeriesStatistics.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections.Generic; -using NzbDrone.Core.Datastore; - -namespace NzbDrone.Core.SeriesStats -{ - public class SeriesStatistics : ResultSet - { - public int SeriesId { get; set; } - public string NextAiringString { get; set; } - public string PreviousAiringString { get; set; } - public int EpisodeFileCount { get; set; } - public int EpisodeCount { get; set; } - public int TotalEpisodeCount { get; set; } - public long SizeOnDisk { get; set; } - public List<SeasonStatistics> SeasonStatistics { get; set; } - - public DateTime? NextAiring - { - get - { - DateTime nextAiring; - - if (!DateTime.TryParse(NextAiringString, out nextAiring)) return null; - - return nextAiring; - } - } - - public DateTime? PreviousAiring - { - get - { - DateTime previousAiring; - - if (!DateTime.TryParse(PreviousAiringString, out previousAiring)) return null; - - return previousAiring; - } - } - } -} diff --git a/src/NzbDrone.Core/SeriesStats/SeriesStatisticsRepository.cs b/src/NzbDrone.Core/SeriesStats/SeriesStatisticsRepository.cs deleted file mode 100644 index 73e4e8b4b..000000000 --- a/src/NzbDrone.Core/SeriesStats/SeriesStatisticsRepository.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using NzbDrone.Core.Datastore; - -namespace NzbDrone.Core.SeriesStats -{ - public interface ISeriesStatisticsRepository - { - List<SeasonStatistics> SeriesStatistics(); - List<SeasonStatistics> SeriesStatistics(int seriesId); - } - - public class SeriesStatisticsRepository : ISeriesStatisticsRepository - { - private readonly IMainDatabase _database; - - public SeriesStatisticsRepository(IMainDatabase database) - { - _database = database; - } - - public List<SeasonStatistics> SeriesStatistics() - { - var mapper = _database.GetDataMapper(); - - mapper.AddParameter("currentDate", DateTime.UtcNow); - - var sb = new StringBuilder(); - sb.AppendLine(GetSelectClause()); - sb.AppendLine(GetEpisodeFilesJoin()); - sb.AppendLine(GetGroupByClause()); - var queryText = sb.ToString(); - - return mapper.Query<SeasonStatistics>(queryText); - } - - public List<SeasonStatistics> SeriesStatistics(int seriesId) - { - var mapper = _database.GetDataMapper(); - - mapper.AddParameter("currentDate", DateTime.UtcNow); - mapper.AddParameter("seriesId", seriesId); - - var sb = new StringBuilder(); - sb.AppendLine(GetSelectClause()); - sb.AppendLine(GetEpisodeFilesJoin()); - sb.AppendLine("WHERE Episodes.SeriesId = @seriesId"); - sb.AppendLine(GetGroupByClause()); - var queryText = sb.ToString(); - - return mapper.Query<SeasonStatistics>(queryText); - } - - private string GetSelectClause() - { - return @"SELECT Episodes.*, SUM(EpisodeFiles.Size) as SizeOnDisk FROM - (SELECT - Episodes.SeriesId, - Episodes.SeasonNumber, - SUM(CASE WHEN AirdateUtc <= @currentDate OR EpisodeFileId > 0 THEN 1 ELSE 0 END) AS TotalEpisodeCount, - SUM(CASE WHEN (Monitored = 1 AND AirdateUtc <= @currentDate) OR EpisodeFileId > 0 THEN 1 ELSE 0 END) AS EpisodeCount, - SUM(CASE WHEN EpisodeFileId > 0 THEN 1 ELSE 0 END) AS EpisodeFileCount, - MIN(CASE WHEN AirDateUtc < @currentDate OR EpisodeFileId > 0 OR Monitored = 0 THEN NULL ELSE AirDateUtc END) AS NextAiringString, - MAX(CASE WHEN AirDateUtc >= @currentDate OR EpisodeFileId = 0 AND Monitored = 0 THEN NULL ELSE AirDateUtc END) AS PreviousAiringString - FROM Episodes - GROUP BY Episodes.SeriesId, Episodes.SeasonNumber) as Episodes"; - } - - private string GetGroupByClause() - { - return "GROUP BY Episodes.SeriesId, Episodes.SeasonNumber"; - } - - private string GetEpisodeFilesJoin() - { - return @"LEFT OUTER JOIN EpisodeFiles - ON EpisodeFiles.SeriesId = Episodes.SeriesId - AND EpisodeFiles.SeasonNumber = Episodes.SeasonNumber"; - } - } -} diff --git a/src/NzbDrone.Core/SeriesStats/SeriesStatisticsService.cs b/src/NzbDrone.Core/SeriesStats/SeriesStatisticsService.cs deleted file mode 100644 index b273f84ce..000000000 --- a/src/NzbDrone.Core/SeriesStats/SeriesStatisticsService.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System.Collections.Generic; -using System.Linq; - -namespace NzbDrone.Core.SeriesStats -{ - public interface ISeriesStatisticsService - { - List<SeriesStatistics> SeriesStatistics(); - SeriesStatistics SeriesStatistics(int seriesId); - } - - public class SeriesStatisticsService : ISeriesStatisticsService - { - private readonly ISeriesStatisticsRepository _seriesStatisticsRepository; - - public SeriesStatisticsService(ISeriesStatisticsRepository seriesStatisticsRepository) - { - _seriesStatisticsRepository = seriesStatisticsRepository; - } - - public List<SeriesStatistics> SeriesStatistics() - { - var seasonStatistics = _seriesStatisticsRepository.SeriesStatistics(); - - return seasonStatistics.GroupBy(s => s.SeriesId).Select(s => MapSeriesStatistics(s.ToList())).ToList(); - } - - public SeriesStatistics SeriesStatistics(int seriesId) - { - var stats = _seriesStatisticsRepository.SeriesStatistics(seriesId); - - if (stats == null || stats.Count == 0) return new SeriesStatistics(); - - return MapSeriesStatistics(stats); - } - - private SeriesStatistics MapSeriesStatistics(List<SeasonStatistics> seasonStatistics) - { - var seriesStatistics = new SeriesStatistics - { - SeasonStatistics = seasonStatistics, - SeriesId = seasonStatistics.First().SeriesId, - EpisodeFileCount = seasonStatistics.Sum(s => s.EpisodeFileCount), - EpisodeCount = seasonStatistics.Sum(s => s.EpisodeCount), - TotalEpisodeCount = seasonStatistics.Sum(s => s.TotalEpisodeCount), - SizeOnDisk = seasonStatistics.Sum(s => s.SizeOnDisk) - }; - - var nextAiring = seasonStatistics.Where(s => s.NextAiring != null) - .OrderBy(s => s.NextAiring) - .FirstOrDefault(); - - var previousAiring = seasonStatistics.Where(s => s.PreviousAiring != null) - .OrderBy(s => s.PreviousAiring) - .LastOrDefault(); - - seriesStatistics.NextAiringString = nextAiring != null ? nextAiring.NextAiringString : null; - seriesStatistics.PreviousAiringString = previousAiring != null ? previousAiring.PreviousAiringString : null; - - return seriesStatistics; - } - } -} diff --git a/src/NzbDrone.Core/Tv/AddSeriesOptions.cs b/src/NzbDrone.Core/Tv/AddSeriesOptions.cs deleted file mode 100644 index fceae6586..000000000 --- a/src/NzbDrone.Core/Tv/AddSeriesOptions.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace NzbDrone.Core.Tv -{ - public class AddSeriesOptions : MonitoringOptions - { - public bool SearchForMissingEpisodes { get; set; } - } -} diff --git a/src/NzbDrone.Core/Tv/Commands/RefreshSeriesCommand.cs b/src/NzbDrone.Core/Tv/Commands/RefreshSeriesCommand.cs deleted file mode 100644 index 4cae630cd..000000000 --- a/src/NzbDrone.Core/Tv/Commands/RefreshSeriesCommand.cs +++ /dev/null @@ -1,22 +0,0 @@ -using NzbDrone.Core.Messaging.Commands; - -namespace NzbDrone.Core.Tv.Commands -{ - public class RefreshSeriesCommand : Command - { - public int? SeriesId { get; set; } - - public RefreshSeriesCommand() - { - } - - public RefreshSeriesCommand(int? seriesId) - { - SeriesId = seriesId; - } - - public override bool SendUpdatesToClient => true; - - public override bool UpdateScheduledTask => !SeriesId.HasValue; - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Tv/Episode.cs b/src/NzbDrone.Core/Tv/Episode.cs deleted file mode 100644 index dcb95069e..000000000 --- a/src/NzbDrone.Core/Tv/Episode.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Collections.Generic; -using Marr.Data; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Datastore; -using NzbDrone.Core.MediaFiles; - -namespace NzbDrone.Core.Tv -{ - public class Episode : ModelBase - { - public Episode() - { - Images = new List<MediaCover.MediaCover>(); - } - - public const string AIR_DATE_FORMAT = "yyyy-MM-dd"; - - public int SeriesId { get; set; } - public int EpisodeFileId { get; set; } - public int SeasonNumber { get; set; } - public int EpisodeNumber { get; set; } - public string Title { get; set; } - public string AirDate { get; set; } - public DateTime? AirDateUtc { get; set; } - public string Overview { get; set; } - public bool Monitored { get; set; } - public int? AbsoluteEpisodeNumber { get; set; } - public int? SceneAbsoluteEpisodeNumber { get; set; } - public int? SceneSeasonNumber { get; set; } - public int? SceneEpisodeNumber { get; set; } - public bool UnverifiedSceneNumbering { get; set; } - public Ratings Ratings { get; set; } - public List<MediaCover.MediaCover> Images { get; set; } - - public string SeriesTitle { get; private set; } - - public LazyLoaded<EpisodeFile> EpisodeFile { get; set; } - - public Series Series { get; set; } - - public bool HasFile => EpisodeFileId > 0; - - public override string ToString() - { - return string.Format("[{0}]{1}", Id, Title.NullSafe()); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Tv/EpisodeAddedService.cs b/src/NzbDrone.Core/Tv/EpisodeAddedService.cs deleted file mode 100644 index 54e3d2991..000000000 --- a/src/NzbDrone.Core/Tv/EpisodeAddedService.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using NLog; -using NzbDrone.Common.Cache; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.IndexerSearch; -using NzbDrone.Core.Messaging.Commands; -using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Tv.Events; - -namespace NzbDrone.Core.Tv -{ - public interface IEpisodeAddedService - { - void SearchForRecentlyAdded(int seriesId); - } - - public class EpisodeAddedService : IHandle<EpisodeInfoRefreshedEvent>, IEpisodeAddedService - { - private readonly IManageCommandQueue _commandQueueManager; - private readonly IEpisodeService _episodeService; - private readonly Logger _logger; - private readonly ICached<List<int>> _addedEpisodesCache; - - public EpisodeAddedService(ICacheManager cacheManager, - IManageCommandQueue commandQueueManager, - IEpisodeService episodeService, - Logger logger) - { - _commandQueueManager = commandQueueManager; - _episodeService = episodeService; - _logger = logger; - _addedEpisodesCache = cacheManager.GetCache<List<int>>(GetType()); - } - - public void SearchForRecentlyAdded(int seriesId) - { - var previouslyAired = _addedEpisodesCache.Find(seriesId.ToString()); - - if (previouslyAired != null && previouslyAired.Any()) - { - var missing = previouslyAired.Select(e => _episodeService.GetEpisode(e)).Where(e => !e.HasFile).ToList(); - - if (missing.Any()) - { - _commandQueueManager.Push(new EpisodeSearchCommand(missing.Select(e => e.Id).ToList())); - } - } - - _addedEpisodesCache.Remove(seriesId.ToString()); - } - - public void Handle(EpisodeInfoRefreshedEvent message) - { - if (message.Series.AddOptions == null) - { - if (!message.Series.Monitored) - { - _logger.Debug("Series is not monitored"); - return; - } - - if (message.Added.Empty()) - { - _logger.Debug("No new episodes, skipping search"); - return; - } - - if (message.Added.None(a => a.AirDateUtc.HasValue)) - { - _logger.Debug("No new episodes have an air date"); - return; - } - - var previouslyAired = message.Added.Where(a => a.AirDateUtc.HasValue && a.AirDateUtc.Value.Before(DateTime.UtcNow.AddDays(1)) && a.Monitored).ToList(); - - if (previouslyAired.Empty()) - { - _logger.Debug("Newly added episodes all air in the future"); - return; - } - - _addedEpisodesCache.Set(message.Series.Id.ToString(), previouslyAired.Select(e => e.Id).ToList()); - } - } - } -} diff --git a/src/NzbDrone.Core/Tv/EpisodeCutoffService.cs b/src/NzbDrone.Core/Tv/EpisodeCutoffService.cs deleted file mode 100644 index 6747aa87e..000000000 --- a/src/NzbDrone.Core/Tv/EpisodeCutoffService.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using NLog; -using NzbDrone.Core.Datastore; -using NzbDrone.Core.Profiles; -using NzbDrone.Core.Qualities; - -namespace NzbDrone.Core.Tv -{ - public interface IEpisodeCutoffService - { - PagingSpec<Episode> EpisodesWhereCutoffUnmet(PagingSpec<Episode> pagingSpec); - } - - public class EpisodeCutoffService : IEpisodeCutoffService - { - private readonly IEpisodeRepository _episodeRepository; - private readonly IProfileService _profileService; - private readonly Logger _logger; - - public EpisodeCutoffService(IEpisodeRepository episodeRepository, IProfileService profileService, Logger logger) - { - _episodeRepository = episodeRepository; - _profileService = profileService; - _logger = logger; - } - - public PagingSpec<Episode> EpisodesWhereCutoffUnmet(PagingSpec<Episode> pagingSpec) - { - var qualitiesBelowCutoff = new List<QualitiesBelowCutoff>(); - var profiles = _profileService.All(); - - //Get all items less than the cutoff - foreach (var profile in profiles) - { - var cutoffIndex = profile.Items.FindIndex(v => v.Quality == profile.Cutoff); - var belowCutoff = profile.Items.Take(cutoffIndex).ToList(); - - if (belowCutoff.Any()) - { - qualitiesBelowCutoff.Add(new QualitiesBelowCutoff(profile.Id, belowCutoff.Select(i => i.Quality.Id))); - } - } - - return _episodeRepository.EpisodesWhereCutoffUnmet(pagingSpec, qualitiesBelowCutoff, false); - } - } -} diff --git a/src/NzbDrone.Core/Tv/EpisodeMonitoredService.cs b/src/NzbDrone.Core/Tv/EpisodeMonitoredService.cs deleted file mode 100644 index b15c130be..000000000 --- a/src/NzbDrone.Core/Tv/EpisodeMonitoredService.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using NLog; -using NzbDrone.Common.Extensions; - -namespace NzbDrone.Core.Tv -{ - public interface IEpisodeMonitoredService - { - void SetEpisodeMonitoredStatus(Series series, MonitoringOptions monitoringOptions); - } - - public class EpisodeMonitoredService : IEpisodeMonitoredService - { - private readonly ISeriesService _seriesService; - private readonly IEpisodeService _episodeService; - private readonly Logger _logger; - - public EpisodeMonitoredService(ISeriesService seriesService, IEpisodeService episodeService, Logger logger) - { - _seriesService = seriesService; - _episodeService = episodeService; - _logger = logger; - } - - public void SetEpisodeMonitoredStatus(Series series, MonitoringOptions monitoringOptions) - { - if (monitoringOptions != null) - { - _logger.Debug("[{0}] Setting episode monitored status.", series.Title); - - var episodes = _episodeService.GetEpisodeBySeries(series.Id); - - if (monitoringOptions.IgnoreEpisodesWithFiles) - { - _logger.Debug("Ignoring Episodes with Files"); - ToggleEpisodesMonitoredState(episodes.Where(e => e.HasFile), false); - } - - else - { - _logger.Debug("Monitoring Episodes with Files"); - ToggleEpisodesMonitoredState(episodes.Where(e => e.HasFile), true); - } - - if (monitoringOptions.IgnoreEpisodesWithoutFiles) - { - _logger.Debug("Ignoring Episodes without Files"); - ToggleEpisodesMonitoredState(episodes.Where(e => !e.HasFile && e.AirDateUtc.HasValue && e.AirDateUtc.Value.Before(DateTime.UtcNow)), false); - } - - else - { - _logger.Debug("Monitoring Episodes without Files"); - ToggleEpisodesMonitoredState(episodes.Where(e => !e.HasFile && e.AirDateUtc.HasValue && e.AirDateUtc.Value.Before(DateTime.UtcNow)), true); - } - - var lastSeason = series.Seasons.Select(s => s.SeasonNumber).MaxOrDefault(); - - foreach (var s in series.Seasons) - { - var season = s; - - if (season.Monitored) - { - if (!monitoringOptions.IgnoreEpisodesWithFiles && !monitoringOptions.IgnoreEpisodesWithoutFiles) - { - ToggleEpisodesMonitoredState(episodes.Where(e => e.SeasonNumber == season.SeasonNumber), true); - } - } - - else - { - if (!monitoringOptions.IgnoreEpisodesWithFiles && !monitoringOptions.IgnoreEpisodesWithoutFiles) - { - ToggleEpisodesMonitoredState(episodes.Where(e => e.SeasonNumber == season.SeasonNumber), false); - } - - else if (season.SeasonNumber == 0) - { - ToggleEpisodesMonitoredState(episodes.Where(e => e.SeasonNumber == season.SeasonNumber), false); - } - } - - if (season.SeasonNumber < lastSeason) - { - if (episodes.Where(e => e.SeasonNumber == season.SeasonNumber).All(e => !e.Monitored)) - { - season.Monitored = false; - } - } - } - - _episodeService.UpdateEpisodes(episodes); - } - - _seriesService.UpdateSeries(series); - } - - private void ToggleEpisodesMonitoredState(IEnumerable<Episode> episodes, bool monitored) - { - foreach (var episode in episodes) - { - episode.Monitored = monitored; - } - } - } -} diff --git a/src/NzbDrone.Core/Tv/EpisodeRepository.cs b/src/NzbDrone.Core/Tv/EpisodeRepository.cs deleted file mode 100644 index 5a1f413ad..000000000 --- a/src/NzbDrone.Core/Tv/EpisodeRepository.cs +++ /dev/null @@ -1,266 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Marr.Data.QGen; -using NLog; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Datastore; -using NzbDrone.Core.Datastore.Extensions; -using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Qualities; - -namespace NzbDrone.Core.Tv -{ - public interface IEpisodeRepository : IBasicRepository<Episode> - { - Episode Find(int seriesId, int season, int episodeNumber); - Episode Find(int seriesId, int absoluteEpisodeNumber); - Episode Get(int seriesId, string date); - Episode Find(int seriesId, string date); - List<Episode> GetEpisodes(int seriesId); - List<Episode> GetEpisodes(int seriesId, int seasonNumber); - List<Episode> GetEpisodeByFileId(int fileId); - List<Episode> EpisodesWithFiles(int seriesId); - PagingSpec<Episode> EpisodesWithoutFiles(PagingSpec<Episode> pagingSpec, bool includeSpecials); - PagingSpec<Episode> EpisodesWhereCutoffUnmet(PagingSpec<Episode> pagingSpec, List<QualitiesBelowCutoff> qualitiesBelowCutoff, bool includeSpecials); - List<Episode> FindEpisodesBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber); - Episode FindEpisodeBySceneNumbering(int seriesId, int sceneAbsoluteEpisodeNumber); - List<Episode> EpisodesBetweenDates(DateTime startDate, DateTime endDate, bool includeUnmonitored); - void SetMonitoredFlat(Episode episode, bool monitored); - void SetMonitoredBySeason(int seriesId, int seasonNumber, bool monitored); - void SetFileId(int episodeId, int fileId); - } - - public class EpisodeRepository : BasicRepository<Episode>, IEpisodeRepository - { - private readonly IMainDatabase _database; - private readonly Logger _logger; - - public EpisodeRepository(IMainDatabase database, IEventAggregator eventAggregator, Logger logger) - : base(database, eventAggregator) - { - _database = database; - _logger = logger; - } - - public Episode Find(int seriesId, int season, int episodeNumber) - { - return Query.Where(s => s.SeriesId == seriesId) - .AndWhere(s => s.SeasonNumber == season) - .AndWhere(s => s.EpisodeNumber == episodeNumber) - .SingleOrDefault(); - } - - public Episode Find(int seriesId, int absoluteEpisodeNumber) - { - return Query.Where(s => s.SeriesId == seriesId) - .AndWhere(s => s.AbsoluteEpisodeNumber == absoluteEpisodeNumber) - .SingleOrDefault(); - } - - public Episode Get(int seriesId, string date) - { - var episode = FindOneByAirDate(seriesId, date); - - if (episode == null) - { - throw new InvalidOperationException("Expected at one episode"); - } - - return episode; - } - - public Episode Find(int seriesId, string date) - { - return FindOneByAirDate(seriesId, date); - } - - public List<Episode> GetEpisodes(int seriesId) - { - return Query.Where(s => s.SeriesId == seriesId).ToList(); - } - - public List<Episode> GetEpisodes(int seriesId, int seasonNumber) - { - return Query.Where(s => s.SeriesId == seriesId) - .AndWhere(s => s.SeasonNumber == seasonNumber) - .ToList(); - } - - public List<Episode> GetEpisodeByFileId(int fileId) - { - return Query.Where(e => e.EpisodeFileId == fileId).ToList(); - } - - public List<Episode> EpisodesWithFiles(int seriesId) - { - return Query.Join<Episode, EpisodeFile>(JoinType.Inner, e => e.EpisodeFile, (e, ef) => e.EpisodeFileId == ef.Id) - .Where(e => e.SeriesId == seriesId); - } - - public PagingSpec<Episode> EpisodesWithoutFiles(PagingSpec<Episode> pagingSpec, bool includeSpecials) - { - var currentTime = DateTime.UtcNow; - var startingSeasonNumber = 1; - - if (includeSpecials) - { - startingSeasonNumber = 0; - } - - pagingSpec.TotalRecords = GetMissingEpisodesQuery(pagingSpec, currentTime, startingSeasonNumber).GetRowCount(); - pagingSpec.Records = GetMissingEpisodesQuery(pagingSpec, currentTime, startingSeasonNumber).ToList(); - - return pagingSpec; - } - - public PagingSpec<Episode> EpisodesWhereCutoffUnmet(PagingSpec<Episode> pagingSpec, List<QualitiesBelowCutoff> qualitiesBelowCutoff, bool includeSpecials) - { - var startingSeasonNumber = 1; - - if (includeSpecials) - { - startingSeasonNumber = 0; - } - - pagingSpec.TotalRecords = EpisodesWhereCutoffUnmetQuery(pagingSpec, qualitiesBelowCutoff, startingSeasonNumber).GetRowCount(); - pagingSpec.Records = EpisodesWhereCutoffUnmetQuery(pagingSpec, qualitiesBelowCutoff, startingSeasonNumber).ToList(); - - return pagingSpec; - } - - public List<Episode> FindEpisodesBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber) - { - return Query.Where(s => s.SeriesId == seriesId) - .AndWhere(s => s.SceneSeasonNumber == seasonNumber) - .AndWhere(s => s.SceneEpisodeNumber == episodeNumber); - } - - public Episode FindEpisodeBySceneNumbering(int seriesId, int sceneAbsoluteEpisodeNumber) - { - var episodes = Query.Where(s => s.SeriesId == seriesId) - .AndWhere(s => s.SceneAbsoluteEpisodeNumber == sceneAbsoluteEpisodeNumber) - .ToList(); - - if (episodes.Empty() || episodes.Count > 1) - { - return null; - } - - return episodes.Single(); - } - - public List<Episode> EpisodesBetweenDates(DateTime startDate, DateTime endDate, bool includeUnmonitored) - { - var query = Query.Join<Episode, Series>(JoinType.Inner, e => e.Series, (e, s) => e.SeriesId == s.Id) - .Where<Episode>(e => e.AirDateUtc >= startDate) - .AndWhere(e => e.AirDateUtc <= endDate); - - - if (!includeUnmonitored) - { - query.AndWhere(e => e.Monitored) - .AndWhere(e => e.Series.Monitored); - } - - return query.ToList(); - } - - public void SetMonitoredFlat(Episode episode, bool monitored) - { - episode.Monitored = monitored; - SetFields(episode, p => p.Monitored); - } - - public void SetMonitoredBySeason(int seriesId, int seasonNumber, bool monitored) - { - var mapper = _database.GetDataMapper(); - - mapper.AddParameter("seriesId", seriesId); - mapper.AddParameter("seasonNumber", seasonNumber); - mapper.AddParameter("monitored", monitored); - - const string sql = "UPDATE Episodes " + - "SET Monitored = @monitored " + - "WHERE SeriesId = @seriesId " + - "AND SeasonNumber = @seasonNumber"; - - mapper.ExecuteNonQuery(sql); - } - - public void SetFileId(int episodeId, int fileId) - { - SetFields(new Episode { Id = episodeId, EpisodeFileId = fileId }, episode => episode.EpisodeFileId); - } - - private SortBuilder<Episode> GetMissingEpisodesQuery(PagingSpec<Episode> pagingSpec, DateTime currentTime, int startingSeasonNumber) - { - return Query.Join<Episode, Series>(JoinType.Inner, e => e.Series, (e, s) => e.SeriesId == s.Id) - .Where(pagingSpec.FilterExpression) - .AndWhere(e => e.EpisodeFileId == 0) - .AndWhere(e => e.SeasonNumber >= startingSeasonNumber) - .AndWhere(BuildAirDateUtcCutoffWhereClause(currentTime)) - .OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection()) - .Skip(pagingSpec.PagingOffset()) - .Take(pagingSpec.PageSize); - } - - private SortBuilder<Episode> EpisodesWhereCutoffUnmetQuery(PagingSpec<Episode> pagingSpec, List<QualitiesBelowCutoff> qualitiesBelowCutoff, int startingSeasonNumber) - { - return Query.Join<Episode, Series>(JoinType.Inner, e => e.Series, (e, s) => e.SeriesId == s.Id) - .Join<Episode, EpisodeFile>(JoinType.Left, e => e.EpisodeFile, (e, s) => e.EpisodeFileId == s.Id) - .Where(pagingSpec.FilterExpression) - .AndWhere(e => e.EpisodeFileId != 0) - .AndWhere(e => e.SeasonNumber >= startingSeasonNumber) - .AndWhere(BuildQualityCutoffWhereClause(qualitiesBelowCutoff)) - .OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection()) - .Skip(pagingSpec.PagingOffset()) - .Take(pagingSpec.PageSize); - } - - private string BuildAirDateUtcCutoffWhereClause(DateTime currentTime) - { - return string.Format("WHERE datetime(strftime('%s', [t0].[AirDateUtc]) + [t1].[RunTime] * 60, 'unixepoch') <= '{0}'", - currentTime.ToString("yyyy-MM-dd HH:mm:ss")); - } - - private string BuildQualityCutoffWhereClause(List<QualitiesBelowCutoff> qualitiesBelowCutoff) - { - var clauses = new List<string>(); - - foreach (var profile in qualitiesBelowCutoff) - { - foreach (var belowCutoff in profile.QualityIds) - { - clauses.Add(string.Format("([t1].[ProfileId] = {0} AND [t2].[Quality] LIKE '%_quality_: {1},%')", profile.ProfileId, belowCutoff)); - } - } - - return string.Format("({0})", string.Join(" OR ", clauses)); - } - - private Episode FindOneByAirDate(int seriesId, string date) - { - var episodes = Query.Where(s => s.SeriesId == seriesId) - .AndWhere(s => s.AirDate == date) - .ToList(); - - if (!episodes.Any()) return null; - - if (episodes.Count == 1) return episodes.First(); - - _logger.Debug("Multiple episodes with the same air date were found, will exclude specials"); - - var regularEpisodes = episodes.Where(e => e.SeasonNumber > 0).ToList(); - - if (regularEpisodes.Count == 1) - { - _logger.Debug("Left with one episode after excluding specials"); - return regularEpisodes.First(); - } - - throw new InvalidOperationException("Multiple episodes with the same air date found"); - } - } -} diff --git a/src/NzbDrone.Core/Tv/EpisodeService.cs b/src/NzbDrone.Core/Tv/EpisodeService.cs deleted file mode 100644 index 32a46ec45..000000000 --- a/src/NzbDrone.Core/Tv/EpisodeService.cs +++ /dev/null @@ -1,225 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using NLog; -using NzbDrone.Core.Configuration; -using NzbDrone.Core.Datastore; -using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.MediaFiles.Events; -using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Tv.Events; - -namespace NzbDrone.Core.Tv -{ - public interface IEpisodeService - { - Episode GetEpisode(int id); - List<Episode> GetEpisodes(IEnumerable<int> ids); - Episode FindEpisode(int seriesId, int seasonNumber, int episodeNumber); - Episode FindEpisode(int seriesId, int absoluteEpisodeNumber); - Episode FindEpisodeByTitle(int seriesId, int seasonNumber, string releaseTitle); - List<Episode> FindEpisodesBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber); - Episode FindEpisodeBySceneNumbering(int seriesId, int sceneAbsoluteEpisodeNumber); - Episode GetEpisode(int seriesId, string date); - Episode FindEpisode(int seriesId, string date); - List<Episode> GetEpisodeBySeries(int seriesId); - List<Episode> GetEpisodesBySeason(int seriesId, int seasonNumber); - List<Episode> EpisodesWithFiles(int seriesId); - PagingSpec<Episode> EpisodesWithoutFiles(PagingSpec<Episode> pagingSpec); - List<Episode> GetEpisodesByFileId(int episodeFileId); - void UpdateEpisode(Episode episode); - void SetEpisodeMonitored(int episodeId, bool monitored); - void UpdateEpisodes(List<Episode> episodes); - List<Episode> EpisodesBetweenDates(DateTime start, DateTime end, bool includeUnmonitored); - void InsertMany(List<Episode> episodes); - void UpdateMany(List<Episode> episodes); - void DeleteMany(List<Episode> episodes); - void SetEpisodeMonitoredBySeason(int seriesId, int seasonNumber, bool monitored); - } - - public class EpisodeService : IEpisodeService, - IHandle<EpisodeFileDeletedEvent>, - IHandle<EpisodeFileAddedEvent>, - IHandleAsync<SeriesDeletedEvent> - { - private readonly IEpisodeRepository _episodeRepository; - private readonly IConfigService _configService; - private readonly Logger _logger; - - public EpisodeService(IEpisodeRepository episodeRepository, IConfigService configService, Logger logger) - { - _episodeRepository = episodeRepository; - _configService = configService; - _logger = logger; - } - - public Episode GetEpisode(int id) - { - return _episodeRepository.Get(id); - } - - public List<Episode> GetEpisodes(IEnumerable<int> ids) - { - return _episodeRepository.Get(ids).ToList(); - } - - public Episode FindEpisode(int seriesId, int seasonNumber, int episodeNumber) - { - return _episodeRepository.Find(seriesId, seasonNumber, episodeNumber); - } - - public Episode FindEpisode(int seriesId, int absoluteEpisodeNumber) - { - return _episodeRepository.Find(seriesId, absoluteEpisodeNumber); - } - - public List<Episode> FindEpisodesBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber) - { - return _episodeRepository.FindEpisodesBySceneNumbering(seriesId, seasonNumber, episodeNumber); - } - - public Episode FindEpisodeBySceneNumbering(int seriesId, int sceneAbsoluteEpisodeNumber) - { - return _episodeRepository.FindEpisodeBySceneNumbering(seriesId, sceneAbsoluteEpisodeNumber); - } - - public Episode GetEpisode(int seriesId, string date) - { - return _episodeRepository.Get(seriesId, date); - } - - public Episode FindEpisode(int seriesId, string date) - { - return _episodeRepository.Find(seriesId, date); - } - - public List<Episode> GetEpisodeBySeries(int seriesId) - { - return _episodeRepository.GetEpisodes(seriesId).ToList(); - } - - public List<Episode> GetEpisodesBySeason(int seriesId, int seasonNumber) - { - return _episodeRepository.GetEpisodes(seriesId, seasonNumber); - } - - public Episode FindEpisodeByTitle(int seriesId, int seasonNumber, string releaseTitle) - { - // TODO: can replace this search mechanism with something smarter/faster/better - var normalizedReleaseTitle = Parser.Parser.NormalizeEpisodeTitle(releaseTitle).Replace(".", " "); - var episodes = _episodeRepository.GetEpisodes(seriesId, seasonNumber); - - var matches = episodes.Select( - episode => new - { - Position = normalizedReleaseTitle.IndexOf(Parser.Parser.NormalizeEpisodeTitle(episode.Title), StringComparison.CurrentCultureIgnoreCase), - Length = Parser.Parser.NormalizeEpisodeTitle(episode.Title).Length, - Episode = episode - }) - .Where(e => e.Episode.Title.Length > 0 && e.Position >= 0) - .OrderBy(e => e.Position) - .ThenByDescending(e => e.Length) - .ToList(); - - if (matches.Any()) - { - return matches.First().Episode; - } - - return null; - } - - public List<Episode> EpisodesWithFiles(int seriesId) - { - return _episodeRepository.EpisodesWithFiles(seriesId); - } - - public PagingSpec<Episode> EpisodesWithoutFiles(PagingSpec<Episode> pagingSpec) - { - var episodeResult = _episodeRepository.EpisodesWithoutFiles(pagingSpec, true); - - return episodeResult; - } - - public List<Episode> GetEpisodesByFileId(int episodeFileId) - { - return _episodeRepository.GetEpisodeByFileId(episodeFileId); - } - - public void UpdateEpisode(Episode episode) - { - _episodeRepository.Update(episode); - } - - public void SetEpisodeMonitored(int episodeId, bool monitored) - { - var episode = _episodeRepository.Get(episodeId); - _episodeRepository.SetMonitoredFlat(episode, monitored); - - _logger.Debug("Monitored flag for Episode:{0} was set to {1}", episodeId, monitored); - } - - public void SetEpisodeMonitoredBySeason(int seriesId, int seasonNumber, bool monitored) - { - _episodeRepository.SetMonitoredBySeason(seriesId, seasonNumber, monitored); - } - - public void UpdateEpisodes(List<Episode> episodes) - { - _episodeRepository.UpdateMany(episodes); - } - - public List<Episode> EpisodesBetweenDates(DateTime start, DateTime end, bool includeUnmonitored) - { - var episodes = _episodeRepository.EpisodesBetweenDates(start.ToUniversalTime(), end.ToUniversalTime(), includeUnmonitored); - - return episodes; - } - - public void InsertMany(List<Episode> episodes) - { - _episodeRepository.InsertMany(episodes); - } - - public void UpdateMany(List<Episode> episodes) - { - _episodeRepository.UpdateMany(episodes); - } - - public void DeleteMany(List<Episode> episodes) - { - _episodeRepository.DeleteMany(episodes); - } - - public void HandleAsync(SeriesDeletedEvent message) - { - var episodes = GetEpisodeBySeries(message.Series.Id); - _episodeRepository.DeleteMany(episodes); - } - - public void Handle(EpisodeFileDeletedEvent message) - { - foreach (var episode in GetEpisodesByFileId(message.EpisodeFile.Id)) - { - _logger.Debug("Detaching episode {0} from file.", episode.Id); - episode.EpisodeFileId = 0; - - if (message.Reason != DeleteMediaFileReason.Upgrade && _configService.AutoUnmonitorPreviouslyDownloadedEpisodes) - { - episode.Monitored = false; - } - - UpdateEpisode(episode); - } - } - - public void Handle(EpisodeFileAddedEvent message) - { - foreach (var episode in message.EpisodeFile.Episodes.Value) - { - _episodeRepository.SetFileId(episode.Id, message.EpisodeFile.Id); - _logger.Debug("Linking [{0}] > [{1}]", message.EpisodeFile.RelativePath, episode); - } - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Tv/Events/EpisodeInfoRefreshedEvent.cs b/src/NzbDrone.Core/Tv/Events/EpisodeInfoRefreshedEvent.cs deleted file mode 100644 index 4eded3b79..000000000 --- a/src/NzbDrone.Core/Tv/Events/EpisodeInfoRefreshedEvent.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; -using System.Collections.ObjectModel; -using NzbDrone.Common.Messaging; - -namespace NzbDrone.Core.Tv.Events -{ - public class EpisodeInfoRefreshedEvent : IEvent - { - public Series Series { get; set; } - public ReadOnlyCollection<Episode> Added { get; private set; } - public ReadOnlyCollection<Episode> Updated { get; private set; } - - public EpisodeInfoRefreshedEvent(Series series, IList<Episode> added, IList<Episode> updated) - { - Series = series; - Added = new ReadOnlyCollection<Episode>(added); - Updated = new ReadOnlyCollection<Episode>(updated); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Tv/Events/SeriesAddedEvent.cs b/src/NzbDrone.Core/Tv/Events/SeriesAddedEvent.cs deleted file mode 100644 index 1a18c2b8d..000000000 --- a/src/NzbDrone.Core/Tv/Events/SeriesAddedEvent.cs +++ /dev/null @@ -1,14 +0,0 @@ -using NzbDrone.Common.Messaging; - -namespace NzbDrone.Core.Tv.Events -{ - public class SeriesAddedEvent : IEvent - { - public Series Series { get; private set; } - - public SeriesAddedEvent(Series series) - { - Series = series; - } - } -} diff --git a/src/NzbDrone.Core/Tv/Events/SeriesDeletedEvent.cs b/src/NzbDrone.Core/Tv/Events/SeriesDeletedEvent.cs deleted file mode 100644 index e04d8f60e..000000000 --- a/src/NzbDrone.Core/Tv/Events/SeriesDeletedEvent.cs +++ /dev/null @@ -1,16 +0,0 @@ -using NzbDrone.Common.Messaging; - -namespace NzbDrone.Core.Tv.Events -{ - public class SeriesDeletedEvent : IEvent - { - public Series Series { get; private set; } - public bool DeleteFiles { get; private set; } - - public SeriesDeletedEvent(Series series, bool deleteFiles) - { - Series = series; - DeleteFiles = deleteFiles; - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Tv/Events/SeriesEditedEvent.cs b/src/NzbDrone.Core/Tv/Events/SeriesEditedEvent.cs deleted file mode 100644 index a37a6c902..000000000 --- a/src/NzbDrone.Core/Tv/Events/SeriesEditedEvent.cs +++ /dev/null @@ -1,16 +0,0 @@ -using NzbDrone.Common.Messaging; - -namespace NzbDrone.Core.Tv.Events -{ - public class SeriesEditedEvent : IEvent - { - public Series Series { get; private set; } - public Series OldSeries { get; private set; } - - public SeriesEditedEvent(Series series, Series oldSeries) - { - Series = series; - OldSeries = oldSeries; - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Tv/Events/SeriesMovedEvent.cs b/src/NzbDrone.Core/Tv/Events/SeriesMovedEvent.cs deleted file mode 100644 index 72c48c269..000000000 --- a/src/NzbDrone.Core/Tv/Events/SeriesMovedEvent.cs +++ /dev/null @@ -1,18 +0,0 @@ -using NzbDrone.Common.Messaging; - -namespace NzbDrone.Core.Tv.Events -{ - public class SeriesMovedEvent : IEvent - { - public Series Series { get; set; } - public string SourcePath { get; set; } - public string DestinationPath { get; set; } - - public SeriesMovedEvent(Series series, string sourcePath, string destinationPath) - { - Series = series; - SourcePath = sourcePath; - DestinationPath = destinationPath; - } - } -} diff --git a/src/NzbDrone.Core/Tv/Events/SeriesRefreshStartingEvent.cs b/src/NzbDrone.Core/Tv/Events/SeriesRefreshStartingEvent.cs deleted file mode 100644 index e330b0004..000000000 --- a/src/NzbDrone.Core/Tv/Events/SeriesRefreshStartingEvent.cs +++ /dev/null @@ -1,14 +0,0 @@ -using NzbDrone.Common.Messaging; - -namespace NzbDrone.Core.Tv.Events -{ - public class SeriesRefreshStartingEvent : IEvent - { - public bool ManualTrigger { get; set; } - - public SeriesRefreshStartingEvent(bool manualTrigger) - { - ManualTrigger = manualTrigger; - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Tv/Events/SeriesUpdatedEvent.cs b/src/NzbDrone.Core/Tv/Events/SeriesUpdatedEvent.cs deleted file mode 100644 index 8dafe0563..000000000 --- a/src/NzbDrone.Core/Tv/Events/SeriesUpdatedEvent.cs +++ /dev/null @@ -1,14 +0,0 @@ -using NzbDrone.Common.Messaging; - -namespace NzbDrone.Core.Tv.Events -{ - public class SeriesUpdatedEvent : IEvent - { - public Series Series { get; private set; } - - public SeriesUpdatedEvent(Series series) - { - Series = series; - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Tv/RefreshEpisodeService.cs b/src/NzbDrone.Core/Tv/RefreshEpisodeService.cs deleted file mode 100644 index 7d1a7d993..000000000 --- a/src/NzbDrone.Core/Tv/RefreshEpisodeService.cs +++ /dev/null @@ -1,199 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using NLog; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Tv.Events; - -namespace NzbDrone.Core.Tv -{ - public interface IRefreshEpisodeService - { - void RefreshEpisodeInfo(Series series, IEnumerable<Episode> remoteEpisodes); - } - - public class RefreshEpisodeService : IRefreshEpisodeService - { - private readonly IEpisodeService _episodeService; - private readonly IEventAggregator _eventAggregator; - private readonly Logger _logger; - - public RefreshEpisodeService(IEpisodeService episodeService, IEventAggregator eventAggregator, Logger logger) - { - _episodeService = episodeService; - _eventAggregator = eventAggregator; - _logger = logger; - } - - public void RefreshEpisodeInfo(Series series, IEnumerable<Episode> remoteEpisodes) - { - _logger.Info("Starting episode info refresh for: {0}", series); - var successCount = 0; - var failCount = 0; - - var existingEpisodes = _episodeService.GetEpisodeBySeries(series.Id); - var seasons = series.Seasons; - - var updateList = new List<Episode>(); - var newList = new List<Episode>(); - var dupeFreeRemoteEpisodes = remoteEpisodes.DistinctBy(m => new { m.SeasonNumber, m.EpisodeNumber }).ToList(); - - if (series.SeriesType == SeriesTypes.Anime) - { - dupeFreeRemoteEpisodes = MapAbsoluteEpisodeNumbers(dupeFreeRemoteEpisodes); - } - - foreach (var episode in OrderEpisodes(series, dupeFreeRemoteEpisodes)) - { - try - { - var episodeToUpdate = GetEpisodeToUpdate(series, episode, existingEpisodes); - - if (episodeToUpdate != null) - { - existingEpisodes.Remove(episodeToUpdate); - updateList.Add(episodeToUpdate); - } - else - { - episodeToUpdate = new Episode(); - episodeToUpdate.Monitored = GetMonitoredStatus(episode, seasons); - newList.Add(episodeToUpdate); - } - - episodeToUpdate.SeriesId = series.Id; - episodeToUpdate.EpisodeNumber = episode.EpisodeNumber; - episodeToUpdate.SeasonNumber = episode.SeasonNumber; - episodeToUpdate.AbsoluteEpisodeNumber = episode.AbsoluteEpisodeNumber; - episodeToUpdate.Title = episode.Title ?? "TBA"; - episodeToUpdate.Overview = episode.Overview; - episodeToUpdate.AirDate = episode.AirDate; - episodeToUpdate.AirDateUtc = episode.AirDateUtc; - episodeToUpdate.Ratings = episode.Ratings; - episodeToUpdate.Images = episode.Images; - - successCount++; - } - catch (Exception e) - { - _logger.Fatal(e, string.Format("An error has occurred while updating episode info for series {0}. {1}", series, episode)); - failCount++; - } - } - - var allEpisodes = new List<Episode>(); - allEpisodes.AddRange(newList); - allEpisodes.AddRange(updateList); - - AdjustMultiEpisodeAirTime(series, allEpisodes); - AdjustDirectToDvdAirDate(series, allEpisodes); - - _episodeService.DeleteMany(existingEpisodes); - _episodeService.UpdateMany(updateList); - _episodeService.InsertMany(newList); - - _eventAggregator.PublishEvent(new EpisodeInfoRefreshedEvent(series, newList, updateList)); - - if (failCount != 0) - { - _logger.Info("Finished episode refresh for series: {0}. Successful: {1} - Failed: {2} ", - series.Title, successCount, failCount); - } - else - { - _logger.Info("Finished episode refresh for series: {0}.", series); - } - } - - private bool GetMonitoredStatus(Episode episode, IEnumerable<Season> seasons) - { - if (episode.EpisodeNumber == 0 && episode.SeasonNumber != 1) - { - return false; - } - - var season = seasons.SingleOrDefault(c => c.SeasonNumber == episode.SeasonNumber); - return season == null || season.Monitored; - } - - private void AdjustMultiEpisodeAirTime(Series series, IEnumerable<Episode> allEpisodes) - { - if (series.Network == "Netflix") - { - _logger.Debug("Not adjusting episode air times for Netflix series {0}", series.Title); - return; - } - - var groups = allEpisodes.Where(c => c.AirDateUtc.HasValue) - .GroupBy(e => new {e.SeasonNumber, e.AirDate}) - .Where(g => g.Count() > 1) - .ToList(); - - foreach (var group in groups) - { - var episodeCount = 0; - - foreach (var episode in group.OrderBy(e => e.SeasonNumber).ThenBy(e => e.EpisodeNumber)) - { - episode.AirDateUtc = episode.AirDateUtc.Value.AddMinutes(series.Runtime * episodeCount); - episodeCount++; - } - } - } - - private void AdjustDirectToDvdAirDate(Series series, IEnumerable<Episode> allEpisodes) - { - if (series.Status == SeriesStatusType.Ended && allEpisodes.All(v => !v.AirDateUtc.HasValue) && series.FirstAired.HasValue) - { - foreach (var episode in allEpisodes) - { - episode.AirDateUtc = series.FirstAired; - episode.AirDate = series.FirstAired.Value.ToString("yyyy-MM-dd"); - } - } - } - - private List<Episode> MapAbsoluteEpisodeNumbers(List<Episode> remoteEpisodes) - { - //Return all episodes with no abs number, but distinct for those with abs number - return remoteEpisodes.Where(e => e.AbsoluteEpisodeNumber.HasValue) - .OrderByDescending(e => e.SeasonNumber) - .DistinctBy(e => e.AbsoluteEpisodeNumber.Value) - .Concat(remoteEpisodes.Where(e => !e.AbsoluteEpisodeNumber.HasValue)) - .ToList(); - } - - private Episode GetEpisodeToUpdate(Series series, Episode episode, List<Episode> existingEpisodes) - { - if (series.SeriesType == SeriesTypes.Anime) - { - if (episode.AbsoluteEpisodeNumber.HasValue) - { - var matchingEpisode = existingEpisodes.FirstOrDefault(e => e.AbsoluteEpisodeNumber == episode.AbsoluteEpisodeNumber); - - if (matchingEpisode != null) return matchingEpisode; - } - } - - return existingEpisodes.FirstOrDefault(e => e.SeasonNumber == episode.SeasonNumber && e.EpisodeNumber == episode.EpisodeNumber); - } - - private IEnumerable<Episode> OrderEpisodes(Series series, List<Episode> episodes) - { - if (series.SeriesType == SeriesTypes.Anime) - { - var withAbs = episodes.Where(e => e.AbsoluteEpisodeNumber.HasValue) - .OrderBy(e => e.AbsoluteEpisodeNumber); - - var withoutAbs = episodes.Where(e => !e.AbsoluteEpisodeNumber.HasValue) - .OrderBy(e => e.SeasonNumber) - .ThenBy(e => e.EpisodeNumber); - - return withAbs.Concat(withoutAbs); - } - - return episodes.OrderBy(e => e.SeasonNumber).ThenBy(e => e.EpisodeNumber); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Tv/RefreshSeriesService.cs b/src/NzbDrone.Core/Tv/RefreshSeriesService.cs deleted file mode 100644 index c39deeffb..000000000 --- a/src/NzbDrone.Core/Tv/RefreshSeriesService.cs +++ /dev/null @@ -1,190 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using NLog; -using NzbDrone.Common.Extensions; -using NzbDrone.Common.Instrumentation.Extensions; -using NzbDrone.Core.DataAugmentation.DailySeries; -using NzbDrone.Core.Exceptions; -using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Messaging.Commands; -using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.MetadataSource; -using NzbDrone.Core.Tv.Commands; -using NzbDrone.Core.Tv.Events; - -namespace NzbDrone.Core.Tv -{ - public class RefreshSeriesService : IExecute<RefreshSeriesCommand> - { - private readonly IProvideSeriesInfo _seriesInfo; - private readonly ISeriesService _seriesService; - private readonly IRefreshEpisodeService _refreshEpisodeService; - private readonly IEventAggregator _eventAggregator; - private readonly IDailySeriesService _dailySeriesService; - private readonly IDiskScanService _diskScanService; - private readonly ICheckIfSeriesShouldBeRefreshed _checkIfSeriesShouldBeRefreshed; - private readonly Logger _logger; - - public RefreshSeriesService(IProvideSeriesInfo seriesInfo, - ISeriesService seriesService, - IRefreshEpisodeService refreshEpisodeService, - IEventAggregator eventAggregator, - IDailySeriesService dailySeriesService, - IDiskScanService diskScanService, - ICheckIfSeriesShouldBeRefreshed checkIfSeriesShouldBeRefreshed, - Logger logger) - { - _seriesInfo = seriesInfo; - _seriesService = seriesService; - _refreshEpisodeService = refreshEpisodeService; - _eventAggregator = eventAggregator; - _dailySeriesService = dailySeriesService; - _diskScanService = diskScanService; - _checkIfSeriesShouldBeRefreshed = checkIfSeriesShouldBeRefreshed; - _logger = logger; - } - - private void RefreshSeriesInfo(Series series) - { - _logger.ProgressInfo("Updating Info for {0}", series.Title); - - Tuple<Series, List<Episode>> tuple; - - try - { - tuple = _seriesInfo.GetSeriesInfo(series.TvdbId); - } - catch (SeriesNotFoundException) - { - _logger.Error("Series '{0}' (tvdbid {1}) was not found, it may have been removed from TheTVDB.", series.Title, series.TvdbId); - return; - } - - var seriesInfo = tuple.Item1; - - if (series.TvdbId != seriesInfo.TvdbId) - { - _logger.Warn("Series '{0}' (tvdbid {1}) was replaced with '{2}' (tvdbid {3}), because the original was a duplicate.", series.Title, series.TvdbId, seriesInfo.Title, seriesInfo.TvdbId); - series.TvdbId = seriesInfo.TvdbId; - } - - series.Title = seriesInfo.Title; - series.TitleSlug = seriesInfo.TitleSlug; - series.TvRageId = seriesInfo.TvRageId; - series.TvMazeId = seriesInfo.TvMazeId; - series.ImdbId = seriesInfo.ImdbId; - series.AirTime = seriesInfo.AirTime; - series.Overview = seriesInfo.Overview; - series.Status = seriesInfo.Status; - series.CleanTitle = seriesInfo.CleanTitle; - series.SortTitle = seriesInfo.SortTitle; - series.LastInfoSync = DateTime.UtcNow; - series.Runtime = seriesInfo.Runtime; - series.Images = seriesInfo.Images; - series.Network = seriesInfo.Network; - series.FirstAired = seriesInfo.FirstAired; - series.Ratings = seriesInfo.Ratings; - series.Actors = seriesInfo.Actors; - series.Genres = seriesInfo.Genres; - series.Certification = seriesInfo.Certification; - - if (_dailySeriesService.IsDailySeries(series.TvdbId)) - { - series.SeriesType = SeriesTypes.Daily; - } - - try - { - series.Path = new DirectoryInfo(series.Path).FullName; - series.Path = series.Path.GetActualCasing(); - } - catch (Exception e) - { - _logger.Warn(e, "Couldn't update series path for " + series.Path); - } - - series.Seasons = UpdateSeasons(series, seriesInfo); - - _seriesService.UpdateSeries(series); - _refreshEpisodeService.RefreshEpisodeInfo(series, tuple.Item2); - - _logger.Debug("Finished series refresh for {0}", series.Title); - _eventAggregator.PublishEvent(new SeriesUpdatedEvent(series)); - } - - private List<Season> UpdateSeasons(Series series, Series seriesInfo) - { - var seasons = seriesInfo.Seasons.DistinctBy(s => s.SeasonNumber).ToList(); - - foreach (var season in seasons) - { - var existingSeason = series.Seasons.FirstOrDefault(s => s.SeasonNumber == season.SeasonNumber); - - //Todo: Should this should use the previous season's monitored state? - if (existingSeason == null) - { - if (season.SeasonNumber == 0) - { - season.Monitored = false; - continue; - } - - _logger.Debug("New season ({0}) for series: [{1}] {2}, setting monitored to true", season.SeasonNumber, series.TvdbId, series.Title); - season.Monitored = true; - } - - else - { - season.Monitored = existingSeason.Monitored; - } - } - - return seasons; - } - - public void Execute(RefreshSeriesCommand message) - { - _eventAggregator.PublishEvent(new SeriesRefreshStartingEvent(message.Trigger == CommandTrigger.Manual)); - - if (message.SeriesId.HasValue) - { - var series = _seriesService.GetSeries(message.SeriesId.Value); - RefreshSeriesInfo(series); - } - else - { - var allSeries = _seriesService.GetAllSeries().OrderBy(c => c.SortTitle).ToList(); - - foreach (var series in allSeries) - { - if (message.Trigger == CommandTrigger.Manual || _checkIfSeriesShouldBeRefreshed.ShouldRefresh(series)) - { - try - { - RefreshSeriesInfo(series); - } - catch (Exception e) - { - _logger.Error(e, "Couldn't refresh info for {0}".Inject(series)); - } - } - - else - { - try - { - _logger.Info("Skipping refresh of series: {0}", series.Title); - _diskScanService.Scan(series); - } - catch (Exception e) - { - _logger.Error(e, "Couldn't rescan series {0}".Inject(series)); - } - } - } - } - } - } -} diff --git a/src/NzbDrone.Core/Tv/Season.cs b/src/NzbDrone.Core/Tv/Season.cs deleted file mode 100644 index e233c734f..000000000 --- a/src/NzbDrone.Core/Tv/Season.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Collections.Generic; -using NzbDrone.Core.Datastore; - -namespace NzbDrone.Core.Tv -{ - public class Season : IEmbeddedDocument - { - public Season() - { - Images = new List<MediaCover.MediaCover>(); - } - - public int SeasonNumber { get; set; } - public bool Monitored { get; set; } - public List<MediaCover.MediaCover> Images { get; set; } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Tv/Series.cs b/src/NzbDrone.Core/Tv/Series.cs deleted file mode 100644 index a3fdb986f..000000000 --- a/src/NzbDrone.Core/Tv/Series.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Collections.Generic; -using Marr.Data; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Datastore; -using NzbDrone.Core.Profiles; - -namespace NzbDrone.Core.Tv -{ - public class Series : ModelBase - { - public Series() - { - Images = new List<MediaCover.MediaCover>(); - Genres = new List<string>(); - Actors = new List<Actor>(); - Seasons = new List<Season>(); - Tags = new HashSet<int>(); - } - - public int TvdbId { get; set; } - public int TvRageId { get; set; } - public int TvMazeId { get; set; } - public string ImdbId { get; set; } - public string Title { get; set; } - public string CleanTitle { get; set; } - public string SortTitle { get; set; } - public SeriesStatusType Status { get; set; } - public string Overview { get; set; } - public string AirTime { get; set; } - public bool Monitored { get; set; } - public int ProfileId { get; set; } - public bool SeasonFolder { get; set; } - public DateTime? LastInfoSync { get; set; } - public int Runtime { get; set; } - public List<MediaCover.MediaCover> Images { get; set; } - public SeriesTypes SeriesType { get; set; } - public string Network { get; set; } - public bool UseSceneNumbering { get; set; } - public string TitleSlug { get; set; } - public string Path { get; set; } - public int Year { get; set; } - public Ratings Ratings { get; set; } - public List<string> Genres { get; set; } - public List<Actor> Actors { get; set; } - public string Certification { get; set; } - public string RootFolderPath { get; set; } - public DateTime Added { get; set; } - public DateTime? FirstAired { get; set; } - public LazyLoaded<Profile> Profile { get; set; } - - public List<Season> Seasons { get; set; } - public HashSet<int> Tags { get; set; } - public AddSeriesOptions AddOptions { get; set; } - - public override string ToString() - { - return string.Format("[{0}][{1}]", TvdbId, Title.NullSafe()); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Tv/SeriesAddedHandler.cs b/src/NzbDrone.Core/Tv/SeriesAddedHandler.cs deleted file mode 100644 index 2e7ee8005..000000000 --- a/src/NzbDrone.Core/Tv/SeriesAddedHandler.cs +++ /dev/null @@ -1,22 +0,0 @@ -using NzbDrone.Core.Messaging.Commands; -using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Tv.Commands; -using NzbDrone.Core.Tv.Events; - -namespace NzbDrone.Core.Tv -{ - public class SeriesAddedHandler : IHandle<SeriesAddedEvent> - { - private readonly IManageCommandQueue _commandQueueManager; - - public SeriesAddedHandler(IManageCommandQueue commandQueueManager) - { - _commandQueueManager = commandQueueManager; - } - - public void Handle(SeriesAddedEvent message) - { - _commandQueueManager.Push(new RefreshSeriesCommand(message.Series.Id)); - } - } -} diff --git a/src/NzbDrone.Core/Tv/SeriesEditedService.cs b/src/NzbDrone.Core/Tv/SeriesEditedService.cs deleted file mode 100644 index 063537f18..000000000 --- a/src/NzbDrone.Core/Tv/SeriesEditedService.cs +++ /dev/null @@ -1,25 +0,0 @@ -using NzbDrone.Core.Messaging.Commands; -using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Tv.Commands; -using NzbDrone.Core.Tv.Events; - -namespace NzbDrone.Core.Tv -{ - public class SeriesEditedService : IHandle<SeriesEditedEvent> - { - private readonly IManageCommandQueue _commandQueueManager; - - public SeriesEditedService(IManageCommandQueue commandQueueManager) - { - _commandQueueManager = commandQueueManager; - } - - public void Handle(SeriesEditedEvent message) - { - if (message.Series.SeriesType != message.OldSeries.SeriesType) - { - _commandQueueManager.Push(new RefreshSeriesCommand(message.Series.Id)); - } - } - } -} diff --git a/src/NzbDrone.Core/Tv/SeriesRepository.cs b/src/NzbDrone.Core/Tv/SeriesRepository.cs deleted file mode 100644 index d5bc343ff..000000000 --- a/src/NzbDrone.Core/Tv/SeriesRepository.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System.Linq; -using NzbDrone.Core.Datastore; -using NzbDrone.Core.Messaging.Events; - - -namespace NzbDrone.Core.Tv -{ - public interface ISeriesRepository : IBasicRepository<Series> - { - bool SeriesPathExists(string path); - Series FindByTitle(string cleanTitle); - Series FindByTitle(string cleanTitle, int year); - Series FindByTvdbId(int tvdbId); - Series FindByTvRageId(int tvRageId); - } - - public class SeriesRepository : BasicRepository<Series>, ISeriesRepository - { - public SeriesRepository(IMainDatabase database, IEventAggregator eventAggregator) - : base(database, eventAggregator) - { - } - - public bool SeriesPathExists(string path) - { - return Query.Where(c => c.Path == path).Any(); - } - - public Series FindByTitle(string cleanTitle) - { - cleanTitle = cleanTitle.ToLowerInvariant(); - - return Query.Where(s => s.CleanTitle == cleanTitle) - .SingleOrDefault(); - } - - public Series FindByTitle(string cleanTitle, int year) - { - cleanTitle = cleanTitle.ToLowerInvariant(); - - return Query.Where(s => s.CleanTitle == cleanTitle) - .AndWhere(s => s.Year == year) - .SingleOrDefault(); - } - - public Series FindByTvdbId(int tvdbId) - { - return Query.Where(s => s.TvdbId == tvdbId).SingleOrDefault(); - } - - public Series FindByTvRageId(int tvRageId) - { - return Query.Where(s => s.TvRageId == tvRageId).SingleOrDefault(); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Tv/SeriesScannedHandler.cs b/src/NzbDrone.Core/Tv/SeriesScannedHandler.cs deleted file mode 100644 index 9d208c764..000000000 --- a/src/NzbDrone.Core/Tv/SeriesScannedHandler.cs +++ /dev/null @@ -1,62 +0,0 @@ -using NLog; -using NzbDrone.Core.IndexerSearch; -using NzbDrone.Core.MediaFiles.Events; -using NzbDrone.Core.Messaging.Commands; -using NzbDrone.Core.Messaging.Events; - -namespace NzbDrone.Core.Tv -{ - public class SeriesScannedHandler : IHandle<SeriesScannedEvent>, - IHandle<SeriesScanSkippedEvent> - { - private readonly IEpisodeMonitoredService _episodeMonitoredService; - private readonly ISeriesService _seriesService; - private readonly IManageCommandQueue _commandQueueManager; - private readonly IEpisodeAddedService _episodeAddedService; - - private readonly Logger _logger; - - public SeriesScannedHandler(IEpisodeMonitoredService episodeMonitoredService, - ISeriesService seriesService, - IManageCommandQueue commandQueueManager, - IEpisodeAddedService episodeAddedService, - Logger logger) - { - _episodeMonitoredService = episodeMonitoredService; - _seriesService = seriesService; - _commandQueueManager = commandQueueManager; - _episodeAddedService = episodeAddedService; - _logger = logger; - } - - private void HandleScanEvents(Series series) - { - if (series.AddOptions == null) - { - _episodeAddedService.SearchForRecentlyAdded(series.Id); - return; - } - - _logger.Info("[{0}] was recently added, performing post-add actions", series.Title); - _episodeMonitoredService.SetEpisodeMonitoredStatus(series, series.AddOptions); - - if (series.AddOptions.SearchForMissingEpisodes) - { - _commandQueueManager.Push(new MissingEpisodeSearchCommand(series.Id)); - } - - series.AddOptions = null; - _seriesService.RemoveAddOptions(series); - } - - public void Handle(SeriesScannedEvent message) - { - HandleScanEvents(message.Series); - } - - public void Handle(SeriesScanSkippedEvent message) - { - HandleScanEvents(message.Series); - } - } -} diff --git a/src/NzbDrone.Core/Tv/SeriesService.cs b/src/NzbDrone.Core/Tv/SeriesService.cs deleted file mode 100644 index 941284407..000000000 --- a/src/NzbDrone.Core/Tv/SeriesService.cs +++ /dev/null @@ -1,226 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using NLog; -using NzbDrone.Common.EnsureThat; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.DataAugmentation.Scene; -using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Organizer; -using NzbDrone.Core.Parser; -using NzbDrone.Core.Tv.Events; - -namespace NzbDrone.Core.Tv -{ - public interface ISeriesService - { - Series GetSeries(int seriesId); - List<Series> GetSeries(IEnumerable<int> seriesIds); - Series AddSeries(Series newSeries); - Series FindByTvdbId(int tvdbId); - Series FindByTvRageId(int tvRageId); - Series FindByTitle(string title); - Series FindByTitle(string title, int year); - Series FindByTitleInexact(string title); - void DeleteSeries(int seriesId, bool deleteFiles); - List<Series> GetAllSeries(); - Series UpdateSeries(Series series); - List<Series> UpdateSeries(List<Series> series); - bool SeriesPathExists(string folder); - void RemoveAddOptions(Series series); - } - - public class SeriesService : ISeriesService - { - private readonly ISeriesRepository _seriesRepository; - private readonly IEventAggregator _eventAggregator; - private readonly ISceneMappingService _sceneMappingService; - private readonly IEpisodeService _episodeService; - private readonly IBuildFileNames _fileNameBuilder; - private readonly Logger _logger; - - public SeriesService(ISeriesRepository seriesRepository, - IEventAggregator eventAggregator, - ISceneMappingService sceneMappingService, - IEpisodeService episodeService, - IBuildFileNames fileNameBuilder, - Logger logger) - { - _seriesRepository = seriesRepository; - _eventAggregator = eventAggregator; - _sceneMappingService = sceneMappingService; - _episodeService = episodeService; - _fileNameBuilder = fileNameBuilder; - _logger = logger; - } - - public Series GetSeries(int seriesId) - { - return _seriesRepository.Get(seriesId); - } - - public List<Series> GetSeries(IEnumerable<int> seriesIds) - { - return _seriesRepository.Get(seriesIds).ToList(); - } - - public Series AddSeries(Series newSeries) - { - Ensure.That(newSeries, () => newSeries).IsNotNull(); - - if (string.IsNullOrWhiteSpace(newSeries.Path)) - { - var folderName = _fileNameBuilder.GetSeriesFolder(newSeries); - newSeries.Path = Path.Combine(newSeries.RootFolderPath, folderName); - } - - _logger.Info("Adding Series {0} Path: [{1}]", newSeries, newSeries.Path); - - newSeries.CleanTitle = newSeries.Title.CleanSeriesTitle(); - newSeries.SortTitle = SeriesTitleNormalizer.Normalize(newSeries.Title, newSeries.TvdbId); - newSeries.Added = DateTime.UtcNow; - - _seriesRepository.Insert(newSeries); - _eventAggregator.PublishEvent(new SeriesAddedEvent(GetSeries(newSeries.Id))); - - return newSeries; - } - - public Series FindByTvdbId(int tvRageId) - { - return _seriesRepository.FindByTvdbId(tvRageId); - } - - public Series FindByTvRageId(int tvRageId) - { - return _seriesRepository.FindByTvRageId(tvRageId); - } - - public Series FindByTitle(string title) - { - var tvdbId = _sceneMappingService.FindTvdbId(title); - - if (tvdbId.HasValue) - { - return _seriesRepository.FindByTvdbId(tvdbId.Value); - } - - return _seriesRepository.FindByTitle(title.CleanSeriesTitle()); - } - - public Series FindByTitleInexact(string title) - { - // find any series clean title within the provided release title - string cleanTitle = title.CleanSeriesTitle(); - var list = _seriesRepository.All().Where(s => cleanTitle.Contains(s.CleanTitle)).ToList(); - if (!list.Any()) - { - // no series matched - return null; - } - if (list.Count == 1) - { - // return the first series if there is only one - return list.Single(); - } - // build ordered list of series by position in the search string - var query = - list.Select(series => new - { - position = cleanTitle.IndexOf(series.CleanTitle), - length = series.CleanTitle.Length, - series = series - }) - .Where(s => (s.position>=0)) - .ToList() - .OrderBy(s => s.position) - .ThenByDescending(s => s.length) - .ToList(); - - // get the leftmost series that is the longest - // series are usually the first thing in release title, so we select the leftmost and longest match - var match = query.First().series; - - _logger.Debug("Multiple series matched {0} from title {1}", match.Title, title); - foreach (var entry in list) - { - _logger.Debug("Multiple series match candidate: {0} cleantitle: {1}", entry.Title, entry.CleanTitle); - } - - return match; - } - - public Series FindByTitle(string title, int year) - { - return _seriesRepository.FindByTitle(title.CleanSeriesTitle(), year); - } - - public void DeleteSeries(int seriesId, bool deleteFiles) - { - var series = _seriesRepository.Get(seriesId); - _seriesRepository.Delete(seriesId); - _eventAggregator.PublishEvent(new SeriesDeletedEvent(series, deleteFiles)); - } - - public List<Series> GetAllSeries() - { - return _seriesRepository.All().ToList(); - } - - public Series UpdateSeries(Series series) - { - var storedSeries = GetSeries(series.Id); - - foreach (var season in series.Seasons) - { - var storedSeason = storedSeries.Seasons.SingleOrDefault(s => s.SeasonNumber == season.SeasonNumber); - - if (storedSeason != null && season.Monitored != storedSeason.Monitored) - { - _episodeService.SetEpisodeMonitoredBySeason(series.Id, season.SeasonNumber, season.Monitored); - } - } - - var updatedSeries = _seriesRepository.Update(series); - _eventAggregator.PublishEvent(new SeriesEditedEvent(updatedSeries, storedSeries)); - - return updatedSeries; - } - - public List<Series> UpdateSeries(List<Series> series) - { - _logger.Debug("Updating {0} series", series.Count); - foreach (var s in series) - { - _logger.Trace("Updating: {0}", s.Title); - if (!s.RootFolderPath.IsNullOrWhiteSpace()) - { - var folderName = new DirectoryInfo(s.Path).Name; - s.Path = Path.Combine(s.RootFolderPath, folderName); - _logger.Trace("Changing path for {0} to {1}", s.Title, s.Path); - } - - else - { - _logger.Trace("Not changing path for: {0}", s.Title); - } - } - - _seriesRepository.UpdateMany(series); - _logger.Debug("{0} series updated", series.Count); - - return series; - } - - public bool SeriesPathExists(string folder) - { - return _seriesRepository.SeriesPathExists(folder); - } - - public void RemoveAddOptions(Series series) - { - _seriesRepository.SetFields(series, s => s.AddOptions); - } - } -} diff --git a/src/NzbDrone.Core/Tv/SeriesStatusType.cs b/src/NzbDrone.Core/Tv/SeriesStatusType.cs deleted file mode 100644 index acc9fbf81..000000000 --- a/src/NzbDrone.Core/Tv/SeriesStatusType.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace NzbDrone.Core.Tv -{ - public enum SeriesStatusType - { - Continuing = 0, - Ended = 1 - } -} diff --git a/src/NzbDrone.Core/Tv/SeriesTitleNormalizer.cs b/src/NzbDrone.Core/Tv/SeriesTitleNormalizer.cs deleted file mode 100644 index 9fc2c5933..000000000 --- a/src/NzbDrone.Core/Tv/SeriesTitleNormalizer.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections.Generic; - -namespace NzbDrone.Core.Tv -{ - public static class SeriesTitleNormalizer - { - private readonly static Dictionary<int, string> PreComputedTitles = new Dictionary<int, string> - { - { 281588, "a to z" }, - { 266757, "ad trials triumph early church" }, - { 289260, "ad bible continues"} - }; - - public static string Normalize(string title, int tvdbId) - { - if (PreComputedTitles.ContainsKey(tvdbId)) - { - return PreComputedTitles[tvdbId]; - } - - return Parser.Parser.NormalizeTitle(title).ToLower(); - } - } -} diff --git a/src/NzbDrone.Core/Tv/SeriesTypes.cs b/src/NzbDrone.Core/Tv/SeriesTypes.cs deleted file mode 100644 index 176ff7655..000000000 --- a/src/NzbDrone.Core/Tv/SeriesTypes.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace NzbDrone.Core.Tv -{ - public enum SeriesTypes - { - Standard = 0, - Daily = 1, - Anime = 2, - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Tv/ShouldRefreshSeries.cs b/src/NzbDrone.Core/Tv/ShouldRefreshSeries.cs deleted file mode 100644 index bbf48cbb8..000000000 --- a/src/NzbDrone.Core/Tv/ShouldRefreshSeries.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Linq; -using NLog; - -namespace NzbDrone.Core.Tv -{ - public interface ICheckIfSeriesShouldBeRefreshed - { - bool ShouldRefresh(Series series); - } - - public class ShouldRefreshSeries : ICheckIfSeriesShouldBeRefreshed - { - private readonly IEpisodeService _episodeService; - private readonly Logger _logger; - - public ShouldRefreshSeries(IEpisodeService episodeService, Logger logger) - { - _episodeService = episodeService; - _logger = logger; - } - - public bool ShouldRefresh(Series series) - { - if (series.LastInfoSync < DateTime.UtcNow.AddDays(-30)) - { - _logger.Trace("Series {0} last updated more than 30 days ago, should refresh.", series.Title); - return true; - } - - if (series.LastInfoSync >= DateTime.UtcNow.AddHours(-6)) - { - _logger.Trace("Series {0} last updated less than 6 hours ago, should not be refreshed.", series.Title); - return false; - } - - if (series.Status == SeriesStatusType.Continuing) - { - _logger.Trace("Series {0} is continuing, should refresh.", series.Title); - return true; - } - - var lastEpisode = _episodeService.GetEpisodeBySeries(series.Id).OrderByDescending(e => e.AirDateUtc).FirstOrDefault(); - - if (lastEpisode != null && lastEpisode.AirDateUtc > DateTime.UtcNow.AddDays(-30)) - { - _logger.Trace("Last episode in {0} aired less than 30 days ago, should refresh.", series.Title); - return true; - } - - _logger.Trace("Series {0} ended long ago, should not be refreshed.", series.Title); - return false; - } - } -} diff --git a/src/NzbDrone.Core/Validation/Paths/MovieAncestorValidator.cs b/src/NzbDrone.Core/Validation/Paths/MovieAncestorValidator.cs index d694d00b4..e72af6221 100644 --- a/src/NzbDrone.Core/Validation/Paths/MovieAncestorValidator.cs +++ b/src/NzbDrone.Core/Validation/Paths/MovieAncestorValidator.cs @@ -1,25 +1,25 @@ -using System.Linq; +using System.Linq; using FluentValidation.Validators; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Validation.Paths { public class MovieAncestorValidator : PropertyValidator { - private readonly IMovieService _seriesService; + private readonly IMovieService _movieService; - public MovieAncestorValidator(IMovieService seriesService) + public MovieAncestorValidator(IMovieService movieService) : base("Path is an ancestor of an existing path") { - _seriesService = seriesService; + _movieService = movieService; } protected override bool IsValid(PropertyValidatorContext context) { if (context.PropertyValue == null) return true; - return !_seriesService.GetAllMovies().Any(s => context.PropertyValue.ToString().IsParentPath(s.Path)); + return !_movieService.GetAllMovies().Any(s => context.PropertyValue.ToString().IsParentPath(s.Path)); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/Validation/Paths/MovieExistsValidator.cs b/src/NzbDrone.Core/Validation/Paths/MovieExistsValidator.cs index 0eda71416..ff5c4786a 100644 --- a/src/NzbDrone.Core/Validation/Paths/MovieExistsValidator.cs +++ b/src/NzbDrone.Core/Validation/Paths/MovieExistsValidator.cs @@ -1,17 +1,17 @@ -using System; +using System; using FluentValidation.Validators; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Validation.Paths { public class MovieExistsValidator : PropertyValidator { - private readonly IMovieService _seriesService; + private readonly IMovieService _movieService; - public MovieExistsValidator(IMovieService seriesService) + public MovieExistsValidator(IMovieService movieService) : base("This movie has already been added") { - _seriesService = seriesService; + _movieService = movieService; } protected override bool IsValid(PropertyValidatorContext context) @@ -20,7 +20,7 @@ namespace NzbDrone.Core.Validation.Paths int tmdbId = (int)context.PropertyValue; - return (!_seriesService.GetAllMovies().Exists(s => s.TmdbId == tmdbId)); + return (!_movieService.GetAllMovies().Exists(s => s.TmdbId == tmdbId)); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/Validation/Paths/MoviePathValidation.cs b/src/NzbDrone.Core/Validation/Paths/MoviePathValidation.cs index cbd36af7a..41690b7cb 100644 --- a/src/NzbDrone.Core/Validation/Paths/MoviePathValidation.cs +++ b/src/NzbDrone.Core/Validation/Paths/MoviePathValidation.cs @@ -1,6 +1,6 @@ using FluentValidation.Validators; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Validation.Paths { diff --git a/src/NzbDrone.Core/Validation/Paths/SeriesAncestorValidator.cs b/src/NzbDrone.Core/Validation/Paths/SeriesAncestorValidator.cs deleted file mode 100644 index c91560873..000000000 --- a/src/NzbDrone.Core/Validation/Paths/SeriesAncestorValidator.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Linq; -using FluentValidation.Validators; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Validation.Paths -{ - public class SeriesAncestorValidator : PropertyValidator - { - private readonly ISeriesService _seriesService; - - public SeriesAncestorValidator(ISeriesService seriesService) - : base("Path is an ancestor of an existing path") - { - _seriesService = seriesService; - } - - protected override bool IsValid(PropertyValidatorContext context) - { - if (context.PropertyValue == null) return true; - - return !_seriesService.GetAllSeries().Any(s => context.PropertyValue.ToString().IsParentPath(s.Path)); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Validation/Paths/SeriesExistsValidator.cs b/src/NzbDrone.Core/Validation/Paths/SeriesExistsValidator.cs deleted file mode 100644 index 21e4ea629..000000000 --- a/src/NzbDrone.Core/Validation/Paths/SeriesExistsValidator.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using FluentValidation.Validators; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Validation.Paths -{ - public class SeriesExistsValidator : PropertyValidator - { - private readonly ISeriesService _seriesService; - - public SeriesExistsValidator(ISeriesService seriesService) - : base("This series has already been added") - { - _seriesService = seriesService; - } - - protected override bool IsValid(PropertyValidatorContext context) - { - if (context.PropertyValue == null) return true; - - var tvdbId = Convert.ToInt32(context.PropertyValue.ToString()); - - return (!_seriesService.GetAllSeries().Exists(s => s.TvdbId == tvdbId)); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Validation/Paths/SeriesPathValidator.cs b/src/NzbDrone.Core/Validation/Paths/SeriesPathValidator.cs deleted file mode 100644 index fa4d8fa59..000000000 --- a/src/NzbDrone.Core/Validation/Paths/SeriesPathValidator.cs +++ /dev/null @@ -1,27 +0,0 @@ -using FluentValidation.Validators; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Validation.Paths -{ - public class SeriesPathValidator : PropertyValidator - { - private readonly ISeriesService _seriesService; - - public SeriesPathValidator(ISeriesService seriesService) - : base("Path is already configured for another series") - { - _seriesService = seriesService; - } - - protected override bool IsValid(PropertyValidatorContext context) - { - if (context.PropertyValue == null) return true; - - dynamic instance = context.ParentContext.InstanceToValidate; - var instanceId = (int)instance.Id; - - return (!_seriesService.GetAllSeries().Exists(s => s.Path.PathEquals(context.PropertyValue.ToString()) && s.Id != instanceId)); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Integration.Test/ApiTests/MovieFixture.cs b/src/NzbDrone.Integration.Test/ApiTests/MovieFixture.cs index 045078b8a..6054f6c5c 100644 --- a/src/NzbDrone.Integration.Test/ApiTests/MovieFixture.cs +++ b/src/NzbDrone.Integration.Test/ApiTests/MovieFixture.cs @@ -3,7 +3,7 @@ using NUnit.Framework; using System.Linq; using System.IO; using System.Collections.Generic; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Movies; namespace NzbDrone.Integration.Test.ApiTests { diff --git a/src/NzbDrone.Integration.Test/IntegrationTestBase.cs b/src/NzbDrone.Integration.Test/IntegrationTestBase.cs index 01017a0c1..e88cefc6b 100644 --- a/src/NzbDrone.Integration.Test/IntegrationTestBase.cs +++ b/src/NzbDrone.Integration.Test/IntegrationTestBase.cs @@ -24,7 +24,7 @@ using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Serializer; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv.Commands; +using NzbDrone.Core.Movies.Commands; using NzbDrone.Integration.Test.Client; using NzbDrone.SignalR; using NzbDrone.Test.Common.Categories; @@ -211,7 +211,7 @@ namespace NzbDrone.Integration.Test movie.ProfileId = 1; movie.Path = Path.Combine(MovieRootFolder, movie.Title); movie.Monitored = true; - movie.AddOptions = new Core.Tv.AddMovieOptions(); + movie.AddOptions = new Core.Movies.AddMovieOptions(); Directory.CreateDirectory(movie.Path); result = Movies.Post(movie);