Youtube
Go to google takeout. Deselect. go down to youtube at the bottom. Change the exports to subscriptions/playlists/channels Hmm. Way too clunk. The playlistso nly have vid id. Not good enough. Could write script I guess.
https://www.reddit.com/r/DataHoarder/wiki/index/
https://www.reddit.com/r/DataHoarder/comments/dxn6fx/is_there_any_way_to_export_a_youtube_playlist/
youtube-dl is the way to go I guess
youtube-dl --flat-playlist --dump-json https://www.youtube.com/playlist?list=PLqggUNm8QSqldCY-MrUktblGeaQOVRt2L > prog10.json
https://github.com/yt-dlp hmm this is better?
https://www.youtube.com/playlist?list=WL
yt-dlp --cookies-from-browser firefox --flat-playlist --dump-json "https://www.youtube.com/playlist?list=WL" > watchlater.json
chatgpt made this script for extraction
import json
import glob
import os
# Path to the directory containing your JSON files
JSON_DIR_PATH = './'
MARKDOWN_FILE_PATH = './all_playlists.md'
def load_playlists(json_dir_path):
"""
Load playlists data from all JSON files in the specified directory.
"""
playlists = {}
json_files = glob.glob(os.path.join(json_dir_path, '*.json'))
for file_path in json_files:
with open(file_path, 'r') as file:
filename = os.path.basename(file_path)
playlists[filename] = []
for line in file:
try:
playlists[filename].append(json.loads(line))
except json.JSONDecodeError as e:
print(f"Error decoding JSON from file {file_path}: {e}")
return playlists
def playlists_to_markdown(playlists):
"""
Convert a list of playlists to a markdown string.
"""
markdown_str = "# YouTube Playlists\n\n"
for filename, videos in playlists.items():
markdown_str += f"## {filename}\n\n"
for video in videos:
title = video.get('title', 'No title available')
video_id = video.get('id', 'No ID available')
url = f"https://www.youtube.com/watch?v={video_id}" if video_id != 'No ID available' else 'No URL available'
markdown_str += f"### [{title}]({url})\n\n"
markdown_str += "---\n\n"
return markdown_str
def save_to_file(content, filename):
"""
Save a string to a markdown file.
"""
with open(filename, 'w') as file:
file.write(content)
if __name__ == "__main__":
playlists = load_playlists(JSON_DIR_PATH)
markdown_content = playlists_to_markdown(playlists)
save_to_file(markdown_content, MARKDOWN_FILE_PATH)
print(f"All playlists saved to {MARKDOWN_FILE_PATH}")