mirror of https://github.com/yt-dlp/yt-dlp.git
parent
5118d2ec58
commit
0cbed930c8
|
@ -17,6 +17,11 @@ class TrovoBaseIE(InfoExtractor):
|
||||||
_VALID_URL_BASE = r'https?://(?:www\.)?trovo\.live/'
|
_VALID_URL_BASE = r'https?://(?:www\.)?trovo\.live/'
|
||||||
_HEADERS = {'Origin': 'https://trovo.live'}
|
_HEADERS = {'Origin': 'https://trovo.live'}
|
||||||
|
|
||||||
|
def _call_api(self, video_id, query=None, data=None):
|
||||||
|
return self._download_json(
|
||||||
|
'https://gql.trovo.live/', video_id, query=query, data=data,
|
||||||
|
headers={'Accept': 'application/json'})
|
||||||
|
|
||||||
def _extract_streamer_info(self, data):
|
def _extract_streamer_info(self, data):
|
||||||
streamer_info = data.get('streamerInfo') or {}
|
streamer_info = data.get('streamerInfo') or {}
|
||||||
username = streamer_info.get('userName')
|
username = streamer_info.get('userName')
|
||||||
|
@ -32,9 +37,8 @@ class TrovoIE(TrovoBaseIE):
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
username = self._match_id(url)
|
username = self._match_id(url)
|
||||||
live_info = self._download_json(
|
live_info = self._call_api(username, query={
|
||||||
'https://gql.trovo.live/', username, query={
|
'query': '''{
|
||||||
'query': '''{
|
|
||||||
getLiveInfo(params: {userName: "%s"}) {
|
getLiveInfo(params: {userName: "%s"}) {
|
||||||
isLive
|
isLive
|
||||||
programInfo {
|
programInfo {
|
||||||
|
@ -53,7 +57,7 @@ class TrovoIE(TrovoBaseIE):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}''' % username,
|
}''' % username,
|
||||||
})['data']['getLiveInfo']
|
})['data']['getLiveInfo']
|
||||||
if live_info.get('isLive') == 0:
|
if live_info.get('isLive') == 0:
|
||||||
raise ExtractorError('%s is offline' % username, expected=True)
|
raise ExtractorError('%s is offline' % username, expected=True)
|
||||||
program_info = live_info['programInfo']
|
program_info = live_info['programInfo']
|
||||||
|
@ -111,15 +115,14 @@ class TrovoVodIE(TrovoBaseIE):
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
vid = self._match_id(url)
|
vid = self._match_id(url)
|
||||||
resp = self._download_json(
|
resp = self._call_api(vid, data=json.dumps([{
|
||||||
'https://gql.trovo.live/', vid, data=json.dumps([{
|
'query': '''{
|
||||||
'query': '''{
|
|
||||||
batchGetVodDetailInfo(params: {vids: ["%s"]}) {
|
batchGetVodDetailInfo(params: {vids: ["%s"]}) {
|
||||||
VodDetailInfos
|
VodDetailInfos
|
||||||
}
|
}
|
||||||
}''' % vid,
|
}''' % vid,
|
||||||
}, {
|
}, {
|
||||||
'query': '''{
|
'query': '''{
|
||||||
getCommentList(params: {appInfo: {postID: "%s"}, pageSize: 1000000000, preview: {}}) {
|
getCommentList(params: {appInfo: {postID: "%s"}, pageSize: 1000000000, preview: {}}) {
|
||||||
commentList {
|
commentList {
|
||||||
author {
|
author {
|
||||||
|
@ -133,9 +136,7 @@ class TrovoVodIE(TrovoBaseIE):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}''' % vid,
|
}''' % vid,
|
||||||
}]).encode(), headers={
|
}]).encode())
|
||||||
'Content-Type': 'application/json',
|
|
||||||
})
|
|
||||||
vod_detail_info = resp[0]['data']['batchGetVodDetailInfo']['VodDetailInfos'][vid]
|
vod_detail_info = resp[0]['data']['batchGetVodDetailInfo']['VodDetailInfos'][vid]
|
||||||
vod_info = vod_detail_info['vodInfo']
|
vod_info = vod_detail_info['vodInfo']
|
||||||
title = vod_info['title']
|
title = vod_info['title']
|
||||||
|
@ -215,7 +216,7 @@ class TrovoChannelBaseIE(InfoExtractor):
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
id = self._match_id(url)
|
id = self._match_id(url)
|
||||||
uid = str(self._download_json('https://gql.trovo.live/', id, query={
|
uid = str(self._call_api(id, query={
|
||||||
'query': '{getLiveInfo(params:{userName:"%s"}){streamerInfo{uid}}}' % id
|
'query': '{getLiveInfo(params:{userName:"%s"}){streamerInfo{uid}}}' % id
|
||||||
})['data']['getLiveInfo']['streamerInfo']['uid'])
|
})['data']['getLiveInfo']['streamerInfo']['uid'])
|
||||||
return self.playlist_result(self._entries(uid), playlist_id=uid)
|
return self.playlist_result(self._entries(uid), playlist_id=uid)
|
||||||
|
@ -237,7 +238,7 @@ class TrovoChannelVodIE(TrovoChannelBaseIE):
|
||||||
_TYPE = 'video'
|
_TYPE = 'video'
|
||||||
|
|
||||||
def _get_vod_json(self, page, uid):
|
def _get_vod_json(self, page, uid):
|
||||||
return self._download_json('https://gql.trovo.live/', uid, query={
|
return self._call_api(uid, query={
|
||||||
'query': self._QUERY % (page, uid)
|
'query': self._QUERY % (page, uid)
|
||||||
})['data']['getChannelLtvVideoInfos']
|
})['data']['getChannelLtvVideoInfos']
|
||||||
|
|
||||||
|
@ -258,6 +259,6 @@ class TrovoChannelClipIE(TrovoChannelBaseIE):
|
||||||
_TYPE = 'clip'
|
_TYPE = 'clip'
|
||||||
|
|
||||||
def _get_vod_json(self, page, uid):
|
def _get_vod_json(self, page, uid):
|
||||||
return self._download_json('https://gql.trovo.live/', uid, query={
|
return self._call_api(uid, query={
|
||||||
'query': self._QUERY % (page, uid)
|
'query': self._QUERY % (page, uid)
|
||||||
})['data']['getChannelClipVideoInfos']
|
})['data']['getChannelClipVideoInfos']
|
||||||
|
|
Loading…
Reference in New Issue