3 from .common
import InfoExtractor
4 from ..utils
import int_or_none
7 class DLiveVODIE(InfoExtractor
):
9 _VALID_URL
= r
'https?://(?:www\.)?dlive\.tv/p/(?P<uploader_id>.+?)\+(?P<id>[^/?#&]+)'
11 'url': 'https://dlive.tv/p/pdp+3mTzOl4WR',
15 'title': 'Minecraft with james charles epic',
16 'upload_date': '20190701',
17 'timestamp': 1562011015,
21 'url': 'https://dlive.tv/p/pdpreplay+D-RD-xSZg',
22 'only_matching': True,
25 def _real_extract(self
, url
):
26 uploader_id
, vod_id
= self
._match
_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'] # noqa: UP031
40 title
= broadcast
['title']
41 formats
= self
._extract
_m
3u8_formats
(
42 broadcast
['playbackUrl'], vod_id
, 'mp4', 'm3u8_native')
46 'uploader_id': uploader_id
,
48 'description': broadcast
.get('content'),
49 'thumbnail': broadcast
.get('thumbnailUrl'),
50 'timestamp': int_or_none(broadcast
.get('createdAt'), 1000),
51 'view_count': int_or_none(broadcast
.get('viewCount')),
55 class DLiveStreamIE(InfoExtractor
):
56 IE_NAME
= 'dlive:stream'
57 _VALID_URL
= r
'https?://(?:www\.)?dlive\.tv/(?!p/)(?P<id>[\w.-]+)'
59 def _real_extract(self
, url
):
60 display_name
= self
._match
_id
(url
)
61 user
= self
._download
_json
(
62 'https://graphigo.prd.dlive.tv/', display_name
,
63 data
=json
.dumps({'query': '''query {
64 userByDisplayName(displayname:"%s") {
74 }''' % display_name
}).encode())['data']['userByDisplayName'] # noqa: UP031
75 livestream
= user
['livestream']
76 title
= livestream
['title']
77 username
= user
['username']
78 formats
= self
._extract
_m
3u8_formats
(
79 f
'https://live.prd.dlive.tv/hls/live/{username}.m3u8',
84 'uploader': display_name
,
85 'uploader_id': username
,
87 'description': livestream
.get('content'),
88 'thumbnail': livestream
.get('thumbnailUrl'),
90 'timestamp': int_or_none(livestream
.get('createdAt'), 1000),
91 'view_count': int_or_none(livestream
.get('watchingCount')),