aboutsummaryrefslogtreecommitdiffstats
path: root/yeetube-mpv.el
diff options
context:
space:
mode:
Diffstat (limited to 'yeetube-mpv.el')
-rw-r--r--yeetube-mpv.el65
1 files changed, 48 insertions, 17 deletions
diff --git a/yeetube-mpv.el b/yeetube-mpv.el
index 2c925a4..39f8881 100644
--- a/yeetube-mpv.el
+++ b/yeetube-mpv.el
@@ -32,20 +32,34 @@
:group 'yeetube)
(defcustom yeetube-mpv-enable-torsocks nil
- "Enable torsocks.")
+ "Enable torsocks."
+ :type 'boolean
+ :group 'yeetube)
-(defvar yeetube-mpv-path (executable-find "mpv")
- "Path for mpv executable.")
+(defcustom yeetube-mpv-show-status nil
+ "Show mpv status in mode-line."
+ :type 'boolean
+ :group 'yeetube)
+
+(setf (alist-get 'yeetube-mpv-show-status mode-line-misc-info nil t)
+ '(("" yeetube-mpv-status)))
+
+(defvar yeetube-mpv-command '("mpv" "--no-msg-color" "--term-status-msg=${?=audio==1:A}${?=video==1:V} ${?=pause==yes:Paused}${?=pause==no:Playing} (${percent-pos}%)")
+ "Cons of mpv command and list of args passed to it.")
(defvar yeetube-mpv-torsocks (executable-find "torsocks")
"Path to torsocks executable.")
(defvar yeetube-mpv-video-quality "720"
- "Video resolution/quality
-
+ "Video resolution/quality.
Accepted values include: 1080, 720, 480, 360, 240, 144")
+(defvar yeetube-mpv-status nil
+ "Contains a brief status of the mpv process.")
+(put 'yeetube-mpv-status 'risky-local-variable t)
+
(defun yeetube-mpv-change-video-quality ()
+ "Change video quality."
(interactive)
(let ((new-value (completing-read (format "Set video quality (current value %s):" yeetube-mpv-video-quality)
'("1080" "720" "480" "360" "240" "144") nil t)))
@@ -87,17 +101,18 @@ Accepted values include: 1080, 720, 480, 360, 240, 144")
This function is not specific to just playing urls. Feel free to use
to play local files."
- (yeetube-mpv-process
- (concat (when yeetube-mpv-enable-torsocks
- (concat yeetube-mpv-torsocks " "))
- yeetube-mpv-path " --ytdl-format="
- (yeetube-mpv-ytdl-format-video-quality yeetube-mpv-video-quality)
- " "
- (shell-quote-argument input)
- (when yeetube-mpv-disable-video " --no-video")))
- (message (if yeetube-mpv-enable-torsocks
- "yeetube: Starting mpv process (using torsocks)"
- "yeetube: Starting mpv process")))
+ (let ((yeetube-mpv-path (executable-find "mpv")))
+ (yeetube-mpv-process
+ (concat (when yeetube-mpv-enable-torsocks
+ (concat yeetube-mpv-torsocks " "))
+ yeetube-mpv-path " --ytdl-format="
+ (yeetube-mpv-ytdl-format-video-quality yeetube-mpv-video-quality)
+ " "
+ (shell-quote-argument input)
+ (when yeetube-mpv-disable-video " --no-video")))
+ (message (if yeetube-mpv-enable-torsocks
+ "yeetube: Starting mpv process (using torsocks)"
+ "yeetube: Starting mpv process"))))
(defun yeetube-mpv-toggle-no-video-flag ()
"Toggle no video flag for mpv player."
@@ -109,7 +124,7 @@ to play local files."
(message "yeetube: mpv disabled video")))
(defun yeetube-mpv-send-keypress (key)
- "Send KEY to yeetube-mpv-process."
+ "Send KEY to `yeetube-mpv-process'."
(interactive "sKey: ")
(process-send-string "yeetube" key))
@@ -131,5 +146,21 @@ to play local files."
(yeetube-mpv-send-keypress "_")
(message "yeetube: toggle video"))
+(defun yeetube-mpv-forward ()
+ "Forward video."
+ (interactive)
+ (yeetube-mpv-send-keypress ""))
+
+(defun yeetube-mpv-backward ()
+ "Go backwards in video."
+ (interactive)
+ (yeetube-mpv-send-keypress ""))
+
+(defun yeetube-mpv-quit ()
+ "Quit mpv."
+ (interactive)
+ (yeetube-mpv-send-keypress "q")
+ (message "yeetube: quit"))
+
(provide 'yeetube-mpv)
;;; yeetube-mpv.el ends here