totem r5780 - in trunk: . src/plugins/youtube



Author: pwithnall
Date: Fri Oct 24 18:01:58 2008
New Revision: 5780
URL: http://svn.gnome.org/viewvc/totem?rev=5780&view=rev

Log:
2008-10-24  Philip Withnall  <philip tecnocode co uk>

	* src/plugins/youtube/youtube.py: Remove redundant HTTP request
	when loading search results.



Modified:
   trunk/ChangeLog
   trunk/src/plugins/youtube/youtube.py

Modified: trunk/src/plugins/youtube/youtube.py
==============================================================================
--- trunk/src/plugins/youtube/youtube.py	(original)
+++ trunk/src/plugins/youtube/youtube.py	Fri Oct 24 18:01:58 2008
@@ -185,21 +185,6 @@
 		else:
 			return ""
 
-	def check_url_for_redirects (self, url_path):
-		try:
-			conn = httplib.HTTPConnection ("www.youtube.com")
-			conn.request ("GET", url_path)
-			response = conn.getresponse ()
-			conn.close ()
-		except:
-			print "Could not resolve stream MRL for YouTube video \"" + url_path + "\"."
-			return False
-
-		if response.status >= 300 and response.status < 400:
-			return response.getheader("location")
-		else:
-			return False
-
 	def resolve_t_param (self, youtube_id):
 		"""We have to get the t parameter from the actual video page, since Google changed how their URLs work"""
 		stream = urllib.urlopen ("http://youtube.com/watch?v="; + urllib.quote (youtube_id))
@@ -321,10 +306,10 @@
 		os.unlink (filename)
 
 		"""Get the video stream MRL"""
-		location = self.check_url_for_redirects ("/v/" + urllib.quote (youtube_id))
+		t_param = self.resolve_t_param (youtube_id)
 
-		if location != False:
-			mrl = "http://www.youtube.com/get_video?video_id="; + urllib.quote (youtube_id) + "&t=" + urllib.quote (self.resolve_t_param (youtube_id)) + self.get_fmt_string ()
+		if t_param != "":
+			mrl = "http://www.youtube.com/get_video?video_id="; + urllib.quote (youtube_id) + "&t=" + urllib.quote (t_param) + self.get_fmt_string ()
 
 		gobject.idle_add (self._append_to_liststore, treeview_name,
 				 pixbuf, entry.title.text, mrl, youtube_id)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]