Ejemplo n.º 1
0
        protected async override Task LoadImage()
        {
            var diAlbumCover = new DirectoryInfo(HurricaneSettings.Instance.CoverDirectory);

            Image = MusicCoverManager.GetYouTubeImage(this, diAlbumCover);

            if (Image == null)
            {
                Image = MusicCoverManager.GetImage(this, diAlbumCover);
            }

            if (Image == null && HurricaneSettings.Instance.Config.LoadAlbumCoverFromInternet)
            {
                try
                {
                    if (!string.IsNullOrEmpty(ThumbnailUrl))
                    {
                        Image = await YouTubeApi.LoadBitmapImage(this, diAlbumCover);
                    }

                    if (Image == null)
                    {
                        Image = await MusicCoverManager.LoadCoverFromWeb(this, diAlbumCover, Uploader != Artist).ConfigureAwait(false);
                    }
                }
                catch (WebException)
                {
                    //Happens, doesn't matter
                }
            }
        }
Ejemplo n.º 2
0
        protected async override Task LoadImage(DirectoryInfo albumCoverDirectory)
        {
            if (albumCoverDirectory.Exists)
            {
                var imageFile =
                    albumCoverDirectory.GetFiles("*.jpg")
                    .FirstOrDefault(item => item.Name.ToLower() == YouTubeId.ToLower());

                if (imageFile != null)
                {
                    Image = new BitmapImage(new Uri(imageFile.FullName));
                    return;
                }

                Image = MusicCoverManager.GetAlbumImage(this, albumCoverDirectory);
                if (Image != null)
                {
                    return;
                }
            }


            if (HurricaneSettings.Instance.Config.LoadAlbumCoverFromInternet)
            {
                try
                {
                    if (!string.IsNullOrEmpty(ThumbnailUrl))
                    {
                        Image = await YouTubeApi.LoadBitmapImage(this, albumCoverDirectory);

                        if (Image != null)
                        {
                            return;
                        }
                    }

                    Image = await MusicCoverManager.LoadCoverFromWeb(this, albumCoverDirectory, Uploader != Artist);
                }
                catch (WebException)
                {
                    //Happens, doesn't matter
                }
            }
        }