mirror of
https://github.com/sphildreth/roadie
synced 2024-11-24 21:23:24 +00:00
Updated NuGet pacakges.
This commit is contained in:
parent
bc227db418
commit
3a6a1ba630
22 changed files with 271 additions and 251 deletions
|
@ -21,8 +21,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.5.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.1" />
|
||||
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="3.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
gci -Path "N:\_complete" -r -include *.zip,*.rar,*.7z | foreach { & 'C:\Program Files\7-Zip\7z.exe' x $_.FullName -y -o"$('"'+$_.DirectoryName+'"')"}
|
||||
Remove-Item –path N:\_complete -include *.7z,*.zip,*.rar -recurse
|
||||
gci -Path "G:\_complete" -r -include *.zip,*.rar,*.7z | foreach { & 'C:\Program Files\7-Zip\7z.exe' x $_.FullName -y -o"$('"'+$_.DirectoryName+'"')"}
|
||||
Remove-Item –path G:\_complete -include *.7z,*.zip,*.rar -recurse
|
|
@ -2,7 +2,7 @@
|
|||
"profiles": {
|
||||
"Inspector": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "-f \"N:\\_complete\" -d \"M:\\inbound\""
|
||||
"commandLineArgs": "-f \"G:\\_complete\\_\" -d \"M:\\inbound\""
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,8 +23,8 @@
|
|||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace Roadie.Library.Engines
|
|||
try
|
||||
{
|
||||
var artistGenreTables = artist.Genres;
|
||||
var artistImages = artist.Images ?? new List<Library.Imaging.Image>();
|
||||
var artistImages = artist.Images ?? new List<Image>();
|
||||
var now = DateTime.UtcNow;
|
||||
artist.AlternateNames = artist.AlternateNames.AddToDelimitedList(new[] { artist.Name.ToAlphanumericName() });
|
||||
artist.Genres = null;
|
||||
|
@ -82,45 +82,41 @@ namespace Roadie.Library.Engines
|
|||
};
|
||||
}
|
||||
var addArtistResult = DbContext.Artists.Add(artist);
|
||||
var inserted = 0;
|
||||
inserted = await DbContext.SaveChangesAsync();
|
||||
var inserted = await DbContext.SaveChangesAsync().ConfigureAwait(false);
|
||||
_addedArtistIds.Add(artist.Id);
|
||||
if (artist.Id < 1 && addArtistResult.Entity.Id > 0) artist.Id = addArtistResult.Entity.Id;
|
||||
if (inserted > 0 && artist.Id > 0)
|
||||
{
|
||||
if (artistGenreTables != null)
|
||||
{
|
||||
if (artistGenreTables != null)
|
||||
foreach (var artistGenreTable in artistGenreTables.Where(x => x?.Genre?.Name != null).Select(x => x.Genre?.Name).Distinct())
|
||||
{
|
||||
foreach (var artistGenreTable in artistGenreTables.Where(x => x?.Genre?.Name != null).Select(x => x.Genre?.Name).Distinct())
|
||||
var genreName = artistGenreTable.ToAlphanumericName().ToTitleCase();
|
||||
var normalizedName = genreName.ToUpper();
|
||||
if (string.IsNullOrEmpty(genreName)) continue;
|
||||
if (genreName.Length > 100)
|
||||
{
|
||||
var genreName = artistGenreTable.ToAlphanumericName().ToTitleCase();
|
||||
var normalizedName = genreName.ToUpper();
|
||||
if (string.IsNullOrEmpty(genreName)) continue;
|
||||
if (genreName.Length > 100)
|
||||
{
|
||||
var originalName = genreName;
|
||||
genreName = genreName.Substring(0, 99);
|
||||
Logger.LogWarning($"Genre Name Too long was [{originalName}] truncated to [{genreName}]");
|
||||
}
|
||||
var genre = DbContext.Genres.FirstOrDefault(x => x.NormalizedName == normalizedName);
|
||||
if (genre == null)
|
||||
{
|
||||
genre = new Genre
|
||||
{
|
||||
Name = genreName,
|
||||
NormalizedName = normalizedName
|
||||
};
|
||||
DbContext.Genres.Add(genre);
|
||||
await DbContext.SaveChangesAsync();
|
||||
}
|
||||
DbContext.ArtistGenres.Add(new ArtistGenre
|
||||
{
|
||||
ArtistId = artist.Id,
|
||||
GenreId = genre.Id
|
||||
});
|
||||
await DbContext.SaveChangesAsync();
|
||||
var originalName = genreName;
|
||||
genreName = genreName.Substring(0, 99);
|
||||
Logger.LogWarning($"Genre Name Too long was [{originalName}] truncated to [{genreName}]");
|
||||
}
|
||||
var genre = DbContext.Genres.FirstOrDefault(x => x.NormalizedName == normalizedName);
|
||||
if (genre == null)
|
||||
{
|
||||
genre = new Genre
|
||||
{
|
||||
Name = genreName,
|
||||
NormalizedName = normalizedName
|
||||
};
|
||||
DbContext.Genres.Add(genre);
|
||||
await DbContext.SaveChangesAsync().ConfigureAwait(false);
|
||||
}
|
||||
DbContext.ArtistGenres.Add(new ArtistGenre
|
||||
{
|
||||
ArtistId = artist.Id,
|
||||
GenreId = genre.Id
|
||||
});
|
||||
await DbContext.SaveChangesAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,7 +127,7 @@ namespace Roadie.Library.Engines
|
|||
string releaseImageFilename;
|
||||
foreach (var artistImage in artistImages)
|
||||
{
|
||||
if (artistImage?.Bytes == null || artistImage?.Bytes.Any() == false)
|
||||
if (!(artistImage?.Bytes.Length > 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -177,7 +173,6 @@ namespace Roadie.Library.Engines
|
|||
}
|
||||
try
|
||||
{
|
||||
|
||||
var searchName = name.NormalizeName().ToLower();
|
||||
var searchSortName = !string.IsNullOrEmpty(sortName) ? sortName.NormalizeName().ToLower() : searchName;
|
||||
var specialSearchName = name.ToAlphanumericName();
|
||||
|
@ -191,21 +186,21 @@ namespace Roadie.Library.Engines
|
|||
var specialSearchNameEnd = $"|{specialSearchName}";
|
||||
|
||||
return await (from a in DbContext.Artists
|
||||
where a.Name.ToLower() == searchName ||
|
||||
a.Name.ToLower() == specialSearchName ||
|
||||
a.SortName.ToLower() == searchName ||
|
||||
a.SortName.ToLower() == searchSortName ||
|
||||
a.SortName.ToLower() == specialSearchName ||
|
||||
a.AlternateNames.ToLower().Equals(searchName) ||
|
||||
a.AlternateNames.ToLower().StartsWith(searchNameStart) ||
|
||||
a.AlternateNames.ToLower().Contains(searchNameIn) ||
|
||||
a.AlternateNames.ToLower().EndsWith(searchNameEnd) ||
|
||||
a.AlternateNames.ToLower().Equals(specialSearchName) ||
|
||||
a.AlternateNames.ToLower().StartsWith(specialSearchNameStart) ||
|
||||
a.AlternateNames.ToLower().Contains(specialSearchNameIn) ||
|
||||
a.AlternateNames.ToLower().EndsWith(specialSearchNameEnd)
|
||||
select a
|
||||
).ToArrayAsync();
|
||||
where a.Name.ToLower() == searchName ||
|
||||
a.Name.ToLower() == specialSearchName ||
|
||||
a.SortName.ToLower() == searchName ||
|
||||
a.SortName.ToLower() == searchSortName ||
|
||||
a.SortName.ToLower() == specialSearchName ||
|
||||
a.AlternateNames.ToLower().Equals(searchName) ||
|
||||
a.AlternateNames.ToLower().StartsWith(searchNameStart) ||
|
||||
a.AlternateNames.ToLower().Contains(searchNameIn) ||
|
||||
a.AlternateNames.ToLower().EndsWith(searchNameEnd) ||
|
||||
a.AlternateNames.ToLower().Equals(specialSearchName) ||
|
||||
a.AlternateNames.ToLower().StartsWith(specialSearchNameStart) ||
|
||||
a.AlternateNames.ToLower().Contains(specialSearchNameIn) ||
|
||||
a.AlternateNames.ToLower().EndsWith(specialSearchNameEnd)
|
||||
select a
|
||||
).ToArrayAsync().ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -236,9 +231,9 @@ namespace Roadie.Library.Engines
|
|||
};
|
||||
}
|
||||
|
||||
var artist = (await DatabaseQueryForArtistName(artistName)).FirstOrDefault();
|
||||
var artist = (await DatabaseQueryForArtistName(artistName).ConfigureAwait(false)).FirstOrDefault();
|
||||
sw.Stop();
|
||||
if (artist == null || !artist.IsValid)
|
||||
if (artist?.IsValid != true)
|
||||
{
|
||||
Logger.LogTrace("ArtistLookupEngine: Artist Not Found By Name [{0}]", artistName);
|
||||
if (doFindIfNotInDatabase)
|
||||
|
@ -257,7 +252,7 @@ namespace Roadie.Library.Engines
|
|||
if (!string.IsNullOrEmpty(releaseRoadieDataFilename) && File.Exists(releaseRoadieDataFilename))
|
||||
{
|
||||
artist = JsonConvert.DeserializeObject<Artist>(File.ReadAllText(releaseRoadieDataFilename));
|
||||
var addResult = await Add(artist);
|
||||
var addResult = await Add(artist).ConfigureAwait(false);
|
||||
if (!addResult.IsSuccess)
|
||||
{
|
||||
sw.Stop();
|
||||
|
@ -267,7 +262,8 @@ namespace Roadie.Library.Engines
|
|||
OperationTime = sw.ElapsedMilliseconds,
|
||||
Errors = addResult.Errors
|
||||
};
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
File.Delete(releaseRoadieDataFilename);
|
||||
}
|
||||
|
@ -277,20 +273,19 @@ namespace Roadie.Library.Engines
|
|||
{
|
||||
try
|
||||
{
|
||||
artistSearch = await PerformMetaDataProvidersArtistSearch(metaData);
|
||||
artistSearch = await PerformMetaDataProvidersArtistSearch(metaData).ConfigureAwait(false);
|
||||
if (artistSearch.IsSuccess)
|
||||
{
|
||||
artist = artistSearch.Data;
|
||||
// See if Artist already exist with either Name or Sort Name
|
||||
var alreadyExists = (await DatabaseQueryForArtistName(artistSearch.Data.Name, artistSearch.Data.SortNameValue)).FirstOrDefault();
|
||||
if (alreadyExists == null || !alreadyExists.IsValid)
|
||||
var alreadyExists = (await DatabaseQueryForArtistName(artistSearch.Data.Name, artistSearch.Data.SortNameValue).ConfigureAwait(false)).FirstOrDefault();
|
||||
if (alreadyExists?.IsValid != true)
|
||||
{
|
||||
var addResult = await Add(artist);
|
||||
var addResult = await Add(artist).ConfigureAwait(false);
|
||||
if (!addResult.IsSuccess)
|
||||
{
|
||||
sw.Stop();
|
||||
Logger.LogWarning("Unable To Add Artist For MetaData [{0}]",
|
||||
metaData.ToString());
|
||||
Logger.LogWarning("Unable To Add Artist For MetaData [{0}]", metaData.ToString());
|
||||
return new OperationResult<Artist>
|
||||
{
|
||||
OperationTime = sw.ElapsedMilliseconds,
|
||||
|
@ -314,7 +309,10 @@ namespace Roadie.Library.Engines
|
|||
}
|
||||
}
|
||||
|
||||
if (artist != null && artist.IsValid) CacheManager.Add(cacheKey, artist);
|
||||
if (artist?.IsValid == true)
|
||||
{
|
||||
CacheManager.Add(cacheKey, artist);
|
||||
}
|
||||
return new OperationResult<Artist>
|
||||
{
|
||||
IsSuccess = artist != null,
|
||||
|
@ -351,7 +349,7 @@ namespace Roadie.Library.Engines
|
|||
if (ITunesArtistSearchEngine.IsEnabled)
|
||||
{
|
||||
var sw2 = Stopwatch.StartNew();
|
||||
var iTunesResult = await ITunesArtistSearchEngine.PerformArtistSearch(artistName, 1);
|
||||
var iTunesResult = await ITunesArtistSearchEngine.PerformArtistSearch(artistName, 1).ConfigureAwait(false);
|
||||
if (iTunesResult.IsSuccess)
|
||||
{
|
||||
var i = iTunesResult.Data.First();
|
||||
|
@ -408,7 +406,7 @@ namespace Roadie.Library.Engines
|
|||
if (MusicBrainzArtistSearchEngine.IsEnabled)
|
||||
{
|
||||
var sw2 = Stopwatch.StartNew();
|
||||
var mbResult = await MusicBrainzArtistSearchEngine.PerformArtistSearch(result.Name, 1);
|
||||
var mbResult = await MusicBrainzArtistSearchEngine.PerformArtistSearch(result.Name, 1).ConfigureAwait(false);
|
||||
if (mbResult.IsSuccess)
|
||||
{
|
||||
var mb = mbResult.Data.First();
|
||||
|
@ -447,6 +445,10 @@ namespace Roadie.Library.Engines
|
|||
BioContext = mb.Bio,
|
||||
Profile = mb.Profile,
|
||||
MusicBrainzId = mb.MusicBrainzId,
|
||||
DiscogsId = mb.DiscogsId,
|
||||
SpotifyId = mb.SpotifyId,
|
||||
ITunesId = mb.iTunesId,
|
||||
AmgId = mb.AmgId,
|
||||
BeginDate = mb.BeginDate,
|
||||
Name = result.Name ?? mb.ArtistName,
|
||||
SortName = result.SortName ?? mb.ArtistSortName,
|
||||
|
@ -469,7 +471,7 @@ namespace Roadie.Library.Engines
|
|||
if (LastFmArtistSearchEngine.IsEnabled)
|
||||
{
|
||||
var sw2 = Stopwatch.StartNew();
|
||||
var lastFmResult = await LastFmArtistSearchEngine.PerformArtistSearch(result.Name, 1);
|
||||
var lastFmResult = await LastFmArtistSearchEngine.PerformArtistSearch(result.Name, 1).ConfigureAwait(false);
|
||||
if (lastFmResult.IsSuccess)
|
||||
{
|
||||
var l = lastFmResult.Data.First();
|
||||
|
@ -482,7 +484,9 @@ namespace Roadie.Library.Engines
|
|||
if (l.ArtistGenres != null) artistGenres.AddRange(l.ArtistGenres);
|
||||
if (!string.IsNullOrEmpty(l.ArtistName) &&
|
||||
!l.ArtistName.Equals(result.Name, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
result.AlternateNames.AddToDelimitedList(new[] { l.ArtistName });
|
||||
}
|
||||
result.CopyTo(new Artist
|
||||
{
|
||||
EndDate = l.EndDate,
|
||||
|
@ -511,7 +515,7 @@ namespace Roadie.Library.Engines
|
|||
if (SpotifyArtistSearchEngine.IsEnabled)
|
||||
{
|
||||
var sw2 = Stopwatch.StartNew();
|
||||
var spotifyResult = await SpotifyArtistSearchEngine.PerformArtistSearch(result.Name, 1);
|
||||
var spotifyResult = await SpotifyArtistSearchEngine.PerformArtistSearch(result.Name, 1).ConfigureAwait(false);
|
||||
if (spotifyResult.IsSuccess)
|
||||
{
|
||||
var s = spotifyResult.Data.First();
|
||||
|
@ -521,13 +525,16 @@ namespace Roadie.Library.Engines
|
|||
if (s.ArtistGenres != null) artistGenres.AddRange(s.ArtistGenres);
|
||||
if (!string.IsNullOrEmpty(s.ArtistName) &&
|
||||
!s.ArtistName.Equals(result.Name, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
result.AlternateNames.AddToDelimitedList(new[] { s.ArtistName });
|
||||
}
|
||||
result.CopyTo(new Artist
|
||||
{
|
||||
EndDate = s.EndDate,
|
||||
BioContext = s.Bio,
|
||||
Profile = HttpEncoder.HtmlEncode(s.Profile),
|
||||
MusicBrainzId = s.MusicBrainzId,
|
||||
SpotifyId = s.SpotifyId,
|
||||
BeginDate = s.BeginDate,
|
||||
Name = result.Name ?? s.ArtistName,
|
||||
SortName = result.SortName ?? s.ArtistSortName,
|
||||
|
@ -550,7 +557,7 @@ namespace Roadie.Library.Engines
|
|||
if (DiscogsArtistSearchEngine.IsEnabled)
|
||||
{
|
||||
var sw2 = Stopwatch.StartNew();
|
||||
var discogsResult = await DiscogsArtistSearchEngine.PerformArtistSearch(result.Name, 1);
|
||||
var discogsResult = await DiscogsArtistSearchEngine.PerformArtistSearch(result.Name, 1).ConfigureAwait(false);
|
||||
if (discogsResult.IsSuccess)
|
||||
{
|
||||
var d = discogsResult?.Data?.FirstOrDefault();
|
||||
|
@ -607,7 +614,7 @@ namespace Roadie.Library.Engines
|
|||
{
|
||||
wikiName += " band";
|
||||
}
|
||||
var wikipediaResult = await WikipediaArtistSearchEngine.PerformArtistSearch(wikiName, 1);
|
||||
var wikipediaResult = await WikipediaArtistSearchEngine.PerformArtistSearch(wikiName, 1).ConfigureAwait(false);
|
||||
if (wikipediaResult?.Data != null)
|
||||
{
|
||||
if (wikipediaResult.IsSuccess)
|
||||
|
@ -647,7 +654,7 @@ namespace Roadie.Library.Engines
|
|||
{
|
||||
result.Tags = string.Join("|", result.Tags.ToListFromDelimited().Distinct().OrderBy(x => x));
|
||||
}
|
||||
if (artistGenres.Any())
|
||||
if (artistGenres.Count > 0)
|
||||
{
|
||||
var sw2 = Stopwatch.StartNew();
|
||||
var genreInfos = from ag in artistGenres
|
||||
|
@ -663,7 +670,7 @@ namespace Roadie.Library.Engines
|
|||
{
|
||||
var ag = new ArtistGenre
|
||||
{
|
||||
Genre = genreInfo.existingGenre != null ? genreInfo.existingGenre : new Genre
|
||||
Genre = genreInfo.existingGenre ?? new Genre
|
||||
{
|
||||
Name = genreInfo.newGenre,
|
||||
NormalizedName = genreInfo.newGenre.ToAlphanumericName()
|
||||
|
@ -678,16 +685,13 @@ namespace Roadie.Library.Engines
|
|||
Logger.LogTrace($"PerformMetaDataProvidersArtistSearch: Artist Genre Processing Complete [{ sw2.ElapsedMilliseconds }]");
|
||||
}
|
||||
|
||||
if (artistImageUrls.Any())
|
||||
if (artistImageUrls.Count > 0)
|
||||
{
|
||||
var sw2 = Stopwatch.StartNew();
|
||||
var imageBag = new ConcurrentBag<IImage>();
|
||||
var i = artistImageUrls.Select(async url =>
|
||||
{
|
||||
imageBag.Add(await WebHelper.GetImageFromUrlAsync(url));
|
||||
});
|
||||
await Task.WhenAll(i);
|
||||
result.Images = imageBag.Where(x => x != null && x.Bytes != null)
|
||||
var i = artistImageUrls.Select(async url => imageBag.Add(await WebHelper.GetImageFromUrlAsync(url).ConfigureAwait(false)));
|
||||
await Task.WhenAll(i).ConfigureAwait(false);
|
||||
result.Images = imageBag.Where(x => x?.Bytes != null)
|
||||
.GroupBy(x => x.Signature)
|
||||
.Select(x => x.First())
|
||||
.Take(Configuration.Processing.MaximumArtistImagesToAdd)
|
||||
|
@ -703,6 +707,7 @@ namespace Roadie.Library.Engines
|
|||
|
||||
result.SortName = result.SortName.ToTitleCase();
|
||||
if (!string.IsNullOrEmpty(result.ArtistType))
|
||||
{
|
||||
switch (result.ArtistType.ToLower().Replace('-', ' '))
|
||||
{
|
||||
case "artist":
|
||||
|
@ -747,6 +752,7 @@ namespace Roadie.Library.Engines
|
|||
result.ArtistType = "Other";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sw.Stop();
|
||||
return new OperationResult<Artist>
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace Roadie.Library.Engines
|
|||
IArtistSearchEngine WikipediaArtistSearchEngine { get; }
|
||||
|
||||
Task<OperationResult<Artist>> Add(Artist artist);
|
||||
|
||||
/// <summary>
|
||||
/// There can be more than one Artist matching the given name with Alternate and Normalized Name matching
|
||||
/// </summary>
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace Roadie.Library.Engines
|
|||
var inserted = 0;
|
||||
try
|
||||
{
|
||||
inserted = await DbContext.SaveChangesAsync();
|
||||
inserted = await DbContext.SaveChangesAsync().ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -95,7 +95,7 @@ namespace Roadie.Library.Engines
|
|||
select l
|
||||
).FirstOrDefault();
|
||||
sw.Stop();
|
||||
if (label == null || !label.IsValid)
|
||||
if (label?.IsValid != true)
|
||||
{
|
||||
Logger.LogTrace("LabelFactory: Label Not Found By Name [{0}]", labelName);
|
||||
if (doFindIfNotInDatabase)
|
||||
|
@ -103,7 +103,7 @@ namespace Roadie.Library.Engines
|
|||
OperationResult<Label> LabelSearch = null;
|
||||
try
|
||||
{
|
||||
LabelSearch = await PerformMetaDataProvidersLabelSearch(labelName);
|
||||
LabelSearch = await PerformMetaDataProvidersLabelSearch(labelName).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ namespace Roadie.Library.Engines
|
|||
if (LabelSearch.IsSuccess)
|
||||
{
|
||||
label = LabelSearch.Data;
|
||||
var addResult = await Add(label);
|
||||
var addResult = await Add(label).ConfigureAwait(false);
|
||||
if (!addResult.IsSuccess)
|
||||
{
|
||||
sw.Stop();
|
||||
|
@ -160,7 +160,7 @@ namespace Roadie.Library.Engines
|
|||
|
||||
if (DiscogsLabelSearchEngine.IsEnabled)
|
||||
{
|
||||
var discogsResult = await DiscogsLabelSearchEngine.PerformLabelSearch(result.Name, 1);
|
||||
var discogsResult = await DiscogsLabelSearchEngine.PerformLabelSearch(result.Name, 1).ConfigureAwait(false);
|
||||
if (discogsResult.IsSuccess)
|
||||
{
|
||||
var d = discogsResult.Data.First();
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using Microsoft.Extensions.Logging;
|
||||
using Roadie.Library.Caching;
|
||||
using Roadie.Library.Configuration;
|
||||
using Roadie.Library.Data;
|
||||
using Roadie.Library.Data.Context;
|
||||
using Roadie.Library.Encoding;
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ namespace Roadie.Library.Engines
|
|||
release.Genres = null;
|
||||
release.LibraryStatus = LibraryStatus.Incomplete;
|
||||
release.Status = Statuses.New;
|
||||
var releaseImages = release.Images ?? new List<Library.Imaging.Image>();
|
||||
var releaseImages = release.Images ?? new List<Image>();
|
||||
if (!release.IsValid)
|
||||
{
|
||||
return new OperationResult<Release>
|
||||
|
@ -100,7 +100,7 @@ namespace Roadie.Library.Engines
|
|||
var inserted = 0;
|
||||
try
|
||||
{
|
||||
inserted = await DbContext.SaveChangesAsync();
|
||||
inserted = await DbContext.SaveChangesAsync().ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -132,14 +132,14 @@ namespace Roadie.Library.Engines
|
|||
NormalizedName = normalizedName
|
||||
};
|
||||
DbContext.Genres.Add(genre);
|
||||
await DbContext.SaveChangesAsync();
|
||||
await DbContext.SaveChangesAsync().ConfigureAwait(false);
|
||||
}
|
||||
DbContext.ReleaseGenres.Add(new ReleaseGenre
|
||||
{
|
||||
ReleaseId = release.Id,
|
||||
GenreId = genre.Id
|
||||
});
|
||||
await DbContext.SaveChangesAsync();
|
||||
await DbContext.SaveChangesAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ namespace Roadie.Library.Engines
|
|||
string releaseImageFilename;
|
||||
foreach (var releaseImage in releaseImages)
|
||||
{
|
||||
if(releaseImage?.Bytes == null || releaseImage?.Bytes.Any() == false)
|
||||
if (releaseImage?.Bytes == null || !(releaseImage?.Bytes.Length > 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -168,19 +168,20 @@ namespace Roadie.Library.Engines
|
|||
while (File.Exists(releaseImageFilename))
|
||||
{
|
||||
looper++;
|
||||
releaseImageFilename = Path.Combine(releaseFolder,string.Format(ImageHelper.ReleaseSecondaryImageFilename, looper.ToString("00")));
|
||||
releaseImageFilename = Path.Combine(releaseFolder, string.Format(ImageHelper.ReleaseSecondaryImageFilename, looper.ToString("00")));
|
||||
}
|
||||
File.WriteAllBytes(releaseImageFilename, releaseImage.Bytes);
|
||||
looper++;
|
||||
}
|
||||
}
|
||||
|
||||
if (releaseLabels != null && releaseLabels.Any(x => x.Status == Statuses.New))
|
||||
if (releaseLabels?.Any(x => x.Status == Statuses.New) == true)
|
||||
{
|
||||
foreach (var neweleaseLabel in releaseLabels.Where(x => x.Status == Statuses.New))
|
||||
{
|
||||
var labelFetch = await LabelLookupEngine.GetByName(neweleaseLabel.Label.Name, true);
|
||||
var labelFetch = await LabelLookupEngine.GetByName(neweleaseLabel.Label.Name, true).ConfigureAwait(false);
|
||||
if (labelFetch.IsSuccess)
|
||||
{
|
||||
DbContext.ReleaseLabels.Add(new ReleaseLabel
|
||||
{
|
||||
CatalogNumber = neweleaseLabel.CatalogNumber,
|
||||
|
@ -189,11 +190,12 @@ namespace Roadie.Library.Engines
|
|||
ReleaseId = release.Id,
|
||||
LabelId = labelFetch.Data.Id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await DbContext.SaveChangesAsync();
|
||||
await DbContext.SaveChangesAsync().ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -203,7 +205,7 @@ namespace Roadie.Library.Engines
|
|||
|
||||
if (doAddTracksInDatabase)
|
||||
{
|
||||
if (releaseMedias != null && releaseMedias.Any(x => x.Status == Statuses.New))
|
||||
if (releaseMedias?.Any(x => x.Status == Statuses.New) == true)
|
||||
{
|
||||
foreach (var newReleaseMedia in releaseMedias.Where(x => x.Status == Statuses.New))
|
||||
{
|
||||
|
@ -224,13 +226,13 @@ namespace Roadie.Library.Engines
|
|||
{
|
||||
if (!release.IsCastRecording)
|
||||
{
|
||||
var trackArtistData = await ArtistLookupEngine.GetByName(new AudioMetaData { Artist = newTrack.TrackArtist.Name }, true);
|
||||
var trackArtistData = await ArtistLookupEngine.GetByName(new AudioMetaData { Artist = newTrack.TrackArtist.Name }, true).ConfigureAwait(false);
|
||||
if (trackArtistData.IsSuccess)
|
||||
{
|
||||
trackArtistId = trackArtistData.Data.Id;
|
||||
}
|
||||
}
|
||||
else if (newTrack.TrackArtists != null && newTrack.TrackArtists.Any())
|
||||
else if (newTrack.TrackArtists?.Any() == true)
|
||||
{
|
||||
partTitles = string.Join("/", newTrack.TrackArtists);
|
||||
}
|
||||
|
@ -265,7 +267,7 @@ namespace Roadie.Library.Engines
|
|||
|
||||
try
|
||||
{
|
||||
await DbContext.SaveChangesAsync();
|
||||
await DbContext.SaveChangesAsync().ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -361,7 +363,7 @@ namespace Roadie.Library.Engines
|
|||
var release = DatabaseQueryForReleaseTitle(artist, metaData.Release);
|
||||
|
||||
sw.Stop();
|
||||
if (release == null || !release.IsValid)
|
||||
if (release?.IsValid != true)
|
||||
{
|
||||
Logger.LogTrace("ReleaseFactory: Release Not Found For Artist `{0}` MetaData [{1}]", artist.ToString(), metaData.ToString());
|
||||
if (doFindIfNotInDatabase)
|
||||
|
@ -369,7 +371,7 @@ namespace Roadie.Library.Engines
|
|||
var releaseSearch = new OperationResult<Release>();
|
||||
try
|
||||
{
|
||||
releaseSearch = await PerformMetaDataProvidersReleaseSearch(metaData, artist.ArtistFileFolder(Configuration), submissionId);
|
||||
releaseSearch = await PerformMetaDataProvidersReleaseSearch(metaData, artist.ArtistFileFolder(Configuration), submissionId).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -386,7 +388,7 @@ namespace Roadie.Library.Engines
|
|||
{
|
||||
release = releaseSearch.Data;
|
||||
release.ArtistId = artist.Id;
|
||||
var addResult = await Add(release, doAddTracksInDatabase);
|
||||
var addResult = await Add(release, doAddTracksInDatabase).ConfigureAwait(false);
|
||||
if (!addResult.IsSuccess)
|
||||
{
|
||||
sw.Stop();
|
||||
|
@ -437,7 +439,7 @@ namespace Roadie.Library.Engines
|
|||
if (metaData.Genres != null) releaseGenres.AddRange(metaData.Genres);
|
||||
var releaseLabels = new List<ReleaseLabelSearchResult>();
|
||||
var releaseMedias = new List<ReleaseMediaSearchResult>();
|
||||
var releaseImages = new List<Imaging.IImage>();
|
||||
var releaseImages = new List<IImage>();
|
||||
var releaseImageUrls = new List<string>();
|
||||
|
||||
var dontDoMetaDataProvidersSearchArtists = Configuration.DontDoMetaDataProvidersSearchArtists;
|
||||
|
@ -457,12 +459,15 @@ namespace Roadie.Library.Engines
|
|||
{
|
||||
var i = iTunesResult.Data.First();
|
||||
if (i.AlternateNames != null)
|
||||
{
|
||||
result.AlternateNames = result.AlternateNames.AddToDelimitedList(i.AlternateNames);
|
||||
}
|
||||
|
||||
if (i.Tags != null) result.Tags = result.Tags.AddToDelimitedList(i.Tags);
|
||||
if (i.Urls != null) result.URLs = result.URLs.AddToDelimitedList(i.Urls);
|
||||
if (i.ImageUrls != null) releaseImageUrls.AddRange(i.ImageUrls);
|
||||
if (i.ReleaseGenres != null) releaseGenres.AddRange(i.ReleaseGenres);
|
||||
if(!string.IsNullOrEmpty(i.ReleaseThumbnailUrl))
|
||||
if (!string.IsNullOrEmpty(i.ReleaseThumbnailUrl))
|
||||
{
|
||||
releaseImages.Add(new Imaging.Image()
|
||||
{
|
||||
|
@ -497,7 +502,7 @@ namespace Roadie.Library.Engines
|
|||
{
|
||||
var sw2 = Stopwatch.StartNew();
|
||||
Logger.LogTrace("MusicBrainzReleaseSearchEngine Release Search for ArtistName [{0}], ReleaseTitle [{1}]", metaData.Artist, result.Title);
|
||||
var mbResult = await MusicBrainzReleaseSearchEngine.PerformReleaseSearch(metaData.Artist, result.Title, 1);
|
||||
var mbResult = await MusicBrainzReleaseSearchEngine.PerformReleaseSearch(metaData.Artist, result.Title, 1).ConfigureAwait(false);
|
||||
if (mbResult.IsSuccess)
|
||||
{
|
||||
var mb = mbResult.Data.First();
|
||||
|
@ -509,10 +514,13 @@ namespace Roadie.Library.Engines
|
|||
if (mb.ReleaseGenres != null) releaseGenres.AddRange(mb.ReleaseGenres);
|
||||
if (!string.IsNullOrEmpty(mb.ReleaseTitle) &&
|
||||
!mb.ReleaseTitle.Equals(result.Title, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
result.AlternateNames.AddToDelimitedList(new[] { mb.ReleaseTitle });
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(mb.ReleaseThumbnailUrl))
|
||||
{
|
||||
releaseImages.Add(new Imaging.Image()
|
||||
releaseImages.Add(new Image()
|
||||
{
|
||||
Bytes = WebHelper.BytesForImageUrl(mb.ReleaseThumbnailUrl)
|
||||
});
|
||||
|
@ -550,7 +558,7 @@ namespace Roadie.Library.Engines
|
|||
var sw2 = Stopwatch.StartNew();
|
||||
Logger.LogTrace("LastFmReleaseSearchEngine Release Search for ArtistName [{0}], ReleaseTitle [{1}]", metaData.Artist, result.Title);
|
||||
var lastFmResult =
|
||||
await LastFmReleaseSearchEngine.PerformReleaseSearch(metaData.Artist, result.Title, 1);
|
||||
await LastFmReleaseSearchEngine.PerformReleaseSearch(metaData.Artist, result.Title, 1).ConfigureAwait(false);
|
||||
if (lastFmResult.IsSuccess)
|
||||
{
|
||||
var l = lastFmResult.Data.First();
|
||||
|
@ -562,10 +570,13 @@ namespace Roadie.Library.Engines
|
|||
if (l.ReleaseGenres != null) releaseGenres.AddRange(l.ReleaseGenres);
|
||||
if (!string.IsNullOrEmpty(l.ReleaseTitle) &&
|
||||
!l.ReleaseTitle.Equals(result.Title, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
result.AlternateNames.AddToDelimitedList(new[] { l.ReleaseTitle });
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(l.ReleaseThumbnailUrl))
|
||||
{
|
||||
releaseImages.Add(new Imaging.Image()
|
||||
releaseImages.Add(new Image()
|
||||
{
|
||||
Bytes = WebHelper.BytesForImageUrl(l.ReleaseThumbnailUrl)
|
||||
});
|
||||
|
@ -601,7 +612,7 @@ namespace Roadie.Library.Engines
|
|||
{
|
||||
var sw2 = Stopwatch.StartNew();
|
||||
Logger.LogTrace("SpotifyReleaseSearchEngine Release Search for ArtistName [{0}], ReleaseTitle [{1}]", metaData.Artist, result.Title);
|
||||
var spotifyResult = await SpotifyReleaseSearchEngine.PerformReleaseSearch(metaData.Artist, result.Title, 1);
|
||||
var spotifyResult = await SpotifyReleaseSearchEngine.PerformReleaseSearch(metaData.Artist, result.Title, 1).ConfigureAwait(false);
|
||||
if (spotifyResult.IsSuccess)
|
||||
{
|
||||
var s = spotifyResult.Data.First();
|
||||
|
@ -611,10 +622,13 @@ namespace Roadie.Library.Engines
|
|||
if (s.ReleaseGenres != null) releaseGenres.AddRange(s.ReleaseGenres);
|
||||
if (!string.IsNullOrEmpty(s.ReleaseTitle) &&
|
||||
!s.ReleaseTitle.Equals(result.Title, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
result.AlternateNames.AddToDelimitedList(new[] { s.ReleaseTitle });
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(s.ReleaseThumbnailUrl))
|
||||
{
|
||||
releaseImages.Add(new Imaging.Image()
|
||||
releaseImages.Add(new Image()
|
||||
{
|
||||
Bytes = WebHelper.BytesForImageUrl(s.ReleaseThumbnailUrl)
|
||||
});
|
||||
|
@ -649,7 +663,7 @@ namespace Roadie.Library.Engines
|
|||
{
|
||||
var sw2 = Stopwatch.StartNew();
|
||||
Logger.LogTrace("DiscogsReleaseSearchEngine Release Search for ArtistName [{0}], ReleaseTitle [{1}]", metaData.Artist, result.Title);
|
||||
var discogsResult = await DiscogsReleaseSearchEngine.PerformReleaseSearch(metaData.Artist, result.Title, 1);
|
||||
var discogsResult = await DiscogsReleaseSearchEngine.PerformReleaseSearch(metaData.Artist, result.Title, 1).ConfigureAwait(false);
|
||||
if (discogsResult.IsSuccess)
|
||||
{
|
||||
var d = discogsResult.Data.First();
|
||||
|
@ -659,10 +673,13 @@ namespace Roadie.Library.Engines
|
|||
result.AlternateNames = result.AlternateNames.AddToDelimitedList(d.AlternateNames);
|
||||
if (!string.IsNullOrEmpty(d.ReleaseTitle) &&
|
||||
!d.ReleaseTitle.Equals(result.Title, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
result.AlternateNames.AddToDelimitedList(new[] { d.ReleaseTitle });
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(d.ReleaseThumbnailUrl))
|
||||
{
|
||||
releaseImages.Add(new Imaging.Image()
|
||||
releaseImages.Add(new Image()
|
||||
{
|
||||
Bytes = WebHelper.BytesForImageUrl(d.ReleaseThumbnailUrl)
|
||||
});
|
||||
|
@ -711,7 +728,7 @@ namespace Roadie.Library.Engines
|
|||
{
|
||||
result.Tags = string.Join("|", result.Tags.ToListFromDelimited().Distinct().OrderBy(x => x));
|
||||
}
|
||||
if (releaseGenres.Any())
|
||||
if (releaseGenres.Count > 0)
|
||||
{
|
||||
var sw2 = Stopwatch.StartNew();
|
||||
result.Genres = new List<ReleaseGenre>();
|
||||
|
@ -732,21 +749,18 @@ namespace Roadie.Library.Engines
|
|||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
sw2.Stop();
|
||||
Logger.LogTrace($"PerformMetaDataProvidersReleaseSearch: Release Genre Processing Complete [{ sw2.ElapsedMilliseconds }]");
|
||||
}
|
||||
|
||||
if (releaseImageUrls.Any())
|
||||
if (releaseImageUrls.Count > 0)
|
||||
{
|
||||
var sw2 = Stopwatch.StartNew();
|
||||
var imageBag = new ConcurrentBag<IImage>();
|
||||
var i = releaseImageUrls.Select(async url =>
|
||||
{
|
||||
imageBag.Add(await WebHelper.GetImageFromUrlAsync(url));
|
||||
});
|
||||
await Task.WhenAll(i);
|
||||
releaseImages = imageBag.Where(x => x != null && x.Bytes != null)
|
||||
var i = releaseImageUrls.Select(async url => imageBag.Add(await WebHelper.GetImageFromUrlAsync(url).ConfigureAwait(false)));
|
||||
await Task.WhenAll(i).ConfigureAwait(false);
|
||||
releaseImages = imageBag.Where(x => x?.Bytes != null)
|
||||
.GroupBy(x => x.Signature)
|
||||
.Select(x => x.First())
|
||||
.Take(Configuration.Processing.MaximumArtistImagesToAdd)
|
||||
|
@ -755,20 +769,20 @@ namespace Roadie.Library.Engines
|
|||
Logger.LogTrace($"PerformMetaDataProvidersReleaseSearch: Image Url Processing Complete [{ sw2.ElapsedMilliseconds }]");
|
||||
}
|
||||
|
||||
if (metaData.Images != null && metaData.Images.Any())
|
||||
if (metaData.Images?.Any() == true)
|
||||
{
|
||||
foreach(var metadataImage in metaData.Images)
|
||||
foreach (var metadataImage in metaData.Images)
|
||||
{
|
||||
releaseImages.Add(new Imaging.Image()
|
||||
releaseImages.Add(new Image()
|
||||
{
|
||||
Bytes = metadataImage?.Data
|
||||
});
|
||||
}
|
||||
}
|
||||
foreach(var releaseImage in releaseImages.Where(x => x.Bytes != null && string.IsNullOrEmpty(x.Signature)))
|
||||
foreach (var releaseImage in releaseImages.Where(x => x.Bytes != null && string.IsNullOrEmpty(x.Signature)))
|
||||
{
|
||||
releaseImage.Signature = releaseImage.GenerateSignature();
|
||||
if(string.IsNullOrEmpty(releaseImage.Signature))
|
||||
if (string.IsNullOrEmpty(releaseImage.Signature))
|
||||
{
|
||||
releaseImage.Bytes = null;
|
||||
}
|
||||
|
@ -777,7 +791,7 @@ namespace Roadie.Library.Engines
|
|||
.GroupBy(x => x.Signature)
|
||||
.Select(x => x.First()).Take(Configuration.Processing.MaximumReleaseImagesToAdd)
|
||||
.ToList();
|
||||
if (releaseLabels.Any())
|
||||
if (releaseLabels.Count > 0)
|
||||
{
|
||||
var sw2 = Stopwatch.StartNew();
|
||||
result.Labels = releaseLabels.GroupBy(x => x.CatalogNumber).Select(x => x.First()).Select(x =>
|
||||
|
@ -803,7 +817,7 @@ namespace Roadie.Library.Engines
|
|||
sw2.Stop();
|
||||
Logger.LogTrace($"PerformMetaDataProvidersReleaseSearch: Release Labels Processing Complete [{ sw2.ElapsedMilliseconds }]");
|
||||
}
|
||||
if (releaseMedias.Any())
|
||||
if (releaseMedias.Count > 0)
|
||||
{
|
||||
var sw2 = Stopwatch.StartNew();
|
||||
var resultReleaseMedias = new List<ReleaseMedia>();
|
||||
|
@ -824,7 +838,7 @@ namespace Roadie.Library.Engines
|
|||
.OrderBy(x => x.TrackNumber))
|
||||
{
|
||||
var foundTrack = true;
|
||||
var rmTrack = rmTracks.FirstOrDefault(x => x.TrackNumber == releaseTrack.TrackNumber.Value);
|
||||
var rmTrack = rmTracks.Find(x => x.TrackNumber == releaseTrack.TrackNumber.Value);
|
||||
if (rmTrack == null)
|
||||
{
|
||||
Artist trackArtist = null;
|
||||
|
@ -856,11 +870,11 @@ namespace Roadie.Library.Engines
|
|||
foundTrack = false;
|
||||
}
|
||||
|
||||
rmTrack.Duration = rmTrack.Duration ?? releaseTrack.Duration;
|
||||
rmTrack.MusicBrainzId = rmTrack.MusicBrainzId ?? releaseTrack.MusicBrainzId;
|
||||
rmTrack.SpotifyId = rmTrack.SpotifyId ?? releaseTrack.SpotifyId;
|
||||
rmTrack.AmgId = rmTrack.AmgId ?? releaseTrack.AmgId;
|
||||
rmTrack.Title = rmTrack.Title ?? releaseTrack.Title;
|
||||
rmTrack.Duration ??= releaseTrack.Duration;
|
||||
rmTrack.MusicBrainzId ??= releaseTrack.MusicBrainzId;
|
||||
rmTrack.SpotifyId ??= releaseTrack.SpotifyId;
|
||||
rmTrack.AmgId ??= releaseTrack.AmgId;
|
||||
rmTrack.Title ??= releaseTrack.Title;
|
||||
rmTrack.Duration = releaseTrack.Duration;
|
||||
rmTrack.Tags = rmTrack.Tags == null
|
||||
? releaseTrack.Tags.ToDelimitedList()
|
||||
|
@ -868,18 +882,18 @@ namespace Roadie.Library.Engines
|
|||
rmTrack.AlternateNames = rmTrack.AlternateNames == null
|
||||
? releaseTrack.AlternateNames.ToDelimitedList()
|
||||
: rmTrack.AlternateNames.AddToDelimitedList(releaseTrack.AlternateNames);
|
||||
rmTrack.ISRC = rmTrack.ISRC ?? releaseTrack.ISRC;
|
||||
rmTrack.LastFMId = rmTrack.LastFMId ?? releaseTrack.LastFMId;
|
||||
rmTrack.ISRC ??= releaseTrack.ISRC;
|
||||
rmTrack.LastFMId ??= releaseTrack.LastFMId;
|
||||
if (!foundTrack) rmTracks.Add(rmTrack);
|
||||
}
|
||||
|
||||
rm.Tracks = rmTracks;
|
||||
rm.TrackCount = (short)rmTracks.Count();
|
||||
rm.TrackCount = (short)rmTracks.Count;
|
||||
resultReleaseMedias.Add(rm);
|
||||
}
|
||||
|
||||
result.Medias = resultReleaseMedias;
|
||||
result.TrackCount = (short)releaseMedias.SelectMany(x => x.Tracks).Count();
|
||||
result.TrackCount = (short)releaseMedias.Sum(x => x.Tracks.Count);
|
||||
sw2.Stop();
|
||||
Logger.LogTrace($"PerformMetaDataProvidersReleaseSearch: Release Media Processing Complete [{ sw2.ElapsedMilliseconds }]");
|
||||
}
|
||||
|
@ -897,9 +911,9 @@ namespace Roadie.Library.Engines
|
|||
// See if cover exist by filename
|
||||
var imageFilesInFolder =
|
||||
ImageHelper.ImageFilesInFolder(releaseFolder.FullName, SearchOption.AllDirectories);
|
||||
if (imageFilesInFolder != null && imageFilesInFolder.Any())
|
||||
if (imageFilesInFolder?.Any() == true)
|
||||
{
|
||||
var imageCoverByReleaseName = imageFilesInFolder.FirstOrDefault(x =>
|
||||
var imageCoverByReleaseName = Array.Find(imageFilesInFolder, x =>
|
||||
x == result.Title || x == result.Title.ToFileNameFriendly());
|
||||
if (imageCoverByReleaseName != null) coverFileName = imageCoverByReleaseName;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace Roadie.Library.FilePlugins
|
|||
{
|
||||
string destinationName = null;
|
||||
|
||||
var metaData = await AudioMetaDataHelper.GetInfo(fileInfo, doJustInfo);
|
||||
var metaData = await AudioMetaDataHelper.GetInfo(fileInfo, doJustInfo).ConfigureAwait(false);
|
||||
if (!metaData.IsValid)
|
||||
{
|
||||
var minWeight = MinWeightToDelete;
|
||||
|
@ -75,7 +75,7 @@ namespace Roadie.Library.FilePlugins
|
|||
SimpleContract.Requires<ArgumentException>(year > 0, string.Format("Invalid Track Year [{0}]", year));
|
||||
SimpleContract.Requires<ArgumentException>(trackNumber > 0, "Missing Track Number");
|
||||
|
||||
var artistFolder = await DetermineArtistFolder(metaData, doJustInfo);
|
||||
var artistFolder = await DetermineArtistFolder(metaData, doJustInfo).ConfigureAwait(false);
|
||||
if (string.IsNullOrEmpty(artistFolder))
|
||||
{
|
||||
Logger.LogWarning("Unable To Find ArtistFolder [{0}] For MetaData [{1}]", artistFolder,
|
||||
|
@ -83,7 +83,7 @@ namespace Roadie.Library.FilePlugins
|
|||
return new OperationResult<bool>("Unable To Find Artist Folder");
|
||||
}
|
||||
|
||||
var releaseFolder = await DetermineReleaseFolder(artistFolder, metaData, doJustInfo, submissionId);
|
||||
var releaseFolder = await DetermineReleaseFolder(artistFolder, metaData, doJustInfo, submissionId).ConfigureAwait(false);
|
||||
if (string.IsNullOrEmpty(releaseFolder))
|
||||
{
|
||||
Logger.LogWarning("Unable To Find ReleaseFolder For MetaData [{0}]", metaData.ToString());
|
||||
|
@ -107,9 +107,9 @@ namespace Roadie.Library.FilePlugins
|
|||
var artistImages = new List<FileInfo>();
|
||||
artistImages.AddRange(ImageHelper.FindImageTypeInDirectory(fileInfo.Directory, ImageType.Artist));
|
||||
artistImages.AddRange(ImageHelper.FindImageTypeInDirectory(fileInfo.Directory.Parent, ImageType.Artist));
|
||||
if (artistImages.Any())
|
||||
if (artistImages.Count > 0)
|
||||
{
|
||||
var artistImage = artistImages.First();
|
||||
var artistImage = artistImages[0];
|
||||
var artistImageFilename = Path.Combine(artistFolder, ImageHelper.ArtistImageFilename);
|
||||
if (artistImageFilename != artistImage.FullName)
|
||||
{
|
||||
|
@ -132,7 +132,7 @@ namespace Roadie.Library.FilePlugins
|
|||
artistImages.Clear();
|
||||
artistImages.AddRange(ImageHelper.FindImageTypeInDirectory(fileInfo.Directory, ImageType.ArtistSecondary));
|
||||
artistImages.AddRange(ImageHelper.FindImageTypeInDirectory(fileInfo.Directory.Parent, ImageType.Artist));
|
||||
if (artistImages.Any())
|
||||
if (artistImages.Count > 0)
|
||||
{
|
||||
var looper = 0;
|
||||
foreach (var artistImage in artistImages)
|
||||
|
@ -230,7 +230,7 @@ namespace Roadie.Library.FilePlugins
|
|||
var existing = new FileInfo(destinationName);
|
||||
|
||||
// If Exists determine which is better - if same do nothing
|
||||
var existingMetaData = await AudioMetaDataHelper.GetInfo(existing, doJustInfo);
|
||||
var existingMetaData = await AudioMetaDataHelper.GetInfo(existing, doJustInfo).ConfigureAwait(false);
|
||||
|
||||
var areSameFile = existing.FullName.Replace("\\", "").Replace("/", "")
|
||||
.Equals(fileInfo.FullName.Replace("\\", "").Replace("/", ""),
|
||||
|
@ -261,6 +261,7 @@ namespace Roadie.Library.FilePlugins
|
|||
{
|
||||
Logger.LogTrace("Moving File To [{0}]", destinationName);
|
||||
if (!doJustInfo)
|
||||
{
|
||||
try
|
||||
{
|
||||
fileInfo.MoveTo(destinationName);
|
||||
|
@ -269,6 +270,7 @@ namespace Roadie.Library.FilePlugins
|
|||
{
|
||||
Logger.LogError(ex, "Error Moving File [{0}}", destinationName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result.AdditionalData.Add(PluginResultInfo.AdditionalDataKeyPluginResultInfo, new PluginResultInfo
|
||||
|
@ -297,7 +299,7 @@ namespace Roadie.Library.FilePlugins
|
|||
private async Task<string> DetermineArtistFolder(AudioMetaData metaData,
|
||||
bool doJustInfo)
|
||||
{
|
||||
var artist = await ArtistLookupEngine.GetByName(metaData, !doJustInfo);
|
||||
var artist = await ArtistLookupEngine.GetByName(metaData, !doJustInfo).ConfigureAwait(false);
|
||||
if (!artist.IsSuccess) return null;
|
||||
try
|
||||
{
|
||||
|
@ -314,13 +316,13 @@ namespace Roadie.Library.FilePlugins
|
|||
private async Task<string> DetermineReleaseFolder(string artistFolder, AudioMetaData metaData, bool doJustInfo,
|
||||
int? submissionId)
|
||||
{
|
||||
var artist = await ArtistLookupEngine.GetByName(metaData, !doJustInfo);
|
||||
var artist = await ArtistLookupEngine.GetByName(metaData, !doJustInfo).ConfigureAwait(false);
|
||||
if (!artist.IsSuccess)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_artistId = artist.Data.RoadieId;
|
||||
var release = await ReleaseLookupEngine.GetByName(artist.Data, metaData, !doJustInfo, submissionId: submissionId);
|
||||
var release = await ReleaseLookupEngine.GetByName(artist.Data, metaData, !doJustInfo, submissionId: submissionId).ConfigureAwait(false);
|
||||
if (!release.IsSuccess)
|
||||
{
|
||||
return null;
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace Roadie.Library.FilePlugins
|
|||
|
||||
protected IHttpEncoder HttpEncoder { get; }
|
||||
|
||||
|
||||
protected ILogger Logger { get; }
|
||||
|
||||
protected IReleaseLookupEngine ReleaseLookupEngine { get; }
|
||||
|
|
|
@ -171,7 +171,7 @@ namespace Roadie.Library.Inspect
|
|||
|
||||
string scriptResult = null;
|
||||
// Run PreInspect script
|
||||
if(!dontRunPreScripts)
|
||||
if(dontRunPreScripts)
|
||||
{
|
||||
Console.BackgroundColor = ConsoleColor.Blue;
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
using MimeMapping;
|
||||
using Roadie.Library.Caching;
|
||||
using Roadie.Library.Configuration;
|
||||
using Roadie.Library.Data;
|
||||
using Roadie.Library.Data.Context;
|
||||
using Roadie.Library.Encoding;
|
||||
using Roadie.Library.Engines;
|
||||
using Roadie.Library.Extensions;
|
||||
|
@ -20,8 +18,6 @@ namespace Roadie.Library.Processors
|
|||
{
|
||||
public sealed class FileProcessor : IFileProcessor
|
||||
{
|
||||
private bool DoDeleteUnknowns => Configuration.Processing.DoDeleteUnknowns;
|
||||
|
||||
private bool DoMoveUnknowns => Configuration.Processing.DoMoveUnknowns;
|
||||
|
||||
public IHttpEncoder HttpEncoder { get; }
|
||||
|
@ -38,8 +34,6 @@ namespace Roadie.Library.Processors
|
|||
|
||||
private IRoadieSettings Configuration { get; }
|
||||
|
||||
private IRoadieDbContext DbContext { get; }
|
||||
|
||||
private ILogger Logger { get; }
|
||||
|
||||
private IReleaseLookupEngine ReleaseLookupEngine { get; }
|
||||
|
@ -60,12 +54,14 @@ namespace Roadie.Library.Processors
|
|||
.SelectMany(s => s.GetTypes())
|
||||
.Where(p => type.IsAssignableFrom(p));
|
||||
foreach (var t in types)
|
||||
{
|
||||
if (t.GetInterface("IFilePlugin") != null && !t.IsAbstract && !t.IsInterface)
|
||||
{
|
||||
var plugin = Activator.CreateInstance(t, Configuration, HttpEncoder, CacheManager, Logger, ArtistLookupEngine,
|
||||
ReleaseLookupEngine, AudioMetaDataHelper) as IFilePlugin;
|
||||
plugins.Add(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -79,14 +75,12 @@ namespace Roadie.Library.Processors
|
|||
}
|
||||
}
|
||||
|
||||
public FileProcessor(IRoadieSettings configuration, IHttpEncoder httpEncoder,
|
||||
IRoadieDbContext context, ICacheManager cacheManager, ILogger<FileProcessor> logger,
|
||||
IArtistLookupEngine artistLookupEngine, IReleaseLookupEngine releaseLookupEngine,
|
||||
IAudioMetaDataHelper audioMetaDataHelper)
|
||||
public FileProcessor(IRoadieSettings configuration, IHttpEncoder httpEncoder, ICacheManager cacheManager,
|
||||
ILogger<FileProcessor> logger, IArtistLookupEngine artistLookupEngine, IReleaseLookupEngine releaseLookupEngine,
|
||||
IAudioMetaDataHelper audioMetaDataHelper)
|
||||
{
|
||||
Configuration = configuration;
|
||||
HttpEncoder = httpEncoder;
|
||||
DbContext = context;
|
||||
CacheManager = cacheManager;
|
||||
Logger = logger;
|
||||
|
||||
|
@ -113,10 +107,7 @@ namespace Roadie.Library.Processors
|
|||
return r;
|
||||
}
|
||||
|
||||
public async Task<OperationResult<bool>> Process(string filename, bool doJustInfo = false)
|
||||
{
|
||||
return await Process(new FileInfo(filename), doJustInfo);
|
||||
}
|
||||
public async Task<OperationResult<bool>> Process(string filename, bool doJustInfo = false) => await Process(new FileInfo(filename), doJustInfo).ConfigureAwait(false);
|
||||
|
||||
public async Task<OperationResult<bool>> Process(FileInfo fileInfo, bool doJustInfo = false)
|
||||
{
|
||||
|
@ -129,33 +120,34 @@ namespace Roadie.Library.Processors
|
|||
|
||||
OperationResult<bool> pluginResult = null;
|
||||
foreach (var p in Plugins)
|
||||
{
|
||||
// See if there is a plugin
|
||||
if (p.HandlesTypes.Contains(fileType))
|
||||
{
|
||||
pluginResult = await p.Process(fileInfo, doJustInfo, SubmissionId);
|
||||
pluginResult = await p.Process(fileInfo, doJustInfo, SubmissionId).ConfigureAwait(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!doJustInfo)
|
||||
{
|
||||
// If no plugin, or if plugin not successfull and toggle then move unknown file
|
||||
if ((pluginResult == null || !pluginResult.IsSuccess) && DoMoveUnknowns)
|
||||
if ((pluginResult?.IsSuccess != true) && DoMoveUnknowns)
|
||||
{
|
||||
var uf = UnknownFolder;
|
||||
if (!string.IsNullOrEmpty(uf))
|
||||
{
|
||||
if (!Directory.Exists(uf)) Directory.CreateDirectory(uf);
|
||||
if (!fileInfo.DirectoryName.Equals(UnknownFolder))
|
||||
if (File.Exists(fileInfo.FullName))
|
||||
{
|
||||
var df = Path.Combine(UnknownFolder,
|
||||
string.Format("{0}~{1}~{2}", Guid.NewGuid(), fileInfo.Directory.Name,
|
||||
fileInfo.Name));
|
||||
Logger.LogDebug("Moving Unknown/Invalid File [{0}] -> [{1}] to UnknownFolder",
|
||||
fileInfo.FullName, df);
|
||||
fileInfo.MoveTo(df);
|
||||
}
|
||||
if (!fileInfo.DirectoryName.Equals(UnknownFolder) && File.Exists(fileInfo.FullName))
|
||||
{
|
||||
var df = Path.Combine(UnknownFolder,
|
||||
string.Format("{0}~{1}~{2}", Guid.NewGuid(), fileInfo.Directory.Name, fileInfo.Name));
|
||||
Logger.LogDebug("Moving Unknown/Invalid File [{0}] -> [{1}] to UnknownFolder", fileInfo.FullName, df);
|
||||
fileInfo.MoveTo(df);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = pluginResult;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
using System.Collections.Generic;
|
||||
using Roadie.Library.Encoding;
|
||||
using Roadie.Library.FilePlugins;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Roadie.Library.Encoding;
|
||||
using Roadie.Library.FilePlugins;
|
||||
|
||||
namespace Roadie.Library.Processors
|
||||
{
|
||||
|
@ -13,6 +13,7 @@ namespace Roadie.Library.Processors
|
|||
int? SubmissionId { get; set; }
|
||||
|
||||
Task<OperationResult<bool>> Process(FileInfo fileInfo, bool doJustInfo = false);
|
||||
|
||||
Task<OperationResult<bool>> Process(string filename, bool doJustInfo = false);
|
||||
}
|
||||
}
|
|
@ -9,28 +9,28 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoCompare.Core" Version="1.0.0" />
|
||||
<PackageReference Include="CsvHelper" Version="13.0.0" />
|
||||
<PackageReference Include="EFCore.BulkExtensions" Version="3.1.0" />
|
||||
<PackageReference Include="FluentFTP" Version="29.0.2" />
|
||||
<PackageReference Include="CsvHelper" Version="15.0.4" />
|
||||
<PackageReference Include="EFCore.BulkExtensions" Version="3.1.1" />
|
||||
<PackageReference Include="FluentFTP" Version="32.3.3" />
|
||||
<PackageReference Include="Hashids.net" Version="1.3.0" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.17" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.23" />
|
||||
<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="LiteDB" Version="4.1.4" />
|
||||
<PackageReference Include="Mapster" Version="4.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.1" />
|
||||
<PackageReference Include="LiteDB" Version="5.0.5" />
|
||||
<PackageReference Include="Mapster" Version="5.3.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Redis" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.1" />
|
||||
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.3.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.3.3" />
|
||||
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.2.8" />
|
||||
<PackageReference Include="Microsoft.PowerShell.SDK" Version="6.2.3" />
|
||||
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.0.0" />
|
||||
<PackageReference Include="MimeMapping" Version="1.0.1.26" />
|
||||
<PackageReference Include="NodaTime" Version="2.4.7" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.0" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.1" />
|
||||
<PackageReference Include="RestSharp" Version="106.10.1" />
|
||||
<PackageReference Include="SixLabors.Core" Version="1.0.0-beta0008" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-beta0007" />
|
||||
|
@ -39,7 +39,7 @@
|
|||
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
|
||||
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="4.7.0" />
|
||||
<PackageReference Include="System.Runtime.Caching" Version="4.7.0" />
|
||||
<PackageReference Include="z440.atl.core" Version="2.16.0" />
|
||||
<PackageReference Include="z440.atl.core" Version="3.3.0" />
|
||||
<PackageReference Include="zlib.net-mutliplatform" Version="1.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -272,12 +272,12 @@ namespace Roadie.Api.Services
|
|||
randomArtistIds = randomArtistData.Select(x => x.Value).ToArray();
|
||||
rowCount = await DbContext.Artists.CountAsync().ConfigureAwait(false);
|
||||
}
|
||||
var result = (from a in DbContext.Artists
|
||||
var result = from a in DbContext.Artists
|
||||
where !onlyWithReleases || a.ReleaseCount > 0
|
||||
where randomArtistIds == null || randomArtistIds.Contains(a.Id)
|
||||
where request.FilterToArtistId == null || a.RoadieId == request.FilterToArtistId
|
||||
where request.FilterMinimumRating == null || a.Rating >= request.FilterMinimumRating.Value
|
||||
where request.FilterValue == "" ||
|
||||
where string.IsNullOrEmpty(request.FilterValue) ||
|
||||
a.Name.Contains(request.FilterValue) ||
|
||||
a.SortName.Contains(request.FilterValue) ||
|
||||
a.RealName.Contains(request.FilterValue) ||
|
||||
|
@ -312,7 +312,7 @@ namespace Roadie.Api.Services
|
|||
TrackCount = a.TrackCount,
|
||||
SortName = a.SortName,
|
||||
Status = a.Status
|
||||
});
|
||||
};
|
||||
|
||||
ArtistList[] rows;
|
||||
rowCount ??= result.Count();
|
||||
|
|
|
@ -510,7 +510,7 @@ namespace Roadie.Api.Services
|
|||
rowCount = DbContext.Releases.Count();
|
||||
}
|
||||
|
||||
var result = (from r in DbContext.Releases
|
||||
var result = from r in DbContext.Releases
|
||||
join a in DbContext.Artists on r.ArtistId equals a.Id
|
||||
where randomReleaseIds == null || randomReleaseIds.Contains(r.Id)
|
||||
where request.FilterMinimumRating == null || r.Rating >= request.FilterMinimumRating.Value
|
||||
|
@ -522,7 +522,7 @@ namespace Roadie.Api.Services
|
|||
(r.ReleaseDate != null && r.ReleaseDate.Value.Year <= request.FilterFromYear)
|
||||
where request.FilterToYear == null ||
|
||||
(r.ReleaseDate != null && r.ReleaseDate.Value.Year >= request.FilterToYear)
|
||||
where request.FilterValue == "" ||
|
||||
where string.IsNullOrEmpty(request.FilterValue) ||
|
||||
r.Title.Contains(request.FilterValue) ||
|
||||
r.AlternateNames.Contains(request.FilterValue) ||
|
||||
r.AlternateNames.Contains(normalizedFilterValue)
|
||||
|
@ -559,7 +559,7 @@ namespace Roadie.Api.Services
|
|||
Thumbnail = ImageHelper.MakeReleaseThumbnailImage(Configuration, HttpContext, r.RoadieId),
|
||||
TrackCount = r.TrackCount,
|
||||
TrackPlayedCount = r.PlayedCount
|
||||
});
|
||||
};
|
||||
|
||||
ReleaseList[] rows = null;
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Hashids.net" Version="1.3.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.6.0" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.20" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.5.0" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.23" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -341,12 +341,12 @@ namespace Roadie.Api.Services
|
|||
where filterToTrackIds == null || filterToTrackIds.Contains(t.RoadieId)
|
||||
where releaseId == null || r.RoadieId == releaseId
|
||||
where request.FilterMinimumRating == null || t.Rating >= request.FilterMinimumRating.Value
|
||||
where request.FilterValue == "" || (trackArtist != null && trackArtist.Name.Contains(request.FilterValue)) || t.Title.Contains(request.FilterValue) || t.AlternateNames.Contains(request.FilterValue) || t.AlternateNames.Contains(normalizedFilterValue) || t.PartTitles.Contains(request.FilterValue)
|
||||
where string.IsNullOrEmpty(request.FilterValue) || (trackArtist != null && trackArtist.Name.Contains(request.FilterValue)) || t.Title.Contains(request.FilterValue) || t.AlternateNames.Contains(request.FilterValue) || t.AlternateNames.Contains(normalizedFilterValue) || t.PartTitles.Contains(request.FilterValue)
|
||||
where !isEqualFilter || t.Title.Equals(request.FilterValue) || t.AlternateNames.Equals(request.FilterValue) || t.AlternateNames.Equals(normalizedFilterValue) || t.PartTitles.Equals(request.FilterValue)
|
||||
where !request.FilterFavoriteOnly || favoriteTrackIds.Contains(t.Id)
|
||||
where request.FilterToPlaylistId == null || playlistTrackIds.Contains(t.Id)
|
||||
where !request.FilterTopPlayedOnly || topTrackids.Contains(t.Id)
|
||||
where request.FilterToArtistId == null || ((t.TrackArtist != null && t.TrackArtist.RoadieId == request.FilterToArtistId) || r.Artist.RoadieId == request.FilterToArtistId)
|
||||
where request.FilterToArtistId == null || (t.TrackArtist != null && t.TrackArtist.RoadieId == request.FilterToArtistId) || r.Artist.RoadieId == request.FilterToArtistId
|
||||
where !request.IsHistoryRequest || t.PlayedCount > 0
|
||||
where request.FilterToCollectionId == null || collectionTrackIds.Contains(t.Id)
|
||||
select new
|
||||
|
|
35
Roadie.Api/LoggingTraceListener.cs
Normal file
35
Roadie.Api/LoggingTraceListener.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
using Serilog;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Roadie.Api
|
||||
{
|
||||
public class LoggingTraceListener : TraceListener
|
||||
{
|
||||
public override void Write(string message) => WriteLog(message);
|
||||
|
||||
public override void WriteLine(string message) => WriteLog(message);
|
||||
|
||||
public override void WriteLine(string o, string category) => WriteLog(o, category);
|
||||
|
||||
public override void Write(string o, string category) => WriteLog(o, category);
|
||||
|
||||
private void WriteLog(string message, string category = null)
|
||||
{
|
||||
switch (category?.ToLower())
|
||||
{
|
||||
case "warning":
|
||||
Log.Warning(message);
|
||||
break;
|
||||
|
||||
case "error":
|
||||
Log.Error(message);
|
||||
break;
|
||||
|
||||
default:
|
||||
Log.Verbose(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -66,33 +66,4 @@ namespace Roadie.Api
|
|||
})
|
||||
.UseSerilog();
|
||||
}
|
||||
|
||||
public class LoggingTraceListener : TraceListener
|
||||
{
|
||||
public override void Write(string message) => WriteLog(message);
|
||||
|
||||
public override void WriteLine(string message) => WriteLog(message);
|
||||
|
||||
public override void WriteLine(string o, string category) => WriteLog(o, category);
|
||||
|
||||
public override void Write(string o, string category) => WriteLog(o, category);
|
||||
|
||||
private void WriteLog(string message, string category = null)
|
||||
{
|
||||
switch (category?.ToLower())
|
||||
{
|
||||
case "warning":
|
||||
Log.Warning(message);
|
||||
break;
|
||||
|
||||
case "error":
|
||||
Log.Error(message);
|
||||
break;
|
||||
|
||||
default:
|
||||
Log.Verbose(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,17 +29,17 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BCrypt-Core" Version="2.0.0" />
|
||||
<PackageReference Include="Mapster" Version="4.1.1" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.12.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.1" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.4.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.4.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.4.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.1" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.0" />
|
||||
<PackageReference Include="Mapster" Version="5.3.0" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.13.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.5.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.5.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.5.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
|
||||
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
|
||||
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
|
||||
|
@ -48,8 +48,8 @@
|
|||
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
|
||||
<PackageReference Include="Serilog.Sinks.LiteDB.NetStandard" Version="1.0.14" />
|
||||
<PackageReference Include="Serilog.Sinks.RollingFileAlternate" Version="2.0.9" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.6.0" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.20" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.5.0" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.23" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
Loading…
Reference in a new issue