From b77f86a6da150a1617ea1ee4e7990fdf1440cbf3 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Wed, 5 Jul 2023 09:41:17 +0300 Subject: Add yeetube-insert-content This was used in yeetube-search. Keeping them seperate to make debugging easier & make it less spaghetti like --- yeetube.el | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/yeetube.el b/yeetube.el index 8834601..7ec1fa7 100644 --- a/yeetube.el +++ b/yeetube.el @@ -118,8 +118,22 @@ Example Usage: (message "Opening with %s" yeetube-player)))) -;; TODO: Check if video_type of videoid is short or video -;; TODO: Titles are getting messed up for livestreams +(defun yeetube-insert-content (prefix url videoTitles videoIds) + "Insert video links with titles into the buffer. + +Arguments: +- PREFIX: The prefix string for each link. +- URL: The base URL for the YouTube links. +- VIDEOTITLES: A list of video titles. +- VIDEOIDS: A list of video IDs. + +For each video ID and video title, inserts a link into the buffer in the format: +PREFIX [[URL/watch?v=VIDEOID][VIDEOTITLE ]]" + (cl-loop for (videoId . videoTitle) in + (cl-mapcar #'cons (reverse videoIds) (reverse videoTitles)) + do (insert (format "%s [[%s/watch?v=%s][%s ]]\n" + prefix url videoId videoTitle)))) + (defun yeetube-search (query) "Search for QUERY." (interactive "sYeetube Search: ") @@ -156,6 +170,9 @@ Example Usage: (cl-mapcar #'cons (reverse videoIds) (reverse videoTitles)) do (insert (format "%s [[https://www.youtube.com/watch?v=%s][%s ]]\n" yeetube-results-prefix videoId videoTitle))) + (yeetube-insert-content + yeetube-results-prefix yeetube-query-url + videoTitles videoIds) (yeetube-info) (setq buffer-read-only t) (goto-char (point-min)) -- cgit v1.2.3