From 05dae71762fae2d63d3f6db352d07b8563990e19 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 30 Jun 2023 04:22:58 +0300 Subject: Add func to download multiple videos by manually yt-download-videos should be used from within a Dired buffer in the desired path. yt-dlp is not youtube specific, just like this package. User should be able to manually run yt-dlp anywhere, downloading videos without being restricted to a predefined search query --- org-yt.el | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/org-yt.el b/org-yt.el index f6f5488..6db46a0 100644 --- a/org-yt.el +++ b/org-yt.el @@ -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 -- cgit v1.2.3