예제 #1
0
 public static BitmapImage GetYouTubeImage(YouTubeTrack track, DirectoryInfo di)
 {
     if (di.Exists)
     {
         return(di.GetFiles("*.jpg").Where(item => item.Name.ToLower() == track.YouTubeId.ToLower()).Select(item => new BitmapImage(new Uri(item.FullName))).FirstOrDefault());
     }
     return(null);
 }
예제 #2
0
        public override PlayableBase ToPlayable()
        {
            var ytresult = (Entry)Result;
            var result = new YouTubeTrack
            {
                YouTubeId = YouTubeTrack.GetYouTubeIdFromLink(Url),
                TimeAdded = DateTime.Now,
                IsChecked = false
            };

            result.LoadInformation(ytresult);
            return result;
        }
예제 #3
0
        public override PlayableBase ToPlayable()
        {
            var ytresult = (IVideoInfo)Result;
            var result   = new YouTubeTrack
            {
                YouTubeId = YouTubeTrack.GetYouTubeIdFromLink(Url),
                TimeAdded = DateTime.Now,
                IsChecked = false
            };

            result.LoadInformation(ytresult);
            return(result);
        }
예제 #4
0
        public static async Task<BitmapImage> LoadBitmapImage(YouTubeTrack track, DirectoryInfo albumDirectory)
        {
            var config = HurricaneSettings.Instance.Config;

            using (var client = new WebClient { Proxy = null })
            {
                var image = await ImageHelper.DownloadImage(client, track.ThumbnailUrl);
                if (config.SaveCoverLocal)
                {
                    if (!albumDirectory.Exists) albumDirectory.Create();
                    await ImageHelper.SaveImage(image, track.YouTubeId, albumDirectory.FullName);
                }
                return image;
            }
        }
예제 #5
0
        public async override Task <PlayableBase> ToPlayable()
        {
            var ytresult = (Entry)Result;
            var result   = new YouTubeTrack
            {
                YouTubeId = YouTubeTrack.GetYouTubeIdFromLink(Url),
                TimeAdded = DateTime.Now
            };

            if (_soundSourceInfo == null && !(await CheckIfAvailable()))
            {
                throw new Exception();
            }

            result.LoadInformation(ytresult, _soundSourceInfo);
            return(result);
        }
예제 #6
0
        public override async Task <bool> CheckIfAvailable()
        {
            var result = new YouTubeTrack {
                YouTubeId = YouTubeTrack.GetYouTubeIdFromLink(Url)
            };

            try
            {
                using (var x = await result.GetSoundSource())
                {
                    _soundSourceInfo = SoundSourceInfo.FromSoundSource(x);
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #7
0
        public static async Task <BitmapImage> LoadBitmapImage(YouTubeTrack track, DirectoryInfo albumDirectory)
        {
            var config = HurricaneSettings.Instance.Config;

            using (var client = new WebClient {
                Proxy = null
            })
            {
                var image = await ImageHelper.DownloadImage(client, track.ThumbnailUrl);

                if (config.SaveCoverLocal)
                {
                    if (!albumDirectory.Exists)
                    {
                        albumDirectory.Create();
                    }
                    await ImageHelper.SaveImage(image, track.YouTubeId, albumDirectory.FullName);
                }
                return(image);
            }
        }