[youtube] Add `player_client=all`

pull/557/head
pukkandan 3 years ago
parent ea05b3020d
commit b4c055bac2
No known key found for this signature in database
GPG Key ID: 0F00D95A001F4698

@ -1354,7 +1354,7 @@ Some extractors accept additional arguments which can be passed using `--extract
The following extractors use this feature: The following extractors use this feature:
* **youtube** * **youtube**
* `skip`: `hls` or `dash` (or both) to skip download of the respective manifests * `skip`: `hls` or `dash` (or both) to skip download of the respective manifests
* `player_client`: Clients to extract video data from - one or more of `web`, `android`, `ios`, `web_music`, `android_music`, `ios_music`. By default, `android,web` is used. If the URL is from `music.youtube.com`, `android,web,android_music,web_music` is used * `player_client`: Clients to extract video data from - one or more of `web`, `android`, `ios`, `web_music`, `android_music`, `ios_music` or `all`. By default, `android,web` is used. If the URL is from `music.youtube.com`, `android,web,android_music,web_music` is used
* `player_skip`: `configs` - skip any requests for client configs and use defaults * `player_skip`: `configs` - skip any requests for client configs and use defaults
* `comment_sort`: `top` or `new` (default) - choose comment sorting mode (on YouTube's side). * `comment_sort`: `top` or `new` (default) - choose comment sorting mode (on YouTube's side).
* `max_comments`: maximum amount of comments to download (default all). * `max_comments`: maximum amount of comments to download (default all).

@ -451,10 +451,6 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
# clients starting with _ cannot be explicity requested by the user # clients starting with _ cannot be explicity requested by the user
_YT_CLIENTS = { _YT_CLIENTS = {
'web': 'WEB',
'web_music': 'WEB_REMIX',
'_web_embedded': 'WEB_EMBEDDED_PLAYER',
'_web_agegate': 'TVHTML5',
'android': 'ANDROID', 'android': 'ANDROID',
'android_music': 'ANDROID_MUSIC', 'android_music': 'ANDROID_MUSIC',
'_android_embedded': 'ANDROID_EMBEDDED_PLAYER', '_android_embedded': 'ANDROID_EMBEDDED_PLAYER',
@ -462,7 +458,11 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
'ios': 'IOS', 'ios': 'IOS',
'ios_music': 'IOS_MUSIC', 'ios_music': 'IOS_MUSIC',
'_ios_embedded': 'IOS_MESSAGES_EXTENSION', '_ios_embedded': 'IOS_MESSAGES_EXTENSION',
'_ios_agegate': 'IOS' '_ios_agegate': 'IOS',
'web': 'WEB',
'web_music': 'WEB_REMIX',
'_web_embedded': 'WEB_EMBEDDED_PLAYER',
'_web_agegate': 'TVHTML5',
} }
def _get_default_ytcfg(self, client='WEB'): def _get_default_ytcfg(self, client='WEB'):
@ -2430,8 +2430,15 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
identity_token, player_url, initial_pr) identity_token, player_url, initial_pr)
def _get_requested_clients(self, url, smuggled_data): def _get_requested_clients(self, url, smuggled_data):
requested_clients = [client for client in self._configuration_arg('player_client') requested_clients = []
if client[:0] != '_' and client in self._YT_CLIENTS] allowed_clients = [client for client in self._YT_CLIENTS.keys() if client[:1] != '_']
for client in self._configuration_arg('player_client'):
if client in allowed_clients:
requested_clients.append(client)
elif client == 'all':
requested_clients.extend(allowed_clients)
else:
self.report_warning(f'Skipping unsupported client {client}')
if not requested_clients: if not requested_clients:
requested_clients = ['android', 'web'] requested_clients = ['android', 'web']

Loading…
Cancel
Save