From: <gre...@us...> - 2007-08-23 00:58:49
|
Revision: 858 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=858&view=rev Author: gregmac45 Date: 2007-08-22 17:58:47 -0700 (Wed, 22 Aug 2007) Log Message: ----------- change the length to string in VideoInfo Added GenericSiteUtil to handle rss with video links Modified Paths: -------------- trunk/plugins/OnlineVideos/Source/OnlineVideos/DailyMotionUtil.cs trunk/plugins/OnlineVideos/Source/OnlineVideos/Favorites.cs trunk/plugins/OnlineVideos/Source/OnlineVideos/GUIOnlineVideos.cs trunk/plugins/OnlineVideos/Source/OnlineVideos/GoogleVideoUtil.cs trunk/plugins/OnlineVideos/Source/OnlineVideos/MetaCafeUtil.cs trunk/plugins/OnlineVideos/Source/OnlineVideos/OnlineVideos.csproj trunk/plugins/OnlineVideos/Source/OnlineVideos/SiteUtilBase.cs trunk/plugins/OnlineVideos/Source/OnlineVideos/YouTubeUtil.cs Added Paths: ----------- trunk/plugins/OnlineVideos/Source/OnlineVideos/GenericSiteUtil.cs Modified: trunk/plugins/OnlineVideos/Source/OnlineVideos/DailyMotionUtil.cs =================================================================== --- trunk/plugins/OnlineVideos/Source/OnlineVideos/DailyMotionUtil.cs 2007-08-22 23:07:31 UTC (rev 857) +++ trunk/plugins/OnlineVideos/Source/OnlineVideos/DailyMotionUtil.cs 2007-08-23 00:58:47 UTC (rev 858) @@ -49,7 +49,7 @@ video.Description = rssItem.description; video.ImageUrl = rssItem.mediaThumbnail; video.Title = rssItem.title; - video.Length = Convert.ToInt32(rssItem.contentList[0].duration); + video.Length = rssItem.contentList[0].duration; video.VideoUrl = rssItem.guid; loVideoList.Add(video); } Modified: trunk/plugins/OnlineVideos/Source/OnlineVideos/Favorites.cs =================================================================== --- trunk/plugins/OnlineVideos/Source/OnlineVideos/Favorites.cs 2007-08-22 23:07:31 UTC (rev 857) +++ trunk/plugins/OnlineVideos/Source/OnlineVideos/Favorites.cs 2007-08-23 00:58:47 UTC (rev 858) @@ -183,7 +183,7 @@ GUIOnlineVideos.VideoInfo video = new GUIOnlineVideos.FavoriteVideoInfo(); video.Description = DatabaseUtility.Get(loResultSet, iRow, "VDO_DESC"); video.ImageUrl = DatabaseUtility.Get(loResultSet, iRow, "VDO_IMG_URL"); - video.Length = DatabaseUtility.GetAsInt(loResultSet, iRow, "VDO_LENGTH"); + video.Length = DatabaseUtility.Get(loResultSet, iRow, "VDO_LENGTH"); video.Tags = DatabaseUtility.Get(loResultSet, iRow, "VDO_TAGS"); video.Title = DatabaseUtility.Get(loResultSet, iRow, "VDO_NM"); video.VideoUrl = DatabaseUtility.Get(loResultSet,iRow,"VDO_URL"); @@ -226,7 +226,7 @@ GUIOnlineVideos.VideoInfo video = new GUIOnlineVideos.FavoriteVideoInfo(); video.Description = DatabaseUtility.Get(loResultSet, iRow, "VDO_DESC"); video.ImageUrl = DatabaseUtility.Get(loResultSet, iRow, "VDO_IMG_URL"); - video.Length = DatabaseUtility.GetAsInt(loResultSet, iRow, "VDO_LENGTH"); + video.Length = DatabaseUtility.Get(loResultSet, iRow, "VDO_LENGTH"); video.Tags = DatabaseUtility.Get(loResultSet, iRow, "VDO_TAGS"); video.Title = DatabaseUtility.Get(loResultSet, iRow, "VDO_NM"); video.VideoUrl = DatabaseUtility.Get(loResultSet,iRow,"VDO_URL"); Modified: trunk/plugins/OnlineVideos/Source/OnlineVideos/GUIOnlineVideos.cs =================================================================== --- trunk/plugins/OnlineVideos/Source/OnlineVideos/GUIOnlineVideos.cs 2007-08-22 23:07:31 UTC (rev 857) +++ trunk/plugins/OnlineVideos/Source/OnlineVideos/GUIOnlineVideos.cs 2007-08-23 00:58:47 UTC (rev 858) @@ -79,14 +79,14 @@ public String Description = ""; public String VideoUrl = ""; public String ImageUrl = ""; - public int Length; + public String Length; public String Tags = ""; public Object Other; public string SiteID = ""; public int VideoID; public VideoInfo() { - Length = -1; + //Length = -1; VideoID = -1; } } @@ -894,7 +894,7 @@ }else{ GUIPropertyManager.SetProperty("#tags", foVideo.Tags); } - TimeSpan t = TimeSpan.FromSeconds(foVideo.Length); + TimeSpan t = TimeSpan.FromSeconds(Convert.ToDouble(foVideo.Length)); GUIPropertyManager.SetProperty("#length", t.ToString()); if(String.IsNullOrEmpty(foVideo.Description)){ GUIPropertyManager.SetProperty("#desc", "None"); Added: trunk/plugins/OnlineVideos/Source/OnlineVideos/GenericSiteUtil.cs =================================================================== --- trunk/plugins/OnlineVideos/Source/OnlineVideos/GenericSiteUtil.cs (rev 0) +++ trunk/plugins/OnlineVideos/Source/OnlineVideos/GenericSiteUtil.cs 2007-08-23 00:58:47 UTC (rev 858) @@ -0,0 +1,111 @@ +/* + * Created by SharpDevelop. + * User: GZamor1 + * Date: 8/22/2007 + * Time: 4:13 PM + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Collections.Generic; +using System.Collections; +using System.Xml; +using System.Text; + +using MediaPortal.GUI.Library; +using MediaPortal.Configuration; + +namespace OnlineVideos +{ + /// <summary> + /// Description of GenericSiteUtil. + /// </summary> + public class GenericSiteUtil:SiteUtilBase + { + ArrayList m_VideoExtensions = new ArrayList(); + public GenericSiteUtil(){ + using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) + { + String strTmp = xmlreader.GetValueAsString("movies", "extensions", ".avi,.mpg,.ogm,.mpeg,.mkv,.wmv,.ifo,.qt,.rm,.mov,.sbe,.dvr-ms,.ts"); + String [] tok = strTmp.Split( ','); + foreach (string extension in tok) + { + m_VideoExtensions.Add(extension.ToLower()); + } + } + + } + public override string getSiteId() + { + return "50"; + } + + protected 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(); + if(!String.IsNullOrEmpty(rssItem.description)){ + video.Description = rssItem.description; + }else{ + video.Description = rssItem.mediaDescription; + } + if(!String.IsNullOrEmpty(rssItem.mediaThumbnail)){ + video.ImageUrl = rssItem.mediaThumbnail; + } + else if(!String.IsNullOrEmpty(rssItem.exInfoImage)){ + video.ImageUrl = rssItem.exInfoImage; + } + //get the video + if(!String.IsNullOrEmpty(rssItem.enclosure)&& isPossibleVideo(rssItem.enclosure)){ + video.VideoUrl = rssItem.enclosure; + video.Length = rssItem.enclosureDuration; + } + else if(rssItem.contentList.Count>0){ + foreach(MediaContent content in rssItem.contentList){ + if(isPossibleVideo(content.url)){ + video.VideoUrl = content.url; + video.Length = content.duration; + break; + } + + } + + + } + //if(!String.IsNullOrEmpty()){ + + //} + //if(!String.IsNullOrEmpty()){ + + //} + + + video.Title = rssItem.title; + + if(String.IsNullOrEmpty(video.VideoUrl)==false){ + + loVideoList.Add(video); + } + } + return loVideoList; + } + private bool isPossibleVideo(string fsUrl){ + string extensionFile = System.IO.Path.GetExtension(fsUrl).ToLower(); + if(String.IsNullOrEmpty(extensionFile))return true; + foreach (string extension in m_VideoExtensions) + { + if (extension == extensionFile) return true; + } + return false; + + } + } +} Modified: trunk/plugins/OnlineVideos/Source/OnlineVideos/GoogleVideoUtil.cs =================================================================== --- trunk/plugins/OnlineVideos/Source/OnlineVideos/GoogleVideoUtil.cs 2007-08-22 23:07:31 UTC (rev 857) +++ trunk/plugins/OnlineVideos/Source/OnlineVideos/GoogleVideoUtil.cs 2007-08-23 00:58:47 UTC (rev 858) @@ -51,7 +51,7 @@ }else if(content.type.Contains("flv")){ flvUrl = content.url; Log.Info("flv url:{0}", content.url); - video.Length = Convert.ToInt32(content.duration); + video.Length = content.duration; } else if (content.type.Contains("mp4")) { Modified: trunk/plugins/OnlineVideos/Source/OnlineVideos/MetaCafeUtil.cs =================================================================== --- trunk/plugins/OnlineVideos/Source/OnlineVideos/MetaCafeUtil.cs 2007-08-22 23:07:31 UTC (rev 857) +++ trunk/plugins/OnlineVideos/Source/OnlineVideos/MetaCafeUtil.cs 2007-08-23 00:58:47 UTC (rev 858) @@ -47,7 +47,7 @@ video.Description = rssItem.description; video.ImageUrl = rssItem.mediaThumbnail; video.Title = rssItem.title; - video.Length = Convert.ToInt32(rssItem.contentList[0].duration); + video.Length = rssItem.contentList[0].duration; video.VideoUrl = Regex.Match(rssItem.link,@"watch/([\d]*)").Groups[1].Value; loVideoList.Add(video); Modified: trunk/plugins/OnlineVideos/Source/OnlineVideos/OnlineVideos.csproj =================================================================== --- trunk/plugins/OnlineVideos/Source/OnlineVideos/OnlineVideos.csproj 2007-08-22 23:07:31 UTC (rev 857) +++ trunk/plugins/OnlineVideos/Source/OnlineVideos/OnlineVideos.csproj 2007-08-23 00:58:47 UTC (rev 858) @@ -82,6 +82,7 @@ <Compile Include="Favorites.cs" /> <Compile Include="FavoriteUtil.cs" /> <Compile Include="FavoriteVideo.cs" /> + <Compile Include="GenericSiteUtil.cs" /> <Compile Include="OnlineVideoSettings.cs" /> <Compile Include="RocketboomUtil.cs" /> <Compile Include="MyVideodeUtil.cs" /> Modified: trunk/plugins/OnlineVideos/Source/OnlineVideos/SiteUtilBase.cs =================================================================== --- trunk/plugins/OnlineVideos/Source/OnlineVideos/SiteUtilBase.cs 2007-08-22 23:07:31 UTC (rev 857) +++ trunk/plugins/OnlineVideos/Source/OnlineVideos/SiteUtilBase.cs 2007-08-23 00:58:47 UTC (rev 858) @@ -225,6 +225,7 @@ if(n.Attributes["duration"]!=null){ loRssItem.enclosureDuration = n.Attributes["duration"].Value; } + break; case "media:category": loRssItem.mediaCategory = n.InnerText; Modified: trunk/plugins/OnlineVideos/Source/OnlineVideos/YouTubeUtil.cs =================================================================== --- trunk/plugins/OnlineVideos/Source/OnlineVideos/YouTubeUtil.cs 2007-08-22 23:07:31 UTC (rev 857) +++ trunk/plugins/OnlineVideos/Source/OnlineVideos/YouTubeUtil.cs 2007-08-23 00:58:47 UTC (rev 858) @@ -127,7 +127,7 @@ Regex loRegex2 = new Regex("http://youtube.com/[?]v=([^<]*)"); video.VideoUrl = loRegex2.Match(rssItem.link).Groups[1].Value; video.Tags = rssItem.mediaCategory; - video.Length = Convert.ToInt32(rssItem.enclosureDuration); + video.Length = rssItem.enclosureDuration; loVideoList.Add(video); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |