mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-27 22:56:45 -04:00
Cleanup Conflicts in Sonarr/Lidarr Pulls
Co-Authored-By: Robin Dadswell <19610103+RobinDadswell@users.noreply.github.com>
This commit is contained in:
@@ -56,15 +56,15 @@ namespace NzbDrone.Core.Extras.Metadata
|
||||
|
||||
if (metadata.Type == MetadataType.BookImage || metadata.Type == MetadataType.BookMetadata)
|
||||
{
|
||||
var localAlbum = _parsingService.GetLocalAlbum(possibleMetadataFile, author);
|
||||
var localBook = _parsingService.GetLocalBook(possibleMetadataFile, author);
|
||||
|
||||
if (localAlbum == null)
|
||||
if (localBook == null)
|
||||
{
|
||||
_logger.Debug("Extra file folder has multiple Books: {0}", possibleMetadataFile);
|
||||
continue;
|
||||
}
|
||||
|
||||
metadata.BookId = localAlbum.Id;
|
||||
metadata.BookId = localBook.Id;
|
||||
}
|
||||
|
||||
if (metadata.Type == MetadataType.BookMetadata)
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace NzbDrone.Core.Extras.Metadata
|
||||
public interface IMetadata : IProvider
|
||||
{
|
||||
string GetFilenameAfterMove(Author author, BookFile bookFile, MetadataFile metadataFile);
|
||||
string GetFilenameAfterMove(Author author, string albumPath, MetadataFile metadataFile);
|
||||
string GetFilenameAfterMove(Author author, string bookPath, MetadataFile metadataFile);
|
||||
MetadataFile FindMetadataFile(Author author, string path);
|
||||
MetadataFileResult AuthorMetadata(Author author);
|
||||
MetadataFileResult BookMetadata(Author author, BookFile bookFile);
|
||||
|
||||
@@ -36,10 +36,10 @@ namespace NzbDrone.Core.Extras.Metadata
|
||||
return newFileName;
|
||||
}
|
||||
|
||||
public virtual string GetFilenameAfterMove(Author author, string albumPath, MetadataFile metadataFile)
|
||||
public virtual string GetFilenameAfterMove(Author author, string bookPath, MetadataFile metadataFile)
|
||||
{
|
||||
var existingFilename = Path.GetFileName(metadataFile.RelativePath);
|
||||
var newFileName = Path.Combine(author.Path, albumPath, existingFilename);
|
||||
var newFileName = Path.Combine(author.Path, bookPath, existingFilename);
|
||||
|
||||
return newFileName;
|
||||
}
|
||||
|
||||
@@ -104,11 +104,11 @@ namespace NzbDrone.Core.Extras.Metadata
|
||||
return files;
|
||||
}
|
||||
|
||||
public override IEnumerable<ExtraFile> CreateAfterBookImport(Author author, Book book, string authorFolder, string albumFolder)
|
||||
public override IEnumerable<ExtraFile> CreateAfterBookImport(Author author, Book book, string authorFolder, string bookFolder)
|
||||
{
|
||||
var metadataFiles = _metadataFileService.GetFilesByAuthor(author.Id);
|
||||
|
||||
if (authorFolder.IsNullOrWhiteSpace() && albumFolder.IsNullOrWhiteSpace())
|
||||
if (authorFolder.IsNullOrWhiteSpace() && bookFolder.IsNullOrWhiteSpace())
|
||||
{
|
||||
return new List<MetadataFile>();
|
||||
}
|
||||
@@ -205,21 +205,21 @@ namespace NzbDrone.Core.Extras.Metadata
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<MetadataFile> GetMetadataFilesForConsumer(IMetadata consumer, List<MetadataFile> artistMetadata)
|
||||
private List<MetadataFile> GetMetadataFilesForConsumer(IMetadata consumer, List<MetadataFile> authorMetadata)
|
||||
{
|
||||
return artistMetadata.Where(c => c.Consumer == consumer.GetType().Name).ToList();
|
||||
return authorMetadata.Where(c => c.Consumer == consumer.GetType().Name).ToList();
|
||||
}
|
||||
|
||||
private MetadataFile ProcessAuthorMetadata(IMetadata consumer, Author author, List<MetadataFile> existingMetadataFiles)
|
||||
{
|
||||
var artistMetadata = consumer.AuthorMetadata(author);
|
||||
var authorMetadata = consumer.AuthorMetadata(author);
|
||||
|
||||
if (artistMetadata == null)
|
||||
if (authorMetadata == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var hash = artistMetadata.Contents.SHA256Hash();
|
||||
var hash = authorMetadata.Contents.SHA256Hash();
|
||||
|
||||
var metadata = GetMetadataFile(author, existingMetadataFiles, e => e.Type == MetadataType.AuthorMetadata) ??
|
||||
new MetadataFile
|
||||
@@ -231,9 +231,9 @@ namespace NzbDrone.Core.Extras.Metadata
|
||||
|
||||
if (hash == metadata.Hash)
|
||||
{
|
||||
if (artistMetadata.RelativePath != metadata.RelativePath)
|
||||
if (authorMetadata.RelativePath != metadata.RelativePath)
|
||||
{
|
||||
metadata.RelativePath = artistMetadata.RelativePath;
|
||||
metadata.RelativePath = authorMetadata.RelativePath;
|
||||
|
||||
return metadata;
|
||||
}
|
||||
@@ -241,15 +241,15 @@ namespace NzbDrone.Core.Extras.Metadata
|
||||
return null;
|
||||
}
|
||||
|
||||
var fullPath = Path.Combine(author.Path, artistMetadata.RelativePath);
|
||||
var fullPath = Path.Combine(author.Path, authorMetadata.RelativePath);
|
||||
|
||||
_otherExtraFileRenamer.RenameOtherExtraFile(author, fullPath);
|
||||
|
||||
_logger.Debug("Writing Author Metadata to: {0}", fullPath);
|
||||
SaveMetadataFile(fullPath, artistMetadata.Contents);
|
||||
SaveMetadataFile(fullPath, authorMetadata.Contents);
|
||||
|
||||
metadata.Hash = hash;
|
||||
metadata.RelativePath = artistMetadata.RelativePath;
|
||||
metadata.RelativePath = authorMetadata.RelativePath;
|
||||
metadata.Extension = Path.GetExtension(fullPath);
|
||||
|
||||
return metadata;
|
||||
|
||||
Reference in New Issue
Block a user