Decicus / DecAPI

API provider/proxy that provides plaintext responses - Documentation: https://docs.decapi.me/
https://decapi.me/
MIT License
118 stars 23 forks source link

[YouTube] Exclude shorts from YouTube API #99

Closed nthnwllms closed 10 months ago

nthnwllms commented 1 year ago

I've been using your API with Nightbot for calling the latest videos and love it and the service you provide. With the introduction of shorts, I noticed that it now returns a short as the latest video which isn't ideal for most creators in my opinion. Is there any chance of implementing a way to filter them out from this call?

A simple work around would be to use the playlist and add all videos to a playlist it can pull from that list and exclude shorts from it but it's just a work around 🤷‍♂️

c4ldas commented 1 year ago

You can create a specific tag for your shorts, add it to the title, like shorts or #shortsand use exclude=shorts parameter to ignore all short videos https://decapi.me/youtube/latest_video?user=nthnwllms&exclude=shorts

Decicus commented 1 year ago

The current YouTube API that DecAPI relies on doesn't contain any information that could be used to filter out shorts reliably. It essentially only gives the YouTube video ID (which can be used for the URL) and the video title.
The "band-aid" solution mentioned by c4ldas was then implemented for those that include something like #shorts in the video title, but I'm aware it's not ideal.

There are other YouTube APIs that can be used to get more information about a video once the video ID has been retrieved, such as the video length, but it'd cost more in terms of the YouTube API quota that DecAPI has allocated.

I do want to explore it a bit more to see if I can implement something properly, but no guarantees.

nthnwllms commented 1 year ago

Perfect solution, thanks for shedding light on that @c4ldas

Understand not wanting to eat up any more of your API quota. Appreciate all the work you've done thus far 😄

Decicus commented 1 year ago

@1265578519 Your comment wasn't relevant to this issue. Please open a separate issue, if there's any problems with the Twitch ingests API endpoint: https://github.com/Decicus/DecAPI/issues/new

Sorry for the notifications to those of you subscribed to this issue.

Decicus commented 1 year ago

This is now live. Add no_shorts=1 as a parameter and any shorts (videos shorter than 1 minute) will be excluded.
Example: https://decapi.me/youtube/latest_video?id=UCJ6td3C9QlPO9O_J5dF4ZzA&no_shorts=1

sylverr commented 11 months ago

Hey, thanks for adding this, it's quite useful. Would it be possible to exclude videos that are shorter or equal than 1 minute ? Some shorts can be 1 minute long and therefore not excluded 😄

Decicus commented 11 months ago

@sylverr

Hey, thanks for adding this, it's quite useful. Would it be possible to exclude videos that are shorter or equal than 1 minute ? Some shorts can be 1 minute long and therefore not excluded 😄

I suppose I should've expected this. Mind linking me an example so I can properly test with it?

sylverr commented 11 months ago

This video for exemple : https://www.youtube.com/watch?v=Fe_bCVr8dxY (that's the only exemple, plz no judgment 🥲)

c4ldas commented 11 months ago

This video for exemple : https://www.youtube.com/watch?v=Fe_bCVr8dxY (that's the only exemple, plz no judgment 🥲)

Ohh, not related to the issue, but I just realized that if you change the /shorts/ to /watch?v= from the URL, it shows as a normal video and we have access to the player controls 😲

Decicus commented 10 months ago

In case it needs to be said: That "Binance Airdrop" comment is a scam. Don't click any links in it.
I've already deleted the comment, but I imagine some of you got emails about it, so figured I'd mention it.

Decicus commented 10 months ago

Sorry it took me a bit to get around to implementing a fix for this. @sylverr Should hopefully be fixed now :)

Any videos that are 1m1s (61 seconds) or less will be considered a "short". I believe this is how YouTube does it, at least.
If anyone finds one that is considered a short by YouTube, but still gets included with no_shorts, feel free to comment again (preferably with the video in question so I can check).

sylverr commented 10 months ago

Sorry it took me a bit to get around to implementing a fix for this. @sylverr Should hopefully be fixed now :)

Any videos that are 1m1s (61 seconds) or less will be considered a "short". I believe this is how YouTube does it, at least. If anyone finds one that is considered a short by YouTube, but still gets included with no_shorts, feel free to comment again (preferably with the video in question so I can check).

No problem ! Thank you for taking some time to fix it ! I think it should be alright, I also exclude shorts on one of my project and I do the same, I haven't had any issues yet so I guess it should be fine :)