From 83889236cd26aa949695d98696ace5767b791854 Mon Sep 17 00:00:00 2001 From: noa@gaiwan.org Date: Sat, 15 Jun 2024 17:16:01 +0000 Subject: Define a function to grab mp3 from youtube --- emacs/init.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/emacs/init.el b/emacs/init.el index e36a9fd..65a3c1b 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -878,6 +878,14 @@ The misspelled word is taken from OVERLAY. WORD is the corrected word." (global-set-key [remap query-replace-regexp] 'anzu-query-replace-regexp) +(defun snarf-song (url) + (interactive "sYoutube url:") + (async-shell-command + (concat "yt-dlp -x --audio-format=mp3 -o " + (shell-quote-argument "~/media/music/%(title)s [%(id)s].%(ext)s") + " " + (shell-quote-argument url)))) + ;;; Escape always quits ;; Due to emacs's legacy running on terminals, some keys are similar but different. By which i mean, we have ESC and escape, TAB and tab, and RET and return. The capital letters refer to the control sequences terminals represent these keys as: C-[, C-i, and C-m respectively. The lower case words refer to the actual keys. -- cgit 1.4.1-2-gfad0