aboutsummaryrefslogtreecommitdiff
path: root/bard-elisp/bard-web.el
diff options
context:
space:
mode:
authorBardofSprites <[email protected]>2025-04-22 18:03:56 -0400
committerBardofSprites <[email protected]>2025-04-22 18:05:37 -0400
commit480dfe2c09070cf4c710e6806cb3a6cbdc93f7cf (patch)
tree50d28c5456737b20f047dcc1c50ba76a4ab23d54 /bard-elisp/bard-web.el
parentf9a7af16c077b89a3db907746d8e1f946b064b02 (diff)
update YouTube/EMMS functions
New Features: - Download currently playing video to prompted locations. - Tacking on current elfeed entry to bard/watch-later-file - Play YouTube video at point
Diffstat (limited to 'bard-elisp/bard-web.el')
-rw-r--r--bard-elisp/bard-web.el23
1 files changed, 23 insertions, 0 deletions
diff --git a/bard-elisp/bard-web.el b/bard-elisp/bard-web.el
index 702fd52..8c9473b 100644
--- a/bard-elisp/bard-web.el
+++ b/bard-elisp/bard-web.el
@@ -1,4 +1,5 @@
(require 'emms)
+(require 'elfeed-search)
(defun bard/play-elfeed-video ()
"Play the URL of the entry at point in mpv if it's a YouTube video."
@@ -31,4 +32,26 @@
(message "The URL is not a YouTube link: %s" url)))
(message "No entry selected in Elfeed."))))
+(defun bard/add-video-watch-later ()
+ "Add the current Elfeed YouTube entry URL to '~/Videos/watch-later.m3u' and mark it as read."
+ (interactive)
+ (let ((entry (elfeed-search-selected :single)))
+ (if entry
+ (let* ((url (elfeed-entry-link entry))
+ (watch-later-file (expand-file-name "~/Videos/watch-later.m3u")))
+ (if (and url (string-match-p "https?://\\(www\\.\\)?youtube\\.com\\|youtu\\.be" url))
+ (progn
+ (with-temp-buffer
+ (insert (concat url "\n"))
+ (append-to-file (point-min) (point-max) watch-later-file))
+ ;; Remove the 'unread tag from the entry directly
+ (setf (elfeed-entry-tags entry)
+ (remove 'unread (elfeed-entry-tags entry)))
+ ;; Force UI update
+ (when (derived-mode-p 'elfeed-search-mode)
+ (elfeed-search-update-entry entry))
+ (message "Added video to watch later: %s" url))
+ (message "The URL is not a YouTube link: %s" url)))
+ (message "No entry selected in Elfeed."))))
+
(provide 'bard-web)