docs/src/config/commands.md
95 lines · 4521 bytes
1# Commands config
2
3The commands config file decides what options (that will run a certain command on select) to be display in the *video* and *playlist* page respectively, it is located in `~/.config/youtube-tui/commands.yml`.
4
5## Example commands config
6
7```yaml
8video:
9- Play video: ${video-player} ${embed-url}
10- Play audio: ${terminal-emulator} ${video-player} ${embed-url} --no-video
11- Play audio (loop): ${terminal-emulator} ${video-player} ${embed-url} --no-video --loop-file=inf
12- View channel: :channel ${channel_id}
13- Open in browser: ${browser} ${url}
14- Download video (webm): ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${embed-url}
15- Download audio (opus): ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${embed-url} -x
16- 'Mode: ${provider}': '%switch-provider%'
17playlist:
18- Switch view: '%switch-view%'
19- Play all videos: ${video-player} ${all-videos}
20- Play all audio: ${terminal-emulator} ${video-player} ${all-videos} --no-video
21- Shuffle play all audio: ${terminal-emulator} ${video-player} ${all-videos} --no-video --shuffle
22- Shuffle play all audio (loop): ${terminal-emulator} ${video-player} ${all-videos} --no-video --shuffle --loop-playlist=inf
23- View channel: :channel ${channel_id}
24- Open in browser: ${browser} ${url}
25- Download all video (webm): ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${all-videos}
26- Download all audio (opus): ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${all-videos} -x
27- 'Mode: ${provider}': '%switch-provider%'
28```
29
30## Env variables
31
32Notice that a lot of the commands contains the `${label}` pattern, this actually replaces the text with the env variables set in `main.yml`, or is added by the current page (video or playlist) on-the-go.
33
34Replacing all these with known values it might look something like this:
35
36```yaml
37video:
38- Play video: mpv 'https://youtube.com/embed/dQw4w9WgXcQ'
39- Play audio: konsole -e mpv 'https://youtube.com/embed/dQw4w9WgXcQ' --no-video
40- Open in browser: firefox 'https://youtu.be/dQw4w9WgXcQ'
41- Download video (webm): konsole -e yt-dlp -o '~/Downloads/%(title)s-%(id)s.%(ext)s' 'https://youtube.com/embed/dQw4w9WgXcQ'
42- 'Mode: ${provider}': '%switch-provider%'
43
44playlist:
45- Switch view: '%switch-view%'
46- Play all videos: mpv 'https://youtube.com/embed/Z8oiddSsB6I' 'https://youtube.com/embed/yiS0DPekSDQ' 'https://youtube.com/embed/YhM8GYuDFps' # and much more...
47- Play all audio: konsole -e mpv 'https://youtube.com/embed/Z8oiddSsB6I' 'https://youtube.com/embed/yiS0DPekSDQ' 'https://youtube.com/embed/YhM8GYuDFps' --no-video
48- Shuffle play all audio: konsole -e mpv 'https://youtube.com/embed/Z8oiddSsB6I' 'https://youtube.com/embed/yiS0DPekSDQ' 'https://youtube.com/embed/YhM8GYuDFps' --no-video --shuffle
49- Open in browser: firefox 'https://www.youtube.com/playlist?list=PLdgHTasZAjYZlCXN9rTcX9LFOQ-RIrzCs'
50- Download all video (webm): konsole -e yt-dlp -o '~/Downloads/%(title)s-%(id)s.%(ext)s' 'https://youtube.com/embed/Z8oiddSsB6I' 'https://youtube.com/embed/yiS0DPekSDQ' 'https://youtube.com/embed/YhM8GYuDFps'
51- 'Mode: ${provider}': '%switch-provider%'
52```
53
54> Global commands can also be used here. (Ones that start with an `:`).
55
56## Item commands
57
58(will be replaced by global vim-like commands in the next major version)
59
60Notice that there is another pattern in the commands, it is the `%label%` commands. They are special cases that are consumed by the item and is never actually ran as a system command.
61
62For instance `%switch-provider%` toggles the provider between `YouTube` and `Invidious`.
63
64<hr>
65
66Below are the description of each of the fields:
67
68### video
69
70Commands to be displayed in a video page.
71
72*Accept: `string_label: string_command` pairs*
73
74### playlist
75
76Commands to be displayed in a playlist page (commands view).
77
78*Accept: `string_label: string_command` pairs*
79
80## Env reference
81
82Does not include custom env set in `main.yml`.
83
84|Name|Page|Value|
85|---|---|---|
86|`url`|video & playlist|String url to the web page|
87|`embed-url`|video|String url to the embed video (required to play video using mpv from Invidious)|
88|`all-videos`|playlist|String url***s*** separated by space to all embed videos in a playlist|
89|`provider`|video & playlist|To display the current provider, is the only env that can be displayed in the label, and can only be used when `%switch-provider%` is the command|
90
91## Item command reference
92
93|Name|Page|Use|
94|---|---|---|
95|`swtich-provider`|video & playlist|Toggles the provider between `YouTube` and `Invidious`|