/// <summary> /// Adds the entry to the statistic collection if it passes the criteria (passed in at constructor) /// </summary> public void FilteredAdd(ILibraryEntry entry) { if (_statisticSelector(entry)) { this.Collection.Add(entry, _keySelector); } }
/// <summary> /// Calculates library entry by audio fingerprint using an online api. /// </summary> public static async Task <ILibraryMetaEntry> IdentifyFingerprint(ILibraryEntry entry) { var context = new AcoustID.ChromaContext(); using (var service = new LookupService()) { } }
public static string GetArtworkKey(ILibraryEntry libraryEntry) { if (!HasValidArtworkKey(libraryEntry)) { return(null); } return(string.Join(',', libraryEntry.AlbumArtists, libraryEntry.Album)); }
public bool ContainsArtworkFor(ILibraryEntry entry) { if (!LibraryArtworkLoader.HasValidArtworkKey(entry)) { return(false); } return(_artwork.ContainsKey(LibraryArtworkLoader.GetArtworkKey(entry))); }
public static bool HasValidArtworkKey(ILibraryEntry libraryEntry) { if (libraryEntry.IsUnknown(x => x.AlbumArtists) || libraryEntry.IsUnknown(x => x.Album)) { return(false); } return(true); }
/// <summary> /// Combined add method to update all library collections /// </summary> public void Add(ILibraryEntry entry) { // All Titles this.AllTitles.Add(entry, x => x.FileName); // Statistics foreach (var statistic in this.Statistics) { statistic.FilteredAdd(entry); } }
/// <summary> /// Tries to look up information for the provided library entry /// </summary> public static IEnumerable <MusicBrainzRecord> Query(ILibraryEntry entry) { return(MusicBrainz.Search .Recording(entry.Title, artist: entry.AlbumArtists.FirstOrDefault(), release: entry.Album) .Data .Select(result => new { Id = result.Id, Title = result.Title, Releases = result.Releaselist, Artists = result.Artistcredit }) .SelectMany(x => x.Releases.Select(release => { uint year = 0; if (!uint.TryParse(release.Date, out year)) { year = 0; } return new { Id = x.Id, Title = x.Title, Release = release.Title, Track = release.Mediumlist.Medium.Position, Country = release.Country, Status = release.Status, Year = year, Artists = x.Artists.Select(artist => artist.Artist.Sortname) }; })) .Select(x => new MusicBrainzRecord(x.Id) { Album = x.Release, AlbumArtists = new SortedObservableCollection <string, string>(x.Artists, x => x), MusicBrainzReleaseCountry = x.Country, MusicBrainzReleaseStatus = x.Status, Title = x.Title, Track = (uint)x.Track, Year = x.Year }) .OrderBy(x => x.Title) .Actualize()); }
public static bool IsUnknown <T>(this ILibraryEntry entry, Expression <Func <ILibraryEntry, T> > propertyExpression) { var expression = (MemberExpression)propertyExpression.Body; var propertyInfo = (PropertyInfo)expression.Member; var propertyValue = propertyInfo.GetValue(entry); // String if (propertyInfo.PropertyType == typeof(string)) { if (string.IsNullOrWhiteSpace((string)propertyValue)) { return(true); } else if ((string)propertyValue == UNKNOWN) { return(true); } else { return(false); } } // Collections of strings else if (propertyInfo.PropertyType == typeof(SortedObservableCollection <string, string>)) { var collection = propertyValue as SortedObservableCollection <string, string>; return(collection.Count() == 0); } // uint else if (propertyInfo.PropertyType == typeof(uint)) { return((uint)propertyValue <= 0); } else { throw new Exception("Unhandled unknown field type LibraryEntry.IsUnknown"); } }
public static async Task <SerializableBitmap> DownloadArtwork(ILibraryEntry entry) { if (entry.IsUnknown(x => x.Album) || entry.IsUnknown(x => x.AlbumArtists)) { return(await Task.FromResult <SerializableBitmap>(null)); } else { try { // Last FM API var client = new LastfmClient(WebConfiguration.LastFmAPIKey, WebConfiguration.LastFmAPISecret); // Web Call ... var response = await client.Album.GetInfoAsync(entry.AlbumArtists.First(), entry.Album, false); // Status OK -> Create bitmap image from the url if (response.Status == LastResponseStatus.Successful && response.Content.Images.Any()) { return(await DownloadImage(response.Content.Images.ExtraLarge.AbsoluteUri)); } else { return(await Task.FromResult <SerializableBitmap>(null)); } } catch (Exception) { return(await Task.FromResult <SerializableBitmap>(null)); } } }
public SerializableBitmap GetArtwork(ILibraryEntry entry) { return(_artwork[LibraryArtworkLoader.GetArtworkKey(entry)]); }
public void AddEntry(ILibraryEntry entry) { _entries.Add(entry.FileName, entry); }