fixing empv-yt-dlp

This commit is contained in:
Chris Cochrun 2025-04-29 14:58:00 -05:00
parent 2a45a5decf
commit cd47010729
2 changed files with 24 additions and 10 deletions

View file

@ -5082,7 +5082,10 @@ With empv we can perhaps control mpv much more fine grainly and even search yout
(let* ((item (when (not file) (empv-youtube-results--current-item))) (let* ((item (when (not file) (empv-youtube-results--current-item)))
(video-id (when (not file) (alist-get 'videoId item))) (video-id (when (not file) (alist-get 'videoId item)))
(playlist-id (when (not file) (alist-get 'playlistId item))) (playlist-id (when (not file) (alist-get 'playlistId item)))
(url (if file (progn (message file) (string-replace "inv.cochrun.xyz" "youtube.com" file)) (url (if file
(progn
(message file)
(string-replace "inv.cochrun.xyz" "youtube.com" file))
(format (format
"https://youtube.com/%s=%s" "https://youtube.com/%s=%s"
(if video-id "watch?v" "playlist?list") (if video-id "watch?v" "playlist?list")
@ -5098,21 +5101,25 @@ 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]" "-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)
(progn (message "running %s because %s" process event) (progn (message "running %s because %s" process event)
(empv-enqueue (concat "/home/chris/vids/" (string-trim ,title) ".mp4")) (empv-enqueue (concat "/home/chris/vids/" (string-trim ,title) ".mp4"))
(kill-buffer output-buffer))))) ;; (kill-buffer ,output-buffer)
)))))
(message url) (message url)
(if (process-live-p process) (if (process-live-p process)
(set-process-sentinel (set-process-sentinel
process enqueue) process enqueue)
(message "No process running")))) (message "No process running"))))
;; (chris/empv-yt-dlp "https://inv.cochrun.xyz/watch?v=mNYcUMZfSP0")
(defun chris/empv-yt-dlp-jellyfin () (defun chris/empv-yt-dlp-jellyfin ()
"Grabs the current video at point and downloads it to my jellyfin server" "Grabs the current video at point and downloads it to my jellyfin server"
(interactive) (interactive)

13
init.el
View file

@ -3726,7 +3726,10 @@ targets."
(let* ((item (when (not file) (empv-youtube-results--current-item))) (let* ((item (when (not file) (empv-youtube-results--current-item)))
(video-id (when (not file) (alist-get 'videoId item))) (video-id (when (not file) (alist-get 'videoId item)))
(playlist-id (when (not file) (alist-get 'playlistId item))) (playlist-id (when (not file) (alist-get 'playlistId item)))
(url (if file (progn (message file) (string-replace "inv.cochrun.xyz" "youtube.com" file)) (url (if file
(progn
(message file)
(string-replace "inv.cochrun.xyz" "youtube.com" file))
(format (format
"https://youtube.com/%s=%s" "https://youtube.com/%s=%s"
(if video-id "watch?v" "playlist?list") (if video-id "watch?v" "playlist?list")
@ -3742,21 +3745,25 @@ 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]" "-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)
(progn (message "running %s because %s" process event) (progn (message "running %s because %s" process event)
(empv-enqueue (concat "/home/chris/vids/" (string-trim ,title) ".mp4")) (empv-enqueue (concat "/home/chris/vids/" (string-trim ,title) ".mp4"))
(kill-buffer output-buffer))))) ;; (kill-buffer ,output-buffer)
)))))
(message url) (message url)
(if (process-live-p process) (if (process-live-p process)
(set-process-sentinel (set-process-sentinel
process enqueue) process enqueue)
(message "No process running")))) (message "No process running"))))
;; (chris/empv-yt-dlp "https://inv.cochrun.xyz/watch?v=mNYcUMZfSP0")
(defun chris/empv-yt-dlp-jellyfin () (defun chris/empv-yt-dlp-jellyfin ()
"Grabs the current video at point and downloads it to my jellyfin server" "Grabs the current video at point and downloads it to my jellyfin server"
(interactive) (interactive)