STEM

How to export a Youtube playlist for free

In this post, I’ll explain the steps to export your playlist on Youtube or one that’s shared with you for free. No, not the actual content like music tracks or videos, as for that, you’ll need a premium account, but the list of names such as artist or author names, tracks or video titles, and additional information.

Steps:

First thing you need to do is go to Google Takeout portal and log in.

Select only YouTube and YouTube Music… near the bottom of the list. Click on “All YouTube data included” in the next popup, Deselect All and select only Playlists.

Click Next step button.
In the next page, set “Transfer to:” to “Send download link via email”
and Frequency to Export once
and click Create export button.

Email will be sent when complete. Actual ETA depends on the size of the playlist…it can go from a few minutes to days. Once you receive the confirmation email, click on the link to download the zip file.

Download and unzip the compressed file…it’ll have a CSV playlist file.

Your CSV playlist file is under zip file> Takeout > YouTube and YouTube Music > playlists > your-playlist.csv
For a music video lst, the csv file will only have Video ID and Timestamp columns at present.
The video ID will be like: ri58RGH931M
(TIP: The video ID can be pasted into Youtube’s search box to get to the actual video, or extract the audio/video using a software designed to download from Youtube if you wish).

Then the choice to get the video information (e.g. artist name, track title), you have 2 choices:

  1. Do it manually by searching by the video ID on youtube, or
  2. Use Google API and code to extract the info from returned JSON response

I wrote my Python code to do that as I have too many on the list to bother myself with the manual method.

Python code:

import requests
import json

def get_video_details(video_id, api_key):
url = f”https://www.googleapis.com/youtube/v3/videos?part=snippet%2CcontentDetails%2Cstatistics&id={video_id}&key={api_key}”
response = requests.get(url)
return response.json()

Replace ‘YOUR_API_KEY’ and ‘VIDEO_ID’ with your actual values

api_key = ‘YOUR_API_KEY’
video_id = ‘VIDEO_ID’
video_details = get_video_details(video_id, api_key)

“Pretty-print” the JSON response

print(json.dumps(video_details, indent=4))

# The JSON output will include the artist and title in most likey “title” key under “snippet” dictionary under “items” array of JSON string.
# e.g.

“items”: [
{
“etag”: “TLuWfpFIOZfDf482O04onOV_HM8”,
“id”: “ri58RGH931M”,
“snippet”: {
“title”: “Jake Bugg – Me And You (Audio)”,

],

       "categoryId": "10",
      ...

WARNING: The JSON output from Youtube is not always accurate because it depends on how the creator/publisher entered the meta tags. It’s all over the place! There are spelling errors, bad grammar, incorrect placement of values, etc. etc. Unfortunately, there’s no foolproof way, really in their wild web repository.

Once you have the JSON output, you’ll need to parse the JSON using your favorite app or coding language (C/C#, Python, even apps like Excel, and more) and save a a pretty list of artists, and track names.

If you don’t have a Google API key, visit this portal first to set up one.

If you’re interested, my music playlist on Youtube is here.

I hope this informative…pass it on! Thanks for reading.



Interested in creating programmable, cool electronic gadgets? Give my newest book on Arduino a try: Hello Arduino!

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top
+