Artist edit work

This commit is contained in:
Steven Hildreth 2018-12-27 15:56:40 -06:00
parent a6c6e7952e
commit f5e57d083d
8 changed files with 46 additions and 28 deletions

View file

@ -39,7 +39,7 @@ namespace Roadie.Library.Data
[Column("isniList", TypeName = "text")]
[MaxLength(65535)]
public string ISNIList { get; set; }
public string ISNI { get; set; }
[Column("iTunesId")]
[MaxLength(100)]

View file

@ -274,7 +274,7 @@ namespace Roadie.Library.Engines
}
if (i.ISNIs != null)
{
result.ISNIList = result.ISNIList.AddToDelimitedList(i.ISNIs);
result.ISNI = result.ISNI.AddToDelimitedList(i.ISNIs);
}
if (i.ImageUrls != null)
{
@ -329,7 +329,7 @@ namespace Roadie.Library.Engines
}
if (mb.ISNIs != null)
{
result.ISNIList = result.ISNIList.AddToDelimitedList(mb.ISNIs);
result.ISNI = result.ISNI.AddToDelimitedList(mb.ISNIs);
}
if (mb.ImageUrls != null)
{
@ -388,7 +388,7 @@ namespace Roadie.Library.Engines
}
if (l.ISNIs != null)
{
result.ISNIList = result.ISNIList.AddToDelimitedList(l.ISNIs);
result.ISNI = result.ISNI.AddToDelimitedList(l.ISNIs);
}
if (l.ImageUrls != null)
{

View file

@ -154,7 +154,7 @@ namespace Roadie.Library.Factories
altNames.Add(ArtistToMerge.SortName);
artistToMergeInto.AlternateNames = artistToMergeInto.AlternateNames.AddToDelimitedList(altNames);
artistToMergeInto.URLs = artistToMergeInto.URLs.AddToDelimitedList(ArtistToMerge.URLs.ToListFromDelimited());
artistToMergeInto.ISNIList = artistToMergeInto.ISNIList.AddToDelimitedList(ArtistToMerge.ISNIList.ToListFromDelimited());
artistToMergeInto.ISNI = artistToMergeInto.ISNI.AddToDelimitedList(ArtistToMerge.ISNI.ToListFromDelimited());
artistToMergeInto.LastUpdated = now;
if (doDbUpdates)

View file

@ -45,18 +45,28 @@ namespace Roadie.Library.Models
[MaxLength(65535)]
[JsonIgnore]
[IgnoreDataMember]
public string ISNIList { get; set; }
public string ISNI { get; set; }
private IEnumerable<string> _isniList = null;
[JsonProperty("isniList")]
public IEnumerable<string> ISNIListList
public IEnumerable<string> ISNIList
{
get
{
if (string.IsNullOrEmpty(this.ISNIList))
if (this._isniList == null)
{
return null;
if (string.IsNullOrEmpty(this.ISNI))
{
return null;
}
return this.ISNI.Split('|');
}
return this.ISNIList.Split('|');
return this._isniList;
}
set
{
this._isniList = value;
}
}

View file

@ -542,7 +542,7 @@ namespace Roadie.Api.Services
artist.DiscogsId = model.DiscogsId;
artist.EndDate = model.EndDate;
artist.IsLocked = model.IsLocked;
artist.ISNIList = model.ISNIList.ToDelimitedList();
artist.ISNI = model.ISNIList.ToDelimitedList();
artist.ITunesId = model.ITunesId;
artist.MusicBrainzId = model.MusicBrainzId;
artist.Name = model.Name;
@ -808,8 +808,16 @@ namespace Roadie.Api.Services
// Ensure is jpeg first
artist.Thumbnail = ImageHelper.ConvertToJpegFormat(artist.Thumbnail);
// Ensure artist folder exists
var artistFolder = artist.ArtistFileFolder(this.Configuration, this.Configuration.LibraryFolder);
if(!Directory.Exists(artistFolder))
{
Directory.CreateDirectory(artistFolder);
this.Logger.LogInformation("Created Artist Folder [0] for `artist`", artistFolder, artist);
}
// Save unaltered image to artist file
var coverFileName = Path.Combine(artist.ArtistFileFolder(this.Configuration, this.Configuration.LibraryFolder), "artist.jpg");
var coverFileName = Path.Combine(artistFolder, "artist.jpg");
File.WriteAllBytes(coverFileName, artist.Thumbnail);
// Resize to store in database as thumbnail
@ -830,7 +838,7 @@ namespace Roadie.Api.Services
return new OperationResult<Library.Models.Image>
{
IsSuccess = !errors.Any(),
Data = this.MakeArtistThumbnailImage(id),
Data = base.MakeThumbnailImage(id, "artist", this.Configuration.MediumImageSize.Width, this.Configuration.MediumImageSize.Height, true),
OperationTime = sw.ElapsedMilliseconds,
Errors = errors
};

View file

@ -941,7 +941,7 @@ namespace Roadie.Api.Services
return new OperationResult<Library.Models.Image>
{
IsSuccess = !errors.Any(),
Data = this.MakeReleaseThumbnailImage(id),
Data = base.MakeThumbnailImage(id, "release", this.Configuration.MediumImageSize.Width, this.Configuration.MediumImageSize.Height, true),
OperationTime = sw.ElapsedMilliseconds,
Errors = errors
};

View file

@ -82,9 +82,9 @@ namespace Roadie.Api.Services
this._httpContext = httpContext;
}
public Image MakeThumbnailImage(Guid id, string type, int? width = null, int? height = null)
public Image MakeThumbnailImage(Guid id, string type, int? width = null, int? height = null, bool includeCachebuster = false)
{
return this.MakeImage(id, type, width ?? this.Configuration.ThumbnailImageSize.Width, height ?? this.Configuration.ThumbnailImageSize.Height);
return this.MakeImage(id, type, width ?? this.Configuration.ThumbnailImageSize.Width, height ?? this.Configuration.ThumbnailImageSize.Height, null, includeCachebuster);
}
protected data.Artist GetArtist(string artistName)
@ -236,9 +236,9 @@ namespace Roadie.Api.Services
return MakeThumbnailImage(id, "collection");
}
protected Image MakeImage(Guid id, int width = 200, int height = 200, string caption = null)
protected Image MakeImage(Guid id, int width = 200, int height = 200, string caption = null, bool includeCachebuster = false)
{
return new Image($"{this.HttpContext.ImageBaseUrl }/{id}/{ width }/{ height }", caption, $"{this.HttpContext.ImageBaseUrl }/{id}/{ this.Configuration.SmallImageSize.Width }/{ this.Configuration.SmallImageSize.Height }");
return new Image($"{this.HttpContext.ImageBaseUrl }/{id}/{ width }/{ height }/{ (includeCachebuster ? DateTime.UtcNow.Ticks.ToString() : string.Empty) }", caption, $"{this.HttpContext.ImageBaseUrl }/{id}/{ this.Configuration.SmallImageSize.Width }/{ this.Configuration.SmallImageSize.Height }");
}
protected Image MakeFullsizeImage(Guid id, string caption = null)
@ -594,11 +594,11 @@ namespace Roadie.Api.Services
}
private Image MakeImage(Guid id, string type, int? width, int? height, string caption = null)
private Image MakeImage(Guid id, string type, int? width, int? height, string caption = null, bool includeCachebuster = false)
{
if (width.HasValue && height.HasValue && (width.Value != this.Configuration.ThumbnailImageSize.Width || height.Value != this.Configuration.ThumbnailImageSize.Height))
{
return new Image($"{this.HttpContext.ImageBaseUrl }/{type}/{id}/{width}/{height}", caption, $"{this.HttpContext.ImageBaseUrl }/{type}/{id}/{ this.Configuration.ThumbnailImageSize.Width }/{ this.Configuration.ThumbnailImageSize.Height }");
return new Image($"{this.HttpContext.ImageBaseUrl }/{type}/{id}/{width}/{height}/{ (includeCachebuster ? DateTime.UtcNow.Ticks.ToString() : string.Empty) }", caption, $"{this.HttpContext.ImageBaseUrl }/{type}/{id}/{ this.Configuration.ThumbnailImageSize.Width }/{ this.Configuration.ThumbnailImageSize.Height }");
}
return new Image($"{this.HttpContext.ImageBaseUrl }/{type}/{id}", caption, null);
}

View file

@ -33,7 +33,7 @@ namespace Roadie.Api.Controllers
// return Ok(this._RoadieDbContext.Tracks.ProjectToType<models.Image>());
//}
[HttpGet("artist/{id}/{width:int?}/{height:int?}")]
[HttpGet("artist/{id}/{width:int?}/{height:int?}/{cacheBuster?}")]
[ProducesResponseType(200)]
[ProducesResponseType(404)]
public async Task<IActionResult> ArtistImage(Guid id, int? width, int? height)
@ -55,7 +55,7 @@ namespace Roadie.Api.Controllers
}
[HttpGet("collection/{id}/{width:int?}/{height:int?}")]
[HttpGet("collection/{id}/{width:int?}/{height:int?}/{cacheBuster?}")]
[ProducesResponseType(200)]
[ProducesResponseType(404)]
public async Task<IActionResult> CollectionImage(Guid id, int? width, int? height)
@ -93,7 +93,7 @@ namespace Roadie.Api.Controllers
return Ok(result);
}
[HttpGet("{id}/{width:int?}/{height:int?}")]
[HttpGet("{id}/{width:int?}/{height:int?}/{cacheBuster?}")]
[ProducesResponseType(200)]
[ProducesResponseType(404)]
public async Task<IActionResult> Get(Guid id, int? width, int? height)
@ -114,7 +114,7 @@ namespace Roadie.Api.Controllers
entityTag: result.ETag);
}
[HttpGet("label/{id}/{width:int?}/{height:int?}")]
[HttpGet("label/{id}/{width:int?}/{height:int?}/{cacheBuster?}")]
[ProducesResponseType(200)]
[ProducesResponseType(404)]
public async Task<IActionResult> LabelImage(Guid id, int? width, int? height)
@ -135,7 +135,7 @@ namespace Roadie.Api.Controllers
entityTag: result.ETag);
}
[HttpGet("playlist/{id}/{width:int?}/{height:int?}")]
[HttpGet("playlist/{id}/{width:int?}/{height:int?}/{cacheBuster?}")]
[ProducesResponseType(200)]
[ProducesResponseType(404)]
public async Task<IActionResult> PlaylistImage(Guid id, int? width, int? height)
@ -156,7 +156,7 @@ namespace Roadie.Api.Controllers
entityTag: result.ETag);
}
[HttpGet("release/{id}/{width:int?}/{height:int?}")]
[HttpGet("release/{id}/{width:int?}/{height:int?}/{cacheBuster?}")]
[ProducesResponseType(200)]
[ProducesResponseType(404)]
public async Task<IActionResult> ReleaseImage(Guid id, int? width, int? height)
@ -177,7 +177,7 @@ namespace Roadie.Api.Controllers
entityTag: result.ETag);
}
[HttpGet("track/{id}/{width:int?}/{height:int?}")]
[HttpGet("track/{id}/{width:int?}/{height:int?}/{cacheBuster?}")]
[ProducesResponseType(200)]
[ProducesResponseType(404)]
public async Task<IActionResult> TrackImage(Guid id, int? width, int? height)
@ -201,7 +201,7 @@ namespace Roadie.Api.Controllers
/// <summary>
/// NOTE that user images/avatars are PNG not JPG this is so it looks better in the menus/applications
/// </summary>
[HttpGet("user/{id}/{width:int?}/{height:int?}")]
[HttpGet("user/{id}/{width:int?}/{height:int?}/{cacheBuster?}")]
[ProducesResponseType(200)]
[ProducesResponseType(404)]
public async Task<IActionResult> UserImage(Guid id, int? width, int? height)