mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-18 01:07:50 +01:00
parent
5118d2ec58
commit
0cbed930c8
@ -17,6 +17,11 @@ class TrovoBaseIE(InfoExtractor):
|
||||
_VALID_URL_BASE = r'https?://(?:www\.)?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):
|
||||
streamer_info = data.get('streamerInfo') or {}
|
||||
username = streamer_info.get('userName')
|
||||
@ -32,8 +37,7 @@ class TrovoIE(TrovoBaseIE):
|
||||
|
||||
def _real_extract(self, url):
|
||||
username = self._match_id(url)
|
||||
live_info = self._download_json(
|
||||
'https://gql.trovo.live/', username, query={
|
||||
live_info = self._call_api(username, query={
|
||||
'query': '''{
|
||||
getLiveInfo(params: {userName: "%s"}) {
|
||||
isLive
|
||||
@ -111,8 +115,7 @@ class TrovoVodIE(TrovoBaseIE):
|
||||
|
||||
def _real_extract(self, url):
|
||||
vid = self._match_id(url)
|
||||
resp = self._download_json(
|
||||
'https://gql.trovo.live/', vid, data=json.dumps([{
|
||||
resp = self._call_api(vid, data=json.dumps([{
|
||||
'query': '''{
|
||||
batchGetVodDetailInfo(params: {vids: ["%s"]}) {
|
||||
VodDetailInfos
|
||||
@ -133,9 +136,7 @@ def _real_extract(self, url):
|
||||
}
|
||||
}
|
||||
}''' % vid,
|
||||
}]).encode(), headers={
|
||||
'Content-Type': 'application/json',
|
||||
})
|
||||
}]).encode())
|
||||
vod_detail_info = resp[0]['data']['batchGetVodDetailInfo']['VodDetailInfos'][vid]
|
||||
vod_info = vod_detail_info['vodInfo']
|
||||
title = vod_info['title']
|
||||
@ -215,7 +216,7 @@ def _entries(self, uid):
|
||||
|
||||
def _real_extract(self, 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
|
||||
})['data']['getLiveInfo']['streamerInfo']['uid'])
|
||||
return self.playlist_result(self._entries(uid), playlist_id=uid)
|
||||
@ -237,7 +238,7 @@ class TrovoChannelVodIE(TrovoChannelBaseIE):
|
||||
_TYPE = 'video'
|
||||
|
||||
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)
|
||||
})['data']['getChannelLtvVideoInfos']
|
||||
|
||||
@ -258,6 +259,6 @@ class TrovoChannelClipIE(TrovoChannelBaseIE):
|
||||
_TYPE = 'clip'
|
||||
|
||||
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)
|
||||
})['data']['getChannelClipVideoInfos']
|
||||
|
Loading…
Reference in New Issue
Block a user