Find the playlists a video is in via Youtube API

Rudie picture Rudie · Dec 23, 2012 · Viewed 7.6k times · Source

I want to know which playlists contain a certain video. The opposite is easy: find which video's are in a playlist, but I don't want that.

I can already have YT do this via the following route, but that's stupid and slow:

  • get channelId from video data (videos?id=...)
  • get playlists from channelId (playlists?channelId=...)
  • loop through all playlists and find all their videos (playlistItems?playlistId=...)

Like I said: stupid and slow. These steps are possible, because I only want playlists authored by the video's author. (Otherwise I'd have to download all of YT.)

What I'm looking for, sort of, is a request: playlists?videoId=..., but of course that doesn't exist.

Is there a better way than my 3 steps?

PS. I've created the script to use my 3 steps, but it's A LOT of requests. That and the playlists don't seem to have usable playlist ID's... I need the ID that the browser uses to show the playlist GUI style.

Answer

Martin Müller picture Martin Müller · Aug 16, 2013

As of now, the Youtube API does not support a call like this, and in my opinion never will. This is probably an intentional decision by Youtube to hide the playlists, even the YT Analytics API doesn't show how many lists use your video.

It seems the way you do it is the only workaround - in case you only need the playlists for one specific user.