Created
July 22, 2024 03:18
-
-
Save tamanobi/248074cf1cf3ba357306cf06cafda141 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import json | |
url = 'URL_YOU_WANTED_TO_ADD_NOTEBOOK_LM' | |
notebook_id = 'YOUR_NOTEBOOK_ID' | |
at = "YOUR_AT" | |
cookie_str = """ | |
YOUR_COOKIE | |
""".strip() | |
data = [[[None, None, [url]]], notebook_id] | |
data_str = json.dumps(data) | |
data_raw = [[[ | |
'izAoDd', | |
data_str, | |
None, | |
'generic' | |
]]] | |
data_raw_str = json.dumps(data_raw) | |
# curlコマンドを構築する | |
command = [ | |
'curl', | |
'https://notebooklm.google.com/_/LabsTailwindUi/data/batchexecute?rpcids=izAoDd&bl=boq_labs-tailwind-frontend_20240716.13_p0&f.sid=-1230583627458655420&hl=ja&_reqid=942336&rt=c', | |
'-H', 'accept: */*', | |
'-H', 'accept-language: ja,en-US;q=0.9,en;q=0.8', | |
'-H', 'cache-control: no-cache', | |
'-H', 'content-type: application/x-www-form-urlencoded;charset=UTF-8', | |
'-H', f'cookie: {cookie_str}', | |
'-H', 'origin: https://notebooklm.google.com', | |
'-H', 'pragma: no-cache', | |
'-H', 'priority: u=1, i', | |
'-H', 'referer: https://notebooklm.google.com/', | |
'-H', 'sec-ch-ua: "Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"', | |
'-H', 'sec-ch-ua-arch: "x86"', | |
'-H', 'sec-ch-ua-bitness: "64"', | |
'-H', 'sec-ch-ua-form-factors: "Desktop"', | |
'-H', 'sec-ch-ua-full-version: "124.0.6478.128"', | |
'-H', 'sec-ch-ua-full-version-list: "Not/A)Brand";v="8.0.0.0", "Chromium";v="124.0.6478.128", "Google Chrome";v="124.0.6478.128"', | |
'-H', 'sec-ch-ua-mobile: ?0', | |
'-H', 'sec-ch-ua-model: ""', | |
'-H', 'sec-ch-ua-platform: "Windows"', | |
'-H', 'sec-ch-ua-platform-version: "15.0.0"', | |
'-H', 'sec-ch-ua-wow64: ?0', | |
'-H', 'sec-fetch-dest: empty', | |
'-H', 'sec-fetch-mode: cors', | |
'-H', 'sec-fetch-site: same-origin', | |
'-H', 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36', | |
'-H', 'x-same-domain: 1', | |
'--data-raw', f'f.req={data_raw_str}&at={at}&' | |
] | |
# サブプロセスを実行する | |
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
# 出力とエラーを取得する | |
output, error = process.communicate() | |
# 出力をデコードする | |
output = output.decode('utf-8') | |
# 結果を表示する | |
print(output) | |
# エラーが発生した場合は表示する | |
if error: | |
print(error.decode('utf-8')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment