ajayyy / SponsorBlock

Skip YouTube video sponsors (browser extension)
https://sponsor.ajay.app
GNU General Public License v3.0
10k stars 321 forks source link

Investigate alternative video info API (used for determining if a video is new and whitelisting) #751

Closed ajayyy closed 3 years ago

ajayyy commented 3 years ago

The API previously used to get channel IDs doesn't work anymore (https://github.com/ajayyy/SponsorBlock/issues/741). Right now, it is reading the channel ID from the page, but this is slow as that part of the page loads late. It also does not work on Invidious embeds.

Another method to determine this, such as by an API call, would solve this.

fluffy-critter commented 3 years ago

If you're able to do OAuth signin, the YouTube data API has videos.list; if you call it with a part of snippet, the returned data will include the channel ID.

However I think this approach does require registering your app with Google and there's a quota on it; by default you can only query this API 10,000 times a day, although you can ask Google to get that raised. (Although considering the nature of this extension they probably wouldn't be particularly happy to.)

ajayyy commented 3 years ago

They don't like that it "modifies the YouTube UI", so refused my quota extension, so it will have to be through an unofficial API.

fluffy-critter commented 3 years ago

Yeah, that's unfortunate, but expected. Oh well. Hopefully you can find something... I've noticed that YouTube is lately very aggressive about detecting anything that looks like data scraping and they're going out of their way to prevent it. I wouldn't be surprised if they purposefully made the channel ID take longer to show up just to prevent things like this from working well.

FireMasterK commented 3 years ago

You could give my API a try: https://pipedapi.kavin.rocks/streams/dQw4w9WgXcQ

The channel id can be found in uploaderUrl in the JSON response.

I also have servers in 3 locations which should help you with latency, wherever it is.

ajayyy commented 3 years ago

@FireMasterK Thanks, but I don't want to leak the videoID to any 3rd party services, since the extension now uses https://github.com/ajayyy/SponsorBlockServer/issues/25 to prevent leaking the videoID to the SponsorBlock server.

FireMasterK commented 3 years ago

In that case, you could consider using the innertube api for this which should have this information.

ajayyy commented 3 years ago

https://github.com/zerodytrash/Simple-YouTube-Age-Restriction-Bypass/commit/1874086c0fed5d7c7bbfa1ccd6a56be3229bdae1

This might only work or the initial video.

ajayyy commented 3 years ago

Adding &html5=1 seems to make the API work again