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

[Feature / YT] Detect member-only streams #6

Open
ii7mood opened this issue Jun 19, 2024 · 3 comments
Open

[Feature / YT] Detect member-only streams #6

ii7mood opened this issue Jun 19, 2024 · 3 comments
Assignees

Comments

@ii7mood
Copy link
Owner

ii7mood commented Jun 19, 2024

Essentially we will be replacing yt-dlp with our own.. parser?

I am not quite sure how this is going to be implemented. See, we could simply use requests.get() and download the webpage and parse its content, or we could use the InnerTube API (which I have no idea how) to send requests for data, or whatever yt-dlp is doing (which I think is a combination of the two? Idk).

Which option is more realistic is the question. I will update this issue with my research.

@ii7mood ii7mood self-assigned this Jun 19, 2024
@ii7mood
Copy link
Owner Author

ii7mood commented Jun 19, 2024

Nah. yt-dlp does too much to simply replace, nuh-uh.

Instead I found something interesting. Using the following command I can essentially select a specific stream to download using yt-dlp CLI:
yt-dlp --lazy-playlist --max-download 1 --match-filter is_live "https://www.youtube.com/@user/streams"

Essentially, yt-dlp somehow, somewhere, holds entries of streams within that tab. But I can't find a way to do this using code.

I completely forgot that I set "playlist_items": 0 in yt_dlp options so obviously no entries are going to be shared to me 🤦‍♂️ Removing that and adding lazy_playlist: true to the yt_dlp options does indeed give us a bunch of streams but no metadata. I had to stop there for today though. I will look more into whenever I am free.

@ii7mood ii7mood changed the title [Feature / YT] Parse '/streams' [Feature / YT] Detect member-only streams Jun 20, 2024
@ii7mood
Copy link
Owner Author

ii7mood commented Jun 20, 2024

Okay. So I used the _extract_data() function within the streamers.py script for testing and yt_dlp_args from streamers_vars.py.

Looking at the returned info_dict of '/streams' URL of a channel with a live members-only stream and keys "playlist_items": 1, "cookies": "path_to_cookies.txt" shows me the latest non-member stream with no metadata. Setting "playlist_items": 0 just returns some basic information about the channel. At this point I thought that maybe yt-dlp is ignoring my cookies.txt file for some reason.

So I tried directly downloading meta-data of a member-only stream using it's exact URL (i.e https://youtube.com/watch?ID). It did not work and an error telling me "no video formats" was logged. I removed a bunch of options that suppress errors and was greeted with this:
ERROR: [youtube] ID: The following content is not available on this app.. Watch on the latest version of YouTube.

Attempting to download a normal non-members stream works though. Also removing the cookies file then attempting to download the members-only stream again tells me that this is a member-only stream or something. I am paraphrasing here because later I tried it again and now it gives me the same error as above regardless of whether a cookies file was passed or not. It still had no problem downloading non-member streams.

I also tried using a VPS I rent as a proxy and still errors out. There is a yt-dlp plugin that allows authenticating using email and password but I don't know if this is safe as I am pretty sure you're breaking TOS and possibly risking a ban. Uhhhhh what to do.

Requests just returns a bunch of Javascript functions (who would've thought) and there is (understandably) no documentation on InnerTube. Now still, using CLI yt-dlp we can download member-only streams (when a cookie file is passed to it) so I assume there is a way. Maybe if I specify the YouTubeBaseInfoExtractor or some complicated function that I can't understand we might get it working?

@ii7mood
Copy link
Owner Author

ii7mood commented Jun 21, 2024

I have not really tested anything today but thinking about it I think InnerTube could possibly be the key here. I have no idea how much data I can access through it though.

Also, Streamlink can detect member-only streams. It does not give us any metadata but it does tell us that a protected-video exists - highly suggesting that it's a members-only stream. So technically I can detect members-only stream but I cannot tell you when it will start or if it has already started, only that it exists. Not really worth it imo.

I wish I had the knowledge for this but I am no better than the average high school programmer. I will learn how this works eventually though, just gotta keep trying.

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

No branches or pull requests

1 participant