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

Unable to watch age restricted videos. #29811

Closed
zisis912 opened this issue Aug 17, 2021 · 10 comments · Fixed by #31043
Closed

Unable to watch age restricted videos. #29811

zisis912 opened this issue Aug 17, 2021 · 10 comments · Fixed by #31043

Comments

@zisis912
Copy link

I have only downloaded youtube-dl.exe which I use together with mpv sometimes to watch youtube videos. The thing is that when I try to watch an age restricted video, I get this response:

C:\Users\user>mpv https://www.youtube.com/watch?v=9roObG3yq-8
[ytdl_hook] ERROR: Sign in to confirm your age
[ytdl_hook] This video may be inappropriate for some users.
[ytdl_hook] youtube-dl failed: unexpected error occurred
Failed to recognize file format.

Exiting... (Errors when loading file)

I've seen some people suggest cookies.. But would there be a point in adding cookies if the age restriction system needs an irl identity just to let you watch the vid?

@Rainyan
Copy link

Rainyan commented Aug 17, 2021

I've moved on to use the (in my opinion) more active youtube-dl fork, yt-dlp.

With yt-dlp installed, this works for me (force-seekable allows you to skip around the video):

REM Pipe to stdout ("-o -"), and then read from it with mpv ("mpv -")
yt-dlp -o - https://www.youtube.com/watch?v=foo |mpv --force-seekable=yes -

@ronkwann
Copy link

extract a cookie from your chrome or firefox as mentioned below;
blackjack4494/yt-dlc#7 (comment)

and use the --cookies argument, works for me

@gordon-quad
Copy link

not everyone has google account, so it would be nice to have such feature w/o requiring login if it is actually possible

@zpangwin
Copy link

zpangwin commented Aug 20, 2021

here's the same workaround ronkwann mentioned but with more detail including a chrome extension for exporting the cookie: https://brian.carnell.com/articles/2021/downloading-age-restricted-videos-with-youtube-dl/

update: for Firefox users who don't want any chromium-based browsers on their pc, you can try this add-on which should do the same thing (untested):
https://addons.mozilla.org/en-US/firefox/addon/export-cookies-txt/

pros: easy, works assuming you meet the age-restriction and are ok being tracked for the specific video but just want an offline copy

cons: not anonymous (requires youtube cookie so google can still track), you need a google account, article doesn't provide a firefox extension (see my update for a possible alternative), still need to meet age restriction requirements. unclear if this works on windows natively (probably works fine in cygwin / WSL)

Edit: updated based on feedback below

@zisis912
Copy link
Author

zisis912 commented Aug 20, 2021

so does it work if i give it cookies, even though I have a non-age restriction verified account? I mean, no one wants to sent their real identity to google. Also, supposing it works, should I do mpv [link] -cookies cookies.txt?

@zisis912
Copy link
Author

zisis912 commented Aug 20, 2021

doesn't seem to work

C:\Users\user>mpv https://www.youtube.com/watch?v=Rp3nRQSumKM -cookies C:\mpv\youtube.com_cookies.txt
Playing: https://www.youtube.com/watch?v=Rp3nRQSumKM
[ytdl_hook] ERROR: Sign in to confirm your age
[ytdl_hook] This video may be inappropriate for some users.
[ytdl_hook] youtube-dl failed: unexpected error occurred
Failed to recognize file format.

Playing: C:\mpv\youtube.com_cookies.txt
Failed to recognize file format.

Exiting... (Errors when loading file)

C:\Users\user>

@zpangwin
Copy link

zpangwin commented Aug 21, 2021

so does it work if i give it cookies, even though I have a non-age restriction verified account? I mean, no one wants to sent their real identity to google. Also, supposing it works, should I do mpv [link] -cookies cookies.txt?

good point, I suppose your account also has to actually pass the age restrictions imposed by google / youtube. :-)

Yeah, the workaround is not a mechanism for bypassing either the age restriction or tracking by google / youtube. It merely allows you to get an offline copy.

There might be options like using a proxy service like nsfwyoutube but in my experience, in many cases those just don't work. e.g. from a video someone shared with me today (is a little gross but IMHO the age restriction is no way warranted)

"Richard Stallman Eats Something From His Foot"
Youtube link: https://www.youtube.com/watch?v=I25UeVXrEHQ
Nsfwyoutube link: https://nsfwyoutube.com/watch?v=I25UeVXrEHQ

at Nsfwyoutube, the video thumbnail displays but I am completly unable to actually play the video, in either Firefox v91 or Chromium v90.0 (on Fedora 34 for both). Likewise, youtube-dl gives ERROR: Unsupported URL: https://nsfwyoutube.com/watch?v=I25UeVXrEHQ

doesn't seem to work

... [Error log]

I did not test on Windows. TBH, I wasn't even aware that you could use youtube-dl on Windows outside of running it in cygwin etc (I don't use Windows often and even then it's usually only on Win7 ... I suppose, WSL might also work on Win10). If you want to try the cygwin route, see my notes below.

On Fedora 34, the following works for me using a cookie that was downloaded in Chromium with me logged in on youtube with the extension mentioned in the article:

$ youtube-dl --version
2021.06.06
$ youtube-dl  --cookies ~/Downloads/youtube.com_cookies.txt https://www.youtube.com/watch?v=I25UeVXrEHQ
$ ls
'Richard Stallman Eats Something From His Foot-I25UeVXrEHQ.mkv'

Downloaded video plays back fine as well.

Also according to my notes from the last time I did use cygwin: I installed via chocolately (but should be the same for regular install). I had to get ffmpeg installed first and I had ended up using the pre-compiled versions built by gyan.dev, also on github. Sounds like I had issues previously when ffmpeg was not present, where youtube-dl wasn't able to merge A/V streams and it just downloaded 2 separate files for picture and for audio. My notes say I went with gyan's "git-full build" and extracted the binaries to "C:/tools/cygwin/bin". After that, I just installed youtube-dl per the instructions in the repo's README.md and it worked correctly (single file with both audio and video).

Hope that helps!

@coletdjnz
Copy link
Contributor

Related:
#29729
#29659
#29578
#29086

@unclechu
Copy link

I get 400 Bad Request error when try to authenticate in order to pass age restriction barrier (MY_EMAIL is my gmail account that I use on YouTube and can view age restricted videos):

$ youtube-dl https://youtu.be/a5-9vAHBNFI --username=MY_EMAIL
Type account password and press [Return]:
[youtube] Downloading login page
[youtube] Looking up account info
WARNING: Unable to look up account info: HTTP Error 400: Bad Request
[youtube] a5-9vAHBNFI: Downloading webpage
[youtube] a5-9vAHBNFI: Refetching age-gated info webpage
WARNING: unable to download video info webpage: HTTP Error 410: Gone
ERROR: Sign in to confirm your age
This video may be inappropriate for some users.

@Syndamia
Copy link

There might be options like using a proxy service like nsfwyoutube but in my experience, in many cases those just don't work. e.g. from a video someone shared with me today (is a little gross but IMHO the age restriction is no way warranted)

inv.riverside.rocks seems to work ok-ish. It has had no issue playing the few age restricted videos I tried, and youtube-dl does download when you give a link.
The only catch is that I can download only the 360p video version, so I can't download the HD video and audio separate and just combine them.
For better or for worse, it has a built in video/audio downloader. It really isn't as nice as youtube-dl but it is a viable workaround (there might be an API endpoint or something which can be used to download from command line, but I haven't looked into it enough).

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

Successfully merging a pull request may close this issue.

8 participants