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); }
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); }
public OpenuVidCatchingForm(CookieContainer _jar, UrlFileCache _cache) { jar = _jar; cache = _cache; var lastView = cache.GetContent(LastViewKey, BrowserCache); if (lastView == null) { lastView = "http://openu.ac.il/sheilta"; } parser = new OpenuParser(jar, cache); InitializeComponent(); AddDynamicComponents(lastView); }