1 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from ..utils import int_or_none
10 class DLiveVODIE(InfoExtractor):
12 _VALID_URL = r'https?://(?:www\.)?dlive\.tv/p/(?P<uploader_id>.+?)\+(?P<id>[a-zA-Z0-9]+)'
14 'url': 'https://dlive.tv/p/pdp+3mTzOl4WR',
18 'title': 'Minecraft with james charles epic',
19 'upload_date': '20190701',
20 'timestamp': 1562011015,
25 def _real_extract(self, url):
26 uploader_id, vod_id = re.match(self._VALID_URL, url).groups()
27 broadcast = self._download_json(
28 'https://graphigo.prd.dlive.tv/', vod_id,
29 data=json.dumps({'query': '''query {
30 pastBroadcast(permlink:"%s+%s") {
39 }''' % (uploader_id, vod_id)}).encode())['data']['pastBroadcast']
40 title = broadcast['title']
41 formats = self._extract_m3u8_formats(
42 broadcast['playbackUrl'], vod_id, 'mp4', 'm3u8_native')
43 self._sort_formats(formats)
47 'uploader_id': uploader_id,
49 'description': broadcast.get('content'),
50 'thumbnail': broadcast.get('thumbnailUrl'),
51 'timestamp': int_or_none(broadcast.get('createdAt'), 1000),
52 'view_count': int_or_none(broadcast.get('viewCount')),
56 class DLiveStreamIE(InfoExtractor):
57 IE_NAME = 'dlive:stream'
58 _VALID_URL = r'https?://(?:www\.)?dlive\.tv/(?P<id>[\w.-]+)'
60 def _real_extract(self, url):
61 display_name = self._match_id(url)
62 user = self._download_json(
63 'https://graphigo.prd.dlive.tv/', display_name,
64 data=json.dumps({'query': '''query {
65 userByDisplayName(displayname:"%s") {
75 }''' % display_name}).encode())['data']['userByDisplayName']
76 livestream = user['livestream']
77 title = livestream['title']
78 username = user['username']
79 formats = self._extract_m3u8_formats(
80 'https://live.prd.dlive.tv/hls/live/%s.m3u8' % username,
82 self._sort_formats(formats)
85 'title': self._live_title(title),
86 'uploader': display_name,
87 'uploader_id': username,
89 'description': livestream.get('content'),
90 'thumbnail': livestream.get('thumbnailUrl'),
92 'timestamp': int_or_none(livestream.get('createdAt'), 1000),
93 'view_count': int_or_none(livestream.get('watchingCount')),