tweaks to empv

This commit is contained in:
Chris Cochrun 2025-07-14 12:54:41 -05:00
parent 0b9f2c5f8b
commit c661203887
2 changed files with 27 additions and 14 deletions

View file

@ -5070,6 +5070,9 @@ Let's use pdf-tools for a lot better interaction with pdfs.
#+end_src #+end_src
** EMPV ** EMPV
:PROPERTIES:
:ID: 20250712T070328.619116
:END:
With empv we can perhaps control mpv much more fine grainly and even search youtube videos easier through emacs. Let's set it up. With empv we can perhaps control mpv much more fine grainly and even search youtube videos easier through emacs. Let's set it up.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package empv (use-package empv
@ -5104,8 +5107,8 @@ With empv we can perhaps control mpv much more fine grainly and even search yout
"https://youtube.com/%s=%s" "https://youtube.com/%s=%s"
(if video-id "watch?v" "playlist?list") (if video-id "watch?v" "playlist?list")
(or video-id playlist-id)))) (or video-id playlist-id))))
(title (if file (shell-command-to-string (title (if file (string-trim (shell-command-to-string
(format "yt-dlp --no-warnings --quiet --get-title %s" url)) (format "yt-dlp --no-warnings --quiet --get-title %s" url)))
(alist-get 'title item))) (alist-get 'title item)))
(output-buffer (generate-new-buffer "*yt-dlp*")) (output-buffer (generate-new-buffer "*yt-dlp*"))
(process (progn (process (progn
@ -5115,17 +5118,22 @@ With empv we can perhaps control mpv much more fine grainly and even search yout
:buffer output-buffer :buffer output-buffer
:command `("yt-dlp" "-o" :command `("yt-dlp" "-o"
"~/vids/%(title)s.%(ext)s" "~/vids/%(title)s.%(ext)s"
"-f best[ext=mp4]"
,(cl-coerce url 'string) ,(cl-coerce url 'string)
"--embed-thumbnail" "--embed-thumbnail"
"--sponsorblock-remove=sponsor,intro,outro")) "--sponsorblock-remove=sponsor,intro,outro"))
(get-buffer-process output-buffer))) (get-buffer-process output-buffer)))
(enqueue `(lambda (process event) (enqueue `(lambda (process event)
(when (eq (process-status process) 'exit) (when (eq (process-status process) 'exit)
(progn (message "running %s because %s" process event) (progn (message "running empv shtuff because %s is %s" process event)
(empv-enqueue (concat "/home/chris/vids/" (string-trim ,title) ".mp4")) (message "%s is a string? %s" ,title (stringp ,title))
;; (kill-buffer ,output-buffer) (let* ((files (directory-files
))))) "/home/chris/vids/" t ,title nil 1))
(file (car files)))
(message "files is %s" files)
(message "file is %s" file)
(message "title is %s" ,title)
(empv-enqueue file))
(kill-buffer ,output-buffer))))))
(message url) (message url)
(if (process-live-p process) (if (process-live-p process)
(set-process-sentinel (set-process-sentinel

19
init.el
View file

@ -3743,8 +3743,8 @@ targets."
"https://youtube.com/%s=%s" "https://youtube.com/%s=%s"
(if video-id "watch?v" "playlist?list") (if video-id "watch?v" "playlist?list")
(or video-id playlist-id)))) (or video-id playlist-id))))
(title (if file (shell-command-to-string (title (if file (string-trim (shell-command-to-string
(format "yt-dlp --no-warnings --quiet --get-title %s" url)) (format "yt-dlp --no-warnings --quiet --get-title %s" url)))
(alist-get 'title item))) (alist-get 'title item)))
(output-buffer (generate-new-buffer "*yt-dlp*")) (output-buffer (generate-new-buffer "*yt-dlp*"))
(process (progn (process (progn
@ -3754,17 +3754,22 @@ targets."
:buffer output-buffer :buffer output-buffer
:command `("yt-dlp" "-o" :command `("yt-dlp" "-o"
"~/vids/%(title)s.%(ext)s" "~/vids/%(title)s.%(ext)s"
"-f best[ext=mp4]"
,(cl-coerce url 'string) ,(cl-coerce url 'string)
"--embed-thumbnail" "--embed-thumbnail"
"--sponsorblock-remove=sponsor,intro,outro")) "--sponsorblock-remove=sponsor,intro,outro"))
(get-buffer-process output-buffer))) (get-buffer-process output-buffer)))
(enqueue `(lambda (process event) (enqueue `(lambda (process event)
(when (eq (process-status process) 'exit) (when (eq (process-status process) 'exit)
(progn (message "running %s because %s" process event) (progn (message "running empv shtuff because %s is %s" process event)
(empv-enqueue (concat "/home/chris/vids/" (string-trim ,title) ".mp4")) (message "%s is a string? %s" ,title (stringp ,title))
;; (kill-buffer ,output-buffer) (let* ((files (directory-files
))))) "/home/chris/vids/" t ,title nil 1))
(file (car files)))
(message "files is %s" files)
(message "file is %s" file)
(message "title is %s" ,title)
(empv-enqueue file))
(kill-buffer ,output-buffer))))))
(message url) (message url)
(if (process-live-p process) (if (process-live-p process)
(set-process-sentinel (set-process-sentinel