Added duration for YouTube videos
authorTailszefox <tails@tailszefox.no-ip.com>
Mon, 22 Oct 2012 16:32:42 +0000 (18:32 +0200)
committerTailszefox <tails@tailszefox.no-ip.com>
Mon, 22 Oct 2012 16:32:42 +0000 (18:32 +0200)
youtube_dl/InfoExtractors.py

index 6bf80900f357b762fba3b48ce7db2b8c5f7d2696..6e59ba8fd740c789435c3ada8ba0a13dcb2297a8 100644 (file)
@@ -414,6 +414,12 @@ class YoutubeIE(InfoExtractor):
                        except Trouble as trouble:
                                self._downloader.trouble(trouble[0])
 
+               if 'length_seconds' not in video_info:
+                       self._downloader.trouble(u'WARNING: unable to extract video duration')
+                       video_duration = ''
+               else:
+                       video_duration = urllib.unquote_plus(video_info['length_seconds'][0])
+
                # token
                video_token = urllib.unquote_plus(video_info['token'][0])
 
@@ -480,7 +486,8 @@ class YoutubeIE(InfoExtractor):
                                'thumbnail':    video_thumbnail.decode('utf-8'),
                                'description':  video_description,
                                'player_url':   player_url,
-                               'subtitles':    video_subtitles
+                               'subtitles':    video_subtitles,
+                               'duration':             video_duration
                        })
                return results