diff options
-rw-r--r-- | yeetube.el | 36 |
1 files changed, 29 insertions, 7 deletions
@@ -139,23 +139,45 @@ PREFIX [[URL/watch?v=VIDEOID][VIDEOTITLE ]]" (interactive "sYeetube Search: ") (let ((videoIds '()) (videoTitles '())) - (with-current-buffer (url-retrieve-synchronously (concat yeetube-query-url query) t t) + (with-current-buffer + (url-retrieve-synchronously (concat yeetube-query-url "/search?q=" query) t t) (goto-char (point-min)) (toggle-enable-multibyte-characters) (while (< (length videoIds) yeetube-results-limit) - (search-forward "videoId") + (if (yeetube-check-if-youtube yeetube-query-url) + (search-forward "videoId") + (search-forward "watch?v")) (let* ((start (point)) - (end (search-forward ",")) - (videoid (buffer-substring (+ start 3) (- end 2)))) + (end (if (yeetube-check-if-youtube yeetube-query-url) + (search-forward ",") + (search-forward ">"))) + (videoid (buffer-substring (if (yeetube-check-if-youtube yeetube-query-url) + (+ start 3) + (+ start 1)) + ;; Yeah they are the same in both cases, + ;; /but/ if we start adding more sites + ;; it will be easier to use something like pcase afterwards + (if (yeetube-check-if-youtube yeetube-query-url) + (- end 2) + (- end 2))))) (unless (or (member videoid videoIds) (not (and (>= (length videoid) 9) (<= (length videoid) 13) (string-match-p "^[a-zA-Z0-9_-]*$" videoid)))) (push videoid videoIds) - (search-forward "text") + (if (yeetube-check-if-youtube yeetube-query-url) + (search-forward "text") + (search-forward "\"auto\">")) (let* ((start (point)) - (end (search-forward ",\"")) - (title (buffer-substring (+ start 3) (- end 5)))) + (end (if (yeetube-check-if-youtube yeetube-query-url) + (search-forward ",\"") + (search-forward ">"))) + (title (buffer-substring (if (yeetube-check-if-youtube yeetube-query-url) + (+ start 3) + (+ start 0)) + (if (yeetube-check-if-youtube yeetube-query-url) + (- end 5) + (- end 4))))) (if (string-match-p "vssLoggingContext" title) (pop videoIds) (push title videoTitles))))))) |