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); }
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; }
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); }
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; } }
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); }
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); } }
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); } }