mirror of
https://github.com/sphildreth/roadie
synced 2024-11-22 04:03:10 +00:00
parent
7e2d3449cb
commit
0c1b276cda
21 changed files with 119 additions and 307 deletions
|
@ -1,64 +1,8 @@
|
|||
{
|
||||
"RoadieSettings": {
|
||||
"SiteName": "Roadie",
|
||||
"DefaultTimeZone": "US/Central",
|
||||
"DiagnosticsPassword": "RoadieDiagPassword",
|
||||
"InboundFolder": "C:\\roadie_dev_root\\inbound",
|
||||
"LibraryFolder": "C:\\\\roadie_dev_root\\\\library",
|
||||
"Thumbnails": {
|
||||
"Height": 80,
|
||||
"Width": 80
|
||||
},
|
||||
"MediumThumbnails": {
|
||||
"Height": 160,
|
||||
"Width": 160
|
||||
},
|
||||
"LargeThumbnails": {
|
||||
"Height": 320,
|
||||
"Width": 320
|
||||
},
|
||||
"DontDoMetaDataProvidersSearchArtists": [ "Various Artists", "Sound Tracks" ],
|
||||
"FileExtensionsToDelete": [ ".accurip", ".bmp", ".cue", ".dat", ".db", ".exe", ".htm", ".html", ".ini", ".log", ".jpg", ".jpeg", ".par", ".par2", ".pdf", ".png", ".md5", ".mht", ".mpg", ".m3u", ".nfo", ".nzb", ".pls", ".sfv", ".srr", ".txt", ".url" ],
|
||||
"RecordNoResultSearches": true,
|
||||
"ArtistNameReplace": {
|
||||
"AC/DC": [ "AC; DC", "AC;DC", "AC/ DC", "AC DC" ],
|
||||
"Love/Hate": [ "Love; Hate", "Love;Hate", "Love/ Hate", "Love Hate" ]
|
||||
},
|
||||
"Integrations": {
|
||||
"ITunesProviderEnabled": true,
|
||||
"MusicBrainzProviderEnabled": true,
|
||||
"SpotifyProviderEnabled": true,
|
||||
"ApiKeys": [
|
||||
{
|
||||
"ApiName": "BingImageSearch",
|
||||
"Key": "<KEY HERE>"
|
||||
},
|
||||
{
|
||||
"ApiName": "LastFMApiKey",
|
||||
"Key": "<KEY HERE>",
|
||||
"KeySecret": "<SECRET HERE>"
|
||||
},
|
||||
{
|
||||
"ApiName": "DiscogsConsumerKey",
|
||||
"Key": "<KEY HERE>",
|
||||
"KeySecret": "<SECRET HERE>"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Processing": {
|
||||
"DoAudioCleanup": true,
|
||||
"DoSaveEditsToTags": true,
|
||||
"DoClearComments": true,
|
||||
"DoParseFromFileName": true,
|
||||
"DoParseFromDiscogsDBFindingTrackForArtist": true,
|
||||
"DoParseFromDiscogsDB": true,
|
||||
"DoParseFromMusicBrainz": true,
|
||||
"DoParseFromLastFM": true,
|
||||
"MaximumArtistImagesToAdd": 12,
|
||||
"MaximumReleaseImagesToAdd": 12,
|
||||
"MaxImageWidth": 2048,
|
||||
"PreInspectScript": "PreInspectScript.ps1",
|
||||
"PostInspectScript": "",
|
||||
"RemoveStringsRegex": "\\b[0-9]+\\s#\\s\\b",
|
||||
"ReleaseRemoveStringsRegex": "(\\\\s*(-\\\\s)*((CD[_\\-#\\s]*[0-9]*)))|((\\\\(|\\\\[)+([0-9]|,|self|bonus|re(leas|master|(e|d)*)*|th|anniversary|cd|disc|deluxe|dig(ipack)*|vinyl|japan(ese)*|asian|remastered|limited|ltd|expanded|edition|\\\\s)+(]|\\\\)*))",
|
||||
"TrackRemoveStringsRegex": "^([0-9]+)(\\.|-|\\s)*",
|
||||
"ReplaceStrings": [
|
||||
|
|
|
@ -1,62 +1,10 @@
|
|||
{
|
||||
"RoadieSettings": {
|
||||
"SiteName": "Roadie",
|
||||
"DefaultTimeZone": "US/Central",
|
||||
"DiagnosticsPassword": "RoadieDiagPassword",
|
||||
"InboundFolder": "C:\\roadie_dev_root\\inbound",
|
||||
"LibraryFolder": "C:\\\\roadie_dev_root\\\\library",
|
||||
"Thumbnails": {
|
||||
"Height": 80,
|
||||
"Width": 80
|
||||
},
|
||||
"MediumThumbnails": {
|
||||
"Height": 160,
|
||||
"Width": 160
|
||||
},
|
||||
"LargeThumbnails": {
|
||||
"Height": 320,
|
||||
"Width": 320
|
||||
},
|
||||
"DontDoMetaDataProvidersSearchArtists": [ "Various Artists", "Sound Tracks" ],
|
||||
"FileExtensionsToDelete": [ ".cue", ".db", ".gif", ".html", ".ini", ".jpg", ".jpeg", ".log", ".mpg", ".m3u", ".png", ".nfo", ".nzb", ".sfv", ".srr", ".txt", ".url" ],
|
||||
"RecordNoResultSearches": true,
|
||||
"ArtistNameReplace": {
|
||||
"AC/DC": [ "AC; DC", "AC;DC", "AC/ DC", "AC DC" ],
|
||||
"Love/Hate": [ "Love; Hate", "Love;Hate", "Love/ Hate", "Love Hate" ]
|
||||
},
|
||||
"Integrations": {
|
||||
"ITunesProviderEnabled": false,
|
||||
"MusicBrainzProviderEnabled": false,
|
||||
"SpotifyProviderEnabled": false,
|
||||
"ApiKeys": [
|
||||
{
|
||||
"ApiName": "BingImageSearch",
|
||||
"Key": ""
|
||||
},
|
||||
{
|
||||
"ApiName": "LastFMApiKey",
|
||||
"Key": "<",
|
||||
"KeySecret": ""
|
||||
},
|
||||
{
|
||||
"ApiName": "DiscogsConsumerKey",
|
||||
"Key": "",
|
||||
"KeySecret": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
"Processing": {
|
||||
"DoAudioCleanup": true,
|
||||
"DoSaveEditsToTags": true,
|
||||
"DoClearComments": true,
|
||||
"DoParseFromFileName": true,
|
||||
"DoParseFromDiscogsDBFindingTrackForArtist": true,
|
||||
"DoParseFromDiscogsDB": true,
|
||||
"DoParseFromMusicBrainz": true,
|
||||
"DoParseFromLastFM": true,
|
||||
"MaximumArtistImagesToAdd": 12,
|
||||
"MaximumReleaseImagesToAdd": 12,
|
||||
"MaxImageWidth": 800,
|
||||
"RemoveStringsRegex": "\\b[0-9]+\\s#\\s\\b",
|
||||
"ReleaseRemoveStringsRegex": "(\\\\s*(-\\\\s)*((CD[_\\-#\\s]*[0-9]*)))|((\\\\(|\\\\[)+([0-9]|,|self|bonus|re(leas|master|(e|d)*)*|th|anniversary|cd|disc|deluxe|dig(ipack)*|vinyl|japan(ese)*|asian|remastered|limited|ltd|expanded|edition|\\\\s)+(]|\\\\)*))",
|
||||
"TrackRemoveStringsRegex": "^([0-9]+)(\\.|-|\\s)*",
|
||||
"ReplaceStrings": [
|
||||
{
|
||||
|
|
|
@ -8,10 +8,8 @@ namespace Roadie.Library.Configuration
|
|||
bool DoAudioCleanup { get; set; }
|
||||
bool DoClearComments { get; set; }
|
||||
bool DoDeleteUnknowns { get; set; }
|
||||
bool DoFolderArtistNameSet { get; set; }
|
||||
bool DoMoveUnknowns { get; set; }
|
||||
bool DoParseFromDiscogsDB { get; }
|
||||
bool DoParseFromDiscogsDBFindingTrackForArtist { get; }
|
||||
bool DoParseFromFileName { get; set; }
|
||||
bool DoParseFromLastFM { get; }
|
||||
bool DoParseFromMusicBrainz { get; }
|
||||
|
|
|
@ -4,13 +4,12 @@ namespace Roadie.Library.Configuration
|
|||
{
|
||||
public interface IRoadieSettings
|
||||
{
|
||||
Dictionary<string, List<string>> ArtistNameReplace { get; set; }
|
||||
Dictionary<string, IEnumerable<string>> ArtistNameReplace { get; set; }
|
||||
string BehindProxyHost { get; set; }
|
||||
string ConnectionString { get; set; }
|
||||
string ContentPath { get; set; }
|
||||
Converting Converting { get; set; }
|
||||
string DefaultTimeZone { get; set; }
|
||||
string DiagnosticsPassword { get; set; }
|
||||
IEnumerable<string> DontDoMetaDataProvidersSearchArtists { get; set; }
|
||||
IEnumerable<string> FileExtensionsToDelete { get; set; }
|
||||
FilePlugins FilePlugins { get; set; }
|
||||
|
|
|
@ -109,6 +109,11 @@ namespace Roadie.Library.Configuration
|
|||
|
||||
public Integrations()
|
||||
{
|
||||
ITunesProviderEnabled = true;
|
||||
MusicBrainzProviderEnabled = true;
|
||||
LastFmProviderEnabled = true;
|
||||
SpotifyProviderEnabled = true;
|
||||
|
||||
DiscogsReadWriteTimeout = short.MaxValue;
|
||||
DiscogsTimeout = short.MaxValue;
|
||||
}
|
||||
|
|
|
@ -14,14 +14,10 @@ namespace Roadie.Library.Configuration
|
|||
|
||||
public bool DoDeleteUnknowns { get; set; }
|
||||
|
||||
public bool DoFolderArtistNameSet { get; set; }
|
||||
|
||||
public bool DoMoveUnknowns { get; set; }
|
||||
|
||||
public bool DoParseFromDiscogsDB { get; private set; }
|
||||
|
||||
public bool DoParseFromDiscogsDBFindingTrackForArtist { get; private set; }
|
||||
|
||||
public bool DoParseFromFileName { get; set; }
|
||||
|
||||
public bool DoParseFromLastFM { get; private set; }
|
||||
|
@ -52,9 +48,21 @@ namespace Roadie.Library.Configuration
|
|||
|
||||
public Processing()
|
||||
{
|
||||
ReplaceStrings = new List<ReplacementString>();
|
||||
DoAudioCleanup = true;
|
||||
DoClearComments = true;
|
||||
DoParseFromDiscogsDB = true;
|
||||
DoParseFromFileName = true;
|
||||
DoParseFromLastFM = true;
|
||||
DoParseFromMusicBrainz = true;
|
||||
DoSaveEditsToTags = true;
|
||||
|
||||
MaximumArtistImagesToAdd = 12;
|
||||
MaximumReleaseImagesToAdd = 12;
|
||||
|
||||
MaxImageWidth = 2048;
|
||||
|
||||
RemoveStringsRegex = "\\b[0-9]+\\s#\\s\\b";
|
||||
ReplaceStrings = new List<ReplacementString>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ namespace Roadie.Library.Configuration
|
|||
/// If the artist name is found in the values then use the key.
|
||||
/// <remark>This was desgined to handle 'AC/DC' type names as they contain the ID3 v2.3 spec artist seperator</remark>
|
||||
/// </summary>
|
||||
public Dictionary<string, List<string>> ArtistNameReplace { get; set; }
|
||||
public Dictionary<string, IEnumerable<string>> ArtistNameReplace { get; set; }
|
||||
|
||||
public string BehindProxyHost { get; set; }
|
||||
|
||||
|
@ -28,8 +28,6 @@ namespace Roadie.Library.Configuration
|
|||
|
||||
public string DefaultTimeZone { get; set; }
|
||||
|
||||
public string DiagnosticsPassword { get; set; }
|
||||
|
||||
public IEnumerable<string> DontDoMetaDataProvidersSearchArtists { get; set; }
|
||||
|
||||
public IEnumerable<string> FileExtensionsToDelete { get; set; }
|
||||
|
@ -88,11 +86,30 @@ namespace Roadie.Library.Configuration
|
|||
|
||||
public RoadieSettings()
|
||||
{
|
||||
ThumbnailImageSize = new ImageSize { Width = 80, Height = 80 };
|
||||
SmallImageSize = new ImageSize { Width = 160, Height = 160 };
|
||||
MediumImageSize = new ImageSize { Width = 320, Height = 320 };
|
||||
ArtistNameReplace = new Dictionary<string, IEnumerable<string>>
|
||||
{
|
||||
{ "AC/DC", new List<string>{ "AC; DC", "AC;DC", "AC/ DC", "AC DC" }},
|
||||
{ "Love/Hate", new List<string>{ "Love; Hate", "Love;Hate", "Love/ Hate", "Love Hate" }}
|
||||
};
|
||||
DefaultTimeZone = "US / Central";
|
||||
DontDoMetaDataProvidersSearchArtists = new List<string> { "Various Artists", "Sound Tracks" };
|
||||
FileExtensionsToDelete = new List<string>{ ".accurip", ".bmp", ".cue", ".dat", ".db", ".exe", ".htm", ".html", ".ini", ".log", ".jpg", ".jpeg", ".par", ".par2", ".pdf", ".png", ".md5", ".mht", ".mpg", ".m3u", ".nfo", ".nzb", ".pls", ".sfv", ".srr", ".txt", ".url" };
|
||||
InboundFolder = "M:/inbound";
|
||||
LargeImageSize = new ImageSize { Width = 500, Height = 500 };
|
||||
MaximumImageSize = new ImageSize { Width = 1024, Height = 1024 };
|
||||
LibraryFolder = "M:/library";
|
||||
MaximumImageSize = new ImageSize { Width = 2048, Height = 2048 };
|
||||
MediumImageSize = new ImageSize { Width = 320, Height = 320 };
|
||||
RecordNoResultSearches = true;
|
||||
SiteName = "Roadie";
|
||||
SmallImageSize = new ImageSize { Width = 160, Height = 160 };
|
||||
ThumbnailImageSize = new ImageSize { Width = 80, Height = 80 };
|
||||
|
||||
SmtpFromAddress = "noreply@roadie.rocks";
|
||||
SmtpPort = 587;
|
||||
SmtpUsername = "roadie";
|
||||
SmtpHost = "smtp.roadie.rocks";
|
||||
SmtpUseSSl = true;
|
||||
|
||||
Inspector = new Inspector();
|
||||
Converting = new Converting();
|
||||
Integrations = new Integrations();
|
||||
|
|
|
@ -10,8 +10,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Roadie.Library.Data
|
||||
{
|
||||
public interface IRoadieDbContext : IDisposable, IInfrastructure<IServiceProvider>, IDbContextDependencies,
|
||||
IDbSetCache, IDbQueryCache, IDbContextPoolable
|
||||
public interface IRoadieDbContext : IDisposable, IInfrastructure<IServiceProvider>, IDbContextDependencies, IDbSetCache, IDbQueryCache, IDbContextPoolable
|
||||
{
|
||||
DbSet<ArtistAssociation> ArtistAssociations { get; set; }
|
||||
DbSet<ArtistGenre> ArtistGenres { get; set; }
|
||||
|
|
|
@ -193,32 +193,65 @@ namespace Roadie.Library.Imaging
|
|||
RegexOptions.IgnoreCase);
|
||||
}
|
||||
|
||||
public static byte[] ResizeImage(byte[] imageBytes, int width, int height) => ImageHelper.ResizeImage(imageBytes, width, height, false).Item2;
|
||||
|
||||
/// <summary>
|
||||
/// Resize a given image to given dimensions
|
||||
/// Resize a given image to given dimensions if needed
|
||||
/// </summary>
|
||||
public static byte[] ResizeImage(byte[] imageBytes, int width, int height)
|
||||
/// <param name="imageBytes">Image bytes to resize</param>
|
||||
/// <param name="width">Resize to width</param>
|
||||
/// <param name="height">Resize to height</param>
|
||||
/// <param name="forceResize">Force resize</param>
|
||||
/// <returns>Tuple with bool for did resize and byte array of image</returns>
|
||||
public static Tuple<bool, byte[]> ResizeImage(byte[] imageBytes, int width, int height, bool? forceResize = false)
|
||||
{
|
||||
if (imageBytes == null) return null;
|
||||
if (imageBytes == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
using (var outStream = new MemoryStream())
|
||||
{
|
||||
var resized = false;
|
||||
IImageFormat imageFormat = null;
|
||||
using (var image = Image.Load(imageBytes, out imageFormat))
|
||||
{
|
||||
if (image.Width > width || image.Height > height)
|
||||
image.Mutate(ctx => ctx.Resize(width, height));
|
||||
var doForce = forceResize ?? false;
|
||||
if (doForce || image.Width > width || image.Height > height)
|
||||
{
|
||||
int newWidth, newHeight;
|
||||
if(doForce)
|
||||
{
|
||||
newWidth = width;
|
||||
newHeight = height;
|
||||
}
|
||||
else
|
||||
{
|
||||
float aspect = image.Width / (float)image.Height;
|
||||
if (aspect < 1)
|
||||
{
|
||||
newWidth = (int)(width * aspect);
|
||||
newHeight = (int)(newWidth / aspect);
|
||||
}
|
||||
else
|
||||
{
|
||||
newHeight = (int)(height / aspect);
|
||||
newWidth = (int)(newHeight * aspect);
|
||||
}
|
||||
}
|
||||
image.Mutate(ctx => ctx.Resize(newWidth, newHeight));
|
||||
resized = true;
|
||||
}
|
||||
image.Save(outStream, imageFormat);
|
||||
}
|
||||
|
||||
return outStream.ToArray();
|
||||
return new Tuple<bool, byte[]>(resized, outStream.ToArray());
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.WriteLine($"Error Resizing Image [{ex}]");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<PackageReference Include="AutoCompare.Core" Version="1.0.0" />
|
||||
<PackageReference Include="CsvHelper" Version="12.1.2" />
|
||||
<PackageReference Include="EFCore.BulkExtensions" Version="2.4.9" />
|
||||
<PackageReference Include="FluentFTP" Version="25.0.5" />
|
||||
<PackageReference Include="FluentFTP" Version="25.0.6" />
|
||||
<PackageReference Include="Hashids.net" Version="1.2.2" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.9" />
|
||||
<PackageReference Include="IdSharp.Common" Version="1.0.1" />
|
||||
|
|
|
@ -69,7 +69,6 @@ namespace Roadie.Library.MetaData.Audio
|
|||
ArtistLookupEngine = artistLookupEngine;
|
||||
|
||||
DoParseFromFileName = configuration.Processing.DoParseFromFileName;
|
||||
DoParseFromDiscogsDBFindingTrackForArtist = configuration.Processing.DoParseFromDiscogsDBFindingTrackForArtist;
|
||||
DoParseFromDiscogsDB = configuration.Processing.DoParseFromDiscogsDB;
|
||||
DoParseFromMusicBrainz = configuration.Processing.DoParseFromMusicBrainz;
|
||||
DoParseFromLastFM = configuration.Processing.DoParseFromLastFM;
|
||||
|
@ -113,8 +112,7 @@ namespace Roadie.Library.MetaData.Audio
|
|||
|
||||
if (!result.IsValid)
|
||||
{
|
||||
Logger.LogWarning("File [{0}] MetaData Invalid, TagSources [{1}] MetaData [{2}]", fileInfo.FullName,
|
||||
string.Join(",", tagSources), result.ToString());
|
||||
Logger.LogWarning("File [{0}] MetaData Invalid, TagSources [{1}] MetaData [{2}]", fileInfo.FullName, string.Join(",", tagSources), result.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -149,9 +147,13 @@ namespace Roadie.Library.MetaData.Audio
|
|||
}
|
||||
|
||||
public bool WriteTags(AudioMetaData metaData, FileInfo fileInfo)
|
||||
{
|
||||
if (Configuration.Processing.DoSaveEditsToTags)
|
||||
{
|
||||
return ID3TagsHelper.WriteTags(metaData, fileInfo.FullName);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static AudioMetaData MergeAudioData(IRoadieSettings settings, AudioMetaData left, AudioMetaData right)
|
||||
{
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace Roadie.Library.SearchEngines.MetaData.iTunes
|
||||
{
|
||||
public interface IiTunesHelper : IArtistSearchEngine, IReleaseSearchEngine
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
using Microsoft.Extensions.Logging;
|
||||
using Roadie.Library.Caching;
|
||||
using Roadie.Library.Configuration;
|
||||
using Roadie.Library.MetaData;
|
||||
using Roadie.Library.SearchEngines.Imaging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Roadie.Library.SearchEngines.MetaData.iTunes
|
||||
{
|
||||
public class iTunesHelper : MetaDataProviderBase, IiTunesHelper
|
||||
{
|
||||
private readonly ITunesSearchEngine _iTunesSearchEngine;
|
||||
|
||||
public override bool IsEnabled => Configuration.Integrations.ITunesProviderEnabled;
|
||||
|
||||
public iTunesHelper(IRoadieSettings configuration, ICacheManager cacheManager, ILogger<iTunesHelper> logger,
|
||||
ITunesSearchEngine iTunesSearchEngine)
|
||||
: base(configuration, cacheManager, logger)
|
||||
{
|
||||
_iTunesSearchEngine = iTunesSearchEngine;
|
||||
}
|
||||
|
||||
public async Task<OperationResult<IEnumerable<ArtistSearchResult>>> PerformArtistSearch(string query, int resultsCount) => await _iTunesSearchEngine.PerformArtistSearch(query, resultsCount);
|
||||
|
||||
public async Task<OperationResult<IEnumerable<ReleaseSearchResult>>> PerformReleaseSearch(string artistName, string query, int resultsCount) => await _iTunesSearchEngine.PerformReleaseSearch(artistName, query, resultsCount);
|
||||
}
|
||||
}
|
|
@ -697,8 +697,7 @@ namespace Roadie.Api.Services
|
|||
File.WriteAllBytes(artistImageName, artist.Thumbnail);
|
||||
|
||||
// Resize to store in database as thumbnail
|
||||
artist.Thumbnail = ImageHelper.ResizeImage(artist.Thumbnail, Configuration.MediumImageSize.Width,
|
||||
Configuration.MediumImageSize.Height);
|
||||
artist.Thumbnail = ImageHelper.ResizeImage(artist.Thumbnail, Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
||||
didChangeThumbnail = true;
|
||||
}
|
||||
|
||||
|
@ -714,13 +713,11 @@ namespace Roadie.Api.Services
|
|||
// Ensure is jpeg first
|
||||
artistSecondaryImage = ImageHelper.ConvertToJpegFormat(artistSecondaryImage);
|
||||
|
||||
var artistImageFilename = Path.Combine(newArtistFolder,
|
||||
string.Format(ImageHelper.ArtistSecondaryImageFilename, looper.ToString("00")));
|
||||
var artistImageFilename = Path.Combine(newArtistFolder,string.Format(ImageHelper.ArtistSecondaryImageFilename, looper.ToString("00")));
|
||||
while (File.Exists(artistImageFilename))
|
||||
{
|
||||
looper++;
|
||||
artistImageFilename = Path.Combine(newArtistFolder,
|
||||
string.Format(ImageHelper.ArtistSecondaryImageFilename, looper.ToString("00")));
|
||||
artistImageFilename = Path.Combine(newArtistFolder,string.Format(ImageHelper.ArtistSecondaryImageFilename, looper.ToString("00")));
|
||||
}
|
||||
|
||||
File.WriteAllBytes(artistImageFilename, artistSecondaryImage);
|
||||
|
|
|
@ -352,24 +352,27 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
}
|
||||
|
||||
private async Task<FileOperationResult<Image>> GetImageFileOperation(string type, string regionUrn, Guid id,
|
||||
int? width, int? height, Func<Task<FileOperationResult<Image>>> action, EntityTagHeaderValue etag = null)
|
||||
private async Task<FileOperationResult<Image>> GetImageFileOperation(string type, string regionUrn, Guid id, int? width, int? height, Func<Task<FileOperationResult<Image>>> action, EntityTagHeaderValue etag = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sw = Stopwatch.StartNew();
|
||||
var result = (await CacheManager.GetAsync($"urn:{type}_by_id_operation:{id}", action, regionUrn))
|
||||
.Adapt<FileOperationResult<Image>>();
|
||||
var result = (await CacheManager.GetAsync($"urn:{type}_by_id_operation:{id}", action, regionUrn)).Adapt<FileOperationResult<Image>>();
|
||||
if (!result.IsSuccess) return new FileOperationResult<Image>(result.IsNotFoundResult, result.Messages);
|
||||
if (result.ETag == etag) return new FileOperationResult<Image>(OperationMessages.NotModified);
|
||||
if ((width.HasValue || height.HasValue) && result?.Data?.Bytes != null)
|
||||
var force = width.HasValue || height.HasValue;
|
||||
var newWidth = width ?? Configuration.MaximumImageSize.Width;
|
||||
var newHeight = height ?? Configuration.MaximumImageSize.Height;
|
||||
if (result?.Data?.Bytes != null)
|
||||
{
|
||||
result.Data.Bytes = ImageHelper.ResizeImage(result?.Data?.Bytes, width.Value, height.Value);
|
||||
var resized = ImageHelper.ResizeImage(result?.Data?.Bytes, newWidth, newHeight, force);
|
||||
result.Data.Bytes = resized.Item2;
|
||||
result.ETag = EtagHelper.GenerateETag(HttpEncoder, result.Data.Bytes);
|
||||
result.LastModified = DateTime.UtcNow;
|
||||
if (width.Value != Configuration.ThumbnailImageSize.Width ||
|
||||
height.Value != Configuration.ThumbnailImageSize.Height)
|
||||
Logger.LogTrace($"{type}: Resized [{id}], Width [{width.Value}], Height [{height.Value}]");
|
||||
if (resized.Item1)
|
||||
{
|
||||
Logger.LogTrace($"{type}: Resized [{id}], Width [{ newWidth}], Height [{ newHeight}], Forced [{ force }]");
|
||||
}
|
||||
}
|
||||
|
||||
sw.Stop();
|
||||
|
|
|
@ -62,17 +62,14 @@ namespace Roadie.Api.Services
|
|||
{
|
||||
var hashids = new Hashids(TrackTokenSalt);
|
||||
var trackIdPart = BitConverter.ToInt32(trackId.ToByteArray(), 6);
|
||||
if (trackIdPart < 0) trackIdPart = trackIdPart * -1;
|
||||
var token = hashids.Encode(user.Id, SafeParser.ToNumber<int>(user.CreatedDate.Value.ToString("DDHHmmss")),
|
||||
trackIdPart);
|
||||
if (trackIdPart < 0) trackIdPart *= -1;
|
||||
var token = hashids.Encode(user.Id, SafeParser.ToNumber<int>(user.CreatedDate.Value.ToString("DDHHmmss")), trackIdPart);
|
||||
return token;
|
||||
}
|
||||
|
||||
public Image MakeThumbnailImage(Guid id, string type, int? width = null, int? height = null,
|
||||
bool includeCachebuster = false)
|
||||
public Image MakeThumbnailImage(Guid id, string type, int? width = null, int? height = null, bool includeCachebuster = false)
|
||||
{
|
||||
return MakeImage(id, type, width ?? Configuration.ThumbnailImageSize.Width,
|
||||
height ?? Configuration.ThumbnailImageSize.Height, null, includeCachebuster);
|
||||
return MakeImage(id, type, width ?? Configuration.ThumbnailImageSize.Width, height ?? Configuration.ThumbnailImageSize.Height, null, includeCachebuster);
|
||||
}
|
||||
|
||||
protected IEnumerable<int> ArtistIdsForRelease(int releaseId)
|
||||
|
@ -221,8 +218,10 @@ namespace Roadie.Api.Services
|
|||
protected Image MakeFullsizeSecondaryImage(Guid id, ImageType type, int imageId, string caption = null)
|
||||
{
|
||||
if (type == ImageType.ArtistSecondary)
|
||||
{
|
||||
return new Image($"{HttpContext.ImageBaseUrl}/artist-secondary/{id}/{imageId}", caption,
|
||||
$"{HttpContext.ImageBaseUrl}/artist-secondary/{id}/{imageId}/{Configuration.SmallImageSize.Width}/{Configuration.SmallImageSize.Height}");
|
||||
}
|
||||
return new Image($"{HttpContext.ImageBaseUrl}/release-secondary/{id}/{imageId}", caption,
|
||||
$"{HttpContext.ImageBaseUrl}/release-secondary/{id}/{imageId}/{Configuration.SmallImageSize.Width}/{Configuration.SmallImageSize.Height}");
|
||||
}
|
||||
|
|
|
@ -49,8 +49,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(404)]
|
||||
public async Task<IActionResult> ArtistSecondaryImage(Guid id, int imageId, int? width, int? height)
|
||||
{
|
||||
var result = await ImageService.ArtistSecondaryImage(id, imageId,
|
||||
width ?? RoadieSettings.MaximumImageSize.Width, height ?? RoadieSettings.MaximumImageSize.Height);
|
||||
var result = await ImageService.ArtistSecondaryImage(id, imageId, width, height);
|
||||
if (result == null || result.IsNotFoundResult) return NotFound();
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
return File(result.Data.Bytes,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"Roadie.Api": {
|
||||
"commandName": "Project",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
"ASPNETCORE_ENVIRONMENT": "Production"
|
||||
},
|
||||
"applicationUrl": "http://localhost:5123/"
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
|
||||
<PackageReference Include="Serilog.Exceptions" Version="5.3.0" />
|
||||
<PackageReference Include="Serilog.Exceptions" Version="5.3.1" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
|
||||
<PackageReference Include="Serilog.Sinks.RollingFileAlternate" Version="2.0.9" />
|
||||
|
|
|
@ -52,48 +52,9 @@
|
|||
},
|
||||
"CORSOrigins": "http://localhost:4200|http://localhost:8080|https://localhost:8080|http://localhost:80|https://localhost:80|http://192.168.1.177:8080",
|
||||
"RoadieSettings": {
|
||||
"SiteName": "Roadie",
|
||||
"DefaultTimeZone": "US/Central",
|
||||
"DiagnosticsPassword": "RoadieDiagPassword",
|
||||
"InboundFolder": "C:\\roadie_dev_root\\inbound",
|
||||
"LibraryFolder": "C:\\\\roadie_dev_root\\\\library",
|
||||
"Thumbnails": {
|
||||
"Height": 80,
|
||||
"Width": 80
|
||||
},
|
||||
"MediumThumbnails": {
|
||||
"Height": 160,
|
||||
"Width": 160
|
||||
},
|
||||
"LargeThumbnails": {
|
||||
"Height": 320,
|
||||
"Width": 320
|
||||
},
|
||||
"DontDoMetaDataProvidersSearchArtists": [ "Various Artists", "Sound Tracks" ],
|
||||
"FileExtensionsToDelete": [ ".cue", ".db", ".gif", ".html", ".ini", ".jpg", ".jpeg", ".log", ".mpg", ".m3u", ".png", ".nfo", ".nzb", ".sfv", ".srr", ".txt", ".url" ],
|
||||
"RecordNoResultSearches": true,
|
||||
"ArtistNameReplace": {
|
||||
"AC/DC": [ "AC; DC", "AC;DC", "AC/ DC", "AC DC" ],
|
||||
"Love/Hate": [ "Love; Hate", "Love;Hate", "Love/ Hate", "Love Hate" ]
|
||||
},
|
||||
"Integrations": {
|
||||
"ITunesProviderEnabled": true,
|
||||
"MusicBrainzProviderEnabled": true,
|
||||
"LastFmProviderEnabled": true,
|
||||
"SpotifyProviderEnabled": true
|
||||
},
|
||||
"Processing": {
|
||||
"DoAudioCleanup": true,
|
||||
"DoSaveEditsToTags": true,
|
||||
"DoClearComments": true,
|
||||
"DoParseFromFileName": true,
|
||||
"DoParseFromDiscogsDBFindingTrackForArtist": true,
|
||||
"DoParseFromDiscogsDB": true,
|
||||
"DoParseFromMusicBrainz": true,
|
||||
"DoParseFromLastFM": true,
|
||||
"MaximumArtistImagesToAdd": 12,
|
||||
"MaximumReleaseImagesToAdd": 12,
|
||||
"MaxImageWidth": 800,
|
||||
"RemoveStringsRegex": "\\b[0-9]+\\s#\\s\\b",
|
||||
"ReplaceStrings": [
|
||||
{
|
||||
|
|
|
@ -52,30 +52,6 @@
|
|||
},
|
||||
"CORSOrigins": "http://localhost:4200|http://localhost:8080|https://localhost:8080|http://localhost:80|https://localhost:80",
|
||||
"RoadieSettings": {
|
||||
"SiteName": "Roadie",
|
||||
"DefaultTimeZone": "US/Central",
|
||||
"DiagnosticsPassword": "RoadieDiagPassword",
|
||||
"InboundFolder": "M:/incoming/",
|
||||
"LibraryFolder": "M:/library/",
|
||||
"Thumbnails": {
|
||||
"Height": 80,
|
||||
"Width": 80
|
||||
},
|
||||
"MediumThumbnails": {
|
||||
"Height": 160,
|
||||
"Width": 160
|
||||
},
|
||||
"LargeThumbnails": {
|
||||
"Height": 320,
|
||||
"Width": 320
|
||||
},
|
||||
"DontDoMetaDataProvidersSearchArtists": [ "Various Artists", "Sound Tracks" ],
|
||||
"FileExtensionsToDelete": [ ".accurip", ".cue", ".dat", ".db", ".exe", ".html", ".ini", ".log", ".jpg", ".jpeg", ".par", ".par2", ".pdf", ".png", ".md5", ".mht", ".mpg", ".m3u", ".nfo", ".nzb", ".pls", ".sfv", ".srr", ".txt", ".url" ],
|
||||
"RecordNoResultSearches": true,
|
||||
"ArtistNameReplace": {
|
||||
"AC/DC": [ "AC; DC", "AC;DC", "AC/ DC", "AC DC" ],
|
||||
"Love/Hate": [ "Love; Hate", "Love;Hate", "Love/ Hate", "Love Hate" ]
|
||||
},
|
||||
"Converting": {
|
||||
"ConvertingEnabled": true,
|
||||
"DoDeleteAfter": true,
|
||||
|
@ -84,46 +60,7 @@
|
|||
"APEConvertCommand": "ffmpeg -i \"{0}\" \"{1}\"",
|
||||
"FLACConvertCommand": "ffmpeg -i \"{0}\" -q:a 0 \"{1}\""
|
||||
},
|
||||
"SmtpFromAddress": "roadie@roadie.rocks",
|
||||
"SmtpPort": 2525,
|
||||
"SmtpUsername": "apikey",
|
||||
"SmtpHost": "smtp.sendgrid.net",
|
||||
"SmtpUseSSl": true,
|
||||
"Integrations": {
|
||||
"ITunesProviderEnabled": true,
|
||||
"MusicBrainzProviderEnabled": true,
|
||||
"LastFmProviderEnabled": true,
|
||||
"SpotifyProviderEnabled": true,
|
||||
"ApiKeys": [
|
||||
{
|
||||
"ApiName": "BingImageSearch",
|
||||
"Key": ""
|
||||
},
|
||||
{
|
||||
"ApiName": "LastFMApiKey",
|
||||
"Key": "",
|
||||
"KeySecret": ""
|
||||
},
|
||||
{
|
||||
"ApiName": "DiscogsConsumerKey",
|
||||
"Key": "",
|
||||
"KeySecret": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
"Processing": {
|
||||
"DoAudioCleanup": true,
|
||||
"DoSaveEditsToTags": true,
|
||||
"DoClearComments": true,
|
||||
"DoParseFromFileName": true,
|
||||
"DoParseFromDiscogsDBFindingTrackForArtist": true,
|
||||
"DoParseFromDiscogsDB": true,
|
||||
"DoParseFromMusicBrainz": true,
|
||||
"DoParseFromLastFM": true,
|
||||
"MaximumArtistImagesToAdd": 12,
|
||||
"MaximumReleaseImagesToAdd": 12,
|
||||
"MaxImageWidth": 800,
|
||||
"RemoveStringsRegex": "\\b[0-9]+\\s#\\s\\b",
|
||||
"ReplaceStrings": [
|
||||
{
|
||||
"order": 1,
|
||||
|
|
Loading…
Reference in a new issue