🔍 How To List All Videos in a YouTube Channel (For Obsidian)
Prerequisites:
- Python
- yt-dlp
- YouTube Channel ID, Found here: https://www.youtube.com/account_advanced
Code:
import subprocess
import json
import re
playlist_url = "https://www.youtube.com/playlist?list=UUpdrY4TWv2GhlCNjiATkugg"
result = subprocess.run(
["yt-dlp", "--flat-playlist", "-J", playlist_url],
capture_output=True,
text=True
)
data = json.loads(result.stdout)
def escape_markdown(text):
# Escape characters that could break markdown or Obsidian links
return re.sub(r'([\[\]#*`_])', r'\\\1', text)
for entry in data.get("entries", []):
raw_title = entry.get("title", "Untitled")
clean_title = escape_markdown(raw_title)
video_id = entry.get("id", "")
url = f"https://www.youtube.com/watch?v={video_id}"
# Format: [[Title]] - [Video](URL)
print(f"[[{clean_title}]] ([Video]({url}))")
Disclaimer
The above was Vibe Coded, it may not be the most efficient way of doing this.
Caveats
- The links don't play nice with Obsidian's formatting, so some safety things are included