Fixed: author manual import (#32)

* Fix: apply fix from Lidarr to the Readarr manual import modal

* Rename Album to Book in the identification override

* Rename "audio" to "book" in the interactive import modal empty message
pull/37/head
Thomas Mathews 4 years ago committed by GitHub
parent 3f8733830a
commit d83d2548e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -676,6 +676,7 @@ class AuthorDetails extends Component {
<InteractiveImportModal <InteractiveImportModal
isOpen={isInteractiveImportModalOpen} isOpen={isInteractiveImportModalOpen}
authorId={id}
folder={path} folder={path}
allowAuthorChange={false} allowAuthorChange={false}
showFilterExistingFiles={true} showFilterExistingFiles={true}

@ -408,7 +408,7 @@ class InteractiveImportModalContent extends Component {
{ {
isPopulated && !items.length && !isFetching && isPopulated && !items.length && !isFetching &&
'No audio files were found in the selected folder' 'No book files were found in the selected folder'
} }
</ModalBody> </ModalBody>

@ -52,6 +52,7 @@ class InteractiveImportModalContentConnector extends Component {
componentDidMount() { componentDidMount() {
const { const {
authorId,
downloadId, downloadId,
folder folder
} = this.props; } = this.props;
@ -62,6 +63,7 @@ class InteractiveImportModalContentConnector extends Component {
} = this.state; } = this.state;
this.props.fetchInteractiveImportItems({ this.props.fetchInteractiveImportItems({
authorId,
downloadId, downloadId,
folder, folder,
filterExistingFiles, filterExistingFiles,
@ -78,11 +80,13 @@ class InteractiveImportModalContentConnector extends Component {
if (prevState.filterExistingFiles !== filterExistingFiles || if (prevState.filterExistingFiles !== filterExistingFiles ||
prevState.replaceExistingFiles !== replaceExistingFiles) { prevState.replaceExistingFiles !== replaceExistingFiles) {
const { const {
authorId,
downloadId, downloadId,
folder folder
} = this.props; } = this.props;
this.props.fetchInteractiveImportItems({ this.props.fetchInteractiveImportItems({
authorId,
downloadId, downloadId,
folder, folder,
filterExistingFiles, filterExistingFiles,
@ -195,6 +199,7 @@ class InteractiveImportModalContentConnector extends Component {
} }
InteractiveImportModalContentConnector.propTypes = { InteractiveImportModalContentConnector.propTypes = {
authorId: PropTypes.number,
downloadId: PropTypes.string, downloadId: PropTypes.string,
folder: PropTypes.string, folder: PropTypes.string,
filterExistingFiles: PropTypes.bool.isRequired, filterExistingFiles: PropTypes.bool.isRequired,
@ -210,6 +215,7 @@ InteractiveImportModalContentConnector.propTypes = {
}; };
InteractiveImportModalContentConnector.defaultProps = { InteractiveImportModalContentConnector.defaultProps = {
authorId: 0,
filterExistingFiles: true, filterExistingFiles: true,
replaceExistingFiles: false replaceExistingFiles: false
}; };

@ -60,16 +60,16 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Identification
// tagCandidate = GetDbCandidatesByRelease(new List<AlbumRelease> { tagMbidRelease }, includeExisting); // tagCandidate = GetDbCandidatesByRelease(new List<AlbumRelease> { tagMbidRelease }, includeExisting);
// } // }
// } // }
if (idOverrides?.Album != null) if (idOverrides?.Book != null)
{ {
// use the release from file tags if it exists and agrees with the specified book // use the release from file tags if it exists and agrees with the specified book
if (tagMbidRelease?.Id == idOverrides.Album.Id) if (tagMbidRelease?.Id == idOverrides.Book.Id)
{ {
candidateReleases = tagCandidate; candidateReleases = tagCandidate;
} }
else else
{ {
candidateReleases = GetDbCandidatesByAlbum(idOverrides.Album, includeExisting); candidateReleases = GetDbCandidatesByAlbum(idOverrides.Book, includeExisting);
} }
} }
else if (idOverrides?.Author != null) else if (idOverrides?.Author != null)

@ -125,6 +125,14 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Identification
if (candidateReleases.Count == 0) if (candidateReleases.Count == 0)
{ {
// can't find any candidates even after fingerprinting
// populate the overrides and return
foreach (var localTrack in localAlbumRelease.LocalBooks)
{
localTrack.Book = idOverrides.Book;
localTrack.Author = idOverrides.Author;
}
return; return;
} }

@ -24,7 +24,7 @@ namespace NzbDrone.Core.MediaFiles.BookImport
public class IdentificationOverrides public class IdentificationOverrides
{ {
public Author Author { get; set; } public Author Author { get; set; }
public Book Album { get; set; } public Book Book { get; set; }
} }
public class ImportDecisionMakerInfo public class ImportDecisionMakerInfo

@ -23,7 +23,7 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Manual
{ {
public interface IManualImportService public interface IManualImportService
{ {
List<ManualImportItem> GetMediaFiles(string path, string downloadId, FilterFilesType filter, bool replaceExistingFiles); List<ManualImportItem> GetMediaFiles(string path, string downloadId, Author author, FilterFilesType filter, bool replaceExistingFiles);
List<ManualImportItem> UpdateItems(List<ManualImportItem> item); List<ManualImportItem> UpdateItems(List<ManualImportItem> item);
} }
@ -72,7 +72,7 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Manual
_logger = logger; _logger = logger;
} }
public List<ManualImportItem> GetMediaFiles(string path, string downloadId, FilterFilesType filter, bool replaceExistingFiles) public List<ManualImportItem> GetMediaFiles(string path, string downloadId, Author author, FilterFilesType filter, bool replaceExistingFiles)
{ {
if (downloadId.IsNotNullOrWhiteSpace()) if (downloadId.IsNotNullOrWhiteSpace())
{ {
@ -110,14 +110,14 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Manual
return new List<ManualImportItem> { result }; return new List<ManualImportItem> { result };
} }
return ProcessFolder(path, downloadId, filter, replaceExistingFiles); return ProcessFolder(path, downloadId, author, filter, replaceExistingFiles);
} }
private List<ManualImportItem> ProcessFolder(string folder, string downloadId, FilterFilesType filter, bool replaceExistingFiles) private List<ManualImportItem> ProcessFolder(string folder, string downloadId, Author author, FilterFilesType filter, bool replaceExistingFiles)
{ {
DownloadClientItem downloadClientItem = null; DownloadClientItem downloadClientItem = null;
var directoryInfo = new DirectoryInfo(folder); var directoryInfo = new DirectoryInfo(folder);
var author = _parsingService.GetArtist(directoryInfo.Name); author = author ?? _parsingService.GetArtist(directoryInfo.Name);
if (downloadId.IsNotNullOrWhiteSpace()) if (downloadId.IsNotNullOrWhiteSpace())
{ {
@ -181,7 +181,7 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Manual
var idOverride = new IdentificationOverrides var idOverride = new IdentificationOverrides
{ {
Author = group.First().Author, Author = group.First().Author,
Album = group.First().Book, Book = group.First().Book,
}; };
var config = new ImportDecisionMakerConfig var config = new ImportDecisionMakerConfig
{ {

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Nancy; using Nancy;
@ -41,10 +42,23 @@ namespace Readarr.Api.V1.ManualImport
{ {
var folder = (string)Request.Query.folder; var folder = (string)Request.Query.folder;
var downloadId = (string)Request.Query.downloadId; var downloadId = (string)Request.Query.downloadId;
NzbDrone.Core.Books.Author author = null;
var authorIdQuery = Request.Query.authorId;
if (authorIdQuery.HasValue)
{
var authorId = Convert.ToInt32(authorIdQuery.Value);
if (authorId > 0)
{
author = _authorService.GetAuthor(authorId);
}
}
var filter = Request.GetBooleanQueryParameter("filterExistingFiles", true) ? FilterFilesType.Matched : FilterFilesType.None; var filter = Request.GetBooleanQueryParameter("filterExistingFiles", true) ? FilterFilesType.Matched : FilterFilesType.None;
var replaceExistingFiles = Request.GetBooleanQueryParameter("replaceExistingFiles", true); var replaceExistingFiles = Request.GetBooleanQueryParameter("replaceExistingFiles", true);
return _manualImportService.GetMediaFiles(folder, downloadId, filter, replaceExistingFiles).ToResource().Select(AddQualityWeight).ToList(); return _manualImportService.GetMediaFiles(folder, downloadId, author, filter, replaceExistingFiles).ToResource().Select(AddQualityWeight).ToList();
} }
private ManualImportResource AddQualityWeight(ManualImportResource item) private ManualImportResource AddQualityWeight(ManualImportResource item)

Loading…
Cancel
Save