mirror of
https://github.com/sphildreth/roadie
synced 2024-11-22 04:03:10 +00:00
Bug Squashing
This commit is contained in:
parent
56c33c19dc
commit
6a985a7316
13 changed files with 202 additions and 159 deletions
|
@ -15,8 +15,7 @@ namespace Roadie.Library.Data
|
|||
public ApplicationUser User { get; set; }
|
||||
|
||||
[Column("userId")]
|
||||
[Required]
|
||||
public int UserId { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public new bool? IsLocked { get; set; }
|
||||
|
|
|
@ -642,7 +642,8 @@ namespace Roadie.Library.Engines
|
|||
{
|
||||
switch (result.ArtistType.ToLower().Replace('-', ' '))
|
||||
{
|
||||
case "Artist":
|
||||
case "artist":
|
||||
case "artists":
|
||||
case "one man band":
|
||||
case "one woman band":
|
||||
case "solo":
|
||||
|
|
|
@ -98,6 +98,7 @@ namespace Roadie.Library.Engines
|
|||
var searchName = metaData.Release.NormalizeName().ToLower();
|
||||
var specialSearchName = metaData.Release.ToAlphanumericName();
|
||||
var release = (from r in this.DbContext.Releases
|
||||
where (r.ArtistId == artist.Id)
|
||||
where (r.Title.Contains(searchName) ||
|
||||
r.AlternateNames.Contains(searchName) ||
|
||||
r.AlternateNames.Contains(specialSearchName))
|
||||
|
|
|
@ -7,12 +7,9 @@ using Roadie.Library.Extensions;
|
|||
using Roadie.Library.Factories;
|
||||
using Roadie.Library.Imaging;
|
||||
using Roadie.Library.MetaData.Audio;
|
||||
using Roadie.Library.MetaData.ID3Tags;
|
||||
using Roadie.Library.MetaData.LastFm;
|
||||
using Roadie.Library.MetaData.MusicBrainz;
|
||||
using Roadie.Library.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -43,7 +40,7 @@ namespace Roadie.Library.FilePlugins
|
|||
ILogger logger,
|
||||
IArtistLookupEngine artistLookupEngine,
|
||||
IReleaseLookupEngine releaseLookupEngine,
|
||||
IAudioMetaDataHelper audioMetaDataHelper)
|
||||
IAudioMetaDataHelper audioMetaDataHelper)
|
||||
: base(configuration, httpEncoder, artistFactory, releaseFactory, imageFactory, cacheManager, logger, artistLookupEngine, releaseLookupEngine)
|
||||
{
|
||||
this.AudioMetaDataHelper = audioMetaDataHelper;
|
||||
|
@ -51,149 +48,169 @@ namespace Roadie.Library.FilePlugins
|
|||
|
||||
public override async Task<OperationResult<bool>> Process(string destinationRoot, FileInfo fileInfo, bool doJustInfo, int? submissionId)
|
||||
{
|
||||
var dr = destinationRoot ?? fileInfo.DirectoryName;
|
||||
this.Logger.LogTrace(">> Audio: Process destinationRoot [{0}], FileInfo [{1}], doJustInfo [{2}], submissionId [{3}]", destinationRoot, fileInfo, doJustInfo, submissionId);
|
||||
var sw = Stopwatch.StartNew();
|
||||
var result = new OperationResult<bool>();
|
||||
|
||||
string destinationName = null;
|
||||
|
||||
var metaData = await this.AudioMetaDataHelper.GetInfo(fileInfo, doJustInfo);
|
||||
if (!metaData.IsValid)
|
||||
try
|
||||
{
|
||||
var minWeight = this.MinWeightToDelete;
|
||||
if (metaData.ValidWeight < minWeight && minWeight > 0)
|
||||
var dr = destinationRoot ?? fileInfo.DirectoryName;
|
||||
|
||||
string destinationName = null;
|
||||
|
||||
var metaData = await this.AudioMetaDataHelper.GetInfo(fileInfo, doJustInfo);
|
||||
if (!metaData.IsValid)
|
||||
{
|
||||
this.Logger.LogTrace("Invalid File{3}: ValidWeight [{0}], Under MinWeightToDelete [{1}]. Deleting File [{2}]", metaData.ValidWeight, minWeight, fileInfo.FullName, doJustInfo ? " [Read Only Mode] " : string.Empty);
|
||||
if (!doJustInfo)
|
||||
var minWeight = this.MinWeightToDelete;
|
||||
if (metaData.ValidWeight < minWeight && minWeight > 0)
|
||||
{
|
||||
fileInfo.Delete();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
var artist = metaData.Artist.CleanString(this.Configuration);
|
||||
var album = metaData.Release.CleanString(this.Configuration);
|
||||
var title = metaData.Title.CleanString(this.Configuration).ToTitleCase(false);
|
||||
var year = metaData.Year;
|
||||
var trackNumber = metaData.TrackNumber ?? 0;
|
||||
var diskNumber = metaData.Disk ?? 0;
|
||||
|
||||
SimpleContract.Requires(metaData.IsValid, "Track MetaData Invalid");
|
||||
SimpleContract.Requires<ArgumentException>(!string.IsNullOrEmpty(artist), "Missing Track Artist");
|
||||
SimpleContract.Requires<ArgumentException>(!string.IsNullOrEmpty(album), "Missing Track Album");
|
||||
SimpleContract.Requires<ArgumentException>(!string.IsNullOrEmpty(title), "Missing Track Title");
|
||||
SimpleContract.Requires<ArgumentException>(year > 0, string.Format("Invalid Track Year [{0}]", year));
|
||||
SimpleContract.Requires<ArgumentException>(trackNumber > 0, "Missing Track Number");
|
||||
|
||||
var artistFolder = await this.DetermineArtistFolder(dr, metaData, doJustInfo);
|
||||
if (string.IsNullOrEmpty(artistFolder))
|
||||
{
|
||||
this.Logger.LogWarning("Unable To Find ArtistFolder [{0}] For MetaData [{1}]", artistFolder, metaData.ToString());
|
||||
return new OperationResult<bool>("Unable To Find Artist Folder");
|
||||
}
|
||||
var releaseFolder = await this.DetermineReleaseFolder(artistFolder, metaData, doJustInfo, submissionId);
|
||||
if (string.IsNullOrEmpty(releaseFolder))
|
||||
{
|
||||
this.Logger.LogWarning("Unable To Find ReleaseFolder For MetaData [{0}]", metaData.ToString());
|
||||
return new OperationResult<bool>("Unable To Find Release Folder");
|
||||
}
|
||||
destinationName = FolderPathHelper.TrackFullPath(this.Configuration, metaData, dr, artistFolder);
|
||||
this.Logger.LogTrace("Info: FileInfo [{0}], Artist Folder [{1}], Destination Name [{2}]", fileInfo.FullName, artistFolder, destinationName);
|
||||
|
||||
if (doJustInfo)
|
||||
{
|
||||
result.IsSuccess = metaData.IsValid;
|
||||
return result;
|
||||
}
|
||||
|
||||
PluginBase.CheckMakeFolder(artistFolder);
|
||||
PluginBase.CheckMakeFolder(releaseFolder);
|
||||
|
||||
// See if folder has "cover" image if so then move to release folder for metadata
|
||||
var imageFiles = ImageHelper.ImageFilesInFolder(fileInfo.DirectoryName);
|
||||
if (imageFiles != null && imageFiles.Any())
|
||||
{
|
||||
foreach (var imageFile in imageFiles)
|
||||
{
|
||||
var i = new FileInfo(imageFile);
|
||||
var iName = i.Name.ToLower().Trim();
|
||||
this.Logger.LogDebug("Found Image File [{0}] [{1}]", imageFile, iName);
|
||||
var isCoverArtType = iName.Contains("cover") || iName.Contains("folder") || iName.Contains("front") || iName.Contains("release") || iName.Contains("album");
|
||||
if (isCoverArtType)
|
||||
{
|
||||
var coverFileName = Path.Combine(releaseFolder, Factories.ReleaseFactory.CoverFilename);
|
||||
if (coverFileName != i.FullName)
|
||||
{
|
||||
// Read image and convert to jpeg
|
||||
var imageBytes = File.ReadAllBytes(i.FullName);
|
||||
imageBytes = ImageHelper.ConvertToJpegFormat(imageBytes);
|
||||
|
||||
// Move cover to release folder
|
||||
if (!doJustInfo)
|
||||
{
|
||||
File.WriteAllBytes(coverFileName, imageBytes);
|
||||
i.Delete();
|
||||
}
|
||||
this.Logger.LogDebug("Found Image File [{0}], Moved to release folder", i.Name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var doesFileExistsForTrack = File.Exists(destinationName);
|
||||
if (doesFileExistsForTrack)
|
||||
{
|
||||
var existing = new FileInfo(destinationName);
|
||||
|
||||
// If Exists determine which is better - if same do nothing
|
||||
var existingMetaData = await this.AudioMetaDataHelper.GetInfo(existing, doJustInfo);
|
||||
|
||||
var areSameFile = existing.FullName.Replace("\\", "").Replace("/", "").Equals(fileInfo.FullName.Replace("\\", "").Replace("/", ""), StringComparison.OrdinalIgnoreCase);
|
||||
var currentBitRate = metaData.AudioBitrate;
|
||||
var existingBitRate = existingMetaData.AudioBitrate;
|
||||
|
||||
if (!areSameFile)
|
||||
{
|
||||
if (!existingMetaData.IsValid || (currentBitRate > existingBitRate))
|
||||
{
|
||||
this.Logger.LogTrace("Newer Is Better: Deleting Existing File [{0}]", existing);
|
||||
if (!doJustInfo)
|
||||
{
|
||||
existing.Delete();
|
||||
fileInfo.MoveTo(destinationName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Logger.LogTrace("Existing [{0}] Is Better or Equal: Deleting Found File [{1}]", existing, fileInfo.FullName);
|
||||
this.Logger.LogTrace("Invalid File{3}: ValidWeight [{0}], Under MinWeightToDelete [{1}]. Deleting File [{2}]", metaData.ValidWeight, minWeight, fileInfo.FullName, doJustInfo ? " [Read Only Mode] " : string.Empty);
|
||||
if (!doJustInfo)
|
||||
{
|
||||
fileInfo.Delete();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Logger.LogTrace("Moving File To [{0}]", destinationName);
|
||||
if (!doJustInfo)
|
||||
|
||||
var artist = metaData.Artist.CleanString(this.Configuration);
|
||||
var album = metaData.Release.CleanString(this.Configuration);
|
||||
var title = metaData.Title.CleanString(this.Configuration).ToTitleCase(false);
|
||||
var year = metaData.Year;
|
||||
var trackNumber = metaData.TrackNumber ?? 0;
|
||||
var diskNumber = metaData.Disk ?? 0;
|
||||
|
||||
SimpleContract.Requires(metaData.IsValid, "Track MetaData Invalid");
|
||||
SimpleContract.Requires<ArgumentException>(!string.IsNullOrEmpty(artist), "Missing Track Artist");
|
||||
SimpleContract.Requires<ArgumentException>(!string.IsNullOrEmpty(album), "Missing Track Album");
|
||||
SimpleContract.Requires<ArgumentException>(!string.IsNullOrEmpty(title), "Missing Track Title");
|
||||
SimpleContract.Requires<ArgumentException>(year > 0, string.Format("Invalid Track Year [{0}]", year));
|
||||
SimpleContract.Requires<ArgumentException>(trackNumber > 0, "Missing Track Number");
|
||||
|
||||
var artistFolder = await this.DetermineArtistFolder(dr, metaData, doJustInfo);
|
||||
if (string.IsNullOrEmpty(artistFolder))
|
||||
{
|
||||
fileInfo.MoveTo(destinationName);
|
||||
this.Logger.LogWarning("Unable To Find ArtistFolder [{0}] For MetaData [{1}]", artistFolder, metaData.ToString());
|
||||
return new OperationResult<bool>("Unable To Find Artist Folder");
|
||||
}
|
||||
var releaseFolder = await this.DetermineReleaseFolder(artistFolder, metaData, doJustInfo, submissionId);
|
||||
if (string.IsNullOrEmpty(releaseFolder))
|
||||
{
|
||||
this.Logger.LogWarning("Unable To Find ReleaseFolder For MetaData [{0}]", metaData.ToString());
|
||||
return new OperationResult<bool>("Unable To Find Release Folder");
|
||||
}
|
||||
destinationName = FolderPathHelper.TrackFullPath(this.Configuration, metaData, dr, artistFolder, releaseFolder);
|
||||
this.Logger.LogTrace("Info: FileInfo [{0}], Artist Folder [{1}], Release Folder [{1}], Destination Name [{3}]", fileInfo.FullName, artistFolder, releaseFolder, destinationName);
|
||||
|
||||
if (doJustInfo)
|
||||
{
|
||||
result.IsSuccess = metaData.IsValid;
|
||||
return result;
|
||||
}
|
||||
|
||||
PluginBase.CheckMakeFolder(artistFolder);
|
||||
PluginBase.CheckMakeFolder(releaseFolder);
|
||||
|
||||
// See if folder has "cover" image if so then move to release folder for metadata
|
||||
var imageFiles = ImageHelper.ImageFilesInFolder(fileInfo.DirectoryName);
|
||||
if (imageFiles != null && imageFiles.Any())
|
||||
{
|
||||
foreach (var imageFile in imageFiles)
|
||||
{
|
||||
var i = new FileInfo(imageFile);
|
||||
var iName = i.Name.ToLower().Trim();
|
||||
this.Logger.LogDebug("Found Image File [{0}] [{1}]", imageFile, iName);
|
||||
var isCoverArtType = iName.Contains("cover") || iName.Contains("folder") || iName.Contains("front") || iName.Contains("release") || iName.Contains("album");
|
||||
if (isCoverArtType)
|
||||
{
|
||||
var coverFileName = Path.Combine(releaseFolder, Factories.ReleaseFactory.CoverFilename);
|
||||
if (coverFileName != i.FullName)
|
||||
{
|
||||
// Read image and convert to jpeg
|
||||
var imageBytes = File.ReadAllBytes(i.FullName);
|
||||
imageBytes = ImageHelper.ConvertToJpegFormat(imageBytes);
|
||||
|
||||
// Move cover to release folder
|
||||
if (!doJustInfo)
|
||||
{
|
||||
File.WriteAllBytes(coverFileName, imageBytes);
|
||||
i.Delete();
|
||||
}
|
||||
this.Logger.LogDebug("Found Image File [{0}], Moved to release folder", i.Name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var doesFileExistsForTrack = File.Exists(destinationName);
|
||||
if (doesFileExistsForTrack)
|
||||
{
|
||||
var existing = new FileInfo(destinationName);
|
||||
|
||||
// If Exists determine which is better - if same do nothing
|
||||
var existingMetaData = await this.AudioMetaDataHelper.GetInfo(existing, doJustInfo);
|
||||
|
||||
var areSameFile = existing.FullName.Replace("\\", "").Replace("/", "").Equals(fileInfo.FullName.Replace("\\", "").Replace("/", ""), StringComparison.OrdinalIgnoreCase);
|
||||
var currentBitRate = metaData.AudioBitrate;
|
||||
var existingBitRate = existingMetaData.AudioBitrate;
|
||||
|
||||
if (!areSameFile)
|
||||
{
|
||||
if (!existingMetaData.IsValid || (currentBitRate > existingBitRate))
|
||||
{
|
||||
this.Logger.LogTrace("Newer Is Better: Deleting Existing File [{0}]", existing);
|
||||
if (!doJustInfo)
|
||||
{
|
||||
existing.Delete();
|
||||
fileInfo.MoveTo(destinationName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Logger.LogTrace("Existing [{0}] Is Better or Equal: Deleting Found File [{1}]", existing, fileInfo.FullName);
|
||||
if (!doJustInfo)
|
||||
{
|
||||
fileInfo.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Logger.LogTrace("Moving File To [{0}]", destinationName);
|
||||
if (!doJustInfo)
|
||||
{
|
||||
try
|
||||
{
|
||||
fileInfo.MoveTo(destinationName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Logger.LogError(ex, "Error Moving File [{0}}", destinationName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result.AdditionalData.Add(PluginResultInfo.AdditionalDataKeyPluginResultInfo, new PluginResultInfo
|
||||
{
|
||||
ArtistFolder = artistFolder,
|
||||
ArtistId = this._artistId,
|
||||
ReleaseFolder = releaseFolder,
|
||||
ReleaseId = this._releaseId,
|
||||
Filename = fileInfo.FullName,
|
||||
TrackNumber = metaData.TrackNumber,
|
||||
TrackTitle = metaData.Title
|
||||
});
|
||||
result.IsSuccess = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Logger.LogError(ex, "Error Processing File [{0}}", fileInfo);
|
||||
}
|
||||
|
||||
result.AdditionalData.Add(PluginResultInfo.AdditionalDataKeyPluginResultInfo, new PluginResultInfo
|
||||
{
|
||||
ArtistFolder = artistFolder,
|
||||
ArtistId = this._artistId,
|
||||
ReleaseFolder = releaseFolder,
|
||||
ReleaseId = this._releaseId,
|
||||
Filename = fileInfo.FullName,
|
||||
TrackNumber = metaData.TrackNumber,
|
||||
TrackTitle = metaData.Title
|
||||
});
|
||||
result.IsSuccess = true;
|
||||
sw.Stop();
|
||||
this.Logger.LogTrace("<< Audio: Process Complete. ElapsedTime [{0}]", sw.ElapsedMilliseconds);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ using Roadie.Library.Utility;
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Security.AccessControl;
|
||||
using System.Security.Principal;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Roadie.Library.FilePlugins
|
||||
|
@ -69,10 +71,10 @@ namespace Roadie.Library.FilePlugins
|
|||
if (!Directory.Exists(folder))
|
||||
{
|
||||
Directory.CreateDirectory(folder);
|
||||
Trace.WriteLine(string.Format("Created Directory [{0}]", folder));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public abstract Task<OperationResult<bool>> Process(string destinationRoot, FileInfo fileInfo, bool doJustInfo, int? submissionId);
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CsvHelper" Version="12.1.1" />
|
||||
<PackageReference Include="EFCore.BulkExtensions" Version="2.3.7" />
|
||||
<PackageReference Include="FluentFTP" Version="19.2.3" />
|
||||
<PackageReference Include="CsvHelper" Version="12.1.2" />
|
||||
<PackageReference Include="EFCore.BulkExtensions" Version="2.3.8" />
|
||||
<PackageReference Include="FluentFTP" Version="19.2.4" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.8.14" />
|
||||
<PackageReference Include="IdSharp.Common" Version="1.0.1" />
|
||||
<PackageReference Include="IdSharp.Tagging" Version="1.0.0-rc3" />
|
||||
<PackageReference Include="Inflatable.Lastfm" Version="1.1.0.339" />
|
||||
<PackageReference Include="Mapster" Version="3.2.0" />
|
||||
<PackageReference Include="Mapster" Version="3.3.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Redis" Version="2.2.0" />
|
||||
|
@ -26,6 +26,7 @@
|
|||
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-beta0005" />
|
||||
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta0005" />
|
||||
<PackageReference Include="SixLabors.Shapes" Version="1.0.0-beta0007" />
|
||||
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="4.5.0" />
|
||||
<PackageReference Include="System.Runtime.Caching" Version="4.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -154,9 +154,13 @@ namespace Roadie.Library.Utility
|
|||
/// <param name="metaData">Populated Track MetaData</param>
|
||||
/// <param name="destinationFolder">Optional Root folder defaults to Library Folder from Settings</param>
|
||||
/// <param name="artistFolder">Optional ArtistFolder default is to get from MetaData artist</param>
|
||||
public static string TrackFullPath(IRoadieSettings configuration, AudioMetaData metaData, string destinationFolder = null, string artistFolder = null)
|
||||
public static string TrackFullPath(IRoadieSettings configuration, AudioMetaData metaData, string destinationFolder = null, string artistFolder = null, string releaseFolder = null)
|
||||
{
|
||||
return FolderPathHelper.TrackFullPath(configuration, metaData.Artist, metaData.Release, SafeParser.ToDateTime(metaData.Year).Value, metaData.Title, metaData.TrackNumber ?? 0, destinationFolder, metaData.Disk ?? 0, metaData.TotalTrackNumbers ?? 0, artistFolder: artistFolder);
|
||||
return FolderPathHelper.TrackFullPath(configuration, metaData.Artist, metaData.Release, SafeParser.ToDateTime(metaData.Year).Value,
|
||||
metaData.Title, metaData.TrackNumber ?? 0, destinationFolder, metaData.Disk ?? 0,
|
||||
metaData.TotalTrackNumbers ?? 0,
|
||||
artistFolder: artistFolder,
|
||||
releaseFolder: releaseFolder);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -183,15 +187,15 @@ namespace Roadie.Library.Utility
|
|||
/// <param name="diskNumber">Optional disk number defaults to 0</param>
|
||||
/// <param name="totalTrackNumber">Optional Total Tracks defaults to TrackNumber</param>
|
||||
/// <param name="fileExtension">Optional File Extension defaults to mp3</param>
|
||||
public static string TrackFullPath(IRoadieSettings configuration, string artistSortName, string releaseTitle, DateTime releaseDate, string trackTitle, short trackNumber, string destinationFolder = null, int? diskNumber = null, int? totalTrackNumber = null, string fileExtension = "mp3", string artistFolder = null)
|
||||
public static string TrackFullPath(IRoadieSettings configuration, string artistSortName, string releaseTitle, DateTime releaseDate, string trackTitle, short trackNumber, string destinationFolder = null, int? diskNumber = null, int? totalTrackNumber = null, string fileExtension = "mp3", string artistFolder = null, string releaseFolder = null)
|
||||
{
|
||||
destinationFolder = destinationFolder ?? configuration.LibraryFolder;
|
||||
artistFolder = artistFolder ?? FolderPathHelper.ArtistPath(configuration, artistSortName, destinationFolder);
|
||||
var releaseFolder = FolderPathHelper.ReleasePath(artistFolder, releaseTitle, releaseDate);
|
||||
releaseFolder = releaseFolder ?? FolderPathHelper.ReleasePath(artistFolder, releaseTitle, releaseDate);
|
||||
var trackFileName = FolderPathHelper.TrackFileName(configuration, trackTitle, trackNumber, diskNumber, totalTrackNumber, fileExtension);
|
||||
|
||||
var result = Path.Combine(artistFolder, releaseFolder, trackFileName);
|
||||
Trace.WriteLine(string.Format("TrackPath [{0}] For ArtistName [{1}], ReleaseTitle [{2}], ReleaseDate [{3}], TrackNumber [{4}]", result, artistSortName, releaseTitle, releaseDate, trackNumber));
|
||||
Trace.WriteLine(string.Format("TrackPath [{0}] For ArtistName [{1}], ReleaseTitle [{2}], ReleaseDate [{3}], ReleaseYear [{4}], TrackNumber [{5}]", result, artistSortName, releaseTitle, releaseDate.ToString("s"), releaseDate.ToString("yyyy"), trackNumber));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
}
|
||||
|
||||
public Task<Library.Models.Pagination.PagedResult<ArtistList>> List(User roadieUser, PagedRequest request, bool? doRandomize = false, bool? onlyIncludeWithReleases = true)
|
||||
public async Task<Library.Models.Pagination.PagedResult<ArtistList>> List(User roadieUser, PagedRequest request, bool? doRandomize = false, bool? onlyIncludeWithReleases = true)
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
@ -258,14 +258,25 @@ namespace Roadie.Api.Services
|
|||
}
|
||||
}
|
||||
sw.Stop();
|
||||
return Task.FromResult(new Library.Models.Pagination.PagedResult<ArtistList>
|
||||
if(!string.IsNullOrEmpty(request.Filter) && rowCount == 0)
|
||||
{
|
||||
// Create request for no artist found
|
||||
var req = new data.Request
|
||||
{
|
||||
UserId = roadieUser?.Id,
|
||||
Description = request.Filter
|
||||
};
|
||||
this.DbContext.Requests.Add(req);
|
||||
await this.DbContext.SaveChangesAsync();
|
||||
}
|
||||
return new Library.Models.Pagination.PagedResult<ArtistList>
|
||||
{
|
||||
TotalCount = rowCount,
|
||||
CurrentPage = request.PageValue,
|
||||
TotalPages = (int)Math.Ceiling((double)rowCount / request.LimitValue),
|
||||
OperationTime = sw.ElapsedMilliseconds,
|
||||
Rows = rows
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<OperationResult<bool>> ScanArtistReleasesFolders(Guid artistId, string destinationFolder, bool doJustInfo)
|
||||
|
|
|
@ -53,12 +53,19 @@ namespace Roadie.Api.Controllers
|
|||
}, ControllerCacheRegionUrn);
|
||||
}
|
||||
}
|
||||
if(this._currentUser == null)
|
||||
{
|
||||
throw new Exception("Access Denied");
|
||||
}
|
||||
return this._currentUser;
|
||||
}
|
||||
|
||||
protected models.User UserModelForUser(ApplicationUser user)
|
||||
{
|
||||
|
||||
if(user == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var result = user.Adapt<models.User>();
|
||||
result.IsAdmin = User.IsInRole("Admin");
|
||||
result.IsEditor = User.IsInRole("Editor") || result.IsAdmin;
|
||||
|
|
|
@ -14,7 +14,7 @@ by editing this MSBuild file. In order to learn more about this please visit htt
|
|||
<ExcludeApp_Data>False</ExcludeApp_Data>
|
||||
<ProjectGuid>68c80416-0d72-409d-b727-3fea7ab7fd2c</ProjectGuid>
|
||||
<publishUrl>bin\x64\Debug\netcoreapp2.2\publish\</publishUrl>
|
||||
<DeleteExistingFiles>False</DeleteExistingFiles>
|
||||
<DeleteExistingFiles>True</DeleteExistingFiles>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<SelfContained>false</SelfContained>
|
||||
<_IsPortable>true</_IsPortable>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"Roadie.Api": {
|
||||
"commandName": "Project",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Production"
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "http://localhost:5123/"
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BCrypt-Core" Version="2.0.0" />
|
||||
<PackageReference Include="Mapster" Version="3.2.0" />
|
||||
<PackageReference Include="Mapster" Version="3.3.0" />
|
||||
<PackageReference Include="Microsoft.AspNet.SignalR" Version="2.4.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.All" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OData" Version="7.1.0" />
|
||||
|
|
12
Roadie.sln
12
Roadie.sln
|
@ -48,24 +48,24 @@ Global
|
|||
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Debug|x64.Build.0 = Debug|x64
|
||||
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Release|x64.Build.0 = Release|Any CPU
|
||||
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Release|x64.ActiveCfg = Release|x64
|
||||
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Release|x64.Build.0 = Release|x64
|
||||
{7B37031E-F2AE-4BE2-9F6F-005CA7A6FDF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7B37031E-F2AE-4BE2-9F6F-005CA7A6FDF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7B37031E-F2AE-4BE2-9F6F-005CA7A6FDF1}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{7B37031E-F2AE-4BE2-9F6F-005CA7A6FDF1}.Debug|x64.Build.0 = Debug|x64
|
||||
{7B37031E-F2AE-4BE2-9F6F-005CA7A6FDF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7B37031E-F2AE-4BE2-9F6F-005CA7A6FDF1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7B37031E-F2AE-4BE2-9F6F-005CA7A6FDF1}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{7B37031E-F2AE-4BE2-9F6F-005CA7A6FDF1}.Release|x64.Build.0 = Release|Any CPU
|
||||
{7B37031E-F2AE-4BE2-9F6F-005CA7A6FDF1}.Release|x64.ActiveCfg = Release|x64
|
||||
{7B37031E-F2AE-4BE2-9F6F-005CA7A6FDF1}.Release|x64.Build.0 = Release|x64
|
||||
{E740C89E-3363-4577-873B-0871823E252C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E740C89E-3363-4577-873B-0871823E252C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E740C89E-3363-4577-873B-0871823E252C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{E740C89E-3363-4577-873B-0871823E252C}.Debug|x64.Build.0 = Debug|x64
|
||||
{E740C89E-3363-4577-873B-0871823E252C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E740C89E-3363-4577-873B-0871823E252C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E740C89E-3363-4577-873B-0871823E252C}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{E740C89E-3363-4577-873B-0871823E252C}.Release|x64.Build.0 = Release|Any CPU
|
||||
{E740C89E-3363-4577-873B-0871823E252C}.Release|x64.ActiveCfg = Release|x64
|
||||
{E740C89E-3363-4577-873B-0871823E252C}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
Loading…
Reference in a new issue