Search code examples
pythonvideodownloadscriptingyoutube-dl

How can I download and sort the videos based on topic wise while downloading from youtube_dl python script?


When I download the playlists from udemy, all videos are saved into a single folder. My requirenment is I want to save them in different folders as per topic. For that I used python script youtube-dl.

Can anyone help me for this?


Solution

  • Provide an output template with the -o option, like this:

    youtube-dl -o 'downloaded/%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s'
    

    followed by your playlist URL(s) and other options.

    There is a lot of possible metadata that can be included in the filename, e.g. episode/track number, video resolution, description, autogenerated numbers, download protocol, artist, genre, release date and the like. Refer to the documentation for the full list.

    Note that not all websites and not all videos support all metadata properties. To see all the metadata available for one specific URL, use the -J option (pipe it through jq to format/select), for instance with:

    youtube-dl -J PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re | jq .