mirror of
https://github.com/sphildreth/roadie
synced 2024-11-10 06:44:12 +00:00
v1.0.0
This commit is contained in:
parent
ab2e8b5787
commit
1a63e49ade
10 changed files with 106 additions and 9 deletions
|
@ -152,8 +152,8 @@ namespace Roadie.Library.FilePlugins
|
|||
foreach (var artistImage in artistImages)
|
||||
{
|
||||
looper++;
|
||||
var aristImageFilename = Path.Combine(artistFolder, string.Format(ImageHelper.ArtistSecondaryImageFilename, looper.ToString("00")));
|
||||
if (aristImageFilename != artistImage.FullName)
|
||||
var artistImageFilename = Path.Combine(artistFolder, string.Format(ImageHelper.ArtistSecondaryImageFilename, looper.ToString("00")));
|
||||
if (artistImageFilename != artistImage.FullName)
|
||||
{
|
||||
// Read image and convert to jpeg
|
||||
var imageBytes = File.ReadAllBytes(artistImage.FullName);
|
||||
|
@ -162,10 +162,15 @@ namespace Roadie.Library.FilePlugins
|
|||
// Move artist image to artist folder
|
||||
if (!doJustInfo)
|
||||
{
|
||||
File.WriteAllBytes(aristImageFilename, imageBytes);
|
||||
while (File.Exists(artistImageFilename))
|
||||
{
|
||||
looper++;
|
||||
artistImageFilename = Path.Combine(artistFolder, string.Format(ImageHelper.ArtistSecondaryImageFilename, looper.ToString("00")));
|
||||
}
|
||||
File.WriteAllBytes(artistImageFilename, imageBytes);
|
||||
artistImage.Delete();
|
||||
}
|
||||
this.Logger.LogDebug("Found Artist Secondary Image File [{0}], Moved to artist folder [{1}].", artistImage.Name, aristImageFilename);
|
||||
this.Logger.LogDebug("Found Artist Secondary Image File [{0}], Moved to artist folder [{1}].", artistImage.Name, artistImageFilename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,7 +101,10 @@ namespace Roadie.Library.Imaging
|
|||
IImageFormat imageFormat = null;
|
||||
using (Image<Rgba32> image = Image.Load(imageBytes, out imageFormat))
|
||||
{
|
||||
image.Mutate(ctx => ctx.Resize(width, height));
|
||||
if (image.Width > width || image.Height > height)
|
||||
{
|
||||
image.Mutate(ctx => ctx.Resize(width, height));
|
||||
}
|
||||
image.Save(outStream, imageFormat);
|
||||
}
|
||||
return outStream.ToArray();
|
||||
|
@ -228,5 +231,6 @@ namespace Roadie.Library.Imaging
|
|||
|
||||
return result.OrderBy(x => x.Name);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -79,9 +79,16 @@ namespace Roadie.Library.Models
|
|||
[MaxLength(250)]
|
||||
public string Name { get; set; }
|
||||
|
||||
// When populated a "data:image" base64 byte array of an image to use as new Thumbnail
|
||||
/// <summary>
|
||||
/// When populated a "data:image" base64 byte array of an image to use as new Thumbnail.
|
||||
/// </summary>
|
||||
public string NewThumbnailData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// When populated a "data:image" base64 byte array of an image to use as secondary Artist images.
|
||||
/// </summary>
|
||||
public List<string> NewSecondaryImagesData { get; set; }
|
||||
|
||||
[MaxLength(65535)]
|
||||
public string Profile { get; set; }
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ using Roadie.Library.Enums;
|
|||
using Roadie.Library.Extensions;
|
||||
using Roadie.Library.Factories;
|
||||
using Roadie.Library.Identity;
|
||||
using Roadie.Library.Imaging;
|
||||
using Roadie.Library.MetaData.Audio;
|
||||
using Roadie.Library.MetaData.FileName;
|
||||
using Roadie.Library.MetaData.ID3Tags;
|
||||
|
@ -88,6 +89,45 @@ namespace Roadie.Api.Services
|
|||
this.ArtistFactory = new ArtistFactory(configuration, httpEncoder, context, cacheManager, MessageLogger, this.ArtistLookupEngine, this.ReleaseFactory, this.ImageFactory, this.ReleaseLookupEngine, this.AudioMetaDataHelper);
|
||||
}
|
||||
|
||||
public async Task<OperationResult<bool>> DeleteArtistSecondaryImage(ApplicationUser user, Guid artistId, int index)
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
var errors = new List<Exception>();
|
||||
var artist = this.DbContext.Artists.FirstOrDefault(x => x.RoadieId == artistId);
|
||||
if (artist == null)
|
||||
{
|
||||
await this.LogAndPublish($"DeleteArtistSecondaryImage Unknown Artist [{ artistId}]", LogLevel.Warning);
|
||||
return new OperationResult<bool>(true, $"Artist Not Found [{ artistId }]");
|
||||
}
|
||||
try
|
||||
{
|
||||
var artistFolder = artist.ArtistFileFolder(this.Configuration, this.Configuration.LibraryFolder);
|
||||
var artistImagesInFolder = ImageHelper.FindImageTypeInDirectory(new DirectoryInfo(artistFolder), ImageType.ArtistSecondary, SearchOption.TopDirectoryOnly);
|
||||
var artistImageFilename = artistImagesInFolder.Skip(index).FirstOrDefault();
|
||||
if (artistImageFilename.Exists)
|
||||
{
|
||||
artistImageFilename.Delete();
|
||||
}
|
||||
this.CacheManager.ClearRegion(artist.CacheRegion);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Logger.LogError(ex);
|
||||
await this.LogAndPublish("Error deleting artist secondary image.");
|
||||
errors.Add(ex);
|
||||
}
|
||||
sw.Stop();
|
||||
await this.LogAndPublish($"DeleteArtistSecondaryImage `{ artist }` Index [{ index }], By User `{user }`", LogLevel.Information);
|
||||
return new OperationResult<bool>
|
||||
{
|
||||
IsSuccess = !errors.Any(),
|
||||
Data = true,
|
||||
OperationTime = sw.ElapsedMilliseconds,
|
||||
Errors = errors
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<OperationResult<bool>> DeleteArtist(ApplicationUser user, Guid artistId)
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
|
|
|
@ -452,7 +452,7 @@ namespace Roadie.Api.Services
|
|||
artist.Thumbnail = ImageHelper.ConvertToJpegFormat(artistImage);
|
||||
|
||||
// Save unaltered image to cover file
|
||||
var artistImageName = Path.Combine(artist.ArtistFileFolder(this.Configuration, this.Configuration.LibraryFolder), ImageHelper.ArtistImageFilename);
|
||||
var artistImageName = Path.Combine(newArtistFolder, ImageHelper.ArtistImageFilename);
|
||||
File.WriteAllBytes(artistImageName, artist.Thumbnail);
|
||||
|
||||
// Resize to store in database as thumbnail
|
||||
|
@ -460,6 +460,30 @@ namespace Roadie.Api.Services
|
|||
didChangeThumbnail = true;
|
||||
}
|
||||
|
||||
if(model.NewSecondaryImagesData != null && model.NewSecondaryImagesData.Any())
|
||||
{
|
||||
// Additional images to add to artist
|
||||
var looper = 0;
|
||||
foreach (var newSecondaryImageData in model.NewSecondaryImagesData)
|
||||
{
|
||||
var artistSecondaryImage = ImageHelper.ImageDataFromUrl(newSecondaryImageData);
|
||||
if (artistSecondaryImage != null)
|
||||
{
|
||||
// Ensure is jpeg first
|
||||
artistSecondaryImage = ImageHelper.ConvertToJpegFormat(artistSecondaryImage);
|
||||
|
||||
var aristImageFilename = Path.Combine(newArtistFolder, string.Format(ImageHelper.ArtistSecondaryImageFilename, looper.ToString("00")));
|
||||
while(File.Exists(aristImageFilename))
|
||||
{
|
||||
looper++;
|
||||
aristImageFilename = Path.Combine(newArtistFolder, string.Format(ImageHelper.ArtistSecondaryImageFilename, looper.ToString("00")));
|
||||
}
|
||||
File.WriteAllBytes(aristImageFilename, artistSecondaryImage);
|
||||
}
|
||||
looper++;
|
||||
}
|
||||
}
|
||||
|
||||
if (model.Genres != null && model.Genres.Any())
|
||||
{
|
||||
// Remove existing Genres not in model list
|
||||
|
|
|
@ -11,6 +11,8 @@ namespace Roadie.Api.Services
|
|||
{
|
||||
Task<OperationResult<bool>> DeleteArtist(ApplicationUser user, Guid artistId);
|
||||
|
||||
Task<OperationResult<bool>> DeleteArtistSecondaryImage(ApplicationUser user, Guid artistId, int index);
|
||||
|
||||
Task<OperationResult<bool>> DeleteArtistReleases(ApplicationUser user, Guid artistId, bool doDeleteFiles = false);
|
||||
|
||||
Task<OperationResult<bool>> DeleteRelease(ApplicationUser user, Guid releaseId, bool? doDeleteFiles);
|
||||
|
|
|
@ -157,6 +157,19 @@ namespace Roadie.Api.Controllers
|
|||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost("delete/artistsecondaryimage/{id}/{index}")]
|
||||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> DeleteArtistSecondaryImage(Guid id, int index)
|
||||
{
|
||||
var result = await this.AdminService.DeleteArtistSecondaryImage(await this.UserManager.GetUserAsync(User), id, index);
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
}
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
|
||||
[HttpPost("delete/artist/releases/{id}")]
|
||||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> DeleteArtistReleases(Guid id)
|
||||
|
|
|
@ -156,5 +156,7 @@ namespace Roadie.Api.Controllers
|
|||
}
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -97,7 +97,7 @@ namespace Roadie.Api.Controllers
|
|||
entityTag: result.ETag);
|
||||
}
|
||||
|
||||
[HttpPost("{id}")]
|
||||
[HttpPost("delete/{id}")]
|
||||
[Authorize(Policy = "Editor")]
|
||||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> Delete(Guid id)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"Roadie.Api": {
|
||||
"commandName": "Project",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Production"
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "http://localhost:5123/"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue