From 476b820019a6ee23d4496d611fe435e2670200ef Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Tue, 25 Mar 2025 10:10:10 -0500 Subject: [PATCH] tweaks to toggle changes and empv --- README.org | 172 +++++++++++++++++++++++++++++------------------------ init.el | 169 ++++++++++++++++++++++++++++------------------------ 2 files changed, 187 insertions(+), 154 deletions(-) diff --git a/README.org b/README.org index 49fd9e41..eeca5706 100644 --- a/README.org +++ b/README.org @@ -581,6 +581,9 @@ Here let's try to add ligatures to our font system since the VictorMono Nerd Fon There are two major packages we need to get the functionality I desire. Evil and general. *** Evil +:PROPERTIES: +:ID: 20250304T164537.064599 +:END: #+begin_src emacs-lisp (use-package evil @@ -614,6 +617,12 @@ This evil-collection package includes a lot of other evil based things. :after evil :init (evil-escape-mode +1) :config + (defun chris/toggle-evil-escape-sequence () + (interactive) + (if (string= evil-escape-key-sequence "ae") + (setq evil-escape-key-sequence "fd") + (setq evil-escape-key-sequence "ae"))) + (setq evil-escape-key-sequence (kbd "ae") evil-escape-delay 0.3)) #+end_src @@ -5049,89 +5058,98 @@ With empv we can perhaps control mpv much more fine grainly and even search yout (message args) (empv-play-or-enqueue video)) - (defun chris/empv-yt-dlp () + (defun chris/empv-yt-dlp (&optional file) "Download the current video and and play it" (interactive) - (let* ((item (empv-youtube-results--current-item)) - (video-id (alist-get 'videoId item)) - (playlist-id (alist-get 'playlistId item)) - (title (alist-get 'title item)) - (url (format - "https://youtube.com/%s=%s" - (if video-id "watch?v" "playlist?list") - (or video-id playlist-id)))) - (async-shell-command (concat - "yt-dlp" " -o '/home/chris/vids/%(title)s.%(ext)s'" - " \"" url "\"")) - (let ((file (format "/home/chris/vids/%s.%s" title "webm"))) - (empv-play file)) - (message url))) + (setq lexical-binding t) + (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)) + (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))))) + (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))) - (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)))) + (get-process "yt-dlp") + (chris/empv-yt-dlp "https://inv.cochrun.xyz/watch?v=qRE6kf30u4g") - (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-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/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-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-seek-forward () - "Seek forward 20 seconds" - (interactive) - (empv-seek "20")) +(defun chris/dired-empv-play-or-enqueue () + "Play file at point in dired" + (interactive) + (let* ((file (dired-get-filename))) + (empv-play-or-enqueue file))) - :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)) +(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)) #+end_src I need to update the new normal mode pieces to this... @@ -5272,7 +5290,7 @@ q quit-window (elfeed-search-untag-all-unread) (if (process-live-p proc) (set-process-sentinel - proc `(empv-play-or-enqueue + proc `(empv-enqueue ,(concat "/home/chris/vids/" title ".webm"))) (message "No process running")))) diff --git a/init.el b/init.el index 9cf38ea2..f58da0ed 100644 --- a/init.el +++ b/init.el @@ -350,6 +350,12 @@ :after evil :init (evil-escape-mode +1) :config + (defun chris/toggle-evil-escape-sequence () + (interactive) + (if (string= evil-escape-key-sequence "ae") + (setq evil-escape-key-sequence "fd") + (setq evil-escape-key-sequence "ae"))) + (setq evil-escape-key-sequence (kbd "ae") evil-escape-delay 0.3)) @@ -3698,89 +3704,98 @@ targets." (message args) (empv-play-or-enqueue video)) - (defun chris/empv-yt-dlp () + (defun chris/empv-yt-dlp (&optional file) "Download the current video and and play it" (interactive) - (let* ((item (empv-youtube-results--current-item)) - (video-id (alist-get 'videoId item)) - (playlist-id (alist-get 'playlistId item)) - (title (alist-get 'title item)) - (url (format - "https://youtube.com/%s=%s" - (if video-id "watch?v" "playlist?list") - (or video-id playlist-id)))) - (async-shell-command (concat - "yt-dlp" " -o '/home/chris/vids/%(title)s.%(ext)s'" - " \"" url "\"")) - (let ((file (format "/home/chris/vids/%s.%s" title "webm"))) - (empv-play file)) - (message url))) + (setq lexical-binding t) + (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)) + (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))))) + (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))) - (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)))) + (get-process "yt-dlp") + (chris/empv-yt-dlp "https://inv.cochrun.xyz/watch?v=qRE6kf30u4g") - (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-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/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-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-seek-forward () - "Seek forward 20 seconds" - (interactive) - (empv-seek "20")) +(defun chris/dired-empv-play-or-enqueue () + "Play file at point in dired" + (interactive) + (let* ((file (dired-get-filename))) + (empv-play-or-enqueue file))) - :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)) +(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)) (use-package elfeed :commands (elfeed) @@ -3839,7 +3854,7 @@ targets." (elfeed-search-untag-all-unread) (if (process-live-p proc) (set-process-sentinel - proc `(empv-play-or-enqueue + proc `(empv-enqueue ,(concat "/home/chris/vids/" title ".webm"))) (message "No process running"))))