blob: 0339dee0839e645dbba3dec877706018653e5237 (
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
|
;;; mpv.el --- Open MPV through Emacs! -*- lexical-binding: t; -*-
;; Copyright (C) 2024 Aryadev Chavali
;; Author: Aryadev Chavali <aryadev@aryadevchavali.com>
;; Keywords: convenience
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License Version
;; 2 as published by the Free Software Foundation.
;; 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:
;;
;;; Code:
(autoload #'ffap-guesser "ffap")
(autoload #'ansi-color-for-comint-mode-on "ansi-color")
(autoload #'comint-output-filter "comint")
(defvar mpv-ytdl-args "--ytdl-format=\"bestvideo[height<=1080][fps<=60]+bestaudio/best[height<=1920]\""
"Arguments for ytdl in mpv format.")
(defvar mpv-args "-v --profile=fast --hwdec=auto-copy"
"General arguments for mpv binary.")
(defun mpv--make-args ()
(concat mpv-args " " mpv-ytdl-args))
(defun mpv-start-process (url)
(message "[mpv]: Starting mpv on `%s'" url)
(with-current-buffer (get-buffer-create "*mpv*")
(ansi-color-for-comint-mode-on)
(comint-mode))
(set-process-filter (start-process-shell-command
"mpv" "*mpv*"
(concat "mpv " (mpv--make-args) " \"" url "\""))
#'comint-output-filter))
(defvar mpv--history nil)
(defun mpv-open-video ()
(interactive)
(let ((url (completing-read "Enter URL: " nil nil t (ffap-guesser) mpv--history)))
(mpv-start-process url)
(switch-to-buffer "*mpv*")))
(provide 'mpv)
;;; mpv.el ends here
|