public async Task <MusicAlbumModel> GetAlbumAsync(ReleaseGroup x)
        {
            ClientUrlsOptions clientUrls = _configuration.GetSection(ClientUrlsOptions.ClientUrls).Get <ClientUrlsOptions>();

            List <string> albumImages = null;

            try
            {
                string artUrl      = string.Format(clientUrls.CoverArtUrl, x.CoverArtId);
                var    coverArtRet = await _httpClientHandler.createHttpResponse(artUrl);

                albumImages = _helper.GetCoverArtImages(coverArtRet) ?? new List <string>();
            }
            catch (Exception ex)
            {
                if (!ex.Message.Contains("404")) //some images doesnt exist
                {
                    throw;
                }
            }

            return(new MusicAlbumModel()
            {
                CoverArtId = x.CoverArtId, Title = x.Title, ImageUrls = albumImages
            });
        }
示例#2
0
        private async Task <AlbumData> GetAlbumDataAsync(ReleaseGroup album)
        {
            var albumData = new AlbumData
            {
                Title = album.Title,
                Id    = album.Id.ToString()
            };
            var url = $"http://coverartarchive.org/release-group/{album.Id}";

            try
            {
                var response = await _httpClient.GetStringAsync(url);

                var coverArt = JsonConvert.DeserializeObject <CoverArtData>(response);
                foreach (var image in coverArt.images)
                {
                    if (image.front)
                    {
                        albumData.Image = image.image;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                // Some albums doesn´t have a image. Image will be null.
            }
            return(albumData);
        }
示例#3
0
        public static async Task Search(string band, string album)
        {
            // Build an advanced query to search for the release.
            var query = new QueryParameters <ReleaseGroup>()
            {
                { "artist", band },
                { "releasegroup", album },
                { "type", "album" },
                { "status", "official" }
            };

            // Search for an release-group by title.
            var groups = await ReleaseGroup.SearchAsync(query);

            Console.WriteLine("Total matches for '{0} - {1}': {2}", band, album, groups.Count);

            // Get best match.
            var group = groups.Items.First();

            // Get detailed information of the release-group, including artists, releases and related urls.
            group = await ReleaseGroup.GetAsync(group.Id, "artists", "releases", "url-rels");

            var artist = group.Credits.First().Artist;

            Console.WriteLine();
            Console.WriteLine("Official album releases of '{0} - {1}':", artist.Name, group.Title);
            Console.WriteLine();

            foreach (var item in group.Releases.OrderBy(r => r.Date))
            {
                Console.WriteLine("     {0} - {1}  {2}", item.Date.ToShortDate(), item.Id, item.Country);
            }

            // Check if there are lyrcis available for the album.
            var lyrics = group.Relations.Where(r => r.Type == "lyrics");

            if (lyrics.Count() > 0)
            {
                Console.WriteLine();
                Console.WriteLine("You can find lyrics for '{0} - {1}' at", artist.Name, group.Title);
                Console.WriteLine();
                Console.WriteLine("     {0}", lyrics.First().Url.Resource);
                Console.WriteLine();
            }

            // Check if there's a wikipedia page for the album.
            var wiki = group.Relations.Where(r => r.Type == "wikipedia");

            if (wiki.Count() > 0)
            {
                Console.WriteLine();
                Console.WriteLine("More info for '{0} - {1}' at", artist.Name, group.Title);
                Console.WriteLine();
                Console.WriteLine("     {0}", wiki.First().Url.Resource);
                Console.WriteLine();
            }
        }
示例#4
0
        public static Uri GetMusicBrainzCoverArtUri(this ReleaseGroup release)
        {
            if (release.Releases.First()?.CoverArtArchive?.Front ?? false)
            {
                string url = "https://coverartarchive.org/release/" + release.Id + "/front-250.jpg";
                return(new Uri(url, UriKind.RelativeOrAbsolute));
            }

            return(null);
        }
        internal CsprojSettings(IDictionary <string, string?> projectWideSettings,
                                IDictionary <string, string?> debugSettings,
                                IDictionary <string, string?> releaseSettings)
        {
            ProjectWideGroup = CreatePropertyGroup(projectWideSettings);

            DebugGroup = CreatePropertyGroup(debugSettings);
            DebugGroup?.Add(new XAttribute(Constants.Condition, string.Format(Mode, Constants.Debug)));

            ReleaseGroup = CreatePropertyGroup(releaseSettings);
            ReleaseGroup?.Add(new XAttribute(Constants.Condition, string.Format(Mode, Constants.Release)));
        }
示例#6
0
        private static async Task Browse(string name)
        {
            // Search for an artist by name (limit to 20 matches).
            var artists = await Artist.SearchAsync(name.Quote(), 20);

            Console.WriteLine("Browsing release-groups of '{0}'", name);

            var artist = artists.Items.OrderByDescending(a => Levenshtein.Similarity(a.Name, name)).First();

            int limit = 50;

            // Browse the first 50 release-groups of given artist, include ratings.
            var groups = await ReleaseGroup.BrowseAsync("artist", artist.Id, limit, 0, "ratings");

            Console.WriteLine();
            Console.WriteLine("Album");
            Console.WriteLine();

            // Show offical albums.
            foreach (var item in groups.Items.Where(g => IsOffical(g)).OrderBy(g => g.FirstReleaseDate))
            {
                Console.WriteLine("     {0} - {1}  {2}  {3}", item.FirstReleaseDate.ToShortDate(),
                                  item.Id, GetRating(item.Rating, 10), item.Title);
            }

            Console.WriteLine();
            Console.WriteLine("Album + Compilation");
            Console.WriteLine();

            // Show compilations.
            foreach (var item in groups.Items.Where(g => IsCompilation(g)).OrderBy(g => g.FirstReleaseDate))
            {
                Console.WriteLine("     {0} - {1}  {2}  {3}", item.FirstReleaseDate.ToShortDate(),
                                  item.Id, GetRating(item.Rating, 10), item.Title);
            }

            Console.WriteLine();

            if (groups.Items.Count == limit)
            {
                Console.WriteLine("There are probably more items to browse ...");
            }

            Console.WriteLine();
        }
示例#7
0
 static bool IsCompilation(ReleaseGroup g)
 {
     return(g.PrimaryType.Equals("album", StringComparison.OrdinalIgnoreCase) &&
            g.SecondaryTypes.Contains("Compilation") &&
            !string.IsNullOrEmpty(g.FirstReleaseDate));
 }
示例#8
0
 static bool IsOffical(ReleaseGroup g)
 {
     return(g.PrimaryType.Equals("album", StringComparison.OrdinalIgnoreCase) &&
            g.SecondaryTypes.Count == 0 &&
            !string.IsNullOrEmpty(g.FirstReleaseDate));
 }
示例#9
0
        private static async Task <IRestResponse <CoverImages> > RequestForCoverAsync(ReleaseGroup album, IRestClient client, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var request  = new RestRequest(album.Id, Method.GET);
            var response = await client.ExecuteAsync <CoverImages>(request, cancellationToken);

            if (response.Data != null)
            {
                response.Data.AlbumId = album.Id;
            }

            return(response);
        }
示例#10
0
 public ReleaseGroupTests()
 {
     this.group = TestHelper.GetJson <ReleaseGroup>("releasegroup-get.json");
 }
示例#11
0
 public ReleaseGroupTests()
 {
     this.group = TestHelper.Get <ReleaseGroup>("releasegroup-get.xml");
 }