From f70c2bb4fa945b815599ae571a5f14c1bbc326de Mon Sep 17 00:00:00 2001 From: BardofSprites <89086143+BardofSprites@users.noreply.github.com> Date: Sun, 29 Dec 2024 19:45:32 -0500 Subject: YouTube queing with elfeed/EMMS --- bard-elisp/bard-web.el | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 bard-elisp/bard-web.el (limited to 'bard-elisp') diff --git a/bard-elisp/bard-web.el b/bard-elisp/bard-web.el new file mode 100644 index 0000000..a0d667c --- /dev/null +++ b/bard-elisp/bard-web.el @@ -0,0 +1,32 @@ +(defun bard/play-elfeed-video () + "Play the URL of the entry at point in mpv if it's a YouTube video." + (interactive) + (let ((entry (elfeed-search-selected :single))) + (if entry + (let ((url (elfeed-entry-link entry))) + (if (and url (string-match-p "https?://\\(www\\.\\)?youtube\\.com\\|youtu\\.be" url)) + (progn + (async-shell-command (format "mpv '%s'" url)) + (elfeed-search-untag-all-unread)) + (message "The URL is not a YouTube link: %s" url))) + (message "No entry selected in Elfeed.")))) + +(defun bard/add-video-emms-queue () + "Play the URL of the entry at point in mpv if it's a YouTube video. Add it to EMMS queue." + (interactive) + (let ((entry (elfeed-search-selected :single))) + (if entry + (let ((url (elfeed-entry-link entry))) + (if (and url (string-match-p "https?://\\(www\\.\\)?youtube\\.com\\|youtu\\.be" url)) + (let* ((playlist-name "Watch Later") + (playlist-buffer (get-buffer (format " *%s*" playlist-name)))) + (unless playlist-buffer + (setq playlist-buffer (emms-playlist-new (format " *%s*" playlist-name)))) + (emms-playlist-set-playlist-buffer playlist-buffer) + (emms-add-url url) + (elfeed-search-untag-all-unread) + (message "Added YouTube video to EMMS playlist: %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