Advertisement
samicrusader

Untitled

Jul 29th, 2023
926
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. import os
  2. import sys
  3. import yt_dlp
  4.  
  5. def get_channel_names(playlist_url):
  6.     with yt_dlp.YoutubeDL() as ydl:
  7.         info = ydl.extract_info(playlist_url, download=False)
  8.         channels = []
  9.         for video in info['entries']:
  10.             channels.append(video['channel_id'])
  11.         return channels
  12.  
  13. def download_channels(channels, output_dir):
  14.     for channel in channels:
  15.         print("Downloading channel:", channel)
  16.         os.makedirs(os.path.join(output_dir, channel), exist_ok=True)
  17.         for video in yt_dlp.YoutubeDL().extract_info(f"https://www.youtube.com/channel/{channel}/videos", download=False)['entries']:
  18.             yt_dlp.YoutubeDL({'outtmpl': os.path.join(output_dir, channel, '%(title)s.%(ext)s')}).download(video['webpage_url'])
  19.  
  20. if __name__ == "__main__":
  21.     playlist_url = sys.argv[1]
  22.     output_dir = sys.argv[2]
  23.     channels = get_channel_names(playlist_url)
  24.     download_channels(channels, output_dir)
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement