diff --git a/frontend/src/InteractiveImport/Interactive/InteractiveImportModalContentConnector.js b/frontend/src/InteractiveImport/Interactive/InteractiveImportModalContentConnector.js index cfdaa3998..719b17d03 100644 --- a/frontend/src/InteractiveImport/Interactive/InteractiveImportModalContentConnector.js +++ b/frontend/src/InteractiveImport/Interactive/InteractiveImportModalContentConnector.js @@ -43,6 +43,7 @@ class InteractiveImportModalContentConnector extends Component { componentDidMount() { const { downloadId, + seriesId, folder } = this.props; @@ -52,6 +53,7 @@ class InteractiveImportModalContentConnector extends Component { this.props.dispatchFetchInteractiveImportItems({ downloadId, + seriesId, folder, filterExistingFiles }); @@ -65,11 +67,13 @@ class InteractiveImportModalContentConnector extends Component { if (prevState.filterExistingFiles !== filterExistingFiles) { const { downloadId, + seriesId, folder } = this.props; this.props.dispatchFetchInteractiveImportItems({ downloadId, + seriesId, folder, filterExistingFiles }); @@ -185,6 +189,7 @@ class InteractiveImportModalContentConnector extends Component { InteractiveImportModalContentConnector.propTypes = { downloadId: PropTypes.string, + seriesId: PropTypes.number, folder: PropTypes.string, filterExistingFiles: PropTypes.bool.isRequired, items: PropTypes.arrayOf(PropTypes.object).isRequired, diff --git a/frontend/src/Series/Details/SeriesDetails.js b/frontend/src/Series/Details/SeriesDetails.js index 0fdd9d1bc..573725bc1 100644 --- a/frontend/src/Series/Details/SeriesDetails.js +++ b/frontend/src/Series/Details/SeriesDetails.js @@ -23,6 +23,7 @@ import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; import Popover from 'Components/Tooltip/Popover'; import Tooltip from 'Components/Tooltip/Tooltip'; import EpisodeFileEditorModal from 'EpisodeFile/Editor/EpisodeFileEditorModal'; +import InteractiveImportModal from 'InteractiveImport/InteractiveImportModal'; import OrganizePreviewModalConnector from 'Organize/OrganizePreviewModalConnector'; import QualityProfileNameConnector from 'Settings/Profiles/Quality/QualityProfileNameConnector'; import SeriesPoster from 'Series/SeriesPoster'; @@ -34,7 +35,6 @@ import SeriesDetailsSeasonConnector from './SeriesDetailsSeasonConnector'; import SeriesTagsConnector from './SeriesTagsConnector'; import SeriesDetailsLinks from './SeriesDetailsLinks'; import styles from './SeriesDetails.css'; -import InteractiveImportModal from '../../InteractiveImport/InteractiveImportModal'; const defaultFontSize = parseInt(fonts.defaultFontSize); const lineHeight = parseFloat(fonts.lineHeight); @@ -638,6 +638,7 @@ class SeriesDetails extends Component { GetMediaFiles(string path, string downloadId, bool filterExistingFiles); + List GetMediaFiles(string path, string downloadId, int? seriesId, bool filterExistingFiles); ManualImportItem ReprocessItem(string path, string downloadId, int seriesId); } @@ -66,7 +66,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual _logger = logger; } - public List GetMediaFiles(string path, string downloadId, bool filterExistingFiles) + public List GetMediaFiles(string path, string downloadId, int? seriesId, bool filterExistingFiles) { if (downloadId.IsNotNullOrWhiteSpace()) { @@ -91,7 +91,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual return new List { ProcessFile(rootFolder, rootFolder, path, downloadId) }; } - return ProcessFolder(path, path, downloadId, filterExistingFiles); + return ProcessFolder(path, path, downloadId, seriesId, filterExistingFiles); } public ManualImportItem ReprocessItem(string path, string downloadId, int seriesId) @@ -102,11 +102,14 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual return ProcessFile(rootFolder, rootFolder, path, downloadId, series); } - private List ProcessFolder(string rootFolder, string baseFolder, string downloadId, bool filterExistingFiles) + private List ProcessFolder(string rootFolder, string baseFolder, string downloadId, int? seriesId, bool filterExistingFiles) { DownloadClientItem downloadClientItem = null; var directoryInfo = new DirectoryInfo(baseFolder); - var series = _parsingService.GetSeries(directoryInfo.Name); + + var series = seriesId.HasValue ? + _seriesService.GetSeries(seriesId.Value) : + _parsingService.GetSeries(directoryInfo.Name); if (downloadId.IsNotNullOrWhiteSpace()) { @@ -119,20 +122,13 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual } } - // Try a lookup by the path if the series is still unknown, this will handle - // the case where the series folder doesn't match the series title. - if (series == null) - { - series = _seriesService.FindByPath(rootFolder); - } - if (series == null) { var files = _diskScanService.FilterFiles(baseFolder, _diskScanService.GetVideoFiles(baseFolder, false)); var subfolders = _diskScanService.FilterFiles(baseFolder, _diskProvider.GetDirectories(baseFolder)); var processedFiles = files.Select(file => ProcessFile(rootFolder, baseFolder, file, downloadId)); - var processedFolders = subfolders.SelectMany(subfolder => ProcessFolder(rootFolder, subfolder, downloadId, filterExistingFiles)); + var processedFolders = subfolders.SelectMany(subfolder => ProcessFolder(rootFolder, subfolder, downloadId, null, filterExistingFiles)); return processedFiles.Concat(processedFolders).Where(i => i != null).ToList(); } diff --git a/src/Sonarr.Api.V3/ManualImport/ManualImportModule.cs b/src/Sonarr.Api.V3/ManualImport/ManualImportModule.cs index 7203365b1..be29b3e37 100644 --- a/src/Sonarr.Api.V3/ManualImport/ManualImportModule.cs +++ b/src/Sonarr.Api.V3/ManualImport/ManualImportModule.cs @@ -27,8 +27,9 @@ namespace Sonarr.Api.V3.ManualImport var folder = (string)Request.Query.folder; var downloadId = (string)Request.Query.downloadId; var filterExistingFiles = Request.GetBooleanQueryParameter("filterExistingFiles", true); + var seriesId = Request.GetNullableIntegerQueryParameter("seriesId", null); - return _manualImportService.GetMediaFiles(folder, downloadId, filterExistingFiles).ToResource().Select(AddQualityWeight).ToList(); + return _manualImportService.GetMediaFiles(folder, downloadId, seriesId, filterExistingFiles).ToResource().Select(AddQualityWeight).ToList(); } private Response ReprocessItems() diff --git a/src/Sonarr.Http/Extensions/RequestExtensions.cs b/src/Sonarr.Http/Extensions/RequestExtensions.cs index dbb518384..77ef4a15e 100644 --- a/src/Sonarr.Http/Extensions/RequestExtensions.cs +++ b/src/Sonarr.Http/Extensions/RequestExtensions.cs @@ -66,5 +66,17 @@ namespace Sonarr.Http.Extensions return defaultValue; } + + public static int? GetNullableIntegerQueryParameter(this Request request, string parameter, int? defaultValue = null) + { + var parameterValue = request.Query[parameter]; + + if (parameterValue.HasValue) + { + return int.Parse(parameterValue.Value); + } + + return defaultValue; + } } }