43

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  
pnuts
  • 17,883
  • 5
  • 55
  • 103
barlop
  • 3,223
  • 13
  • 39
  • 55

4 Answers4

28

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.

Rubén - Volunteer Moderator -
  • 46,305
  • 18
  • 101
  • 297
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

Martin Odhelius
  • 179
  • 1
  • 1
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.

Tiberiu
  • 169
  • 1
  • 4
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
rd51
  • 101
  • 2