Example #1
0
        public async Task <ReleaseGroup> GetAlbum(string albumId)
        {
            var g = await _musicBrainzApi.GetAlbumInformation(albumId);

            var release = new ReleaseGroup
            {
                ReleaseType = g.ReleaseGroup.PrimaryType,
                Id          = g.Id,
                Title       = g.Title,
                ReleaseDate = g.ReleaseGroup.FirstReleaseDate,
            };

            await RunSearchRules(release);

            return(release);
        }
Example #2
0
        public async Task <ArtistInformation> GetArtistInformation(string artistId)
        {
            var artist = await _musicBrainzApi.GetArtistInformation(artistId);

            var lidarrSettings = await GetLidarrSettings();

            Task <ArtistResult> lidarrArtistTask = null;

            if (lidarrSettings.Enabled)
            {
                lidarrArtistTask = _lidarrApi.GetArtistByForeignId(artistId, lidarrSettings.ApiKey, lidarrSettings.FullUri);
            }

            var info = new ArtistInformation
            {
                Id             = artistId,
                Name           = artist.Name,
                Country        = artist.Country,
                Region         = artist.Area?.Name,
                Type           = artist.Type,
                StartYear      = artist.LifeSpan?.Begin ?? "",
                EndYear        = artist.LifeSpan?.End ?? "",
                Disambiguation = artist.Disambiguation,
                ReleaseGroups  = new List <ReleaseGroup>(),
                Members        = new List <BandMember>()
            };

            foreach (var g in artist.ReleaseGroups)
            {
                var release = new ReleaseGroup
                {
                    ReleaseType = g.PrimaryType,
                    Id          = g.Id,
                    Title       = g.Title,
                    ReleaseDate = g.FirstReleaseDate,
                };

                await RunSearchRules(release);

                info.ReleaseGroups.Add(release);
            }

            info.Links   = GetLinksForArtist(artist);
            info.Members = GetBandMembers(artist);

            if (lidarrArtistTask != null)
            {
                try
                {
                    var artistResult = await lidarrArtistTask;
                    info.Banner   = artistResult.images?.FirstOrDefault(x => x.coverType.Equals("banner", StringComparison.InvariantCultureIgnoreCase))?.url.ToHttpsUrl();
                    info.Logo     = artistResult.images?.FirstOrDefault(x => x.coverType.Equals("logo", StringComparison.InvariantCultureIgnoreCase))?.url.ToHttpsUrl();
                    info.Poster   = artistResult.images?.FirstOrDefault(x => x.coverType.Equals("poster", StringComparison.InvariantCultureIgnoreCase))?.url.ToHttpsUrl();
                    info.FanArt   = artistResult.images?.FirstOrDefault(x => x.coverType.Equals("fanart", StringComparison.InvariantCultureIgnoreCase))?.url.ToHttpsUrl();
                    info.Overview = artistResult.overview;
                }
                catch (JsonSerializationException)
                {
                    // swallow, Lidarr probably doesn't have this artist
                }
            }

            return(info);
        }