aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/youtube.py
diff options
context:
space:
mode:
authorFilippo Valsorda <filippo.valsorda@gmail.com>2013-09-30 16:26:25 -0400
committerFilippo Valsorda <filippo.valsorda@gmail.com>2013-09-30 16:26:25 -0400
commit47192f92d801f38c0a608ca9c6cecc682ab2ecc6 (patch)
tree847734f3ccfe41bb0d46afdba8843524f7cb40b9 /youtube_dl/extractor/youtube.py
parent722076a123c60ed6d5a978c4bc2609f46c8e3ee9 (diff)
implement --no-playlist to only download current video - closes #755
Diffstat (limited to 'youtube_dl/extractor/youtube.py')
-rw-r--r--youtube_dl/extractor/youtube.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py
index 53f13b516..c6876c69f 100644
--- a/youtube_dl/extractor/youtube.py
+++ b/youtube_dl/extractor/youtube.py
@@ -13,6 +13,7 @@ import struct
import traceback
import xml.etree.ElementTree
import zlib
+import urlparse
from .common import InfoExtractor, SearchInfoExtractor
from .subtitles import SubtitlesInfoExtractor
@@ -1523,9 +1524,19 @@ class YoutubePlaylistIE(InfoExtractor):
mobj = re.match(self._VALID_URL, url, re.VERBOSE)
if mobj is None:
raise ExtractorError(u'Invalid URL: %s' % url)
+ playlist_id = mobj.group(1) or mobj.group(2)
+
+ # Check if it's a video-specific URL
+ query_dict = urlparse.parse_qs(urlparse.urlparse(url).query)
+ if 'v' in query_dict:
+ video_id = query_dict['v'][0]
+ if self._downloader.params.get('noplaylist'):
+ self.to_screen(u'Downloading just video %s because of --no-playlist' % video_id)
+ return self.url_result('https://www.youtube.com/watch?v=' + video_id, 'Youtube')
+ else:
+ self.to_screen(u'Downloading playlist PL%s - add --no-playlist to just download video %s' % (playlist_id, video_id))
# Download playlist videos from API
- playlist_id = mobj.group(1) or mobj.group(2)
videos = []
for page_num in itertools.count(1):