public static IEnumerable <VideoInfo> GetDownloadUrlsAsync(Uri videoUri)
        {
            if (videoUri == null)
            {
                throw new ArgumentNullException("videoUri");
            }

            var videoUrl   = NormalizeYoutubeUrl(videoUri.ToString());
            var id         = YoutubeUrl.GetVideoId(new Uri(videoUrl));
            var pageSource = GetPageSourceAsync(videoUrl);

            if (IsVideoUnavailable(pageSource))
            {
                throw new Exception("Video not available");
            }
            var requestUrl = String.Format("http://www.youtube.com/get_video_info?&video_id={0}&el=detailpage&ps=default&eurl=&gl=US&hl=en", id);
            var source     = GetPageSourceAsync(requestUrl);

            try {
                var videoInfos = GetVideoInfos(source);
                return(videoInfos);
            } catch (Exception ex) {
                ThrowYoutubeParseException(ex);
            }
            ThrowYoutubeParseException(null);
            return(null);
        }
        public static YoutubeUrl Create(Uri u)
        {

            var surl = u.ToString();
            if (surl.StartsWith("https://")) {
                surl = "http://" + surl.Substring(8);
            } else if (!surl.StartsWith("http://")) {
                surl = "http://" + u;
            }
            var url = new YoutubeUrl { Uri = u, Type = VideoUrlType.Unknown, Provider = ContentProviderType.NONE };
            url.Parse(surl);
            return url;
        }
        public static YoutubeUrl Create(Uri u)
        {
            var surl = u.ToString();

            if (surl.StartsWith("https://"))
            {
                surl = "http://" + surl.Substring(8);
            }
            else if (!surl.StartsWith("http://"))
            {
                surl = "http://" + u;
            }
            var url = new YoutubeUrl {
                Uri = u, Type = VideoUrlType.Unknown, Provider = ContentProviderType.NONE
            };

            url.Parse(surl);
            return(url);
        }
예제 #4
0
 private void Browser_LoadCompleted(object sender, NavigationEventArgs e)
 {
     Url.Text = e.Uri.ToString();
     MixpanelTrack("Navigated", new {Url = e.Uri.ToString(), Guid = _settings.ApplicationConfiguration.Guid});
     _youtubeUrl = YoutubeUrl.Create(e.Uri);
     var doc = Browser.Document as IHTMLDocument3; ;
     if (doc == null) return;
     var html = doc.documentElement.outerHTML;
     _youtubeEntry = YoutubeEntry.Create(e.Uri, html);
     Loading();
 }