diff options
-rw-r--r-- | org-yt.el | 36 |
1 files changed, 34 insertions, 2 deletions
@@ -32,8 +32,6 @@ -;; TODO: Download videos using yt-dlp - ;; TODO: let user decide custom name and path (defun yt-download-video () "Download using link at point in an `'org-mode buffer with yt-dlp." @@ -44,6 +42,40 @@ (async-shell-command (format "yt-dlp %s" url)) (message "Downloading %s " url)))) +(defun yt-download-videos () + "Download one or multiple videos using yt-dlp. + +Usage Example: +Open a Dired buffer and navigate where you want to download your videos, +then run this command interactively." + (interactive) + (let ((links '()) + (names '()) + (url "") + (name "") + (buffer-counter 1) + (name-counter 1)) + ;; Read links and names until "q" is entered + (while (not (string= url "q")) + (setq url (read-string "Enter URL (q to quit): ")) + (unless (string= url "q") + (setq links (cons url links)) + (setq name (read-string (format "Enter name (%d-NAME): " name-counter))) + (while (get-buffer (format "download-video-%d" buffer-counter)) + (setq buffer-counter (1+ buffer-counter))) + (setq names (cons name names)) + (setq buffer-counter (1+ buffer-counter)) + (setq name-counter (1+ name-counter)))) + ;; Process the collected links and names + (setq links (reverse links)) + (setq names (reverse names)) + (dolist (pair (cl-mapcar 'cons links names)) + (let ((url (car pair)) + (name (cdr pair)) + (buffer-name (format "download-video-%d" buffer-counter))) + (async-shell-command (format "yt-dlp %s -o %s" url name) buffer-name) + (setq buffer-counter (1+ buffer-counter)))))) + (provide 'org-yt) ;;; org-yt.el ends here |