mirror of
https://github.com/sphildreth/roadie
synced 2024-11-22 04:03:10 +00:00
Fixed several issues with Artist updating.
This commit is contained in:
parent
a738b89a3a
commit
247502408a
6 changed files with 74 additions and 45 deletions
|
@ -81,13 +81,11 @@ namespace Roadie.Library.Engines
|
|||
artist.Thumbnail = firstImageWithNotNullBytes.Bytes;
|
||||
if (artist.Thumbnail != null)
|
||||
{
|
||||
artist.Thumbnail = ImageHelper.ResizeImage(artist.Thumbnail,
|
||||
Configuration.ThumbnailImageSize.Width, Configuration.ThumbnailImageSize.Height);
|
||||
artist.Thumbnail = ImageHelper.ResizeImage(artist.Thumbnail, Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
||||
artist.Thumbnail = ImageHelper.ConvertToJpegFormat(artist.Thumbnail);
|
||||
if (artist.Thumbnail.Length >= ImageHelper.MaximumThumbnailByteSize)
|
||||
{
|
||||
Logger.LogWarning(
|
||||
$"Artist Thumbnail larger than maximum size after resizing to [{Configuration.ThumbnailImageSize.Width}x{Configuration.ThumbnailImageSize.Height}] Thumbnail Size [{artist.Thumbnail.Length}]");
|
||||
Logger.LogWarning($"Artist Thumbnail larger than maximum size after resizing to [{Configuration.MediumImageSize.Width}x{Configuration.MediumImageSize.Height}] Thumbnail Size [{artist.Thumbnail.Length}]");
|
||||
artist.Thumbnail = null;
|
||||
}
|
||||
}
|
||||
|
@ -546,19 +544,24 @@ namespace Roadie.Library.Engines
|
|||
if (WikipediaArtistSearchEngine.IsEnabled)
|
||||
{
|
||||
var wikiName = result.Name;
|
||||
// Help get better results for bands with proper nouns (e.g. "Poison")
|
||||
// Help get better results for bands with proper nouns (e.g. "Poison" vs "Poison Band")
|
||||
if (!result.ArtistType.Equals("Person", StringComparison.OrdinalIgnoreCase))
|
||||
wikiName = wikiName + " band";
|
||||
{
|
||||
wikiName += " band";
|
||||
}
|
||||
var wikipediaResult = await WikipediaArtistSearchEngine.PerformArtistSearch(wikiName, 1);
|
||||
if (wikipediaResult != null)
|
||||
{
|
||||
if (wikipediaResult.IsSuccess)
|
||||
{
|
||||
var w = wikipediaResult.Data.First();
|
||||
result.CopyTo(new Artist
|
||||
var w = wikipediaResult?.Data?.FirstOrDefault();
|
||||
if (w != null)
|
||||
{
|
||||
BioContext = HttpEncoder.HtmlEncode(w.Bio)
|
||||
});
|
||||
result.CopyTo(new Artist
|
||||
{
|
||||
BioContext = HttpEncoder.HtmlEncode(w.Bio)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (wikipediaResult.Errors != null) resultsExceptions.AddRange(wikipediaResult.Errors);
|
||||
|
@ -620,8 +623,7 @@ namespace Roadie.Library.Engines
|
|||
|
||||
if (result.Thumbnail != null)
|
||||
{
|
||||
result.Thumbnail = ImageHelper.ResizeImage(result.Thumbnail, Configuration.ThumbnailImageSize.Width,
|
||||
Configuration.ThumbnailImageSize.Height);
|
||||
result.Thumbnail = ImageHelper.ResizeImage(result.Thumbnail, Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
||||
result.Thumbnail = ImageHelper.ConvertToJpegFormat(result.Thumbnail);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -841,13 +841,12 @@ namespace Roadie.Library.Engines
|
|||
|
||||
if (result.Thumbnail != null)
|
||||
{
|
||||
result.Thumbnail = ImageHelper.ResizeImage(result.Thumbnail, Configuration.ThumbnailImageSize.Width,
|
||||
Configuration.ThumbnailImageSize.Height);
|
||||
result.Thumbnail = ImageHelper.ResizeImage(result.Thumbnail, Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
||||
result.Thumbnail = ImageHelper.ConvertToJpegFormat(result.Thumbnail);
|
||||
if (result.Thumbnail.Length >= ImageHelper.MaximumThumbnailByteSize)
|
||||
{
|
||||
Logger.LogWarning(
|
||||
$"Release Thumbnail larger than maximum size after resizing to [{Configuration.ThumbnailImageSize.Width}x{Configuration.ThumbnailImageSize.Height}] Thumbnail Size [{result.Thumbnail.Length}]");
|
||||
$"Release Thumbnail larger than maximum size after resizing to [{Configuration.MediumImageSize.Width}x{Configuration.MediumImageSize.Height}] Thumbnail Size [{result.Thumbnail.Length}]");
|
||||
result.Thumbnail = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Roadie.Library.Imaging
|
|||
public static string ArtistImageFilename = "artist.jpg";
|
||||
public static string ArtistSecondaryImageFilename = "artist {0}.jpg";
|
||||
public static string LabelImageFilename = "label.jpg";
|
||||
public static int MaximumThumbnailByteSize = 65535;
|
||||
public static int MaximumThumbnailByteSize = 65000;
|
||||
|
||||
// Replace with counter of image
|
||||
public static string ReleaseCoverFilename = "cover.jpg";
|
||||
|
|
|
@ -692,10 +692,12 @@ namespace Roadie.Api.Services
|
|||
if (!newArtistFolder.Equals(originalArtistFolder, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
didRenameArtist = true;
|
||||
|
||||
// Rename artist folder to reflect new artist name
|
||||
Logger.LogTrace("Moving Artist From Folder [{0}] To [{1}]", originalArtistFolder, newArtistFolder);
|
||||
Directory.Move(originalArtistFolder, newArtistFolder);
|
||||
if (Directory.Exists(originalArtistFolder))
|
||||
{
|
||||
// Rename artist folder to reflect new artist name
|
||||
Logger.LogTrace("Moving Artist From Folder [{0}] To [{1}]", originalArtistFolder, newArtistFolder);
|
||||
Directory.Move(originalArtistFolder, newArtistFolder);
|
||||
}
|
||||
}
|
||||
|
||||
var artistImage = ImageHelper.ImageDataFromUrl(model.NewThumbnailData);
|
||||
|
@ -710,6 +712,11 @@ namespace Roadie.Api.Services
|
|||
|
||||
// Resize to store in database as thumbnail
|
||||
artist.Thumbnail = ImageHelper.ResizeImage(artist.Thumbnail, Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
||||
if (artist.Thumbnail.Length >= ImageHelper.MaximumThumbnailByteSize)
|
||||
{
|
||||
Logger.LogWarning($"Artist Thumbnail larger than maximum size after resizing to [{Configuration.MediumImageSize.Width}x{Configuration.MediumImageSize.Height}] Thumbnail Size [{artist.Thumbnail.Length}]");
|
||||
artist.Thumbnail = null;
|
||||
}
|
||||
didChangeThumbnail = true;
|
||||
}
|
||||
|
||||
|
@ -853,19 +860,23 @@ namespace Roadie.Api.Services
|
|||
await DbContext.SaveChangesAsync();
|
||||
if (didRenameArtist)
|
||||
{
|
||||
// Update artist tracks to have new artist name in ID3 metadata
|
||||
foreach (var mp3 in Directory.GetFiles(newArtistFolder, "*.mp3", SearchOption.AllDirectories))
|
||||
// Many contributing artists do not have releases and will not have an empty Artist folder
|
||||
if (Directory.Exists(newArtistFolder))
|
||||
{
|
||||
var trackFileInfo = new FileInfo(mp3);
|
||||
var audioMetaData = await AudioMetaDataHelper.GetInfo(trackFileInfo);
|
||||
if (audioMetaData != null)
|
||||
// Update artist tracks to have new artist name in ID3 metadata
|
||||
foreach (var mp3 in Directory.GetFiles(newArtistFolder, "*.mp3", SearchOption.AllDirectories))
|
||||
{
|
||||
audioMetaData.Artist = artist.Name;
|
||||
AudioMetaDataHelper.WriteTags(audioMetaData, trackFileInfo);
|
||||
var trackFileInfo = new FileInfo(mp3);
|
||||
var audioMetaData = await AudioMetaDataHelper.GetInfo(trackFileInfo);
|
||||
if (audioMetaData != null)
|
||||
{
|
||||
audioMetaData.Artist = artist.Name;
|
||||
AudioMetaDataHelper.WriteTags(audioMetaData, trackFileInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await ScanArtistReleasesFolders(user, artist.RoadieId, Configuration.LibraryFolder, false);
|
||||
await ScanArtistReleasesFolders(user, artist.RoadieId, Configuration.LibraryFolder, false);
|
||||
}
|
||||
}
|
||||
|
||||
CacheManager.ClearRegion(artist.CacheRegion);
|
||||
|
@ -1295,8 +1306,12 @@ namespace Roadie.Api.Services
|
|||
File.WriteAllBytes(artistImage, 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);
|
||||
if (artist.Thumbnail.Length >= ImageHelper.MaximumThumbnailByteSize)
|
||||
{
|
||||
Logger.LogWarning($"Artist Thumbnail larger than maximum size after resizing to [{Configuration.MediumImageSize.Width}x{Configuration.MediumImageSize.Height}] Thumbnail Size [{artist.Thumbnail.Length}]");
|
||||
artist.Thumbnail = null;
|
||||
}
|
||||
}
|
||||
|
||||
artist.LastUpdated = now;
|
||||
|
@ -1384,9 +1399,13 @@ namespace Roadie.Api.Services
|
|||
{
|
||||
// Read image and convert to jpeg
|
||||
artist.Thumbnail = File.ReadAllBytes(i.FullName);
|
||||
artist.Thumbnail = ImageHelper.ResizeImage(artist.Thumbnail,
|
||||
Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
||||
artist.Thumbnail = ImageHelper.ResizeImage(artist.Thumbnail,Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
||||
artist.Thumbnail = ImageHelper.ConvertToJpegFormat(artist.Thumbnail);
|
||||
if (artist.Thumbnail.Length >= ImageHelper.MaximumThumbnailByteSize)
|
||||
{
|
||||
Logger.LogWarning($"Artist Thumbnail larger than maximum size after resizing to [{Configuration.MediumImageSize.Width}x{Configuration.MediumImageSize.Height}] Thumbnail Size [{artist.Thumbnail.Length}]");
|
||||
artist.Thumbnail = null;
|
||||
}
|
||||
artist.LastUpdated = DateTime.UtcNow;
|
||||
await DbContext.SaveChangesAsync();
|
||||
CacheManager.ClearRegion(artist.CacheRegion);
|
||||
|
|
|
@ -1289,20 +1289,17 @@ namespace Roadie.Api.Services
|
|||
|
||||
if (release.Thumbnail == null)
|
||||
{
|
||||
var imageFiles = ImageHelper.FindImageTypeInDirectory(new DirectoryInfo(releasePath),
|
||||
ImageType.Release, SearchOption.TopDirectoryOnly);
|
||||
var imageFiles = ImageHelper.FindImageTypeInDirectory(new DirectoryInfo(releasePath), ImageType.Release, SearchOption.TopDirectoryOnly);
|
||||
if (imageFiles != null && imageFiles.Any())
|
||||
{
|
||||
// Read image and convert to jpeg
|
||||
var i = imageFiles.First();
|
||||
release.Thumbnail = File.ReadAllBytes(i.FullName);
|
||||
release.Thumbnail = ImageHelper.ResizeImage(release.Thumbnail,
|
||||
Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
||||
release.Thumbnail = ImageHelper.ResizeImage(release.Thumbnail, Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
||||
release.Thumbnail = ImageHelper.ConvertToJpegFormat(release.Thumbnail);
|
||||
if (release.Thumbnail.Length >= ImageHelper.MaximumThumbnailByteSize)
|
||||
{
|
||||
Logger.LogWarning(
|
||||
$"Release Thumbnail larger than maximum size after resizing to [{Configuration.ThumbnailImageSize.Width}x{Configuration.ThumbnailImageSize.Height}] Thumbnail Size [{release.Thumbnail.Length}]");
|
||||
Logger.LogWarning($"Release Thumbnail larger than maximum size after resizing to [{Configuration.MediumImageSize.Width}x{Configuration.MediumImageSize.Height}] Thumbnail Size [{release.Thumbnail.Length}]");
|
||||
release.Thumbnail = null;
|
||||
}
|
||||
|
||||
|
@ -1415,8 +1412,12 @@ namespace Roadie.Api.Services
|
|||
File.WriteAllBytes(coverFileName, release.Thumbnail);
|
||||
|
||||
// Resize to store in database as thumbnail
|
||||
release.Thumbnail = ImageHelper.ResizeImage(release.Thumbnail, Configuration.MediumImageSize.Width,
|
||||
Configuration.MediumImageSize.Height);
|
||||
release.Thumbnail = ImageHelper.ResizeImage(release.Thumbnail, Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
||||
if (release.Thumbnail.Length >= ImageHelper.MaximumThumbnailByteSize)
|
||||
{
|
||||
Logger.LogWarning($"Release Thumbnail larger than maximum size after resizing to [{Configuration.MediumImageSize.Width}x{Configuration.MediumImageSize.Height}] Thumbnail Size [{release.Thumbnail.Length}]");
|
||||
release.Thumbnail = null;
|
||||
}
|
||||
didChangeThumbnail = true;
|
||||
}
|
||||
|
||||
|
@ -1888,8 +1889,12 @@ namespace Roadie.Api.Services
|
|||
File.WriteAllBytes(coverFileName, release.Thumbnail);
|
||||
|
||||
// Resize to store in database as thumbnail
|
||||
release.Thumbnail = ImageHelper.ResizeImage(release.Thumbnail, Configuration.MediumImageSize.Width,
|
||||
Configuration.MediumImageSize.Height);
|
||||
release.Thumbnail = ImageHelper.ResizeImage(release.Thumbnail, Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
||||
if (release.Thumbnail.Length >= ImageHelper.MaximumThumbnailByteSize)
|
||||
{
|
||||
Logger.LogWarning($"Release Thumbnail larger than maximum size after resizing to [{Configuration.MediumImageSize.Width}x{Configuration.MediumImageSize.Height}] Thumbnail Size [{release.Thumbnail.Length}]");
|
||||
release.Thumbnail = null;
|
||||
}
|
||||
}
|
||||
|
||||
release.LastUpdated = now;
|
||||
|
|
|
@ -845,8 +845,12 @@ namespace Roadie.Api.Services
|
|||
File.WriteAllBytes(trackThumbnailName, track.Thumbnail);
|
||||
|
||||
// Resize to store in database as thumbnail
|
||||
track.Thumbnail = ImageHelper.ResizeImage(track.Thumbnail, Configuration.MediumImageSize.Width,
|
||||
Configuration.MediumImageSize.Height);
|
||||
track.Thumbnail = ImageHelper.ResizeImage(track.Thumbnail, Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
||||
if (track.Thumbnail.Length >= ImageHelper.MaximumThumbnailByteSize)
|
||||
{
|
||||
Logger.LogWarning($"Track Thumbnail larger than maximum size after resizing to [{Configuration.MediumImageSize.Width}x{Configuration.MediumImageSize.Height}] Thumbnail Size [{track.Thumbnail.Length}]");
|
||||
track.Thumbnail = null;
|
||||
}
|
||||
didChangeThumbnail = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue