mirror of
https://git.sr.ht/~cadence/NewLeaf
synced 2026-05-04 16:41:37 +00:00
Refactor everything to separate files
This commit is contained in:
parent
a271db0632
commit
40759efb03
8 changed files with 742 additions and 629 deletions
12
tools/extractors.py
Normal file
12
tools/extractors.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import re
|
||||
import json
|
||||
|
||||
r_yt_initial_data = re.compile(r"""^\s*window\["ytInitialData"\] = (\{.*\});\n?$""", re.M)
|
||||
|
||||
def extract_yt_initial_data(content):
|
||||
m_yt_initial_data = re.search(r_yt_initial_data, content)
|
||||
if m_yt_initial_data:
|
||||
yt_initial_data = json.loads(m_yt_initial_data.group(1))
|
||||
return yt_initial_data
|
||||
else:
|
||||
raise Exception("Could not match ytInitialData in content")
|
||||
Loading…
Add table
Add a link
Reference in a new issue