diff options
-rw-r--r-- | yeetube.el | 30 |
1 files changed, 26 insertions, 4 deletions
@@ -117,6 +117,11 @@ Valid options include: :type 'boolean :group 'yeetube) +(defcustom yeetube-pop-to-same-window-p t + "When non-nil, create *yeetube* buffer at the same window." + :type 'boolean + :group 'yeetube) + (defgroup yeetube-faces nil "Faces used by yeetube." :group 'yeetube @@ -332,7 +337,10 @@ WHERE indicates where in the buffer the update should happen." (defun yeetube--callback (status) "Yeetube callback handling STATUS." - (let ((url-buffer (current-buffer))) + (let ((url-buffer (current-buffer)) + (pop-to-buffer-func (if yeetube-pop-to-same-window-p + #'pop-to-buffer-same-window + #'pop-to-buffer))) (unwind-protect (if-let ((err (plist-get :error status))) (message "Error %s in retrieving yeetube results: %S" (car err) (cdr err)) @@ -341,7 +349,7 @@ WHERE indicates where in the buffer the update should happen." (url-insert url-buffer) (decode-coding-region (point-min) (point-max) 'utf-8) (yeetube-get-content)) - (pop-to-buffer-same-window "*yeetube*") + (funcall pop-to-buffer-func "*yeetube*") (yeetube-mode)) (kill-buffer url-buffer)))) @@ -396,6 +404,10 @@ Image is inserted in BUFFER for ENTRY." (defun yeetube-search (query) "Search for QUERY." (interactive (list (yeetube-read-query))) + (pop-to-buffer-same-window "*yeetube*") + (let ((inhibit-read-only t)) + (erase-buffer) + (insert (propertize "Loading..." 'face 'bold-italic))) (yeetube-display-content-from-url (format "https://youtube.com/search?q=%s%s" (url-hexify-string query) @@ -417,6 +429,13 @@ Image is inserted in BUFFER for ENTRY." (setf yeetube--channel-id (substring channel-id 2)) (yeetube-display-content-from-url (format "https://youtube.com/%s/videos" channel-id))) +(defun yeetube-channel-streams (&optional channel-id) + "View streams for the channel with CHANNEL-ID." + (interactive (list (or (yeetube-channel-id-at-point) + (format "@%s" (read-string "Channel: "))))) + (setf yeetube--channel-id (substring channel-id 2)) + (yeetube-display-content-from-url (format "https://youtube.com/%s/streams" channel-id))) + (defun yeetube-channel-search (channel-id query) "Search channel with CHANNEL-ID for videoes matching QUERY." (interactive (list (yeetube-channel-id-at-point) (yeetube-read-query))) @@ -475,7 +494,8 @@ Image is inserted in BUFFER for ENTRY." (setf yeetube-content nil) (goto-char (point-min)) (let ((count 0) - (result-rx (rx "\"" (or "video" (and (or "playlist" "compact") (? "Video"))) "Renderer\"")) + (result-rx + (rx "\"" (or "video" (and (or "playlist" "compact") (? "Video"))) "Renderer\"")) id ids videop pos) ;; Keep scraping while there are results and the limit is not reached (while (and (< count yeetube-results-limit) @@ -566,7 +586,8 @@ Optional values: (let* ((tor-command (when yeetube-enable-tor (executable-find "torsocks"))) (name-command (when name (format "-o %s" (shell-quote-argument name)))) (format-command (when audio-format - (format "--extract-audio --audio-format %s" (shell-quote-argument audio-format)))) + (format "--extract-audio --audio-format %s" + (shell-quote-argument audio-format)))) (command (mapconcat 'identity (delq nil (list tor-command (executable-find "yt-dlp") @@ -637,6 +658,7 @@ FIELDS-FACE-PAIRS is a list of fields and faces." "v" #'yeetube-mpv-toggle-video "V" #'yeetube-mpv-toggle-no-video-flag "s" #'yeetube-save-video + "S" #'yeetube-channel-streams "P" #'yeetube-play-saved-video "r" #'yeetube-replay "T" #'yeetube-mpv-toggle-torsocks |