40

How can I view what playlist, if any, a video is in?

For example: http://www.youtube.com/watch?v=QuqCMHe4kxQ

This longer link shows what playlist the video is in, and it's in a playlist, but I only see that at this link but this link only seems to come up when clicking the video in a playlist. So I can see what playlist it's in.

But what if I didn't have that link?

http://www.youtube.com/watch?v=QuqCMHe4kxQ&list=PLD5DC2D06E087D609&index=4

Another example of a video I'd want to know what playlist, if any, it's in, is this one:

http://www.youtube.com/watch?v=xB2ZtKsYjFA  
0

4 Answers 4

26
+50

Short answer

For the example in the question, on Google, try something like the following:

site:youtube.com inurl:(QuqCMHe4kxQ list)

or

inurl:list QuqCMHe4kxQ

(Thanks to Annan)

Explanation

site: and inurl: are Google Search advanced operators.

  • site: limits results to the specified site, in this case youtube.com
  • inurl: limit results to URL having the specified strings, in this case the video id QuqCMHe4kxQ and the parameter name list.
  • parenthesis groups search terms, they help us to avoid having to repeat the same search operator several times.
  • If you want a exhaustive list of playlists you should try several operator and keyword search combinations.

It's worth to say that there is a Youtube API. AFAIK it doesn't include methods to query the search youtube search index to find all the playlists that include a video by its id.

8
  • 1
    It's worth noting that this will only work if an external website has a link to the playlist. My example was trying to find this playlist using this search site:youtube.com inurl:(k2_wuThLG6o list) which returned no results. However the video is evidently in the playlist (it's the intro). It was published 2 years ago so I doubt it is google catching up.
    – AnnanFay
    Oct 25, 2016 at 1:06
  • In other words the URL including the list id should be indexed. Oct 25, 2016 at 2:18
  • I wouldn't use the word 'should' since this implies Google is doing something wrong, or that we have an expectation for it to be indexed. But, yes, the link must be indexed for this method to work.
    – AnnanFay
    Oct 25, 2016 at 16:36
  • How do you found the playlist for your video? Are you doing the course? (As I understand the video is an introduction to an MIT OpenCourseWare course) Oct 25, 2016 at 16:38
  • 1
    The intro video description says the course is "MIT 4.241J", if you search google for inurl:list intitle:"MIT 4.241J" you get the playlist. This method only works for courses where the playlist names and video descriptions contain the course code. Now, something which might work is site:youtube.com inurl:list k2_wuThLG6o, however this gives no results. But inurl:list k2_wuThLG6o gives two results - both which contain the video.
    – AnnanFay
    Oct 25, 2016 at 16:48
7

All methods described here seems to have stopped working. I found a way of doing it directly on the YouTube-site though that seems to work in most cases:

Search for the video title and the channel name in the top search bar, then on the result page, choose to filter on "Playlists"

Like this https://www.youtube.com/results?search_query=%22The+Amazing+Universe+%28through+the+eyes+of+a+scientist%29%22++Thunderf00t&sp=EgIQAw%253D%253D

6

Update: It seems Google removed this functionality and it no longer returns valid results.

Just use Google Advanced Search if you do not want to bother with remembering the semantics and fill the data as in the image:

enter image description here

The quotes from the search string will make sure you do not have duplicate results like these 2 since it is the same playlist:

www.youtube.com/watch?v=QuqCMHe4kxQ&list=PLDEEFF9F4E7272A22&index=5
www.youtube.com/watch?v=QuqCMHe4kxQ&index=5&list=PLDEEFF9F4E7272A22

You can search in youtube.com or www.youtube.com depending on how many results you want and narrow further your results by different criteria.

2
  • Doesn't work anymore. I have tried to find a solution for a long time, even learned the entire YouTube API. No solution. Even using the API you cannot find a playlist by video ID. For some reason they don't expose the relationship between a playlist and a video.
    – monstro
    Mar 18, 2021 at 11:36
  • It seems Google removed this functionality... probably for privacy reasons...
    – Tiberiu
    Mar 19, 2021 at 12:08
0

Although this python script doesn't have a look at all the playlists across youtube, it will only have a look at the playlists that belong to a channel for finding all the playlists that will match a given video id.

Before running this script, make sure to install Python 3 and then install google-api-python-client by using this in the operating system's terminal:

pip install google-api-python-client

Also follow this tutorial on how to get your API key.

You have to fill in these fields in the script with your own values:

API_KEY 
VIDEO_ID
CHANNEL_INPUT    

Python script:

from googleapiclient.discovery import build

API_KEY = 'API_KEY'
youtube = build('youtube', 'v3', developerKey=API_KEY)

VIDEO_ID = 'YOUR_VIDEO_ID' # Replace with the video ID you're checking

CHANNEL_INPUT = 'CHANNEL_ID_OR_CUSTOM_NAME'  # Replace with either CHANNEL ID ('UC...') or CUSTOM NAME ('@CustomName')

def find_channel_id_by_custom_name(custom_name):
    search_response = youtube.search().list(
        q=custom_name,
        part='snippet',
        type='channel',
        maxResults=1
    ).execute()

    if search_response['items']:
        return search_response['items'][0]['snippet']['channelId']
    else:
        return None

def list_channel_playlists(channel_id):
    playlists = []
    next_page_token = None
    while True:
        response = youtube.playlists().list(
            part='snippet',
            channelId=channel_id,
            maxResults=50,
            pageToken=next_page_token
        ).execute()

        playlists += response.get('items', [])
        next_page_token = response.get('nextPageToken')
        if not next_page_token:
            break
    return playlists

def is_video_in_playlist(playlist_id):
    next_page_token = None
    index = 1
    while True:
        response = youtube.playlistItems().list(
            part='snippet',
            playlistId=playlist_id,
            maxResults=50,
            pageToken=next_page_token
        ).execute()
        
        for item in response.get('items', []):
            if item['snippet']['resourceId']['videoId'] == VIDEO_ID:
                return True, index
            index += 1
        
        next_page_token = response.get('nextPageToken')
        if not next_page_token:
            break
    return False, None

def main(channel_id_or_custom_name):
    if channel_id_or_custom_name.startswith('UC'):
        channel_id = channel_id_or_custom_name
    else:
        channel_id = find_channel_id_by_custom_name(channel_id_or_custom_name)
        if not channel_id:
            print(f"Could not find channel ID for: {channel_id_or_custom_name}")
            return

    playlists = list_channel_playlists(channel_id)
    print(f"Found {len(playlists)} playlists in the channel.")

    for playlist in playlists:
        playlist_id = playlist['id']
        found, index = is_video_in_playlist(playlist_id)
        if found:
            video_url = f"https://www.youtube.com/watch?v={VIDEO_ID}"
            playlist_url = f"https://www.youtube.com/playlist?list={playlist_id}"
            combined_url = f"{video_url}&list={playlist_id}&index={index}"
            print(f"Video {VIDEO_ID} is in playlist: {playlist['snippet']['title']} ({playlist_id})")
            print(f"Video URL: {video_url}")
            print(f"Playlist URL: {playlist_url}")
            print(f"Combined URL: {combined_url}")
            break
    else:
        print("Video is not in any of the channel's playlists.")

if __name__ == "__main__":
    main(CHANNEL_INPUT)

For example, for these two fields:

CHANNEL_INPUT = 'RedBullRally'

or

CHANNEL_INPUT = 'UC2492xZi4QffVBZkX4h_Mbw'

# Full channel URL:
# https://www.youtube.com/@RedBullRally

VIDEO_ID = 'Q4tY92MuCiU' # This video belongs to the youtube channel above

# Full video URL:
# https://www.youtube.com/watch?v=Q4tY92MuCiU

I got this result:

Found 65 playlists in the channel.
Video Q4tY92MuCiU is in playlist: Dakar Rally 2024 (PLE6DWjoc4itod2z5bKXdXhKPmkRl17ju4)
Video URL: https://www.youtube.com/watch?v=Q4tY92MuCiU
Playlist URL: https://www.youtube.com/playlist?list=PLE6DWjoc4itod2z5bKXdXhKPmkRl17ju4
Combined URL: https://www.youtube.com/watch?v=Q4tY92MuCiU&list=PLE6DWjoc4itod2z5bKXdXhKPmkRl17ju4&index=3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.