summaryrefslogtreecommitdiff
path: root/.emacs.d/modules/thanos-yeetube.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2023-09-03 17:05:49 +0300
committerThanos Apollo <[email protected]>2023-09-03 17:06:54 +0300
commit8efa6f3f1db166d30a4eb38780f6c47855c51439 (patch)
tree873e0c0aeb443c10153a44e14a3d89c938e68e4d /.emacs.d/modules/thanos-yeetube.el
parentf7c3db0c688b9b98762464cc9e4cc7c87a9dbe96 (diff)
emacs: Modularize
Diffstat (limited to '.emacs.d/modules/thanos-yeetube.el')
-rw-r--r--.emacs.d/modules/thanos-yeetube.el95
1 files changed, 95 insertions, 0 deletions
diff --git a/.emacs.d/modules/thanos-yeetube.el b/.emacs.d/modules/thanos-yeetube.el
new file mode 100644
index 0000000..517d245
--- /dev/null
+++ b/.emacs.d/modules/thanos-yeetube.el
@@ -0,0 +1,95 @@
+;;; thanos-yeetube.el --- -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2023 Thanos Apollo
+
+;; Author: Thanos Apollo <[email protected]>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(require 'yeetube)
+
+
+(defun yeetube-download-vimeo-videos ()
+ (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)))))
+
+(defun yeetube-download-videos-ffmpeg ()
+ "Download one or multiple videos using yt-dlp.
+ This command is not meant to be used in the *Yeetube Search* buffer.
+
+ Usage Example:
+ Open a Dired buffer and navigate where you want to download your videos,
+ then run this command interactively. You can leave the 'Custom name:'
+ prompt blank to keep the default name."
+ (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))))))
+
+(when is-zeus
+ (load-file "~/Developer/yeetube.el/yeetube.el"))
+(require 'yeetube)
+
+(setf yeetube-results-limit 30
+ yeetube-mpv-disable-video t)
+
+(define-prefix-command 'thanos/yeetube)
+(global-set-key (kbd "C-c y") 'thanos/yeetube)
+(define-key thanos/yeetube (kbd "s") 'yeetube-search)
+(define-key thanos/yeetube (kbd "b") 'yeetube-play-saved-video)
+(define-key thanos/yeetube (kbd "d") 'yeetube-download-videos)
+(define-key thanos/yeetube (kbd "p") 'yeetube-mpv-toggle-pause)
+(define-key thanos/yeetube (kbd "C-p") 'yeetube-mpv-toggle-video)
+(define-key thanos/yeetube (kbd "k") 'yeetube-remove-saved-video)
+(define-key thanos/yeetube (kbd "u") 'yeetube-change-platform)
+(define-key thanos/yeetube (kbd "C-d") 'yeetube-download-vimeo-videos)
+(define-key yeetube-mode-map (kbd "c") 'yeetube-switch-mpv)
+
+(provide 'thanos-yeetube)
+;;; thanos-yeetube.el ends here