|
From: <gre...@us...> - 2007-04-16 17:56:45
|
Revision: 331
http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=331&view=rev
Author: gregmac45
Date: 2007-04-16 10:52:44 -0700 (Mon, 16 Apr 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/plugins/OnlineVideos/OnlineVideoSettings.xml
trunk/plugins/OnlineVideos/Source/GoogleVideoUtil.cs
trunk/plugins/OnlineVideos/Source/YouTubeUtil.cs
Modified: trunk/plugins/OnlineVideos/OnlineVideoSettings.xml
===================================================================
--- trunk/plugins/OnlineVideos/OnlineVideoSettings.xml 2007-04-15 14:09:40 UTC (rev 330)
+++ trunk/plugins/OnlineVideos/OnlineVideoSettings.xml 2007-04-16 17:52:44 UTC (rev 331)
@@ -10,6 +10,7 @@
<!-- set the password if you wish to add/delete favorites to youtube -->
<password></password>
<!-- set the confirmAge to yes if you wish to confirm your age to view certain videos -->
+<!-- The user and password must be set if confirmAge is set to yes
<confirmAge>no</confirmAge>
<rss name="Top Rated"><![CDATA[http://youtube.com/rss/global/top_rated.rss]]></rss>
<rss name="Recently Added"><![CDATA[http://youtube.com/rss/global/recently_added.rss]]></rss>
Modified: trunk/plugins/OnlineVideos/Source/GoogleVideoUtil.cs
===================================================================
--- trunk/plugins/OnlineVideos/Source/GoogleVideoUtil.cs 2007-04-15 14:09:40 UTC (rev 330)
+++ trunk/plugins/OnlineVideos/Source/GoogleVideoUtil.cs 2007-04-16 17:52:44 UTC (rev 331)
@@ -36,13 +36,36 @@
video.Description = rssItem.mediaDescription;
video.ImageUrl = rssItem.mediaThumbnail;
video.Title = rssItem.title;
+ String flvUrl = String.Empty;
+ String aviUrl = String.Empty;
+ String mp4Url = String.Empty;
+ String youtubeUrl = String.Empty;
foreach(MediaContent content in rssItem.contentList){
- if(content.type.Contains("flv")){
- video.VideoUrl = content.url;
- break;
- }
+ if(content.type.Contains("msvideo")){
+ aviUrl = content.url;
+ Log.Info("avi url:{0}",content.url);
+ //break;
+ }else if(content.type.Contains("flv")){
+ flvUrl = content.url;
+ Log.Info("flv url:{0}", content.url);
+ }
+ else if (content.type.Contains("mp4"))
+ {
+
+ mp4Url = content.url;
+ Log.Info("mp4 url:{0}", content.url);
+ }
+ else
+ {
+
+ Log.Info("unknown url:{0}", content.url);
+ }
+ video.VideoUrl = flvUrl;
}
- loVideoList.Add(video);
+ if(String.IsNullOrEmpty(video.VideoUrl)==false){
+
+ loVideoList.Add(video);
+ }
}
return loVideoList;
}
Modified: trunk/plugins/OnlineVideos/Source/YouTubeUtil.cs
===================================================================
--- trunk/plugins/OnlineVideos/Source/YouTubeUtil.cs 2007-04-15 14:09:40 UTC (rev 330)
+++ trunk/plugins/OnlineVideos/Source/YouTubeUtil.cs 2007-04-16 17:52:44 UTC (rev 331)
@@ -199,17 +199,35 @@
{
String lsUrl;
String lsNextUrl = "";
- if(foSite.confirmAge){
- lsUrl = "http://www.youtube.com/verify_age?next_url=/watch%%3Fv%%3D"+fsId;
- lsNextUrl = "http://youtube.com/watch?v=" + fsId;
- if(!isLoggedIn()){
- //try to login
- login(foSite.username,foSite.password);
- }
- }
- else{
- lsUrl = "http://youtube.com/watch?v=" + fsId;
- }
+ String lsPostData = "";
+ if (foSite.confirmAge)
+ {
+ Log.Info("confirmAge is set to yes");
+ lsUrl = "http://www.youtube.com/verify_age?next_url=/watch?v=" + fsId;
+ lsNextUrl = "/watch?v=" + fsId;
+ lsPostData = "next_url=" + lsNextUrl + "&action_confirm=Confirm";
+ if (!isLoggedIn())
+ {
+ Log.Info("Not currently logged in. Trying to log in");
+ //try to login
+ if (login(foSite.username, foSite.password))
+ {
+ Log.Info("logged in successfully");
+ //foreach(Cookie cookie in moCookies){
+ // Log.Info("Found cookie:" + cookie.Name);
+ //}
+
+ }
+ else
+ {
+ Log.Info("login failed");
+ }
+ }
+ }
+ else
+ {
+ lsUrl = "http://youtube.com/watch?v=" + fsId;
+ }
//String lsHtml = getHTMLData(lsUrl);
//WebClient loClient1 = new WebClient();
@@ -218,17 +236,21 @@
Request.ContentType = "application/x-www-form-urlencoded";
Request.CookieContainer = new CookieContainer();
-
- Request.CookieContainer.Add(moCookies);
+ if (moCookies!=null)
+ {
+ Log.Info("setting the cookies for the request");
+ Request.CookieContainer.Add(moCookies);
+ }
Stream RequestStream = Request.GetRequestStream();
ASCIIEncoding ASCIIEncoding = new ASCIIEncoding();
//Byte [] PostData = ASCIIEncoding.GetBytes("username=" + fsUser +"&password="+ fsPassword);
- Byte [] PostData = ASCIIEncoding.GetBytes("next_url="+lsNextUrl+"&action_confirm=Confirm");
+ Byte [] PostData = ASCIIEncoding.GetBytes(lsPostData);
RequestStream.Write(PostData, 0, PostData.Length);
RequestStream.Close();
HttpWebResponse response = (HttpWebResponse)Request.GetResponse();
StreamReader Reader = new StreamReader(Request.GetResponse().GetResponseStream());
- String lsHtml = Reader.ReadToEnd();
+ String lsHtml = Reader.ReadToEnd();
+ //Log.Info("Session Html:{0}",lsHtml);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|