From ba9ba6b9e68570b7d1b9c4a3461925889c99894e Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 17 Jan 2025 03:39:22 +0200 Subject: get-url: Adjust for type from within the function. * Get video type using yeetube-get-url instead of passing it as an arg. --- yeetube.el | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'yeetube.el') diff --git a/yeetube.el b/yeetube.el index 351f9aa..62f2b9a 100644 --- a/yeetube.el +++ b/yeetube.el @@ -212,8 +212,7 @@ videos from.") (interactive) (let* ((id (tabulated-list-get-id)) (entry-content (cadr (assoc id yeetube-content))) - (type (aref entry-content (- (length entry-content) 1))) - (video-url (yeetube-get-url id type)) + (video-url (yeetube-get-url id)) (video-title (aref entry-content (if yeetube-display-thumbnails-p 1 0))) (proc (apply yeetube-play-function video-url (when yeetube-mpv-modeline-mode (list video-title))))) @@ -230,7 +229,9 @@ Select entry title from `yeetube-history' and play corresponding URL." (interactive) (let* ((titles (mapcar (lambda (entry) (cl-getf entry :title)) yeetube-history)) (selected (completing-read "Replay: " titles)) - (selected-entry (cl-find-if (lambda (entry) (string= selected (cl-getf entry :title))) yeetube-history)) + (selected-entry (cl-find-if (lambda (entry) + (string= selected (cl-getf entry :title))) + yeetube-history)) (title (cl-getf selected-entry :title)) (url (cl-getf selected-entry :url))) (funcall yeetube-play-function url (when yeetube-mpv-modeline-mode title)) @@ -248,12 +249,14 @@ Select entry title from `yeetube-history' and play corresponding URL." (write-region "nil" nil file-path)))) ;;;###autoload -(defun yeetube-save-video () - "Save url at point." - (interactive) +(defun yeetube-save-video (arg) + "Save url at point. + +If ARG is non-nil, save as a playlist URL." + (interactive "P") (yeetube-load-saved-videos) (let ((name (read-string "Save as: ")) - (url (yeetube-get-url))) + (url (yeetube-get-url (tabulated-list-get-id) (if arg 'playlist 'video)))) (push (cons name url) yeetube-saved-videos))) ;; We could use keywords here, but it would break users saved videos -- cgit v1.2.3