mirror of
https://github.com/l1ving/youtube-dl
synced 2025-03-12 21:37:30 +08:00
[aliexpress] fixed possible regex and return issue and used better dict getter
This commit is contained in:
parent
5e31985b03
commit
3e51145032
@ -1,7 +1,12 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..utils import try_get, float_or_none
|
||||||
|
from ..compat import compat_str
|
||||||
|
|
||||||
|
|
||||||
class AliExpressLiveIE(InfoExtractor):
|
class AliExpressLiveIE(InfoExtractor):
|
||||||
@ -23,15 +28,13 @@ class AliExpressLiveIE(InfoExtractor):
|
|||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
page = self._download_webpage(url, video_id)
|
page = self._download_webpage(url, video_id)
|
||||||
# runParams is a variable which contains information about the stream
|
run_params_json = self._search_regex(r'runParams = (.+)[\s+]var myCtl', page, 'runParams', flags=re.DOTALL)
|
||||||
run_params_json = self._search_regex(r'runParams = ([^<]+)[\s+]var [a-z]+', page, 'runParams')
|
|
||||||
run_params = self._parse_json(run_params_json, video_id)
|
run_params = self._parse_json(run_params_json, video_id)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_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', {'name': None}).get('name'),
|
'uploader': try_get(run_params, lambda x: x['followBar']['name'], compat_str),
|
||||||
# the given unix timestamp contains 000 at the end, so we have to strip it off by dividing it with 1000
|
'timestamp': float_or_none(try_get(run_params, lambda x: x['followBar']['createTime']) / 1000),
|
||||||
'timestamp': run_params.get('followBar', {'createTime': 0}).get('createTime', 0) / 1000,
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user