making a yt-dlp to empv function
This commit is contained in:
parent
d0ff0b78ad
commit
2f23e73011
158
README.org
158
README.org
|
@ -5066,91 +5066,101 @@ 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)))
|
||||
(video-id (when (not file) (alist-get 'videoId item)))
|
||||
(playlist-id (when (not file) (alist-get 'playlistId item)))
|
||||
(title (if file (shell-command
|
||||
(format "yt-dlp --get-title %s" file))
|
||||
(title (if file (shell-command-to-string
|
||||
(format "yt-dlp --no-warnings --quiet --get-title %s" file))
|
||||
(alist-get 'title item)))
|
||||
(url (if file file
|
||||
(format
|
||||
"https://youtube.com/%s=%s"
|
||||
(if video-id "watch?v" "playlist?list")
|
||||
(or video-id playlist-id)))))
|
||||
(or video-id playlist-id))))
|
||||
(output-buffer (generate-new-buffer "*yt-dlp*"))
|
||||
(process (progn
|
||||
(message "Starting to download %s at %s" title url)
|
||||
(make-process
|
||||
:name "yt-dlp"
|
||||
:buffer output-buffer
|
||||
:command `("yt-dlp" "-o"
|
||||
"~/vids/%(title)s.%(ext)s"
|
||||
;; "-f best[ext=mp4]"
|
||||
,(cl-coerce url 'string)
|
||||
"--embed-thumbnail"
|
||||
"--sponsorblock-remove=sponsor,intro,outro"))
|
||||
(get-buffer-process output-buffer)))
|
||||
(enqueue `(lambda (process event)
|
||||
(message "running %s because %s" process event)
|
||||
(empv-enqueue (concat "/home/chris/vids/" (string-trim ,title) ".mp4")))))
|
||||
(message url)
|
||||
(async-start-process
|
||||
"yt-dlp" "yt-dlp"
|
||||
(lambda ()
|
||||
(let ((file (format "/home/chris/vids/%s.%s" title "webm")))
|
||||
(empv-play-or-enqueue file))
|
||||
(message "here be the url %s" url))
|
||||
"-o" "'/home/chris/vids/%(title)s.%(ext)s'" url)))
|
||||
(if (process-live-p process)
|
||||
(set-process-sentinel
|
||||
process enqueue)
|
||||
(message "No process running"))))
|
||||
|
||||
(get-process "yt-dlp")
|
||||
(chris/empv-yt-dlp "https://inv.cochrun.xyz/watch?v=qRE6kf30u4g")
|
||||
(defun chris/empv-yt-dlp-jellyfin ()
|
||||
"Grabs the current video at point and downloads it to my jellyfin server"
|
||||
(interactive)
|
||||
(let* ((server "jelly.cochrun.xyz")
|
||||
(item (empv-youtube-results--current-item))
|
||||
(video-id (alist-get 'videoId item))
|
||||
(playlist-id (alist-get 'playlistId item))
|
||||
(title (alist-get 'title item))
|
||||
(location (completing-read "location: " '("dev" "house" "ministry" "misc")))
|
||||
(url (format
|
||||
"https://youtube.com/%s=%s"
|
||||
(if video-id "watch?v" "playlist?list")
|
||||
(or video-id playlist-id))))
|
||||
(async-shell-command (concat
|
||||
"ssh " server " \"" "yt-dlp"
|
||||
" -o '/storage/media/media/chris/extras/yt/"
|
||||
location
|
||||
"/%(title)s.%(ext)s'"
|
||||
" '" url "'" "\""))
|
||||
(message (format "%s is downloading to the %s folder on jellyfin" url location))))
|
||||
|
||||
(defun chris/empv-yt-dlp-jellyfin ()
|
||||
"Grabs the current video at point and downloads it to my jellyfin server"
|
||||
(interactive)
|
||||
(let* ((server "jelly.cochrun.xyz")
|
||||
(item (empv-youtube-results--current-item))
|
||||
(video-id (alist-get 'videoId item))
|
||||
(playlist-id (alist-get 'playlistId item))
|
||||
(title (alist-get 'title item))
|
||||
(location (completing-read "location: " '("dev" "house" "ministry" "misc")))
|
||||
(url (format
|
||||
"https://youtube.com/%s=%s"
|
||||
(if video-id "watch?v" "playlist?list")
|
||||
(or video-id playlist-id))))
|
||||
(async-shell-command (concat
|
||||
"ssh " server " \"" "yt-dlp"
|
||||
" -o '/storage/media/media/chris/extras/yt/"
|
||||
location
|
||||
"/%(title)s.%(ext)s'"
|
||||
" '" url "'" "\""))
|
||||
(message (format "%s is downloading to the %s folder on jellyfin" url location))))
|
||||
(defun chris/empv-org-play-link (&optional link)
|
||||
"Play link in empv from either supplied link or link at point in org-mode"
|
||||
(interactive)
|
||||
(let ((link (if link
|
||||
link
|
||||
(org-babel-read-link))))
|
||||
(empv-play link)))
|
||||
|
||||
(defun chris/empv-org-play-link (&optional link)
|
||||
"Play link in empv from either supplied link or link at point in org-mode"
|
||||
(interactive)
|
||||
(let ((link (if link
|
||||
link
|
||||
(org-babel-read-link))))
|
||||
(empv-play link)))
|
||||
(defun chris/dired-empv-play-or-enqueue ()
|
||||
"Play file at point in dired"
|
||||
(interactive)
|
||||
(let* ((file (dired-get-filename)))
|
||||
(empv-play-or-enqueue file)))
|
||||
|
||||
(defun chris/dired-empv-play-or-enqueue ()
|
||||
"Play file at point in dired"
|
||||
(interactive)
|
||||
(let* ((file (dired-get-filename)))
|
||||
(empv-play-or-enqueue file)))
|
||||
(defun chris/empv-seek-forward ()
|
||||
"Seek forward 20 seconds"
|
||||
(interactive)
|
||||
(empv-seek "20"))
|
||||
|
||||
(defun chris/empv-seek-forward ()
|
||||
"Seek forward 20 seconds"
|
||||
(interactive)
|
||||
(empv-seek "20"))
|
||||
|
||||
:general
|
||||
(chris/leader-keys
|
||||
:states 'normal
|
||||
:keymaps 'override
|
||||
"vo" 'empv-play-or-enqueue
|
||||
"vt" 'empv-toggle
|
||||
"vv" 'empv-play-video
|
||||
"vx" 'empv-chapter-select
|
||||
"vy" 'empv-youtube-tabulated
|
||||
"vn" 'empv-playlist-next
|
||||
"vp" 'empv-playlist-prev
|
||||
"vs" 'empv-playlist-select
|
||||
"vS" 'chris/empv-seek-forward)
|
||||
(general-def
|
||||
:states 'normal
|
||||
:keymaps 'empv-youtube-results-mode-map
|
||||
"q" 'kill-current-buffer
|
||||
"RET" 'empv-youtube-results-play-or-enqueue-current
|
||||
"i" 'empv-youtube-results-inspect
|
||||
"d" 'chris/empv-yt-dlp
|
||||
"D" 'chris/empv-yt-dlp-jellyfin)
|
||||
(general-def
|
||||
:states 'normal
|
||||
:keymaps 'dired-mode-map
|
||||
"vi" 'chris/dired-empv-play-or-enqueue))
|
||||
:general
|
||||
(chris/leader-keys
|
||||
:states 'normal
|
||||
:keymaps 'override
|
||||
"vo" 'empv-play-or-enqueue
|
||||
"vt" 'empv-toggle
|
||||
"vv" 'empv-play-video
|
||||
"vx" 'empv-chapter-select
|
||||
"vy" 'empv-youtube-tabulated
|
||||
"vn" 'empv-playlist-next
|
||||
"vp" 'empv-playlist-prev
|
||||
"vs" 'empv-playlist-select
|
||||
"vS" 'chris/empv-seek-forward)
|
||||
(general-def
|
||||
:states 'normal
|
||||
:keymaps 'empv-youtube-results-mode-map
|
||||
"q" 'kill-current-buffer
|
||||
"RET" 'empv-youtube-results-play-or-enqueue-current
|
||||
"i" 'empv-youtube-results-inspect
|
||||
"d" 'chris/empv-yt-dlp
|
||||
"D" 'chris/empv-yt-dlp-jellyfin)
|
||||
(general-def
|
||||
:states 'normal
|
||||
:keymaps 'dired-mode-map
|
||||
"vi" 'chris/dired-empv-play-or-enqueue))
|
||||
#+end_src
|
||||
|
||||
I need to update the new normal mode pieces to this...
|
||||
|
|
158
init.el
158
init.el
|
@ -3712,91 +3712,101 @@ targets."
|
|||
(let* ((item (when (not file) (empv-youtube-results--current-item)))
|
||||
(video-id (when (not file) (alist-get 'videoId item)))
|
||||
(playlist-id (when (not file) (alist-get 'playlistId item)))
|
||||
(title (if file (shell-command
|
||||
(format "yt-dlp --get-title %s" file))
|
||||
(title (if file (shell-command-to-string
|
||||
(format "yt-dlp --no-warnings --quiet --get-title %s" file))
|
||||
(alist-get 'title item)))
|
||||
(url (if file file
|
||||
(format
|
||||
"https://youtube.com/%s=%s"
|
||||
(if video-id "watch?v" "playlist?list")
|
||||
(or video-id playlist-id)))))
|
||||
(or video-id playlist-id))))
|
||||
(output-buffer (generate-new-buffer "*yt-dlp*"))
|
||||
(process (progn
|
||||
(message "Starting to download %s at %s" title url)
|
||||
(make-process
|
||||
:name "yt-dlp"
|
||||
:buffer output-buffer
|
||||
:command `("yt-dlp" "-o"
|
||||
"~/vids/%(title)s.%(ext)s"
|
||||
;; "-f best[ext=mp4]"
|
||||
,(cl-coerce url 'string)
|
||||
"--embed-thumbnail"
|
||||
"--sponsorblock-remove=sponsor,intro,outro"))
|
||||
(get-buffer-process output-buffer)))
|
||||
(enqueue `(lambda (process event)
|
||||
(message "running %s because %s" process event)
|
||||
(empv-enqueue (concat "/home/chris/vids/" (string-trim ,title) ".mp4")))))
|
||||
(message url)
|
||||
(async-start-process
|
||||
"yt-dlp" "yt-dlp"
|
||||
(lambda ()
|
||||
(let ((file (format "/home/chris/vids/%s.%s" title "webm")))
|
||||
(empv-play-or-enqueue file))
|
||||
(message "here be the url %s" url))
|
||||
"-o" "'/home/chris/vids/%(title)s.%(ext)s'" url)))
|
||||
(if (process-live-p process)
|
||||
(set-process-sentinel
|
||||
process enqueue)
|
||||
(message "No process running"))))
|
||||
|
||||
(get-process "yt-dlp")
|
||||
(chris/empv-yt-dlp "https://inv.cochrun.xyz/watch?v=qRE6kf30u4g")
|
||||
(defun chris/empv-yt-dlp-jellyfin ()
|
||||
"Grabs the current video at point and downloads it to my jellyfin server"
|
||||
(interactive)
|
||||
(let* ((server "jelly.cochrun.xyz")
|
||||
(item (empv-youtube-results--current-item))
|
||||
(video-id (alist-get 'videoId item))
|
||||
(playlist-id (alist-get 'playlistId item))
|
||||
(title (alist-get 'title item))
|
||||
(location (completing-read "location: " '("dev" "house" "ministry" "misc")))
|
||||
(url (format
|
||||
"https://youtube.com/%s=%s"
|
||||
(if video-id "watch?v" "playlist?list")
|
||||
(or video-id playlist-id))))
|
||||
(async-shell-command (concat
|
||||
"ssh " server " \"" "yt-dlp"
|
||||
" -o '/storage/media/media/chris/extras/yt/"
|
||||
location
|
||||
"/%(title)s.%(ext)s'"
|
||||
" '" url "'" "\""))
|
||||
(message (format "%s is downloading to the %s folder on jellyfin" url location))))
|
||||
|
||||
(defun chris/empv-yt-dlp-jellyfin ()
|
||||
"Grabs the current video at point and downloads it to my jellyfin server"
|
||||
(interactive)
|
||||
(let* ((server "jelly.cochrun.xyz")
|
||||
(item (empv-youtube-results--current-item))
|
||||
(video-id (alist-get 'videoId item))
|
||||
(playlist-id (alist-get 'playlistId item))
|
||||
(title (alist-get 'title item))
|
||||
(location (completing-read "location: " '("dev" "house" "ministry" "misc")))
|
||||
(url (format
|
||||
"https://youtube.com/%s=%s"
|
||||
(if video-id "watch?v" "playlist?list")
|
||||
(or video-id playlist-id))))
|
||||
(async-shell-command (concat
|
||||
"ssh " server " \"" "yt-dlp"
|
||||
" -o '/storage/media/media/chris/extras/yt/"
|
||||
location
|
||||
"/%(title)s.%(ext)s'"
|
||||
" '" url "'" "\""))
|
||||
(message (format "%s is downloading to the %s folder on jellyfin" url location))))
|
||||
(defun chris/empv-org-play-link (&optional link)
|
||||
"Play link in empv from either supplied link or link at point in org-mode"
|
||||
(interactive)
|
||||
(let ((link (if link
|
||||
link
|
||||
(org-babel-read-link))))
|
||||
(empv-play link)))
|
||||
|
||||
(defun chris/empv-org-play-link (&optional link)
|
||||
"Play link in empv from either supplied link or link at point in org-mode"
|
||||
(interactive)
|
||||
(let ((link (if link
|
||||
link
|
||||
(org-babel-read-link))))
|
||||
(empv-play link)))
|
||||
(defun chris/dired-empv-play-or-enqueue ()
|
||||
"Play file at point in dired"
|
||||
(interactive)
|
||||
(let* ((file (dired-get-filename)))
|
||||
(empv-play-or-enqueue file)))
|
||||
|
||||
(defun chris/dired-empv-play-or-enqueue ()
|
||||
"Play file at point in dired"
|
||||
(interactive)
|
||||
(let* ((file (dired-get-filename)))
|
||||
(empv-play-or-enqueue file)))
|
||||
(defun chris/empv-seek-forward ()
|
||||
"Seek forward 20 seconds"
|
||||
(interactive)
|
||||
(empv-seek "20"))
|
||||
|
||||
(defun chris/empv-seek-forward ()
|
||||
"Seek forward 20 seconds"
|
||||
(interactive)
|
||||
(empv-seek "20"))
|
||||
|
||||
:general
|
||||
(chris/leader-keys
|
||||
:states 'normal
|
||||
:keymaps 'override
|
||||
"vo" 'empv-play-or-enqueue
|
||||
"vt" 'empv-toggle
|
||||
"vv" 'empv-play-video
|
||||
"vx" 'empv-chapter-select
|
||||
"vy" 'empv-youtube-tabulated
|
||||
"vn" 'empv-playlist-next
|
||||
"vp" 'empv-playlist-prev
|
||||
"vs" 'empv-playlist-select
|
||||
"vS" 'chris/empv-seek-forward)
|
||||
(general-def
|
||||
:states 'normal
|
||||
:keymaps 'empv-youtube-results-mode-map
|
||||
"q" 'kill-current-buffer
|
||||
"RET" 'empv-youtube-results-play-or-enqueue-current
|
||||
"i" 'empv-youtube-results-inspect
|
||||
"d" 'chris/empv-yt-dlp
|
||||
"D" 'chris/empv-yt-dlp-jellyfin)
|
||||
(general-def
|
||||
:states 'normal
|
||||
:keymaps 'dired-mode-map
|
||||
"vi" 'chris/dired-empv-play-or-enqueue))
|
||||
:general
|
||||
(chris/leader-keys
|
||||
:states 'normal
|
||||
:keymaps 'override
|
||||
"vo" 'empv-play-or-enqueue
|
||||
"vt" 'empv-toggle
|
||||
"vv" 'empv-play-video
|
||||
"vx" 'empv-chapter-select
|
||||
"vy" 'empv-youtube-tabulated
|
||||
"vn" 'empv-playlist-next
|
||||
"vp" 'empv-playlist-prev
|
||||
"vs" 'empv-playlist-select
|
||||
"vS" 'chris/empv-seek-forward)
|
||||
(general-def
|
||||
:states 'normal
|
||||
:keymaps 'empv-youtube-results-mode-map
|
||||
"q" 'kill-current-buffer
|
||||
"RET" 'empv-youtube-results-play-or-enqueue-current
|
||||
"i" 'empv-youtube-results-inspect
|
||||
"d" 'chris/empv-yt-dlp
|
||||
"D" 'chris/empv-yt-dlp-jellyfin)
|
||||
(general-def
|
||||
:states 'normal
|
||||
:keymaps 'dired-mode-map
|
||||
"vi" 'chris/dired-empv-play-or-enqueue))
|
||||
|
||||
(use-package elfeed
|
||||
:commands (elfeed)
|
||||
|
|
Loading…
Reference in a new issue