Test; fetch upload date and timestamp
This commit is contained in:
parent
66086f7950
commit
b8bd2a22cb
@ -1,6 +1,8 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from calendar import timegm
|
||||||
|
from datetime import datetime
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
@ -22,7 +24,6 @@ class CCTVIE(InfoExtractor):
|
|||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
# fo.addVariable("videoCenterId","id")
|
# fo.addVariable("videoCenterId","id")
|
||||||
'url': 'http://sports.cntv.cn/2016/02/12/ARTIaBRxv4rTT1yWf1frW2wi160212.shtml',
|
'url': 'http://sports.cntv.cn/2016/02/12/ARTIaBRxv4rTT1yWf1frW2wi160212.shtml',
|
||||||
'md5': 'd61ec00a493e09da810bf406a078f691',
|
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '5ecdbeab623f4973b40ff25f18b174e8',
|
'id': '5ecdbeab623f4973b40ff25f18b174e8',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
@ -112,6 +113,17 @@ class CCTVIE(InfoExtractor):
|
|||||||
'skip_download': True,
|
'skip_download': True,
|
||||||
},
|
},
|
||||||
'expected_warnings': ['Failed to download m3u8 information'],
|
'expected_warnings': ['Failed to download m3u8 information'],
|
||||||
|
}, {
|
||||||
|
# older multi-part streams, non-HLS
|
||||||
|
'url': 'http://english.cntv.cn/program/learnchinese/20110325/103360.shtml',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '20110325100557_00',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Learn to Speak Chinese Edition 24-2011 (Chapter 01)',
|
||||||
|
'duration': 295,
|
||||||
|
'timestamp': 1301053440,
|
||||||
|
'upload_date': '20110325',
|
||||||
|
},
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://ent.cntv.cn/2016/01/18/ARTIjprSSJH8DryTVr5Bx8Wb160118.shtml',
|
'url': 'http://ent.cntv.cn/2016/01/18/ARTIjprSSJH8DryTVr5Bx8Wb160118.shtml',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
@ -163,6 +175,12 @@ class CCTVIE(InfoExtractor):
|
|||||||
data = self._parse_json(data, video_id)
|
data = self._parse_json(data, video_id)
|
||||||
entries = []
|
entries = []
|
||||||
title = data.get('title')
|
title = data.get('title')
|
||||||
|
upload_date = self._search_regex(
|
||||||
|
'<em>(?:\s+)?(\d{2}\-\d{2}\-\d{4}\s+\d{2}\:\d{2})[^<]+',
|
||||||
|
webpage, 'upload date', fatal=False).strip()
|
||||||
|
upload_date = re.sub(r'\s+', ' ', upload_date)
|
||||||
|
udt = datetime.strptime(upload_date, '%m-%d-%Y %H:%M')
|
||||||
|
|
||||||
for i, chapter in enumerate(data.get('chapters', [])):
|
for i, chapter in enumerate(data.get('chapters', [])):
|
||||||
url = chapter.get('url')
|
url = chapter.get('url')
|
||||||
if title:
|
if title:
|
||||||
@ -170,12 +188,18 @@ class CCTVIE(InfoExtractor):
|
|||||||
else:
|
else:
|
||||||
ctitle = 'Chapter %02d' % (i + 1,)
|
ctitle = 'Chapter %02d' % (i + 1,)
|
||||||
if url:
|
if url:
|
||||||
|
if not url.startswith('http'):
|
||||||
|
url = re.sub(r'^[^\:]+', 'http', url)
|
||||||
entries.append(dict(id='%s_%02d' % (video_id, i,),
|
entries.append(dict(id='%s_%02d' % (video_id, i,),
|
||||||
thumbnail=data.get('imagePath'),
|
thumbnail=data.get('imagePath'),
|
||||||
title=ctitle,
|
title=ctitle,
|
||||||
duration=int_or_none(chapter.get('duration')),
|
duration=int_or_none(chapter.get('duration')),
|
||||||
|
upload_date=udt.strftime('%Y%m%d'),
|
||||||
|
timestamp=timegm(udt.timetuple()),
|
||||||
url=url))
|
url=url))
|
||||||
return self.playlist_result(entries, playlist_id=video_id, playlist_title=data.get('title'))
|
return self.playlist_result(entries,
|
||||||
|
playlist_id=video_id,
|
||||||
|
playlist_title=title)
|
||||||
|
|
||||||
title = data['title']
|
title = data['title']
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user