Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- import yt_dlp
- def get_channel_names(playlist_url):
- with yt_dlp.YoutubeDL() as ydl:
- info = ydl.extract_info(playlist_url, download=False)
- channels = []
- for video in info['entries']:
- channels.append(video['channel_id'])
- return channels
- def download_channels(channels, output_dir):
- for channel in channels:
- print("Downloading channel:", channel)
- os.makedirs(os.path.join(output_dir, channel), exist_ok=True)
- for video in yt_dlp.YoutubeDL().extract_info(f"https://www.youtube.com/channel/{channel}/videos", download=False)['entries']:
- yt_dlp.YoutubeDL({'outtmpl': os.path.join(output_dir, channel, '%(title)s.%(ext)s')}).download(video['webpage_url'])
- if __name__ == "__main__":
- playlist_url = sys.argv[1]
- output_dir = sys.argv[2]
- channels = get_channel_names(playlist_url)
- download_channels(channels, output_dir)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement