diff options
author | Thanos Apollo <[email protected]> | 2024-10-12 10:58:01 +0300 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2024-10-12 10:58:01 +0300 |
commit | f73172433a944551558204554efae0e441388034 (patch) | |
tree | 1cdbdf5ac865d24ceca22331df1d0ed637544273 | |
parent | c4262818cbc68eebe21b00f7c31384a1bde72537 (diff) |
browse-url: Adjust for list length & for a single string value.
-rw-r--r-- | yeetube.el | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -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." |