Open lesf0 opened 1 week ago
Hi, the integration you are doing with oauth2 seems very interesting, it would be great to be able to review your code, maybe you could publish it in your fork of ytdlp2strm?
I think I know what the problem is. In my code, cookies (or cookies-from-browser) are currently used only when requesting the final manifest of a video from YouTube, using the direct() function of the youtube.py file. Within this you can see the call to set_cookies on line 762, but I am not adding it to the commands to obtain the list of videos from a channel. You can review it above in the code in the same file within the Youtube class. I will work to include cookies in all yt-dlp commands. If we can also include your integration with oauth2, even better.
I think that all the problems would be solved with this. The redirection is handled automatically by youtube when the manifest is accessed, ytdlp2strm checks if there are no cookies set for age-restricted videos then it is not possible to get the hls manifest and only in that case it uses the command to get the final webm or mp4 url but this is only available in low resolution. You can also check this in the direct() function
With the necessary context I answer your questions
If we integrate oauth then we could completely skip the use of cookies or cookies-from-browser
As I mentioned, the m3u (which come from the hls manifest) and the 302 redirects are not intentional behaviors of ytdlp2strm, it is the logic of youtube.
In other issues we have seen that it is necessary to activate hardware acceleration in JF for everything to work correctly.
The -f best parameters on YouTube have not been offered pre-merged in HD for a long time, so I use -j to get the full json and extract the hls manifest which does work to play the content in maximum quality, with the limitation that for videos with age restrictions we will need to authenticate (until now with cookies or cookies-from-browser)
I've experienced an issue (#78) with youtube not allowing to get video data without an authorization, so I've started poking around and found a possible solution: https://github.com/coletdjnz/yt-dlp-youtube-oauth2 I managed to integrate it to ytdlp2STRM so it started to work for me, but then I've encountered a few weird playback issues:
/youtube/direct/g5btvgHY5w4
returned 302 redirect with empty location string. After some digging around I've managed to attribute it to-f best
command line option because my videos seem to not have pre-merged format available. So, I've tried to remove it.So, a few questions:
--cookies-from-browser
is set by default but no browser or cookies are present in the docker image? This leads to errors from yt-dlp command and apparently changes behaviour. Also, why setting either--cookies
or--cookies-from-browser
is mandatory and cannot be omited entirely?-f best
? I wasn't able to find any youtube video with pre-merged stream, do they even exist or is it some legacy stuff?P.S. If you're interested, I will gladly submit all my work on integrating yt-dlp-youtube-oauth to your repo once I'll figure it out and tie some ends (e.g. add it to configuration file and show authentification code in admin panel).