Replace ytel with ytdious

Better interface
This commit is contained in:
Case Duckworth 2021-10-05 14:23:47 -05:00
parent 4fe1c79b45
commit 3f7a8703ed
2 changed files with 49 additions and 8 deletions

13
init.el
View File

@ -2470,14 +2470,15 @@ If used with a numeric prefix argument N, N backticks will be inserted."
(setup (:straight xr))
(setup (:straight-when ytel
(setup (:straight-when ytdious
(executable-find "mpv"))
(:also-load acdw-ytel)
;; This might need to be changed depending on whether the instance goes down.
(:option ytel-invidious-api-url "https://invidious.snopyta.org")
(:also-load acdw-ytel) ; so named because I used ytel first
(:option ytdious-invidious-api-url "https://invidious.snopyta.org")
(:hook #'hl-line-mode)
(:bind "v" #'acdw/ytel-watch
"w" #'acdw/ytel-copy-link))
(:global "C-c y" #'ytdious)
(:bind "v" #'acdw/ytdious-watch
"w" #'acdw/ytdious-copy-link
"q" #'acdw/ytdious-quit))
(setup (:straight zzz-to-char)

View File

@ -7,12 +7,12 @@
;;; Code:
(require 'ytel)
(require 'ytel nil t)
(defun acdw/ytel-current-video-link ()
"Get the link of the video at point."
(let* ((video (ytel-get-current-video))
(id (ytel-video-id video)))
(id (ytel-video-id video)))
(concat "https://www.youtube.com/watch?v=" id)))
(defun acdw/ytel-watch () ; This could possibly use `browse-url'.
@ -31,5 +31,45 @@
(kill-new link)
(message "Copied %s to kill-ring" link)))
;;; YTDIOUS: https://github.com/spiderbit/ytdious
;; a fork of ytel that uses table-view or w/e. looks nicer
(require 'ytdious nil t)
(defun acdw/ytdious-current-video-link ()
"Get the link of the video at point."
(let* ((video (ytdious-get-current-video))
(id (ytdious-video-id-fun video)))
(concat "https://www.youtube.com/watch?v=" id)))
(defun acdw/ytdious-watch () ; This could possibly use `browse-url'.
"Stream video at point in mpv."
(interactive)
(let ((link (acdw/ytdious-current-video-link)))
(start-process "ytdious mpv" nil
"mpv"
link
"--ytdl-format=bestvideo[height<=?720]+bestaudio/best")
(message "Streaming %s..." link)))
(defun acdw/ytdious-copy-link ()
"Copy link of the video at point."
(interactive)
(let ((link (acdw/ytdious-current-video-link)))
(kill-new link)
(message "Copied %s to kill-ring" link)))
(defun acdw/ytdious-quit ()
"Quit ytdious."
;; This corrects an error with `ytdious-quit' where it doesn't have the right
;; buffer setup.
(interactive)
(quit-window))
;;; Ignore `ytdious-show-image-asyncron' because it's buggy.
(defalias 'ytdious-show-image-asyncron #'ignore)
(provide 'acdw-ytel)
;;; acdw-ytel.el ends here