12 ms·
Show HN: Interactively select the quality and format for youtube-dl
- synox 7y agoPS: I coded this in an evening. This proves for me that nodejs makes it so easy to make beautiful CLI apps. It is simple and makes may life easier. See more node cli tools at: https://github.com/sindresorhus/awesome-nodejs#command-line-utilities https://github.com/sindresorhus/awesome-nodejs#command-line-...
- reimertz 7y agoJust so you know, the tool is great, the code looks fine and the link is appreciated. I think the reason why you get down voted is because your comment could be read as you humble bragging. Don't take it personally though, I've done similar posts/comments in the past and it took me quite some time to realize comments with this tone can be discouraging for people just getting into software engineering. So please continue creating awesome tools like this and share it with us all and don't be discouraged. We all love to see tools like this. :)
- arcticfox 7y agoThat's great, it's a cool tool, but I don't understand why this couldn't have been done in a similar amount of time in a different language. I think if you replace "nodejs" with "English" in the sentence it might explain why people are downvoting; it just doesn't really mean anything.
- nextlevelwizard 7y agoJust few questions checking the repo. Why are you using meow? It seems like you are just using it to grab args and print help. Does it do something that is not immediately apparent? It has a lot of dependencies that might be completely useless for you. log-symbols seems also completely useless dependency, you could just add the two symbols you are using by hand. Is it doing something special? As for nodejs making things easier. Maybe it's just what you are used to. There isn't much code here, but I'm guessing node_modules is going to be pretty large. I think you could make this work just as well using any language. I guess the bonus here is that this is portable (compared to implementing with bash), but since youtube-dl (as far as I know) is made with Python, maybe it would have been better to make this TUI using Python as well since at least the user will have it installed.
- synox 7y agoYes I will clean up those dependencies. Yeah Node is just what I know best. Or Java - haha, but that would not make a good CLI <-D
- Mister_Snuggles 7y agoOn a side-note, can you recommend any good TUI libraries for Python? I've got a mini project that a decent TUI would potentially work very well for.
- nextlevelwizard 7y agoSorry, I don't have any ready recommendations up my sleeve. Pretty much only CLI library I use is argparse.
- malvosenior 7y agoThanks for making this. I'd say that Node does not make good CLI apps though. It means I have to install it on my machine in order to use your program. The best CLI apps are made with compiled languages so you can distributed them without a runtime, third party libs...
- w56rjrtyu6ru 7y agoStatically link ALL the things!
- paol 7y agoI just have an alias with the format codes I want in order of preference (youtube-dl allows that) That's a very nice interactive ui though
- StavrosK 7y agoCan you post the alias?
- aepiepaey 7y agoIt's well-documented in youtube-dl's readme: https://github.com/ytdl-org/youtube-dl#format-selection https://github.com/ytdl-org/youtube-dl#format-selection It has examples as well: https://github.com/ytdl-org/youtube-dl#format-selection-examples https://github.com/ytdl-org/youtube-dl#format-selection-exam...
- StavrosK 7y agoOh nice, thank you, I never saw the examples page.
- aepiepaey 7y agoYou don't even need an alias, you can just stick the flag in ~/.config/youtube-dl/config instead.
- klntsky 7y agoThis is too trivial to share, IMO. Anyway, shell is more suitable for this kind of programs: you could write a bash script that ties together youtube-dl and dmenu or fzf or whatever within an hour.
- hnlmorg 7y agoI think this is probably their first CLI tool. Maybe even their first node project? So that's probably where the excitement comes from. And if that's the case then I can appreciate that. Personally I'd probably go a similar approach as yourself but that's purely because I don't have node installed.
- onion2k 7y agoThis is too trivial to share, IMO. How do you define complexity threshold for something being worth sharing? More to the point, why do you define that threshold? What benefit is there to saying someone's work that they're sharing has to be sufficiently complicated? Simple things can be immensely useful and well worth sharing.
- C4stor 7y agoWhy would there be a link between trivial and worth sharing? On the contrary, I find that a lot of tools I'm happy to have are the trivials one. Who have never used whoami for example ? It's two chained system calls, but I'm still glad it's baked in and I don't have to rewrite it everywhere I use it.
- synox 7y agoA bash script would be shorter for sure. I just could not find any that does the job. And those 50 line bash scripts tend to be hard to distribute and maintain IMHO.
- CaptainMarvel 7y agoI struggle to use youtube-dl due to the abundance of parameters, and this gave me the realisation that it is missing interactive mode! So, I'm quite grateful that this person shared their creation.
- cm-t 7y agoplease, need a snap to install it!
- howiroll 7y ago380 dependencies for like 30 lines of bash script. Javascript became the cancer of the Internet.
- modzu 7y agoi don't know either project but on the surface doesn't this seem like it would be a welcome PR?
- monsieurbanana 7y agoI'm generally against adding interactive features to CLI programs if there isn't a good reason for that. I don't want to remember which options I can/can't use in a non-interactive script. Plus youtube-dl already has multiple GUI/wrappers, so there's already a separation for interactive features.
- w56rjrtyu6ru 7y agoPeople gotta realize that Node.js is actually excellent for this sort of task. It hits quite a few sweet spots as an all-round Unix scripting language: * Familiar syntax and semantics (Bash/Zsh/Fish/Csh/Ksh/Ash/Wtfsh are all way weirder than JS - and they are _only_ scripting languages, while JS is already everywhere) * Standard library (https://nodejs.org/dist/latest-v12.x/docs/api/fs.html https://nodejs.org/dist/latest-v12.x/docs/api/fs.html) gives you access to POSIX APIs ("batteries included" - but not bloated) * Sane packaging, package management, and ecosystem (overreliance on third-party module is a thing exactly because NPM works with much less friction than e.g. the Python situation) * Asynchronous event model lets you safely do multiple things in parallel without worrying about low-level memory management, or which concurrency boilerplate library to use, etc. All in all, it's the perfect Unix glue. All it misses is a mature S-expression-based syntax. For example, take the problem of locking your encrypted partitions before suspending your Linux machine. Since distro developers are too "busy" to provide what one might say is basic functionality, power users took matters in their own hands and wrote this 100-ish line Bash script (https://github.com/vianney/arch-luks-suspend https://github.com/vianney/arch-luks-suspend), which evolved into this 1500-ish line Go monstrosity (https://github.com/guns/go-luks-suspend https://github.com/guns/go-luks-suspend)... as well as these ~75 lines of Node.js (https://github.com/egasimus/node-luks-suspend https://github.com/egasimus/node-luks-suspend). But yeah, sure, hurr durr JaavaaScriipt baad, 0.1+0.2!==0.3, 'true'==true, etc... The horror!
- StavrosK 7y agoAll of these features are things other languages have too (I personally disagree that npm's "download the world" model is better than Python's envs). A huge drawback Node has is that it's not installed by default on any Linux distribution I know of, so I'd take a Python script over a Node one any day. Compiled languages have an even better distribution story, and Rust's Cargo is nothing to laugh at. I'm not sure what you hope your posted comparisons show, but the Go "monstrosity" seems to have many more features than the Node one.
- pushpop 7y agoSure, the the node code uses fewer lines than the Go code. But what you’ve failed to notice is the Go code calls APIs directly rather than fork()ing and does so within its own code base (how many lines of code is in the countless imports of your node example?). Plus the Go code also has unit tests which the others don’t. Line numbers are always a terrible metric for proving anything but in this case your especially abusing that data.
- chapium 7y agoRemembering flags is hard? Are shell scripts no longer a thing?
- onion2k 7y agoRemembering flags is hard, yes. If you use a lot of different apps remembering the flags for something you use infrequently is a pain. I don't think I've ever used ffmpeg without looking at the docs first. As for shell scripts, they are a thing, and this thing is one (just written in node rather than bash.)
- mixmastamyk 7y agoIt's not that bad. Captain Obvious example: command -h # or --help For ffmpeg (and other huge cli) I use my shell history, man page, and Super User site. Then edit the params.
- sametmax 7y agoWell... https://xkcd.com/1168/ https://xkcd.com/1168/ So I understand the sentiment.
- amelius 7y agos/shell scripts/manpages/
- exabrial 7y agoYoutube-dl is one those things I wish could stay under the radar.
- xwdv 7y agoDon’t see why, if anything more people should know about it so shared content can become more redundant as people download it across the world. YouTube is a fairly brittle hub sometimes with all the takedowns.
- Wowfunhappy 7y agoI suspect the GP is concerned Youtube will take steps to block it. This scares me a bit too, I watch basically all Youtube content via Youtube-dl. I have a script that runs every night on Mac, so that new content automagically appears in my Movies folder.
- sunsetMurk 7y agowould love to know more about this. do you just download new videos from your subscriptions? what sort of script? can you share it? :-)
- Wowfunhappy 7y agoLaunchd + bash script. The channels and playlists to download from are managed in a text file. I really need to get around to throwing this up on Github, I’ll see if I can find some time to do that in the next few days and let you know. Fair warning, it’s quite macOS specific.
- exabrial 7y agoYep, exactly. When I fly i like to buffer a few hours worth of videos
- mixmastamyk 7y agoWhat content fron youtube do you watch on such trips?
- loeg 7y agoIt's impressive how little code is needed with 7 npm dependencies for a little CLI program.
- z92 7y agoI always download with "-f 18".
- pdkl95 7y agoI recently wrote[1] a track-selector front end script for youtube-dl that uses yad[2] as a simple GUI[3]. It's not finished (it needs better error handling anbd the gui layout is kind of ugly), but it mostly works. [1] https://gist.github.com/pdkl95/0f963eae3612ecb104f233ca9eed435d https://gist.github.com/pdkl95/0f963eae3612ecb104f233ca9eed4... [2] https://github.com/v1cont/yad https://github.com/v1cont/yad (yad is similar to zenity/{g,}dialog) [3] https://i.imgur.com/B5uf0PB.png https://i.imgur.com/B5uf0PB.png
- acassara 7y agoLooooooove this package! Use `youtube-dl` regularly and always forget the params. It's a nightmare. Opened a PR to remove Lodash, emojis welcomed: https://github.com/synox/youtube-dl-interactive/pull/3 https://github.com/synox/youtube-dl-interactive/pull/3
- founderling 7y agoJesus .. the package.json alone is probably longer then a shellscript would be that implements the same functionality.
- synox 7y agoI would love to see the shellscript equivalent! :))
- natch 7y agoFor videos, this should work... added to your .bashrc file, which then needs to be reloaded (only once) by typing source .bashrc in your home directory from the command line: alias yt='youtube-dl --recode-video mp4' On my system I have a funky python setup so I need to use this instead: alias yt='unset PYTHONPATH; youtube-dl --recode-video mp4' I don't see the need for interactivity because the only format I ever want is mp4. For audio, I would just do a separate alias with a different name. For example (edit: tested): alias yta='youtube-dl --extract-audio --audio-format mp3' Invoke each with the URL. For example: Video: yt https://www.youtube.com/watch?v=IFe9wiDfb0E Audio: yta https://www.youtube.com/watch?v=qKS8KsTC4IU If a youtube URL has extra parameters separated by &, delete those before invoking. For example the URL below, which has extra parameters because it came from a playlist: https://www.youtube.com/watch?v=7uQuX1sOYk4&list=PLYq_mcte9NvDA2Xi5Qjl1DrH5LuDKDlAI should be changed to this before using it to attempt a download: https://www.youtube.com/watch?v=7uQuX1sOYk4 Or you can use the full original URL but you need to protect it from interpretation by UNIX by surrounding it with single quotes when invoking. yta 'https://www.youtube.com/watch?v=7uQuX1sOYk4&list=PLYq_mcte9NvDA2Xi5Qjl1DrH5LuDKDlAI'
- why-oh-why 7y ago> I don't see the need for interactivity because the only format I ever want is mp4. Then this tool isn't for you. If you're gonna skip the whole point of the tool, you can't claim your code suggestions are equivalent.
- 7y ago
- Rolpa 7y ago'Because remembering CLI flags is hard.' Indeed. :)
- peter_retief 7y agoFYI it works with Debian Buster, interesting switches I didn't know
- soulofmischief 7y agoI just uploaded a batch script I use almost daily to grab music videos, live videos, sessions, etc. if anyone finds it useful: https://github.com/soulofmischief/Batch-Utilities/blob/master/src/dl.bat https://github.com/soulofmischief/Batch-Utilities/blob/maste... It automatically places videos in the configured folder based on type. Just type in an artist name, and select the type of video. Saves me a ton of time. It's easy to extend and I plan to generalize it and translate it to bash sometime soon. I just do all of my media consumption in Windows currently.
- mixmastamyk 7y agoCool, here's my simple script to select format called vdl, and can be extended: #!/bin/bash OPTS="-o %(title)s.%(ext)s --console-title --restrict-filenames" if [ "$#" -eq 2 ]; then if [ "$2" -eq "251" ]; then OPTS="$OPTS -x" fi echo youtube-dl $OPTS -f $2 $1 youtube-dl $OPTS -f $2 $1 else echo youtube-dl -F $* youtube-dl -F $* echo echo -n "Enter number: " read fmt youtube-dl $OPTS -f $fmt $* fi To explain, if you know the format number off the top of your head you can pass it after the video id, otherwise it will prompt. Might upgrade it one day to use "set -x" instead of echo and exec.
- JetSpiegel 7y ago- Quote "$2" and "$1" - Use "$@" instead of $* - Use: OPTS=(-o "%(title)s.%(ext)s" --console-title --restrict-filenames) "${OPTS[@]}" This is what shellcheck reports.
- mixmastamyk 7y agoCool, love those kind of tools. However, the youtube (and other sites id) and the format number will never contain spaces, so quoting isn't really needed here. If it gives peace of mind, sure.