Scan work

This commit is contained in:
Steven Hildreth 2018-12-14 22:19:52 -06:00
parent 304c808acd
commit 6253677d01
21 changed files with 225 additions and 86 deletions

View file

@ -68,6 +68,7 @@ namespace Roadie.Library.Tests
Assert.NotNull(metaData.TrackNumber);
Assert.True(metaData.TotalSeconds > 0);
Assert.True(metaData.ValidWeight > 30);
Assert.True(metaData.IsValid);
}
else
{
@ -100,6 +101,7 @@ namespace Roadie.Library.Tests
Assert.NotNull(metaData.Title);
Assert.True(metaData.Year > 0);
Assert.True(metaData.ValidWeight > 30);
Assert.True(metaData.IsValid);
}
}
@ -122,6 +124,7 @@ namespace Roadie.Library.Tests
Assert.True(metaData.TotalSeconds > 0);
Assert.False(metaData.IsSoundTrack);
Assert.True(metaData.ValidWeight > 30);
Assert.True(metaData.IsValid);
}
else
{
@ -147,6 +150,7 @@ namespace Roadie.Library.Tests
Assert.True(metaData.TotalSeconds > 0);
Assert.True(metaData.IsSoundTrack);
Assert.True(metaData.ValidWeight > 30);
Assert.True(metaData.IsValid);
}
else
{
@ -172,6 +176,7 @@ namespace Roadie.Library.Tests
Assert.NotNull(metaData.TrackNumber);
Assert.True(metaData.TotalSeconds > 0);
Assert.True(metaData.ValidWeight > 30);
Assert.True(metaData.IsValid);
}
else
{
@ -198,6 +203,7 @@ namespace Roadie.Library.Tests
Assert.NotNull(metaData.TrackNumber);
Assert.True(metaData.TotalSeconds > 0);
Assert.True(metaData.ValidWeight > 30);
Assert.True(metaData.IsValid);
}
else
{
@ -224,6 +230,7 @@ namespace Roadie.Library.Tests
Assert.NotNull(metaData.TrackNumber);
Assert.True(metaData.TotalSeconds > 0);
Assert.True(metaData.ValidWeight > 30);
Assert.True(metaData.IsValid);
}
else
{
@ -250,6 +257,7 @@ namespace Roadie.Library.Tests
Assert.NotNull(metaData.TrackNumber);
Assert.True(metaData.TotalSeconds > 0);
Assert.True(metaData.ValidWeight > 30);
Assert.True(metaData.IsValid);
}
else
{
@ -298,14 +306,16 @@ namespace Roadie.Library.Tests
var tagLib = this.TagsHelper.MetaDataForFile(file.FullName);
Assert.True(tagLib.IsSuccess);
var metaData = tagLib.Data;
Assert.True(metaData.IsValid);
Assert.NotNull(metaData.Artist);
Assert.NotNull(metaData.Release);
Assert.NotNull(metaData.Title);
Assert.True(metaData.Year > 0);
Assert.NotNull(metaData.TrackNumber);
Assert.Equal(metaData.TrackNumber.Value, 10);
Assert.Equal(10, metaData.TrackNumber.Value);
Assert.True(metaData.TotalSeconds > 0);
Assert.True(metaData.ValidWeight > 30);
Assert.True(metaData.IsValid);
}
else
{
@ -332,6 +342,7 @@ namespace Roadie.Library.Tests
Assert.Equal(10, metaData.TotalTrackNumbers.Value);
Assert.True(metaData.TotalSeconds > 0);
Assert.True(metaData.ValidWeight > 30);
Assert.True(metaData.IsValid);
}
else
{
@ -354,9 +365,10 @@ namespace Roadie.Library.Tests
Assert.NotNull(metaData.Title);
Assert.True(metaData.Year > 0);
Assert.NotNull(metaData.TrackNumber);
Assert.Equal(metaData.TrackNumber.Value, 10);
Assert.Equal(10, metaData.TrackNumber.Value);
Assert.True(metaData.TotalSeconds > 0);
Assert.True(metaData.ValidWeight > 30);
Assert.True(metaData.IsValid);
}
else
{
@ -365,6 +377,31 @@ namespace Roadie.Library.Tests
}
}
[Fact]
public void ReadID3TagsFromFile5()
{
var file = new FileInfo(@"E:\Roadie_Test_Files\01 Martian.mp3");
if (file.Exists)
{
var tagLib = this.TagsHelper.MetaDataForFile(file.FullName);
Assert.True(tagLib.IsSuccess);
var metaData = tagLib.Data;
Assert.NotNull(metaData.Artist);
Assert.NotNull(metaData.Release);
Assert.NotNull(metaData.Title);
Assert.True(metaData.Year > 0);
Assert.NotNull(metaData.TrackNumber);
Assert.Equal(1, metaData.TrackNumber.Value);
Assert.True(metaData.TotalSeconds > 0);
Assert.True(metaData.ValidWeight > 30);
Assert.True(metaData.IsValid);
}
else
{
Console.WriteLine($"skipping { file}");
Assert.True(true);
}
}
}
}

View file

@ -33,7 +33,7 @@ namespace Roadie.Api.Controllers
[Authorize("Admin")]
public async Task<IActionResult> Scan()
{
var result = await this.AdminService.ScanInboundFolder(await this.UserManager.GetUserAsync(User), true);
var result = await this.AdminService.ScanInboundFolder(await this.UserManager.GetUserAsync(User));
if (!result.IsSuccess)
{
return StatusCode((int)HttpStatusCode.InternalServerError);

View file

@ -76,9 +76,19 @@ namespace Roadie.Api.Services
long processedFolders = 0;
var folderProcessor = new FolderProcessor(this.Configuration, this.HttpEncoder, this.Configuration.LibraryFolder, this.DbContext, this.CacheManager, this.MessageLogger);
var newArtists = 0;
var newReleases = 0;
var newTracks = 0;
foreach (var folder in Directory.EnumerateDirectories(d.FullName).ToArray())
{
await folderProcessor.Process(new DirectoryInfo(folder), isReadOnly);
var result = await folderProcessor.Process(new DirectoryInfo(folder), isReadOnly);
if(result.AdditionalData != null)
{
newArtists += SafeParser.ToNumber<int>(result.AdditionalData["newArtists"]);
newReleases += SafeParser.ToNumber<int>(result.AdditionalData["newReleases"]);
newTracks += SafeParser.ToNumber<int>(result.AdditionalData["newTracks"]);
}
processedFolders++;
}
if (!isReadOnly)
@ -86,6 +96,15 @@ namespace Roadie.Api.Services
folderProcessor.DeleteEmptyFolders(d);
}
sw.Stop();
this.DbContext.ScanHistories.Add(new data.ScanHistory
{
UserId = user.Id,
NewArtists = newArtists,
NewReleases = newReleases,
NewTracks = newTracks,
TimeSpanInSeconds = (int)sw.Elapsed.TotalSeconds
});
await this.DbContext.SaveChangesAsync();
await this.LogAndPublish($"**Completed!Processed Folders[{ processedFolders }], Processed Files[{ processedFiles}] : Elapsed Time[{ sw.Elapsed}]");
return new OperationResult<bool>
{

View file

@ -564,19 +564,19 @@ namespace Roadie.Api.Services
rm.Id,
rm.MediaNumber
});
var releaseTime = releaseTracks.Sum(x => x.time);
var releaseTime = releaseTracks?.Sum(x => x.time) ?? 0;
var releaseStats = new ReleaseStatistics
{
MediaCount = release.MediaCount,
MissingTrackCount = releaseTracks.Where(x => x.isMissing).Count(),
MissingTrackCount = releaseTracks?.Where(x => x.isMissing).Count(),
TrackCount = release.TrackCount,
TrackPlayedCount = release.PlayedCount,
TrackSize = releaseTracks.Sum(x => (long?)x.size).ToFileSize(),
TrackSize = releaseTracks?.Sum(x => (long?)x.size).ToFileSize(),
TrackTime = releaseTracks.Any() ? new TimeInfo((decimal)releaseTime).ToFullFormattedString() : "--:--"
};
result.MaxMediaNumber = releaseMedias.Max(x => x.MediaNumber);
result.MaxMediaNumber = releaseMedias.Any() ? releaseMedias.Max(x => x.MediaNumber) : (short)0;
result.Statistics = releaseStats;
result.MediaCount = release.MediaCount ?? (short?)releaseStats.MediaCount;
result.MediaCount = release.MediaCount ?? (short?)releaseStats?.MediaCount;
}
if (includes.Contains("images"))
{

View file

@ -82,6 +82,7 @@ namespace Roadie.Library.Data
public Artist()
{
this.Releases = new HashSet<Release>();
this.Rating = 0;
}
}

View file

@ -24,15 +24,13 @@ namespace Roadie.Library.Data
public string Profile { get; set; }
[Column("artistCount")]
public int? ArtistCount { get; set; } // TODO update this on artist folder scane
public int? ArtistCount { get; set; }
[Column("releaseCount")]
public int? ReleaseCount { get; set; } // TODO update this on artist folder scan
public int? ReleaseCount { get; set; }
[Column("trackCount")]
public int? TrackCount { get; set; } // TODO update this on artist folder scan
public int? TrackCount { get; set; }
public List<ReleaseLabel> ReleaseLabels { get; set; }
}

View file

@ -109,5 +109,11 @@ namespace Roadie.Library.Data
[Column("urls", TypeName = "text")]
[MaxLength(65535)]
public string URLs { get; set; }
public Release()
{
this.Rating = 0;
this.Medias = new HashSet<ReleaseMedia>();
}
}
}

View file

@ -24,5 +24,10 @@ namespace Roadie.Library.Data
public short TrackCount { get; set; }
public ICollection<Track> Tracks { get; set; }
public ReleaseMedia()
{
this.Tracks = new HashSet<Track>();
}
}
}

View file

@ -85,5 +85,10 @@ namespace Roadie.Library.Data
[Column("trackNumber")]
[Required]
public short TrackNumber { get; set; }
public Track()
{
this.Rating = 0;
}
}
}

View file

@ -27,5 +27,10 @@ namespace Roadie.Library.Data
[Column("userId")]
[Required]
public int UserId { get; set; }
public UserArtist()
{
this.Rating = 0;
}
}
}

View file

@ -27,5 +27,10 @@ namespace Roadie.Library.Data
[Column("userId")]
[Required]
public int UserId { get; set; }
public UserRelease()
{
this.Rating = 0;
}
}
}

View file

@ -112,7 +112,7 @@ namespace Roadie.Library.Factories
}
if (genre != null && genre.Id > 0)
{
sql = string.Format("INSERT INTO `ArtistGenreTable` (ArtistId, genreId) VALUES ({0}, {1});", artist.Id, genre.Id);
sql = string.Format("INSERT INTO `artistGenreTable` (artistId, genreId) VALUES ({0}, {1});", artist.Id, genre.Id);
await this.DbContext.Database.ExecuteSqlCommandAsync(sql);
}
}
@ -236,9 +236,9 @@ namespace Roadie.Library.Factories
Data = resultInCache
};
}
var Artist = this.DatabaseQueryForArtistName(ArtistName);
var artist = this.DatabaseQueryForArtistName(ArtistName);
sw.Stop();
if (Artist == null || !Artist.IsValid)
if (artist == null || !artist.IsValid)
{
this._logger.LogInformation("ArtistFactory: Artist Not Found By Name [{0}]", ArtistName);
if (doFindIfNotInDatabase)
@ -254,12 +254,12 @@ namespace Roadie.Library.Factories
}
if (ArtistSearch.IsSuccess)
{
Artist = ArtistSearch.Data;
artist = ArtistSearch.Data;
// See if Artist already exist with either Name or Sort Name
var alreadyExists = this.DatabaseQueryForArtistName(ArtistSearch.Data.Name, ArtistSearch.Data.SortNameValue);
if (alreadyExists == null || !alreadyExists.IsValid)
{
var addResult = await this.Add(Artist);
var addResult = await this.Add(artist);
if (!addResult.IsSuccess)
{
sw.Stop();
@ -270,24 +270,24 @@ namespace Roadie.Library.Factories
Errors = addResult.Errors
};
}
Artist = addResult.Data;
artist = addResult.Data;
}
else
{
Artist = alreadyExists;
artist = alreadyExists;
}
}
}
}
if (Artist != null && Artist.IsValid)
if (artist != null && artist.IsValid)
{
this.CacheManager.Add(cacheKey, Artist);
this.CacheManager.Add(cacheKey, artist);
}
return new OperationResult<Artist>
{
IsSuccess = Artist != null,
IsSuccess = artist != null,
OperationTime = sw.ElapsedMilliseconds,
Data = Artist
Data = artist
};
}
catch (Exception ex)
@ -301,12 +301,12 @@ namespace Roadie.Library.Factories
/// Merge one Artist into another one
/// </summary>
/// <param name="ArtistToMerge">The Artist to be merged</param>
/// <param name="ArtistToMergeInto">The Artist to merge into</param>
/// <param name="artistToMergeInto">The Artist to merge into</param>
/// <returns></returns>
public async Task<OperationResult<Artist>> MergeArtists(Artist ArtistToMerge, Artist ArtistToMergeInto, bool doDbUpdates = false)
public async Task<OperationResult<Artist>> MergeArtists(Artist ArtistToMerge, Artist artistToMergeInto, bool doDbUpdates = false)
{
SimpleContract.Requires<ArgumentNullException>(ArtistToMerge != null, "Invalid Artist");
SimpleContract.Requires<ArgumentNullException>(ArtistToMergeInto != null, "Invalid Artist");
SimpleContract.Requires<ArgumentNullException>(artistToMergeInto != null, "Invalid Artist");
var result = false;
var now = DateTime.UtcNow;
@ -314,48 +314,48 @@ namespace Roadie.Library.Factories
var sw = new Stopwatch();
sw.Start();
ArtistToMergeInto.RealName = ArtistToMerge.RealName ?? ArtistToMergeInto.RealName;
ArtistToMergeInto.MusicBrainzId = ArtistToMerge.MusicBrainzId ?? ArtistToMergeInto.MusicBrainzId;
ArtistToMergeInto.ITunesId = ArtistToMerge.ITunesId ?? ArtistToMergeInto.ITunesId;
ArtistToMergeInto.AmgId = ArtistToMerge.AmgId ?? ArtistToMergeInto.AmgId;
ArtistToMergeInto.SpotifyId = ArtistToMerge.SpotifyId ?? ArtistToMergeInto.SpotifyId;
ArtistToMergeInto.Thumbnail = ArtistToMerge.Thumbnail ?? ArtistToMergeInto.Thumbnail;
ArtistToMergeInto.Profile = ArtistToMerge.Profile ?? ArtistToMergeInto.Profile;
ArtistToMergeInto.BirthDate = ArtistToMerge.BirthDate ?? ArtistToMergeInto.BirthDate;
ArtistToMergeInto.BeginDate = ArtistToMerge.BeginDate ?? ArtistToMergeInto.BeginDate;
ArtistToMergeInto.EndDate = ArtistToMerge.EndDate ?? ArtistToMergeInto.EndDate;
artistToMergeInto.RealName = ArtistToMerge.RealName ?? artistToMergeInto.RealName;
artistToMergeInto.MusicBrainzId = ArtistToMerge.MusicBrainzId ?? artistToMergeInto.MusicBrainzId;
artistToMergeInto.ITunesId = ArtistToMerge.ITunesId ?? artistToMergeInto.ITunesId;
artistToMergeInto.AmgId = ArtistToMerge.AmgId ?? artistToMergeInto.AmgId;
artistToMergeInto.SpotifyId = ArtistToMerge.SpotifyId ?? artistToMergeInto.SpotifyId;
artistToMergeInto.Thumbnail = ArtistToMerge.Thumbnail ?? artistToMergeInto.Thumbnail;
artistToMergeInto.Profile = ArtistToMerge.Profile ?? artistToMergeInto.Profile;
artistToMergeInto.BirthDate = ArtistToMerge.BirthDate ?? artistToMergeInto.BirthDate;
artistToMergeInto.BeginDate = ArtistToMerge.BeginDate ?? artistToMergeInto.BeginDate;
artistToMergeInto.EndDate = ArtistToMerge.EndDate ?? artistToMergeInto.EndDate;
if (!string.IsNullOrEmpty(ArtistToMerge.ArtistType) && !ArtistToMerge.ArtistType.Equals("Other", StringComparison.OrdinalIgnoreCase))
{
ArtistToMergeInto.ArtistType = ArtistToMerge.ArtistType;
artistToMergeInto.ArtistType = ArtistToMerge.ArtistType;
}
ArtistToMergeInto.BioContext = ArtistToMerge.BioContext ?? ArtistToMergeInto.BioContext;
ArtistToMergeInto.DiscogsId = ArtistToMerge.DiscogsId ?? ArtistToMergeInto.DiscogsId;
artistToMergeInto.BioContext = ArtistToMerge.BioContext ?? artistToMergeInto.BioContext;
artistToMergeInto.DiscogsId = ArtistToMerge.DiscogsId ?? artistToMergeInto.DiscogsId;
ArtistToMergeInto.Tags = ArtistToMergeInto.Tags.AddToDelimitedList(ArtistToMerge.Tags.ToListFromDelimited());
artistToMergeInto.Tags = artistToMergeInto.Tags.AddToDelimitedList(ArtistToMerge.Tags.ToListFromDelimited());
var altNames = ArtistToMerge.AlternateNames.ToListFromDelimited().ToList();
altNames.Add(ArtistToMerge.Name);
altNames.Add(ArtistToMerge.SortName);
ArtistToMergeInto.AlternateNames = ArtistToMergeInto.AlternateNames.AddToDelimitedList(altNames);
ArtistToMergeInto.URLs = ArtistToMergeInto.URLs.AddToDelimitedList(ArtistToMerge.URLs.ToListFromDelimited());
ArtistToMergeInto.ISNIList = ArtistToMergeInto.ISNIList.AddToDelimitedList(ArtistToMerge.ISNIList.ToListFromDelimited());
ArtistToMergeInto.LastUpdated = now;
artistToMergeInto.AlternateNames = artistToMergeInto.AlternateNames.AddToDelimitedList(altNames);
artistToMergeInto.URLs = artistToMergeInto.URLs.AddToDelimitedList(ArtistToMerge.URLs.ToListFromDelimited());
artistToMergeInto.ISNIList = artistToMergeInto.ISNIList.AddToDelimitedList(ArtistToMerge.ISNIList.ToListFromDelimited());
artistToMergeInto.LastUpdated = now;
if (doDbUpdates)
{
string sql = null;
sql = "UPDATE `ArtistGenreTable` set ArtistId = " + ArtistToMergeInto.Id + " WHERE ArtistId = " + ArtistToMerge.Id + ";";
sql = "UPDATE `artistGenreTable` set artistId = " + artistToMergeInto.Id + " WHERE artistId = " + ArtistToMerge.Id + ";";
await this.DbContext.Database.ExecuteSqlCommandAsync(sql);
sql = "UPDATE `image` set ArtistId = " + ArtistToMergeInto.Id + " WHERE ArtistId = " + ArtistToMerge.Id + ";";
sql = "UPDATE `image` set artistId = " + artistToMergeInto.Id + " WHERE artistId = " + ArtistToMerge.Id + ";";
await this.DbContext.Database.ExecuteSqlCommandAsync(sql);
sql = "UPDATE `userArtist` set ArtistId = " + ArtistToMergeInto.Id + " WHERE ArtistId = " + ArtistToMerge.Id + ";";
sql = "UPDATE `userArtist` set artistId = " + artistToMergeInto.Id + " WHERE artistId = " + ArtistToMerge.Id + ";";
await this.DbContext.Database.ExecuteSqlCommandAsync(sql);
sql = "UPDATE `track` set ArtistId = " + ArtistToMergeInto.Id + " WHERE ArtistId = " + ArtistToMerge.Id + ";";
sql = "UPDATE `track` set artistId = " + artistToMergeInto.Id + " WHERE artistId = " + ArtistToMerge.Id + ";";
await this.DbContext.Database.ExecuteSqlCommandAsync(sql);
try
{
sql = "UPDATE `release` set ArtistId = " + ArtistToMergeInto.Id + " WHERE ArtistId = " + ArtistToMerge.Id + ";";
sql = "UPDATE `release` set artistId = " + artistToMergeInto.Id + " WHERE artistId = " + ArtistToMerge.Id + ";";
await this.DbContext.Database.ExecuteSqlCommandAsync(sql);
}
catch (Exception ex)
@ -377,7 +377,7 @@ namespace Roadie.Library.Factories
sw.Stop();
return new OperationResult<Artist>
{
Data = ArtistToMergeInto,
Data = artistToMergeInto,
IsSuccess = result,
OperationTime = sw.ElapsedMilliseconds
};

View file

@ -10,6 +10,9 @@ using Roadie.Library.SearchEngines.MetaData;
using Roadie.Library.SearchEngines.MetaData.Discogs;
using Roadie.Library.SearchEngines.MetaData.Spotify;
using Roadie.Library.SearchEngines.MetaData.Wikipedia;
using System;
using System.Linq;
using System.Threading.Tasks;
namespace Roadie.Library.Factories
{
@ -186,5 +189,58 @@ namespace Roadie.Library.Factories
this._wikipediaArtistSearchEngine = new WikipediaHelper(this.Configuration, this.CacheManager, this.Logger, this.HttpEncoder);
this._discogsArtistSearchEngine = new DiscogsHelper(this.Configuration, this.CacheManager, this.Logger);
}
protected async Task UpdateReleaseCounts(int releaseId, DateTime now)
{
var release = this.DbContext.Releases.FirstOrDefault(x => x.Id == releaseId);
if (release != null)
{
release.Duration = (from t in this.DbContext.Tracks
join rm in this.DbContext.ReleaseMedias on t.ReleaseMediaId equals rm.Id
where rm.ReleaseId == releaseId
select t).Sum(x => x.Duration);
await this.DbContext.SaveChangesAsync();
}
}
protected async Task UpdateArtistCounts(int artistId, DateTime now)
{
var artist = this.DbContext.Artists.FirstOrDefault(x => x.Id == artistId);
if (artist != null)
{
artist.ReleaseCount = this.DbContext.Releases.Where(x => x.ArtistId == artistId).Count();
artist.TrackCount = (from r in this.DbContext.Releases
join rm in this.DbContext.ReleaseMedias on r.Id equals rm.ReleaseId
join tr in this.DbContext.Tracks on rm.Id equals tr.ReleaseMediaId
where r.ArtistId == artistId
select tr).Count();
artist.LastUpdated = now;
await this.DbContext.SaveChangesAsync();
}
}
protected async Task UpdateLabelCounts(int labelId, DateTime now)
{
var label = this.DbContext.Labels.FirstOrDefault(x => x.Id == labelId);
if(label != null)
{
label.ReleaseCount = this.DbContext.ReleaseLabels.Where(x => x.LabelId == label.Id).Count();
label.ArtistCount = (from r in this.DbContext.Releases
join rl in this.DbContext.ReleaseLabels on r.Id equals rl.ReleaseId
join a in this.DbContext.Artists on r.ArtistId equals a.Id
where rl.LabelId == label.Id
group a by a.Id into artists
select artists).Select(x => x.Key).Count();
label.TrackCount = (from r in this.DbContext.Releases
join rl in this.DbContext.ReleaseLabels on r.Id equals rl.ReleaseId
join rm in this.DbContext.ReleaseMedias on r.Id equals rm.ReleaseId
join t in this.DbContext.Tracks on rm.Id equals t.ReleaseMediaId
where rl.LabelId == label.Id
select t).Count();
await this.DbContext.SaveChangesAsync();
}
}
}
}

View file

@ -92,7 +92,7 @@ namespace Roadie.Library.Factories
OR alternatenames like @startAlt
OR alternatenames like @inAlt
OR alternatenames like @endAlt
LIMIT 1;", getParams.ToArray()).FirstOrDefault();
LIMIT 1", getParams.ToArray()).FirstOrDefault();
sw.Stop();
if (Label == null || !Label.IsValid)
{

View file

@ -107,6 +107,7 @@ namespace Roadie.Library.Factories
release.Images = null;
release.Labels = null;
release.Medias = null;
release.Genres = null;
release.LibraryStatus = LibraryStatus.Incomplete;
release.Status = Statuses.New;
if (!release.IsValid)
@ -517,7 +518,7 @@ namespace Roadie.Library.Factories
OR alternatenames like @sinAlt
OR alternatenames like @endAlt
OR alternatenames like @sendAlt)
LIMIT 1;", getParams.ToArray()).FirstOrDefault();
LIMIT 1", getParams.ToArray()).FirstOrDefault();
sw.Stop();
if (release == null || !release.IsValid)
{
@ -1402,7 +1403,7 @@ namespace Roadie.Library.Factories
#region Scan Folder and Add or Update Existing Tracks from Files
var existingReleaseMedia = this.DbContext.ReleaseMedias.Include("tracks").Where(x => x.ReleaseId == release.Id).ToList();
var existingReleaseMedia = this.DbContext.ReleaseMedias.Include(x => x.Tracks).Where(x => x.ReleaseId == release.Id).ToList();
var foundInFolderTracks = new List<Data.Track>();
short totalNumberOfTracksFound = 0;
// This is the number of tracks metadata says the release should have (releaseMediaNumber, TotalNumberOfTracks)
@ -1633,6 +1634,10 @@ namespace Roadie.Library.Factories
}
sw.Stop();
await base.UpdateReleaseCounts(release.Id, now);
await base.UpdateArtistCounts(release.ArtistId, now);
this.Logger.LogInformation("Scanned Release `{0}` Folder [{1}], Modified Release [{2}], OperationTime [{3}]", release.ToString(), releasePath, modifiedRelease, sw.ElapsedMilliseconds);
result = true;
}

View file

@ -214,7 +214,6 @@ namespace Roadie.Library.FilePlugins
}
}
result.IsSuccess = true;
result.AdditionalData.Add(PluginResultInfo.AdditionalDataKeyPluginResultInfo, new PluginResultInfo
{
ArtistFolder = artistFolder,
@ -225,6 +224,7 @@ namespace Roadie.Library.FilePlugins
TrackNumber = metaData.TrackNumber,
TrackTitle = metaData.Title
});
result.IsSuccess = true;
return result;
}

View file

@ -62,6 +62,7 @@ namespace Roadie.Library.Identity
this.DoUseHtmlPlayer = true;
this.PlayerTrackLimit = 50;
this.Timeformat = "YYYY-MM-DD HH:mm:ss";
this.Timezone = "US/Central";
this.IsPrivate = false;
this.RecentlyPlayedLimit = 20;
this.RandomReleaseLimit = 20;

View file

@ -32,7 +32,7 @@ namespace Roadie.Library
[JsonIgnore]
[XmlIgnore]
public Dictionary<string, object> AdditionalData { get; set; }
public Dictionary<string, object> AdditionalData { get; set; } = new Dictionary<string, object>();
/// <summary>
/// Client friendly exceptions

View file

@ -116,11 +116,6 @@ namespace Roadie.Library.Processors
}
if (pluginResults != null)
{
//await Task.Run(() => Parallel.ForEach(pluginResults.GroupBy(x => x.ReleaseId).Select(x => x.First()), async releasesInfo =>
//{
// await this.ReleaseFactory.ScanReleaseFolder(releasesInfo.ReleaseId, this.DestinationRoot, doJustInfo);
//}));
foreach (var releasesInfo in pluginResults.GroupBy(x => x.ReleaseId).Select(x => x.First()))
{
await this.ReleaseFactory.ScanReleaseFolder(releasesInfo.ReleaseId, this.DestinationRoot, doJustInfo);

View file

@ -130,7 +130,8 @@ namespace Roadie.Library.MetaData.ID3Tags
var trackparts = id3v2.TrackNumber?.Split('/');
result.TrackNumber = SafeParser.ToNumber<short?>(trackparts[0]);
result.TotalTrackNumbers = trackparts.Length > 1 ? SafeParser.ToNumber<short?>(trackparts[1]) : 0;
result.Year = SafeParser.ToNumber<int?>(id3v2.Year);
var date = SafeParser.ToDateTime(id3v2.Year);
result.Year = date?.Year ?? SafeParser.ToNumber<int?>(id3v2.Year);
isSuccess = true;
}

View file

@ -58,7 +58,7 @@ CREATE TABLE `artist` (
UNIQUE KEY `ix_artist_name` (`name`),
UNIQUE KEY `ix_artist_sortname` (`sortName`),
KEY `ix_artist_roadieId` (`roadieId`)
) ENGINE=InnoDB AUTO_INCREMENT=35855 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -77,7 +77,7 @@ CREATE TABLE `artistAssociation` (
KEY `idx_artistAssociation` (`artistId`,`associatedArtistId`),
CONSTRAINT `artistAssociation_ibfk_1` FOREIGN KEY (`artistId`) REFERENCES `artist` (`id`) ON DELETE CASCADE,
CONSTRAINT `artistAssociation_ibfk_2` FOREIGN KEY (`associatedArtistId`) REFERENCES `artist` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=181 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -97,7 +97,7 @@ CREATE TABLE `artistGenreTable` (
KEY `ix_artistGenreTable_artistId` (`artistId`),
CONSTRAINT `artistGenreTable_ibfk_1` FOREIGN KEY (`artistId`) REFERENCES `artist` (`id`) ON DELETE CASCADE,
CONSTRAINT `artistGenreTable_ibfk_2` FOREIGN KEY (`genreId`) REFERENCES `genre` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=30900 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -124,7 +124,7 @@ CREATE TABLE `bookmark` (
KEY `ix_bookmark_roadieId` (`roadieId`),
KEY `ix_bookmark_userId` (`userId`),
CONSTRAINT `bookmark_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `user` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=588 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -146,7 +146,7 @@ CREATE TABLE `chatMessage` (
PRIMARY KEY (`id`),
KEY `idx_user` (`userId`),
CONSTRAINT `chatMessage_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `user` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=82 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -207,7 +207,7 @@ CREATE TABLE `collectionrelease` (
KEY `ix_collectionrelease_roadieId` (`roadieId`),
CONSTRAINT `collectionrelease_ibfk_1` FOREIGN KEY (`releaseId`) REFERENCES `release` (`id`) ON DELETE CASCADE,
CONSTRAINT `collectionrelease_ibfk_2` FOREIGN KEY (`collectionId`) REFERENCES `collection` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=48191 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -228,7 +228,7 @@ CREATE TABLE `genre` (
PRIMARY KEY (`id`),
UNIQUE KEY `ix_genre_name` (`name`),
KEY `ix_genre_roadieId` (`roadieId`)
) ENGINE=InnoDB AUTO_INCREMENT=1912 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -257,7 +257,7 @@ CREATE TABLE `image` (
KEY `ix_image_artistId` (`artistId`),
CONSTRAINT `image_ibfk_1` FOREIGN KEY (`artistId`) REFERENCES `artist` (`id`) ON DELETE CASCADE,
CONSTRAINT `image_ibfk_2` FOREIGN KEY (`releaseId`) REFERENCES `release` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=77949 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -292,7 +292,7 @@ CREATE TABLE `label` (
PRIMARY KEY (`id`),
UNIQUE KEY `ix_label_name` (`name`),
KEY `ix_label_roadieId` (`roadieId`)
) ENGINE=InnoDB AUTO_INCREMENT=2291 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -325,7 +325,7 @@ CREATE TABLE `playlist` (
KEY `ix_playlist_roadieId` (`roadieId`),
KEY `ix_playlist_userId` (`userId`),
CONSTRAINT `playlist_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `user` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -351,7 +351,7 @@ CREATE TABLE `playlisttrack` (
KEY `ix_playlisttrack_roadieId` (`roadieId`),
CONSTRAINT `playlisttrack_ibfk_1` FOREIGN KEY (`trackId`) REFERENCES `track` (`id`) ON DELETE CASCADE,
CONSTRAINT `playlisttrack_ibfk_2` FOREIGN KEY (`playListId`) REFERENCES `playlist` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1060 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -398,7 +398,7 @@ CREATE TABLE `release` (
KEY `ix_release_roadieId` (`roadieId`),
KEY `ix_release_title` (`title`),
CONSTRAINT `release_ibfk_1` FOREIGN KEY (`artistId`) REFERENCES `artist` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=26476 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -445,7 +445,7 @@ CREATE TABLE `releaselabel` (
KEY `ix_releaselabel_roadieId` (`roadieId`),
CONSTRAINT `releaselabel_ibfk_1` FOREIGN KEY (`releaseId`) REFERENCES `release` (`id`) ON DELETE CASCADE,
CONSTRAINT `releaselabel_ibfk_2` FOREIGN KEY (`labelId`) REFERENCES `label` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=9374 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -470,7 +470,7 @@ CREATE TABLE `releasemedia` (
KEY `ix_releasemedia_roadieId` (`roadieId`),
KEY `releasemedia_releaseId_IDX` (`releaseId`,`releaseMediaNumber`) USING BTREE,
CONSTRAINT `releasemedia_ibfk_1` FOREIGN KEY (`releaseId`) REFERENCES `release` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=24953 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -492,7 +492,7 @@ CREATE TABLE `request` (
KEY `ix_request_roadieId` (`roadieId`),
KEY `requestartist_ibfk_1` (`userId`),
CONSTRAINT `requestartist_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `user` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1028 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -519,7 +519,7 @@ CREATE TABLE `scanHistory` (
KEY `ix_scanHistory_roadieId` (`roadieId`),
KEY `rscanHistoryt_ibfk_1` (`userId`),
CONSTRAINT `scanHistory_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `user` (`id`) ON DELETE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1026 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -541,7 +541,7 @@ CREATE TABLE `submission` (
KEY `ix_submission_roadieId` (`roadieId`),
KEY `submission_ibfk_1` (`userId`),
CONSTRAINT `submission_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `user` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -587,7 +587,7 @@ CREATE TABLE `track` (
KEY `track_artistId_IDX` (`artistId`) USING BTREE,
KEY `track_releaseMediaId_IDX` (`releaseMediaId`) USING BTREE,
CONSTRAINT `track_ibfk_1` FOREIGN KEY (`releaseMediaId`) REFERENCES `releasemedia` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=267358 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -659,7 +659,7 @@ CREATE TABLE `user` (
UNIQUE KEY `email` (`email`),
UNIQUE KEY `ix_user_username` (`username`),
KEY `ix_user_roadieId` (`roadieId`)
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -750,7 +750,7 @@ CREATE TABLE `userartist` (
KEY `ix_userartist_roadieId` (`roadieId`),
CONSTRAINT `userartist_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `user` (`id`) ON DELETE CASCADE,
CONSTRAINT `userartist_ibfk_2` FOREIGN KEY (`artistId`) REFERENCES `artist` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -778,7 +778,7 @@ CREATE TABLE `userrelease` (
KEY `ix_userrelease_roadieId` (`roadieId`),
CONSTRAINT `userrelease_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `user` (`id`) ON DELETE CASCADE,
CONSTRAINT `userrelease_ibfk_2` FOREIGN KEY (`releaseId`) REFERENCES `release` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=222 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -802,7 +802,7 @@ CREATE TABLE `userrole` (
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
KEY `ix_userrole_roadieId` (`roadieId`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -851,7 +851,7 @@ CREATE TABLE `usertrack` (
KEY `ix_usertrack_roadieId` (`roadieId`),
CONSTRAINT `usertrack_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `user` (`id`) ON DELETE CASCADE,
CONSTRAINT `usertrack_ibfk_2` FOREIGN KEY (`trackId`) REFERENCES `track` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=25874 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--