1 ;;; youtube-dl-transient.el --- transient interface for youtube-dl -*- lexical-binding: t; -*-
2 ;; -*- coding: utf-8 -*-
4 ;; Copyright (C) 2020-2021 Christopher M. Miles, all rights reserved.
15 ;;; transient interface for youtube-dl download to toggle command-line options.
16 ;;; Reference command man page options.
17 (transient-define-prefix youtube-dl-general-options
()
18 "youtube-dl command-line general options."
20 :class transient-column
22 ("-ie" "ignore errors" "--ignore-errors")
23 ("-ae" "abort on error" "--abort-on-error")
24 ("-ic" "ignore config" "--ignore-config")
25 ("-nc" "no output colors" "--no-colors")
26 ("-mw" "mark videos watched" "--mark-watched")])
28 (transient-define-prefix youtube-dl-network-options
()
29 "youtube-dl command-line network options."
31 :class transient-column
33 ("-p" "specify proxy" "--proxy <URL>")])
35 (transient-define-prefix youtube-dl-video-options
()
36 "youtube-dl command-line video options."
38 :class transient-column
40 ("-PI" "Comma separated playlist_index of the items to download by range [START]:[STOP][:STEP]" "--playlist-items <ITEM_SPEC>")
41 ("-PL" "Download the playlist" "--yes-playlist")
42 ("-MD" "Abort after downloading NUMBER files" "--max-downloads <NUMBER>")])
44 (transient-define-prefix youtube-dl-download-options
()
45 "youtube-dl command-line download options."
47 :class transient-column
49 ("-nd" "Number of fragments of a dash/hlsnative video that should be downloaded concurrently." "--concurrent-fragments <N>")
50 ("-lr" "Maximum download rate in bytes per second, e.g. 50K or 4.2M" "--limit-rate <RATE>")
51 ("-RT" "Number of retries (default is 10), or \"infinite\"." "--retries <RETRIES>")
52 ("-RS" "Time to sleep between retries in seconds." "--retry-sleep linear=1::2")
53 ("-SI" "Number of seconds to sleep before each download." "--sleep-interval <SECONDS>")])
55 (transient-define-prefix youtube-dl-filesystem-options
()
56 "youtube-dl command-line filesystem options."
58 :class transient-column
60 ("-a" "File containing URLs to download (\"-\" for stdin), one URL per line. (support comment start with # ; )." "--batch-file <FILE>")
61 ("-o" "Output filename template; see \"OUTPUT TEMPLATE\" for details." "--output <[TYPES:]TEMPLATE>")
62 ("-rf" "Restrict filenames to only ASCII characters, and avoid \"&\" and spaces in filenames." "--restrict-filenames")
63 ("-tf" "Limit the filename length (excluding extension) to the specified number of characters." "--trim-filenames <LENGTH>")
64 ("-w" "Do not overwrite any files." "--no-overwrites")
65 ("-O" "Overwrite all video and metadata files." "--force-overwrites")
66 ("-W" "Do not overwrite the video, but overwrite related files (default)." "--no-force-overwrites")
67 ("-c" "Resume partially downloaded files/fragments (default)" "--continue")
68 ("-J" "Write video metadata to a .info.json file." "--write-info-json")
69 ("-C" "Retrieve video comments to be placed in the .info.json." "--write-comments")
70 ("-b" "Load cookies from web browser." "--cookies-from-browser chrome")])
72 (transient-define-prefix youtube-dl-thumbnail-options
()
73 "youtube-dl command-line thumbnail options."
75 :class transient-column
77 ("-t" "Write thumbnail image to disk." "--write-thumbnail")
78 ("-lt" "List available thumbnails of each video." "--list-thumbnails")])
80 (transient-define-prefix youtube-dl-internet-shortcut-options
()
81 "youtube-dl command-line internet shortcut options."
82 ["Internet Shortcut Options"
83 :class transient-column
85 ("-L" "Write an internet shortcut file, depending on the current platform (.url, .webloc or .desktop)." "--write-link")])
87 (transient-define-prefix youtube-dl-verbosity-options
()
88 "youtube-dl command-line verbosity and simulation options."
89 ["Verbosity and Simulation Options"
90 :class transient-column
92 ("-q" "Activate quiet mode. If used with --verbose, print the log to stderr." "--quiet")
93 ("-nw" "Ignore warnings" "--no-warnings")
94 ("-S" "Do not download the video and do not write anything to disk." "--simulate")
95 ("-dj" "Quiet, but print JSON information for each video." "--dump-json")
96 ("-n" "Output progress bar as new lines" "--newline")
97 ("-p" "Show progress bar, even if in quiet mode." "--progress")])
99 (transient-define-prefix youtube-dl-workarounds-options
()
100 "youtube-dl command-line workarounds options."
102 :class transient-column
104 ("-SL" "Explicitly allow HTTPS connection to servers that do not support RFC 5746 secure renegotiation." "--legacy-server-connect")
105 ("-NC" "Suppress HTTPS certificate validation." "--no-check-certificates")
106 ("-H" "Specify a custom HTTP header and its value, separated by a colon \":\"." "--add-headers <FIELD:VALUE>")])
108 (transient-define-prefix youtube-dl-video-format-options
()
109 "youtube-dl command-line video format options."
110 ["Video Format Options"
111 :class transient-column
113 ("-f" "Video format code, see \"FORMAT SELECTION\" for more details." "--format <FORMAT>")
114 ("-lf" "List available formats of each video. Simulate unless --no-simulate is used." "--list-formats")])
116 (transient-define-prefix youtube-dl-subtitle-options
()
117 "youtube-dl command-line subtitle options."
119 :class transient-column
121 ("-s" "Write subtitle file" "--write-subs")
122 ("-sa" "Write automatically generated subtitle file." "--write-auto-subs")
123 ("-sf" "Subtitle format; accepts formats preference, e.g. \"srt\" or \"ass/srt/best\"." "--sub-format <FORMAT>")
124 ("-sl" "Languages of the subtitles to download (can be regex) or \"all\" separated by commas like \"en.*,ja\"." "--sub-langs <LANGS>")
125 ("-ls" "List available subtitles of each video." "--list-subs")])
127 (transient-define-prefix youtube-dl-authentication-options
()
128 "youtube-dl command-line authentication options."
129 ["Authentication Options"
130 :class transient-column
134 (transient-define-prefix youtube-dl-post-processing-options
()
135 "youtube-dl command-line post-processing options."
136 ["Post-Processing Options"
137 :class transient-column
139 ("-x" "Convert video files to audio-only files." "--extract-audio")
140 ("-AF" "Format to convert the audio to when -x is used. (currently supported: best (default), aac, alac, flac, m4a, mp3, opus, vorbis, wav)." "--audio-format <FORMAT>")
141 ("-AQ" "Specify ffmpeg audio quality to use when converting the audio with -x." "--audio-quality <QUALITY>")
142 ("-CS" "Convert the subtitles to another format (currently supported: ass, lrc, srt, vtt)" "--convert-subs <FORMAT>")])
144 (transient-define-prefix youtube-dl-extractor-options
()
145 "youtube-dl command-line extractor options."
147 :class transient-column
149 ("-ER" "Number of retries for known extractor errors (default is 3)" "--extractor-retries <RETRIES>" :transient transient--do-return
)])
151 (transient-define-prefix youtube-dl-options
()
152 "youtube-dl command-line options."
153 :man-page
"yt-dlp" ; youtube-dl-program
156 (format "youtube-dl options: %s" youtube-dl-extra-arguments
))
157 [("g" "General Options" youtube-dl-general-options
:transient transient--do-recurse
)
158 ("n" "Network Options" youtube-dl-network-options
)
159 ("d" "Download Options" youtube-dl-download-options
)
160 ("f" "Filesystem Options" youtube-dl-filesystem-options
)
161 ("t" "Thumbnail Options" youtube-dl-thumbnail-options
)
162 ("i" "Internet Shortcut Options" youtube-dl-internet-shortcut-options
)
163 ("V" "Verbosity & Simulation Options" youtube-dl-verbosity-options
)
164 ("w" "Workarounds Options" youtube-dl-workarounds-options
)
165 ("v" "Video Format Options" youtube-dl-video-format-options
)
166 ("s" "Subtitle Options" youtube-dl-subtitle-options
)
167 ("a" "Authentication Options" youtube-dl-authentication-options
)
168 ("P" "Post-Processing Options" youtube-dl-post-processing-options
)
169 ("e" "Extractor Options" youtube-dl-extractor-options
)]]
172 (defun youtube-dl-transient ()
173 "Entrypoint command for transient interface to specify command-line options."
175 (transient-args 'youtube-dl-options
))
177 ;;; TODO: how to pass toggled options to `youtube-dl-extra-arguments'?
180 ;;; transient interface for youtube-dl list buffer.
181 (transient-define-prefix youtube-dl-list-dispatch
()
182 "youtube-dl list buffer commands dispatcher."
183 ["youtube-dl list buffer commands"
185 ("y" "yank item url" youtube-dl-list-yank
)
186 ("k" "kill item at point" youtube-dl-list-kill
)
187 ("p" "pause item at point" youtube-dl-list-toggle-pause
)
188 ("P" "pause all items" youtube-dl-list-toggle-pause-all
)
189 ("r" "resume item at point" youtube-dl-list-resume
)
190 ("s" "slow down item at point" youtube-dl-list-toggle-slow
)
191 ("S" "slow down all items" youtube-dl-list-toggle-slow-all
)
192 ("]" "increase priority up" youtube-dl-list-priority-up
)
193 ("[" "decrease priority down" youtube-dl-list-priority-down
)]
195 ("a" "download" youtube-dl
)
196 ("A" "download playlist" youtube-dl-download-playlist
)]
197 ["List buffer operations"
198 ("g" "refresh" youtube-dl-list-redisplay
)
199 ("l" "open process log buffer" youtube-dl-list-log
)
200 ("L" "close list log buffer" youtube-dl-list-kill-log
)]
202 ("j" "next item" youtube-dl-list-next-item
)
203 ("k" "previous item" youtube-dl-list-prev-item
)]
205 ;; ("m" "mark item(s) at point" youtube-dl-mark)
206 ;; ("M" "mark all items" youtube-dl-mark-all)
207 ;; ("u" "unmark item(s) at point" youtube-dl-unmark)
208 ;; ("U" "unmark all items" youtube-dl-unmark-all)
209 ;; ("%" "mark items matching regexp" youtube-dl-mark-with-regexp)]
212 ;;; transient interface
213 (define-key youtube-dl-list-mode-map
(kbd "C-c C-c") 'youtube-dl-list-dispatch
)
216 (provide 'youtube-dl-transient
)
218 ;;; youtube-dl-transient.el ends here