YoutubeIE: use a negative index when accessing the last element of the format list
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Mon, 1 Jul 2013 15:19:33 +0000 (17:19 +0200)
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Mon, 1 Jul 2013 15:19:33 +0000 (17:19 +0200)
youtube_dl/extractor/youtube.py

index 656f46f219ebadedf9e25458367550f6d6e72e25..6782bbff6addf710ab17bec5baf73a2e11c50201 100644 (file)
@@ -586,7 +586,7 @@ class YoutubeIE(InfoExtractor):
             if req_format is None or req_format == 'best':
                 video_url_list = [(existing_formats[0], url_map[existing_formats[0]])] # Best quality
             elif req_format == 'worst':
-                video_url_list = [(existing_formats[len(existing_formats)-1], url_map[existing_formats[len(existing_formats)-1]])] # worst quality
+                video_url_list = [(existing_formats[-1], url_map[existing_formats[-1]])] # worst quality
             elif req_format in ('-1', 'all'):
                 video_url_list = [(f, url_map[f]) for f in existing_formats] # All formats
             else: