diff options
| author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-07-27 16:29:41 +0100 | 
|---|---|---|
| committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-07-27 16:36:34 +0100 | 
| commit | f740c21d7957e0c1fd4099efcd01193374e8cee9 (patch) | |
| tree | cfceac8ef77a6c7bfb2b841d92a34197580bb072 /Emacs/.config/emacs/elisp | |
| parent | 370793e72e67c22fae687ee3438fe65dcb136311 (diff) | |
| download | dotfiles-f740c21d7957e0c1fd4099efcd01193374e8cee9.tar.gz dotfiles-f740c21d7957e0c1fd4099efcd01193374e8cee9.tar.bz2 dotfiles-f740c21d7957e0c1fd4099efcd01193374e8cee9.zip  | |
(Emacs/elisp)~Make separate module for mpv from org-bookmark
Diffstat (limited to 'Emacs/.config/emacs/elisp')
| -rw-r--r-- | Emacs/.config/emacs/elisp/mpv.el | 58 | ||||
| -rw-r--r-- | Emacs/.config/emacs/elisp/org-bookmark.el | 18 | 
2 files changed, 61 insertions, 15 deletions
diff --git a/Emacs/.config/emacs/elisp/mpv.el b/Emacs/.config/emacs/elisp/mpv.el new file mode 100644 index 0000000..0339dee --- /dev/null +++ b/Emacs/.config/emacs/elisp/mpv.el @@ -0,0 +1,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 diff --git a/Emacs/.config/emacs/elisp/org-bookmark.el b/Emacs/.config/emacs/elisp/org-bookmark.el index 3b4c7d1..d2ab950 100644 --- a/Emacs/.config/emacs/elisp/org-bookmark.el +++ b/Emacs/.config/emacs/elisp/org-bookmark.el @@ -27,11 +27,9 @@  (autoload #'org-get-tags "org")  (autoload #'org-entry-get "org")  (autoload #'org-make-tags-matcher "org") +(autoload #'mpv-start-process "mpv")  (defvar org-bookmark/file (expand-file-name (concat org-directory "/bookmarks.org"))) -(defvar org-bookmark/mpv-args "-v --ytdl-raw-options=force-ipv4= \ -                               --ytdl-format=\"bestvideo[height<=1080][fps<=60]+bestaudio/best[height<=1920]\" \ -                               --profile=fast --hwdec=auto-copy")  (defun org-bookmark/--get-heading-data ()    "In an org-mode buffer, with point on a heading: get the title, @@ -68,6 +66,7 @@ urls)."  (defvar org-bookmark/--cache nil    "Cached alist constructed from bookmarks file of form (TITLE+TAG  . URL).") +  (defvar org-bookmark/--cache-last-modified nil    "Last modified time for bookmarks file as a float.") @@ -85,21 +84,10 @@ are cached for faster lookup."                                   (org-bookmark/--get-all-heading-data))))))    org-bookmark/--cache) -(defun org-bookmark/open-mpv (url) -  (interactive) -  (message "[bookmark]: Starting MPV process") -  (with-current-buffer (get-buffer-create "*mpv*") -    (ansi-color-for-comint-mode-on) -    (comint-mode)) -  (set-process-filter (start-process-shell-command -                       "bookmark-mpv" "*mpv*" -                       (concat "mpv " org-bookmark/mpv-args " \"" url "\"")) -                      #'comint-output-filter)) -  (defconst org-bookmark/dispatch-list    '((("^https://\\(www.\\)?youtu\\(.\\)?be"        "\\.mp4$") -     . org-bookmark/open-mpv) +     . mpv-start-process)      (otherwise . eww))    "List of pairs of type (PATTERNS . FUNC) which is used in  ORG-BOOKMARK/OPEN-BOOKMARK to handle opening urls.  | 
