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"
11781178[[package]]
11791179name = "tui-additions"
11801180version = "0.2.1"
1181source = "registry+https://github.com/rust-lang/crates.io-index"
1182checksum = "1de5841ec45de71c46252a832bb1e3e69abf2ee2492eb309ea077c8d78e798e7"
11811183dependencies = [
11821184 "crossterm 0.26.1",
11831185 "dyn-clone",
Cargo.toml +2 −2
@@ -29,7 +29,7 @@ viuer = {version = "0.6", default-features = false, optional = true}
2929home = "0.5"
3030chrono = {version = "0.4", default-features = false, features = ["clock"]}
3131typemap = {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"]}
3333invidious = {version = "0.5"}
3434serde_yaml = {version = "0.9", default-features = false}
3535dyn-clone = {version = "1.0", default-features = false}
@@ -40,7 +40,7 @@ ratatui = {version = "0.21", default-features = false, features = ["serde"]}
4040libmpv = { git = "https://github.com/sudipghimire533/libmpv-rs", optional = true }
4141unicode-segmentation = "1"
4242
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"]}
4444# invidious = {path = "../../Rust/Packages/invidious"}
4545
4646[package.metadata.docs.rs]
README.md +6 −11
@@ -7,21 +7,16 @@
77
88***Read more in the [user manual](https://siriusmart.github.io/youtube-tui) (including installation guide and documentation).***
99
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
1710# Overview
1811
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.
2013
2114![](./docs/src/images/search-showcase.png)
2215
2316It is like an _app launcher_, it launches other programs to do the heavy lifting (for example, `mpv` for playing videos).
2417
18<sub>It also have an embedded mpv music player, but that can be disabled in compile time.</sub>
19
2520> Consider regenerating config files on updates to allow new features.
2621
2722## Customisable
@@ -61,10 +56,10 @@ However, the programs to launch can be changed, and therefore the YouTube TUI <u
6156
6257The YouTube TUI allows you to browse YouTube with (almost) all of it's features, functions including:
6358
64- View popular/trending videos
6559- View information about channels, playlists and videos
6660- Use search filters to sort and filter search results
6761- Save browsing history
62- Embedded audio/music player
6863
6964It also includes features like:
7065
@@ -77,9 +72,9 @@ It also includes features like:
7772### What it doesn't have
7873
7974- [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.
8176- 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.
8378
8479## How to contribute
8580
docs/src/README.md +5 −3
@@ -1,11 +1,13 @@
11# Overview
22
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.
44
55![](./images/search-showcase.png)
66
77It is like an _app launcher_, it launches other programs to do the heavy lifting (for example, `mpv` for playing videos).
88
9<sub>It also have an embedded mpv music player, but that can be disabled in compile time.</sub>
10
911> Consider regenerating config files on updates to allow new features.
1012
1113## Customisable
@@ -45,10 +47,10 @@ However, the programs to launch can be changed, and therefore the YouTube TUI <u
4547
4648The YouTube TUI allows you to browse YouTube with (almost) all of it's features, functions including:
4749
48- View popular/trending videos
4950- View information about channels, playlists and videos
5051- Use search filters to sort and filter search results
5152- Save browsing history
53- Embedded audio/music player
5254
5355It also includes features like:
5456
@@ -63,7 +65,7 @@ It also includes features like:
6365- [URGENT] Replace the no-longer-going-to-compile `typemap` dependency with either a self implementation of it or a useable crate.
6466- Strip down some libraries to reduce compile speed.
6567- 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.
6769
6870## How to contribute
6971
docs/src/SUMMARY.md +4 −1
@@ -3,7 +3,8 @@
33- [Overview](README.md)
44- [Installation](installation.md)
55- [Basic usage](basic_usage.md)
6- [Invidious](invidious.md)
6<!-- - [Invidious](invidious.md) -->
7<!-- Will add it back in when it's relevant again -->
78- [Commands](commands.md)
89
910# Customisation guide
@@ -16,6 +17,8 @@
1617 - [pages](config/pages.md)
1718 - [appearance](config/appearance.md)
1819 - [search](config/search.md)
20 - [cmdefine](config/cmdefine.md)
21 - [remap](config/remap.md)
1922
2023# Contributing
2124
docs/src/basic_usage.md +20 −2
@@ -24,6 +24,10 @@ The item with the cursor hovering will have a <u>red outline</u>.
2424|First page history|Home|
2525|Clear page history|End|
2626|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|
2731|Enter command mode|`:`|
2832|Quit|`q`|
2933
@@ -41,13 +45,27 @@ To apply search filters, select the button with 3 dots (`...`) to the right of t
4145
4246![](./images/search-filters-showcase.png)
4347
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.
4563
4664> 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.
4765>
4866> If that is not the case, you can learn how to change that in the *custom commands* section.
4967
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.
5169
5270## Feeds
5371
docs/src/changelogs.md +17 −9
@@ -1,20 +1,28 @@
11# Changelogs
22
3### v0.8.0 (latest unstable on Github)
3## v0.8.0 (latest)
44
5#### Added
5### Added
66
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.
810
9## v0.7.4 (latest stable on crates.io)
11### Fixed
1012
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
1220
1321- `Ctrl + w` and `Ctrl + u` in search bar and command mode.
1422- Keybindings works even when an item is selected (`legacy_input_handling: false` in `main.yml`).
1523- Creating fake key input using `:key`
1624
17### Fixed
25#### Fixed
1826
1927- Search filters popup closing when you click on it.
2028- Configured keybindings in all items.
@@ -66,7 +74,7 @@
6674
6775- Empty ItemList crash (<a href="https://github.com/Siriusmart/youtube-tui/issues/26" target=_blank>issue 26</a>)
6876
69<hr>
77---
7078
7179## v0.6.2
7280
@@ -98,7 +106,7 @@
98106- Vim-like commands
99107- Pasting with `Ctrl + V` in search bar and command mode
100108
101<hr>
109---
102110
103111## v0.5.3
104112
@@ -132,7 +140,7 @@
132140- Sixels image support
133141- Improved config files
134142
135<hr>
143---
136144
137145## v0.4.4
138146
docs/src/commands.md +26 −12
@@ -1,6 +1,12 @@
11# Commands
22
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```
410
511> Env variables can be used by passing in as `${key}`, such as `:channel ${channel-id}` when in a video or playlist page.
612
@@ -15,13 +21,7 @@ Below are the avaliable commands:
1521`loadpage` can be used to load a specific page.
1622
1723```vim
18loadpage popular (alt: `popular`)
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] `)
24loadpage [page]
2525```
2626
2727## History
@@ -29,20 +29,21 @@ loadpage channel [id or url] (alt: `channel [id or url] `)
2929`history` is used to manage page history (`Backspace` equivalent).
3030
3131```vim
32history back (alt: `back`)
32history back
3333history clear
3434```
3535
3636## Utility
3737
3838```vim
39reload (alt `r`)
40reload configs (alt `reload/r config/configs`)
39reload // reloads the page
40reload configs // reload config files in ~/.config/youtube-tui/
4141flush
42quit (alt `q`, `exit`, `x`)
42quit
4343run [command]
4444parrun [command]
4545key [keycode] [keymodifier]
46echo [mode] (message) # run youtube-tui help to learn more about modes
4647```
4748
4849> 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
6667syncall Sync all subscriptions
6768```
6869
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
6983## Text commands
7084
7185Text 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:
1212- [`pages.yml`](./pages.md)
1313- [`appearance.yml`](./appearance.md)
1414- [`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
55## Example commands config
66
77```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
99video:
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%'
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# ...
2923```
3024
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
5825<hr>
5926
60Below are the description of each of the fields:
61
62### video
27The few required fields are:
6328
64Commands to be displayed in a video page.
29- `video`
30- `saved_video`
31- `playlist`
32- `saved_playlist`
6533
66*Accept: `string_label: string_command` pairs*
67
68### playlist
69
70Commands to be displayed in a playlist page (commands view).
34## Env variables
7135
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.
7337
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
7576
7677Does not include custom env set in `main.yml`.
7778
@@ -88,3 +89,6 @@ Does not include custom env set in `main.yml`.
8889|`hover-video-url`|feed|Url of the currenly hovering video.|
8990|`hover-video-id`|feed|ID of the currenly hovering video.|
9091|`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`.
66
77```yaml
88mouse_support: true
9invidious_instance: https://y.com.sb
9invidious_instance: https://invidious.fdn.fr
1010write_config: Try
11max_watch_history: 50
12allow_unicode: false
11allow_unicode: true
1312message_bar_default: All good :)
1413images: Sixels
1514refresh_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
1624image_index: 4
1725provider: YouTube
26shell: sh
27legacy_input_handling: false
1828env:
19 browser: firefox
29 video-player: mpv
30 download-path: ~/Downloads/%(title)s-%(id)s.%(ext)s
2031 terminal-emulator: konsole -e
2132 youtube-downloader: yt-dlp
22 video-player: mpv
33 save-path: ~/.local/share/youtube-tui/saved/
34 browser: firefox
2335```
2436
2537<hr>
@@ -52,11 +64,6 @@ Whether to write to config after every read, this allows for auto-formatting the
5264
5365*Accept: `Must`/`Try`/`Dont`*
5466
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*
6067
6168### allow_unicode
6269
@@ -106,6 +113,12 @@ Sync all do not sync videos from channel if it has been synced in the past *n* s
106113
107114*Accept: integer value seconds*
108115
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
109122### image_index
110123
111124The 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
6464|ChannelMain|Channel display|Loads the main channel page|
6565|ChannelVideos|Channel display|Loads the channel videos page|
6666|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.
2323
2424*Accept: any string*
2525
26### Sort
26### sort
2727
2828How the search results are sorted.
2929
3030*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`<
8585Allows clipboard pasting in commands and search bar.
8686
8787Requires <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>> {
184184 HashMap::from([
185185 (
186186 2,
187 String::from("mpv seek -5 ;; echo mpv Reversed 5 seconds"),
187 String::from("mpv seek -5 ;; echo mpv Rewinded 5 seconds"),
188188 ),
189189 (3, String::from("back ;; echo mpv Unskipped")),
190190 ]),
src/global/functions/key_input.rs +1 −3
@@ -2,9 +2,7 @@ use std::{any::TypeId, io::Stdout};
22
33use crossterm::event::KeyEvent;
44use ratatui::{backend::CrosstermBackend, Terminal};
5use tui_additions::{
6 framework::{Framework, FrameworkDirection},
7};
5use tui_additions::framework::{Framework, FrameworkDirection};
86
97use crate::{config::*, global::structs::*, items::SearchBar};
108
src/global/functions/run_command.rs +12
@@ -303,6 +303,12 @@ pub fn run_single_command(
303303 *framework.data.global.get_mut::<Message>().unwrap() =
304304 Message::Success(String::from("Copied to clipboad"));
305305 }
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 }
306312 ["sync", identifier] => {
307313 let id = if identifier.len() == 24 {
308314 identifier.to_string()
@@ -520,6 +526,11 @@ pub fn run_single_command(
520526 _ => unreachable!(),
521527 };
522528 }
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 }
523534 ["echo", r#type, ..] => {
524535 *framework.data.global.get_mut::<Message>().unwrap() = match *r#type {
525536 "message" => Message::Message(command[2..].join(" ")),
@@ -618,6 +629,7 @@ fn help_msg(cmdefines: &CommandsRemapConfig) -> String {
618629 \x1b[33mparrun [command]\x1b[0m Runs a system command non blocking (e.g. `run firefox example.com`)
619630 \x1b[33mcopy [text]\x1b[0m Copies text to clipboard
620631 \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)
621633
622634\x1b[91mLIBRARY:\x1b[0m
623635 \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::{
77 backend::CrosstermBackend, layout::Alignment, style::Style, widgets::Paragraph, Frame, Terminal,
88};
99use std::{error::Error, io::Stdout, mem};
10use tui_additions::framework::{CursorState, Framework, FrameworkItem};
10use tui_additions::framework::{CursorState, Framework};
1111use typemap::Key;
1212
1313/// tasks to be put on taskqueues
@@ -258,36 +258,36 @@ impl TaskQueue {
258258 framework.render(frame);
259259 }
260260
261 pub fn render_filter(
262 framework: &mut Framework,
263 terminal: &mut Terminal<CrosstermBackend<Stdout>>,
264 filter: impl Fn(&Box<dyn FrameworkItem>) -> bool,
265 ) -> Result<(), Box<dyn Error>> {
266 Self::render_filter_with_frame(framework, &mut terminal.get_frame(), filter);
267 terminal.flush()?;
268 Ok(())
269 }
270
271 pub fn render_filter_with_frame(
272 framework: &mut Framework,
273 frame: &mut Frame<CrosstermBackend<Stdout>>,
274 filter: impl Fn(&Box<dyn FrameworkItem>) -> bool,
275 ) {
276 let area = frame.size();
277
278 framework
279 .data
280 .global
281 .get_mut::<Status>()
282 .unwrap()
283 .prev_frame = Some(area);
284
285 if Self::protective_screen(framework, frame) {
286 return;
287 }
288
289 framework.render_filter(frame, filter);
290 }
261 // pub fn render_filter(
262 // framework: &mut Framework,
263 // terminal: &mut Terminal<CrosstermBackend<Stdout>>,
264 // filter: impl Fn(&Box<dyn FrameworkItem>) -> bool,
265 // ) -> Result<(), Box<dyn Error>> {
266 // Self::render_filter_with_frame(framework, &mut terminal.get_frame(), filter);
267 // terminal.flush()?;
268 // Ok(())
269 // }
270 //
271 // pub fn render_filter_with_frame(
272 // framework: &mut Framework,
273 // frame: &mut Frame<CrosstermBackend<Stdout>>,
274 // filter: impl Fn(&Box<dyn FrameworkItem>) -> bool,
275 // ) {
276 // let area = frame.size();
277 //
278 // framework
279 // .data
280 // .global
281 // .get_mut::<Status>()
282 // .unwrap()
283 // .prev_frame = Some(area);
284 //
285 // if Self::protective_screen(framework, frame) {
286 // return;
287 // }
288 //
289 // framework.render_filter(frame, filter);
290 // }
291291
292292 /// this function renders onto the given frame
293293 pub fn protective_screen(
src/items/messagebar.rs +71 −68
@@ -1,13 +1,12 @@
1use crate::{
2 config::*,
3 global::{functions::secs_display_string, structs::*},
4};
1#[cfg(feature = "mpv")]
2use crate::global::functions::secs_display_string;
3use crate::{config::*, global::structs::*};
54use ratatui::{
65 layout::Rect,
76 style::Style,
87 widgets::{Block, Borders, Paragraph},
98};
10use tui_additions::framework::{FrameworkClean, FrameworkItem};
9use tui_additions::framework::*;
1110
1211/// a message bar item, contains no fields because the message is taken from `data.global.Message`
1312#[derive(Clone, Copy, Default)]
@@ -26,72 +25,75 @@ impl FrameworkItem for MessageBar {
2625 return;
2726 }
2827
29 let mpv = framework.data.global.get::<MpvWrapper>().unwrap();
30 if Self::is_mpv_render(framework) {
31 let mut label = mpv.property("media-title".to_string()).unwrap();
32 if let Some((name, ext)) = label.rsplit_once('.') {
33 if ext.len() < 5
34 && !name.len() > 13
35 && &name[name.len() - 1..name.len()] == "]"
36 && name[name.len() - 12..name.len() - 1]
37 .chars()
38 .all(|c| c.is_ascii_alphanumeric() || matches!(c, '-' | '_'))
39 && &name[name.len() - 13..name.len() - 12] == "["
40 {
41 label = name[0..name.len() - 13].to_string();
28 #[cfg(feature = "mpv")]
29 {
30 let mpv = framework.data.global.get::<MpvWrapper>().unwrap();
31 if Self::is_mpv_render(framework) {
32 let mut label = mpv.property("media-title".to_string()).unwrap();
33 if let Some((name, ext)) = label.rsplit_once('.') {
34 if ext.len() < 5
35 && !name.len() > 13
36 && &name[name.len() - 1..name.len()] == "]"
37 && name[name.len() - 12..name.len() - 1]
38 .chars()
39 .all(|c| c.is_ascii_alphanumeric() || matches!(c, '-' | '_'))
40 && &name[name.len() - 13..name.len() - 12] == "["
41 {
42 label = name[0..name.len() - 13].to_string();
43 }
4244 }
43 }
44 let duration = mpv
45 .property("duration".to_string())
46 .unwrap_or_default()
47 .parse::<f64>()
48 .unwrap() as u64;
49 let duration_s = secs_display_string(duration as u32);
50 let playerhead = mpv
51 .property("time-pos".to_string())
52 .unwrap_or_default()
53 .parse::<f64>()
54 .unwrap() as u64;
55 let mut playerhead_s = secs_display_string(playerhead as u32);
56 if playerhead_s.len() != duration_s.len() {
57 playerhead_s = format!(
58 "{}{playerhead_s}",
59 " ".repeat(duration_s.len() - playerhead_s.len())
60 );
61 }
62 let percentage = (playerhead * 100 / duration).to_string();
45 let duration = mpv
46 .property("duration".to_string())
47 .unwrap_or_default()
48 .parse::<f64>()
49 .unwrap() as u64;
50 let duration_s = secs_display_string(duration as u32);
51 let playerhead = mpv
52 .property("time-pos".to_string())
53 .unwrap_or_default()
54 .parse::<f64>()
55 .unwrap() as u64;
56 let mut playerhead_s = secs_display_string(playerhead as u32);
57 if playerhead_s.len() != duration_s.len() {
58 playerhead_s = format!(
59 "{}{playerhead_s}",
60 " ".repeat(duration_s.len() - playerhead_s.len())
61 );
62 }
63 let percentage = (playerhead * 100 / duration).to_string();
6364
64 let right_chunk = format!(
65 "{playerhead_s}/{duration_s} {}[{percentage}%]",
66 " ".repeat(3 - percentage.len())
67 );
68 let left_chunk = format!("[Now Playing]: {label}");
69 let length = area.width as usize - 2;
70 let total_len = right_chunk.len() + left_chunk.len();
65 let right_chunk = format!(
66 "{playerhead_s}/{duration_s} {}[{percentage}%]",
67 " ".repeat(3 - percentage.len())
68 );
69 let left_chunk = format!("[Now Playing]: {label}");
70 let length = area.width as usize - 2;
71 let total_len = right_chunk.len() + left_chunk.len();
7172
72 *framework.data.global.get_mut::<Message>().unwrap() =
73 Message::Mpv(if length > total_len + 6 {
74 let mut seeker_len = length - total_len - 4;
75 let seeker_pad = if seeker_len > 10 { seeker_len / 10 } else { 0 };
76 seeker_len -= seeker_pad * 2;
77 let seeker_pos = (seeker_len - 1) * playerhead as usize / duration as usize;
78 format!(
79 "{left_chunk} {}├{}-{}┤{} {right_chunk}",
80 " ".repeat(seeker_pad),
81 "─".repeat(seeker_pos),
82 "─".repeat(seeker_len - seeker_pos - 1),
83 " ".repeat(seeker_pad)
84 )
85 } else if length > total_len + 3 {
86 format!(
87 "{left_chunk}{}{right_chunk}",
88 " ".repeat(length - total_len)
89 )
90 } else if length > 19 {
91 left_chunk
92 } else {
93 String::from("Not enough width")
94 });
73 *framework.data.global.get_mut::<Message>().unwrap() =
74 Message::Mpv(if length > total_len + 6 {
75 let mut seeker_len = length - total_len - 4;
76 let seeker_pad = if seeker_len > 10 { seeker_len / 10 } else { 0 };
77 seeker_len -= seeker_pad * 2;
78 let seeker_pos = (seeker_len - 1) * playerhead as usize / duration as usize;
79 format!(
80 "{left_chunk} {}├{}-{}┤{} {right_chunk}",
81 " ".repeat(seeker_pad),
82 "─".repeat(seeker_pos),
83 "─".repeat(seeker_len - seeker_pos - 1),
84 " ".repeat(seeker_pad)
85 )
86 } else if length > total_len + 3 {
87 format!(
88 "{left_chunk}{}{right_chunk}",
89 " ".repeat(length - total_len)
90 )
91 } else if length > 19 {
92 left_chunk
93 } else {
94 String::from("Not enough width")
95 });
96 }
9597 }
9698
9799 let message = framework.data.global.get::<Message>().unwrap();
@@ -156,6 +158,7 @@ impl FrameworkItem for MessageBar {
156158 }
157159}
158160
161#[cfg(feature = "mpv")]
159162impl MessageBar {
160163 pub fn is_mpv_render(framework: &FrameworkClean) -> bool {
161164 framework.data.global.get::<MpvWrapper>().unwrap().playing()
src/run.rs +7 −7
@@ -1,17 +1,14 @@
11use crossterm::event::{self, Event, MouseButton, MouseEventKind};
22use ratatui::{backend::CrosstermBackend, Terminal};
3use std::{
4 any::TypeId,
5 error::Error,
6 io::Stdout,
7 time::{Duration, Instant},
8};
3#[cfg(feature = "mpv")]
4use std::time::{Duration, Instant};
5use std::{any::TypeId, error::Error, io::Stdout};
96use tui_additions::framework::Framework;
107
118use crate::{
129 config::*,
1310 global::{functions::*, structs::*},
14 items::{MessageBar, SearchFilter},
11 items::*,
1512};
1613
1714/// the main event loop of the program
@@ -19,7 +16,9 @@ pub fn run(
1916 terminal: &mut Terminal<CrosstermBackend<Stdout>>,
2017 framework: &mut Framework,
2118) -> Result<(), Box<dyn Error>> {
19 #[cfg(feature = "mpv")]
2220 let tick_rate = Duration::from_secs(1);
21 #[cfg(feature = "mpv")]
2322 let mut last_tick = Instant::now();
2423 loop {
2524 // repeat forever until all tasks are ran (and Tasks is cleared)
@@ -41,6 +40,7 @@ pub fn run(
4140 break;
4241 }
4342
43 #[cfg(feature = "mpv")]
4444 if !event::poll(
4545 tick_rate
4646 .checked_sub(last_tick.elapsed())