4

I am using Ubuntu 14.04 and youtube-dl to download videos. How can I download videos in respective directory?

e.g. Playlist name is: MyPlaylist, that contains several videos

how can I download videos in directory like: MyPlaylist/index_title.ext

  • have you really not considered specifying an mv command after, to move the file where you want it to be – barlop Oct 30 '15 at 16:05
  • @barlop I wanted to do it on-the-go, with some inbuilt option in youtube-dl. Look at the accepted answer, that perfectly resolves my query. – Piyush Kumar Baliyan Oct 31 '15 at 4:26
  • Sure but you could have put in your question that you wanted to do it without mv, and using functionality of youtube-dl – barlop Oct 31 '15 at 11:58
9

Have you checked the documentation? Specifically the -o, --output option. Using that, you should be able to do:

youtube-dl -o '/home/me/%(playlist_title)s/%(playlist_index)s_%(title)s.%(ext)s'

That said, please be sure to respect the owner's rights with any videos you use this program for.

| improve this answer | |
  • Thanks, That saved me a lot of work. And I'll keep the disclaimer in mind. – Piyush Kumar Baliyan Oct 31 '15 at 4:20
  • @nerdwaller Can you update your answer to add a missing single quote at the end of the code snippet? – Nate Jul 4 at 3:32
  • @Nate done, thanks for the heads up! – nerdwaller Jul 5 at 4:15
1

See Output template examples. https://github.com/ytdl-org/youtube-dl/blob/master/README.md#output-template-examples

# Download YouTube playlist videos in separate directory indexed by video order in a playlist
$ youtube-dl -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re

# Download all playlists of YouTube channel/user keeping each playlist in separate directory:
$ youtube-dl -o '%(uploader)s/%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' https://www.youtube.com/user/TheLinuxFoundation/playlists

My example.

youtube-dl -ci -o "~/dl.folder/%(playlist_title)s/%(title)s-%(id)s.%(ext)s" --write-sub --convert-subs srt -k --download-archive archive.txt --proxy socks5://127.0.0.1:1080/ https://www.youtube.com/channel/UCzBGtBze1AIcDmRwD2ZjiAA

-o, --output TEMPLATE Output filename template, see the "OUTPUT TEMPLATE" for all the info

~

-c, --continue Force resume of partially downloaded files. By default, youtube-dl will resume downloads if possible.

~

-i, --ignore-errors Continue on download errors, for example to skip unavailable videos in a playlist

~

--download-archive FILE Download only videos not listed in the archive file. Record the IDs of all downloaded videos in it.

~

--proxy URL Use the specified HTTP/HTTPS/SOCKS proxy. To enable SOCKS proxy, specify a proper scheme. For example socks5://127.0.0.1:1080/. Pass in an empty string (--proxy "") for direct connection

~

--write-sub Write subtitle file

~

-k, --keep-video Keep the video file on disk after the post-processing; the video is erased by default

~

--convert-subs FORMAT Convert the subtitles to other format (currently supported: srt|ass|vtt|lrc)

ref:

https://ytdl-org.github.io/youtube-dl/index.html

https://github.com/ytdl-org/youtube-dl/blob/master/README.md

https://github.com/ytdl-org/youtube-dl/blob/master/README.md#output-template

youtube-dl --help (youtube-dl --version 2019.08.13)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.