mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-06 13:07:07 +01:00
[youtube_live_chat] Improve extraction
:ci skip dl
This commit is contained in:
parent
885d36d4e4
commit
4d608b522f
@ -50,7 +50,16 @@ def download_and_parse_fragment(url, frag_index):
|
|||||||
success, raw_fragment = dl_fragment(url)
|
success, raw_fragment = dl_fragment(url)
|
||||||
if not success:
|
if not success:
|
||||||
return False, None, None
|
return False, None, None
|
||||||
data = parse_yt_initial_data(raw_fragment) or json.loads(raw_fragment)['response']
|
data = parse_yt_initial_data(raw_fragment)
|
||||||
|
if not data:
|
||||||
|
raw_data = json.loads(raw_fragment)
|
||||||
|
# sometimes youtube replies with a list
|
||||||
|
if not isinstance(raw_data, list):
|
||||||
|
raw_data = [raw_data]
|
||||||
|
try:
|
||||||
|
data = next(item['response'] for item in raw_data if 'response' in item)
|
||||||
|
except StopIteration:
|
||||||
|
data = {}
|
||||||
|
|
||||||
live_chat_continuation = try_get(
|
live_chat_continuation = try_get(
|
||||||
data,
|
data,
|
||||||
|
Loading…
Reference in New Issue
Block a user