aboutsummaryrefslogtreecommitdiffstats
path: root/yeetube-mpv.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-03-18 11:03:56 +0200
committerThanos Apollo <[email protected]>2024-03-18 11:29:55 +0200
commitffd26e2ffe30f01dec4924b6c184509cb0e3aa6b (patch)
tree563fa9008a5a6eabc5143917e6852b42790a93df /yeetube-mpv.el
parent5fa23846a66e7a57c0b9bb9894227f4cce3ebe30 (diff)
parent3916a2332a79c0640b5f9167bf67865493264937 (diff)
Merge patches from Rahguzar into 2.1.5-dev
Patches sent by Rahguzar <[email protected]>: 1. Make use of `url-retrieve` for fetching youtube urls asynchronously. 2. Use `url-queue-retrieve` for fetching thumbnails, this removes the dependency on `wget` and also fixes the sort issue. 3. Commands for showing playlists/related videos. 4. Parse json string to remove json encoding artifacts. 5. Refactor mpv process to not rely on shell quoting. 6. Show mpv status on modeline. 7. Commands for seeking forward/backward. Merged with minor tweaks.
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