Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]How do I download age restricted video with youtube-dlc? youtube-dl is fine automatically #7

Closed
Klaus1189 opened this issue Oct 24, 2020 · 24 comments
Labels
question Further information is requested

Comments

@Klaus1189
Copy link

Klaus1189 commented Oct 24, 2020

I used youtube-dl many years and it automatically made it possible to download age restricted videos.

But if I use youtube-dlc, it tells me:
ERROR: Video is age restricted and only playable on Youtube. Requires cookies!

How do I get the same automatically "cookie creation"?

Thanks in advance

@Klaus1189 Klaus1189 added the question Further information is requested label Oct 24, 2020
@blackjack4494
Copy link
Owner

If it says so you need to provide your very own cookies. That is due the fact that some videos are only playable on youtube itself. There is a workaround in place to skip the need of cookies by using the embedded version but that is not working for on youtube only videos hence the need for cookies.

@nbmrjuhneibkr
Copy link

There is a workaround in place

The workaround doesn't seem to be working in yt-dlc right now. All age-restricted videos can't be downloaded with yt-dlc, not just "YouTube-only" ones. Meanwhile, youtube-dl downloads such videos just fine.

@nbmrjuhneibkr
Copy link

Here is the commit that introduced this bug: b492464

@october262
Copy link

There is a workaround in place

The workaround doesn't seem to be working in yt-dlc right now. All age-restricted videos can't be downloaded with yt-dlc, not just "YouTube-only" ones. Meanwhile, youtube-dl downloads such videos just fine.

this should be fixed in youtube-dlc

@nicolaasjan
Copy link

nicolaasjan commented Oct 24, 2020

Works here...

But you have to use the --cookies.txt option.
From the Readme (updated with recent links by me):

How do I pass cookies to youtube-dl?

Use the --cookies option, for example --cookies /path/to/cookies/file.txt.

In order to extract cookies from browser use any conforming browser extension for exporting cookies. For example, Get cookies.txt (for Chrome) or cookies.txt (for Firefox).

Note that the cookies file must be in Mozilla/Netscape format and the first line of the cookies file must be either # HTTP Cookie File or # Netscape HTTP Cookie File. Make sure you have correct newline format in the cookies file and convert newlines if necessary to correspond with your OS, namely CRLF (\r\n) for Windows and LF (\n) for Unix and Unix-like systems (Linux, Mac OS, etc.). HTTP Error 400: Bad Request when using --cookies is a good sign of invalid newline format.

Passing cookies to youtube-dl is a good way to workaround login when a particular extractor does not implement it explicitly. Another use case is working around CAPTCHA some websites require you to solve in particular cases in order to get access (e.g. YouTube, CloudFlare).

[Side-note]
The example video you linked to, is one of the reasons of the DMCA take-down of the youtube-dl repo.
I don't think it's wise to mention it here...

Better replace it with a less high-profile link. ;)

@nbmrjuhneibkr
Copy link

But you have to use the --cookies.txt option.

No, you don't. I'll repeat: youtube-dl downloads age-restricted videos perfectly fine without cookies.txt. Only yt-dlc has this problem.

@Klaus1189
Copy link
Author

But you have to use the --cookies.txt option.

No, you don't. I'll repeat: youtube-dl downloads age-restricted videos perfectly fine without cookies.txt. Only yt-dlc has this problem.

Yes. I think now that it is indeed a bug.

How would I use the cookies.txt option for that? Documentation is down, do I need a new link?

@nicolaasjan
Copy link

nicolaasjan commented Oct 24, 2020

But you have to use the --cookies.txt option.

No, you don't. I'll repeat: youtube-dl downloads age-restricted videos perfectly fine without cookies.txt. Only yt-dlc has this problem.

Then just use youtube-dl for those. ;)
I just meant, that with yt-dlc you must use this option (for now?).

@nbmrjuhneibkr
Copy link

nbmrjuhneibkr commented Oct 24, 2020

youtube-dl https://www.youtube.com/watch?v=7t0SqerlBA0 -f best

Result:

[youtube] 7t0SqerlBA0: Downloading webpage
[youtube] 7t0SqerlBA0: Downloading embed webpage
[youtube] 7t0SqerlBA0: Refetching age-gated info webpage
[download] Destination: Test Age Restricted Video-7t0SqerlBA0.mp4
[download] 100% of 10.59MiB in 00:03

youtube-dlc https://www.youtube.com/watch?v=7t0SqerlBA0 -f best

Result:

[youtube] 7t0SqerlBA0: Downloading webpage
[youtube] 7t0SqerlBA0: Downloading embed webpage
ERROR: Video is age restricted and only playable on Youtube. Requires cookies!

@nicolaasjan
Copy link

nicolaasjan commented Oct 24, 2020

Yes. I think now that it is indeed a bug.

How would I use the cookies.txt option for that? Documentation is down, do I need a new link?

I explained above, Klaus.

@Klaus1189
Copy link
Author

Thanks.

Hopefully this gets fixed

@blackjack4494
Copy link
Owner

blackjack4494 commented Oct 24, 2020

@nbmrjuhneibkr you are partially right.
Indeed the video you gave as an example is interesting.
The way yt-dlc detecs whether you need cookies or not is by certain elements.
I haven't seen an html (unavailable message with playability status ok) like your example before.

To determine whether you can circumvent age gating the embedded version will be checked:
So yt-dlc checks for
<div class="player-unavailable"><h1 class="message">
which is also present in your video so it trigger the needs cookies warning
However this video also contains
"playabilityStatus\":{\"status\":\"OK\"},\"videoFlags\":{\"playableInEmbed\":true,\"isCrawlable\":true,\"
which wasn't the case with the normal working embedded ones and those who require youtube only and age.

So for instance try to download this video
https://www.youtube.com/watch?v=7takIh1nK0s
<div class="player-unavailable"><h1 class="message">
\"playabilityStatus\":{\"status\":\"UNPLAYABLE\",\"reason\":\"Video nicht verfügbar\"},\"videoFlags\":{\"playableInEmbed\":false,\"isCrawlable\":true,\"

So at least I know I should check for both playability Status and unavailable messages.

@nbmrjuhneibkr
Copy link

nbmrjuhneibkr commented Oct 24, 2020

I don't think there's anything special about the example I provided. It behaves the same with every age-restricted video I could find (all of which could be embedded, and therefore could be downloaded by youtube-dl, but not by yt-dlc).

@rubyFeedback
Copy link

Recently youtube-dl stopped working for me in regards to age-gate restricted videos.

I am almost 100% sure that this has to do with google changing things - guess they
don't like youtube-dl and variants.

@shakeyourbunny
Copy link

You need a VPN to appear to come from outside the European Union, then it works.

@shakeyourbunny
Copy link

https://www.digitalmusicnews.com/2020/11/02/youtube-age-gate-verification-europe/

Although this is an article from November 2020, they seem to have finally rolled it out for everyone there.

@pukkandan
Copy link
Contributor

@rubyFeedback This repo has not had any updates for a while. You can try my fork yt-dlp where most age-gated content still works (not tested from EU)

@caniko
Copy link

caniko commented Jun 27, 2021

@rubyFeedback This repo has not had any updates for a while. You can try my fork yt-dlp where most age-gated content still works (not tested from EU)

Just tested in Germany, it works.

@aindriu80
Copy link

aindriu80 commented Jul 29, 2021

I got it to work with the following (cookies.txt by Lennon Hill) extension:-

Cookies.txt by Lennon Hill

It adds an icon to the address bar, while on a youtube page click on the icon and export cookies.txt to the location you are running youtube-dl

Then type:

youtube-dl --cookies cookies.txt https://www.youtube.com/XYZ

♫♪.ılılıll|̲̅̅●̲̅̅|̲̅̅=̲̅̅|̲̅̅●̲̅̅|llılılı.♫♪

@tkwetzhy
Copy link

Works here...

But you have to use the --cookies.txt option.
From the Readme (updated with recent links by me):

How do I pass cookies to youtube-dl?

Use the --cookies option, for example --cookies /path/to/cookies/file.txt.
In order to extract cookies from browser use any conforming browser extension for exporting cookies. For example, Get cookies.txt (for Chrome) or cookies.txt (for Firefox).
Note that the cookies file must be in Mozilla/Netscape format and the first line of the cookies file must be either # HTTP Cookie File or # Netscape HTTP Cookie File. Make sure you have correct newline format in the cookies file and convert newlines if necessary to correspond with your OS, namely CRLF (\r\n) for Windows and LF (\n) for Unix and Unix-like systems (Linux, Mac OS, etc.). HTTP Error 400: Bad Request when using --cookies is a good sign of invalid newline format.
Passing cookies to youtube-dl is a good way to workaround login when a particular extractor does not implement it explicitly. Another use case is working around CAPTCHA some websites require you to solve in particular cases in order to get access (e.g. YouTube, CloudFlare).

[Side-note]
The example video you linked to, is one of the reasons of the DMCA take-down of the youtube-dl repo.
I don't think it's wise to mention it here...

Better replace it with a less high-profile link. ;)

It really works,thanks a lot!!

@nicolaasjan
Copy link

It really works,thanks a lot!!

No problem!

In the mean time, note that this yt-dlc fork is no longer actively maintained.
You may want to try the yt-dlp fork instead.

@THGhost
Copy link

THGhost commented Jun 7, 2022

But you have to use the --cookies.txt option.

No, you don't. I'll repeat: youtube-dl downloads age-restricted videos perfectly fine without cookies.txt. Only yt-dlc has this problem.

Can confirm that it does not. yt-dpl does though so all good there I guess.

@tkwetzhy
Copy link

It really works,thanks a lot!!

No problem!

In the mean time, note that this yt-dlc fork is no longer actively maintained. You may want to try the yt-dlp fork instead.

Thank you again!!!

@ValGadZ
Copy link

ValGadZ commented Jul 2, 2023

import subprocess
video_url = 'https://www.youtube.com/watch?v=HLuHxEzO3sE'
save_path = "airbourne.mp3"
command = f"yt-dlp --ffmpeg-location D:/Biggi/Trans/Mp3/ffmpeg-master-latest-win64-gpl-shared/bin/ffmpeg.exe --extract-audio --audio-format mp3 --audio-quality 192K {video_url} -o {save_path}"
subprocess.call(command, shell=True)
print("Downloaded successfuly.")

this helped me for mp3 download

[youtube] Extracting URL: https://www.youtube.com/watch?v=HLuHxEzO3sE
[youtube] HLuHxEzO3sE: Downloading webpage
[youtube] HLuHxEzO3sE: Downloading ios player API JSON
[youtube] HLuHxEzO3sE: Downloading android player API JSON
[youtube] HLuHxEzO3sE: Downloading m3u8 information
[info] HLuHxEzO3sE: Downloading 1 format(s): 251
[download] Destination: airbourne.webm
[download] 100% of 76.61MiB in 00:00:25 at 2.98MiB/s
[ExtractAudio] Destination: airbourne.mp3
Deleting original file airbourne.webm (pass -k to keep)
Downloaded successfuly.

Process finished with exit code 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests