mirror of
https://github.com/sphildreth/roadie
synced 2025-02-16 21:18:26 +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;
|
artist.Thumbnail = firstImageWithNotNullBytes.Bytes;
|
||||||
if (artist.Thumbnail != null)
|
if (artist.Thumbnail != null)
|
||||||
{
|
{
|
||||||
artist.Thumbnail = ImageHelper.ResizeImage(artist.Thumbnail,
|
artist.Thumbnail = ImageHelper.ResizeImage(artist.Thumbnail, Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
||||||
Configuration.ThumbnailImageSize.Width, Configuration.ThumbnailImageSize.Height);
|
|
||||||
artist.Thumbnail = ImageHelper.ConvertToJpegFormat(artist.Thumbnail);
|
artist.Thumbnail = ImageHelper.ConvertToJpegFormat(artist.Thumbnail);
|
||||||
if (artist.Thumbnail.Length >= ImageHelper.MaximumThumbnailByteSize)
|
if (artist.Thumbnail.Length >= ImageHelper.MaximumThumbnailByteSize)
|
||||||
{
|
{
|
||||||
Logger.LogWarning(
|
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 larger than maximum size after resizing to [{Configuration.ThumbnailImageSize.Width}x{Configuration.ThumbnailImageSize.Height}] Thumbnail Size [{artist.Thumbnail.Length}]");
|
|
||||||
artist.Thumbnail = null;
|
artist.Thumbnail = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -546,20 +544,25 @@ namespace Roadie.Library.Engines
|
||||||
if (WikipediaArtistSearchEngine.IsEnabled)
|
if (WikipediaArtistSearchEngine.IsEnabled)
|
||||||
{
|
{
|
||||||
var wikiName = result.Name;
|
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))
|
if (!result.ArtistType.Equals("Person", StringComparison.OrdinalIgnoreCase))
|
||||||
wikiName = wikiName + " band";
|
{
|
||||||
|
wikiName += " band";
|
||||||
|
}
|
||||||
var wikipediaResult = await WikipediaArtistSearchEngine.PerformArtistSearch(wikiName, 1);
|
var wikipediaResult = await WikipediaArtistSearchEngine.PerformArtistSearch(wikiName, 1);
|
||||||
if (wikipediaResult != null)
|
if (wikipediaResult != null)
|
||||||
{
|
{
|
||||||
if (wikipediaResult.IsSuccess)
|
if (wikipediaResult.IsSuccess)
|
||||||
{
|
{
|
||||||
var w = wikipediaResult.Data.First();
|
var w = wikipediaResult?.Data?.FirstOrDefault();
|
||||||
|
if (w != null)
|
||||||
|
{
|
||||||
result.CopyTo(new Artist
|
result.CopyTo(new Artist
|
||||||
{
|
{
|
||||||
BioContext = HttpEncoder.HtmlEncode(w.Bio)
|
BioContext = HttpEncoder.HtmlEncode(w.Bio)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (wikipediaResult.Errors != null) resultsExceptions.AddRange(wikipediaResult.Errors);
|
if (wikipediaResult.Errors != null) resultsExceptions.AddRange(wikipediaResult.Errors);
|
||||||
}
|
}
|
||||||
|
@ -620,8 +623,7 @@ namespace Roadie.Library.Engines
|
||||||
|
|
||||||
if (result.Thumbnail != null)
|
if (result.Thumbnail != null)
|
||||||
{
|
{
|
||||||
result.Thumbnail = ImageHelper.ResizeImage(result.Thumbnail, Configuration.ThumbnailImageSize.Width,
|
result.Thumbnail = ImageHelper.ResizeImage(result.Thumbnail, Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
||||||
Configuration.ThumbnailImageSize.Height);
|
|
||||||
result.Thumbnail = ImageHelper.ConvertToJpegFormat(result.Thumbnail);
|
result.Thumbnail = ImageHelper.ConvertToJpegFormat(result.Thumbnail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -841,13 +841,12 @@ namespace Roadie.Library.Engines
|
||||||
|
|
||||||
if (result.Thumbnail != null)
|
if (result.Thumbnail != null)
|
||||||
{
|
{
|
||||||
result.Thumbnail = ImageHelper.ResizeImage(result.Thumbnail, Configuration.ThumbnailImageSize.Width,
|
result.Thumbnail = ImageHelper.ResizeImage(result.Thumbnail, Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
||||||
Configuration.ThumbnailImageSize.Height);
|
|
||||||
result.Thumbnail = ImageHelper.ConvertToJpegFormat(result.Thumbnail);
|
result.Thumbnail = ImageHelper.ConvertToJpegFormat(result.Thumbnail);
|
||||||
if (result.Thumbnail.Length >= ImageHelper.MaximumThumbnailByteSize)
|
if (result.Thumbnail.Length >= ImageHelper.MaximumThumbnailByteSize)
|
||||||
{
|
{
|
||||||
Logger.LogWarning(
|
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;
|
result.Thumbnail = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace Roadie.Library.Imaging
|
||||||
public static string ArtistImageFilename = "artist.jpg";
|
public static string ArtistImageFilename = "artist.jpg";
|
||||||
public static string ArtistSecondaryImageFilename = "artist {0}.jpg";
|
public static string ArtistSecondaryImageFilename = "artist {0}.jpg";
|
||||||
public static string LabelImageFilename = "label.jpg";
|
public static string LabelImageFilename = "label.jpg";
|
||||||
public static int MaximumThumbnailByteSize = 65535;
|
public static int MaximumThumbnailByteSize = 65000;
|
||||||
|
|
||||||
// Replace with counter of image
|
// Replace with counter of image
|
||||||
public static string ReleaseCoverFilename = "cover.jpg";
|
public static string ReleaseCoverFilename = "cover.jpg";
|
||||||
|
|
|
@ -692,11 +692,13 @@ namespace Roadie.Api.Services
|
||||||
if (!newArtistFolder.Equals(originalArtistFolder, StringComparison.OrdinalIgnoreCase))
|
if (!newArtistFolder.Equals(originalArtistFolder, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
didRenameArtist = true;
|
didRenameArtist = true;
|
||||||
|
if (Directory.Exists(originalArtistFolder))
|
||||||
|
{
|
||||||
// Rename artist folder to reflect new artist name
|
// Rename artist folder to reflect new artist name
|
||||||
Logger.LogTrace("Moving Artist From Folder [{0}] To [{1}]", originalArtistFolder, newArtistFolder);
|
Logger.LogTrace("Moving Artist From Folder [{0}] To [{1}]", originalArtistFolder, newArtistFolder);
|
||||||
Directory.Move(originalArtistFolder, newArtistFolder);
|
Directory.Move(originalArtistFolder, newArtistFolder);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var artistImage = ImageHelper.ImageDataFromUrl(model.NewThumbnailData);
|
var artistImage = ImageHelper.ImageDataFromUrl(model.NewThumbnailData);
|
||||||
if (artistImage != null)
|
if (artistImage != null)
|
||||||
|
@ -710,6 +712,11 @@ namespace Roadie.Api.Services
|
||||||
|
|
||||||
// Resize to store in database as 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;
|
||||||
|
}
|
||||||
didChangeThumbnail = true;
|
didChangeThumbnail = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -852,6 +859,9 @@ namespace Roadie.Api.Services
|
||||||
artist.LastUpdated = now;
|
artist.LastUpdated = now;
|
||||||
await DbContext.SaveChangesAsync();
|
await DbContext.SaveChangesAsync();
|
||||||
if (didRenameArtist)
|
if (didRenameArtist)
|
||||||
|
{
|
||||||
|
// Many contributing artists do not have releases and will not have an empty Artist folder
|
||||||
|
if (Directory.Exists(newArtistFolder))
|
||||||
{
|
{
|
||||||
// Update artist tracks to have new artist name in ID3 metadata
|
// Update artist tracks to have new artist name in ID3 metadata
|
||||||
foreach (var mp3 in Directory.GetFiles(newArtistFolder, "*.mp3", SearchOption.AllDirectories))
|
foreach (var mp3 in Directory.GetFiles(newArtistFolder, "*.mp3", SearchOption.AllDirectories))
|
||||||
|
@ -867,6 +877,7 @@ namespace Roadie.Api.Services
|
||||||
|
|
||||||
await ScanArtistReleasesFolders(user, artist.RoadieId, Configuration.LibraryFolder, false);
|
await ScanArtistReleasesFolders(user, artist.RoadieId, Configuration.LibraryFolder, false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CacheManager.ClearRegion(artist.CacheRegion);
|
CacheManager.ClearRegion(artist.CacheRegion);
|
||||||
Logger.LogInformation(
|
Logger.LogInformation(
|
||||||
|
@ -1295,8 +1306,12 @@ namespace Roadie.Api.Services
|
||||||
File.WriteAllBytes(artistImage, artist.Thumbnail);
|
File.WriteAllBytes(artistImage, artist.Thumbnail);
|
||||||
|
|
||||||
// Resize to store in database as thumbnail
|
// Resize to store in database as thumbnail
|
||||||
artist.Thumbnail = ImageHelper.ResizeImage(artist.Thumbnail, Configuration.MediumImageSize.Width,
|
artist.Thumbnail = ImageHelper.ResizeImage(artist.Thumbnail, Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
||||||
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;
|
artist.LastUpdated = now;
|
||||||
|
@ -1384,9 +1399,13 @@ namespace Roadie.Api.Services
|
||||||
{
|
{
|
||||||
// Read image and convert to jpeg
|
// Read image and convert to jpeg
|
||||||
artist.Thumbnail = File.ReadAllBytes(i.FullName);
|
artist.Thumbnail = File.ReadAllBytes(i.FullName);
|
||||||
artist.Thumbnail = ImageHelper.ResizeImage(artist.Thumbnail,
|
artist.Thumbnail = ImageHelper.ResizeImage(artist.Thumbnail,Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
||||||
Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
|
||||||
artist.Thumbnail = ImageHelper.ConvertToJpegFormat(artist.Thumbnail);
|
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;
|
artist.LastUpdated = DateTime.UtcNow;
|
||||||
await DbContext.SaveChangesAsync();
|
await DbContext.SaveChangesAsync();
|
||||||
CacheManager.ClearRegion(artist.CacheRegion);
|
CacheManager.ClearRegion(artist.CacheRegion);
|
||||||
|
|
|
@ -1289,20 +1289,17 @@ namespace Roadie.Api.Services
|
||||||
|
|
||||||
if (release.Thumbnail == null)
|
if (release.Thumbnail == null)
|
||||||
{
|
{
|
||||||
var imageFiles = ImageHelper.FindImageTypeInDirectory(new DirectoryInfo(releasePath),
|
var imageFiles = ImageHelper.FindImageTypeInDirectory(new DirectoryInfo(releasePath), ImageType.Release, SearchOption.TopDirectoryOnly);
|
||||||
ImageType.Release, SearchOption.TopDirectoryOnly);
|
|
||||||
if (imageFiles != null && imageFiles.Any())
|
if (imageFiles != null && imageFiles.Any())
|
||||||
{
|
{
|
||||||
// Read image and convert to jpeg
|
// Read image and convert to jpeg
|
||||||
var i = imageFiles.First();
|
var i = imageFiles.First();
|
||||||
release.Thumbnail = File.ReadAllBytes(i.FullName);
|
release.Thumbnail = File.ReadAllBytes(i.FullName);
|
||||||
release.Thumbnail = ImageHelper.ResizeImage(release.Thumbnail,
|
release.Thumbnail = ImageHelper.ResizeImage(release.Thumbnail, Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
||||||
Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
|
||||||
release.Thumbnail = ImageHelper.ConvertToJpegFormat(release.Thumbnail);
|
release.Thumbnail = ImageHelper.ConvertToJpegFormat(release.Thumbnail);
|
||||||
if (release.Thumbnail.Length >= ImageHelper.MaximumThumbnailByteSize)
|
if (release.Thumbnail.Length >= ImageHelper.MaximumThumbnailByteSize)
|
||||||
{
|
{
|
||||||
Logger.LogWarning(
|
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 larger than maximum size after resizing to [{Configuration.ThumbnailImageSize.Width}x{Configuration.ThumbnailImageSize.Height}] Thumbnail Size [{release.Thumbnail.Length}]");
|
|
||||||
release.Thumbnail = null;
|
release.Thumbnail = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1415,8 +1412,12 @@ namespace Roadie.Api.Services
|
||||||
File.WriteAllBytes(coverFileName, release.Thumbnail);
|
File.WriteAllBytes(coverFileName, release.Thumbnail);
|
||||||
|
|
||||||
// Resize to store in database as thumbnail
|
// Resize to store in database as thumbnail
|
||||||
release.Thumbnail = ImageHelper.ResizeImage(release.Thumbnail, Configuration.MediumImageSize.Width,
|
release.Thumbnail = ImageHelper.ResizeImage(release.Thumbnail, Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
||||||
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;
|
didChangeThumbnail = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1888,8 +1889,12 @@ namespace Roadie.Api.Services
|
||||||
File.WriteAllBytes(coverFileName, release.Thumbnail);
|
File.WriteAllBytes(coverFileName, release.Thumbnail);
|
||||||
|
|
||||||
// Resize to store in database as thumbnail
|
// Resize to store in database as thumbnail
|
||||||
release.Thumbnail = ImageHelper.ResizeImage(release.Thumbnail, Configuration.MediumImageSize.Width,
|
release.Thumbnail = ImageHelper.ResizeImage(release.Thumbnail, Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
||||||
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;
|
release.LastUpdated = now;
|
||||||
|
|
|
@ -845,8 +845,12 @@ namespace Roadie.Api.Services
|
||||||
File.WriteAllBytes(trackThumbnailName, track.Thumbnail);
|
File.WriteAllBytes(trackThumbnailName, track.Thumbnail);
|
||||||
|
|
||||||
// Resize to store in database as thumbnail
|
// Resize to store in database as thumbnail
|
||||||
track.Thumbnail = ImageHelper.ResizeImage(track.Thumbnail, Configuration.MediumImageSize.Width,
|
track.Thumbnail = ImageHelper.ResizeImage(track.Thumbnail, Configuration.MediumImageSize.Width, Configuration.MediumImageSize.Height);
|
||||||
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;
|
didChangeThumbnail = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue