From 15434866f7d28e7b78380d275547f444ded7b2d3 Mon Sep 17 00:00:00 2001 From: Tobias Bengfort Date: Tue, 16 May 2017 09:07:26 +0200 Subject: [PATCH] add playlist-skip option --- README.md | 2 ++ youtube_dl/YoutubeDL.py | 14 +++++++++++--- youtube_dl/__init__.py | 1 + youtube_dl/options.py | 4 ++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dc0be1f40..2a051a757 100644 --- a/README.md +++ b/README.md @@ -174,6 +174,8 @@ Alternatively, refer to the [developer instructions](#developer-instructions) fo downloaded videos in it. --include-ads Download advertisements as well (experimental) + --playlist-skip Skip over playlist items that fail to + download. ## Download Options: -r, --limit-rate RATE Maximum download rate in bytes per second diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 4c33d494a..d07688f2c 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -164,6 +164,7 @@ class YoutubeDL(object): playlist_items: Specific indices of playlist to download. playlistreverse: Download playlist items in reverse order. playlistrandom: Download playlist items in random order. + playlistskip: Skip over playlist items that fail to download. matchtitle: Download only matching titles. rejecttitle: Reject downloads for matching titles. logger: Log messages to a logging.Logger instance. @@ -957,9 +958,16 @@ class YoutubeDL(object): self.to_screen('[download] ' + reason) continue - entry_result = self.process_ie_result(entry, - download=download, - extra_info=extra) + try: + entry_result = self.process_ie_result(entry, + download=download, + extra_info=extra) + except DownloadError: + if self.params.get('playlistskip'): + continue + else: + raise + playlist_results.append(entry_result) ie_result['entries'] = playlist_results self.to_screen('[download] Finished downloading playlist: %s' % playlist) diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index c4589411e..b123e00d2 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -353,6 +353,7 @@ def _real_main(argv=None): 'playlistend': opts.playlistend, 'playlistreverse': opts.playlist_reverse, 'playlistrandom': opts.playlist_random, + 'playlistskip': opts.playlist_skip, 'noplaylist': opts.noplaylist, 'logtostderr': opts.outtmpl == '-', 'consoletitle': opts.consoletitle, diff --git a/youtube_dl/options.py b/youtube_dl/options.py index 3021a6f41..5829ecc42 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -492,6 +492,10 @@ def parseOpts(overrideArguments=None): '--playlist-random', action='store_true', help='Download playlist videos in random order') + selection.add_option( + '--playlist-skip', + action='store_true', + help='Skip over playlist items that fail to download.') downloader.add_option( '--xattr-set-filesize', dest='xattr_set_filesize', action='store_true',