From 480dfe2c09070cf4c710e6806cb3a6cbdc93f7cf Mon Sep 17 00:00:00 2001 From: BardofSprites <89086143+BardofSprites@users.noreply.github.com> Date: Tue, 22 Apr 2025 18:03:56 -0400 Subject: 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 --- bard-elisp/bard-web.el | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'bard-elisp/bard-web.el') 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) -- cgit v1.2.3