]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/dlive.py
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
6 from ..utils
import int_or_none
9 class DLiveVODIE(InfoExtractor
):
11 _VALID_URL
= r
'https?://(?:www\.)?dlive\.tv/p/(?P<uploader_id>.+?)\+(?P<id>[^/?#&]+)'
13 'url': 'https://dlive.tv/p/pdp+3mTzOl4WR',
17 'title': 'Minecraft with james charles epic',
18 'upload_date': '20190701',
19 'timestamp': 1562011015,
23 'url': 'https://dlive.tv/p/pdpreplay+D-RD-xSZg',
24 'only_matching': True,
27 def _real_extract(self
, url
):
28 uploader_id
, vod_id
= self
._match
_valid
_url
(url
).groups()
29 broadcast
= self
._download
_json
(
30 'https://graphigo.prd.dlive.tv/', vod_id
,
31 data
=json
.dumps({'query': '''query {
32 pastBroadcast(permlink:"%s+%s") {
41 }''' % (uploader_id
, vod_id
)}).encode())['data']['pastBroadcast']
42 title
= broadcast
['title']
43 formats
= self
._extract
_m
3u8_formats
(
44 broadcast
['playbackUrl'], vod_id
, 'mp4', 'm3u8_native')
45 self
._sort
_formats
(formats
)
49 'uploader_id': uploader_id
,
51 'description': broadcast
.get('content'),
52 'thumbnail': broadcast
.get('thumbnailUrl'),
53 'timestamp': int_or_none(broadcast
.get('createdAt'), 1000),
54 'view_count': int_or_none(broadcast
.get('viewCount')),
58 class DLiveStreamIE(InfoExtractor
):
59 IE_NAME
= 'dlive:stream'
60 _VALID_URL
= r
'https?://(?:www\.)?dlive\.tv/(?!p/)(?P<id>[\w.-]+)'
62 def _real_extract(self
, url
):
63 display_name
= self
._match
_id
(url
)
64 user
= self
._download
_json
(
65 'https://graphigo.prd.dlive.tv/', display_name
,
66 data
=json
.dumps({'query': '''query {
67 userByDisplayName(displayname:"%s") {
77 }''' % display_name
}).encode())['data']['userByDisplayName']
78 livestream
= user
['livestream']
79 title
= livestream
['title']
80 username
= user
['username']
81 formats
= self
._extract
_m
3u8_formats
(
82 'https://live.prd.dlive.tv/hls/live/%s.m3u8' % username
,
84 self
._sort
_formats
(formats
)
87 'title': self
._live
_title
(title
),
88 'uploader': display_name
,
89 'uploader_id': username
,
91 'description': livestream
.get('content'),
92 'thumbnail': livestream
.get('thumbnailUrl'),
94 'timestamp': int_or_none(livestream
.get('createdAt'), 1000),
95 'view_count': int_or_none(livestream
.get('watchingCount')),