]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/dlive.py
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']
40 title
= broadcast
['title']
41 formats
= self
._extract
_m
3u8_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/)(?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
_m
3u8_formats
(
80 'https://live.prd.dlive.tv/hls/live/%s.m3u8' % username
,
82 self
._sort
_formats
(formats
)
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')),