]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/dlive.py
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>[^/?#&]+)'
14 'url': 'https://dlive.tv/p/pdp+3mTzOl4WR',
18 'title': 'Minecraft with james charles epic',
19 'upload_date': '20190701',
20 'timestamp': 1562011015,
24 'url': 'https://dlive.tv/p/pdpreplay+D-RD-xSZg',
25 'only_matching': True,
28 def _real_extract(self
, url
):
29 uploader_id
, vod_id
= re
.match(self
._VALID
_URL
, url
).groups()
30 broadcast
= self
._download
_json
(
31 'https://graphigo.prd.dlive.tv/', vod_id
,
32 data
=json
.dumps({'query': '''query {
33 pastBroadcast(permlink:"%s+%s") {
42 }''' % (uploader_id
, vod_id
)}).encode())['data']['pastBroadcast']
43 title
= broadcast
['title']
44 formats
= self
._extract
_m
3u8_formats
(
45 broadcast
['playbackUrl'], vod_id
, 'mp4', 'm3u8_native')
46 self
._sort
_formats
(formats
)
50 'uploader_id': uploader_id
,
52 'description': broadcast
.get('content'),
53 'thumbnail': broadcast
.get('thumbnailUrl'),
54 'timestamp': int_or_none(broadcast
.get('createdAt'), 1000),
55 'view_count': int_or_none(broadcast
.get('viewCount')),
59 class DLiveStreamIE(InfoExtractor
):
60 IE_NAME
= 'dlive:stream'
61 _VALID_URL
= r
'https?://(?:www\.)?dlive\.tv/(?!p/)(?P<id>[\w.-]+)'
63 def _real_extract(self
, url
):
64 display_name
= self
._match
_id
(url
)
65 user
= self
._download
_json
(
66 'https://graphigo.prd.dlive.tv/', display_name
,
67 data
=json
.dumps({'query': '''query {
68 userByDisplayName(displayname:"%s") {
78 }''' % display_name
}).encode())['data']['userByDisplayName']
79 livestream
= user
['livestream']
80 title
= livestream
['title']
81 username
= user
['username']
82 formats
= self
._extract
_m
3u8_formats
(
83 'https://live.prd.dlive.tv/hls/live/%s.m3u8' % username
,
85 self
._sort
_formats
(formats
)
88 'title': self
._live
_title
(title
),
89 'uploader': display_name
,
90 'uploader_id': username
,
92 'description': livestream
.get('content'),
93 'thumbnail': livestream
.get('thumbnailUrl'),
95 'timestamp': int_or_none(livestream
.get('createdAt'), 1000),
96 'view_count': int_or_none(livestream
.get('watchingCount')),