mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-10 01:02:13 +01:00
[ie/tiktok] Extract via mobile API only if app_info
is passed (#9938)
Partially addresses #9506 Authored by: bashonly
This commit is contained in:
parent
351dc0bc33
commit
41ba4a808b
2 changed files with 15 additions and 17 deletions
|
@ -1813,8 +1813,8 @@ #### tiktok
|
||||||
* `app_name`: Default app name to use with mobile API calls, e.g. `trill`
|
* `app_name`: Default app name to use with mobile API calls, e.g. `trill`
|
||||||
* `app_version`: Default app version to use with mobile API calls - should be set along with `manifest_app_version`, e.g. `34.1.2`
|
* `app_version`: Default app version to use with mobile API calls - should be set along with `manifest_app_version`, e.g. `34.1.2`
|
||||||
* `manifest_app_version`: Default numeric app version to use with mobile API calls, e.g. `2023401020`
|
* `manifest_app_version`: Default numeric app version to use with mobile API calls, e.g. `2023401020`
|
||||||
* `aid`: Default app ID to use with API calls, e.g. `1180`
|
* `aid`: Default app ID to use with mobile API calls, e.g. `1180`
|
||||||
* `app_info`: One or more app info strings in the format of `<iid>/[app_name]/[app_version]/[manifest_app_version]/[aid]`, where `iid` is the unique app install ID. `iid` is the only required value; all other values and their `/` separators can be omitted, e.g. `tiktok:app_info=1234567890123456789` or `tiktok:app_info=123,456/trill///1180,789//34.0.1/340001`
|
* `app_info`: Enable mobile API extraction with one or more app info strings in the format of `<iid>/[app_name]/[app_version]/[manifest_app_version]/[aid]`, where `iid` is the unique app install ID. `iid` is the only required value; all other values and their `/` separators can be omitted, e.g. `tiktok:app_info=1234567890123456789` or `tiktok:app_info=123,456/trill///1180,789//34.0.1/340001`
|
||||||
|
|
||||||
#### rokfinchannel
|
#### rokfinchannel
|
||||||
* `tab`: Which tab to download - one of `new`, `top`, `videos`, `podcasts`, `streams`, `stacks`
|
* `tab`: Which tab to download - one of `new`, `top`, `videos`, `podcasts`, `streams`, `stacks`
|
||||||
|
|
|
@ -45,19 +45,18 @@ class TikTokBaseIE(InfoExtractor):
|
||||||
# "app id": aweme = 1128, trill = 1180, musical_ly = 1233, universal = 0
|
# "app id": aweme = 1128, trill = 1180, musical_ly = 1233, universal = 0
|
||||||
'aid': '0',
|
'aid': '0',
|
||||||
}
|
}
|
||||||
_KNOWN_APP_INFO = [
|
|
||||||
'7351144126450059040',
|
|
||||||
'7351149742343391009',
|
|
||||||
'7351153174894626592',
|
|
||||||
]
|
|
||||||
_APP_INFO_POOL = None
|
_APP_INFO_POOL = None
|
||||||
_APP_INFO = None
|
_APP_INFO = None
|
||||||
_APP_USER_AGENT = None
|
_APP_USER_AGENT = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _KNOWN_APP_INFO(self):
|
||||||
|
return self._configuration_arg('app_info', ie_key=TikTokIE)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _API_HOSTNAME(self):
|
def _API_HOSTNAME(self):
|
||||||
return self._configuration_arg(
|
return self._configuration_arg(
|
||||||
'api_hostname', ['api22-normal-c-useast2a.tiktokv.com'], ie_key=TikTokIE)[0]
|
'api_hostname', ['api16-normal-c-useast1a.tiktokv.com'], ie_key=TikTokIE)[0]
|
||||||
|
|
||||||
def _get_next_app_info(self):
|
def _get_next_app_info(self):
|
||||||
if self._APP_INFO_POOL is None:
|
if self._APP_INFO_POOL is None:
|
||||||
|
@ -66,13 +65,10 @@ def _get_next_app_info(self):
|
||||||
for key, default in self._APP_INFO_DEFAULTS.items()
|
for key, default in self._APP_INFO_DEFAULTS.items()
|
||||||
if key != 'iid'
|
if key != 'iid'
|
||||||
}
|
}
|
||||||
app_info_list = (
|
|
||||||
self._configuration_arg('app_info', ie_key=TikTokIE)
|
|
||||||
or random.sample(self._KNOWN_APP_INFO, len(self._KNOWN_APP_INFO)))
|
|
||||||
self._APP_INFO_POOL = [
|
self._APP_INFO_POOL = [
|
||||||
{**defaults, **dict(
|
{**defaults, **dict(
|
||||||
(k, v) for k, v in zip(self._APP_INFO_DEFAULTS, app_info.split('/')) if v
|
(k, v) for k, v in zip(self._APP_INFO_DEFAULTS, app_info.split('/')) if v
|
||||||
)} for app_info in app_info_list
|
)} for app_info in self._KNOWN_APP_INFO
|
||||||
]
|
]
|
||||||
|
|
||||||
if not self._APP_INFO_POOL:
|
if not self._APP_INFO_POOL:
|
||||||
|
@ -757,11 +753,13 @@ class TikTokIE(TikTokBaseIE):
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id, user_id = self._match_valid_url(url).group('id', 'user_id')
|
video_id, user_id = self._match_valid_url(url).group('id', 'user_id')
|
||||||
try:
|
|
||||||
return self._extract_aweme_app(video_id)
|
if self._KNOWN_APP_INFO:
|
||||||
except ExtractorError as e:
|
try:
|
||||||
e.expected = True
|
return self._extract_aweme_app(video_id)
|
||||||
self.report_warning(f'{e}; trying with webpage')
|
except ExtractorError as e:
|
||||||
|
e.expected = True
|
||||||
|
self.report_warning(f'{e}; trying with webpage')
|
||||||
|
|
||||||
url = self._create_url(user_id, video_id)
|
url = self._create_url(user_id, video_id)
|
||||||
webpage = self._download_webpage(url, video_id, headers={'User-Agent': 'Mozilla/5.0'})
|
webpage = self._download_webpage(url, video_id, headers={'User-Agent': 'Mozilla/5.0'})
|
||||||
|
|
Loading…
Reference in a new issue