Wie kann youtube-dl Videos herunterladen, für die eine Benutzerauthentifizierung und 2FA erforderlich sind?

1631
Dave Parrish

Wenn ich versuche, eines meiner privaten Videos herunterzuladen, erhalte ich Folgendes:

youtube-dl https://youtu.be/Q-xxxx-xxxx [youtube] Q-xxxx-xxxx: Downloading webpage [youtube] Q-xxxx-xxxx: Downloading video info webpage WARNING: Unable to extract video title ERROR: This video is unavailable. 

Wenn ich versuche, Benutzername und Passwort zu verwenden, schlägt dies auf meiner 2FA fehl.

youtube-dl --username=me@gmail.com https://youtu.be/Q-xxxx-xxxx Type account password and press [Return]:  [youtube] Downloading login page [youtube] Looking up account info [youtube] Logging in Type 2-step verification code and press [Return]:  [youtube] Submitting TFA code WARNING: Unable to submit TFA code: HTTP Error 400: Bad Request [youtube] Q-xxxx-xxxx: Downloading webpage [youtube] Q-xxxx-xxxx: Downloading video info webpage WARNING: Unable to extract video title ERROR: This video is unavailable. 

Wenn ich versuche, --cookiesmit EditThisCookie in Chrome exportiert zu werden, schlägt dies ebenfalls fehl. Ich exportierte, indem ich in Chrome zum Video ging und die Cookies in eine Datei kopierte.

youtube-dl --cookies=cookies.txt https://youtu.be/Q-xxxx-xxxx Traceback (most recent call last): File "/usr/bin/youtube-dl", line 11, in <module> load_entry_point('youtube-dl==2018.6.14', 'console_scripts', 'youtube-dl')() File "/usr/lib/python3.6/site-packages/youtube_dl/__init__.py", line 472, in main _real_main(argv) File "/usr/lib/python3.6/site-packages/youtube_dl/__init__.py", line 439, in _real_main with YoutubeDL(ydl_opts) as ydl: File "/usr/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 414, in __init__ self._setup_opener() File "/usr/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 2303, in _setup_opener self.cookiejar.load() File "/usr/lib/python3.6/http/cookiejar.py", line 1784, in load self._really_load(f, filename, ignore_discard, ignore_expires) File "/usr/lib/python3.6/http/cookiejar.py", line 2007, in _really_load filename) http.cookiejar.LoadError: 'cookies.txt' does not look like a Netscape format cookies fil 

Wie kann ich mein privates Video mit youtube-dl herunterladen?

BEARBEITEN:

Ich habe auch ein App-Passwort ausprobiert, aber aus irgendeinem Grund ist das auch für mich fehlgeschlagen:

youtube-dl --username=me@gmail.com --password=xxxxxxxxx youtu.be/Q-xxxxxxxx [youtube] Downloading login page [youtube] Looking up account info [youtube] Logging in WARNING: Unable to login: Invalid password [youtube] Q-xxxxxx: Downloading webpage [youtube] Q-xxxxxx: Downloading video info webpage WARNING: Unable to extract video title ERROR: This video is unavailable. 
0

1 Antwort auf die Frage

0
Dave Parrish

Ich konnte private Videos über die --cookiesRoute herunterladen . Ich musste die Cookies zuerst im Netscape-Format formatieren, was in EditThisCookie eine Option ist. Beachten Sie, dass Sie die Cookies nicht nur für https://youtube.com, sondern auch für https://accounts.google.com benötigen . Sie müssen dies manuell mit dem EditThisCookie Chrome-Plugin durchführen.

Ich musste dann das Format der mit EditThisCookie erzeugten Cookies korrigieren curl. Etwas wie: curl -b oldcookiefile.txt --cookie-jar newcookiefile.txt 'https://youtube.com'.

Die --cookiesFlagge kann dann mit youtube-dl verwendet werden, um private Videos herunterzuladen.

Ich habe auch einen Blog-Beitrag erstellt, in dem das Gelernte genauer beschrieben wird.

Verwenden Sie die Chrome-Erweiterung "cookies.txt", es ist einfacher :-) https://chrome.google.com/webstore/detail/cookiestxt/njabckikapfpffapmjgojcnbfjonfjfg?hl=de sekmo vor 5 Jahren 1