]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/ichinanalive.py
1 from .common
import InfoExtractor
2 from ..utils
import ExtractorError
, str_or_none
, traverse_obj
, unified_strdate
5 class IchinanaLiveIE(InfoExtractor
):
7 _VALID_URL
= r
'https?://(?:www\.)?17\.live/(?:[^/]+/)*(?:live|profile/r)/(?P<id>\d+)'
9 'url': 'https://17.live/live/3773096',
14 'uploader': '萠珈☕🤡🍫moka',
15 'uploader_id': '3773096',
18 'timestamp': 1630569012,
20 'skip': 'running as of writing, but may be ended as of testing',
22 'note': 'nothing except language differs',
23 'url': 'https://17.live/ja/live/3773096',
24 'only_matching': True,
28 def suitable(cls
, url
):
29 return not IchinanaLiveClipIE
.suitable(url
) and super().suitable(url
)
31 def _real_extract(self
, url
):
32 video_id
= self
._match
_id
(url
)
33 url
= f
'https://17.live/live/{video_id}'
35 enter
= self
._download
_json
(
36 f
'https://api-dsa.17app.co/api/v1/lives/{video_id}/enter', video_id
,
37 headers
={'Referer': url}
, fatal
=False, expected_status
=420,
39 if enter
and enter
.get('message') == 'ended':
40 raise ExtractorError('This live has ended.', expected
=True)
42 view_data
= self
._download
_json
(
43 f
'https://api-dsa.17app.co/api/v1/lives/{video_id}', video_id
,
44 headers
={'Referer': url}
)
46 uploader
= traverse_obj(
47 view_data
, ('userInfo', 'displayName'), ('userInfo', 'openID'))
49 video_urls
= view_data
.get('rtmpUrls')
51 raise ExtractorError('unable to extract live URL information')
53 for (name
, value
) in video_urls
[0].items():
54 if not isinstance(value
, str):
56 if not value
.startswith('http'):
69 'http_headers': {'Referer': url}
,
77 'title': uploader
or video_id
,
81 'uploader_id': video_id
,
82 'like_count': view_data
.get('receivedLikeCount'),
83 'view_count': view_data
.get('viewerCount'),
84 'thumbnail': view_data
.get('coverPhoto'),
85 'description': view_data
.get('caption'),
86 'timestamp': view_data
.get('beginTime'),
90 class IchinanaLiveClipIE(InfoExtractor
):
91 IE_NAME
= '17live:clip'
92 _VALID_URL
= r
'https?://(?:www\.)?17\.live/(?:[^/]+/)*profile/r/(?P<uploader_id>\d+)/clip/(?P<id>[^/]+)'
94 'url': 'https://17.live/profile/r/1789280/clip/1bHQSK8KUieruFXaCH4A4upCzlN',
96 'id': '1bHQSK8KUieruFXaCH4A4upCzlN',
97 'title': 'マチコ先生🦋Class💋',
98 'description': 'マチ戦隊 第一次 バスターコール\n総額200万coin!\n動画制作@うぉーかー🌱Walker🎫',
99 'uploader_id': '1789280',
102 'url': 'https://17.live/ja/profile/r/1789280/clip/1bHQSK8KUieruFXaCH4A4upCzlN',
103 'only_matching': True,
106 def _real_extract(self
, url
):
107 uploader_id
, video_id
= self
._match
_valid
_url
(url
).groups()
108 url
= f
'https://17.live/profile/r/{uploader_id}/clip/{video_id}'
110 view_data
= self
._download
_json
(
111 f
'https://api-dsa.17app.co/api/v1/clips/{video_id}', video_id
,
112 headers
={'Referer': url}
)
114 uploader
= traverse_obj(
115 view_data
, ('userInfo', 'displayName'), ('userInfo', 'name'))
118 if view_data
.get('videoURL'):
121 'url': view_data
['videoURL'],
124 if view_data
.get('transcodeURL'):
127 'url': view_data
['transcodeURL'],
130 if view_data
.get('srcVideoURL'):
134 'url': view_data
['srcVideoURL'],
144 'http_headers': {'Referer': url}
,
149 'title': uploader
or video_id
,
151 'uploader': uploader
,
152 'uploader_id': uploader_id
,
153 'like_count': view_data
.get('likeCount'),
154 'view_count': view_data
.get('viewCount'),
155 'thumbnail': view_data
.get('imageURL'),
156 'duration': view_data
.get('duration'),
157 'description': view_data
.get('caption'),
158 'upload_date': unified_strdate(str_or_none(view_data
.get('createdAt'))),