コード例 #1
0
        private ReleaseData GetReleaseImages(DatabaseRelease release)
        {
            ReleaseData data = new ReleaseData();

            data.Release = release;

            var searchResult   = this.RunSearch(release);
            var releaseResults = searchResult.Results.Cast <ReleaseSearchResult>().ToArray();
            List <ReleaseSearchResult> releasesToScan = new List <ReleaseSearchResult>();

            var firstReleases = releaseResults.Take(15).Select(r => this.discogs.GetRelease(r.Id)).ToArray();

            if (firstReleases.Any(r => this.MatchTracklist(release, r) && r.Images != null && r.Images.Length > 0))
            {
                foreach (ReleaseSearchResult releaseResult in releaseResults.Take(30))
                {
                    Release discogsRelease = this.discogs.GetRelease(releaseResult.Id);
                    if (this.MatchTracklist(release, discogsRelease) && discogsRelease.Images != null && discogsRelease.Images.Length > 0)
                    {
                        releasesToScan.Add(releaseResult);
                    }
                }
            }
            else
            {
                releasesToScan.AddRange(releaseResults);
            }

            foreach (var releaseResult in releasesToScan)
            {
                if (data.Images.Count >= 9)
                {
                    break;
                }

                var discogsRelease = discogs.GetRelease(releaseResult.Id);
                var image          = discogsRelease.Aggregate.DesiredImage;
                if (image == null)
                {
                    continue;
                }
                var imageData = this.discogs.GetImage(image.Uri);

                data.Images.Add(new ImageItem()
                {
                    Image = image,
                    Data  = imageData
                });
            }

            data.Deduplicate();

            return(data);
        }
コード例 #2
0
        private ReleaseData GetReleaseImages(DatabaseRelease release)
        {
            ReleaseData data = new ReleaseData();
            data.Release = release;

            var searchResult = this.RunSearch(release);
            var releaseResults = searchResult.Results.Cast<ReleaseSearchResult>().ToArray();
            List<ReleaseSearchResult> releasesToScan = new List<ReleaseSearchResult>();

            var firstReleases = releaseResults.Take(15).Select(r => this.discogs.GetRelease(r.Id)).ToArray();
            if (firstReleases.Any(r => this.MatchTracklist(release, r) && r.Images != null && r.Images.Length > 0))
            {
                foreach (ReleaseSearchResult releaseResult in releaseResults.Take(30))
                {
                    Release discogsRelease = this.discogs.GetRelease(releaseResult.Id);
                    if (this.MatchTracklist(release, discogsRelease) && discogsRelease.Images != null && discogsRelease.Images.Length > 0)
                    {
                        releasesToScan.Add(releaseResult);
                    }
                }
            }
            else
            {
                releasesToScan.AddRange(releaseResults);
            }

            foreach (var releaseResult in releasesToScan)
            {
                if (data.Images.Count >= 9)
                {
                    break;
                }

                var discogsRelease = discogs.GetRelease(releaseResult.Id);
                var image = discogsRelease.Aggregate.DesiredImage;
                if (image == null)
                {
                    continue;
                }
                var imageData = this.discogs.GetImage(image.Uri);

                data.Images.Add(new ImageItem()
                {
                    Image = image,
                    Data = imageData
                });
            }

            data.Deduplicate();

            return data;
        }