]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
[vevo] Centralize timestamp handling
authorPhilipp Hagemeister <phihag@phihag.de>
Thu, 13 Mar 2014 14:30:25 +0000 (15:30 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Thu, 13 Mar 2014 14:30:25 +0000 (15:30 +0100)
youtube_dl/YoutubeDL.py
youtube_dl/extractor/common.py
youtube_dl/extractor/vevo.py

index 63ed08abfc17bdb65a6f2575af09a37296e17729..d9f83419e1f20cb917a79f4e1bd143fa067220c4 100644 (file)
@@ -4,6 +4,7 @@
 from __future__ import absolute_import, unicode_literals
 
 import collections
+import datetime
 import errno
 import io
 import json
@@ -688,6 +689,11 @@ class YoutubeDL(object):
         if 'display_id' not in info_dict and 'id' in info_dict:
             info_dict['display_id'] = info_dict['id']
 
+        if info_dict.get('upload_date') is None and info_dict.get('upload_timestamp') is not None:
+            upload_date = datetime.datetime.utcfromtimestamp(
+                info_dict['upload_timestamp'])
+            info_dict['upload_date'] = upload_date.strftime('%Y%m%d')
+
         # This extractors handle format selection themselves
         if info_dict['extractor'] in ['Youku']:
             if download:
index fed05ce02f3f34c538f589fe3df9da548f70a229..103528414c3981343559eec259036bbb2f7118cc 100644 (file)
@@ -97,7 +97,9 @@ class InfoExtractor(object):
     thumbnail:      Full URL to a video thumbnail image.
     description:    One-line video description.
     uploader:       Full name of the video uploader.
+    upload_timestamp:UNIX timestamp of the upload moment.
     upload_date:    Video upload date (YYYYMMDD).
+                    If not explicitly set, calculated from update_timestamp.
     uploader_id:    Nickname or id of the video uploader.
     location:       Physical location of the video.
     subtitles:      The subtitle file contents as a dictionary in the format
index 888eb7402b085014516c1457b37f42273618ce05..7c97b9b364efc8c47ef3594e4382222ba2b09d5a 100644 (file)
@@ -2,7 +2,6 @@ from __future__ import unicode_literals
 
 import re
 import xml.etree.ElementTree
-import datetime
 
 from .common import InfoExtractor
 from ..utils import (
@@ -57,7 +56,8 @@ class VevoIE(InfoExtractor):
             'age_limit': 18,
             'title': 'Tunnel Vision (Explicit)',
             'uploader': 'Justin Timberlake',
-            'upload_date': '20130703',
+            'upload_date': '20130704',
+            'upload_timestamp': 1372906800,
         },
         'params': {
             'skip_download': 'true',
@@ -169,13 +169,13 @@ class VevoIE(InfoExtractor):
 
         timestamp_ms = int(self._search_regex(
             r'/Date\((\d+)\)/', video_info['launchDate'], 'launch date'))
-        upload_date = datetime.datetime.utcfromtimestamp(timestamp_ms // 1000)
+
         return {
             'id': video_id,
             'title': video_info['title'],
             'formats': formats,
             'thumbnail': video_info['imageUrl'],
-            'upload_date': upload_date.strftime('%Y%m%d'),
+            'upload_timestamp': timestamp_ms // 1000,
             'uploader': video_info['mainArtists'][0]['artistName'],
             'duration': video_info['duration'],
             'age_limit': age_limit,