From 5ce1e994ffd75e96c65373530d61255045b996b5 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 6 Oct 2023 18:09:03 +0300 Subject: yeetube-buffer: Use cl-loop to insert contents Simplify yeetube-buffer-create using cl-loop --- yeetube-buffer.el | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/yeetube-buffer.el b/yeetube-buffer.el index 8713616..fed3c66 100644 --- a/yeetube-buffer.el +++ b/yeetube-buffer.el @@ -199,22 +199,8 @@ Emojis cause formatting issues, this should be off by default." (setf buffer-read-only nil) (erase-buffer) (yeetube-buffer--format-header query) - (dolist (info (reverse content)) - (let ((title (yeetube-buffer-fix-title (car info))) - (view-count (nth 2 info)) - (video-duration (nth 3 info)) - (channel-name (nth 4 info))) - (insert - (yeetube-buffer--format-title title) - (yeetube-buffer--format-view-count - (yeetube-buffer-view-count-add-commas - (yeetube-buffer-fix-view-count view-count))) - (yeetube-buffer--format-video-duration - (if (string-match-p "^[0-9:]+$" video-duration) - video-duration - "nil")) - (yeetube-buffer--format-channel channel-name) - "\n"))) + (cl-loop for result in (reverse content) + do (yeetube-buffer-insert-content result)) (delete-char -1) (goto-char (point-min)))) -- cgit v1.2.3 From 62166f4e9ef8c98b99c070edaef9224fb95ed0ed Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 6 Oct 2023 18:20:43 +0300 Subject: [fix] yeetube-buffer: Set buffer-read-only t after creation --- yeetube-buffer.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yeetube-buffer.el b/yeetube-buffer.el index fed3c66..565d192 100644 --- a/yeetube-buffer.el +++ b/yeetube-buffer.el @@ -202,7 +202,8 @@ Emojis cause formatting issues, this should be off by default." (cl-loop for result in (reverse content) do (yeetube-buffer-insert-content result)) (delete-char -1) - (goto-char (point-min)))) + (goto-char (point-min)) + (setf buffer-read-only t))) (provide 'yeetube-buffer) ;;; yeetube-buffer.el ends here -- cgit v1.2.3 From d72a8021b2d26d1d0c73630deb9f365374b8ff7b Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sat, 7 Oct 2023 10:22:24 +0300 Subject: Add yeetube-invidious instances List with popular invidious instances, which is going to be used with yeetube-browse-url function. --- yeetube.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/yeetube.el b/yeetube.el index a125e96..566bb30 100644 --- a/yeetube.el +++ b/yeetube.el @@ -72,6 +72,15 @@ Example Usage: :type 'string :group 'yeetube) +(defvar yeetube-invidious-instances + '("vid.puffyan.us" + "invidious.flokinet.to" + "yt.artemislena.eu" + "invidious.privacydev.net" + "onion.tube" + "yewtu.be") + "List of invidious instaces.") + (defvar yeetube-content nil "Scraped content.") -- cgit v1.2.3 From 3fa20bde85dcd505aa705c883a3f252b5fd52532 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sat, 7 Oct 2023 10:24:28 +0300 Subject: [feature] yeetube-browse-url: Open url using an invidious instance. Function to browse video URL at point, using an invidious instance. --- yeetube.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/yeetube.el b/yeetube.el index 566bb30..cd5ed4b 100644 --- a/yeetube.el +++ b/yeetube.el @@ -174,9 +174,13 @@ WHERE indicates where in the buffer the update should happen." (yeetube-buffer-create query yeetube-content 'yeetube-mode))) (defun yeetube-browse-url () - "Open URL in browser." + "Open URL for video at point, using an invidious instance." (interactive) - (browse-url (yeetube-get-url))) + (let ((invidious-instance (+ 1 (random (length yeetube-invidious-instances))))) + (browse-url + (replace-regexp-in-string "youtube.com" + (nth invidious-instance yeetube-invidious-instances) + (yeetube-get-url))))) (defun yeetube-get-item (query) "Get item from youtube results for QUERY. @@ -278,6 +282,7 @@ prompt blank to keep the default name." ;; Yeetube Mode (defvar yeetube-mode-map (make-sparse-keymap)) (define-key yeetube-mode-map (kbd "RET") #'yeetube-play) +(define-key yeetube-mode-map (kbd "b") #'yeetube-browse-url) (define-key yeetube-mode-map (kbd "d") #'yeetube-download-video) (define-key yeetube-mode-map (kbd "D") #'yeetube-download-change-directory) (define-key yeetube-mode-map (kbd "a") #'yeetube-download-change-audio-format) -- cgit v1.2.3