summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-04-11 16:28:58 +0300
committerThanos Apollo <[email protected]>2024-04-11 16:28:58 +0300
commitdfcbb8498b30b83d6f97d5777603d5f2dce39298 (patch)
treeb9cfdd661fd5156e2ffe039ab232b17dad6b362c
parentf9c28a527a60811c4b60bdd3730ca25c9522739a (diff)
parent06f24b6f58ae7d67b5201084562bb0b9926bf9b2 (diff)
Merge branch '2.1.6-dev'
- Add support for yeetube-mpv-modeline
-rw-r--r--yeetube-mpv.el36
-rw-r--r--yeetube.el21
2 files changed, 47 insertions, 10 deletions
diff --git a/yeetube-mpv.el b/yeetube-mpv.el
index 5070fd5..2e8325a 100644
--- a/yeetube-mpv.el
+++ b/yeetube-mpv.el
@@ -43,6 +43,15 @@
"Video resolution/quality.
Accepted values include: 1080, 720, 480, 360, 240, 144")
+(defvar yeetube-mpv-currently-playing nil
+ "Currently playing information.")
+
+(defun yeetube-mpv-modeline-string ()
+ "Return modeline string for yeetube-mpv."
+ (if yeetube-mpv-currently-playing
+ (format "%s" yeetube-mpv-currently-playing)
+ "nil"))
+
(defun yeetube-mpv-change-video-quality ()
"Change video quality."
(interactive)
@@ -81,9 +90,11 @@ Accepted values include: 1080, 720, 480, 360, 240, 144")
"Return shell quoted argument for ytdlp with RESOLUTION."
(shell-quote-argument (format "bestvideo[height<=?%s]+bestaudio/best" resolution)))
-(defun yeetube-mpv-play (input)
+(defun yeetube-mpv-play (input &optional info)
"Start yeetube process to play INPUT using mpv.
+INFO: Information to display with `yeetube-mpv-modeline-mode'
+
This function is not specific to just playing urls. Feel free to use
to play local files."
(let ((yeetube-mpv-path (executable-find "mpv")))
@@ -97,7 +108,28 @@ to play local files."
(when yeetube-mpv-disable-video " --no-video")))
(message (if yeetube-mpv-enable-torsocks
"yeetube: Starting mpv process (using torsocks)"
- "yeetube: Starting mpv process"))))
+ "yeetube: Starting mpv process"))
+ (setf yeetube-mpv-currently-playing (format "[%s]" info))))
+
+(define-minor-mode yeetube-mpv-modeline-mode
+ "Minor mode for showing currently playing information on the modeline.
+
+To use this mode, you should set `yeetube-play-function' to
+`yeetube-mpv-play'."
+ :global t
+ :group 'yeetube
+ :lighter nil
+ (if yeetube-mpv-modeline-mode
+ (progn
+ (add-to-list 'global-mode-string '(:eval
+ (format " ♫:%s" (yeetube-mpv-modeline-string))))
+ (force-mode-line-update))
+ (setf global-mode-string
+ (seq-remove (lambda (item)
+ (and (listp item) (eq (car item) :eval)
+ (string-prefix-p " ♫:" (format "%s" (eval (cadr item))))))
+ global-mode-string))
+ (force-mode-line-update)))
(defun yeetube-mpv-toggle-no-video-flag ()
"Toggle no video flag for mpv player."
diff --git a/yeetube.el b/yeetube.el
index c4a977f..8c49b83 100644
--- a/yeetube.el
+++ b/yeetube.el
@@ -5,7 +5,7 @@
;; Author: Thanos Apollo <[email protected]>
;; Keywords: extensions youtube videos
;; URL: https://thanosapollo.org/projects/yeetube/
-;; Version: 2.1.5
+;; Version: 2.1.6
;; Package-Requires: ((emacs "27.2") (compat "29.1.4.2"))
@@ -228,7 +228,8 @@ Keywords:
(interactive)
(let* ((video-url (yeetube-get-url))
(video-title (yeetube-get :title))
- (proc (funcall yeetube-play-function video-url)))
+ (proc (apply yeetube-play-function video-url
+ (when yeetube-mpv-modeline-mode (list video-title)))))
(when (processp proc)
(process-put proc :now-playing video-title))
(push (list :url video-url :title video-title) yeetube-history)
@@ -243,8 +244,9 @@ Select entry title from `yeetube-history' and play corresponding URL."
(let* ((titles (mapcar (lambda (entry) (cl-getf entry :title)) yeetube-history))
(selected (completing-read "Replay: " titles))
(selected-entry (cl-find-if (lambda (entry) (string= selected (cl-getf entry :title))) yeetube-history))
+ (title (cl-getf selected-entry :title))
(url (cl-getf selected-entry :url)))
- (funcall yeetube-play-function url)
+ (funcall yeetube-play-function url (when yeetube-mpv-modeline-mode title))
(message "Replaying: %s" selected)))
(defun yeetube-load-saved-videos ()
@@ -274,11 +276,14 @@ Select entry title from `yeetube-history' and play corresponding URL."
"Select & Play a saved video."
(interactive)
(yeetube-load-saved-videos)
- (let ((video (completing-read "Select video: " yeetube-saved-videos nil t)))
- (funcall yeetube-play-function (cdr (assoc video yeetube-saved-videos)))
+ (let* ((video (completing-read "Select video: " yeetube-saved-videos nil t))
+ (url (cdr (assoc video yeetube-saved-videos)))
+ (title (car (assoc video yeetube-saved-videos))))
+ (funcall yeetube-play-function url (when yeetube-mpv-modeline-mode title))
(message "Playing: %s" (car (assoc video yeetube-saved-videos)))))
;;;###autoload
+
(defun yeetube-remove-saved-video ()
"Select video to remove from saved videos."
(interactive)
@@ -658,12 +663,12 @@ A and B are vectors."
"Yeetube mode."
:keymap yeetube-mode-map
(setf tabulated-list-format
- [("Title" 60 t)
+ [("Title" 50 t)
("Views" 11 yeetube--sort-views)
("Duration" 9 yeetube--sort-duration)
("Date" 13 yeetube--sort-date)
("Channel" 12 t)
- ("Thumbnail" 0 nil)]
+ ("Thumbnail" 20 nil)]
tabulated-list-entries
(cl-map 'list
(lambda (content)
@@ -674,7 +679,7 @@ A and B are vectors."
:duration 'yeetube-face-duration
:date 'yeetube-face-date
:channel 'yeetube-face-channel
- :image nil)))
+ :image nil)))
yeetube-content)
tabulated-list-sort-key (cons yeetube-default-sort-column
yeetube-default-sort-ascending))