
Show HN: Simple YouTube Downloader - 3xblah
test $# -gt 0||exec echo usage: echo youtube-url\|$0 fmt \[saveas\];b=$(exec sed &#x27;s&#x2F;http:&#x2F;https:&#x2F;; s&#x2F;m.youtube&#x2F;www.youtube&#x2F;;s&#x2F;youtu.be.&#x2F;www.youtube.com\&#x2F;watch?v=&#x2F;;s&#x2F;hooktube.com&#x2F;youtube.com&#x2F;;s&#x2F;embed.&#x2F;watch?v=&#x2F;;#etc.;s&#x2F;?version.<i>&#x2F;&#x2F;;s&#x2F;;.</i>&#x2F;&#x2F;;&#x27;);echo source url: $b;c=${b##<i>=};a=$(ftp -4o&#x2F;dev&#x2F;stdout $b|exec grep -o &quot;https%3A%2F%2Fr[0-9]</i>[a-zA-Z0-9.%_-]*&quot;|exec sed &#x27;s&#x2F;%26&#x2F;\&amp;&#x2F;g;s&#x2F;%3D&#x2F;=&#x2F;g;s&#x2F;%3A&#x2F;:&#x2F;g;s&#x2F;%2F&#x2F;\&#x2F;&#x2F;g;s&#x2F;%3F&#x2F;?&#x2F;g;s&#x2F;%25&#x2F;%&#x2F;g;&#x2F;itag=&#x27;&quot;$1&quot;&#x27;&#x2F;!d&#x27;);echo video url: $a;exec ftp -4o ${2-$c} $a;
======
O_H_E
1) Couldn't get it to work

2) An explination would be much appreciated

3) You probably want to format this as code
([https://news.ycombinator.com/formatdoc](https://news.ycombinator.com/formatdoc))

4) Difference between this and youtube-dl? other than doing it without any
dependencies.

~~~
3xblah
1) What did you try?

2) It is a shell script

3) Sorry about that

4)

(a) It is smaller, simpler and faster.

(b) When YouTube occasionally makes a change I can fix it immediately rather
than waiting for someone else to fix youtube-dl

~~~
O_H_E
It is probably my incompetence and arrogance. I am not that proficient in the
unix shell yet. I was trying to run the entire thing from the command line,
but also tried a couple of putting it in a function names `youtube-url`
without success. I was stubborn and trying to use it like that `youtube-url
fmt "[https://you..."`](https://you..."`) and never got what you wrote in the
usage section because I had `youtube-url` twice in the output (so I was never
actually piping the url to that command)

But now after you said "script", I tried putting it in its own fine giving it
an honest read/try. Figured out you are using netbsd, as Ubuntu's (and by
definition Debian) `ftp` doesn't have an `-o` option. After deleting the o now
I get

    
    
      source url: https://www.youtube.com/watch?v=CneL0GoZ3tk
      video url:
      ftp: https://www.youtube.com/watch?v=CneL0GoZ3tk: Name or service not known
    

> When YouTube occasionally makes a change I can fix it immediately rather
> than waiting for someone else to fix youtube-dl

I hear you. Had to download manually the latest ytdl development versions
before they were packaged before.

EDIT: know what, you don't have to waste much time on me as it looks like
there 'might' be more differences with grep/sed (who am I to know) I should
not be here nor on my command line wasting time anyway. Have a ton of work to
do to graduate on time.

~~~
3xblah
Tested on Linux. ftp package is called tnftp. You can substitute curl -4o,
wget -4O, fetch -4o or whatever client you prefer for downloading files.

------
gitgud
That blob of bash output is not what _i 'd_ consider simple...

~~~
3xblah
I would not consider it simple either. However, the word "simple" was not
used. The word was used was "simpler".

The source for youtube-dl is not what I'd consider "simple". While _neither
solution is "simple"_, one may be "simpler" than the other.

Also, it is ash, not bash.

