public static DecryptDownloadUrl ( VideoInfo videoInfo ) : void | ||
videoInfo | VideoInfo | The video info which's downlaod URL should be decrypted. |
리턴 | void |
public static IEnumerable <VideoInfo> GetDownloadUrls(string videoUrl, bool decryptSignature = true) { if (videoUrl == null) { throw new ArgumentNullException("videoUrl"); } if (!DownloadUrlResolver.TryNormalizeYoutubeUrl(videoUrl, out videoUrl)) { throw new ArgumentException("URL is not a valid youtube URL!"); } try { JObject json = DownloadUrlResolver.LoadJson(videoUrl); string videoTitle = DownloadUrlResolver.GetVideoTitle(json); IEnumerable <VideoInfo> list = (IEnumerable <VideoInfo>)Enumerable.ToList <VideoInfo>(DownloadUrlResolver.GetVideoInfos(DownloadUrlResolver.ExtractDownloadUrls(json), videoTitle)); string html5PlayerVersion = DownloadUrlResolver.GetHtml5PlayerVersion(json); IEnumerator <VideoInfo> enumerator = list.GetEnumerator(); try { while (((IEnumerator)enumerator).MoveNext()) { VideoInfo current = enumerator.Current; current.HtmlPlayerVersion = html5PlayerVersion; if (decryptSignature && current.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(current); } } } finally { if (enumerator != null) { ((IDisposable)enumerator).Dispose(); } } return(list); } catch (Exception ex) { if (ex is WebException || ex is VideoNotAvailableException) { throw; } else { DownloadUrlResolver.ThrowYoutubeParseException(ex, videoUrl); } } return(null); }
public static async Task <Uri> GetVideoUriAsync(string videoId) { var videoUrl = "http://www.youtube.com/watch?v=" + videoId; var videoInfos = await GetDownloadUrls(videoUrl, false); // TODO - parameterize video resolution VideoInfo video = videoInfos .First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360); // If the video has an encrypted signature, decipher it if (video.RequiresDecryption) { await DownloadUrlResolver.DecryptDownloadUrl(video); } return(new Uri(video.DownloadUrl)); }