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

            Image = MusicCoverManager.GetSoundCloudImage(this, diAlbumCover, HurricaneSettings.Instance.Config.DownloadAlbumCoverQuality, HurricaneSettings.Instance.Config.LoadAlbumCoverFromInternet);

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

            if (Image == null && HurricaneSettings.Instance.Config.LoadAlbumCoverFromInternet)
            {
                try
                {
                    if (!string.IsNullOrEmpty(ArtworkUrl))
                    {
                        Image = await SoundCloudApi.LoadBitmapImage(this, HurricaneSettings.Instance.Config.DownloadAlbumCoverQuality, diAlbumCover);
                    }
                    if (Image == null)
                    {
                        Image = await MusicCoverManager.LoadCoverFromWeb(this, diAlbumCover, Uploader != Artist).ConfigureAwait(false);
                    }
                }
                catch (WebException)
                {
                    //Happens, doesn't matter
                }
            }
        }
Example #2
0
        protected async override Task LoadImage()
        {
            try
            {
                using (var file = File.Create(Path))
                {
                    if (file.Tag.Pictures != null && file.Tag.Pictures.Any())
                    {
                        Image = ImageHelper.ByteArrayToBitmapImage(file.Tag.Pictures.First().Data.ToArray());
                    }
                }
            }
            catch (Exception)
            {
                Image = null;
            }

            if (Image == null)
            {
                DirectoryInfo diAlbumCover = new DirectoryInfo(HurricaneSettings.Instance.CoverDirectory);
                Image = MusicCoverManager.GetImage(this, diAlbumCover);
                if (Image == null && HurricaneSettings.Instance.Config.LoadAlbumCoverFromInternet)
                {
                    try
                    {
                        Image = await MusicCoverManager.LoadCoverFromWeb(this, diAlbumCover).ConfigureAwait(false);
                    }
                    catch (WebException)
                    {
                        //Happens, doesn't matter
                    }
                }
            }
        }
Example #3
0
        protected async override Task LoadImage(DirectoryInfo albumCoverDirectory)
        {
            if (albumCoverDirectory.Exists)
            {
                var regex =
                    new Regex(HurricaneSettings.Instance.Config.LoadAlbumCoverFromInternet
                        ? string.Format("^{0}_{1}.", SoundCloudID,
                                        SoundCloudApi.GetQualityModifier(HurricaneSettings.Instance.Config.DownloadAlbumCoverQuality))
                        : string.Format("^{0}_", SoundCloudID));

                var imageFile = albumCoverDirectory.GetFiles().FirstOrDefault(item => regex.IsMatch(item.Name.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(ArtworkUrl))
                    {
                        Image = await SoundCloudApi.LoadBitmapImage(this, HurricaneSettings.Instance.Config.DownloadAlbumCoverQuality, albumCoverDirectory);

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

                    Image = await MusicCoverManager.LoadCoverFromWeb(this, albumCoverDirectory, Uploader != Artist);
                }
                catch (WebException)
                {
                    //Happens, doesn't matter
                }
            }
        }
Example #4
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
                }
            }
        }
Example #5
0
        protected async override Task LoadImage(DirectoryInfo albumCoverDirectory)
        {
            try
            {
                using (var file = File.Create(Path))
                {
                    if (file.Tag.Pictures != null && file.Tag.Pictures.Any())
                    {
                        Image = ImageHelper.ByteArrayToBitmapImage(file.Tag.Pictures.First().Data.ToArray());
                        return;
                    }
                }
            }
            catch
            {
                // ignored
            }

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

            if (AnyListenSettings.Instance.Config.LoadAlbumCoverFromInternet)
            {
                try
                {
                    Image = await MusicCoverManager.LoadCoverFromWeb(this, albumCoverDirectory);
                }
                catch (WebException)
                {
                    //Happens, doesn't matter
                }
            }
        }