Esempio n. 1
0
        public List <OpenuVideoData> GetVideosInView(string vidChooserHtml)
        {
            List <OpenuVideoData> videoUrls = extractViewedCollection(vidChooserHtml);

            foreach (var vid in videoUrls)
            {
                var vidUrlCacheName = vid.formatCacheFileName();
                var vidIdentifier   = cache.GetContent(vidUrlCacheName);
                if (vidIdentifier == null)
                {
                    vidIdentifier = GetVidUrl(vid, cookieJar);
                    cache.PutContent(vidUrlCacheName, vidIdentifier);
                }
                if (vidIdentifier == null)
                {
                    Console.WriteLine("Error when trying to fetch video with id = {0}", vid);
                }
                else
                {
                    vid.PlaylistUrl = string.Format("http://api.bynetcdn.com/Redirector/openu/manifest/{0}_mp4/HLS/playlist.m3u8", vidIdentifier);
                }
            }

            // This way we get the videos in chronological order
            videoUrls.Reverse();
            return(videoUrls);
        }
        private void copyHtml()
        {
            Cef.GetGlobalCookieManager().VisitAllCookies(new CookieConverter(jar));
            cache.PutContent(LastViewKey, addressBar.Text, BrowserCache);
            var html = browser.GetMainFrame().GetSourceAsync().Result;

            playlist = parser.GetVideosInView(html);

            var videoChooser = new VideoChooserDialog(playlist);

            videoChooser.ShowDialog();
        }
Esempio n. 3
0
        string requestPlaylist(OpenuVideoData data)
        {
            var playlistFile = cache.GetContent(data.formatPlaylistFile(), data.VideoId);

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

            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(data.PlaylistUrl);

            req.AllowAutoRedirect = true;
            var response = (HttpWebResponse)req.GetResponse();

            if (response.StatusCode != HttpStatusCode.OK)
            {
                return(null);
            }
            playlistFile = new StreamReader(response.GetResponseStream()).ReadToEnd();
            cache.PutContent(data.formatPlaylistFile(), playlistFile, data.VideoId);
            return(playlistFile);
        }