<https://prefect-community.slack.com/archives/CKNS...
# show-and-tell
a
Code Contest This is a simple flow that downloads videos of a playlist in parallel using pytube
Copy code
#!/usr/bin/env python
import argparse
from pytube import Playlist, YouTube
from prefect import task, flow
from pydantic import HttpUrl
from prefect_dask import DaskTaskRunner

@task(retries=3, retry_delay_seconds=4)
def download_video(video: YouTube):
    video.streams.get_highest_resolution().download()
    return

@flow(task_runner=DaskTaskRunner)
def playlist_downloader(playlist_url: HttpUrl):
    p = Playlist(playlist_url)
    for video in p.videos:
        download_video.submit(video)
    return


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Downloads all youtubes videos in a playlist in parallel using the highest available resolution')
    parser.add_argument('playlist', help='a playlist url to download videos')
    
    args = parser.parse_args()
    playlist_downloader(args.playlist)
It is really great that using Prefect we are able to orchestrate this functionality in so few lines of code and use features like running stuff in parallel using Dask and having retry functionality prefect duck
🙌 9
youtube 5
🦜 4
💪 3
prefect2 5
marvin 4
c
First submission! Very cool, thank you for sharing.
❤️ 1