docs/src/config/commands.md

88 lines · 3935 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- Open in browser: ${browser} ${url}
12- Download video (webm): ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${embed-url}
13- 'Mode: ${provider}': '%switch-provider%'
14
15playlist:
16- Switch view: '%switch-view%'
17- Play all videos: ${video-player} ${all-videos}
18- Play all audio: ${terminal-emulator} ${video-player} ${all-videos} --no-video
19- Shuffle play all audio: ${terminal-emulator} ${video-player} ${all-videos} --no-video --shuffle
20- Open in browser: ${browser} ${url}
21- Download all video (webm): ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${all-videos}
22- 'Mode: ${provider}': '%switch-provider%'
23```
24
25## Env variables
26
27Notice 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.
28
29Replacing all these with known values it might look something like this:
30
31```yaml
32video:
33- Play video: mpv 'https://youtube.com/embed/dQw4w9WgXcQ'
34- Play audio: konsole -e mpv 'https://youtube.com/embed/dQw4w9WgXcQ' --no-video
35- Open in browser: firefox 'https://youtu.be/dQw4w9WgXcQ'
36- Download video (webm): konsole -e yt-dlp -o '~/Downloads/%(title)s-%(id)s.%(ext)s' 'https://youtube.com/embed/dQw4w9WgXcQ'
37- 'Mode: ${provider}': '%switch-provider%'
38
39playlist:
40- Switch view: '%switch-view%'
41- Play all videos: mpv 'https://youtube.com/embed/Z8oiddSsB6I' 'https://youtube.com/embed/yiS0DPekSDQ' 'https://youtube.com/embed/YhM8GYuDFps' # and much more...
42- Play all audio: konsole -e mpv 'https://youtube.com/embed/Z8oiddSsB6I' 'https://youtube.com/embed/yiS0DPekSDQ' 'https://youtube.com/embed/YhM8GYuDFps' --no-video
43- 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
44- Open in browser: firefox 'https://www.youtube.com/playlist?list=PLdgHTasZAjYZlCXN9rTcX9LFOQ-RIrzCs'
45- 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'
46- 'Mode: ${provider}': '%switch-provider%'
47```
48
49## Item commands
50
51(will be replaced by global vim-like commands in the next major version)
52
53Notice 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.
54
55For instance `%switch-provider%` toggles the provider between `YouTube` and `Invidious`.
56
57<hr>
58
59Below are the description of each of the fields:
60
61### video
62
63Commands to be displayed in a video page.
64
65*Accept: `string_label: string_command` pairs*
66
67### playlist
68
69Commands to be displayed in a playlist page (commands view).
70
71*Accept: `string_label: string_command` pairs*
72
73## Env reference
74
75Does not include custom env set in `main.yml`.
76
77|Name|Page|Value|
78|---|---|---|
79|`url`|video & playlist|String url to the web page|
80|`embed-url`|video|String url to the embed video (required to play video using mpv from Invidious)|
81|`all-videos`|playlist|String url***s*** separated by space to all embed videos in a playlist|
82|`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|
83
84## Item command reference
85
86|Name|Page|Use|
87|---|---|---|
88|`swtich-provider`|video & playlist|Toggles the provider between `YouTube` and `Invidious`|