summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-10-12 10:58:01 +0300
committerThanos Apollo <[email protected]>2024-10-12 10:58:01 +0300
commitf73172433a944551558204554efae0e441388034 (patch)
tree1cdbdf5ac865d24ceca22331df1d0ed637544273
parentc4262818cbc68eebe21b00f7c31384a1bde72537 (diff)
browse-url: Adjust for list length & for a single string value.
-rw-r--r--yeetube.el14
1 files 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."