From 5f7a8cd7ba47bc38da8ac7a1e6a7c0550528084a Mon Sep 17 00:00:00 2001 From: Nat1an Date: Tue, 27 Aug 2024 21:49:10 +0800 Subject: [PATCH] chore(poToken_generator.py, README.md): update script to use docker for YouTube trusted session generation (#173) * chore(poToken_generator.py, README.md): update script to use docker for YouTube trusted session generation * chore(README.md): remove instruction for skipping Spotify setup --- README.md | 4 +--- poToken_generator.py | 31 ------------------------------- 2 files changed, 1 insertion(+), 34 deletions(-) delete mode 100644 poToken_generator.py diff --git a/README.md b/README.md index 103b10e..dc8e128 100644 --- a/README.md +++ b/README.md @@ -149,8 +149,6 @@ docker run -it \ -> 如果你有需要跳過 Spotify 自動設定 (`Go to the following url: ...`),你可以將 `SKIP_SPOTIFY_SETUP` 設定為 `1` -

(回到頂部)

@@ -172,7 +170,7 @@ docker run -it \ > 由於 YouTube 的種種限制,必須填入一些驗證資訊才能使音樂服務正常工作,具體方式請詳閱下方教學。 首先,請先使用 `pip install -r requirements.txt` 安裝所有必要的套件 -安裝完後進入到Lava的資料夾運行 `python poToken_generator.py` +安裝完後進入到 Lava 的資料夾運行 `docker run quay.io/invidious/youtube-trusted-session-generator` 運行後你會看到終端輸出以下內容: ``` diff --git a/poToken_generator.py b/poToken_generator.py deleted file mode 100644 index d266eff..0000000 --- a/poToken_generator.py +++ /dev/null @@ -1,31 +0,0 @@ -from nodriver import start, cdp, loop -import json -import sys - - -async def main(): # pylint: disable=W0613 - browser = await start(headless=False) - print("[INFO] launching browser.") - tab = browser.main_tab - tab.add_handler(cdp.network.RequestWillBeSent, send_handler) - await browser.get('https://www.youtube.com/embed/jNQXAC9IVRw') - await tab.wait(cdp.network.RequestWillBeSent) - button_play = await tab.select("#movie_player") - await button_play.click() - await tab.wait(cdp.network.RequestWillBeSent) - print("[INFO] waiting additional 30 seconds for slower connections.") - await tab.sleep(30) - - -async def send_handler(event: cdp.network.RequestWillBeSent): # pylint: disable=W0613 - if "/youtubei/v1/player" in event.request.url: - post_data = event.request.post_data - post_data_json = json.loads(post_data) - print("visitor_data: " + post_data_json["context"]["client"]["visitorData"]) - print("po_token: " + post_data_json["serviceIntegrityDimensions"]["poToken"]) - sys.exit(0) - return - - -if __name__ == '__main__': - loop().run_until_complete(main())