Merge branch 'master' of https://github.com/psi-neamf/youtube-dl into psi-neamf
authorRicardo Garcia <sarbalap+freshmeat@gmail.com>
Fri, 19 Nov 2010 17:30:58 +0000 (18:30 +0100)
committerRicardo Garcia <sarbalap+freshmeat@gmail.com>
Fri, 19 Nov 2010 17:30:58 +0000 (18:30 +0100)
1  2 
youtube-dl

diff --combined youtube-dl
index 6a888cc3f56d1da39be4acd547961ed608152ab4,1a53c2c41be9cca1c2845e7f523488ff35f661b6..e164d5c8caa5a287eadcf02d1cc6fdbcc55dca80
mode 100644,100755..100644
@@@ -5,6 -5,7 +5,7 @@@
  # Author: Benjamin Johnson
  # License: Public domain code
  import cookielib
+ import datetime
  import htmlentitydefs
  import httplib
  import locale
@@@ -831,7 -832,7 +832,7 @@@ class YoutubeIE(InfoExtractor)
  
                # Get video webpage
                self.report_video_webpage_download(video_id)
 -              request = urllib2.Request('http://www.youtube.com/watch?v=%s&gl=US&hl=en' % video_id, None, std_headers)
 +              request = urllib2.Request('http://www.youtube.com/watch?v=%s&gl=US&hl=en&amp;has_verified=1' % video_id, None, std_headers)
                try:
                        video_webpage = urllib2.urlopen(request).read()
                except (urllib2.URLError, httplib.HTTPException, socket.error), err:
                        return
  
                # Attempt to extract SWF player URL
 -              mobj = re.search(r'swfConfig.*"(http://.*?watch.*?-.*?\.swf)"', video_webpage)
 +              mobj = re.search(r'swfConfig.*?"(http:\\/\\/.*?watch.*?-.*?\.swf)"', video_webpage)
                if mobj is not None:
 -                      player_url = mobj.group(1)
 +                      player_url = re.sub(r'\\(.)', r'\1', mobj.group(1))
                else:
                        player_url = None
  
                else:   # don't panic if we can't find it
                        video_thumbnail = urllib.unquote_plus(video_info['thumbnail_url'][0])
  
+               # upload date
+               upload_date = u'NA'
+               mobj = re.search(r'id="eow-date".*?>(.*?)</span>', video_webpage, re.DOTALL)
+               if mobj is not None:
+                       upload_date = mobj.group(1).split()
+                       format_expressions = ['%d %B %Y', '%B %d, %Y']
+                       for expression in format_expressions:
+                               try:
+                                       upload_date = datetime.datetime.strptime(upload_date, expression).strftime('%Y%m%d')
+                               except:
+                                       pass
                # description
                video_description = 'No description available.'
                if self._downloader.params.get('forcedescription', False):
                                        'id':           video_id.decode('utf-8'),
                                        'url':          video_real_url.decode('utf-8'),
                                        'uploader':     video_uploader.decode('utf-8'),
+                                       'uploaddate':   upload_date,
                                        'title':        video_title,
                                        'stitle':       simple_title,
                                        'ext':          video_extension.decode('utf-8'),
@@@ -1094,6 -1108,7 +1108,7 @@@ class MetacafeIE(InfoExtractor)
                                'id':           video_id.decode('utf-8'),
                                'url':          video_url.decode('utf-8'),
                                'uploader':     video_uploader.decode('utf-8'),
+                               'uploaddate':   u'NA',
                                'title':        video_title,
                                'stitle':       simple_title,
                                'ext':          video_extension.decode('utf-8'),
@@@ -1182,6 -1197,7 +1197,7 @@@ class DailymotionIE(InfoExtractor)
                                'id':           video_id.decode('utf-8'),
                                'url':          video_url.decode('utf-8'),
                                'uploader':     video_uploader.decode('utf-8'),
+                               'uploaddate':   u'NA',
                                'title':        video_title,
                                'stitle':       simple_title,
                                'ext':          video_extension.decode('utf-8'),
@@@ -1291,6 -1307,7 +1307,7 @@@ class GoogleIE(InfoExtractor)
                                'id':           video_id.decode('utf-8'),
                                'url':          video_url.decode('utf-8'),
                                'uploader':     u'NA',
+                               'uploaddate':   u'NA',
                                'title':        video_title,
                                'stitle':       simple_title,
                                'ext':          video_extension.decode('utf-8'),
@@@ -1372,6 -1389,7 +1389,7 @@@ class PhotobucketIE(InfoExtractor)
                                'id':           video_id.decode('utf-8'),
                                'url':          video_url.decode('utf-8'),
                                'uploader':     video_uploader,
+                               'uploaddate':   u'NA',
                                'title':        video_title,
                                'stitle':       simple_title,
                                'ext':          video_extension.decode('utf-8'),
@@@ -1526,6 -1544,7 +1544,7 @@@ class YahooIE(InfoExtractor)
                                'id':           video_id.decode('utf-8'),
                                'url':          video_url,
                                'uploader':     video_uploader,
+                               'uploaddate':   u'NA',
                                'title':        video_title,
                                'stitle':       simple_title,
                                'ext':          video_extension.decode('utf-8'),
@@@ -1628,6 -1647,7 +1647,7 @@@ class GenericIE(InfoExtractor)
                                'id':           video_id.decode('utf-8'),
                                'url':          video_url.decode('utf-8'),
                                'uploader':     video_uploader,
+                               'uploaddate':   u'NA',
                                'title':        video_title,
                                'stitle':       simple_title,
                                'ext':          video_extension.decode('utf-8'),