Peertube V7.0 import problem

Hello!

I used 6.3.3 version and imported videos from YouTube without any problem. After updating to 7.0 I’m unable to import anything from YouTube, getting this error:

Job: 4
Type: video-import
Processed on 12/26/24, 11:11:06.671 PM
Finished on 12/26/24, 11:11:10.373 PM
{
  "type": "youtube-dl",
  "videoImportId": 4,
  "fileExt": ".webm",
  "generateTranscription": true,
  "preventException": false
}
ExecaError: Command failed with exit code 1: /usr/bin/python3 /data/bin/yt-dlp --merge-output-format mp4 -f 'bestvideo[vcodec!*=av01][vcodec!*=vp9.2]+bestaudio/best[vcodec!*=av01][vcodec!*=vp9.2]/bestvideo[ext=mp4]+bestaudio[ext=m4a]/best' -o /data/tmp/60884894fcbce110875d72a5d2d8e0e2b94db7cbadec3bf8c5053f7df3f2029e-import 'https://youtu.be/[truncated link]'

ERROR: unable to download video data: HTTP Error 403: Forbidden

[youtube] Extracting URL: https://youtu.be/ [truncated link]
[youtube] 112PH61FSmA: Downloading webpage
[youtube] 112PH61FSmA: Downloading ios player API JSON
[youtube] 112PH61FSmA: Downloading mweb player API JSON
[youtube] 112PH61FSmA: Downloading m3u8 information
[info] 112PH61FSmA: Downloading 1 format(s): 313+251
    at getFinalError (file:///app/node_modules/execa/lib/return/final-error.js:6:9)
    at makeError (file:///app/node_modules/execa/lib/return/result.js:108:16)
    at getAsyncResult (file:///app/node_modules/execa/lib/methods/main-async.js:167:4)
    at handlePromise (file:///app/node_modules/execa/lib/methods/main-async.js:150:17)
    at async YoutubeDLCLI.run (file:///app/dist/core/helpers/youtube-dl/youtube-dl-cli.js:148:24)
    at async YoutubeDLWrapper.downloadVideo (file:///app/dist/core/helpers/youtube-dl/youtube-dl-wrapper.js:74:13)
    at async processFile (file:///app/dist/core/lib/job-queue/handlers/video-import.js:84:24)
    at async Object.processVideoImport [as video-import] (file:///app/dist/core/lib/job-queue/handlers/video-import.js:45:13)
    at async Object.wrapPromiseFun (file:///app/dist/core/lib/plugins/hooks.js:8:24)
    at async /app/node_modules/bullmq/dist/cjs/classes/worker.js:512:32
    at async Worker.retryIfFailed (/app/node_modules/bullmq/dist/cjs/classes/worker.js:741:24)

Many thanks for any advice!

Hi,

Can you try with another youtube video?

I tried with multiple videos, both public and unlisted, same result (403 error)

Can you try to run the yt-dlp command manually from your docker container?

Sorry, not sure how to do that exactly…

sudo docker exec -it peertube-peertube-1 yt-dlp gives no result (OCI runtime exec failed: exec failed: unable to start container process: exec: "yt-dlp": executable file not found in $PATH: unknown). If I try sudo docker exec -it peertube-peertube-1 sh then yt-dlp is just not found again…

Command is

 /usr/bin/python3 /data/bin/yt-dlp --merge-output-format mp4 -f 'bestvideo[vcodec!*=av01][vcodec!*=vp9.2]+bestaudio/best[vcodec!*=av01][vcodec!*=vp9.2]/bestvideo[ext=mp4]+bestaudio[ext=m4a]/best' -o /data/tmp/60884894fcbce110875d72a5d2d8e0e2b94db7cbadec3bf8c5053f7df3f2029e-import 'https://youtu.be/[truncated link]'

My result from docker:

# /usr/bin/python3 /data/bin/yt-dlp --merge-output-format mp4 -f 'bestvideo[vcodec!*=av01][vcodec!*=vp9.2]+bestaudio/best[vcodec!*=av01][vcodec!*=vp9.2]/bestvideo[ext=mp4]+bestaudio[ext=m4a]/best' -o /data/tmp/60884894fcbce110875d72a5d2d8e0e2b94db7cbadec3bf8c5053f7df3f2029e-import 'https://youtu.be/watch?v=jS0-rTyH6hk'

[generic] Extracting URL: https://youtu.be/watch?v=jS0-rTyH6hk

[generic] watch?v=jS0-rTyH6hk: Downloading webpage

[redirect] Following redirect to https://www.youtube.com/watch?v=jS0-rTyH6hk&v=watch&feature=youtu.be

[youtube] Extracting URL: https://www.youtube.com/watch?v=jS0-rTyH6hk&v=watch&feature=youtu.be

[youtube] jS0-rTyH6hk: Downloading webpage

[youtube] jS0-rTyH6hk: Downloading ios player API JSON

[youtube] jS0-rTyH6hk: Downloading mweb player API JSON

[youtube] jS0-rTyH6hk: Downloading m3u8 information

[info] jS0-rTyH6hk: Downloading 1 format(s): 271+251

ERROR: unable to download video data: HTTP Error 403: Forbidden

Your server IP may have been blocked by youtube :confused:

Is there any option to use proxy? I saw this in documentation, but not sure how to set this up inside docker…

Yes: PeerTube/config/production.yaml.example at develop · Chocobozzz/PeerTube · GitHub

With docker you can create a production.yaml with keys that cannot be defined by env variables in the config directory inside your docker volumes.

Updated to 7.1 version.
Now, when I am trying to import something from YouTube I am getting this message:

An error occurred while importing the video https://www.youtube.com/watch?v=AchtKBclcxI.
{
  "err": {
    "stack": "ExecaError: Command failed with exit code 1: /usr/bin/python3 /data/bin/yt-dlp --dump-json -f 'bestvideo[vcodec!*=av01][vcodec!*=vp9.2]+bestaudio/best[vcodec!*=av01][vcodec!*=vp9.2]/bestvideo[ext=mp4]+bestaudio[ext=m4a]/best' 'https://www.youtube.com/watch?v=AchtKBclcxI'\n\nERROR: [youtube] AchtKBclcxI: Sign in to confirm you’re not a bot. Use --cookies-from-browser or --cookies for the authentication. See  https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp  for how to manually pass cookies. Also see  https://github.com/yt-dlp/yt-dlp/wiki/Extractors#exporting-youtube-cookies  for tips on effectively exporting YouTube cookies\n    at getFinalError (file:///app/node_modules/execa/lib/return/final-error.js:6:9)\n    at makeError (file:///app/node_modules/execa/lib/return/result.js:108:16)\n    at getAsyncResult (file:///app/node_modules/execa/lib/methods/main-async.js:167:4)\n    at handlePromise (file:///app/node_modules/execa/lib/methods/main-async.js:150:17)\n    at async YoutubeDLCLI.run (file:///app/dist/core/helpers/youtube-dl/youtube-dl-cli.js:148:24)\n    at async YoutubeDLCLI.getInfo (file:///app/dist/core/helpers/youtube-dl/youtube-dl-cli.js:93:22)\n    at async YoutubeDLWrapper.getInfoForDownload (file:///app/dist/core/helpers/youtube-dl/youtube-dl-wrapper.js:23:22)\n    at async buildYoutubeDLImport (file:///app/dist/core/lib/video-pre-import.js:104:25)\n    at async handleYoutubeDlImport (file:///app/dist/core/controllers/api/videos/import.js:114:38)",
    "message": "Cannot fetch information from import for URL https://www.youtube.com/watch?v=AchtKBclcxI",
    "code": 0,
    "cause": {
      "stack": "ExecaError: Command failed with exit code 1: /usr/bin/python3 /data/bin/yt-dlp --dump-json -f 'bestvideo[vcodec!*=av01][vcodec!*=vp9.2]+bestaudio/best[vcodec!*=av01][vcodec!*=vp9.2]/bestvideo[ext=mp4]+bestaudio[ext=m4a]/best' 'https://www.youtube.com/watch?v=AchtKBclcxI'\n\nERROR: [youtube] AchtKBclcxI: Sign in to confirm you’re not a bot. Use --cookies-from-browser or --cookies for the authentication. See  https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp  for how to manually pass cookies. Also see  https://github.com/yt-dlp/yt-dlp/wiki/Extractors#exporting-youtube-cookies  for tips on effectively exporting YouTube cookies\n    at getFinalError (file:///app/node_modules/execa/lib/return/final-error.js:6:9)\n    at makeError (file:///app/node_modules/execa/lib/return/result.js:108:16)\n    at getAsyncResult (file:///app/node_modules/execa/lib/methods/main-async.js:167:4)\n    at handlePromise (file:///app/node_modules/execa/lib/methods/main-async.js:150:17)\n    at async YoutubeDLCLI.run (file:///app/dist/core/helpers/youtube-dl/youtube-dl-cli.js:148:24)\n    at async YoutubeDLCLI.getInfo (file:///app/dist/core/helpers/youtube-dl/youtube-dl-cli.js:93:22)\n    at async YoutubeDLWrapper.getInfoForDownload (file:///app/dist/core/helpers/youtube-dl/youtube-dl-wrapper.js:23:22)\n    at async buildYoutubeDLImport (file:///app/dist/core/lib/video-pre-import.js:104:25)\n    at async handleYoutubeDlImport (file:///app/dist/core/controllers/api/videos/import.js:114:38)",
      "message": "Command failed with exit code 1: /usr/bin/python3 /data/bin/yt-dlp --dump-json -f 'bestvideo[vcodec!*=av01][vcodec!*=vp9.2]+bestaudio/best[vcodec!*=av01][vcodec!*=vp9.2]/bestvideo[ext=mp4]+bestaudio[ext=m4a]/best' 'https://www.youtube.com/watch?v=AchtKBclcxI'\n\nERROR: [youtube] AchtKBclcxI: Sign in to confirm you’re not a bot. Use --cookies-from-browser or --cookies for the authentication. See  https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp  for how to manually pass cookies. Also see  https://github.com/yt-dlp/yt-dlp/wiki/Extractors#exporting-youtube-cookies  for tips on effectively exporting YouTube cookies",
      "shortMessage": "Command failed with exit code 1: /usr/bin/python3 /data/bin/yt-dlp --dump-json -f 'bestvideo[vcodec!*=av01][vcodec!*=vp9.2]+bestaudio/best[vcodec!*=av01][vcodec!*=vp9.2]/bestvideo[ext=mp4]+bestaudio[ext=m4a]/best' 'https://www.youtube.com/watch?v=AchtKBclcxI'",
      "command": "/usr/bin/python3 /data/bin/yt-dlp --dump-json -f bestvideo[vcodec!*=av01][vcodec!*=vp9.2]+bestaudio/best[vcodec!*=av01][vcodec!*=vp9.2]/bestvideo[ext=mp4]+bestaudio[ext=m4a]/best https://www.youtube.com/watch?v=AchtKBclcxI",
      "escapedCommand": "/usr/bin/python3 /data/bin/yt-dlp --dump-json -f 'bestvideo[vcodec!*=av01][vcodec!*=vp9.2]+bestaudio/best[vcodec!*=av01][vcodec!*=vp9.2]/bestvideo[ext=mp4]+bestaudio[ext=m4a]/best' 'https://www.youtube.com/watch?v=AchtKBclcxI'",
      "cwd": "/app",
      "durationMs": 2524.996983,
      "failed": true,
      "timedOut": false,
      "isCanceled": false,
      "isGracefullyCanceled": false,
      "isTerminated": false,
      "isMaxBuffer": false,
      "isForcefullyTerminated": false,
      "exitCode": 1,
      "stdout": "",
      "stderr": "ERROR: [youtube] AchtKBclcxI: Sign in to confirm you’re not a bot. Use --cookies-from-browser or --cookies for the authentication. See  https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp  for how to manually pass cookies. Also see  https://github.com/yt-dlp/yt-dlp/wiki/Extractors#exporting-youtube-cookies  for tips on effectively exporting YouTube cookies",
      "stdio": [
        null,
        "",
        "ERROR: [youtube] AchtKBclcxI: Sign in to confirm you’re not a bot. Use --cookies-from-browser or --cookies for the authentication. See  https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp  for how to manually pass cookies. Also see  https://github.com/yt-dlp/yt-dlp/wiki/Extractors#exporting-youtube-cookies  for tips on effectively exporting YouTube cookies"
      ],
      "ipcOutput": [],
      "pipedFrom": []
    }
  }
}

This command worked inside docker and the video was downloaded:
/usr/bin/python3 /data/bin/yt-dlp -f bestvideo[vcodec!=av01][vcodec!=vp9.2]+bestaudio/best[vcodec!=av01][vcodec!=vp9.2]/bestvideo[ext=mp4]+bestaudio[ext=m4a]/best https://youtu.be/AchtKBclcxI --cookies /data/yt.txt

However, I don’t know how to import it now… could you please advice how to modify my command? Thanks a lot!!

Congratulations: you are now member of the « Peertube instances that can’t sync with youtube because Google decided to blocklist our IPs » club.

More seriously, this started a few months ago. Google started to block all IP that are flagged as « Datacenter » on youtube… There is no ideal solution for now.
If you have some IP that are not flagged, you can configure proxies (Peertube has an option to specify one or several proxies for ytb-dlp).