summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-01-18 19:28:35 +0200
committerThanos Apollo <[email protected]>2024-01-18 19:28:44 +0200
commit9ca00913de53e5cde5dd148299ff117575739d35 (patch)
treea93c3b913989dca03d7c2ed34186ea52094eb632
parentc4a42d39842f839e1e8e6bb9e9d7a6e605477c24 (diff)
Add yeetube-get-thumbnails
-rw-r--r--yeetube.el17
1 files changed, 16 insertions, 1 deletions
diff --git a/yeetube.el b/yeetube.el
index 01100cb..28ea9a4 100644
--- a/yeetube.el
+++ b/yeetube.el
@@ -232,6 +232,20 @@ WHERE indicates where in the buffer the update should happen."
(save-buffer)
(kill-buffer)))
+(cl-defun yeetube-get-thumbnails (content)
+ "Download thumbnails for CONTENT using `wget'."
+ (interactive)
+ (let ((wget-exec (executable-find "wget"))
+ (default-directory temporary-file-directory))
+ (unless wget-exec
+ (error "Please install `wget', to download thumbnails"))
+ (cl-loop for item in content
+ do (let ((title (plist-get item :title))
+ (thumbnail (plist-get item :thumbnail)))
+ (call-process-shell-command
+ (concat "wget " (shell-quote-argument thumbnail) " -O" (shell-quote-argument title))
+ nil 0)))))
+
;;;###autoload
(defun yeetube-search (query)
"Search for QUERY."
@@ -246,7 +260,8 @@ WHERE indicates where in the buffer the update should happen."
(decode-coding-region (point-min) (point-max) 'utf-8)
(goto-char (point-min))
(toggle-enable-multibyte-characters)
- (yeetube-get-content))
+ (yeetube-get-content)
+ (yeetube-get-thumbnails yeetube-content))
(with-current-buffer
(switch-to-buffer (get-buffer-create (concat "*yeetube*")))
(yeetube-mode)))