Created
August 27, 2017 06:59
-
-
Save mnn/841fd3cabca1f5c9bd094796cba3c013 to your computer and use it in GitHub Desktop.
YouTube download helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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