From eae7419bd1398991ed91c317ccffc32781510e5d Mon Sep 17 00:00:00 2001 From: JSDurand Date: Sat, 27 Feb 2021 02:07:41 +0800 Subject: Further adjustments to eshell and elfeed. * elfeed-conf.el (durand-eshell-download-sentinel): (durand-elfeed-download-video): (elfeed-search-mode-map): (elfeed-show-mode-map): Add the ability to conveniently download videos. * eshell-conf.el (eshell/mark): Quote the shell argument properly. --- elfeed-conf.el | 34 ++++++++++++++++++++++++++++++++++ eshell-conf.el | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/elfeed-conf.el b/elfeed-conf.el index 6ae8b41..378ac9f 100644 --- a/elfeed-conf.el +++ b/elfeed-conf.el @@ -76,5 +76,39 @@ (kill-buffer buffer))))) (buffer-list))) +;;;###autoload +(defun durand-eshell-download-sentinel (process status) + "Inform the user when the download process is terminated. +PROCESS should have the name \"elfeed download video\". + +This informs the user when STATUS is the string \"finished\\n\"." + (cond ((string-equal (process-name process) "elfeed download video")) + ((error "The download sentinel is applied to a wrong process: %S" + process))) + (cond ((string-equal status "finished\n") + (message "Downloading videos has finished.")))) + +;;;###autoload +(defun durand-elfeed-download-video () + "Download the video in the feed." + (interactive) + (let ((default-directory "/Users/durand/Desktop/Centre/Vidéos/") + link) + (cond ((derived-mode-p 'elfeed-search-mode) + (setq link (elfeed-entry-link (elfeed-search-selected :ignore-region)))) + ((derived-mode-p 'elfeed-show-mode) + (setq link (elfeed-entry-link elfeed-show-entry))) + ((user-error "Not in an elfeed buffer"))) + (make-process + :name "elfeed download video" + :buffer "*elfeed download*" + :sentinel #'durand-eshell-download-sentinel + :command (list + "youtube-dl" "-f" "bestvideo[height<=720]+bestaudio/best[height<=720]/best" + link)))) + +(define-key elfeed-search-mode-map (vector ?w) #'durand-elfeed-download-video) +(define-key elfeed-show-mode-map (vector ?w) #'durand-elfeed-download-video) + (provide 'elfeed-conf) ;;; elfeed-conf.el ends here diff --git a/eshell-conf.el b/eshell-conf.el index a1bdf68..6bb255a 100644 --- a/eshell-conf.el +++ b/eshell-conf.el @@ -73,7 +73,7 @@ directory is used." (directory-file-name (file-name-directory default-directory)))))) (eshell-command-result - (format "ln -sf %s %s" + (format "ln -sf \"%s\" \"%s\"" default-directory (expand-file-name args eshell-mark-directory)))) ;;;###autoload -- cgit v1.2.3-18-g5258