X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=inline;f=youtube_dl%2F__init__.py;h=818a3a73a20ec18a7e0aa55cf687a765e09eb0df;hb=47a53c9e46a232275e012ea368669d02816e7d85;hp=6a603349115d45de2cb28fa07324a7ac4e6e3cb4;hpb=561504fffaec8a141a5bdd20ca0a418795d38835;p=youtube-dl diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index 6a6033491..818a3a73a 100755 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -__author__ = ( +__authors__ = ( 'Ricardo Garcia Gonzalez', 'Danny Colligan', 'Benjamin Johnson', @@ -18,7 +18,7 @@ __author__ = ( ) __license__ = 'Public Domain' -__version__ = '2011.12.08' +__version__ = '2012.01.05' UPDATE_URL = 'https://raw.github.com/rg3/youtube-dl/master/youtube-dl' @@ -290,6 +290,15 @@ def _orderedSet(iterable): res.append(el) return res +def _unescapeHTML(s): + """ + @param s a string (of type unicode) + """ + assert type(s) == type(u'') + + htmlParser = HTMLParser.HTMLParser() + return htmlParser.unescape(s) + class DownloadError(Exception): """Download Error exception. @@ -759,10 +768,6 @@ class FileDownloader(object): if filename is None: return - if self.params.get('nooverwrites', False) and os.path.exists(filename): - self.to_stderr(u'WARNING: file exists and will be skipped') - return - try: dn = os.path.dirname(filename) if dn != '' and not os.path.exists(dn): @@ -804,16 +809,19 @@ class FileDownloader(object): return if not self.params.get('skip_download', False): - try: - success = self._do_download(filename, info_dict) - except (OSError, IOError), err: - raise UnavailableVideoError - except (urllib2.URLError, httplib.HTTPException, socket.error), err: - self.trouble(u'ERROR: unable to download video data: %s' % str(err)) - return - except (ContentTooShortError, ), err: - self.trouble(u'ERROR: content too short (expected %s bytes and served %s)' % (err.expected, err.downloaded)) - return + if self.params.get('nooverwrites', False) and os.path.exists(filename): + success = True + else: + try: + success = self._do_download(filename, info_dict) + except (OSError, IOError), err: + raise UnavailableVideoError + except (urllib2.URLError, httplib.HTTPException, socket.error), err: + self.trouble(u'ERROR: unable to download video data: %s' % str(err)) + return + except (ContentTooShortError, ), err: + self.trouble(u'ERROR: content too short (expected %s bytes and served %s)' % (err.expected, err.downloaded)) + return if success: try: @@ -1601,7 +1609,6 @@ class DailymotionIE(InfoExtractor): self._downloader.increment_downloads() video_id = mobj.group(1) - simple_title = mobj.group(2).decode('utf-8') video_extension = 'flv' # Retrieve video webpage to extract further information @@ -1631,12 +1638,13 @@ class DailymotionIE(InfoExtractor): video_url = mediaURL - mobj = re.search(r'(?im)\s*(.+)\s*-\s*Video\s+Dailymotion', webpage) + mobj = re.search(r'', webpage) if mobj is None: self._downloader.trouble(u'ERROR: unable to extract title') return - video_title = mobj.group(1).decode('utf-8') + video_title = _unescapeHTML(mobj.group('title').decode('utf-8')) video_title = sanitize_title(video_title) + simple_title = _simplify_title(video_title) mobj = re.search(r'(?im)[^<]+?]+?>([^<]+?)', webpage) if mobj is None: @@ -3150,7 +3158,7 @@ class ComedyCentralIE(InfoExtractor): return epTitle = mobj.group('episode') - mMovieParams = re.findall('', html) + mMovieParams = re.findall('(?: