Commit f321f7c1e9

f321f7c1e9b41644b976ea8672807c3062908c5c

parent: e2ab565c5c

Unsigned

Siriusmart <71584876+Siriusmart@users.noreply.github.com> · 2023-08-25 11:24 UTC

0.8.0 - wrote some docs, fixed up some minor things so check commit urself

Layout: unified · split

Cargo.lock +2
@@ -1178,6 +1178,8 @@ checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079"
1178[[package]] 1178[[package]]
1179name = "tui-additions" 1179name = "tui-additions"
1180version = "0.2.1" 1180version = "0.2.1"
1181source = "registry+https://github.com/rust-lang/crates.io-index"
1182checksum = "1de5841ec45de71c46252a832bb1e3e69abf2ee2492eb309ea077c8d78e798e7"
1181dependencies = [ 1183dependencies = [
1182 "crossterm 0.26.1", 1184 "crossterm 0.26.1",
1183 "dyn-clone", 1185 "dyn-clone",
Cargo.toml +2 −2
@@ -29,7 +29,7 @@ viuer = {version = "0.6", default-features = false, optional = true}
29home = "0.5" 29home = "0.5"
30chrono = {version = "0.4", default-features = false, features = ["clock"]} 30chrono = {version = "0.4", default-features = false, features = ["clock"]}
31typemap = {version = "0.3", default-features = false} 31typemap = {version = "0.3", default-features = false}
32# tui-additions = {version = "0.2.1", default-features = false, features = ["framework", "widgets"]} 32tui-additions = {version = "0.2.1", default-features = false, features = ["framework", "widgets"]}
33invidious = {version = "0.5"} 33invidious = {version = "0.5"}
34serde_yaml = {version = "0.9", default-features = false} 34serde_yaml = {version = "0.9", default-features = false}
35dyn-clone = {version = "1.0", default-features = false} 35dyn-clone = {version = "1.0", default-features = false}
@@ -40,7 +40,7 @@ ratatui = {version = "0.21", default-features = false, features = ["serde"]}
40libmpv = { git = "https://github.com/sudipghimire533/libmpv-rs", optional = true } 40libmpv = { git = "https://github.com/sudipghimire533/libmpv-rs", optional = true }
41unicode-segmentation = "1" 41unicode-segmentation = "1"
42 42
43tui-additions = {path = "../../Rust/Packages/tui-additions", default-features = false, features = ["framework", "widgets"]} 43# tui-additions = {path = "../../Rust/Packages/tui-additions", default-features = false, features = ["framework", "widgets"]}
44# invidious = {path = "../../Rust/Packages/invidious"} 44# invidious = {path = "../../Rust/Packages/invidious"}
45 45
46[package.metadata.docs.rs] 46[package.metadata.docs.rs]
README.md +6 −11
@@ -7,21 +7,16 @@
7 7
8***Read more in the [user manual](https://siriusmart.github.io/youtube-tui) (including installation guide and documentation).*** 8***Read more in the [user manual](https://siriusmart.github.io/youtube-tui) (including installation guide and documentation).***
9 9
10> "May Invidious live and prosper, with, or without us."
11>
12> ~ The Invidious team on [YouTube trying to take them down](https://github.com/iv-org/invidious/issues/3872).
13
14Go show them some support by [donating](https://invidious.io/donate/) and starring their
15[GitHub repos](https://github.com/iv-org)!
16
17# Overview 10# Overview
18 11
19Written in Rust, the **YouTube TUI** is a lightweight and user friendly TUI for browsing YouTube content from the terminal. 12Written in Rust, the **YouTube TUI** is a lightweight and user friendly TUI for browsing YouTube content from the terminal. Works out of the box and easily to configurable.
20 13
21![](./docs/src/images/search-showcase.png) 14![](./docs/src/images/search-showcase.png)
22 15
23It is like an _app launcher_, it launches other programs to do the heavy lifting (for example, `mpv` for playing videos). 16It is like an _app launcher_, it launches other programs to do the heavy lifting (for example, `mpv` for playing videos).
24 17
18<sub>It also have an embedded mpv music player, but that can be disabled in compile time.</sub>
19
25> Consider regenerating config files on updates to allow new features. 20> Consider regenerating config files on updates to allow new features.
26 21
27## Customisable 22## Customisable
@@ -61,10 +56,10 @@ However, the programs to launch can be changed, and therefore the YouTube TUI <u
61 56
62The YouTube TUI allows you to browse YouTube with (almost) all of it's features, functions including: 57The YouTube TUI allows you to browse YouTube with (almost) all of it's features, functions including:
63 58
64- View popular/trending videos
65- View information about channels, playlists and videos 59- View information about channels, playlists and videos
66- Use search filters to sort and filter search results 60- Use search filters to sort and filter search results
67- Save browsing history 61- Save browsing history
62- Embedded audio/music player
68 63
69It also includes features like: 64It also includes features like:
70 65
@@ -77,9 +72,9 @@ It also includes features like:
77### What it doesn't have 72### What it doesn't have
78 73
79- [URGENT] Replace the no-longer-going-to-compile `typemap` dependency with either a self implementation of it or a useable crate. 74- [URGENT] Replace the no-longer-going-to-compile `typemap` dependency with either a self implementation of it or a useable crate.
80- Strip down some libraries to reduce compile speed, specifically removing. 75- Strip down some libraries to reduce compile speed.
81- Add command section for channel main page (first priority) 76- Add command section for channel main page (first priority)
82- Add NewPipe as a source alongside Invidious 77- Git like command line to improve on `yt-dlp` - make changes to existing downloaded playlists instead of redownloading the entire thing.
83 78
84## How to contribute 79## How to contribute
85 80
docs/src/README.md +5 −3
@@ -1,11 +1,13 @@
1# Overview 1# Overview
2 2
3Written in Rust, the **YouTube TUI** is a lightweight and user friendly TUI for browsing YouTube content from the terminal. 3Written in Rust, the **YouTube TUI** is a lightweight and user friendly TUI for browsing YouTube content from the terminal. Works out of the box and easily to configurable.
4 4
5![](./images/search-showcase.png) 5![](./images/search-showcase.png)
6 6
7It is like an _app launcher_, it launches other programs to do the heavy lifting (for example, `mpv` for playing videos). 7It is like an _app launcher_, it launches other programs to do the heavy lifting (for example, `mpv` for playing videos).
8 8
9<sub>It also have an embedded mpv music player, but that can be disabled in compile time.</sub>
10
9> Consider regenerating config files on updates to allow new features. 11> Consider regenerating config files on updates to allow new features.
10 12
11## Customisable 13## Customisable
@@ -45,10 +47,10 @@ However, the programs to launch can be changed, and therefore the YouTube TUI <u
45 47
46The YouTube TUI allows you to browse YouTube with (almost) all of it's features, functions including: 48The YouTube TUI allows you to browse YouTube with (almost) all of it's features, functions including:
47 49
48- View popular/trending videos
49- View information about channels, playlists and videos 50- View information about channels, playlists and videos
50- Use search filters to sort and filter search results 51- Use search filters to sort and filter search results
51- Save browsing history 52- Save browsing history
53- Embedded audio/music player
52 54
53It also includes features like: 55It also includes features like:
54 56
@@ -63,7 +65,7 @@ It also includes features like:
63- [URGENT] Replace the no-longer-going-to-compile `typemap` dependency with either a self implementation of it or a useable crate. 65- [URGENT] Replace the no-longer-going-to-compile `typemap` dependency with either a self implementation of it or a useable crate.
64- Strip down some libraries to reduce compile speed. 66- Strip down some libraries to reduce compile speed.
65- Add command section for channel main page (first priority) 67- Add command section for channel main page (first priority)
66- Up arrow command history + Ctrl arrow keys move between words 68- Git like command line to improve on `yt-dlp` - make changes to existing downloaded playlists instead of redownloading the entire thing.
67 69
68## How to contribute 70## How to contribute
69 71
docs/src/SUMMARY.md +4 −1
@@ -3,7 +3,8 @@
3- [Overview](README.md) 3- [Overview](README.md)
4- [Installation](installation.md) 4- [Installation](installation.md)
5- [Basic usage](basic_usage.md) 5- [Basic usage](basic_usage.md)
6- [Invidious](invidious.md) 6<!-- - [Invidious](invidious.md) -->
7<!-- Will add it back in when it's relevant again -->
7- [Commands](commands.md) 8- [Commands](commands.md)
8 9
9# Customisation guide 10# Customisation guide
@@ -16,6 +17,8 @@
16 - [pages](config/pages.md) 17 - [pages](config/pages.md)
17 - [appearance](config/appearance.md) 18 - [appearance](config/appearance.md)
18 - [search](config/search.md) 19 - [search](config/search.md)
20 - [cmdefine](config/cmdefine.md)
21 - [remap](config/remap.md)
19 22
20# Contributing 23# Contributing
21 24
docs/src/basic_usage.md +20 −2
@@ -24,6 +24,10 @@ The item with the cursor hovering will have a <u>red outline</u>.
24|First page history|Home| 24|First page history|Home|
25|Clear page history|End| 25|Clear page history|End|
26|Paste from clipboard|`Ctrl` + `V`| 26|Paste from clipboard|`Ctrl` + `V`|
27|Next/previous entry on search and command|`Ctrl` + up/down arrow|
28|Next song|`Ctrl` + `Shift` + Right arrow|
29|Seek audio|`Ctrl` + left/right arrow|
30|Pause/resume audio|Space|
27|Enter command mode|`:`| 31|Enter command mode|`:`|
28|Quit|`q`| 32|Quit|`q`|
29 33
@@ -41,13 +45,27 @@ To apply search filters, select the button with 3 dots (`...`) to the right of t
41 45
42![](./images/search-filters-showcase.png) 46![](./images/search-filters-showcase.png)
43 47
44## Playing videos and playlists 48> You may use `Ctrl + Up/Down arrow` to cycle through previously searched queries (when focused on the search bar).
49
50## Playing media with embedded player
51
52By default, running any "play video" options in video or playlist view will open a new mpv player window.
53
54While any "play audio" options will start playing the audio in the embedded audio player,
55
56- seek and rewind using `Ctrl + Left/Right arrow`
57- skip with `Ctrl + Shift + Right arrow`
58- pause and resume with space
59
60## Playing videos and playlists externally
61
62You can also play audio and videos externally.
45 63
46> This part assumes that you use `mpv` as your video player, `konsole` as your terminal emulator, `yt-dlp` as your YouTube video downloader, and `firefox` as your browser. 64> This part assumes that you use `mpv` as your video player, `konsole` as your terminal emulator, `yt-dlp` as your YouTube video downloader, and `firefox` as your browser.
47> 65>
48> If that is not the case, you can learn how to change that in the *custom commands* section. 66> If that is not the case, you can learn how to change that in the *custom commands* section.
49 67
50Press `Enter` to select a video or playlist from any lists, then move the cursor to the *bottom item* where you can play, download and open the webpage in browser. 68You can press keybindings like `Shift` + `A` to run a command which opens a new terminal screen, and in that terminal screen it runs an mpv command to play the media.
51 69
52## Feeds 70## Feeds
53 71
docs/src/changelogs.md +17 −9
@@ -1,20 +1,28 @@
1# Changelogs 1# Changelogs
2 2
3### v0.8.0 (latest unstable on Github) 3## v0.8.0 (latest)
4 4
5#### Added 5### Added
6 6
7- Build in MPV player, controlled by command `mpv [libmpv command] [args...]` 7- Built in MPV player, controlled by command `mpv [libmpv command] [args...]`
8- Command/search histories.
9- Keys remapping, custom commands.
8 10
9## v0.7.4 (latest stable on crates.io) 11### Fixed
10 12
11### Added 13- Some keys captured in search bar and are not working [#37](https://github.com/Siriusmart/youtube-tui/issues/37).
14
15---
16
17### v0.7.4
18
19#### Added
12 20
13- `Ctrl + w` and `Ctrl + u` in search bar and command mode. 21- `Ctrl + w` and `Ctrl + u` in search bar and command mode.
14- Keybindings works even when an item is selected (`legacy_input_handling: false` in `main.yml`). 22- Keybindings works even when an item is selected (`legacy_input_handling: false` in `main.yml`).
15- Creating fake key input using `:key` 23- Creating fake key input using `:key`
16 24
17### Fixed 25#### Fixed
18 26
19- Search filters popup closing when you click on it. 27- Search filters popup closing when you click on it.
20- Configured keybindings in all items. 28- Configured keybindings in all items.
@@ -66,7 +74,7 @@
66 74
67- Empty ItemList crash (<a href="https://github.com/Siriusmart/youtube-tui/issues/26" target=_blank>issue 26</a>) 75- Empty ItemList crash (<a href="https://github.com/Siriusmart/youtube-tui/issues/26" target=_blank>issue 26</a>)
68 76
69<hr> 77---
70 78
71## v0.6.2 79## v0.6.2
72 80
@@ -98,7 +106,7 @@
98- Vim-like commands 106- Vim-like commands
99- Pasting with `Ctrl + V` in search bar and command mode 107- Pasting with `Ctrl + V` in search bar and command mode
100 108
101<hr> 109---
102 110
103## v0.5.3 111## v0.5.3
104 112
@@ -132,7 +140,7 @@
132- Sixels image support 140- Sixels image support
133- Improved config files 141- Improved config files
134 142
135<hr> 143---
136 144
137## v0.4.4 145## v0.4.4
138 146
docs/src/commands.md +26 −12
@@ -1,6 +1,12 @@
1# Commands 1# Commands
2 2
3Commands can be entered to the TUI by pressing the `:` key, the same as in Vim. Some commands have shorter *alternatives* that can be used instead. 3Commands can be entered to the TUI by pressing the `:` key, the same as in Vim.
4
5Run the help command to view more detailed help.
6
7```sh
8youtube-tui help
9```
4 10
5> Env variables can be used by passing in as `${key}`, such as `:channel ${channel-id}` when in a video or playlist page. 11> Env variables can be used by passing in as `${key}`, such as `:channel ${channel-id}` when in a video or playlist page.
6 12
@@ -15,13 +21,7 @@ Below are the avaliable commands:
15`loadpage` can be used to load a specific page. 21`loadpage` can be used to load a specific page.
16 22
17```vim 23```vim
18loadpage popular (alt: `popular`) 24loadpage [page]
19loadpage trending (alt: `trending`)
20loadpage watchhistory (alt: `watchhistory`)
21loadpage search [search query] (alt: `search [search query]`)
22loadpage video [id or url] (alt: `video [id or url]`)
23loadpage playlist [id or url] (alt: `playlist [id or url] `)
24loadpage channel [id or url] (alt: `channel [id or url] `)
25``` 25```
26 26
27## History 27## History
@@ -29,20 +29,21 @@ loadpage channel [id or url] (alt: `channel [id or url] `)
29`history` is used to manage page history (`Backspace` equivalent). 29`history` is used to manage page history (`Backspace` equivalent).
30 30
31```vim 31```vim
32history back (alt: `back`) 32history back
33history clear 33history clear
34``` 34```
35 35
36## Utility 36## Utility
37 37
38```vim 38```vim
39reload (alt `r`) 39reload // reloads the page
40reload configs (alt `reload/r config/configs`) 40reload configs // reload config files in ~/.config/youtube-tui/
41flush 41flush
42quit (alt `q`, `exit`, `x`) 42quit
43run [command] 43run [command]
44parrun [command] 44parrun [command]
45key [keycode] [keymodifier] 45key [keycode] [keymodifier]
46echo [mode] (message) # run youtube-tui help to learn more about modes
46``` 47```
47 48
48> The `flush` command is used to run all tasks in queue immediately, this is usually done automatically. 49> The `flush` command is used to run all tasks in queue immediately, this is usually done automatically.
@@ -66,6 +67,19 @@ unsub [id or url] Remove channel from subscription
66syncall Sync all subscriptions 67syncall Sync all subscriptions
67``` 68```
68 69
70## MPV commands
71
72<sub>Only with the [`mpv`](installation.md#mpv-default) feature.</sub>
73
74```vim
75mpv prop [label] Gets mpv property
76mpv sprop [label] [value] Set mpv property
77mpv tprop [label] [value] Toggle a yes/no property
78mpv [command] Runs a libmpv command
79```
80
81> Note that properties and commands are **libmpv** commands, *not* mpv commands. Please refer to [mpv reference](https://mpv.io/manual/master/).
82
69## Text commands 83## Text commands
70 84
71Text commands generates a *text only response* without launching the TUI. 85Text commands generates a *text only response* without launching the TUI.
docs/src/config/README.md +2
@@ -12,3 +12,5 @@ In the following sections we will go through all config files including:
12- [`pages.yml`](./pages.md) 12- [`pages.yml`](./pages.md)
13- [`appearance.yml`](./appearance.md) 13- [`appearance.yml`](./appearance.md)
14- [`search.yml`](./search.md) 14- [`search.yml`](./search.md)
15- [`cmdefine.yml`](./cmdefine.md)
16- [`remap.yml`](./remap.md)
docs/src/config/cmdefine.md added +28
@@ -0,0 +1,28 @@
1# Custom commands
2
3Define custom commands. It can be found in `~/.config/youtube-tui/cmdefine.yml`.
4
5> This is still a work in progress, perhaps in the future scripting will be allowed to control and interact with elements within the TUI.
6
7```yml
8print: echo
9pause: mpv sprop pause yes ;; echo mpv Player paused
10next: mpv playlist-next ;; echo mpv Skipped
11resume: mpv sprop pause no ;; echo mpv Player resumed
12search: loadpage search
13rc: reload configs
14```
15
16---
17
18General format:
19
20```yml
21new command: original command
22```
23
24This allows for alternative shorthand commands.
25
26<sub>More about commands run `youtube-tui help` or check out [commands](commands.md).</sub>
27
28> Try not to use self referencing commands, it'll make a mess.
docs/src/config/commands.md +62 −58
@@ -5,73 +5,74 @@ The commands config file decides what options (that will run a certain command o
5## Example commands config 5## Example commands config
6 6
7```yaml 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 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: 9video:
10- Play video: ${video-player} ${embed-url} 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 audio: ${terminal-emulator} ${video-player} ${embed-url} --no-video 11- Play video: parrun ${video-player} '${embed-url}'
12- Play audio (loop): ${terminal-emulator} ${video-player} ${embed-url} --no-video --loop-file=inf 12- Play audio: mpv stop ;; resume ;; mpv sprop loop-file no ;; mpv loadfile '${embed-url}' ;; echo mpv Player started
13- View channel: :channel ${channel-id} 13- Play audio (loop): mpv stop ;; resume ;; mpv sprop loop-file inf ;; mpv loadfile '${embed-url}' ;; echo mpv Player started
14- Open in browser: ${browser} ${url} 14- View channel: channel ${channel-id}
15- Download video (webm): ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${embed-url} 15- Subscribe to channel: sync ${channel-id}
16- Download audio (opus): ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${embed-url} -x 16- Open in browser: parrun ${browser} '${url}'
17- 'Mode: ${provider}': '%switch-provider%' 17- Toggle bookmark: togglemark ${id}
18playlist: 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- Switch view: '%switch-view%' 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- Play all videos: ${video-player} ${all-videos} 20- 'Mode: ${provider}': switchprovider
21- Play all audio: ${terminal-emulator} ${video-player} ${all-videos} --no-video 21
22- Shuffle play all audio: ${terminal-emulator} ${video-player} ${all-videos} --no-video --shuffle 22# ...
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``` 23```
30 24
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> 25<hr>
59 26
60Below are the description of each of the fields: 27The few required fields are:
61
62### video
63 28
64Commands to be displayed in a video page. 29- `video`
30- `saved_video`
31- `playlist`
32- `saved_playlist`
65 33
66*Accept: `string_label: string_command` pairs* 34## Env variables
67
68### playlist
69
70Commands to be displayed in a playlist page (commands view).
71 35
72*Accept: `string_label: string_command` pairs* 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.
73 37
74## Env reference 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
75 76
76Does not include custom env set in `main.yml`. 77Does not include custom env set in `main.yml`.
77 78
@@ -88,3 +89,6 @@ Does not include custom env set in `main.yml`.
88|`hover-video-url`|feed|Url of the currenly hovering video.| 89|`hover-video-url`|feed|Url of the currenly hovering video.|
89|`hover-video-id`|feed|ID of the currenly hovering video.| 90|`hover-video-id`|feed|ID of the currenly hovering video.|
90|`all-ids`|playlist|IDs of all videos in a playlist, separated with space.| 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.|
docs/src/config/main.md +23 −10
@@ -6,20 +6,32 @@ The main config file is located in `~/.config/youtube-tui/main.yml`.
6 6
7```yaml 7```yaml
8mouse_support: true 8mouse_support: true
9invidious_instance: https://y.com.sb 9invidious_instance: https://invidious.fdn.fr
10write_config: Try 10write_config: Try
11max_watch_history: 50 11allow_unicode: true
12allow_unicode: false
13message_bar_default: All good :) 12message_bar_default: All good :)
14images: Sixels 13images: Sixels
15refresh_after_modifying_search_filters: true 14refresh_after_modifying_search_filters: true
15syncing:
16 download_images: true
17 sync_channel_info: true
18 sync_channel_cooldown_secs: 86400
19 sync_videos_cooldown_secs: 600
20limits:
21 watch_history: 50
22 search_history: 75
23 commands_history: 75
16image_index: 4 24image_index: 4
17provider: YouTube 25provider: YouTube
26shell: sh
27legacy_input_handling: false
18env: 28env:
19 browser: firefox 29 video-player: mpv
30 download-path: ~/Downloads/%(title)s-%(id)s.%(ext)s
20 terminal-emulator: konsole -e 31 terminal-emulator: konsole -e
21 youtube-downloader: yt-dlp 32 youtube-downloader: yt-dlp
22 video-player: mpv 33 save-path: ~/.local/share/youtube-tui/saved/
34 browser: firefox
23``` 35```
24 36
25<hr> 37<hr>
@@ -52,11 +64,6 @@ Whether to write to config after every read, this allows for auto-formatting the
52 64
53*Accept: `Must`/`Try`/`Dont`* 65*Accept: `Must`/`Try`/`Dont`*
54 66
55### max_watch_history
56
57The maximum length that the watch history can hold, a value higher will record more items, but will also result in a larger file size in storage.
58
59*Accept: positive integer below 2<sup>*your CPU architecture*</sup> - 1*
60 67
61### allow_unicode 68### allow_unicode
62 69
@@ -106,6 +113,12 @@ Sync all do not sync videos from channel if it has been synced in the past *n* s
106 113
107*Accept: integer value seconds* 114*Accept: integer value seconds*
108 115
116### limits
117
118The maximum length that the watch/search/command history can hold, a value higher will record more items, but will also result in a larger file size in storage.
119
120*Accept: positive integer below 2<sup>*your CPU architecture*</sup> - 1*
121
109### image_index 122### image_index
110 123
111The index in the array of thumbnail qualities you want to download 124The index in the array of thumbnail qualities you want to download
docs/src/config/pages.md +2
@@ -64,3 +64,5 @@ Command to run when the page loads, you can use the `key` command to select an i
64|ChannelMain|Channel display|Loads the main channel page| 64|ChannelMain|Channel display|Loads the main channel page|
65|ChannelVideos|Channel display|Loads the channel videos page| 65|ChannelVideos|Channel display|Loads the channel videos page|
66|ChannelPlaylists|Channel display|Loads the channel playlists page| 66|ChannelPlaylists|Channel display|Loads the channel playlists page|
67|ChannelList|Feed|Displays subscribed channels|
68|VideoList|Feed|Displays videos of subscribed channels|
docs/src/config/remap.md added +5
@@ -0,0 +1,5 @@
1# Key remaps
2
3Very old concept of hard remapping one key to another. The config file can be found in `~/.config/youtube-tui/remaps.yml`.
4
5Not recommended using unless you got some issues that prevents certain keys from being pressed.
docs/src/config/search.md +21 −1
@@ -23,8 +23,28 @@ The default query when you launch the TUI.
23 23
24*Accept: any string* 24*Accept: any string*
25 25
26### Sort 26### sort
27 27
28How the search results are sorted. 28How the search results are sorted.
29 29
30*Accept: `Relevance`/`Rating`/`Date`/`Views`* 30*Accept: `Relevance`/`Rating`/`Date`/`Views`*
31
32### date
33
34Restrict videos publish date.
35
36*Accept: `None`, `Hour`, `Day`, `Week`, `Month`, `Year`*
37
38### duration
39
40Restrict videos duration.
41
42*Accept: `None`, `Short`, `Medium`, `Long`*
43
44### type
45
46Restrict video types
47
48*Accept: `All`, `Video`, `Channel`, `Playlist`*
49
50> All these options can also be changed in runtime using [search filters](basic_usage.md#searching)
docs/src/images/search-showcase.png

Binary file not shown.

docs/src/installation.md +6
@@ -85,3 +85,9 @@ Requires <a href="https://github.com/saitoha/libsixel" target=_blank>`libsixel`<
85Allows clipboard pasting in commands and search bar. 85Allows clipboard pasting in commands and search bar.
86 86
87Requires <a href="https://xcb.freedesktop.org/" target=_blank>`libxcb`</a>. 87Requires <a href="https://xcb.freedesktop.org/" target=_blank>`libxcb`</a>.
88
89### `mpv` (default)
90
91Embedded audio player
92
93Requires <a href="https://mpv.io/" target=_blank>`mpv`</a> (libmpv) to be installed in your system.
src/config/commandbindings.rs +1 −1
@@ -184,7 +184,7 @@ fn global_default() -> HashMap<KeyCodeSerde, HashMap<u8, String>> {
184 HashMap::from([ 184 HashMap::from([
185 ( 185 (
186 2, 186 2,
187 String::from("mpv seek -5 ;; echo mpv Reversed 5 seconds"), 187 String::from("mpv seek -5 ;; echo mpv Rewinded 5 seconds"),
188 ), 188 ),
189 (3, String::from("back ;; echo mpv Unskipped")), 189 (3, String::from("back ;; echo mpv Unskipped")),
190 ]), 190 ]),
src/global/functions/key_input.rs +1 −3
@@ -2,9 +2,7 @@ use std::{any::TypeId, io::Stdout};
2 2
3use crossterm::event::KeyEvent; 3use crossterm::event::KeyEvent;
4use ratatui::{backend::CrosstermBackend, Terminal}; 4use ratatui::{backend::CrosstermBackend, Terminal};
5use tui_additions::{ 5use tui_additions::framework::{Framework, FrameworkDirection};
6 framework::{Framework, FrameworkDirection},
7};
8 6
9use crate::{config::*, global::structs::*, items::SearchBar}; 7use crate::{config::*, global::structs::*, items::SearchBar};
10 8
src/global/functions/run_command.rs +12
@@ -303,6 +303,12 @@ pub fn run_single_command(
303 *framework.data.global.get_mut::<Message>().unwrap() = 303 *framework.data.global.get_mut::<Message>().unwrap() =
304 Message::Success(String::from("Copied to clipboad")); 304 Message::Success(String::from("Copied to clipboad"));
305 } 305 }
306 #[cfg(not(feature = "clipboard"))]
307 ["copy", ..] => {
308 *framework.data.global.get_mut::<Message>().unwrap() = Message::Error(String::from(
309 "Feature `clipboard` is disabled and not compiled",
310 ));
311 }
306 ["sync", identifier] => { 312 ["sync", identifier] => {
307 let id = if identifier.len() == 24 { 313 let id = if identifier.len() == 24 {
308 identifier.to_string() 314 identifier.to_string()
@@ -520,6 +526,11 @@ pub fn run_single_command(
520 _ => unreachable!(), 526 _ => unreachable!(),
521 }; 527 };
522 } 528 }
529 #[cfg(not(feature = "mpv"))]
530 ["mpv", ..] => {
531 *framework.data.global.get_mut::<Message>().unwrap() =
532 Message::Error(String::from("Feature `mpv` is disabled and not compiled"));
533 }
523 ["echo", r#type, ..] => { 534 ["echo", r#type, ..] => {
524 *framework.data.global.get_mut::<Message>().unwrap() = match *r#type { 535 *framework.data.global.get_mut::<Message>().unwrap() = match *r#type {
525 "message" => Message::Message(command[2..].join(" ")), 536 "message" => Message::Message(command[2..].join(" ")),
@@ -618,6 +629,7 @@ fn help_msg(cmdefines: &CommandsRemapConfig) -> String {
618 \x1b[33mparrun [command]\x1b[0m Runs a system command non blocking (e.g. `run firefox example.com`) 629 \x1b[33mparrun [command]\x1b[0m Runs a system command non blocking (e.g. `run firefox example.com`)
619 \x1b[33mcopy [text]\x1b[0m Copies text to clipboard 630 \x1b[33mcopy [text]\x1b[0m Copies text to clipboard
620 \x1b[33mkey [keycode] [keymodifier]\x1b[0m Create a key input event 631 \x1b[33mkey [keycode] [keymodifier]\x1b[0m Create a key input event
632 \x1b[33mecho [mode] [message]\x1b[0m Dispalys a message in message bar, mode: none, success, warn, error, mpv (can be overwritten by mpv player)
621 633
622\x1b[91mLIBRARY:\x1b[0m 634\x1b[91mLIBRARY:\x1b[0m
623 \x1b[33mbookmark [id]\x1b[0m Bookmark item with ID (item must be already loaded) 635 \x1b[33mbookmark [id]\x1b[0m Bookmark item with ID (item must be already loaded)
src/global/structs/tasks.rs +31 −31
@@ -7,7 +7,7 @@ use ratatui::{
7 backend::CrosstermBackend, layout::Alignment, style::Style, widgets::Paragraph, Frame, Terminal, 7 backend::CrosstermBackend, layout::Alignment, style::Style, widgets::Paragraph, Frame, Terminal,
8}; 8};
9use std::{error::Error, io::Stdout, mem}; 9use std::{error::Error, io::Stdout, mem};
10use tui_additions::framework::{CursorState, Framework, FrameworkItem}; 10use tui_additions::framework::{CursorState, Framework};
11use typemap::Key; 11use typemap::Key;
12 12
13/// tasks to be put on taskqueues 13/// tasks to be put on taskqueues
@@ -258,36 +258,36 @@ impl TaskQueue {
258 framework.render(frame); 258 framework.render(frame);
259 } 259 }
260 260
261 pub fn render_filter( 261 // pub fn render_filter(
262 framework: &mut Framework, 262 // framework: &mut Framework,
263 terminal: &mut Terminal<CrosstermBackend<Stdout>>, 263 // terminal: &mut Terminal<CrosstermBackend<Stdout>>,
264 filter: impl Fn(&Box<dyn FrameworkItem>) -> bool, 264 // filter: impl Fn(&Box<dyn FrameworkItem>) -> bool,
265 ) -> Result<(), Box<dyn Error>> { 265 // ) -> Result<(), Box<dyn Error>> {
266 Self::render_filter_with_frame(framework, &mut terminal.get_frame(), filter); 266 // Self::render_filter_with_frame(framework, &mut terminal.get_frame(), filter);
267 terminal.flush()?; 267 // terminal.flush()?;
268 Ok(()) 268 // Ok(())
269 } 269 // }
270 270 //
271 pub fn render_filter_with_frame( 271 // pub fn render_filter_with_frame(
272 framework: &mut Framework, 272 // framework: &mut Framework,
273 frame: &mut Frame<CrosstermBackend<Stdout>>, 273 // frame: &mut Frame<CrosstermBackend<Stdout>>,
274 filter: impl Fn(&Box<dyn FrameworkItem>) -> bool, 274 // filter: impl Fn(&Box<dyn FrameworkItem>) -> bool,
275 ) { 275 // ) {
276 let area = frame.size(); 276 // let area = frame.size();
277 277 //
278 framework 278 // framework
279 .data 279 // .data
280 .global 280 // .global
281 .get_mut::<Status>() 281 // .get_mut::<Status>()
282 .unwrap() 282 // .unwrap()
283 .prev_frame = Some(area); 283 // .prev_frame = Some(area);
284 284 //
285 if Self::protective_screen(framework, frame) { 285 // if Self::protective_screen(framework, frame) {
286 return; 286 // return;
287 } 287 // }
288 288 //
289 framework.render_filter(frame, filter); 289 // framework.render_filter(frame, filter);
290 } 290 // }
291 291
292 /// this function renders onto the given frame 292 /// this function renders onto the given frame
293 pub fn protective_screen( 293 pub fn protective_screen(
src/items/messagebar.rs +71 −68
@@ -1,13 +1,12 @@
1use crate::{ 1#[cfg(feature = "mpv")]
2 config::*, 2use crate::global::functions::secs_display_string;
3 global::{functions::secs_display_string, structs::*}, 3use crate::{config::*, global::structs::*};
4};
5use ratatui::{ 4use ratatui::{
6 layout::Rect, 5 layout::Rect,
7 style::Style, 6 style::Style,
8 widgets::{Block, Borders, Paragraph}, 7 widgets::{Block, Borders, Paragraph},
9}; 8};
10use tui_additions::framework::{FrameworkClean, FrameworkItem}; 9use tui_additions::framework::*;
11 10
12/// a message bar item, contains no fields because the message is taken from `data.global.Message` 11/// a message bar item, contains no fields because the message is taken from `data.global.Message`
13#[derive(Clone, Copy, Default)] 12#[derive(Clone, Copy, Default)]
@@ -26,72 +25,75 @@ impl FrameworkItem for MessageBar {
26 return; 25 return;
27 } 26 }
28 27
29 let mpv = framework.data.global.get::<MpvWrapper>().unwrap(); 28 #[cfg(feature = "mpv")]
30 if Self::is_mpv_render(framework) { 29 {
31 let mut label = mpv.property("media-title".to_string()).unwrap(); 30 let mpv = framework.data.global.get::<MpvWrapper>().unwrap();
32 if let Some((name, ext)) = label.rsplit_once('.') { 31 if Self::is_mpv_render(framework) {
33 if ext.len() < 5 32 let mut label = mpv.property("media-title".to_string()).unwrap();
34 && !name.len() > 13 33 if let Some((name, ext)) = label.rsplit_once('.') {
35 && &name[name.len() - 1..name.len()] == "]" 34 if ext.len() < 5
36 && name[name.len() - 12..name.len() - 1] 35 && !name.len() > 13
37 .chars() 36 && &name[name.len() - 1..name.len()] == "]"
38 .all(|c| c.is_ascii_alphanumeric() || matches!(c, '-' | '_')) 37 && name[name.len() - 12..name.len() - 1]
39 && &name[name.len() - 13..name.len() - 12] == "[" 38 .chars()
40 { 39 .all(|c| c.is_ascii_alphanumeric() || matches!(c, '-' | '_'))
41 label = name[0..name.len() - 13].to_string(); 40 && &name[name.len() - 13..name.len() - 12] == "["
41 {
42 label = name[0..name.len() - 13].to_string();
43 }
42 } 44 }
43 } 45 let duration = mpv
44 let duration = mpv 46 .property("duration".to_string())
45 .property("duration".to_string()) 47 .unwrap_or_default()
46 .unwrap_or_default() 48 .parse::<f64>()
47 .parse::<f64>() 49 .unwrap() as u64;
48 .unwrap() as u64; 50 let duration_s = secs_display_string(duration as u32);
49 let duration_s = secs_display_string(duration as u32); 51 let playerhead = mpv
50 let playerhead = mpv 52 .property("time-pos".to_string())
51 .property("time-pos".to_string()) 53 .unwrap_or_default()
52 .unwrap_or_default() 54 .parse::<f64>()
53 .parse::<f64>() 55 .unwrap() as u64;
54 .unwrap() as u64; 56 let mut playerhead_s = secs_display_string(playerhead as u32);
55 let mut playerhead_s = secs_display_string(playerhead as u32); 57 if playerhead_s.len() != duration_s.len() {
56 if playerhead_s.len() != duration_s.len() { 58 playerhead_s = format!(
57 playerhead_s = format!( 59 "{}{playerhead_s}",
58 "{}{playerhead_s}", 60 " ".repeat(duration_s.len() - playerhead_s.len())
59 " ".repeat(duration_s.len() - playerhead_s.len()) 61 );
60 ); 62 }
61 } 63 let percentage = (playerhead * 100 / duration).to_string();
62 let percentage = (playerhead * 100 / duration).to_string();
63 64
64 let right_chunk = format!( 65 let right_chunk = format!(
65 "{playerhead_s}/{duration_s} {}[{percentage}%]", 66 "{playerhead_s}/{duration_s} {}[{percentage}%]",
66 " ".repeat(3 - percentage.len()) 67 " ".repeat(3 - percentage.len())
67 ); 68 );
68 let left_chunk = format!("[Now Playing]: {label}"); 69 let left_chunk = format!("[Now Playing]: {label}");
69 let length = area.width as usize - 2; 70 let length = area.width as usize - 2;
70 let total_len = right_chunk.len() + left_chunk.len(); 71 let total_len = right_chunk.len() + left_chunk.len();
71 72
72 *framework.data.global.get_mut::<Message>().unwrap() = 73 *framework.data.global.get_mut::<Message>().unwrap() =
73 Message::Mpv(if length > total_len + 6 { 74 Message::Mpv(if length > total_len + 6 {
74 let mut seeker_len = length - total_len - 4; 75 let mut seeker_len = length - total_len - 4;
75 let seeker_pad = if seeker_len > 10 { seeker_len / 10 } else { 0 }; 76 let seeker_pad = if seeker_len > 10 { seeker_len / 10 } else { 0 };
76 seeker_len -= seeker_pad * 2; 77 seeker_len -= seeker_pad * 2;
77 let seeker_pos = (seeker_len - 1) * playerhead as usize / duration as usize; 78 let seeker_pos = (seeker_len - 1) * playerhead as usize / duration as usize;
78 format!( 79 format!(
79 "{left_chunk} {}├{}-{}┤{} {right_chunk}", 80 "{left_chunk} {}├{}-{}┤{} {right_chunk}",
80 " ".repeat(seeker_pad), 81 " ".repeat(seeker_pad),
81 "─".repeat(seeker_pos), 82 "─".repeat(seeker_pos),
82 "─".repeat(seeker_len - seeker_pos - 1), 83 "─".repeat(seeker_len - seeker_pos - 1),
83 " ".repeat(seeker_pad) 84 " ".repeat(seeker_pad)
84 ) 85 )
85 } else if length > total_len + 3 { 86 } else if length > total_len + 3 {
86 format!( 87 format!(
87 "{left_chunk}{}{right_chunk}", 88 "{left_chunk}{}{right_chunk}",
88 " ".repeat(length - total_len) 89 " ".repeat(length - total_len)
89 ) 90 )
90 } else if length > 19 { 91 } else if length > 19 {
91 left_chunk 92 left_chunk
92 } else { 93 } else {
93 String::from("Not enough width") 94 String::from("Not enough width")
94 }); 95 });
96 }
95 } 97 }
96 98
97 let message = framework.data.global.get::<Message>().unwrap(); 99 let message = framework.data.global.get::<Message>().unwrap();
@@ -156,6 +158,7 @@ impl FrameworkItem for MessageBar {
156 } 158 }
157} 159}
158 160
161#[cfg(feature = "mpv")]
159impl MessageBar { 162impl MessageBar {
160 pub fn is_mpv_render(framework: &FrameworkClean) -> bool { 163 pub fn is_mpv_render(framework: &FrameworkClean) -> bool {
161 framework.data.global.get::<MpvWrapper>().unwrap().playing() 164 framework.data.global.get::<MpvWrapper>().unwrap().playing()
src/run.rs +7 −7
@@ -1,17 +1,14 @@
1use crossterm::event::{self, Event, MouseButton, MouseEventKind}; 1use crossterm::event::{self, Event, MouseButton, MouseEventKind};
2use ratatui::{backend::CrosstermBackend, Terminal}; 2use ratatui::{backend::CrosstermBackend, Terminal};
3use std::{ 3#[cfg(feature = "mpv")]
4 any::TypeId, 4use std::time::{Duration, Instant};
5 error::Error, 5use std::{any::TypeId, error::Error, io::Stdout};
6 io::Stdout,
7 time::{Duration, Instant},
8};
9use tui_additions::framework::Framework; 6use tui_additions::framework::Framework;
10 7
11use crate::{ 8use crate::{
12 config::*, 9 config::*,
13 global::{functions::*, structs::*}, 10 global::{functions::*, structs::*},
14 items::{MessageBar, SearchFilter}, 11 items::*,
15}; 12};
16 13
17/// the main event loop of the program 14/// the main event loop of the program
@@ -19,7 +16,9 @@ pub fn run(
19 terminal: &mut Terminal<CrosstermBackend<Stdout>>, 16 terminal: &mut Terminal<CrosstermBackend<Stdout>>,
20 framework: &mut Framework, 17 framework: &mut Framework,
21) -> Result<(), Box<dyn Error>> { 18) -> Result<(), Box<dyn Error>> {
19 #[cfg(feature = "mpv")]
22 let tick_rate = Duration::from_secs(1); 20 let tick_rate = Duration::from_secs(1);
21 #[cfg(feature = "mpv")]
23 let mut last_tick = Instant::now(); 22 let mut last_tick = Instant::now();
24 loop { 23 loop {
25 // repeat forever until all tasks are ran (and Tasks is cleared) 24 // repeat forever until all tasks are ran (and Tasks is cleared)
@@ -41,6 +40,7 @@ pub fn run(
41 break; 40 break;
42 } 41 }
43 42
43 #[cfg(feature = "mpv")]
44 if !event::poll( 44 if !event::poll(
45 tick_rate 45 tick_rate
46 .checked_sub(last_tick.elapsed()) 46 .checked_sub(last_tick.elapsed())