From 56755f394d2130b58f128ebb099584b8e1392b11 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sat, 6 Apr 2024 20:42:14 +0300 Subject: Add yeetube-mpv-currently-playing Variable to hold info regarding currently playing video/file --- yeetube-mpv.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/yeetube-mpv.el b/yeetube-mpv.el index 5070fd5..141e6e9 100644 --- a/yeetube-mpv.el +++ b/yeetube-mpv.el @@ -43,6 +43,9 @@ "Video resolution/quality. Accepted values include: 1080, 720, 480, 360, 240, 144") +(defvar yeetube-mpv-currently-playing nil + "Currently playing information.") + (defun yeetube-mpv-change-video-quality () "Change video quality." (interactive) @@ -81,7 +84,7 @@ 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. This function is not specific to just playing urls. Feel free to use @@ -97,7 +100,9 @@ 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)))) + (defun yeetube-mpv-toggle-no-video-flag () "Toggle no video flag for mpv player." -- cgit v1.2.3 From ed7807cb7c8de3133cd1b503c0bbdeced1a5e6ab Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sat, 6 Apr 2024 20:43:08 +0300 Subject: yeetube-mpv: Add yeetube-mpv-modeline-mode --- yeetube-mpv.el | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/yeetube-mpv.el b/yeetube-mpv.el index 141e6e9..4bab5e9 100644 --- a/yeetube-mpv.el +++ b/yeetube-mpv.el @@ -46,6 +46,12 @@ 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) @@ -103,6 +109,22 @@ to play local files." "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." + :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." -- cgit v1.2.3 From c443a9146b70f0b9697e2ee68356ac79a19bd81e Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sat, 6 Apr 2024 20:43:31 +0300 Subject: yeetube: Add support for yeetube-modeline-mode --- yeetube.el | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/yeetube.el b/yeetube.el index c4a977f..3eb5ad3 100644 --- a/yeetube.el +++ b/yeetube.el @@ -228,7 +228,7 @@ Keywords: (interactive) (let* ((video-url (yeetube-get-url)) (video-title (yeetube-get :title)) - (proc (funcall yeetube-play-function video-url))) + (proc (funcall yeetube-play-function video-url (when yeetube-mpv-modeline-mode video-title)))) (when (processp proc) (process-put proc :now-playing video-title)) (push (list :url video-url :title video-title) yeetube-history) @@ -243,8 +243,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 +275,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 +662,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 +678,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)) -- cgit v1.2.3 From 447005142a254516ad51f85efc023e2b9dc0e92c Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Thu, 11 Apr 2024 16:22:25 +0300 Subject: [fix] yeetube-play: Use 2nd argument only when yeetube-mpv-modeline - Pass information for yeetube-mpv-modeline as a second argument only when it's enabled. This way it should not break current users configuration with different media players. We could write this differently to hardcode yeetube-mpv-play, but I would like to make it possible for others to make 3rd party media players to be used with yeetube & yeetube-mpv-modeline. --- yeetube-mpv.el | 7 ++++++- yeetube.el | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/yeetube-mpv.el b/yeetube-mpv.el index 4bab5e9..2e8325a 100644 --- a/yeetube-mpv.el +++ b/yeetube-mpv.el @@ -93,6 +93,8 @@ Accepted values include: 1080, 720, 480, 360, 240, 144") (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"))) @@ -110,7 +112,10 @@ to play local files." (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." + "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 diff --git a/yeetube.el b/yeetube.el index 3eb5ad3..838cfc1 100644 --- a/yeetube.el +++ b/yeetube.el @@ -228,7 +228,8 @@ Keywords: (interactive) (let* ((video-url (yeetube-get-url)) (video-title (yeetube-get :title)) - (proc (funcall yeetube-play-function video-url (when yeetube-mpv-modeline-mode video-title)))) + (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) -- cgit v1.2.3 From 06f24b6f58ae7d67b5201084562bb0b9926bf9b2 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Thu, 11 Apr 2024 16:28:45 +0300 Subject: Version bump: 2.1.6 --- yeetube.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yeetube.el b/yeetube.el index 838cfc1..8c49b83 100644 --- a/yeetube.el +++ b/yeetube.el @@ -5,7 +5,7 @@ ;; Author: Thanos Apollo ;; 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")) -- cgit v1.2.3