summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eshell-conf.el27
1 files changed, 27 insertions, 0 deletions
diff --git a/eshell-conf.el b/eshell-conf.el
index 6dbc49a..7386400 100644
--- a/eshell-conf.el
+++ b/eshell-conf.el
@@ -133,6 +133,33 @@ Add a time information at the beginning. -- Modified by Durand."
#'eshell-clear))
;;;###autoload
+(defun eshell/yt-url (&rest args)
+ "Run `durand-convert-youtube-video-to-url' on the first arg."
+ (eshell-eval-using-options
+ "yt-url" args
+ '((?o "open" nil open-p "Open in the default external browser.")
+ (?h "help" nil nil "Print this help message.")
+ :parse-leading-options-only
+ :usage "[-ho] video-name"
+ :show-usage)
+ (eshell-yt-url args open-p)))
+
+;;;###autoload
+(defun eshell-yt-url (&optional video-name open-p)
+ "Save the URL of a video downloaded from YouTube to the kill-ring.
+The video is given by VIDEO-NAME.
+
+If OPEN-P is non-nil, then open the video in the default external
+browser instead."
+ (let ((url (durand-convert-youtube-video-to-url
+ (eshell-flatten-and-stringify video-name))))
+ (cond
+ ((string= url "")
+ (user-error "Please specify VIDEO-NAME"))
+ (open-p (browse-url-default-browser url))
+ ((kill-new url)))))
+
+;;;###autoload
(defun eshell-clear ()
(interactive)
(let ((inhibit-read-only t))