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

Question:

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.

Asked By: Lv_InSaNe_vL

||

Answers:

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=Xge20AqKSRE 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.

Answered By: Benjamin Loison