diff options
-rw-r--r-- | lisp/servall-results.el | 2 | ||||
-rw-r--r-- | lisp/servall-ytdl.el | 35 |
2 files changed, 30 insertions, 7 deletions
diff --git a/lisp/servall-results.el b/lisp/servall-results.el index 33a1461..137c52f 100644 --- a/lisp/servall-results.el +++ b/lisp/servall-results.el @@ -30,6 +30,6 @@ (defun servall-results-open () (interactive) - (funcall servall-results-open-function)) + (call-interactively servall-results-open-function)) (provide 'servall-results) diff --git a/lisp/servall-ytdl.el b/lisp/servall-ytdl.el index 426333b..9d2e1f0 100644 --- a/lisp/servall-ytdl.el +++ b/lisp/servall-ytdl.el @@ -2,6 +2,9 @@ (require 'servall-client) (require 'servall-results) +(defvar servall-ytdl-invidious-host "https://yewtu.be") +(defvar servall-ytdl-player-command "mpv") + ;; ytdl results (define-derived-mode servall-ytdl-results-mode servall-results-mode "servall-ytdl-results" @@ -28,14 +31,34 @@ (erase-buffer) (mapc (lambda (result) - (let ((title (alist-get 'title result))) - (insert - (propertize - (concat "* " title "\n") - 'title title)) - (insert (alist-get 'description result) "\n\n"))) + (insert + (propertize + (concat "* " (alist-get 'title result) " [" + (seconds-to-string (alist-get 'duration result)) "]\n") + 'id (alist-get 'id result))) + (insert (alist-get 'description result) "\n\n")) results) (goto-char (point-min)))) (funcall cb)))) +(defun servall-ytdl-copy-id () + (interactive) + (let ((id (get-text-property (point) 'id))) + (kill-new id) + (message "Copied %s" id))) +(define-key servall-ytdl-results-mode-map "w" 'servall-ytdl-copy-id) + +(defun servall-ytdl-results-open (arg) + (interactive "P") + (let* ((id (get-text-property (point) 'id)) + (url (format "%s/watch?v=%s" servall-ytdl-invidious-host id))) + (cond ((equal arg '(4)) + (start-process-with-torsocks + nil "servall-ytdl-player" "*servall-ytdl-player*" + servall-ytdl-player-command url)) + ((equal arg '(16)) + (start-process "servall-ytdl-player" "*servall-ytdl-player*" + servall-ytdl-player-command url)) + (t (emms-play-url url))))) + (provide 'servall-ytdl) |