tubearchivist / tubearchivist

Your self hosted YouTube media server
https://www.tubearchivist.com
GNU General Public License v3.0
5.09k stars 225 forks source link

Feature Request: Allow use of cookies.txt file to pass to YT-DLP #199

Closed Marthisdil closed 2 years ago

Marthisdil commented 2 years ago

Just in case YT wants to be picky about age restricted, etc, files - be nice to be able to point to a cookies.txt file in the tubearchivist appdata folder that it can pass to YT-DLP

bbilly1 commented 2 years ago

I haven't encountered any video, even age restricted, where yt-dlp had any problem. Did you?

But this could also parse the "watch later" or favorites lists, so that could be useful anyways.

Marthisdil commented 2 years ago

I haven't encountered any video, even age restricted, where yt-dlp had any problem. Did you?

But this could also parse the "watch later" or favorites lists, so that could be useful anyways.

nothing specific, yet. in the past there were a handful of age restricted vids that i couldn't get with yt-dl/yt-dlp, soon as i grabbed cookies.txt from my browser while logged in to YT and used it as a parameter, no problems.

pairofcrocs commented 2 years ago

We've talked about integrating this with the browser extension so that it could automatically send the cookies VIA a simple API call.

Do you think something like is would solve that pitfall in your use case?

Marthisdil commented 2 years ago

We've talked about integrating this with the browser extension so that it could automatically send the cookies VIA a simple API call.

Do you think something like is would solve that pitfall in your use case?

possibly - an addon to pull the cookie data and pass to TA would effectively be the same thing as using an addon to create a cookies.txt file for YT which would then be put into the TA folder and the TA config pointed to it. I thnk it would at least.

UIDEVEL commented 2 years ago

vote for this too.

a-jackson commented 2 years ago

I've just had one logging Sign in to confirm your age. This video may be inappropriate for some users. so 👍 from me for this.

traktuner commented 2 years ago

+1 for this

mdajr commented 2 years ago

Just hit a "confirm your age" issue on an April Fools video from the Gaming Historian (vW8evni8Lj4)

Also this would allow downloading of members only content which would be nice for some stream VODs

bbilly1 commented 2 years ago

@Marthisdil it's on the road map now. if you want to get a head start on that feature, these are the things we need to figure out:

please help in figuring these things out.

Marthisdil commented 2 years ago

To generate the file:

I used Chrome to get the cookies:

1) Install Get Cookies.txt addon from chrome store: https://chrome.google.com/webstore/detail/get-cookiestxt/bgaddhkoddajcdgocldbbfleckgcbcid

2) Visit Youtube and login with whichever Youtube account you wish to use to generate the cookies.

3) Click on the extension icon in the Chrome toolbar - it will drop down showing the active cookies for YT

4) Click Export to export the cookies - I saved mine as cookies.txt and put in the path I used to store YT-DLP files

5) (this step will change based on the TA UI) - point YT-DLP to use the cookies.txt file you just saved by passing the --cookies parameter

I used TarTube GUI for YT-DL/YT-DLP and that's what was done to bypass age restrictions, limits, etc, as necessary at times.

Never looked into using it for the favorites playlist - it was just used to bypass some restrictions that are bypassed by being logged in to YT

No idea how to determine when the cookies expire. I used the same file for over a year, but I guess if by using it, and you can no longer grab an age-restricted file that YT-DLP can't workaround internally, that would be a signal.

I don't think it will be perfect, but it certainly helps.

Marthisdil commented 2 years ago

with per channel settings, you could technically allow a unique cookies.txt file for each channel - for those people with multiple YT accounts for various reasons, or just 1 general one for the majority of users.

pairofcrocs commented 2 years ago

Just jumping in here quick. I believe that everyone's liked videos are under https://www.youtube.com/playlist?list=LL.

I think this is a global default for every channel.

bbilly1 commented 2 years ago

Very interesting, thanks everybody for looking into it. Following the instructions to export the cookie and using the liked videos as a testing URL i got the following without the cookie:

❯ yt-dlp "https://www.youtube.com/playlist?list=LL" --simulate
[youtube:tab] LL: Downloading webpage
WARNING: [youtube:tab] YouTube said: The playlist does not exist.
ERROR: [youtube:tab] LL: YouTube said: The playlist does not exist.

throwing an error because the playlist does not exist, which is technically correct. And this is with the cookie:

❯ yt-dlp "https://www.youtube.com/playlist?list=LL" --cookies cookies.google.txt --simulate
[youtube:tab] LL: Downloading webpage
[youtube:tab] LL: Downloading API JSON with unavailable videos
[download] Downloading playlist: Liked videos
[youtube:tab] playlist Liked videos: Downloading 0 videos
[download] Finished downloading playlist: Liked videos

Successfully accessing the playlist, empty in my case, but it's there.

Not sure about the expiring part. But as we can verify that now, we could do that periodically to make sure that's still valid.

Additionally there is also https://www.youtube.com/playlist?list=WL for watch later. And this should also be able to access private playlists too.

bbilly1 commented 2 years ago

There has been some progress: Newest unstable build has now cookie import and you can access your watch later and liked videos playlists. Please give it a try in your testing environment and let me know how this is working for you: https://github.com/tubearchivist/tubearchivist/blob/master/docs/Settings.md#cookie

bbilly1 commented 2 years ago

This is now published in v0.1.5. Please update!