docs/src/config/commands.md

90 lines · 4571 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
 8launch_command: loadpage popular ;; flush ;; history clear # suggested to set page to watchhistory if you don't want to wait for popular to load
 9video:
10- Play video: ${video-player} ${embed-url}
11- Play audio: ${terminal-emulator} ${video-player} ${embed-url} --no-video
12- Play audio (loop): ${terminal-emulator} ${video-player} ${embed-url} --no-video --loop-file=inf
13- View channel: :channel ${channel-id}
14- Open in browser: ${browser} ${url}
15- Download video (webm): ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${embed-url}
16- Download audio (opus): ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${embed-url} -x
17- 'Mode: ${provider}': '%switch-provider%'
18playlist:
19- Switch view: '%switch-view%'
20- Play all videos: ${video-player} ${all-videos}
21- Play all audio: ${terminal-emulator} ${video-player} ${all-videos} --no-video
22- Shuffle play all audio: ${terminal-emulator} ${video-player} ${all-videos} --no-video --shuffle
23- Shuffle play all audio (loop): ${terminal-emulator} ${video-player} ${all-videos} --no-video --shuffle --loop-playlist=inf
24- View channel: :channel ${channel-id}
25- Open in browser: ${browser} ${url}
26- Download all video (webm): ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${all-videos}
27- Download all audio (opus): ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${all-videos} -x
28- 'Mode: ${provider}': '%switch-provider%'
29```
30
31## Env variables
32
33Notice 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.
34
35Replacing all these with known values it might look something like this:
36
37```yaml
38launch_command: loadpage popular ;; flush ;; history clear
39video:
40- Play video: mpv 'https://youtube.com/embed/dQw4w9WgXcQ'
41- Play audio: konsole -e mpv 'https://youtube.com/embed/dQw4w9WgXcQ' --no-video
42- Open in browser: firefox 'https://youtu.be/dQw4w9WgXcQ'
43- Download video (webm): konsole -e yt-dlp -o '~/Downloads/%(title)s-%(id)s.%(ext)s' 'https://youtube.com/embed/dQw4w9WgXcQ'
44- 'Mode: ${provider}': '%switch-provider%'
45
46playlist:
47- Switch view: '%switch-view%'
48- Play all videos: mpv 'https://youtube.com/embed/Z8oiddSsB6I' 'https://youtube.com/embed/yiS0DPekSDQ' 'https://youtube.com/embed/YhM8GYuDFps' # and much more...
49- Play all audio: konsole -e mpv 'https://youtube.com/embed/Z8oiddSsB6I' 'https://youtube.com/embed/yiS0DPekSDQ' 'https://youtube.com/embed/YhM8GYuDFps' --no-video
50- 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
51- Open in browser: firefox 'https://www.youtube.com/playlist?list=PLdgHTasZAjYZlCXN9rTcX9LFOQ-RIrzCs'
52- 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'
53- 'Mode: ${provider}': '%switch-provider%'
54```
55
56> Global commands can also be used here. (Ones that start with an `:`).
57
58<hr>
59
60Below are the description of each of the fields:
61
62### video
63
64Commands to be displayed in a video page.
65
66*Accept: `string_label: string_command` pairs*
67
68### playlist
69
70Commands to be displayed in a playlist page (commands view).
71
72*Accept: `string_label: string_command` pairs*
73
74## Env reference
75
76Does not include custom env set in `main.yml`.
77
78|Name|Page|Value|
79|---|---|---|
80|`url`|search, popular, trending, video, playlist|String url to the web page|
81|`id`|video, playlist|String id of the video or playlist|
82|`channel-id`|video, playlist|String id of the channel|
83|`embed-url`|video|String url to the embed video (required to play video using mpv from Invidious)|
84|`all-videos`|playlist|String url***s*** separated by space to all embed videos in a playlist|
85|`hover-url`|trending, popular, search|Url of the currenly hovering item.|
86|`hover-channel-url`|feed|Url of the currenly hovering channel.|
87|`hover-channel-id`|feed|ID of the currenly hovering channel.|
88|`hover-video-url`|feed|Url of the currenly hovering video.|
89|`hover-video-id`|feed|ID of the currenly hovering video.|
90|`all-ids`|playlist|IDs of all videos in a playlist, separated with space.|