News for hackers. Stuff that matters.
Re:Show HN: Interactively select the quality and format for ... by founderling on Monday May 27, 2019 @12:17PM (#20023185)
Jesus .. the package.json alone is probably longer then a shellscript would be that implements the same functionality.
Re:Show HN: Interactively select the quality and format for ... by dang on Monday May 27, 2019 @03:09PM (#20024537)
This comment breaks the HN guidelines and especially the Show HN guidelines. Would you mind reviewing them and not posting like this here?

https://news.ycombinator.com/newsguidelines.html

https://news.ycombinator.com/showhn.html

Re:Show HN: Interactively select the quality and format for ... by why-oh-why on Monday May 27, 2019 @02:39PM (#20024307)
Doubt you can write that in less than 7 lines of non-gibberish. Shell scripts aren't known to be particularly easy to write, read, use and to be portable.

This tool probably works anywhere node runs and the author didn't have to think about that, during the evening they took to write it.

Re:Show HN: Interactively select the quality and format for ... by synox on Monday May 27, 2019 @12:34PM (#20023326)
I would love to see the shellscript equivalent! :))
Re:Show HN: Interactively select the quality and format for ... by natch on Monday May 27, 2019 @02:00PM (#20024043)
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'
Re:Show HN: Interactively select the quality and format for ... by why-oh-why on Monday May 27, 2019 @02:41PM (#20024317)
> 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.

Re:Show HN: Interactively select the quality and format for ... by natch on Monday May 27, 2019 @10:33PM (#20026765)
True! I should have made it more clear my examples weren't providing interactivity, I guess you're saying. OK.
Re:Show HN: Interactively select the quality and format for ... by 3xblah on Monday May 27, 2019 @06:28PM (#20025713)

   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.

Re:Show HN: Interactively select the quality and format for ... by mirashii on Monday May 27, 2019 @02:55PM (#20024426)
Would be pretty straightforward to do with fzf.