diff options
author | Thanos Apollo <[email protected]> | 2023-08-03 23:56:30 +0300 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2023-08-03 23:56:30 +0300 |
commit | c523227cf09a00bb8c342b3102140ec2fa82a6dd (patch) | |
tree | cb649a2e3ada32e7d85356ee7409f15948b56037 | |
parent | cdaa20b994531856d747639acb908919d988b74f (diff) |
Simplify names
-rw-r--r-- | yeetube.el | 45 |
1 files changed, 25 insertions, 20 deletions
@@ -274,37 +274,42 @@ It's recommended you keep it as the default value." (goto-char (point-min)) (toggle-enable-multibyte-characters) (if is-youtube? - (yeetube--get-content-youtube) - (yeetube--get-content-invidious)) - (yeetube-create-buffer query yeetube--video-titles yeetube--video-ids)))) + (yeetube-get-content-youtube) + (yeetube-get-content-invidious)) + (yeetube-create-buffer query yeetube-content)))) -(defun yeetube--get-content-youtube () +(defun yeetube-get-content-youtube () "Get content from youtube." - (setq yeetube--video-ids nil) - (setq yeetube--video-titles nil) - (while (and (< (length yeetube--video-ids) yeetube-results-limit) + (setq yeetube-content nil) + ;; we define these temp lists to keep tract of video-ids and + ;; video-titles, ensuring we push only unique ones to + ;; yeetube-content + (let ((video-ids nil) + (video-titles nil)) + (while (and (< (length video-ids) yeetube-results-limit) (search-forward "videoId" nil t)) - (let* ((start (point)) - (end (search-forward ",")) + (let* ((videoid-start (point)) + (videoid-end (search-forward ",")) (videoid (buffer-substring - (+ start 3) - (- end 2)))) - (unless (or (member videoid yeetube--video-ids) + (+ videoid-start 3) + (- videoid-end 2)))) + (unless (or (member videoid video-ids) (not (and (>= (length videoid) 9) (<= (length videoid) 13) (string-match-p "^[a-zA-Z0-9_-]*$" videoid)))) - (push videoid yeetube--video-ids) + (push videoid video-ids) (search-forward "text") - (let* ((start (point)) - (end (search-forward ",\"")) + (let* ((title-start (point)) + (title-end (search-forward ",\"")) (title (buffer-substring - (+ start 3) - (- end 5)))) + (+ title-start 3) + (- title-end 5)))) (if (string-match-p "vssLoggingContext" title) - (pop yeetube--video-ids) - (push title yeetube--video-titles))))))) + (pop video-ids) + (push title video-titles) + (push (cons videoid title) yeetube-content)))))))) -(defun yeetube--get-content-invidious () +(defun yeetube-get-content-invidious () "Get content from an invidious instance." (setq yeetube--video-ids nil) (setq yeetube--video-titles nil) |