Rafostar / gtuber

C library to fetch media info from websites
https://rafostar.github.io/gtuber/
GNU Lesser General Public License v2.1
9 stars 3 forks source link

Handle YouTube URLs that don't contain the video ID. #29

Closed juxuanu closed 1 year ago

juxuanu commented 1 year ago

As discussed in the Matrix channel, GTuber doesn't handle this kind of links: https://youtube.com/nasa/live.

Example Clapper output:

❯ flatpak run --env=LC_ALL=C com.github.rafostar.Clapper 

(com.github.rafostar.Clapper:2): Clapper-CRITICAL **: 21:13:55.241: Error from element /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0: Your GStreamer installation is missing a plug-in.
Your GStreamer installation is missing a plug-in.
../subprojects/gst-plugins-base/gst/playback/gsturidecodebin.c(1027): no_more_pads_full (): /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0:
no suitable plugins found:
../subprojects/gst-plugins-base/gst/playback/gstdecodebin2.c(4701): gst_decode_bin_expose (): /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0/GstDecodeBin:decodebin0:
no suitable plugins found:
Missing decoder: text/html (text/html)

A workaround is to access the URL, right-click the video and "Copy video URL", which lets you obtain a URL that GTuber can handle. In the example above, that'd be https://youtu.be/nA9UZF-SZoQ.


yt-dlp can handle this correctly, so it might be worth checking out what they do.

Rafostar commented 1 year ago

Normally we get video_id from initial URI. ID is a must as its used with the YT API everywhere. What this probably needs to do is a change plugin_query () implementation in youtube plugin to detect this special */live case, continuing without the ID and then downloading webpage as HTML and extracting ID value from it, then proceeding like we do normally.

juxuanu commented 1 year ago

It doesn't seem trivial. Scraping the live link resulted in no video ID... I have been looking around the yt-dlp code but I need more time to understand the code. I also took a look at the function you mentioned and it'd seem trivial once there is a way to figure out the video ID.

Rafostar commented 1 year ago

@juxuanu Should be supported by linked above PR. I will add a test case to it before merging.