1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-03-13 04:57:19 +08:00

[aliexpress] fixed possible extraction issues and removed unnecessary things

This commit is contained in:
dubber0 2017-07-23 18:28:26 +02:00
parent 4b990cb33a
commit 5e31985b03

View File

@ -2,7 +2,6 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from .common import InfoExtractor from .common import InfoExtractor
from datetime import datetime
class AliExpressLiveIE(InfoExtractor): class AliExpressLiveIE(InfoExtractor):
@ -10,34 +9,29 @@ class AliExpressLiveIE(InfoExtractor):
_VALID_URL = r'https?://live\.aliexpress\.com/live/(?P<id>[0-9]{16})' _VALID_URL = r'https?://live\.aliexpress\.com/live/(?P<id>[0-9]{16})'
_TEST = { _TEST = {
'url': 'https://live.aliexpress.com/live/2800002704436634', 'url': 'https://live.aliexpress.com/live/2800002704436634',
'md5': '7ac2bc46afdd18f0b45a0a340fc47ffe',
'info_dict': { 'info_dict': {
'id': '2800002704436634', 'id': '2800002704436634',
'ext': 'm3u8', 'ext': 'm3u8',
'title': 'CASIMA7.22', 'title': 'CASIMA7.22',
'uploader': 'CASIMA Official Store', 'uploader': 'CASIMA Official Store',
'upload_date': '20170714', 'upload_date': '20170714',
'is_live': True, 'timestamp': 1500027138,
}, },
'params': {
'skip_download': True,
}
} }
def _real_extract(self, url): def _real_extract(self, url):
vid_id = str(self._match_id(url)) video_id = self._match_id(url)
page = self._download_webpage(url, self._match_id(url)).replace('\n', '') page = self._download_webpage(url, video_id)
# runParams is a variable which contains information about the stream # runParams is a variable which contains information about the stream
run_params_json = self._search_regex(r'runParams = ([^<]+)[\s+]var [a-z]+', page, 'runParams') run_params_json = self._search_regex(r'runParams = ([^<]+)[\s+]var [a-z]+', page, 'runParams')
run_params = self._parse_json(run_params_json, vid_id) run_params = self._parse_json(run_params_json, video_id)
# the given unix timestamp contains 000 at the end, so we have to strip it off by dividing it with 1000
upload_date = datetime.fromtimestamp(run_params.get('followBar').get('createTime') / 1000).strftime('%Y%m%d')
return { return {
'id': vid_id, 'id': video_id,
'title': run_params['title'], 'title': run_params['title'],
'url': run_params['replyStreamUrl'], 'url': run_params['replyStreamUrl'],
'uploader': run_params.get('followBar').get('name'), 'uploader': run_params.get('followBar', {'name': None}).get('name'),
'upload_date': upload_date, # the given unix timestamp contains 000 at the end, so we have to strip it off by dividing it with 1000
'is_live': True, 'timestamp': run_params.get('followBar', {'createTime': 0}).get('createTime', 0) / 1000,
} }