mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-27 22:56:45 -04:00
8547af9fae
Co-Authored-By: ta264 <ta264@users.noreply.github.com>
69 lines
2.4 KiB
C#
69 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using FluentValidation.Results;
|
|
using NzbDrone.Core.Books;
|
|
using NzbDrone.Core.Extras.Metadata.Files;
|
|
using NzbDrone.Core.MediaFiles;
|
|
using NzbDrone.Core.ThingiProvider;
|
|
|
|
namespace NzbDrone.Core.Extras.Metadata
|
|
{
|
|
public abstract class MetadataBase<TSettings> : IMetadata
|
|
where TSettings : IProviderConfig, new()
|
|
{
|
|
public abstract string Name { get; }
|
|
|
|
public Type ConfigContract => typeof(TSettings);
|
|
|
|
public virtual ProviderMessage Message => null;
|
|
|
|
public IEnumerable<ProviderDefinition> DefaultDefinitions => new List<ProviderDefinition>();
|
|
|
|
public ProviderDefinition Definition { get; set; }
|
|
|
|
public ValidationResult Test()
|
|
{
|
|
return new ValidationResult();
|
|
}
|
|
|
|
public virtual string GetFilenameAfterMove(Author author, BookFile bookFile, MetadataFile metadataFile)
|
|
{
|
|
var existingFilename = Path.Combine(author.Path, metadataFile.RelativePath);
|
|
var extension = Path.GetExtension(existingFilename).TrimStart('.');
|
|
var newFileName = Path.ChangeExtension(bookFile.Path, extension);
|
|
|
|
return newFileName;
|
|
}
|
|
|
|
public virtual string GetFilenameAfterMove(Author author, string albumPath, MetadataFile metadataFile)
|
|
{
|
|
var existingFilename = Path.GetFileName(metadataFile.RelativePath);
|
|
var newFileName = Path.Combine(author.Path, albumPath, existingFilename);
|
|
|
|
return newFileName;
|
|
}
|
|
|
|
public abstract MetadataFile FindMetadataFile(Author author, string path);
|
|
|
|
public abstract MetadataFileResult ArtistMetadata(Author author);
|
|
public abstract MetadataFileResult AlbumMetadata(Author author, Book book, string albumPath);
|
|
public abstract MetadataFileResult TrackMetadata(Author author, BookFile bookFile);
|
|
public abstract List<ImageFileResult> ArtistImages(Author author);
|
|
public abstract List<ImageFileResult> AlbumImages(Author author, Book book, string albumPath);
|
|
public abstract List<ImageFileResult> TrackImages(Author author, BookFile bookFile);
|
|
|
|
public virtual object RequestAction(string action, IDictionary<string, string> query)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
protected TSettings Settings => (TSettings)Definition.Settings;
|
|
|
|
public override string ToString()
|
|
{
|
|
return GetType().Name;
|
|
}
|
|
}
|
|
}
|