summaryrefslogtreecommitdiff
path: root/elfeed-conf.el
diff options
context:
space:
mode:
Diffstat (limited to 'elfeed-conf.el')
-rw-r--r--elfeed-conf.el34
1 files changed, 34 insertions, 0 deletions
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