[YouTube] 下載 mp3 遇到錯誤: HTTP Error 403: Forbidden. Retrying fragment

在使用 yt-dlp 下載 youtube 影片為 mp3 時出現錯訊息, 這時候即使把瀏覽器的 cookie 儲存為 .txt 檔餵給 yt-dlp 一樣顯示無法下載.

解法:
https://github.com/yt-dlp/yt-dlp/issues/15586#issuecomment-3758088372

See this:
#15012

update installed yt-dlp and install deno or nodejs

pip install -U "yt-dlp[default]"

說明, 一定要執行上面這行, 會多安裝一些新的元件.


Linux/Mac users:

# install deno
curl -fsSL https://deno.land/install.sh | sh

# upgrade yt-dlp
pip install -U "yt-dlp[default]"

Windows 平台下載 mp3 使用 dl.bat

yt-dlp -x --audio-format mp3 --js-runtimes node --cookies c:\max\bin\www.youtube.com_cookies.txt --embed-thumbnail %1 %2

如果不需要使用 cookie 也可以下載話, 你可以使用這個 dl.bat

yt-dlp -x --audio-format mp3 --js-runtimes node --embed-thumbnail %1 %2

如果你是要下載影片, 直接使用 yt-dlp 下載, 無法下載到正確版本的影片, 請使用這個 dlvideo.bat

yt-dlp -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" --js-runtimes node %1 %2

取得瀏覽器的 cookies:

在 yt-dlp 改用 –cookies 參數來解決問題

你要先在 chrome 瀏覽器安裝擴充工具(extension): Get cookies.txt LOCALLY

傳送門: https://chromewebstore.google.com/detail/get-cookiestxt-locally/cclelndahbckbenkjhflpdbgdldlbecc

點下上面網址後, 按右上角的 “Add to chrome”

接著到 youtube 網站, 並登入你的Google 帳號.

在 chrome 瀏覽器網址列右側點開擴充工具的小圖, 並點擊 get cookies.txt locally 的小圖:

點擊 Export As

預設會取得 youtube 網站的 cookies 並儲存到「下載」的資料夾下,

我是使用 “Export As”, 請把 www.youtube.com_cookies.txt 檔案移到一個你記得起來的與 youtube 外部指令相關的資料夾, 我放在 C:\max\bin\ 目錄下,

想偷懶, 不想多點幾下滑鼠去選擇資料夾, 也不想用鍵盤打太多字的話, 可以直接在檔案名稱第一個字之前插入一個 \ 符號, 就會直接存到根目錄.

Facebook網友回應

您可能也會感興趣的文章...

「假粉圓體」:有字重的粉圓字體

生活小事

有好心人出了一個免費的粉圓字體,剛好有空就幫忙調整一下字的重量,並重新放到網路上讓大家下載:https://github.com/max32002/FakePearl 測 […]

Read More

《電腦欺詐和濫用法》(Computer Fraud and Abuse Act,CFAA)

hiQ 寫了一支爬虫程式去parse linkedin 的資料,透過這個方式賺錢,被parse 資料的人眼紅告了 hiQ, 結果 hiQ 無罪,這告訴我們快點來寫爬虫程式 […]

Read More

如何透過Colab複製Google Drive 上面的目錄

電腦相關應用

為什麼要透過 Colab 來複製 Google Drive 上的目錄?因為我的使用空間滿了,我的儲存空間已使用92%: 原本以為,先在分身帳號分享目錄後,在主帳號把目錄移 […]

Read More

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *