mirror of
https://git.sr.ht/~cadence/NewLeaf
synced 2026-03-05 12:01:38 +00:00
Fix manifest
This commit is contained in:
parent
e95d814709
commit
20b133dbb6
2 changed files with 44 additions and 33 deletions
|
|
@ -2,6 +2,7 @@ import re
|
|||
import json
|
||||
|
||||
r_yt_initial_data = re.compile(r"""(?:^\s*window\["ytInitialData"\]|var ytInitialData) = (\{.+?\});(?:\s*$|</script>)""", re.S + re.M)
|
||||
r_yt_initial_player_response = re.compile(r"""(?:^\s*window\["ytInitialPlayerResponse"\]|var ytInitialPlayerResponse) = (\{.+?\});(?:\s*$|</script>|var )""", re.S + re.M)
|
||||
|
||||
def extract_yt_initial_data(content):
|
||||
m_yt_initial_data = re.search(r_yt_initial_data, content)
|
||||
|
|
@ -10,3 +11,11 @@ def extract_yt_initial_data(content):
|
|||
return yt_initial_data
|
||||
else:
|
||||
raise Exception("Could not match ytInitialData in content")
|
||||
|
||||
def extract_yt_initial_player_response(content):
|
||||
m_yt_initial_player_response = re.search(r_yt_initial_player_response, content)
|
||||
if m_yt_initial_player_response:
|
||||
yt_initial_player_response = json.loads(m_yt_initial_player_response.group(1))
|
||||
return yt_initial_player_response
|
||||
else:
|
||||
raise Exception("Could not match ytInitialPlayerResponse in content")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue