home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
MediaPortal 1 Plugins
Popular Plugins
OnlineVideos
Comedy network
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="corporate_gadfly" data-source="post: 781627" data-attributes="member: 113254"><p><strong>Re: Support for a site request thread</strong></p><p></p><p>Installed SAF 5.02 and all is well with OnlineVideos in VMWare Fusion.</p><p></p><p></p><p>CTV works <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin :D" loading="lazy" data-shortname=":D" />. Code is as follows:</p><p>[spoiler]</p><p>[CODE]using System;</p><p>using System.Collections.Generic;</p><p>using System.Linq;</p><p>using System.Text;</p><p>using System.Text.RegularExpressions;</p><p>using System.Web;</p><p></p><p>namespace OnlineVideos.Sites</p><p>{</p><p> public class CTVUtil : SiteUtilBase</p><p> {</p><p> private string baseUrl = @"http://watch.ctv.ca";</p><p> private Regex mainCategoriesRegex = new Regex(@"<li[^>]*>\s*<a\sid=""(?<id>[^""]*)""\sonclick=""[^""]*""\shref=""(?<url>[^""]*)""\stitle=""[^""]*"">\s*(?<title>[^<]*)<span></span>\s*</a>\s*</li>",</p><p> RegexOptions.Compiled);</p><p> private Regex subcategoriesRegex = new Regex(@"<li[^>]*>\s*<a\sid=""(?<id>[^""]*)""\sonclick=""return\sInterface\.GetChildPanel\('Season'[^""]*""\shref=""(?<url>[^""]*)""\stitle=""[^""]*"">\s*(?<title>[^<]*)<span></span>\s*</a>\s*</li>",</p><p> RegexOptions.Compiled);</p><p> private Regex episodeListRegex = new Regex(@"<dd(\sid=""[^""]*"")?\sclass=""Thumbnail""><a\shref=""javascript:Interface\.PlayEpisode\((?<episode>[^,]*),\strue\s\)""\stitle=""(?<title>[^""]*)""><img\ssrc=""(?<thumb>[^""]*)""\s/><span></span></a></dd>.*?<dd class=""Description"">(?<description>[^<]*)</dd>",</p><p> RegexOptions.Compiled | RegexOptions.Singleline);</p><p> private Regex clipListRegex = new Regex(@"<dt><a\shref=""[^#]*#clip(?<clip>[^""]*)""\sonclick=""return\sPlaylist\.GetInstance.*?<img.*?/></a></dt>",</p><p> RegexOptions.Compiled);</p><p> private Regex clipUrlRegex = new Regex(@"Video\.Load\({url:'(?<url>[^']*)'.*?",</p><p> RegexOptions.Compiled);</p><p> private Regex rtmpUrlRegex = new Regex(@"rtmpe://(?<host>[^/]*)/ondemand/(?<file>[^?]*)\?(?<params>.*)",</p><p> RegexOptions.Compiled);</p><p></p><p> public override int DiscoverDynamicCategories()</p><p> {</p><p> Settings.Categories.Clear();</p><p></p><p> string webData = GetWebData(baseUrl + @"/AJAX/VideoLibraryWithFrame.aspx");</p><p></p><p> if (!string.IsNullOrEmpty(webData))</p><p> {</p><p> foreach (Match m in mainCategoriesRegex.Matches(webData))</p><p> {</p><p> RssLink cat = new RssLink();</p><p></p><p> cat.Name = HttpUtility.HtmlDecode(m.Groups["title"].Value);</p><p> cat.Url = HttpUtility.HtmlDecode(m.Groups["url"].Value);</p><p> cat.HasSubCategories = true;</p><p></p><p> Settings.Categories.Add(cat);</p><p> }</p><p> }</p><p></p><p> Settings.DynamicCategoriesDiscovered = true;</p><p> return Settings.Categories.Count;</p><p> }</p><p></p><p> public override int DiscoverSubCategories(Category parentCategory)</p><p> {</p><p> parentCategory.SubCategories = new List<Category>();</p><p></p><p> RssLink parentRssLink = (RssLink)parentCategory;</p><p> string webData = GetWebData((parentRssLink).Url);</p><p></p><p> if (!string.IsNullOrEmpty(webData))</p><p> {</p><p> foreach (Match m in subcategoriesRegex.Matches(webData))</p><p> {</p><p> RssLink cat = new RssLink();</p><p></p><p> cat.ParentCategory = parentCategory;</p><p> cat.Name = HttpUtility.HtmlDecode(m.Groups["title"].Value);</p><p> cat.Url = HttpUtility.HtmlDecode(m.Groups["url"].Value);</p><p> // this id will be used later on, so store it in the .Other property</p><p> cat.Other = HttpUtility.HtmlDecode(m.Groups["id"].Value);</p><p> cat.HasSubCategories = false;</p><p></p><p> parentCategory.SubCategories.Add(cat);</p><p> }</p><p> }</p><p></p><p> parentCategory.SubCategoriesDiscovered = true;</p><p> return parentCategory.SubCategories.Count;</p><p> }</p><p></p><p> public override List<VideoInfo> getVideoList(Category category)</p><p> {</p><p> List<VideoInfo> result = new List<VideoInfo>();</p><p></p><p> string parentId = (string) ((RssLink) category).Other;</p><p></p><p> // Level 3 shows episodes</p><p> string webData = GetWebData(baseUrl</p><p> + @"/AJAX/VideoLibraryContents.aspx?GetChildOnly=true&PanelID=3&SeasonID="</p><p> + parentId);</p><p></p><p> if (!string.IsNullOrEmpty(webData))</p><p> {</p><p> foreach (Match m in episodeListRegex.Matches(webData))</p><p> {</p><p> VideoInfo info = new VideoInfo();</p><p> info.Title = HttpUtility.HtmlDecode(m.Groups["title"].Value);</p><p> info.ImageUrl = HttpUtility.HtmlDecode(m.Groups["thumb"].Value);</p><p> info.Description = HttpUtility.HtmlDecode(m.Groups["description"].Value);</p><p> // this episode ID will be used later on, so store it in the .Other property</p><p> info.Other = HttpUtility.HtmlDecode(m.Groups["episode"].Value);</p><p></p><p> result.Add(info);</p><p> }</p><p> }</p><p></p><p> return result;</p><p> }</p><p></p><p> public override List<string> getMultipleVideoUrls(VideoInfo video, bool inPlaylist = false)</p><p> {</p><p> List<string> result = new List<string>();</p><p></p><p> // Level 4 shows clips</p><p> string webData = GetWebData(baseUrl</p><p> + @"/AJAX/VideoLibraryContents.aspx?GetChildOnly=true&PanelID=4&EpisodeID="</p><p> + video.Other);</p><p></p><p> if (!string.IsNullOrEmpty(webData))</p><p> {</p><p> foreach (Match m in clipListRegex.Matches(webData))</p><p> {</p><p> string clipId = HttpUtility.HtmlDecode(m.Groups["clip"].Value);</p><p> // this is the URL which will eventually reveal the rtmpe locations</p><p> result.Add(String.Format("http://cls.ctvdigital.net/cliplookup.aspx?id={0}", clipId));</p><p> }</p><p> }</p><p></p><p> return result;</p><p> }</p><p></p><p> public override string getPlaylistItemUrl(VideoInfo clonedVideoInfo, string chosenPlaybackOption, bool inPlaylist = false)</p><p> {</p><p> Log.Debug(@"Video URL (before): {0}", clonedVideoInfo.VideoUrl);</p><p></p><p> string result = clonedVideoInfo.VideoUrl;</p><p></p><p> // must specify referer (or we will get 403 Forbidden from cls.ctvdigital.net)</p><p> string webData = GetWebData(clonedVideoInfo.VideoUrl, null, baseUrl);</p><p></p><p> if (!string.IsNullOrEmpty(webData))</p><p> {</p><p> Match urlMatch = clipUrlRegex.Match(webData);</p><p> if (urlMatch.Success)</p><p> {</p><p> string rtmp = HttpUtility.HtmlDecode(urlMatch.Groups["url"].Value);</p><p></p><p> Log.Debug("RTMP URL found: {0}", rtmp);</p><p></p><p> Match m = rtmpUrlRegex.Match(rtmp);</p><p> if (m.Success)</p><p> {</p><p> string rtmpUrl = String.Format("rtmp://{0}/ondemand?{1}", m.Groups["host"], m.Groups["params"]);</p><p> string playPath = String.Format("mp4:{0}", m.Groups["file"]);</p><p></p><p> string url = String.Format("http://127.0.0.1/stream.flv?rtmpurl={0}&playpath={1}&swfVfy={2}",</p><p> HttpUtility.UrlEncode(rtmpUrl),</p><p> HttpUtility.UrlEncode(playPath),</p><p> HttpUtility.UrlEncode(@"http://watch.ctv.ca/Flash/player.swf?themeURL=http://watch.ctv.ca/themes/CTV/player/theme.aspx"));</p><p></p><p> Log.Debug(@"Video URL (after): {0}", url);</p><p> result = ReverseProxy.GetProxyUri(RTMP_LIB.RTMPRequestHandler.Instance, url);</p><p> }</p><p> }</p><p> }</p><p> return result;</p><p> }</p><p> }</p><p>}</p><p>[/CODE]</p><p>[/spoiler]</p><p>Does anyone want to take it for a "test ride"? <s>Sorry, no descriptions at the moment and minimal thumbnails (easy to add, I guess)</s></p><p></p><p>Unless anyone else has a better idea, I'm planning on creating a BaseCTVUtil and try to get all the other stations working (as per my <a href="https://forum.team-mediaportal.com/773298-post654.html" target="_blank">original post</a>) except Comedy Network. I'm pretty sure CTV, TSN (sports), CTV News, Discovery, Space, Bravo, BNN and Fashion can all be run with the same infrastructure but differing base URLs.</p><p></p><p>And again, I apologize for my C# (it is my first project ever).</p><p></p><p>Cheers.</p></blockquote><p></p>
[QUOTE="corporate_gadfly, post: 781627, member: 113254"] [b]Re: Support for a site request thread[/b] Installed SAF 5.02 and all is well with OnlineVideos in VMWare Fusion. CTV works :D. Code is as follows: [spoiler] [CODE]using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Web; namespace OnlineVideos.Sites { public class CTVUtil : SiteUtilBase { private string baseUrl = @"http://watch.ctv.ca"; private Regex mainCategoriesRegex = new Regex(@"<li[^>]*>\s*<a\sid=""(?<id>[^""]*)""\sonclick=""[^""]*""\shref=""(?<url>[^""]*)""\stitle=""[^""]*"">\s*(?<title>[^<]*)<span></span>\s*</a>\s*</li>", RegexOptions.Compiled); private Regex subcategoriesRegex = new Regex(@"<li[^>]*>\s*<a\sid=""(?<id>[^""]*)""\sonclick=""return\sInterface\.GetChildPanel\('Season'[^""]*""\shref=""(?<url>[^""]*)""\stitle=""[^""]*"">\s*(?<title>[^<]*)<span></span>\s*</a>\s*</li>", RegexOptions.Compiled); private Regex episodeListRegex = new Regex(@"<dd(\sid=""[^""]*"")?\sclass=""Thumbnail""><a\shref=""javascript:Interface\.PlayEpisode\((?<episode>[^,]*),\strue\s\)""\stitle=""(?<title>[^""]*)""><img\ssrc=""(?<thumb>[^""]*)""\s/><span></span></a></dd>.*?<dd class=""Description"">(?<description>[^<]*)</dd>", RegexOptions.Compiled | RegexOptions.Singleline); private Regex clipListRegex = new Regex(@"<dt><a\shref=""[^#]*#clip(?<clip>[^""]*)""\sonclick=""return\sPlaylist\.GetInstance.*?<img.*?/></a></dt>", RegexOptions.Compiled); private Regex clipUrlRegex = new Regex(@"Video\.Load\({url:'(?<url>[^']*)'.*?", RegexOptions.Compiled); private Regex rtmpUrlRegex = new Regex(@"rtmpe://(?<host>[^/]*)/ondemand/(?<file>[^?]*)\?(?<params>.*)", RegexOptions.Compiled); public override int DiscoverDynamicCategories() { Settings.Categories.Clear(); string webData = GetWebData(baseUrl + @"/AJAX/VideoLibraryWithFrame.aspx"); if (!string.IsNullOrEmpty(webData)) { foreach (Match m in mainCategoriesRegex.Matches(webData)) { RssLink cat = new RssLink(); cat.Name = HttpUtility.HtmlDecode(m.Groups["title"].Value); cat.Url = HttpUtility.HtmlDecode(m.Groups["url"].Value); cat.HasSubCategories = true; Settings.Categories.Add(cat); } } Settings.DynamicCategoriesDiscovered = true; return Settings.Categories.Count; } public override int DiscoverSubCategories(Category parentCategory) { parentCategory.SubCategories = new List<Category>(); RssLink parentRssLink = (RssLink)parentCategory; string webData = GetWebData((parentRssLink).Url); if (!string.IsNullOrEmpty(webData)) { foreach (Match m in subcategoriesRegex.Matches(webData)) { RssLink cat = new RssLink(); cat.ParentCategory = parentCategory; cat.Name = HttpUtility.HtmlDecode(m.Groups["title"].Value); cat.Url = HttpUtility.HtmlDecode(m.Groups["url"].Value); // this id will be used later on, so store it in the .Other property cat.Other = HttpUtility.HtmlDecode(m.Groups["id"].Value); cat.HasSubCategories = false; parentCategory.SubCategories.Add(cat); } } parentCategory.SubCategoriesDiscovered = true; return parentCategory.SubCategories.Count; } public override List<VideoInfo> getVideoList(Category category) { List<VideoInfo> result = new List<VideoInfo>(); string parentId = (string) ((RssLink) category).Other; // Level 3 shows episodes string webData = GetWebData(baseUrl + @"/AJAX/VideoLibraryContents.aspx?GetChildOnly=true&PanelID=3&SeasonID=" + parentId); if (!string.IsNullOrEmpty(webData)) { foreach (Match m in episodeListRegex.Matches(webData)) { VideoInfo info = new VideoInfo(); info.Title = HttpUtility.HtmlDecode(m.Groups["title"].Value); info.ImageUrl = HttpUtility.HtmlDecode(m.Groups["thumb"].Value); info.Description = HttpUtility.HtmlDecode(m.Groups["description"].Value); // this episode ID will be used later on, so store it in the .Other property info.Other = HttpUtility.HtmlDecode(m.Groups["episode"].Value); result.Add(info); } } return result; } public override List<string> getMultipleVideoUrls(VideoInfo video, bool inPlaylist = false) { List<string> result = new List<string>(); // Level 4 shows clips string webData = GetWebData(baseUrl + @"/AJAX/VideoLibraryContents.aspx?GetChildOnly=true&PanelID=4&EpisodeID=" + video.Other); if (!string.IsNullOrEmpty(webData)) { foreach (Match m in clipListRegex.Matches(webData)) { string clipId = HttpUtility.HtmlDecode(m.Groups["clip"].Value); // this is the URL which will eventually reveal the rtmpe locations result.Add(String.Format("http://cls.ctvdigital.net/cliplookup.aspx?id={0}", clipId)); } } return result; } public override string getPlaylistItemUrl(VideoInfo clonedVideoInfo, string chosenPlaybackOption, bool inPlaylist = false) { Log.Debug(@"Video URL (before): {0}", clonedVideoInfo.VideoUrl); string result = clonedVideoInfo.VideoUrl; // must specify referer (or we will get 403 Forbidden from cls.ctvdigital.net) string webData = GetWebData(clonedVideoInfo.VideoUrl, null, baseUrl); if (!string.IsNullOrEmpty(webData)) { Match urlMatch = clipUrlRegex.Match(webData); if (urlMatch.Success) { string rtmp = HttpUtility.HtmlDecode(urlMatch.Groups["url"].Value); Log.Debug("RTMP URL found: {0}", rtmp); Match m = rtmpUrlRegex.Match(rtmp); if (m.Success) { string rtmpUrl = String.Format("rtmp://{0}/ondemand?{1}", m.Groups["host"], m.Groups["params"]); string playPath = String.Format("mp4:{0}", m.Groups["file"]); string url = String.Format("http://127.0.0.1/stream.flv?rtmpurl={0}&playpath={1}&swfVfy={2}", HttpUtility.UrlEncode(rtmpUrl), HttpUtility.UrlEncode(playPath), HttpUtility.UrlEncode(@"http://watch.ctv.ca/Flash/player.swf?themeURL=http://watch.ctv.ca/themes/CTV/player/theme.aspx")); Log.Debug(@"Video URL (after): {0}", url); result = ReverseProxy.GetProxyUri(RTMP_LIB.RTMPRequestHandler.Instance, url); } } } return result; } } } [/CODE] [/spoiler] Does anyone want to take it for a "test ride"? [s]Sorry, no descriptions at the moment and minimal thumbnails (easy to add, I guess)[/s] Unless anyone else has a better idea, I'm planning on creating a BaseCTVUtil and try to get all the other stations working (as per my [URL="https://forum.team-mediaportal.com/773298-post654.html"]original post[/URL]) except Comedy Network. I'm pretty sure CTV, TSN (sports), CTV News, Discovery, Space, Bravo, BNN and Fashion can all be run with the same infrastructure but differing base URLs. And again, I apologize for my C# (it is my first project ever). Cheers. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
MediaPortal 1 Plugins
Popular Plugins
OnlineVideos
Comedy network
Contact us
RSS
Top
Bottom