summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-01-18 19:28:50 +0200
committerThanos Apollo <[email protected]>2024-01-18 19:28:50 +0200
commitb1e0585bac20fdac244ac38ed48c04669bfc94b4 (patch)
tree4cac726d1b01638baf705f4fac0e49fd35898d0d
parent9ca00913de53e5cde5dd148299ff117575739d35 (diff)
yeetube-get-item: Rewrite as cl-defun and return item
-rw-r--r--yeetube.el9
1 files changed, 6 insertions, 3 deletions
diff --git a/yeetube.el b/yeetube.el
index 28ea9a4..7c5473c 100644
--- a/yeetube.el
+++ b/yeetube.el
@@ -276,15 +276,18 @@ WHERE indicates where in the buffer the update should happen."
(nth invidious-instance yeetube-invidious-instances)
(yeetube-get-url)))))
-(defun yeetube-get-item (query)
+(cl-defun yeetube-get-item (&key item (item-start "text") item-end (substring-start 3) substring-end)
"Get item from youtube results for QUERY.
Video result starts with videorenderer.
Search back to videorenderer (start of video results),
then for item."
(search-backward "videorenderer" nil t)
- (search-forward query nil t)
- (search-forward "text" nil t))
+ (search-forward item nil t)
+ (search-forward item-start nil t)
+ (let ((item (buffer-substring (+ (point) substring-start)
+ (- (search-forward item-end) substring-end))))
+ item))
(defvar yeetube--title-replacements
'(("&amp;" . "&")