blob: 69df8df7b0b1309299aed30fd16973a52f605040 (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
;;; thanos-multimedia.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:
;; EMMS
(use-package emms
:straight t
:bind
("A" . 'emms-add-directory)
:config
(setf emms-player-list '(emms-player-mpv)
emms-player-mpv-parameters '("--no-video")
emms-info-functions '(emms-info-native)
emms-playlist-buffer-name "*Music*"
emms-source-file-default-directory "~/Music"))
(define-key 'thanos/applications-map (kbd "e") 'emms)
;; 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
(add-to-list 'load-path "~/Developer/emacs-lisp/yeetube")
(load-file "~/Developer/emacs-lisp/yeetube/yeetube.el"))
(straight-use-package '(yeetube :type git :host nil :repo "https://git.thanosapollo.com/yeetube"))
(setf yeetube-results-limit 20
yeetube-mpv-disable-video t)
(defun yeetube-play-url (url)
"Open URL using yeetube-player."
(interactive "sURL:")
(let ((media-player (executable-find (symbol-name yeetube-player))))
(unless media-player
(error (format "%s not found." media-player)))
(when (string-prefix-p "http" url)
(setf yeetube-last-played url)
(if (eq yeetube-player 'mpv)
(yeetube-start-mpv-process url)
(yeetube-start-process
(format "%s \"%s\"" media-player
(replace-regexp-in-string "\\byewtu\\.be\b" "youtube.com" url)))))))
(defvar-keymap thanos/yeetube-map
:doc "Personal yeetube map."
"s" #'yeetube-search
"b" #'yeetube-play-saved-video
"d" #'yeetube-download-videos
"C-d" #'yeetube-download-vimeo-videos
"p" #'yeetube-mpv-toggle-pause
"v" #'yeetube-mpv-toggle-no-video-flag
"C-p" #'yeetube-mpv-toggle-video
"k" #'yeetube-remove-saved-video)
(global-set-key (kbd "C-c y") thanos/yeetube-map)
(provide 'thanos-multimedia)
;;; thanos-multimedia.el ends here
|