1

Is it possible to make a list of title and thumbnail of videos of playlist? Then we can try to run macros or cronjob to automate it in regular basis.

So I'm a newbie here. I've found out today that more than 25 of my fav videos are gone from YouTube playlist which is irrecoverable as far as I know by now. Anyways that brings me an idea to try to make or perhaps if already exists such program, then trying to find out. Is it possible to make a list of title and thumbnail of videos of playlist? Then we can try to run macros or cronjob to automate it in regular basis. I know that it's possible to get title list from yt-dlp but how can I integrate thumbnail to the list? Or are there such site/program exist already? Any help is very much appreciated. For the information, I'm basically on Android.....so any python/ html/site/android app solution Will be very much helpful in this regard.

  • 1
    It seems that you are looking for [YouTube Data API v3](https://developers.google.com/youtube/v3) [PlaylistItems: list](https://developers.google.com/youtube/v3/docs/playlistItems/list) endpoint. – Benjamin Loison Dec 28 '22 at 18:01
  • Could you be a lil bit elaborate? Pretty much everything went over. my mind. Although thank you for first comment ☺️ – Ragib Rownak Dec 28 '22 at 18:17

1 Answers1

1

You are looking for YouTube Data API v3 PlaylistItems: list endpoint. You can use it the following way in Python:

import requests, json, csv

API_KEY = 'AIzaSy...'
PLAYLIST_ID = 'YOUR_PLAYLIST_ID'

with open('playlist.csv', 'w') as csvFile:
    csvWriter = csv.writer(csvFile)
    csvWriter.writerow(['videoId', 'title', 'thumbnails'])

    pageToken = ''
    while True:
        url = f'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet,contentDetails&playlistId={PLAYLIST_ID}&maxResults=50&pageToken={pageToken}&key={API_KEY}'
        content = requests.get(url).text
        data = json.loads(content)
        for item in data['items']:
            print(json.dumps(item, indent=4))
            snippet = item['snippet']
            csvWriter.writerow([snippet['resourceId']['videoId'], snippet['title'], snippet['thumbnails']])
        if 'nextPageToken' in data:
            pageToken = data['nextPageToken']
        else:
            break
Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
  • Is it possible to retrieve at least the thumbnail or just title of unavailable videos? About 40 videos have vanished overnight from my playlist. I can live without them though but if possible then it'd be nice. – Ragib Rownak Dec 29 '22 at 17:41
  • Can you give an example of video id that is *unavailable*? If I solved your initial question, think about [interacting positively towards my answer](https://stackoverflow.com/help/someone-answers). – Benjamin Loison Dec 29 '22 at 18:53
  • https://www.youtube.com/watch?v=iwSw0r9FkYU&list=PLXFzz_xH35n39TzOIWmJqDVbQJmPLttEZ&index=21 – Ragib Rownak Dec 31 '22 at 20:04
  • It is showing private. I don't need the video at least if I get the name, it'd be fine. – Ragib Rownak Dec 31 '22 at 20:05