public WesternClassicalCompositionSet(MusicDb db, MusicOptions musicOptions, string composerName, string compositionName, IEnumerable <MusicFile> musicFiles, TaskItem taskItem) : base(db, musicOptions, MusicStyles.WesternClassical, musicFiles, taskItem) { var fileNameList = musicFiles.Select(x => Path.GetFileName(x.File)); this.ComposerName = musicOptions.ReplaceAlias(composerName); this.CompositionName = musicOptions.ReplaceAlias(compositionName); //**NB** following calls must remain in this order!! conductors = GetConductors(); orchestras = GetOrchestras(); otherPerformers = GetOtherPerformers(); }
private IEnumerable <string> GetOrchestras() { return(MusicFiles .Where(x => x.GetOrchestra() != null) .Select(x => MusicOptions.ReplaceAlias(x.GetOrchestra())) .Distinct(comparer) .OrderBy(x => x)); }
private IEnumerable <string> GetConductors() { return(MusicFiles .Where(x => x.GetConductor() != null) .Select(x => MusicOptions.ReplaceAlias(x.GetConductor())) .Distinct(comparer) .OrderBy(x => x.GetLastName())); }
public void LoadTags(IEnumerable <string> movementFilenames, IEnumerable <WesternClassicalMusicFileTEO> trackTeos) { MovementFilenames = movementFilenames;// fileTeoList.Select(x => x.File); SetMovementTEOList(trackTeos); var performanceIdList = MovementList.Select(t => t.PerformanceId).Distinct(); Debug.Assert(performanceIdList.Count() == 1); PerformanceId = performanceIdList.First();// ?? 0; ComposerTag = new TagValueStatus(TagNames.Composer, MovementList.Where(x => x.ComposerTag != null).SelectMany(x => x.ComposerTag.Values)); CompositionTag = new TagValueStatus(TagNames.Composition, MovementList.Where(x => x.CompositionTag != null).SelectMany(x => x.CompositionTag.Values)); OrchestraTag = new TagValueStatus(TagNames.Orchestra, MovementList.Where(x => x.OrchestraTag != null).SelectMany(x => x.OrchestraTag.Values)); ConductorTag = new TagValueStatus(TagNames.Conductor, MovementList.Where(x => x.ConductorTag != null).SelectMany(x => x.ConductorTag.Values)); var allPerformers = MovementList .Where(x => x.PerformerTag != null) .SelectMany(x => x.PerformerTag.Values) .Select(x => x.Value) .ToList(); for (int i = 0; i < allPerformers.Count(); ++i) { var performer = allPerformers[i]; var p = Regex.Replace(performer, @"\(.*?\)", "").Trim(); allPerformers[i] = p; } allPerformers = allPerformers .Select(x => musicOptions.ReplaceAlias(x)) .Distinct(accentsAndCaseInsensitiveComparer) .OrderBy(x => x.GetLastName()) .ToList(); // now remove any performers that are already defined as orchestras foreach (var name in OrchestraTag.Values.Select(x => x.Value)) { var matched = allPerformers.FirstOrDefault(x => x.IsEqualIgnoreAccentsAndCase(name)); if (matched != null) { allPerformers.Remove(matched); } } // now remove any performers that are already defined as conductors foreach (var name in ConductorTag.Values.Select(x => x.Value)) { var matched = allPerformers.FirstOrDefault(x => x.IsEqualIgnoreAccentsAndCase(name)); if (matched != null) { allPerformers.Remove(matched); } } PerformerTag = new TagValueStatus(TagNames.Performer, allPerformers, true); }
private IEnumerable <string> GetOtherPerformers() { var _names = new List <string>(); foreach (var mf in MusicFiles) { var list = mf.GetPerformers() .Select(x => MusicOptions.ReplaceAlias(x)) .Except(new string[] { MusicOptions.ReplaceAlias(mf.Musician) }, comparer) ; _names.AddRange(list); } //names = names.Distinct(comparer).ToList(); _names = _names.Distinct(comparer).ToList(); var g1 = _names.GroupBy(x => x.GetLastName()); var names = new List <string>(); foreach (var item in g1) { if (!ComposerName.EndsWithIgnoreAccentsAndCase(item.Key)) { names.Add(item.OrderByDescending(x => x.Length).First()); } } names = names //.Distinct(comparer) .OrderBy(x => x.GetLastName()) //.ThenBy(x => x) .ToList(); foreach (var orchestra in orchestras) { names = RemoveName(names, orchestra).ToList(); } foreach (var conductor in conductors) { names = RemoveName(names, conductor).ToList(); } return(names); }
protected async Task <Artist> GetArtistAsync(string name) { Debug.Assert(MusicDb != null); name = MusicOptions.ReplaceAlias(name); Artist artist = FindArtist(name); if (artist == null) { artist = new Artist { UID = Guid.NewGuid(), Name = name, Type = ArtistType.Artist, OriginalName = name, }; artist.ArtistStyles.Add(new ArtistStyle { Artist = artist, StyleId = MusicStyle }); log.Debug($"{taskItem} new artist instance for {name}, {artist.Id}"); if (this is PopularMusicAlbumSet && OpusType == OpusType.Collection) { artist.Type = ArtistType.Various; } await MusicDb.Artists.AddAsync(artist); await MusicDb.SaveChangesAsync(); } if (artist.Type != ArtistType.Various) { // var artistFoldername = OpusType == OpusType.Collection ? null : FirstFile.OpusPath.Split('\\')[0];// Path.GetFileName(Path.GetDirectoryName(FirstFile.File)); var portrait = artist.GetPortraitFile(MusicOptions); if (portrait != null) { artist.Portrait = await portrait.GetImage(); } } artist.LastModified = DateTimeOffset.Now; return(artist); }
public WesternClassicalAlbumSet(MusicDb db, MusicOptions musicOptions, IEnumerable <MusicFile> musicFiles, TaskItem taskItem) : base(db, musicOptions, MusicStyles.WesternClassical, musicFiles, taskItem) { this.ArtistName = OpusType == OpusType.Collection ? "Various Composers" : MusicOptions.ReplaceAlias(FirstFile.Musician); this.AlbumName = FirstFile.OpusName; this.YearNumber = FirstFile.GetYear() ?? 0; }