docs/src/config/commands.md

94 lines · 5015 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 library ;; flush ;; history clear ;; key Esc 0 ;; key Up 0 ;; key Up 0 ;; key Left 0 ;; key Enter 0 # the key commands select the searchbar on launch
 9video:
10- Reload updated video: run rm '~/.cache/youtube-tui/info/${id}.json' ;; video ${id} # remove the cached info first, then reload the page
11- Play video: parrun ${video-player} '${embed-url}'
12- Play audio: mpv stop ;; resume ;; mpv sprop loop-file no ;; mpv loadfile '${embed-url}' ;; echo mpv Player started
13- Play audio (loop): mpv stop ;; resume ;; mpv sprop loop-file inf ;; mpv loadfile '${embed-url}' ;; echo mpv Player started
14- View channel: channel ${channel-id}
15- Subscribe to channel: sync ${channel-id}
16- Open in browser: parrun ${browser} '${url}'
17- Toggle bookmark: togglemark ${id}
18- Save video to library: bookmark ${id} ;; run rm -rf '${save-path}${id}.*' ;; parrun ${terminal-emulator} ${youtube-downloader} '${embed-url}' -o '${save-path}%(title)s[%(id)s].%(ext)s'
19- Save audio to library: bookmark ${id} ;; parrun rm -rf '${save-path}${id}.*' ;; parrun ${terminal-emulator} ${youtube-downloader} '${embed-url}' -x -o '${save-path}%(title)s[%(id)s].%(ext)s'
20- 'Mode: ${provider}': switchprovider
21
22# ...
23```
24
25<hr>
26
27The few required fields are:
28
29- `video`
30- `saved_video`
31- `playlist`
32- `saved_playlist`
33
34## Env variables
35
36Notice 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.
37
38<!-- Replacing all these with known values it might look something like this: -->
39<!--  -->
40<!-- ```yaml -->
41<!-- launch_command: loadpage popular ;; flush ;; history clear -->
42<!-- video: -->
43<!-- - Play video: mpv 'https://youtube.com/embed/dQw4w9WgXcQ' -->
44<!-- - Play audio: konsole -e mpv 'https://youtube.com/embed/dQw4w9WgXcQ' --no-video -->
45<!-- - Open in browser: firefox 'https://youtu.be/dQw4w9WgXcQ' -->
46<!-- - Download video (webm): konsole -e yt-dlp -o '~/Downloads/%(title)s-%(id)s.%(ext)s' 'https://youtube.com/embed/dQw4w9WgXcQ' -->
47<!-- - 'Mode: ${provider}': '%switch-provider%' -->
48<!--  -->
49<!-- playlist: -->
50<!-- - Switch view: '%switch-view%' -->
51<!-- - Play all videos: mpv 'https://youtube.com/embed/Z8oiddSsB6I' 'https://youtube.com/embed/yiS0DPekSDQ' 'https://youtube.com/embed/YhM8GYuDFps' # and much more... -->
52<!-- - Play all audio: konsole -e mpv 'https://youtube.com/embed/Z8oiddSsB6I' 'https://youtube.com/embed/yiS0DPekSDQ' 'https://youtube.com/embed/YhM8GYuDFps' --no-video -->
53<!-- - 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 -->
54<!-- - Open in browser: firefox 'https://www.youtube.com/playlist?list=PLdgHTasZAjYZlCXN9rTcX9LFOQ-RIrzCs' -->
55<!-- - 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' -->
56<!-- - 'Mode: ${provider}': '%switch-provider%' -->
57<!-- ``` -->
58
59<!-- > Global commands can also be used here. (Ones that start with an `:`). -->
60
61<!-- Below are the description of each of the fields: -->
62<!--  -->
63<!-- ### video -->
64<!--  -->
65<!-- Commands to be displayed in a video page. -->
66<!--  -->
67<!-- *Accept: `string_label: string_command` pairs* -->
68<!--  -->
69<!-- ### playlist -->
70<!--  -->
71<!-- Commands to be displayed in a playlist page (commands view). -->
72<!--  -->
73<!-- *Accept: `string_label: string_command` pairs* -->
74
75### Env reference
76
77Does not include custom env set in `main.yml`.
78
79|Name|Page|Value|
80|---|---|---|
81|`url`|search, popular, trending, video, playlist|String url to the web page|
82|`id`|video, playlist|String id of the video or playlist|
83|`channel-id`|video, playlist|String id of the channel|
84|`embed-url`|video|String url to the embed video (required to play video using mpv from Invidious)|
85|`all-videos`|playlist|String url***s*** separated by space to all embed videos in a playlist|
86|`hover-url`|trending, popular, search|Url of the currenly hovering item.|
87|`hover-channel-url`|feed|Url of the currenly hovering channel.|
88|`hover-channel-id`|feed|ID of the currenly hovering channel.|
89|`hover-video-url`|feed|Url of the currenly hovering video.|
90|`hover-video-id`|feed|ID of the currenly hovering video.|
91|`all-ids`|playlist|IDs of all videos in a playlist, separated with space.|
92|`offline-path`|Saved video and playlist only|Direct path to saved file.|
93|`mpv-queuelist`|Online playlists only|Valid mpv command to queue all videos in the list.|
94|`offline-queuelist`|Saved playlists only|Valid mpv command to queue all saved videos in the list.|