From f73172433a944551558204554efae0e441388034 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sat, 12 Oct 2024 10:58:01 +0300 Subject: browse-url: Adjust for list length & for a single string value. --- yeetube.el | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/yeetube.el b/yeetube.el index 05d56a0..a8588f6 100644 --- a/yeetube.el +++ b/yeetube.el @@ -433,11 +433,17 @@ Image is inserted in BUFFER for ENTRY." (defun yeetube-browse-url () "Open URL for video at point, using an invidious instance." (interactive) - (let ((invidious-instance (+ 1 (random (length yeetube-invidious-instances))))) + (let ((invidious-instance (cond ((and (listp yeetube-invidious-instances) + (length> yeetube-invidious-instances 1)) + (nth (random (length yeetube-invidious-instances)) + yeetube-invidious-instances)) + ((and (listp yeetube-invidious-instances) + (length= yeetube-invidious-instances 1)) + (car yeetube-invidious-instances)) + ((stringp yeetube-invidious-instances) + yeetube-invidious-instances)))) (browse-url - (replace-regexp-in-string "youtube.com" - (nth invidious-instance yeetube-invidious-instances) - (yeetube-get-url))))) + (replace-regexp-in-string "youtube.com" invidious-instance (yeetube-get-url))))) (defun yeetube--scrape-string (pos item &optional sub-item) "Scrape string corresponding of SUB-ITEM of ITEM after POS." -- cgit v1.2.3