summaryrefslogtreecommitdiff
path: root/.emacs.d
diff options
context:
space:
mode:
Diffstat (limited to '.emacs.d')
-rw-r--r--.emacs.d/init.el46
-rw-r--r--.emacs.d/modules/thanos-commands.el88
2 files changed, 88 insertions, 46 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index 9aae99c..150ed9b 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -606,52 +606,6 @@
(("M-'" . jinx-correct)))
:hook ((org-mode . jinx-mode)))
-(defun dired-watch-video ()
- "Watch play file with mpv."
- (interactive)
- (call-process-shell-command
- (format "mpv \"%s\"" (dired-get-filename)) nil 0))
-
-(defun dired-set-wallpaper ()
- "Set NAME as wallpaper using feh."
- (interactive)
- (call-process-shell-command
- (format "feh --bg-scale %s" (dired-get-filename)) nil 0))
-
-(defun dired-delete-files-except ()
- "Delete all files inside directory except match."
- (interactive)
- (let* ((directory (read-directory-name "Select directory: "))
- (files (directory-files directory t))
- (except-match (read-string "Except the ones that have: ")))
- (dolist (file files)
- (unless (or (string= "." (substring file -1))
- (string= ".." (substring file -2))
- (string-match except-match file))
- (dired-delete-file file t)))))
-
-(defun dired-delete-file-match ()
- "Delete all files inside directory except match."
- (interactive)
- (let* ((directory (read-directory-name "Select directory: "))
- (files (directory-files directory t))
- (match (read-string "Delete files that match: ")))
- (dolist (file files)
- (when (string-match-p match file)
- (dired-delete-file file t)))))
-
-(defun dired-rename-capitalize-file ()
- "Capitalize the base name of the file at point in a Dired buffer."
- (interactive)
- (let* ((file (dired-get-file-for-visit))
- (new-file (capitalize (file-name-nondirectory file))))
- (if (string-prefix-p "." file)
- (message "Skipping file starting with '.'")
- (progn
- (rename-file file (concat (file-name-directory file) new-file))
- (revert-buffer)
- (message "Renamed %s to %s" file new-file)))))
-
(use-package term
:bind (("C-c t" . term)
:map term-mode-map
diff --git a/.emacs.d/modules/thanos-commands.el b/.emacs.d/modules/thanos-commands.el
index da5b4ae..7dba0c7 100644
--- a/.emacs.d/modules/thanos-commands.el
+++ b/.emacs.d/modules/thanos-commands.el
@@ -145,5 +145,93 @@
(define-key global-map (kbd "C-c a") thanos/applications-map)
+(defun dired-watch-video ()
+ "Watch play file with mpv."
+ (interactive)
+ (call-process-shell-command
+ (format "mpv \"%s\"" (dired-get-filename)) nil 0))
+
+(defun dired-set-wallpaper ()
+ "Set NAME as wallpaper using feh."
+ (interactive)
+ (call-process-shell-command
+ (format "feh --bg-scale %s" (dired-get-filename)) nil 0))
+
+(defun dired-delete-files-except ()
+ "Delete all files inside directory except match."
+ (interactive)
+ (let* ((directory (read-directory-name "Select directory: "))
+ (files (directory-files directory t))
+ (except-match (read-string "Except the ones that have: ")))
+ (dolist (file files)
+ (unless (or (string= "." (substring file -1))
+ (string= ".." (substring file -2))
+ (string-match except-match file))
+ (dired-delete-file file t)))))
+
+(defun dired-delete-file-match ()
+ "Delete all files inside directory except match."
+ (interactive)
+ (let* ((directory (read-directory-name "Select directory: "))
+ (files (directory-files directory t))
+ (match (read-string "Delete files that match: ")))
+ (dolist (file files)
+ (when (string-match-p match file)
+ (dired-delete-file file t)))))
+
+(defun dired-rename-capitalize-file ()
+ "Capitalize the base name of the file at point in a Dired buffer."
+ (interactive)
+ (let* ((file (dired-get-file-for-visit))
+ (new-file (capitalize (file-name-nondirectory file))))
+ (if (string-prefix-p "." file)
+ (message "Skipping file starting with '.'")
+ (progn
+ (rename-file file (concat (file-name-directory file) new-file))
+ (revert-buffer)
+ (message "Renamed %s to %s" file new-file)))))
+
+;; yeetube
+(defun yeetube-download-videos-ffmpeg ()
+ "Download videos using ffmpeg."
+ (interactive)
+ (let ((url "")
+ (name "")
+ (download-counter 1)
+ (stored-contents nil))
+ ;; Read links and names until "q" is entered
+ (while (not (string= url "q"))
+ (setf url (read-string "Enter URL (q to quit): "))
+ (unless (string= url "q")
+ (setf name (read-string (format "Custom name (download counter: %d) " download-counter)))
+ (push (cons url name) stored-contents)
+ (setf download-counter (1+ download-counter))))
+ ;; Process the collected links and names
+ (dolist (pair stored-contents)
+ (let ((url (car pair))
+ (name (cdr pair)))
+ (async-shell-command
+ (format
+ "ffmpeg -protocol_whitelist file,crypto,data,https,tls,tcp -stats -i '%s' -codec copy '%s.mp4'"
+ url name))))))
+
+(defun yeetube-download-vimeo-videos ()
+ "Download videos from vimeo services."
+ (interactive)
+ (let ((url "")
+ (name "")
+ (download-counter 1))
+ (while (not (string= url "q"))
+ (setf url (read-string "Enter URL (q to quit): "))
+ (unless (string= url "q")
+ (setf name (read-string (format "Custom name (download counter: %d) " download-counter)))
+ (setf download-counter (1+ download-counter))
+ (call-process-shell-command
+ (format
+ "yt-dlp '%s' -o '%s'"
+ (replace-regexp-in-string "\\.json" ".m3u8" url) name)
+ nil 0)))))
+
+
(provide 'thanos-commands)
;;; thanos-commands.el ends here