mirror of
https://github.com/sphildreth/roadie
synced 2024-11-10 06:44:12 +00:00
Some old config cleanup, ability to add and delete secondary release images.
This commit is contained in:
parent
5aebef4d8c
commit
b3a3294b4b
15 changed files with 100 additions and 11 deletions
|
@ -20,7 +20,6 @@
|
|||
"DontDoMetaDataProvidersSearchArtists": [ "Various Artists", "Sound Tracks" ],
|
||||
"FileExtenionsToDelete": [ ".cue", ".db", ".gif", ".html", ".ini", ".jpg", ".jpeg", ".log", ".mpg", ".m3u", ".png", ".nfo", ".nzb", ".sfv", ".srr", ".txt", ".url" ],
|
||||
"RecordNoResultSearches": true,
|
||||
"SingleArtistHoldingFolder": "C:\\roadie_dev_root\\single_holding",
|
||||
"ArtistNameReplace": {
|
||||
"AC/DC": [ "AC; DC", "AC;DC", "AC/ DC", "AC DC" ],
|
||||
"Love/Hate": [ "Love; Hate", "Love;Hate", "Love/ Hate", "Love Hate" ]
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
"DontDoMetaDataProvidersSearchArtists": [ "Various Artists", "Sound Tracks" ],
|
||||
"FileExtenionsToDelete": [ ".cue", ".db", ".gif", ".html", ".ini", ".jpg", ".jpeg", ".log", ".mpg", ".m3u", ".png", ".nfo", ".nzb", ".sfv", ".srr", ".txt", ".url" ],
|
||||
"RecordNoResultSearches": true,
|
||||
"SingleArtistHoldingFolder": "C:\\roadie_dev_root\\single_holding",
|
||||
"ArtistNameReplace": {
|
||||
"AC/DC": [ "AC; DC", "AC;DC", "AC/ DC", "AC DC" ],
|
||||
"Love/Hate": [ "Love; Hate", "Love;Hate", "Love/ Hate", "Love Hate" ]
|
||||
|
|
|
@ -6,8 +6,10 @@ namespace Roadie.Library.Configuration
|
|||
public class Converting : IConverting
|
||||
{
|
||||
public string APEConvertCommand { get; set; }
|
||||
public bool ConvertingEnabled { get; set; }
|
||||
public bool DoDeleteAfter { get; set; }
|
||||
public string M4AConvertCommand { get; set; }
|
||||
public string OGGConvertCommand { get; set; }
|
||||
public string FLACConvertCommand { get; set; }
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
{
|
||||
public interface IConverting
|
||||
{
|
||||
bool ConvertingEnabled { get; set; }
|
||||
string APEConvertCommand { get; set; }
|
||||
bool DoDeleteAfter { get; set; }
|
||||
string M4AConvertCommand { get; set; }
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace Roadie.Library.Configuration
|
|||
bool RecordNoResultSearches { get; set; }
|
||||
RedisCache Redis { get; set; }
|
||||
string SecretKey { get; set; }
|
||||
string SingleArtistHoldingFolder { get; set; }
|
||||
string SiteName { get; set; }
|
||||
ImageSize SmallImageSize { get; set; }
|
||||
string SmtpFromAddress { get; set; }
|
||||
|
|
|
@ -40,7 +40,6 @@ namespace Roadie.Library.Configuration
|
|||
public RedisCache Redis { get; set; }
|
||||
public ImageSize SmallImageSize { get; set; }
|
||||
public string SecretKey { get; set; }
|
||||
public string SingleArtistHoldingFolder { get; set; }
|
||||
public string SiteName { get; set; }
|
||||
public string SmtpFromAddress { get; set; }
|
||||
public string SmtpHost { get; set; }
|
||||
|
|
|
@ -70,6 +70,10 @@ namespace Roadie.Library.Models.Releases
|
|||
// When populated a "data:image" base64 byte array of an image to use as new Thumbnail
|
||||
public string NewThumbnailData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// When populated a "data:image" base64 byte array of an image to use as secondary Release images.
|
||||
/// </summary>
|
||||
public List<string> NewSecondaryImagesData { get; set; }
|
||||
|
||||
[MaxLength(250)]
|
||||
[Required]
|
||||
|
|
|
@ -390,9 +390,15 @@ namespace Roadie.Library.MetaData.LastFm
|
|||
{
|
||||
parameters = new Dictionary<string, string>();
|
||||
}
|
||||
parameters.Add("method", method);
|
||||
parameters.Add("api_key", this._apiKey.Key);
|
||||
if (!string.IsNullOrEmpty(sk))
|
||||
if (!parameters.ContainsKey("method"))
|
||||
{
|
||||
parameters.Add("method", method);
|
||||
}
|
||||
if (!parameters.ContainsKey("api_key"))
|
||||
{
|
||||
parameters.Add("api_key", this._apiKey.Key);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(sk) && !parameters.ContainsKey("sk"))
|
||||
{
|
||||
parameters.Add("sk", sk);
|
||||
}
|
||||
|
|
|
@ -234,6 +234,45 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
}
|
||||
|
||||
public async Task<OperationResult<bool>> DeleteReleaseSecondaryImage(ApplicationUser user, Guid releaseId, int index)
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
var errors = new List<Exception>();
|
||||
var release = this.DbContext.Releases.Include(x => x.Artist).FirstOrDefault(x => x.RoadieId == releaseId);
|
||||
if (release == null)
|
||||
{
|
||||
await this.LogAndPublish($"DeleteReleaseSecondaryImage Unknown Release [{ releaseId}]", LogLevel.Warning);
|
||||
return new OperationResult<bool>(true, $"Release Not Found [{ releaseId }]");
|
||||
}
|
||||
try
|
||||
{
|
||||
var releaseFolder = release.ReleaseFileFolder(release.Artist.ArtistFileFolder(this.Configuration, this.Configuration.LibraryFolder));
|
||||
var releaseImagesInFolder = ImageHelper.FindImageTypeInDirectory(new DirectoryInfo(releaseFolder), ImageType.ReleaseSecondary, SearchOption.TopDirectoryOnly);
|
||||
var releaseImageFilename = releaseImagesInFolder.Skip(index).FirstOrDefault();
|
||||
if (releaseImageFilename.Exists)
|
||||
{
|
||||
releaseImageFilename.Delete();
|
||||
}
|
||||
this.CacheManager.ClearRegion(release.CacheRegion);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Logger.LogError(ex);
|
||||
await this.LogAndPublish("Error deleting release secondary image.");
|
||||
errors.Add(ex);
|
||||
}
|
||||
sw.Stop();
|
||||
await this.LogAndPublish($"DeleteReleaseSecondaryImage `{ release }` 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>> DeleteTrack(ApplicationUser user, Guid trackId, bool? doDeleteFile)
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
|
|
|
@ -17,6 +17,8 @@ namespace Roadie.Api.Services
|
|||
|
||||
Task<OperationResult<bool>> DeleteRelease(ApplicationUser user, Guid releaseId, bool? doDeleteFiles);
|
||||
|
||||
Task<OperationResult<bool>> DeleteReleaseSecondaryImage(ApplicationUser user, Guid releaseId, int index);
|
||||
|
||||
Task<OperationResult<bool>> DeleteTrack(ApplicationUser user, Guid trackId, bool? doDeleteFile);
|
||||
|
||||
Task<OperationResult<bool>> DeleteUser(ApplicationUser applicationUser, Guid id);
|
||||
|
|
|
@ -657,6 +657,32 @@ namespace Roadie.Api.Services
|
|||
didChangeThumbnail = true;
|
||||
}
|
||||
|
||||
if (model.NewSecondaryImagesData != null && model.NewSecondaryImagesData.Any())
|
||||
{
|
||||
var releaseFolder = release.ReleaseFileFolder(release.Artist.ArtistFileFolder(this.Configuration, this.Configuration.LibraryFolder));
|
||||
// Additional images to add to artist
|
||||
var looper = 0;
|
||||
foreach (var newSecondaryImageData in model.NewSecondaryImagesData)
|
||||
{
|
||||
var releaseSecondaryImage = ImageHelper.ImageDataFromUrl(newSecondaryImageData);
|
||||
if (releaseSecondaryImage != null)
|
||||
{
|
||||
// Ensure is jpeg first
|
||||
releaseSecondaryImage = ImageHelper.ConvertToJpegFormat(releaseSecondaryImage);
|
||||
|
||||
var releaseImageFilename = Path.Combine(releaseFolder, string.Format(ImageHelper.ReleaseSecondaryImageFilename, looper.ToString("00")));
|
||||
while (File.Exists(releaseImageFilename))
|
||||
{
|
||||
looper++;
|
||||
releaseImageFilename = Path.Combine(releaseFolder, string.Format(ImageHelper.ReleaseSecondaryImageFilename, looper.ToString("00")));
|
||||
}
|
||||
File.WriteAllBytes(releaseImageFilename, releaseSecondaryImage);
|
||||
}
|
||||
looper++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (model.Genres != null && model.Genres.Any())
|
||||
{
|
||||
// Remove existing Genres not in model list
|
||||
|
|
|
@ -85,6 +85,19 @@ namespace Roadie.Api.Controllers
|
|||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost("delete/releasesecondaryimage/{id}/{index}")]
|
||||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> DeleteReleaseSecondaryImage(Guid id, int index)
|
||||
{
|
||||
var result = await this.AdminService.DeleteReleaseSecondaryImage(await this.UserManager.GetUserAsync(User), id, index);
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
}
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
|
||||
[HttpPost("delete/track/{id}")]
|
||||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> DeleteTrack(Guid id, bool? doDeleteFile)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"Roadie.Api": {
|
||||
"commandName": "Project",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Production"
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "http://localhost:5123/"
|
||||
}
|
||||
|
|
|
@ -72,7 +72,6 @@
|
|||
"DontDoMetaDataProvidersSearchArtists": [ "Various Artists", "Sound Tracks" ],
|
||||
"FileExtenionsToDelete": [ ".cue", ".db", ".gif", ".html", ".ini", ".jpg", ".jpeg", ".log", ".mpg", ".m3u", ".png", ".nfo", ".nzb", ".sfv", ".srr", ".txt", ".url" ],
|
||||
"RecordNoResultSearches": true,
|
||||
"SingleArtistHoldingFolder": "C:\\roadie_dev_root\\single_holding",
|
||||
"ArtistNameReplace": {
|
||||
"AC/DC": [ "AC; DC", "AC;DC", "AC/ DC", "AC DC" ],
|
||||
"Love/Hate": [ "Love; Hate", "Love;Hate", "Love/ Hate", "Love Hate" ]
|
||||
|
|
|
@ -72,16 +72,17 @@
|
|||
"DontDoMetaDataProvidersSearchArtists": [ "Various Artists", "Sound Tracks" ],
|
||||
"FileExtenionsToDelete": [ ".cue", ".db", ".gif", ".html", ".ini", ".jpg", ".jpeg", ".log", ".mpg", ".m3u", ".png", ".nfo", ".nzb", ".sfv", ".srr", ".txt", ".url" ],
|
||||
"RecordNoResultSearches": true,
|
||||
"SingleArtistHoldingFolder": "M:/single_holding/",
|
||||
"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,
|
||||
"M4AConvertCommand": "ffmpeg -i \"{0}\" -acodec libmp3lame -q:a 0 \"{1}\"",
|
||||
"OGGConvertCommand": "ffmpeg -i \"{0}\" -acodec libmp3lame -q:a 0 \"{1}\"\"",
|
||||
"APEConvertCommand": "ffmpeg -i \"{0}\" \"{1}\""
|
||||
"APEConvertCommand": "ffmpeg -i \"{0}\" \"{1}\"",
|
||||
"FLACConvertCommand": "ffmpeg -i \"{0}\" -q:a 0 \"{1}\""
|
||||
},
|
||||
"SmtpFromAddress": "roadie@roadie.rocks",
|
||||
"SmtpPort": 2525,
|
||||
|
|
Loading…
Reference in a new issue