Hacker News new | past | comments | ask | show | jobs | submit | synox's comments login

I would love to see the shellscript equivalent! :))


For 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'


> 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.


True! I should have made it more clear my examples weren't providing interactivity, I guess you're saying. OK.


   f=/tmp/youtube-urls;sed 's/^/url=/'|exec curl -K-|exec grep -o "https%3A%2F%2Fr[0-9][a-zA-Z0-9.%_-]*"|exec sed -n 's/%26/\&/g;s/%3D/=/g;s/%3A/:/g;s/%2F/\//g;s/%3F/?/g;s/%25/%/g;w'"$f"'';case $1 in --help|-help|-h|-?)exec echo usage: echo youtube-url\|$0 \[fmt\] \[saveas\];;*) a=$(exec grep "itag=$1"\& $f 2>/dev/null);case ${#a} in 0) echo "the fmt (itag number \""$1"\") is not available. here are the available formats:";exec grep -o "itag=[0-9]*" $f;;*)exec curl -4o ${1-$c} $a;esac;esac
The idea of interactively selecting the format seems like it would become cumbersome after the user learns the formats, i.e., itag numbers, that she can play on her computer.

Once she has that knowledge, she will just be looking for the same itag numbers every time, e.g., 18 or 22 are popular for mp4.


Would be pretty straightforward to do with fzf.


A 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.


PS: 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-...


Just 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.


Yes 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


On 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.


Sorry, I don't have any ready recommendations up my sleeve. Pretty much only CLI library I use is argparse.


Thanks 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...


Statically link ALL the things!


Just 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. :)


That'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.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: