NikkelM / Random-YouTube-Video

A browser extension that allows you to truly randomly shuffle videos from any YouTube channel, offering many customization options.
https://chromewebstore.google.com/detail/random-youtube-video/kijgnjhogkjodpakfmhgleobifempckf
GNU Lesser General Public License v3.0
17 stars 3 forks source link

[Shorts] Find a better way of finding out if a video is a short #186

Closed NikkelM closed 1 year ago

NikkelM commented 1 year ago

See #151 The current implementation fails if a video cannot be embedded. An alternative approach would work like this:

await fetch(`https://www.youtube.com/shorts/${randomVideo}`)
    .then(res => {
        response = res;
    });

However, previous tests have shown that this may be a bit slower than the oembed approach. Perhaps both approaches could be bundled, with the second one being the fallback if oembed returns an 'Unauthorized' response.

An alternative approach may be to use a community-driven alternative API which implements a shorts endpoint, as described here. It looks like this custom API variant also allows us to fetch only shorts for a given channel, perhaps it also allows us to fetch normal videos and shorts separately, which we could then save as such in the database from the get-go, without having to separate between the two types whenever shuffling.

NikkelM commented 1 year ago

If no separate videos endpoint is given, we could also fetch both, and remove the intersection of the two from the videos list.

NikkelM commented 1 year ago

Fixed by #200