From: Rogério Brito Date: Mon, 25 Oct 2010 04:23:18 +0000 (-0200) Subject: Imported Debian patch 2010.10.24-1 X-Git-Url: https://git.rapsys.eu/youtubedl/commitdiff_plain/aa222958906ca312c82e3540898cc61ed63cbce0?hp=d3379076f5a45504e2d1a17d4ebed629f2da1b9f Imported Debian patch 2010.10.24-1 --- diff --git a/.hg_archival.txt b/.hg_archival.txt index 6f2bddf..21226b5 100644 --- a/.hg_archival.txt +++ b/.hg_archival.txt @@ -1,5 +1,4 @@ repo: f87cf8f2527c4adda57b14bd79a354f815164a41 -node: 190d2d0fd729eecabaf246813801f5228050e0ad +node: 3b1889cc83b5085e178593f4dfa376b429f5be0d branch: default -latesttag: 2010.10.03 -latesttagdistance: 1 +tag: 2010.10.24 diff --git a/LATEST_VERSION b/LATEST_VERSION index 92947da..8418210 100644 --- a/LATEST_VERSION +++ b/LATEST_VERSION @@ -1 +1 @@ -2010.10.03 +2010.10.24 diff --git a/debian/changelog b/debian/changelog index 63bdb92..17ee981 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +youtube-dl (2010.10.24-1) unstable; urgency=low + + * New upstream release + + -- Rogério Brito Mon, 25 Oct 2010 02:23:18 -0200 + youtube-dl (2010.10.03-1) unstable; urgency=low * The "upload from sunny California" release diff --git a/debian/changelog.dch b/debian/changelog.dch new file mode 100644 index 0000000..f3d2b97 --- /dev/null +++ b/debian/changelog.dch @@ -0,0 +1,317 @@ +youtube-dl (2010.10.24-1) unstable; urgency=low + + * New upstream release. Highlights: + + Add --cookies option to allow saving cookies to disk + (primarily to be used with external downloaders: e.g., aria2c). + + Support "https" both for YouTube URLs and for login. + * debian/patches: + + refresh patch. + + -- Rogério Brito Mon, 25 Oct 2010 02:23:40 -0200 + +youtube-dl (2010.10.03-1) unstable; urgency=low + + * The "upload from sunny California" release + * New upstream release: + + Downloading manually the release 2010.10.03 corresponding to + http://bitbucket.org/rg3/youtube-dl/changeset/190d2d0fd729 + + Abort downloads that can't be written to the disk + + Fix downloading some videos from metacafe.com + + Try to discover the video extension from metacafe.com + + Allow #! in youtube urls + + Fix extraction of uploader nickname on dailymotion + + Support downloads from youtube-nocookie.com urls + + Code improvements in general + + Retry that fail with codes 5xx on youtube + * debian/patches/*: + + rename 01-add-support-to-webm.patch to 01-prefer-open-formats.patch + + update the patch to apply to new versions of youtube-dl + + re-enable the patch to give preference to webm videos + + -- Rogério Brito Wed, 13 Oct 2010 21:58:24 -0700 + +youtube-dl (2010.08.04-1) unstable; urgency=low + + * New upstream release: + + Fix metacafe.com code not working due to gdaKey again + + Add option (--playlist-start) to specify the initial video for playlists + + Put back -b option as a placeholder with a warning message + + Consider the file downloaded if the size differs in less than 100 bytes + + Reorganize request code to make it a bit more robust + + Properly detect YouTube error messages to print them on screen + * debian/control: + + Remove suggests on gst-p-b (>= 0.10.18.3-2) + + The package complies with Policy 3.9.1 without any other changes. + * debian/watch: + + Remove commented lines. + * debian/youtube-dl.pod: + + Update the manpage to include newer options. + + Don't mention removed options anymore. Closes: #590825, #592368. + + -- Rogério Brito Mon, 09 Aug 2010 13:27:41 -0400 + +youtube-dl (2010.07.24-1) unstable; urgency=medium + + * Urgency medium due to changes in the site that broke earlier versions. + * New upstream release: + + restore support for WebM formats. + * debian/changelog: + + fix entry that stated incorrect removed options. Closes: #590144. + + -- Rogério Brito Sat, 24 Jul 2010 22:29:21 -0300 + +youtube-dl (2010.07.22-1) unstable; urgency=medium + + * Urgency set to medium due to changes in the site + * New upstream release: + + make youtube-dl work again. Closes: #589974. + + removed command line options -b and -d. + * debian/NEWS: + + document the removal of command line options and the new behavior. + * debian/patches: + + disabled for the moment. + * debian/control: + + include the support of dailymotion in the long description. + + update the standards version to 3.9.0, with no other changes. + + -- Rogério Brito Thu, 22 Jul 2010 18:58:29 -0300 + +youtube-dl (2010.07.14-1) unstable; urgency=low + + * New upstream release: + + add preliminary support for Dailymotion videos + + improve support for WebM in YouTube + + add support for the "original" video format in YouTube + + add a --max-quality option + + add support for youtu.be URLs + + add fixes. + * debian/patches/01-add-support-to-webm.patch: + + update and refresh. + + -- Rogério Brito Wed, 14 Jul 2010 22:39:54 -0300 + +youtube-dl (2010.06.06-1) unstable; urgency=low + + * New upstream release: + + support for retrying connections after a 503 error + + argument '-' can be used with -a to indicate stdin + + support for webm formats + * debian/patches/01-add-support-to-webm.patch: + + remove parts applied upstream + + update to download webm videos based on their quality + + -- Rogério Brito Mon, 07 Jun 2010 04:16:54 -0300 + +youtube-dl (2010.04.04-3) unstable; urgency=low + + * Migrate the packaging to smaller dh(7) style. + * Update the years of copyright. + + -- Rogério Brito Tue, 01 Jun 2010 11:06:06 -0300 + +youtube-dl (2010.04.04-2) unstable; urgency=low + + * Add support to webm (vp8 + vorbis) format: + + debian/patches/01-add-support-to-webm.patch: the code + + debian/NEWS: the documentation + + debian/control: the suggests field + + -- Rogério Brito Sat, 29 May 2010 13:11:43 -0300 + +youtube-dl (2010.04.04-1) unstable; urgency=low + + * New upstream release: + + allow grabbing videos from vevo. + + allow download whole playlists and keep the videos numbered. + + add support for new playlist style. + + fix detection of multipage playlists. + + insist a little bit more to grab videos from youtube. + + add information extractor for video.yahoo.com. + + fix cosmetic issues with rtmpdump. + + add option --all-formats to grab all available formats for a given video. + + add "-" (without quotes) as an alias to output videos to stdout. + + -- Rogério Brito Sun, 04 Apr 2010 17:55:00 -0300 + +youtube-dl (2010.03.13-1) unstable; urgency=low + + * New upstream release + + added option to disable the status/progress updates. + + fine tuned the sequence of formats searched to discover the best quality. + + -- Rogério Brito Sun, 14 Mar 2010 23:33:48 -0300 + +youtube-dl (2010.02.13-1) unstable; urgency=low + + * New upstream release + + stronger parsing of URLs. + + better generation of filenames. + * debian/control: + + include misc-depends due to debhelper. + + the package is compliant with policy 3.8.4. + + -- Rogério Brito Wed, 17 Feb 2010 00:19:23 -0200 + +youtube-dl (2010.01.19-1) unstable; urgency=low + + * New upstream release. As upstream does not provide a changelog, here + are the highlights: + + patched to add Google Video and Photobucket support + + add support for using rtmpdump + + added support to download all of a user's videos! + + fix detection of uploader nickname in metacafe + + take format 37 into account + + add self-updating code + + allow empty titles because they do appear in some videos + + use default values for "continuedl" and "nooverwrites" parameters + + avoid using Unicode strings when forming URL requests + + improve preferred encoding detection method + * Remove all patches (applied upstream). + * Add suggests on rtmpdump. + * Shorten the short description. + * Include list of sites supported in the long description. + + -- Rogério Brito Tue, 26 Jan 2010 11:28:40 -0200 + +youtube-dl (2009.09.13-2) unstable; urgency=low + + * change to "3.0 (quilt)" format. + * add support for 1080p videos. Thanks Josh Triplett. Closes: #557042. + * include a better manpage. Closes: #553919. + * include the DMUA: yes field. + * kindly reviewed by Li Daobing. + + -- Rogério Brito Thu, 19 Nov 2009 11:21:36 -0200 + +youtube-dl (2009.09.13-1) unstable; urgency=low + + * New upstream release + * debian/watch: + + adjust for the new upstream layout. + * debian/control: + + Standards-Version updated to 3.8.3. No changes needed. + + -- Rogério Brito Sat, 10 Oct 2009 12:17:53 -0300 + +youtube-dl (2009.08.08-1~try01) unstable; urgency=low + + * The current maintainer seems busy (Closes: #491616): + + ability to recognize more qualities of a video. + + ability to automatically find the best quality video. + + ability to download entire playlists. + + ability to specify various urls. (Closes: #452071) + + ability to resume interrupted downloads. + + many other things. + * debian/copyright: + + rework the file. + + mention that the package is in the public domain. + + include my information. + + update the URL of the package. + * debian/control: + + add a Homepage: field. + + keeping the current manpage for now. + + give more details in the long description. + + list me as the maintainer. + + Standards-Version updated to 3.8.2. + * debian/watch: + + let's help with automatic updates. + + -- Rogério Brito Mon, 10 Aug 2009 08:14:08 -0300 + +youtube-dl (2008.03.22-1) unstable; urgency=low + + * New upstream release: + - adds -f / --format command line option. + + -- Robert S. Edmonds Wed, 26 Mar 2008 13:19:23 -0400 + +youtube-dl (2008.03.08-1) unstable; urgency=low + + * New upstream release: + - adds -b / --best-quality command line option. + + -- Robert S. Edmonds Wed, 12 Mar 2008 14:26:04 -0400 + +youtube-dl (2008.01.24-1) unstable; urgency=low + + * New upstream release; closes: #462427, #462428. + - fixes youtube download issues. + + -- Robert S. Edmonds Thu, 24 Jan 2008 22:15:05 -0500 + +youtube-dl (2007.10.09-1) unstable; urgency=low + + * New upstream release. + + -- Robert S. Edmonds Mon, 08 Oct 2007 19:22:33 -0400 + +youtube-dl (2007.08.24-1) unstable; urgency=low + + * New upstream release; closes: #439363. + + -- Robert S. Edmonds Fri, 24 Aug 2007 13:54:40 -0400 + +youtube-dl (2007.06.22-1) unstable; urgency=low + + * New upstream release: + - regex update. + + -- Robert S. Edmonds Thu, 21 Jun 2007 20:42:57 -0400 + +youtube-dl (2007.06.06-1) unstable; urgency=low + + * New upstream release: + - "--title-too" command line option to print the video's title. + + -- Robert S. Edmonds Thu, 07 Jun 2007 01:04:01 -0400 + +youtube-dl (2007.03.27-1) unstable; urgency=low + + * New upstream release: + - Progress meter. + - "--literal" command line option to use the video title in the filename. + - "--get-url" command line option to print the real video URL. + + -- Robert S. Edmonds Mon, 2 Apr 2007 21:46:56 -0400 + +youtube-dl (2007.02.18-1) unstable; urgency=low + + * New upstream release: + - Diction. + - Catches socket errors. + + -- Robert S. Edmonds Tue, 20 Feb 2007 13:57:32 -0500 + +youtube-dl (2007.01.19-1) unstable; urgency=low + + * New upstream release, closes: #406146. + + -- Robert S. Edmonds Sun, 28 Jan 2007 17:41:44 -0500 + +youtube-dl (2006.12.07-1) unstable; urgency=low + + * New upstream release: + - Use -t to name the downloaded file after the title, closes: #395184. + - Parses URLs without a leading "http://", closes: #400321. + + -- Robert S. Edmonds Sun, 10 Dec 2006 13:52:36 -0500 + +youtube-dl (2006.11.12-1) unstable; urgency=low + + * New upstream release. + + -- Robert S. Edmonds Sat, 25 Nov 2006 16:12:03 -0500 + +youtube-dl (2006.09.25-1) unstable; urgency=low + + * New upstream release. + * python >= 2.4 is now required. + + -- Robert S. Edmonds Wed, 27 Sep 2006 17:43:07 -0400 + +youtube-dl (2006.08.28-1) unstable; urgency=low + + * Initial release, closes: #385748. + + -- Robert S. Edmonds Sun, 3 Sep 2006 19:43:27 -0400 + diff --git a/debian/patches/01-prefer-open-formats.patch b/debian/patches/01-prefer-open-formats.patch index 06b8020..3012028 100644 --- a/debian/patches/01-prefer-open-formats.patch +++ b/debian/patches/01-prefer-open-formats.patch @@ -5,7 +5,7 @@ Last-Update: 2010-10-13 --- a/youtube-dl +++ b/youtube-dl -@@ -692,7 +692,7 @@ +@@ -703,7 +703,7 @@ _AGE_URL = 'http://www.youtube.com/verify_age?next_url=/&gl=US&hl=en' _NETRC_MACHINE = 'youtube' # Listed in order of quality diff --git a/youtube-dl b/youtube-dl index 51344f2..466b506 100755 --- a/youtube-dl +++ b/youtube-dl @@ -4,6 +4,7 @@ # Author: Danny Colligan # Author: Benjamin Johnson # License: Public domain code +import cookielib import htmlentitydefs import httplib import locale @@ -27,7 +28,7 @@ except ImportError: from cgi import parse_qs std_headers = { - 'User-Agent': 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100723 Firefox/3.6.8', + 'User-Agent': 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.11) Gecko/20101019 Firefox/3.6.11', 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'en-us,en;q=0.5', @@ -94,6 +95,9 @@ def sanitize_open(filename, open_mode): """ try: if filename == u'-': + if sys.platform == 'win32': + import msvcrt + msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) return (sys.stdout, filename) stream = open(filename, open_mode) return (stream, filename) @@ -181,22 +185,26 @@ class FileDownloader(object): Available options: - username: Username for authentication purposes. - password: Password for authentication purposes. - usenetrc: Use netrc for authentication instead. - quiet: Do not print messages to stdout. - forceurl: Force printing final URL. - forcetitle: Force printing title. - simulate: Do not download the video files. - format: Video format code. - format_limit: Highest quality format to try. - outtmpl: Template for output names. - ignoreerrors: Do not stop on download errors. - ratelimit: Download speed limit, in bytes/sec. - nooverwrites: Prevent overwriting files. - retries: Number of times to retry for HTTP error 5xx - continuedl: Try to continue downloads if possible. - noprogress: Do not print the progress bar. + username: Username for authentication purposes. + password: Password for authentication purposes. + usenetrc: Use netrc for authentication instead. + quiet: Do not print messages to stdout. + forceurl: Force printing final URL. + forcetitle: Force printing title. + forcethumbnail: Force printing thumbnail URL. + forcedescription: Force printing description. + simulate: Do not download the video files. + format: Video format code. + format_limit: Highest quality format to try. + outtmpl: Template for output names. + ignoreerrors: Do not stop on download errors. + ratelimit: Download speed limit, in bytes/sec. + nooverwrites: Prevent overwriting files. + retries: Number of times to retry for HTTP error 5xx + continuedl: Try to continue downloads if possible. + noprogress: Do not print the progress bar. + playliststart: Playlist item to start at. + logtostderr: Log messages to stderr instead of stdout. """ params = None @@ -204,6 +212,7 @@ class FileDownloader(object): _pps = [] _download_retcode = None _num_downloads = None + _screen_file = None def __init__(self, params): """Create a FileDownloader object with the given options.""" @@ -211,6 +220,7 @@ class FileDownloader(object): self._pps = [] self._download_retcode = 0 self._num_downloads = 0 + self._screen_file = [sys.stdout, sys.stderr][params.get('logtostderr', False)] self.params = params @staticmethod @@ -297,12 +307,13 @@ class FileDownloader(object): self._pps.append(pp) pp.set_downloader(self) - def to_stdout(self, message, skip_eol=False, ignore_encoding_errors=False): + def to_screen(self, message, skip_eol=False, ignore_encoding_errors=False): """Print message to stdout if not in quiet mode.""" try: if not self.params.get('quiet', False): - print (u'%s%s' % (message, [u'\n', u''][skip_eol])).encode(preferredencoding()), - sys.stdout.flush() + terminator = [u'\n', u''][skip_eol] + print >>self._screen_file, (u'%s%s' % (message, terminator)).encode(preferredencoding()), + self._screen_file.flush() except (UnicodeEncodeError), err: if not ignore_encoding_errors: raise @@ -343,40 +354,40 @@ class FileDownloader(object): def report_destination(self, filename): """Report destination filename.""" - self.to_stdout(u'[download] Destination: %s' % filename, ignore_encoding_errors=True) + self.to_screen(u'[download] Destination: %s' % filename, ignore_encoding_errors=True) def report_progress(self, percent_str, data_len_str, speed_str, eta_str): """Report download progress.""" if self.params.get('noprogress', False): return - self.to_stdout(u'\r[download] %s of %s at %s ETA %s' % + self.to_screen(u'\r[download] %s of %s at %s ETA %s' % (percent_str, data_len_str, speed_str, eta_str), skip_eol=True) def report_resuming_byte(self, resume_len): """Report attempt to resume at given byte.""" - self.to_stdout(u'[download] Resuming download at byte %s' % resume_len) + self.to_screen(u'[download] Resuming download at byte %s' % resume_len) def report_retry(self, count, retries): """Report retry in case of HTTP error 5xx""" - self.to_stdout(u'[download] Got server HTTP error. Retrying (attempt %d of %d)...' % (count, retries)) + self.to_screen(u'[download] Got server HTTP error. Retrying (attempt %d of %d)...' % (count, retries)) def report_file_already_downloaded(self, file_name): """Report file has already been fully downloaded.""" try: - self.to_stdout(u'[download] %s has already been downloaded' % file_name) + self.to_screen(u'[download] %s has already been downloaded' % file_name) except (UnicodeEncodeError), err: - self.to_stdout(u'[download] The file has already been downloaded') + self.to_screen(u'[download] The file has already been downloaded') def report_unable_to_resume(self): """Report it was impossible to resume download.""" - self.to_stdout(u'[download] Unable to resume') + self.to_screen(u'[download] Unable to resume') def report_finish(self): """Report download finished.""" if self.params.get('noprogress', False): - self.to_stdout(u'[download] Download completed') + self.to_screen(u'[download] Download completed') else: - self.to_stdout(u'') + self.to_screen(u'') def increment_downloads(self): """Increment the ordinal that assigns a number to each file.""" @@ -486,14 +497,14 @@ class FileDownloader(object): retval = subprocess.call(basic_args + [[], ['-e', '-k', '1']][self.params.get('continuedl', False)]) while retval == 2 or retval == 1: prevsize = os.path.getsize(filename) - self.to_stdout(u'\r[rtmpdump] %s bytes' % prevsize, skip_eol=True) + self.to_screen(u'\r[rtmpdump] %s bytes' % prevsize, skip_eol=True) time.sleep(5.0) # This seems to be needed retval = subprocess.call(basic_args + ['-e'] + [[], ['-k', '1']][retval == 1]) cursize = os.path.getsize(filename) if prevsize == cursize and retval == 1: break if retval == 0: - self.to_stdout(u'\r[rtmpdump] %s bytes' % os.path.getsize(filename)) + self.to_screen(u'\r[rtmpdump] %s bytes' % os.path.getsize(filename)) return True else: self.trouble(u'\nERROR: rtmpdump exited with code %d' % retval) @@ -686,9 +697,9 @@ class InfoExtractor(object): class YoutubeIE(InfoExtractor): """Information extractor for youtube.com.""" - _VALID_URL = r'^((?:http://)?(?:youtu\.be/|(?:\w+\.)?youtube(?:-nocookie)?\.com/(?:(?:v/)|(?:(?:watch(?:_popup)?(?:\.php)?)?(?:\?|#!?)(?:.+&)?v=))))?([0-9A-Za-z_-]+)(?(1).+)?$' + _VALID_URL = r'^((?:https?://)?(?:youtu\.be/|(?:\w+\.)?youtube(?:-nocookie)?\.com/(?:(?:v/)|(?:(?:watch(?:_popup)?(?:\.php)?)?(?:\?|#!?)(?:.+&)?v=))))?([0-9A-Za-z_-]+)(?(1).+)?$' _LANG_URL = r'http://www.youtube.com/?hl=en&persist_hl=1&gl=US&persist_gl=1&opt_out_ackd=1' - _LOGIN_URL = 'http://www.youtube.com/signup?next=/&gl=US&hl=en' + _LOGIN_URL = 'https://www.youtube.com/signup?next=/&gl=US&hl=en' _AGE_URL = 'http://www.youtube.com/verify_age?next_url=/&gl=US&hl=en' _NETRC_MACHINE = 'youtube' # Listed in order of quality @@ -710,35 +721,35 @@ class YoutubeIE(InfoExtractor): def report_lang(self): """Report attempt to set language.""" - self._downloader.to_stdout(u'[youtube] Setting language') + self._downloader.to_screen(u'[youtube] Setting language') def report_login(self): """Report attempt to log in.""" - self._downloader.to_stdout(u'[youtube] Logging in') + self._downloader.to_screen(u'[youtube] Logging in') def report_age_confirmation(self): """Report attempt to confirm age.""" - self._downloader.to_stdout(u'[youtube] Confirming age') + self._downloader.to_screen(u'[youtube] Confirming age') def report_video_webpage_download(self, video_id): """Report attempt to download video webpage.""" - self._downloader.to_stdout(u'[youtube] %s: Downloading video webpage' % video_id) + self._downloader.to_screen(u'[youtube] %s: Downloading video webpage' % video_id) def report_video_info_webpage_download(self, video_id): """Report attempt to download video info webpage.""" - self._downloader.to_stdout(u'[youtube] %s: Downloading video info webpage' % video_id) + self._downloader.to_screen(u'[youtube] %s: Downloading video info webpage' % video_id) def report_information_extraction(self, video_id): """Report attempt to extract video information.""" - self._downloader.to_stdout(u'[youtube] %s: Extracting video information' % video_id) + self._downloader.to_screen(u'[youtube] %s: Extracting video information' % video_id) def report_unavailable_format(self, video_id, format): """Report extracted video URL.""" - self._downloader.to_stdout(u'[youtube] %s: Format %s not available' % (video_id, format)) + self._downloader.to_screen(u'[youtube] %s: Format %s not available' % (video_id, format)) def report_rtmp_download(self): """Indicate the download will use the RTMP protocol.""" - self._downloader.to_stdout(u'[youtube] RTMP download detected') + self._downloader.to_screen(u'[youtube] RTMP download detected') def _real_initialize(self): if self._downloader is None: @@ -966,19 +977,19 @@ class MetacafeIE(InfoExtractor): def report_disclaimer(self): """Report disclaimer retrieval.""" - self._downloader.to_stdout(u'[metacafe] Retrieving disclaimer') + self._downloader.to_screen(u'[metacafe] Retrieving disclaimer') def report_age_confirmation(self): """Report attempt to confirm age.""" - self._downloader.to_stdout(u'[metacafe] Confirming age') + self._downloader.to_screen(u'[metacafe] Confirming age') def report_download_webpage(self, video_id): """Report webpage download.""" - self._downloader.to_stdout(u'[metacafe] %s: Downloading webpage' % video_id) + self._downloader.to_screen(u'[metacafe] %s: Downloading webpage' % video_id) def report_extraction(self, video_id): """Report information extraction.""" - self._downloader.to_stdout(u'[metacafe] %s: Extracting information' % video_id) + self._downloader.to_screen(u'[metacafe] %s: Extracting information' % video_id) def _real_initialize(self): # Retrieve disclaimer @@ -1106,11 +1117,11 @@ class DailymotionIE(InfoExtractor): def report_download_webpage(self, video_id): """Report webpage download.""" - self._downloader.to_stdout(u'[dailymotion] %s: Downloading webpage' % video_id) + self._downloader.to_screen(u'[dailymotion] %s: Downloading webpage' % video_id) def report_extraction(self, video_id): """Report information extraction.""" - self._downloader.to_stdout(u'[dailymotion] %s: Extracting information' % video_id) + self._downloader.to_screen(u'[dailymotion] %s: Extracting information' % video_id) def _real_initialize(self): return @@ -1193,11 +1204,11 @@ class GoogleIE(InfoExtractor): def report_download_webpage(self, video_id): """Report webpage download.""" - self._downloader.to_stdout(u'[video.google] %s: Downloading webpage' % video_id) + self._downloader.to_screen(u'[video.google] %s: Downloading webpage' % video_id) def report_extraction(self, video_id): """Report information extraction.""" - self._downloader.to_stdout(u'[video.google] %s: Extracting information' % video_id) + self._downloader.to_screen(u'[video.google] %s: Extracting information' % video_id) def _real_initialize(self): return @@ -1303,11 +1314,11 @@ class PhotobucketIE(InfoExtractor): def report_download_webpage(self, video_id): """Report webpage download.""" - self._downloader.to_stdout(u'[photobucket] %s: Downloading webpage' % video_id) + self._downloader.to_screen(u'[photobucket] %s: Downloading webpage' % video_id) def report_extraction(self, video_id): """Report information extraction.""" - self._downloader.to_stdout(u'[photobucket] %s: Extracting information' % video_id) + self._downloader.to_screen(u'[photobucket] %s: Extracting information' % video_id) def _real_initialize(self): return @@ -1387,11 +1398,11 @@ class YahooIE(InfoExtractor): def report_download_webpage(self, video_id): """Report webpage download.""" - self._downloader.to_stdout(u'[video.yahoo] %s: Downloading webpage' % video_id) + self._downloader.to_screen(u'[video.yahoo] %s: Downloading webpage' % video_id) def report_extraction(self, video_id): """Report information extraction.""" - self._downloader.to_stdout(u'[video.yahoo] %s: Extracting information' % video_id) + self._downloader.to_screen(u'[video.yahoo] %s: Extracting information' % video_id) def _real_initialize(self): return @@ -1539,12 +1550,12 @@ class GenericIE(InfoExtractor): def report_download_webpage(self, video_id): """Report webpage download.""" - self._downloader.to_stdout(u'WARNING: Falling back on generic information extractor.') - self._downloader.to_stdout(u'[generic] %s: Downloading webpage' % video_id) + self._downloader.to_screen(u'WARNING: Falling back on generic information extractor.') + self._downloader.to_screen(u'[generic] %s: Downloading webpage' % video_id) def report_extraction(self, video_id): """Report information extraction.""" - self._downloader.to_stdout(u'[generic] %s: Extracting information' % video_id) + self._downloader.to_screen(u'[generic] %s: Extracting information' % video_id) def _real_initialize(self): return @@ -1646,7 +1657,7 @@ class YoutubeSearchIE(InfoExtractor): def report_download_page(self, query, pagenum): """Report attempt to download playlist page with given number.""" query = query.decode(preferredencoding()) - self._downloader.to_stdout(u'[youtube] query "%s": Downloading page %s' % (query, pagenum)) + self._downloader.to_screen(u'[youtube] query "%s": Downloading page %s' % (query, pagenum)) def _real_initialize(self): self._youtube_ie.initialize() @@ -1737,7 +1748,7 @@ class GoogleSearchIE(InfoExtractor): def report_download_page(self, query, pagenum): """Report attempt to download playlist page with given number.""" query = query.decode(preferredencoding()) - self._downloader.to_stdout(u'[video.google] query "%s": Downloading page %s' % (query, pagenum)) + self._downloader.to_screen(u'[video.google] query "%s": Downloading page %s' % (query, pagenum)) def _real_initialize(self): self._google_ie.initialize() @@ -1828,7 +1839,7 @@ class YahooSearchIE(InfoExtractor): def report_download_page(self, query, pagenum): """Report attempt to download playlist page with given number.""" query = query.decode(preferredencoding()) - self._downloader.to_stdout(u'[video.yahoo] query "%s": Downloading page %s' % (query, pagenum)) + self._downloader.to_screen(u'[video.yahoo] query "%s": Downloading page %s' % (query, pagenum)) def _real_initialize(self): self._yahoo_ie.initialize() @@ -1918,7 +1929,7 @@ class YoutubePlaylistIE(InfoExtractor): def report_download_page(self, playlist_id, pagenum): """Report attempt to download playlist page with given number.""" - self._downloader.to_stdout(u'[youtube] PL %s: Downloading page #%s' % (playlist_id, pagenum)) + self._downloader.to_screen(u'[youtube] PL %s: Downloading page #%s' % (playlist_id, pagenum)) def _real_initialize(self): self._youtube_ie.initialize() @@ -1982,7 +1993,7 @@ class YoutubeUserIE(InfoExtractor): def report_download_page(self, username): """Report attempt to download user page.""" - self._downloader.to_stdout(u'[youtube] user %s: Downloading page ' % (username)) + self._downloader.to_screen(u'[youtube] user %s: Downloading page ' % (username)) def _real_initialize(self): self._youtube_ie.initialize() @@ -2083,7 +2094,7 @@ if __name__ == '__main__': if not os.access (filename, os.W_OK): sys.exit('ERROR: no write permissions on %s' % filename) - downloader.to_stdout('Updating to latest stable version...') + downloader.to_screen('Updating to latest stable version...') latest_url = 'http://bitbucket.org/rg3/youtube-dl/raw/tip/LATEST_VERSION' latest_version = urllib.urlopen(latest_url).read().strip() prog_url = 'http://bitbucket.org/rg3/youtube-dl/raw/%s/youtube-dl' % latest_version @@ -2091,17 +2102,12 @@ if __name__ == '__main__': stream = open(filename, 'w') stream.write(newcontent) stream.close() - downloader.to_stdout('Updated to version %s' % latest_version) - - # General configuration - urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())) - urllib2.install_opener(urllib2.build_opener(urllib2.HTTPCookieProcessor())) - socket.setdefaulttimeout(300) # 5 minutes should be enough (famous last words) + downloader.to_screen('Updated to version %s' % latest_version) # Parse command line parser = optparse.OptionParser( usage='Usage: %prog [options] url...', - version='2010.10.03', + version='2010.10.24', conflict_handler='resolve', ) @@ -2172,10 +2178,29 @@ if __name__ == '__main__': action='store_true', dest='nooverwrites', help='do not overwrite files', default=False) filesystem.add_option('-c', '--continue', action='store_true', dest='continue_dl', help='resume partially downloaded files', default=False) + filesystem.add_option('--cookies', + dest='cookiefile', metavar='FILE', help='file to dump cookie jar to') parser.add_option_group(filesystem) (opts, args) = parser.parse_args() + # Open appropriate CookieJar + if opts.cookiefile is None: + jar = cookielib.CookieJar() + else: + try: + jar = cookielib.MozillaCookieJar(opts.cookiefile) + if os.path.isfile(opts.cookiefile) and os.access(opts.cookiefile, os.R_OK): + jar.load() + except (IOError, OSError), err: + sys.exit(u'ERROR: unable to open cookie file') + + # General configuration + cookie_processor = urllib2.HTTPCookieProcessor(jar) + urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())) + urllib2.install_opener(urllib2.build_opener(cookie_processor)) + socket.setdefaulttimeout(300) # 5 minutes should be enough (famous last words) + # Batch file verification batchurls = [] if opts.batchfile is not None: @@ -2261,6 +2286,7 @@ if __name__ == '__main__': 'continuedl': opts.continue_dl, 'noprogress': opts.noprogress, 'playliststart': opts.playliststart, + 'logtostderr': opts.outtmpl == '-', }) fd.add_info_extractor(youtube_search_ie) fd.add_info_extractor(youtube_pl_ie) @@ -2289,6 +2315,14 @@ if __name__ == '__main__': else: sys.exit() retcode = fd.download(all_urls) + + # Dump cookie jar if requested + if opts.cookiefile is not None: + try: + jar.save() + except (IOError, OSError), err: + sys.exit(u'ERROR: unable to save cookie jar') + sys.exit(retcode) except DownloadError: