Check and see if video is available on YouTube Music using the YouTube API
Asked Answered
T

1

2

Hey guys I'm working on a little project to automate some of my playlists on YouTube Music, although I am running into a problem where some of the songs I am finding are available on YouTube, but not YouTube Music specifically.

Right now I am just running a check to see if the page returns a 404 which sort of works, except YouTube music likes to just auto play the next song if the requested song is unavailable so I'll need a bit more robust system.

For a bit of an example, you can go to this video on YouTube with a video ID of Xge20AqKSRE on YouTube you can watch the video no problem, although it is unavailable on YouTube Music. If you try this other link you get a little popup in the bottom left saying "This song is unavailable. Skipping to the next one." which is a problem since right now I'm just checking to see if the page returns a 404, which this obviously wont.

I have been digging through the YouTube API but I cannot find anything specific to YouTube Music.

Thisbee answered 6/2, 2022 at 19:19 Comment(2)
"except YouTube music likes to just auto play the next song if the requested song is unavailable so I'll need a bit more robust system." I don't understand what you mean. Does YouTube music skip the problematic video or is blocked in some way ? Could you provide an example of playlist leading to your issue ?Wire
@BenjaminLoison yes, I can provide a better example. If you go to this link with a video ID of Xge20AqKSRE on YouTube you can watch the video no problem, even though this video is unavailable on YouTube Music. You can try this with this other link, what should* happen is you get a little popup in the bottom left saying "This song is unavailable. Skipping to the next one." which is a problem since right now I'm just checking to see if the page returns a 404, which this obviously wont.Thisbee
W
4

AFAIK YouTube Data API v3 doesn't provide support for knowing whether or not a given video isn't supported in YouTube Music.

However the feature you are looking for is available in my YouTube operational API, indeed by requesting https://yt.lemnoslife.com/videos?part=music&id=F3cXzL266TE you'll receive a JSON with available equals to true if the video is available on YouTube music, false otherwise. That way https://yt.lemnoslife.com/videos?part=music&id=ntG3GQdY_Ok returns available true while the first link returns available false.

If you have any question don't hesitate to comment or come to the Discord support.

Wire answered 7/2, 2022 at 0:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.