From: <gre...@us...> - 2007-05-07 22:22:31
|
Revision: 384 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=384&view=rev Author: gregmac45 Date: 2007-05-07 15:21:32 -0700 (Mon, 07 May 2007) Log Message: ----------- Added support for MyVideo.de and rocketboom.com Modified Paths: -------------- trunk/plugins/OnlineVideos/Source/OnlineVideos/SiteUtilFactory.cs Added Paths: ----------- trunk/plugins/OnlineVideos/Source/OnlineVideos/MyVideodeUtil.cs trunk/plugins/OnlineVideos/Source/OnlineVideos/RocketboomUtil.cs Added: trunk/plugins/OnlineVideos/Source/OnlineVideos/MyVideodeUtil.cs =================================================================== --- trunk/plugins/OnlineVideos/Source/OnlineVideos/MyVideodeUtil.cs (rev 0) +++ trunk/plugins/OnlineVideos/Source/OnlineVideos/MyVideodeUtil.cs 2007-05-07 22:21:32 UTC (rev 384) @@ -0,0 +1,128 @@ +using System; +using MediaPortal.GUI.Library; +using System.Text.RegularExpressions; +using System.Net; +using System.Text; +using MediaPortal.Player; +using System.Collections.Generic; +//using MediaPortal.Utils.Services; +using MediaPortal.GUI.View ; +using MediaPortal.Dialogs; +using System.Xml; +using System.Xml.XPath; +using System.ComponentModel; +using System.Threading; + + + +namespace OnlineVideos +{ + public class MyVideodeUtil : SiteUtilBase + { + + public override String getUrl(String fsId) + { + String lsUrl = ""; + HttpWebRequest webrequest = + (HttpWebRequest)WebRequest.Create("http://www.myvideo.de/movie/15714"); + webrequest.KeepAlive = false; + webrequest.Method = "GET"; + webrequest.ContentType = "text/html"; + webrequest.AllowAutoRedirect = false; + HttpWebResponse webresponse; + webresponse = (HttpWebResponse)webrequest.GetResponse(); + WebHeaderCollection headers = webresponse.Headers; + if ((webresponse.StatusCode == HttpStatusCode.Found) || + (webresponse.StatusCode == HttpStatusCode.Redirect) || + (webresponse.StatusCode == HttpStatusCode.Moved) || + (webresponse.StatusCode == HttpStatusCode.MovedPermanently)) + { + // Get redirected uri + string lsUri = headers["Location"]; + lsUrl = Regex.Match(lsUri, "V=([^&]*)").Groups[1].Value; + } + + return lsUrl; + } + public override List<GUIOnlineVideos.VideoInfo> getVideoList(string fsUrl) + { + List<RssItem> loRssItemList = getRssDataItems(fsUrl); + List<GUIOnlineVideos.VideoInfo> loVideoList = new List<GUIOnlineVideos.VideoInfo>(); + GUIOnlineVideos.VideoInfo video; + foreach(RssItem rssItem in loRssItemList){ + video = new GUIOnlineVideos.VideoInfo(); + video.Description = rssItem.description; + video.ImageUrl = rssItem.mediaThumbnail; + video.Title = rssItem.title; + video.VideoUrl = Regex.Match(rssItem.link, "watch/([\\d]*)").Groups[1].Value; + loVideoList.Add(video); + + } + return loVideoList; + } + /* + public List<GUIOnlineVideos.VideoInfo> getRssData(String fsUrl) + { + + XmlDocument doc = new XmlDocument(); + //XPathDocument doc = new XPathDocument(fsUrl); + + doc.Load(XmlReader.Create(fsUrl)); + XmlNamespaceManager expr = new XmlNamespaceManager(doc.NameTable); + expr.AddNamespace("media", "http://search.yahoo.com/mrss"); + + //Create the root XmlNode and generate an XmlNodeList from it. + XmlNode root = doc.SelectSingleNode("//rss/channel/item", expr); + XmlNodeList nodeList; + nodeList = root.SelectNodes("//rss/channel/item"); + //RssItem loRssItem = new RssItem(); + //loRssItem. + //This loops through each node found in the nodeList and adds the + //Node data to the DataTable. + XmlAttributeCollection ac; + //List<RssItem> loRssItems = new List<RssItem>(); + List<GUIOnlineVideos.VideoInfo> loRssItems = new List<GUIOnlineVideos.VideoInfo>(); + GUIOnlineVideos.VideoInfo loRssItem; + //GUIListItem loListItem; + foreach (XmlNode chileNode in nodeList) + { + loRssItem = new GUIOnlineVideos.VideoInfo(); + + XmlNode node = chileNode.SelectSingleNode("title"); + loRssItem.Title = node.InnerText; + + //node = chileNode.SelectSingleNode("link"); + //loRssItem.link = node.InnerText; + + node = chileNode.SelectSingleNode("description"); + loRssItem.Description = node.InnerText; + + node = chileNode.SelectSingleNode("media:thumbnail[@width=\"260\"]", expr); + if (node != null) + { + ac = node.Attributes; + loRssItem.ImageUrl = ac["url"].InnerText; + } + + + node = chileNode.SelectSingleNode("guid"); + if (node != null) + { + //ac = node.Attributes; + loRssItem.VideoUrl = node.InnerText; + } + + //Log.Write(loRssItem.ToString()); + //loListItem = new GUIListItem(loRssItem.title); + //loListItem.Path = loRssItem.videoUrl; + loRssItems.Add(loRssItem); + + + } + return loRssItems; + } + + */ + + } +} Added: trunk/plugins/OnlineVideos/Source/OnlineVideos/RocketboomUtil.cs =================================================================== --- trunk/plugins/OnlineVideos/Source/OnlineVideos/RocketboomUtil.cs (rev 0) +++ trunk/plugins/OnlineVideos/Source/OnlineVideos/RocketboomUtil.cs 2007-05-07 22:21:32 UTC (rev 384) @@ -0,0 +1,107 @@ +using System; +using MediaPortal.GUI.Library; +using System.Text.RegularExpressions; +using System.Net; +using System.Text; +using MediaPortal.Player; +using System.Collections.Generic; +//using MediaPortal.Utils.Services; +using MediaPortal.GUI.View ; +using MediaPortal.Dialogs; +using System.Xml; +using System.Xml.XPath; +using System.ComponentModel; +using System.Threading; + + + +namespace OnlineVideos +{ + public class RocketboomUtil : SiteUtilBase + { + + public override String getUrl(String fsId) + { + return fsId; + } + public override List<GUIOnlineVideos.VideoInfo> getVideoList(string fsUrl) + { + List<RssItem> loRssItemList = getRssDataItems(fsUrl); + List<GUIOnlineVideos.VideoInfo> loVideoList = new List<GUIOnlineVideos.VideoInfo>(); + GUIOnlineVideos.VideoInfo video; + foreach(RssItem rssItem in loRssItemList){ + video = new GUIOnlineVideos.VideoInfo(); + video.Description = rssItem.description; + video.Title = rssItem.title; + video.VideoUrl = rssItem.enclosure; + loVideoList.Add(video); + + } + return loVideoList; + } + /* + public List<GUIOnlineVideos.VideoInfo> getRssData(String fsUrl) + { + + XmlDocument doc = new XmlDocument(); + //XPathDocument doc = new XPathDocument(fsUrl); + + doc.Load(XmlReader.Create(fsUrl)); + XmlNamespaceManager expr = new XmlNamespaceManager(doc.NameTable); + expr.AddNamespace("media", "http://search.yahoo.com/mrss"); + + //Create the root XmlNode and generate an XmlNodeList from it. + XmlNode root = doc.SelectSingleNode("//rss/channel/item", expr); + XmlNodeList nodeList; + nodeList = root.SelectNodes("//rss/channel/item"); + //RssItem loRssItem = new RssItem(); + //loRssItem. + //This loops through each node found in the nodeList and adds the + //Node data to the DataTable. + XmlAttributeCollection ac; + //List<RssItem> loRssItems = new List<RssItem>(); + List<GUIOnlineVideos.VideoInfo> loRssItems = new List<GUIOnlineVideos.VideoInfo>(); + GUIOnlineVideos.VideoInfo loRssItem; + //GUIListItem loListItem; + foreach (XmlNode chileNode in nodeList) + { + loRssItem = new GUIOnlineVideos.VideoInfo(); + + XmlNode node = chileNode.SelectSingleNode("title"); + loRssItem.Title = node.InnerText; + + //node = chileNode.SelectSingleNode("link"); + //loRssItem.link = node.InnerText; + + node = chileNode.SelectSingleNode("description"); + loRssItem.Description = node.InnerText; + + node = chileNode.SelectSingleNode("media:thumbnail[@width=\"260\"]", expr); + if (node != null) + { + ac = node.Attributes; + loRssItem.ImageUrl = ac["url"].InnerText; + } + + + node = chileNode.SelectSingleNode("guid"); + if (node != null) + { + //ac = node.Attributes; + loRssItem.VideoUrl = node.InnerText; + } + + //Log.Write(loRssItem.ToString()); + //loListItem = new GUIListItem(loRssItem.title); + //loListItem.Path = loRssItem.videoUrl; + loRssItems.Add(loRssItem); + + + } + return loRssItems; + } + + */ + + } +} Modified: trunk/plugins/OnlineVideos/Source/OnlineVideos/SiteUtilFactory.cs =================================================================== --- trunk/plugins/OnlineVideos/Source/OnlineVideos/SiteUtilFactory.cs 2007-05-07 02:00:09 UTC (rev 383) +++ trunk/plugins/OnlineVideos/Source/OnlineVideos/SiteUtilFactory.cs 2007-05-07 22:21:32 UTC (rev 384) @@ -100,6 +100,16 @@ lbFound = true; moSiteTable.Add("15", new ItunesTrailerUtil()); } + else if (fsSiteId == "16") + { + lbFound = true; + moSiteTable.Add("16", new MyVideodeUtil()); + } + else if (fsSiteId == "17") + { + lbFound = true; + moSiteTable.Add("17", new RocketboomUtil()); + } if(lbFound){ return moSiteTable[fsSiteId]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |