mirror of
https://github.com/yt-dlp/yt-dlp
synced 2025-12-16 22:25:40 +07:00
Compare commits
2 Commits
2801650268
...
4433b3a217
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4433b3a217 | ||
|
|
419776ecf5 |
@@ -5,6 +5,7 @@
|
|||||||
from ..networking import Request
|
from ..networking import Request
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
|
UserNotLive,
|
||||||
js_to_json,
|
js_to_json,
|
||||||
traverse_obj,
|
traverse_obj,
|
||||||
update_url_query,
|
update_url_query,
|
||||||
@@ -205,6 +206,9 @@ def _real_extract(self, url):
|
|||||||
'client_app': 'browser_hls',
|
'client_app': 'browser_hls',
|
||||||
'ipv6': '',
|
'ipv6': '',
|
||||||
}), headers={'X-Requested-With': 'XMLHttpRequest'})
|
}), headers={'X-Requested-With': 'XMLHttpRequest'})
|
||||||
|
# A non-zero 'status' indicates the stream is not live, so check truthiness
|
||||||
|
if traverse_obj(control_server, ('status', {int})) and 'control_token' not in control_server:
|
||||||
|
raise UserNotLive(video_id=video_id)
|
||||||
self._set_cookie('live.fc2.com', 'l_ortkn', control_server['orz_raw'])
|
self._set_cookie('live.fc2.com', 'l_ortkn', control_server['orz_raw'])
|
||||||
|
|
||||||
ws_url = update_url_query(control_server['url'], {'control_token': control_server['control_token']})
|
ws_url = update_url_query(control_server['url'], {'control_token': control_server['control_token']})
|
||||||
|
|||||||
@@ -4029,6 +4029,11 @@ def process_language(container, base_url, lang_code, sub_name, client_name, quer
|
|||||||
STREAMING_DATA_CLIENT_NAME: client_name,
|
STREAMING_DATA_CLIENT_NAME: client_name,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def set_audio_lang_from_orig_subs_lang(lang_code):
|
||||||
|
for f in formats:
|
||||||
|
if f.get('acodec') != 'none' and not f.get('language'):
|
||||||
|
f['language'] = lang_code
|
||||||
|
|
||||||
subtitles = {}
|
subtitles = {}
|
||||||
skipped_subs_clients = set()
|
skipped_subs_clients = set()
|
||||||
|
|
||||||
@@ -4088,7 +4093,8 @@ def process_language(container, base_url, lang_code, sub_name, client_name, quer
|
|||||||
|
|
||||||
orig_lang = qs.get('lang', [None])[-1]
|
orig_lang = qs.get('lang', [None])[-1]
|
||||||
lang_name = self._get_text(caption_track, 'name', max_runs=1)
|
lang_name = self._get_text(caption_track, 'name', max_runs=1)
|
||||||
if caption_track.get('kind') != 'asr':
|
is_manual_subs = caption_track.get('kind') != 'asr'
|
||||||
|
if is_manual_subs:
|
||||||
if not lang_code:
|
if not lang_code:
|
||||||
continue
|
continue
|
||||||
process_language(
|
process_language(
|
||||||
@@ -4099,16 +4105,14 @@ def process_language(container, base_url, lang_code, sub_name, client_name, quer
|
|||||||
if not trans_code:
|
if not trans_code:
|
||||||
continue
|
continue
|
||||||
orig_trans_code = trans_code
|
orig_trans_code = trans_code
|
||||||
if caption_track.get('kind') != 'asr' and trans_code != 'und':
|
if is_manual_subs and trans_code != 'und':
|
||||||
if not get_translated_subs:
|
if not get_translated_subs:
|
||||||
continue
|
continue
|
||||||
trans_code += f'-{lang_code}'
|
trans_code += f'-{lang_code}'
|
||||||
trans_name += format_field(lang_name, None, ' from %s')
|
trans_name += format_field(lang_name, None, ' from %s')
|
||||||
if lang_code == f'a-{orig_trans_code}':
|
if lang_code == f'a-{orig_trans_code}':
|
||||||
# Set audio language based on original subtitles
|
# Set audio language based on original subtitles
|
||||||
for f in formats:
|
set_audio_lang_from_orig_subs_lang(orig_trans_code)
|
||||||
if f.get('acodec') != 'none' and not f.get('language'):
|
|
||||||
f['language'] = orig_trans_code
|
|
||||||
# Add an "-orig" label to the original language so that it can be distinguished.
|
# Add an "-orig" label to the original language so that it can be distinguished.
|
||||||
# The subs are returned without "-orig" as well for compatibility
|
# The subs are returned without "-orig" as well for compatibility
|
||||||
process_language(
|
process_language(
|
||||||
@@ -4119,6 +4123,21 @@ def process_language(container, base_url, lang_code, sub_name, client_name, quer
|
|||||||
automatic_captions, base_url, trans_code, trans_name, client_name,
|
automatic_captions, base_url, trans_code, trans_name, client_name,
|
||||||
pot_params if orig_lang == orig_trans_code else {'tlang': trans_code, **pot_params})
|
pot_params if orig_lang == orig_trans_code else {'tlang': trans_code, **pot_params})
|
||||||
|
|
||||||
|
# Extract automatic captions when the language is not in 'translationLanguages'
|
||||||
|
# e.g. Cantonese [yue], see https://github.com/yt-dlp/yt-dlp/issues/14889
|
||||||
|
lang_code = remove_start(lang_code, 'a-')
|
||||||
|
if is_manual_subs or not lang_code or lang_code in automatic_captions:
|
||||||
|
continue
|
||||||
|
lang_name = remove_end(lang_name, ' (auto-generated)')
|
||||||
|
if caption_track.get('isTranslatable'):
|
||||||
|
# We can assume this is the original audio language
|
||||||
|
set_audio_lang_from_orig_subs_lang(lang_code)
|
||||||
|
process_language(
|
||||||
|
automatic_captions, base_url, f'{lang_code}-orig',
|
||||||
|
f'{lang_name} (Original)', client_name, pot_params)
|
||||||
|
process_language(
|
||||||
|
automatic_captions, base_url, lang_code, lang_name, client_name, pot_params)
|
||||||
|
|
||||||
# Avoid duplication if we've already got everything we need
|
# Avoid duplication if we've already got everything we need
|
||||||
need_subs_langs.difference_update(subtitles)
|
need_subs_langs.difference_update(subtitles)
|
||||||
need_caps_langs.difference_update(automatic_captions)
|
need_caps_langs.difference_update(automatic_captions)
|
||||||
|
|||||||
Reference in New Issue
Block a user