Support for YouTube in CoverDownloader.

This commit is contained in:
Justin Forest 2008-10-13 19:07:01 +04:00 committed by Thomas Perl
parent 47c98633e6
commit bb7e7c786b
2 changed files with 27 additions and 0 deletions

View File

@ -25,6 +25,7 @@
# * Support for Vimeo, maybe blip.tv and others.
import re
import urllib2
from gpodder.liblogger import log
from gpodder.util import proxy_request
@ -71,3 +72,24 @@ def get_real_channel_url(url):
return next
return url
def get_real_cover(url):
log('Cover: %s', url)
r = re.compile('http://www\.youtube\.com/rss/user/([a-z0-9]+)/videos\.rss', re.IGNORECASE)
m = r.match(url)
if m is not None:
data = urllib2.urlopen('http://www.youtube.com/user/'+ m.group(1)).read()
data = data[data.find('id="user-profile-image"'):]
data = data[data.find('src="') + 5:]
next = data[:data.find('"')]
if next.strip() == '':
return None
log('YouTube userpic for %s is: %s', url, next)
return next
return None

View File

@ -28,6 +28,7 @@ from gpodder.liblogger import log
from gpodder.libgpodder import gl
from gpodder import util
from gpodder import resolver
import gtk
import gobject
@ -152,6 +153,10 @@ class CoverDownloader(ObservableService):
if url is None:
url = channel.image
new_url = resolver.get_real_cover(channel.url)
if new_url is not None:
url = new_url
if url is not None:
image_data = None
try: