Skip to content

Instantly share code, notes, and snippets.

@mnn
Created August 27, 2017 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnn/841fd3cabca1f5c9bd094796cba3c013 to your computer and use it in GitHub Desktop.
Save mnn/841fd3cabca1f5c9bd094796cba3c013 to your computer and use it in GitHub Desktop.
YouTube download helper
#!/usr/bin/env clojure
(ns yt.core
(:require [clojure.java.shell :as sh]
[clojure.java.io :as io]))
(def home-dir (System/getProperty "user.home"))
(def download-dir-suffix "/Downloads/yt")
(def download-dir (str home-dir download-dir-suffix))
(defn run-cmd [cmd]
(let [proc (.exec (Runtime/getRuntime) (into-array cmd) nil (io/file download-dir))]
(with-open [rdr (io/reader (.getInputStream proc))]
(doseq [line (line-seq rdr)]
(println line)))))
(defn main []
(print "link: ")
(flush)
(let [link (read-line)]
(run-cmd ["youtube-dl" "--no-playlist" link])))
(main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment