blob: 6c59552e5e4aa20f477aad672bb3bbcb81f069bb (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
;;; yeetube-mpv.el --- Provide yeetube mpv functionality -*- lexical-binding: t; -*-
;; Copyright (C) 2023 Thanos Apollo
;; Author: Thanos Apollo <[email protected]>
;; Keywords: extensions youtube videos
;; URL: https://git.thanosapollo.com/yeetube
;; Version: 0.1
;; Package-Requires: ((emacs "27.2"))
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; This package is a yeetube extension, to start an mpv process &
;; remotely control it.
;;; Code:
(defcustom yeetube-mpv-disable-video nil
"Add no-video flag when using mpv."
:type 'boolean
:group 'yeetube)
(defvar yeetube-mpv-path (executable-find "mpv")
"Path for mpv executable.")
(defun yeetube-mpv-process (command)
"Start yeetube process for shell COMMAND."
(unless yeetube-mpv-path
(error "Mpv not found. Install mpv or change the value of yeetube-player"))
(let ((yeetube-mpv-process "yeetube"))
(dolist (process (process-list))
(when (string-match yeetube-mpv-process (process-name process))
(kill-process process)))
(sit-for 0.1)
(unless (get-process yeetube-mpv-process)
(start-process-shell-command
"yeetube" nil command))))
(defun yeetube-mpv-play-url (url)
"Start yeetube process to play URL using mpv."
(yeetube-mpv-process
(concat yeetube-mpv-path " "
(shell-quote-argument url)
(when yeetube-mpv-disable-video " --no-video")))
(message "yeetube: starting mpv process"))
(defun yeetube-mpv-toggle-no-video-flag ()
"Toggle no video flag for mpv player."
(interactive)
(if yeetube-mpv-disable-video
(progn (setf yeetube-mpv-disable-video nil)
(message "yeetube: mpv removed no-video flag"))
(setf yeetube-mpv-disable-video t)
(message "yeetube: mpv added no-video flag")))
(defun yeetube-mpv-send-keypress (key)
"Send KEY to yeetube-mpv-process."
(interactive "sKey: ")
(process-send-string "yeetube" key))
(defun yeetube-mpv-toggle-pause ()
"Toggle pause mpv."
(interactive)
(yeetube-mpv-send-keypress "p")
(message "yeetube: toggle pause"))
(defun yeetube-mpv-toggle-fullscreen ()
"Toggle fullscreen."
(interactive)
(yeetube-mpv-send-keypress "f")
(message "toggle fullscreen"))
(defun yeetube-mpv-toggle-video ()
"Toggle video mpv."
(interactive)
(yeetube-mpv-send-keypress "_")
(message "yeetube: toggle video"))
(provide 'yeetube-mpv)
;;; yeetube-mpv.el ends here
|