List All Videos On A Youtube Channel π π
Best for channels with < 50 videos.
Limitations: Time-consuming, no metadata (views, date, duration).
How it works:
Pros:
Cons:
Example command:
yt-dlp --flat-playlist --print "%(title)s, %(id)s, %(upload_date)s" https://www.youtube.com/@ChannelHandle/videos
"videoId": "abc123",
"title": "Example",
"publishedAt": "2024-03-01T12:00:00Z",
"description": "...",
"duration": "PT5M30S",
"viewCount": 12345,
"thumbnail": "https://...",
"privacyStatus": "public"
for v in videos: print(v["title"], v["url"]) list all videos on a youtube channel
links = [a.get_attribute("href") for a in driver.find_elements(By.CSS_SELECTOR, "#video-title")]
Pros: No API key, works for any channel.
Cons: Slow, breaks if YouTube changes DOM, needs maintenance.
Limitation: Tedious for channels with hundreds of videos. Best for channels with < 50 videos
Simulates scrolling and scrapes data. Use when API is overkill or blocked.
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
driver = webdriver.Chrome()
driver.get("https://www.youtube.com/@ChannelHandle/videos")
last_height = driver.execute_script("return document.documentElement.scrollHeight")
while True:
driver.execute_script("window.scrollTo(0, document.documentElement.scrollHeight);")
time.sleep(3)
new_height = driver.execute_script("return document.documentElement.scrollHeight")
if new_height == last_height:
break
last_height = new_height






