Commit 54a1ffb572
Unsigned
Layout: unified · split
README.md +5 −5
| @@ -14,10 +14,6 @@ Written in Rust, the **YouTube TUI** is a lightweight and user friendly TUI for | |||
| 14 | 14 | ||
| 15 | It is like an *app launcher*, it launches other programs to do the heavy lifting (for example, `mpv` for playing videos). | 15 | It is like an *app launcher*, it launches other programs to do the heavy lifting (for example, `mpv` for playing videos). |
| 16 | 16 | ||
| 17 | > ### Mouse support | ||
| 18 | > | ||
| 19 | > Mouse support completely implemented, currently writing docs. | ||
| 20 | |||
| 21 | ## Customisable | 17 | ## Customisable |
| 22 | 18 | ||
| 23 | The YouTube TUI can be customised through config files, they are located in `~/.config/youtube-tui` and are in the YAML format. | 19 | The YouTube TUI can be customised through config files, they are located in `~/.config/youtube-tui` and are in the YAML format. |
| @@ -58,9 +54,13 @@ The YouTube TUI allows you to browse YouTube with (almost) all of it's features, | |||
| 58 | - Use search filters to sort and filter search results | 54 | - Use search filters to sort and filter search results |
| 59 | - Save browsing history | 55 | - Save browsing history |
| 60 | 56 | ||
| 57 | It also includes features like: | ||
| 58 | |||
| 59 | - Vim-like commands | ||
| 60 | - Mouse support | ||
| 61 | |||
| 61 | ### What it doesn't have | 62 | ### What it doesn't have |
| 62 | 63 | ||
| 63 | - Vim-like commands (first priority) | ||
| 64 | - Command line args (first priority) | 64 | - Command line args (first priority) |
| 65 | - Bootleg Vimscript? (will implement) | 65 | - Bootleg Vimscript? (will implement) |
| 66 | - Channel search (will implement) | 66 | - Channel search (will implement) |
docs/src/README.md +5 −1
| @@ -46,9 +46,13 @@ The YouTube TUI allows you to browse YouTube with (almost) all of it's features, | |||
| 46 | - Use search filters to sort and filter search results | 46 | - Use search filters to sort and filter search results |
| 47 | - Save browsing history | 47 | - Save browsing history |
| 48 | 48 | ||
| 49 | It also includes features like: | ||
| 50 | |||
| 51 | - Vim-like commands | ||
| 52 | - Mouse support | ||
| 53 | |||
| 49 | ### What it doesn't have | 54 | ### What it doesn't have |
| 50 | 55 | ||
| 51 | - Vim-like commands (first priority) | ||
| 52 | - Command line args (first priority) | 56 | - Command line args (first priority) |
| 53 | - Bootleg Vimscript? (will implement) | 57 | - Bootleg Vimscript? (will implement) |
| 54 | - Channel search (will implement) | 58 | - Channel search (will implement) |
docs/src/SUMMARY.md +3 −2
| @@ -3,6 +3,7 @@ | |||
| 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 | - [Commands](commands.md) | ||
| 6 | 7 | ||
| 7 | # Customisation guide | 8 | # Customisation guide |
| 8 | 9 | ||
| @@ -16,8 +17,8 @@ | |||
| 16 | 17 | ||
| 17 | # Contributing | 18 | # Contributing |
| 18 | 19 | ||
| 19 | - [How it works]() | 20 | - [How it works](how_it_works.md) |
| 20 | - [Framework]() | 21 | - [Framework](framework.md) |
| 21 | - [Invidious API]() | 22 | - [Invidious API]() |
| 22 | - [Individual items]() | 23 | - [Individual items]() |
| 23 | 24 | ||
docs/src/basic_usage.md +23
| @@ -23,6 +23,8 @@ The item with the cursor hovering will have a <u>red outline</u>. | |||
| 23 | |Previous page|Backspace / Alt + Left arrow| | 23 | |Previous page|Backspace / Alt + Left arrow| |
| 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`| | ||
| 27 | |Enter command mode|`:`| | ||
| 26 | |Quit|`q`| | 28 | |Quit|`q`| |
| 27 | 29 | ||
| 28 | ## Selection | 30 | ## Selection |
| @@ -53,6 +55,27 @@ The playlist page allows two different view modes, the first of which is *comman | |||
| 53 | 55 | ||
| 54 | The other one is *videos view*, which allows you to look at each videos in the playlist individually. | 56 | The other one is *videos view*, which allows you to look at each videos in the playlist individually. |
| 55 | 57 | ||
| 58 | ## Command mode | ||
| 59 | |||
| 60 | Command mode is like that of Vim, it can be started by pressing `:` when nothing is selected. | ||
| 61 | |||
| 62 | More about commands in the [next chapter](commands.md). | ||
| 63 | |||
| 56 | ## Buttons | 64 | ## Buttons |
| 57 | 65 | ||
| 58 | Buttons have no use on their own, but allows you to navigate between pages. | 66 | Buttons have no use on their own, but allows you to navigate between pages. |
| 67 | |||
| 68 | ## Mouse click control | ||
| 69 | |||
| 70 |  | ||
| 71 | |||
| 72 | Mouse click controls has been added, you can now use your mouse to navigate around the TUI. Here are the general rules: | ||
| 73 | |||
| 74 | 1. Clicking an item *moves the cursor* to that item, clicking again *selects* the item | ||
| 75 | 2. Clicking on buttons, or items on a list has the same effect as pressing `Enter` on them | ||
| 76 | 3. Clicking outside a popup closes the popup | ||
| 77 | |||
| 78 | However, there are some downsides to not using your keyboard. | ||
| 79 | |||
| 80 | 1. Cannot move up or down to items not on screen in a list (you can do that with `Up` or `Down arrow`) | ||
| 81 | 2. Cannot access function keys like `Backspace` or `Q` | ||
docs/src/changelogs.md +10
| @@ -1,5 +1,15 @@ | |||
| 1 | # Changelogs | 1 | # Changelogs |
| 2 | 2 | ||
| 3 | ## v0.6.0 | ||
| 4 | |||
| 5 | ### Added | ||
| 6 | |||
| 7 | - Mouse support | ||
| 8 | - Vim-like commands | ||
| 9 | - Pasting with `Ctrl + V` in search bar and command mode | ||
| 10 | |||
| 11 | <hr> | ||
| 12 | |||
| 3 | ## v0.5.3 | 13 | ## v0.5.3 |
| 4 | 14 | ||
| 5 | #### Fixed | 15 | #### Fixed |
docs/src/commands.md added +41
| @@ -0,0 +1,41 @@ | |||
| 1 | # Commands | ||
| 2 | |||
| 3 | Commands 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. | ||
| 4 | |||
| 5 | Below are the avaliable commands: | ||
| 6 | |||
| 7 | ## Loadpage | ||
| 8 | |||
| 9 | `loadpage` can be used to load a specific page. | ||
| 10 | |||
| 11 | ```vim | ||
| 12 | :loadpage popular (alt: `popular`) | ||
| 13 | :loadpage trending (alt: `trending`) | ||
| 14 | :loadpage watchhistory (alt: `watchhistory`) | ||
| 15 | :loadpage search [search query] (alt: `search [search query]`) | ||
| 16 | :loadpage video [id or url] (alt: `video [id or url]`) | ||
| 17 | :loadpage playlist [id or url] (alt: `playlist [id or url] `) | ||
| 18 | :loadpage channel [id or url] (alt: `channel [id or url] `) | ||
| 19 | ``` | ||
| 20 | |||
| 21 | ## History | ||
| 22 | |||
| 23 | `history` is used to manage page history (`Backspace` equivalent). | ||
| 24 | |||
| 25 | ```vim | ||
| 26 | :history back (alt: `back`) | ||
| 27 | :history clear | ||
| 28 | ``` | ||
| 29 | |||
| 30 | ## Utility | ||
| 31 | |||
| 32 | ```vim | ||
| 33 | :reload (alt `r`) | ||
| 34 | :reload configs (alt `reload/r config/configs`) | ||
| 35 | :flush | ||
| 36 | :quit (alt `q`, `exit`, `x`) | ||
| 37 | ``` | ||
| 38 | |||
| 39 | > The `flush` command is used to run all tasks in queue immediately, this is usually done automatically. | ||
| 40 | > | ||
| 41 | > But for when tasks are stacked up in the *same* event loop and the order of which they are executed matters, this command can be used to force the already stacked up commands to be ran first. | ||
docs/src/config/commands.md +8 −1
| @@ -8,17 +8,22 @@ The commands config file decides what options (that will run a certain command o | |||
| 8 | video: | 8 | video: |
| 9 | - Play video: ${video-player} ${embed-url} | 9 | - Play video: ${video-player} ${embed-url} |
| 10 | - Play audio: ${terminal-emulator} ${video-player} ${embed-url} --no-video | 10 | - Play audio: ${terminal-emulator} ${video-player} ${embed-url} --no-video |
| 11 | - Play audio (loop): ${terminal-emulator} ${video-player} ${embed-url} --no-video --loop-file=inf | ||
| 12 | - View channel: :channel ${channel_id} | ||
| 11 | - Open in browser: ${browser} ${url} | 13 | - Open in browser: ${browser} ${url} |
| 12 | - Download video (webm): ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${embed-url} | 14 | - Download video (webm): ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${embed-url} |
| 15 | - Download audio (opus): ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${embed-url} -x | ||
| 13 | - 'Mode: ${provider}': '%switch-provider%' | 16 | - 'Mode: ${provider}': '%switch-provider%' |
| 14 | |||
| 15 | playlist: | 17 | playlist: |
| 16 | - Switch view: '%switch-view%' | 18 | - Switch view: '%switch-view%' |
| 17 | - Play all videos: ${video-player} ${all-videos} | 19 | - Play all videos: ${video-player} ${all-videos} |
| 18 | - Play all audio: ${terminal-emulator} ${video-player} ${all-videos} --no-video | 20 | - 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 | 21 | - Shuffle play all audio: ${terminal-emulator} ${video-player} ${all-videos} --no-video --shuffle |
| 22 | - Shuffle play all audio (loop): ${terminal-emulator} ${video-player} ${all-videos} --no-video --shuffle --loop-playlist=inf | ||
| 23 | - View channel: :channel ${channel_id} | ||
| 20 | - Open in browser: ${browser} ${url} | 24 | - Open in browser: ${browser} ${url} |
| 21 | - Download all video (webm): ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${all-videos} | 25 | - Download all video (webm): ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${all-videos} |
| 26 | - Download all audio (opus): ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${all-videos} -x | ||
| 22 | - 'Mode: ${provider}': '%switch-provider%' | 27 | - 'Mode: ${provider}': '%switch-provider%' |
| 23 | ``` | 28 | ``` |
| 24 | 29 | ||
| @@ -46,6 +51,8 @@ playlist: | |||
| 46 | - 'Mode: ${provider}': '%switch-provider%' | 51 | - 'Mode: ${provider}': '%switch-provider%' |
| 47 | ``` | 52 | ``` |
| 48 | 53 | ||
| 54 | > Global commands can also be used here. (Ones that start with an `:`). | ||
| 55 | |||
| 49 | ## Item commands | 56 | ## Item commands |
| 50 | 57 | ||
| 51 | (will be replaced by global vim-like commands in the next major version) | 58 | (will be replaced by global vim-like commands in the next major version) |
docs/src/config/main.md +7
| @@ -5,6 +5,7 @@ The main config file is located in `~/.config/youtube-tui/main.yml`. | |||
| 5 | ## Example main.yml | 5 | ## Example main.yml |
| 6 | 6 | ||
| 7 | ```yaml | 7 | ```yaml |
| 8 | mouse_support: true | ||
| 8 | invidious_instance: https://vid.puffyan.us | 9 | invidious_instance: https://vid.puffyan.us |
| 9 | max_watch_history: 50 | 10 | max_watch_history: 50 |
| 10 | allow_unicode: false | 11 | allow_unicode: false |
| @@ -24,6 +25,12 @@ env: | |||
| 24 | 25 | ||
| 25 | Below are the description of each of the fields: | 26 | Below are the description of each of the fields: |
| 26 | 27 | ||
| 28 | ### mouse_support | ||
| 29 | |||
| 30 | Whether mouse click events are supports, if `false` then mouse will not do anything to the program. | ||
| 31 | |||
| 32 | *Accept: `true`/`false`* | ||
| 33 | |||
| 27 | ### invidious_instance | 34 | ### invidious_instance |
| 28 | 35 | ||
| 29 | The Invidious instance you want to use, a full list of Invidious instances can be found here <a href="https://api.invidious.io" target=_blank>*here*</a>. | 36 | The Invidious instance you want to use, a full list of Invidious instances can be found here <a href="https://api.invidious.io" target=_blank>*here*</a>. |
docs/src/framework.md added +20
| @@ -0,0 +1,20 @@ | |||
| 1 | # Framework | ||
| 2 | |||
| 3 | At the core of this TUI, is the framework from the <a href="https://crates.io/crates/tui-additions" target=_blank>`tui-additions`</a> crate, it allows the program to *render* onto the screen, *take inputs* (mouse and keyboard) in an orderly fashion. | ||
| 4 | |||
| 5 | ## Items | ||
| 6 | |||
| 7 | Items are placed across the screen *in rows*, each item is <u>individual</u> and changing of one should not affect others in anyway. | ||
| 8 | |||
| 9 | Each item has a set of funcitons (from the trait `FrameworkItem`), or handlers. | ||
| 10 | |||
| 11 | |Function|Return type|Purpose| | ||
| 12 | |---|---|---| | ||
| 13 | |`selectable`|Boolean|Check if the item can be selected, and should the user be able to hover the cursor over the item.<br><br>(E.g. Message bar is not selectable)| | ||
| 14 | |`render`|None|The item renders itself within a given area of the screen.| | ||
| 15 | |`key_event`|Result|The item handles the keyboard input when it is selected, if an `Err(_)` is returned then the error will be displayed in the message bar.| | ||
| 16 | |`mouse_event`|Boolean|The selected item handles the mouse click event when being clicked on.| | ||
| 17 | |||
| 18 | Todo... | ||
| 19 | |||
| 20 |  | ||
docs/src/how_it_works.md added +10
| @@ -0,0 +1,10 @@ | |||
| 1 | # How it works | ||
| 2 | |||
| 3 | This sections talks about roughly how this TUI works, *crates*, *important structs* and their location, and the *main event loop* will be mentioned. | ||
| 4 | |||
| 5 | ## Table of contents | ||
| 6 | |||
| 7 | - [Framework](framework.md) talks about how a *single frame* is rendered, and how a *single input* is handled. | ||
| 8 | - [Invidious]() talks about how information from YouTube is retrieved. | ||
| 9 | - [Important struct]() talks about how variables are stored across the program. | ||
| 10 | - [The main event loop]() talks about how different parts of the program are chained together to function as is. | ||
docs/src/images/mouse-showcase.png added
Binary file not shown.
docs/src/images/rows.svg added +20
| @@ -0,0 +1,20 @@ | |||
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <!-- Created with Inkscape (http://www.inkscape.org/) --> | ||
| 3 | <svg width="800" height="600" version="1.1" viewBox="0 0 211.67 158.75" xmlns="http://www.w3.org/2000/svg"> | ||
| 4 | <g transform="matrix(.85817 0 0 .61208 29.598 27.242)" fill-opacity="0" stroke="#fff" stroke-width="4.7459"> | ||
| 5 | <rect x="20.096" y="21.934" width="36.446" height="18.468" ry="9.2342"/> | ||
| 6 | <rect x="71.8" y="21.934" width="36.446" height="18.468" ry="9.2342"/> | ||
| 7 | <rect x="123.5" y="21.934" width="36.446" height="18.468" ry="9.2342"/> | ||
| 8 | </g> | ||
| 9 | <g fill-opacity="0" stroke="#fff" stroke-width="3.4396"> | ||
| 10 | <rect x="14.26" y="12.88" width="185.19" height="16.665" ry="8.1169"/> | ||
| 11 | <rect x="14.26" y="128.64" width="185.19" height="16.665" ry="7.638"/> | ||
| 12 | <rect x="14.816" y="60.78" width="184.07" height="57.458" ry="8.996"/> | ||
| 13 | </g> | ||
| 14 | <g stroke-width="0"> | ||
| 15 | <rect x="5.0988e-7" y="35.719" width="211.67" height="21.167" ry="0" fill="#ffca00" fill-opacity=".3"/> | ||
| 16 | <rect x="5e-7" y="5e-7" width="211.67" height="35.719" ry="0" fill="#f00" fill-opacity=".3"/> | ||
| 17 | <rect x="7.0082e-7" y="56.885" width="211.67" height="66.146" ry="0" fill="#00ff38" fill-opacity=".3"/> | ||
| 18 | <rect x="3.9584e-7" y="123.03" width="211.67" height="35.719" ry="0" fill="#00a1ff" fill-opacity=".3"/> | ||
| 19 | </g> | ||
| 20 | </svg> | ||
index.html deleted −250
| @@ -1,250 +0,0 @@ | |||
| 1 | <!DOCTYPE HTML> | ||
| 2 | <html lang="en" class="sidebar-visible no-js ayu"> | ||
| 3 | <head> | ||
| 4 | <!-- Book generated using mdBook --> | ||
| 5 | <meta charset="UTF-8"> | ||
| 6 | <title>Overview - YouTube TUI User Manual</title> | ||
| 7 | <!-- Custom HTML head --> | ||
| 8 | <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> | ||
| 9 | <meta name="description" content="The user manual, documentation and contribution guide for YouTube TUI"> | ||
| 10 | <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
| 11 | <meta name="theme-color" content="#ffffff" /> | ||
| 12 | |||
| 13 | <link rel="icon" href="favicon.svg"> | ||
| 14 | <link rel="shortcut icon" href="favicon.png"> | ||
| 15 | <link rel="stylesheet" href="css/variables.css"> | ||
| 16 | <link rel="stylesheet" href="css/general.css"> | ||
| 17 | <link rel="stylesheet" href="css/chrome.css"> | ||
| 18 | <link rel="stylesheet" href="css/print.css" media="print"> | ||
| 19 | <!-- Fonts --> | ||
| 20 | <link rel="stylesheet" href="FontAwesome/css/font-awesome.css"> | ||
| 21 | <link rel="stylesheet" href="fonts/fonts.css"> | ||
| 22 | <!-- Highlight.js Stylesheets --> | ||
| 23 | <link rel="stylesheet" href="highlight.css"> | ||
| 24 | <link rel="stylesheet" href="tomorrow-night.css"> | ||
| 25 | <link rel="stylesheet" href="ayu-highlight.css"> | ||
| 26 | |||
| 27 | <!-- Custom theme stylesheets --> | ||
| 28 | </head> | ||
| 29 | <body> | ||
| 30 | <!-- Provide site root to javascript --> | ||
| 31 | <script type="text/javascript"> | ||
| 32 | var path_to_root = ""; | ||
| 33 | var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "ayu"; | ||
| 34 | </script> | ||
| 35 | |||
| 36 | <!-- Work around some values being stored in localStorage wrapped in quotes --> | ||
| 37 | <script type="text/javascript"> | ||
| 38 | try { | ||
| 39 | var theme = localStorage.getItem('mdbook-theme'); | ||
| 40 | var sidebar = localStorage.getItem('mdbook-sidebar'); | ||
| 41 | |||
| 42 | if (theme.startsWith('"') && theme.endsWith('"')) { | ||
| 43 | localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1)); | ||
| 44 | } | ||
| 45 | |||
| 46 | if (sidebar.startsWith('"') && sidebar.endsWith('"')) { | ||
| 47 | localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1)); | ||
| 48 | } | ||
| 49 | } catch (e) { } | ||
| 50 | </script> | ||
| 51 | |||
| 52 | <!-- Set the theme before any content is loaded, prevents flash --> | ||
| 53 | <script type="text/javascript"> | ||
| 54 | var theme; | ||
| 55 | try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { } | ||
| 56 | if (theme === null || theme === undefined) { theme = default_theme; } | ||
| 57 | var html = document.querySelector('html'); | ||
| 58 | html.classList.remove('no-js') | ||
| 59 | html.classList.remove('ayu') | ||
| 60 | html.classList.add(theme); | ||
| 61 | html.classList.add('js'); | ||
| 62 | </script> | ||
| 63 | |||
| 64 | <!-- Hide / unhide sidebar before it is displayed --> | ||
| 65 | <script type="text/javascript"> | ||
| 66 | var html = document.querySelector('html'); | ||
| 67 | var sidebar = 'hidden'; | ||
| 68 | if (document.body.clientWidth >= 1080) { | ||
| 69 | try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { } | ||
| 70 | sidebar = sidebar || 'visible'; | ||
| 71 | } | ||
| 72 | html.classList.remove('sidebar-visible'); | ||
| 73 | html.classList.add("sidebar-" + sidebar); | ||
| 74 | </script> | ||
| 75 | |||
| 76 | <nav id="sidebar" class="sidebar" aria-label="Table of contents"> | ||
| 77 | <div class="sidebar-scrollbox"> | ||
| 78 | <ol class="chapter"><li class="chapter-item expanded "><a href="../../index.html" class="active"><strong aria-hidden="true">1.</strong> Overview</a></li><li class="chapter-item expanded "><a href="installation.html"><strong aria-hidden="true">2.</strong> Installation</a></li><li class="chapter-item expanded "><a href="basic_usage.html"><strong aria-hidden="true">3.</strong> Basic usage</a></li><li class="chapter-item expanded affix "><li class="part-title">Customisation guide</li><li class="chapter-item expanded "><a href="config/index.html"><strong aria-hidden="true">4.</strong> Config files</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="config/main.html"><strong aria-hidden="true">4.1.</strong> main</a></li><li class="chapter-item expanded "><a href="config/commands.html"><strong aria-hidden="true">4.2.</strong> commands</a></li><li class="chapter-item expanded "><a href="config/keybindings.html"><strong aria-hidden="true">4.3.</strong> keybindings</a></li><li class="chapter-item expanded "><a href="config/pages.html"><strong aria-hidden="true">4.4.</strong> pages</a></li><li class="chapter-item expanded "><a href="config/appearance.html"><strong aria-hidden="true">4.5.</strong> appearance</a></li><li class="chapter-item expanded "><a href="config/search.html"><strong aria-hidden="true">4.6.</strong> search</a></li></ol></li><li class="chapter-item expanded "><li class="part-title">Contributing</li><li class="chapter-item expanded "><div><strong aria-hidden="true">5.</strong> How it works</div></li><li><ol class="section"><li class="chapter-item expanded "><div><strong aria-hidden="true">5.1.</strong> Framework</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">5.2.</strong> Invidious API</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">5.3.</strong> Individual items</div></li></ol></li><li class="chapter-item expanded "><div><strong aria-hidden="true">6.</strong> Contribution guide</div></li><li class="chapter-item expanded "><a href="changelogs.html"><strong aria-hidden="true">7.</strong> Changelogs</a></li><li class="chapter-item expanded "><a href="contributors.html"><strong aria-hidden="true">8.</strong> Contributors</a></li></ol> | ||
| 79 | </div> | ||
| 80 | <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div> | ||
| 81 | </nav> | ||
| 82 | |||
| 83 | <div id="page-wrapper" class="page-wrapper"> | ||
| 84 | |||
| 85 | <div class="page"> | ||
| 86 | <div id="menu-bar-hover-placeholder"></div> | ||
| 87 | <div id="menu-bar" class="menu-bar sticky bordered"> | ||
| 88 | <div class="left-buttons"> | ||
| 89 | <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar"> | ||
| 90 | <i class="fa fa-bars"></i> | ||
| 91 | </button> | ||
| 92 | <button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list"> | ||
| 93 | <i class="fa fa-paint-brush"></i> | ||
| 94 | </button> | ||
| 95 | <ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu"> | ||
| 96 | <li role="none"><button role="menuitem" class="theme" id="light">Light</button></li> | ||
| 97 | <li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li> | ||
| 98 | <li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li> | ||
| 99 | <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li> | ||
| 100 | <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu (default)</button></li> | ||
| 101 | </ul> | ||
| 102 | <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar"> | ||
| 103 | <i class="fa fa-search"></i> | ||
| 104 | </button> | ||
| 105 | </div> | ||
| 106 | |||
| 107 | <h1 class="menu-title">YouTube TUI User Manual</h1> | ||
| 108 | |||
| 109 | <div class="right-buttons"> | ||
| 110 | <a href="print.html" title="Print this book" aria-label="Print this book"> | ||
| 111 | <i id="print-button" class="fa fa-print"></i> | ||
| 112 | </a> | ||
| 113 | <a href="https://github.com/siriusmart/youtube-tui/tree/master/docs" title="Git repository" aria-label="Git repository"> | ||
| 114 | <i id="git-repository-button" class="fa fa-github"></i> | ||
| 115 | </a> | ||
| 116 | <a href="https://github.com/siriusmart/youtube-tui/edit/master/docs/src/../../README.md" title="Suggest an edit" aria-label="Suggest an edit"> | ||
| 117 | <i id="git-edit-button" class="fa fa-edit"></i> | ||
| 118 | </a> | ||
| 119 | </div> | ||
| 120 | </div> | ||
| 121 | |||
| 122 | <div id="search-wrapper" class="hidden"> | ||
| 123 | <form id="searchbar-outer" class="searchbar-outer"> | ||
| 124 | <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header"> | ||
| 125 | </form> | ||
| 126 | <div id="searchresults-outer" class="searchresults-outer hidden"> | ||
| 127 | <div id="searchresults-header" class="searchresults-header"></div> | ||
| 128 | <ul id="searchresults"> | ||
| 129 | </ul> | ||
| 130 | </div> | ||
| 131 | </div> | ||
| 132 | <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM --> | ||
| 133 | <script type="text/javascript"> | ||
| 134 | document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible'); | ||
| 135 | document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible'); | ||
| 136 | Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) { | ||
| 137 | link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1); | ||
| 138 | }); | ||
| 139 | </script> | ||
| 140 | |||
| 141 | <div id="content" class="content"> | ||
| 142 | <main> | ||
| 143 | <p><img src="https://img.shields.io/github/languages/top/siriusmart/youtube-tui?label=rust" alt="" /> | ||
| 144 | <img src="https://shields.io/github/license/siriusmart/youtube-tui" alt="" /> | ||
| 145 | <a href="https://crates.io/crates/youtube-tui"><img src="https://img.shields.io/crates/d/youtube-tui?label=crates.io%20downloads" alt="" /></a> | ||
| 146 | <a href="https://crates.io/crates/youtube-tui"><img src="https://img.shields.io/crates/v/youtube-tui?label=crates.io%20version" alt="" /></a> | ||
| 147 | <img src="https://shields.io/github/stars/siriusmart/youtube-tui?style=social" alt="" /></p> | ||
| 148 | <p><em><strong>Read more in the <a href="https://siriusmart.github.io/youtube-tui">user manual</a> (including installation gude and documentation).</strong></em></p> | ||
| 149 | <h1 id="overview"><a class="header" href="#overview">Overview</a></h1> | ||
| 150 | <p>Written in Rust, the <strong>YouTube TUI</strong> is a lightweight and user friendly TUI for browsing YouTube content from the terminal.</p> | ||
| 151 | <p><img src="./docs/src/images/search-showcase.png" alt="" /></p> | ||
| 152 | <p>It is like an <em>app launcher</em>, it launches other programs to do the heavy lifting (for example, <code>mpv</code> for playing videos).</p> | ||
| 153 | <h2 id="customisable"><a class="header" href="#customisable">Customisable</a></h2> | ||
| 154 | <p>The YouTube TUI can be customised through config files, they are located in <code>~/.config/youtube-tui</code> and are in the YAML format.</p> | ||
| 155 | <p>Here's an example of the config file:</p> | ||
| 156 | <pre><code class="language-yaml">invidious_instance: https://vid.puffyan.us | ||
| 157 | max_watch_history: 50 | ||
| 158 | allow_unicode: false | ||
| 159 | images: Sixels | ||
| 160 | refresh_after_modifying_search_filters: true | ||
| 161 | provider: YouTube | ||
| 162 | env: | ||
| 163 | browser: firefox | ||
| 164 | video-player: mpv | ||
| 165 | youtube-downloader: yt-dlp | ||
| 166 | terminal-emulator: konsole -e | ||
| 167 | |||
| 168 | </code></pre> | ||
| 169 | <p>Anything from layouts to colours and keybindings can be customised, more on that later.</p> | ||
| 170 | <h2 id="dependency-free"><a class="header" href="#dependency-free">Dependency-free</a></h2> | ||
| 171 | <p>The YouTube TUI does not work on its own, it is instead like a <em>TUI frontend</em> for programs like <code>mpv</code> or <code>yt-dlp</code>/<code>youtube-dl</code>.</p> | ||
| 172 | <p>However, the programs to launch can be changed, and therefore the YouTube TUI <u>does not rely on any specific dependencies</u> to run.</p> | ||
| 173 | <p><img src="./images/custom-dependencies-showcase.png" alt="" /></p> | ||
| 174 | <h2 id="powerful"><a class="header" href="#powerful">Powerful</a></h2> | ||
| 175 | <p>The YouTube TUI allows you to browse YouTube with (almost) all of it's features, functions including:</p> | ||
| 176 | <ul> | ||
| 177 | <li>View popular/trending videos</li> | ||
| 178 | <li>View information about channels, playlists and videos</li> | ||
| 179 | <li>Use search filters to sort and filter search results</li> | ||
| 180 | <li>Save browsing history</li> | ||
| 181 | </ul> | ||
| 182 | <h3 id="what-it-doesnt-have"><a class="header" href="#what-it-doesnt-have">What it doesn't have</a></h3> | ||
| 183 | <ul> | ||
| 184 | <li>Vim-like commands (first priority)</li> | ||
| 185 | <li>Command line args (first priority)</li> | ||
| 186 | <li>Bootleg Vimscript? (will implement)</li> | ||
| 187 | <li>Channel search (will implement)</li> | ||
| 188 | <li>Channel videos sorting (will implement)</li> | ||
| 189 | <li>Subscriptions (will implement)</li> | ||
| 190 | <li>Recommendations/comments (probably will not implement)</li> | ||
| 191 | </ul> | ||
| 192 | <h2 id="how-to-contribute"><a class="header" href="#how-to-contribute">How to contribute</a></h2> | ||
| 193 | <p>You will need a <u>general knowledge</u> of the Rust programming language, and the ability to <em>understand my spaghetti</em>.</p> | ||
| 194 | <ol> | ||
| 195 | <li>Open an issue to make sure nobody else is working on the same feature</li> | ||
| 196 | <li>Write code</li> | ||
| 197 | <li>Open a pull request</li> | ||
| 198 | <li>Get merged?</li> | ||
| 199 | </ol> | ||
| 200 | <p>Or just <em>fix that typo in README</em> -_-</p> | ||
| 201 | |||
| 202 | </main> | ||
| 203 | |||
| 204 | <nav class="nav-wrapper" aria-label="Page navigation"> | ||
| 205 | <!-- Mobile navigation buttons --> | ||
| 206 | <a rel="next" href="installation.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> | ||
| 207 | <i class="fa fa-angle-right"></i> | ||
| 208 | </a> | ||
| 209 | <div style="clear: both"></div> | ||
| 210 | </nav> | ||
| 211 | </div> | ||
| 212 | </div> | ||
| 213 | |||
| 214 | <nav class="nav-wide-wrapper" aria-label="Page navigation"> | ||
| 215 | <a rel="next" href="installation.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> | ||
| 216 | <i class="fa fa-angle-right"></i> | ||
| 217 | </a> | ||
| 218 | </nav> | ||
| 219 | |||
| 220 | </div> | ||
| 221 | |||
| 222 | <!-- Livereload script (if served using the cli tool) --> | ||
| 223 | <script type="text/javascript"> | ||
| 224 | const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:'; | ||
| 225 | const wsAddress = wsProtocol + "//" + location.host + "/" + "__livereload"; | ||
| 226 | const socket = new WebSocket(wsAddress); | ||
| 227 | socket.onmessage = function (event) { | ||
| 228 | if (event.data === "reload") { | ||
| 229 | socket.close(); | ||
| 230 | location.reload(); | ||
| 231 | } | ||
| 232 | }; | ||
| 233 | |||
| 234 | window.onbeforeunload = function() { | ||
| 235 | socket.close(); | ||
| 236 | } | ||
| 237 | </script> | ||
| 238 | <script type="text/javascript"> | ||
| 239 | window.playground_copyable = true; | ||
| 240 | </script> | ||
| 241 | <script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script> | ||
| 242 | <script src="mark.min.js" type="text/javascript" charset="utf-8"></script> | ||
| 243 | <script src="searcher.js" type="text/javascript" charset="utf-8"></script> | ||
| 244 | <script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script> | ||
| 245 | <script src="highlight.js" type="text/javascript" charset="utf-8"></script> | ||
| 246 | <script src="book.js" type="text/javascript" charset="utf-8"></script> | ||
| 247 | |||
| 248 | <!-- Custom JS scripts --> | ||
| 249 | </body> | ||
| 250 | </html> | ||
src/config/pages.rs +6 −6
| @@ -187,15 +187,15 @@ impl PageItems { | |||
| 187 | /// Converts `Self` into a `FrameworkItem` to be used in `State` | 187 | /// Converts `Self` into a `FrameworkItem` to be used in `State` |
| 188 | pub fn to_framework_item(&self, _framework: &mut Framework) -> Box<dyn FrameworkItem> { | 188 | pub fn to_framework_item(&self, _framework: &mut Framework) -> Box<dyn FrameworkItem> { |
| 189 | match *self { | 189 | match *self { |
| 190 | Self::SearchBar => Box::new(SearchBar::default()), | 190 | Self::SearchBar => Box::<SearchBar>::default(), |
| 191 | Self::Popular => Box::new(PageButton::Popular), | 191 | Self::Popular => Box::new(PageButton::Popular), |
| 192 | Self::Trending => Box::new(PageButton::Trending), | 192 | Self::Trending => Box::new(PageButton::Trending), |
| 193 | Self::History => Box::new(PageButton::History), | 193 | Self::History => Box::new(PageButton::History), |
| 194 | Self::MessageBar => Box::new(MessageBar::default()), | 194 | Self::MessageBar => Box::<MessageBar>::default(), |
| 195 | Self::ItemList => Box::new(ItemList::default()), | 195 | Self::ItemList => Box::<ItemList>::default(), |
| 196 | Self::SearchFilters => Box::new(SearchFilter::default()), | 196 | Self::SearchFilters => Box::<SearchFilter>::default(), |
| 197 | Self::SingleItemInfo => Box::new(SingleItem::default()), | 197 | Self::SingleItemInfo => Box::<SingleItem>::default(), |
| 198 | Self::ChannelDisplay => Box::new(ChannelDisplay::default()), | 198 | Self::ChannelDisplay => Box::<ChannelDisplay>::default(), |
| 199 | Self::ChannelMain => Box::new(PageButton::ChannelMain), | 199 | Self::ChannelMain => Box::new(PageButton::ChannelMain), |
| 200 | Self::ChannelVideos => Box::new(PageButton::ChannelVideos), | 200 | Self::ChannelVideos => Box::new(PageButton::ChannelVideos), |
| 201 | Self::ChannelPlaylists => Box::new(PageButton::ChannelPlaylists), | 201 | Self::ChannelPlaylists => Box::new(PageButton::ChannelPlaylists), |
src/eggs.rs added +57
| @@ -0,0 +1,57 @@ | |||
| 1 | use std::{fs::{self, File}, thread, time::Duration, process::Command, io::Write}; | ||
| 2 | |||
| 3 | use chrono::Datelike; | ||
| 4 | use home::home_dir; | ||
| 5 | |||
| 6 | use crate::global::functions::fake_rand_range; | ||
| 7 | |||
| 8 | pub fn egg() { | ||
| 9 | let date_chrono = chrono::Local::now().date_naive(); | ||
| 10 | |||
| 11 | let month = date_chrono.month(); | ||
| 12 | let date = date_chrono.day(); | ||
| 13 | |||
| 14 | let home_dir = home_dir().unwrap(); | ||
| 15 | let displayed_store_path = home_dir.join(".local/share/youtube-tui/eggs/"); | ||
| 16 | let video_cache_path = home_dir.join(".cache/youtube-tui/eggs/"); | ||
| 17 | |||
| 18 | if !displayed_store_path.exists() { | ||
| 19 | let _ = fs::create_dir_all(displayed_store_path); | ||
| 20 | } | ||
| 21 | |||
| 22 | if !video_cache_path.exists() { | ||
| 23 | let _ = fs::create_dir_all(video_cache_path); | ||
| 24 | } | ||
| 25 | |||
| 26 | match (month, date) { | ||
| 27 | (12, 25) | (12, 26) => if !displayed("christmas") { | ||
| 28 | thread::spawn(|| { | ||
| 29 | thread::sleep(Duration::from_secs(fake_rand_range(30_i64, 250) as u64)); | ||
| 30 | |||
| 31 | store("christmas", "happy christmas ;)"); | ||
| 32 | let _ = Command::new("mpv").args(["--no-terminal", CHRISTMAS_VIDEOS[fake_rand_range(0_i64, CHRISTMAS_VIDEOS.len() as i64) as usize]]).output(); | ||
| 33 | }); | ||
| 34 | }, | ||
| 35 | _ => {} | ||
| 36 | } | ||
| 37 | } | ||
| 38 | |||
| 39 | fn displayed(label: &str) -> bool { | ||
| 40 | let home_dir = home_dir().unwrap(); | ||
| 41 | let year = chrono::Local::now().date_naive().year(); | ||
| 42 | let file_path = home_dir.join(".local/share/youtube-tui/eggs/").join(format!("{label}{year}")); | ||
| 43 | |||
| 44 | file_path.exists() | ||
| 45 | } | ||
| 46 | |||
| 47 | fn store(label: &str, content: &str) { | ||
| 48 | let home_dir = home_dir().unwrap(); | ||
| 49 | let year = chrono::Local::now().date_naive().year(); | ||
| 50 | let file_path = home_dir.join(".local/share/youtube-tui/eggs/").join(format!("{label}{year}")); | ||
| 51 | |||
| 52 | |||
| 53 | let mut file = File::create(file_path).unwrap(); | ||
| 54 | let _ =file.write_all(content.as_bytes()); | ||
| 55 | } | ||
| 56 | |||
| 57 | const CHRISTMAS_VIDEOS: &[&str] = &["https://youtu.be/YH7LouNgIvE", "https://youtu.be/KsInh3VvE3s"]; | ||
src/global/functions/from_url.rs added +72
| @@ -0,0 +1,72 @@ | |||
| 1 | pub fn from_channel_url(identifier: &str) -> Result<String, String> { | ||
| 2 | // a youtube channel id is exactly 24 characters long, so if the identifier to 24 chars | ||
| 3 | // long, then just assume its the channel id | ||
| 4 | if identifier.len() == 24 { | ||
| 5 | Ok(identifier.to_string()) | ||
| 6 | } else { | ||
| 7 | // the channel id comes after `/channel/` in an url | ||
| 8 | let index = if let Some(index) = identifier.find("/channel/") { | ||
| 9 | // if there isnt 24 characters after `/channel/`, that url must not have | ||
| 10 | // contained a channel id | ||
| 11 | if identifier.len() < index + 33 { | ||
| 12 | return Err(format!( | ||
| 13 | "Cannot find channel id from string `{}`", | ||
| 14 | identifier | ||
| 15 | )); | ||
| 16 | } | ||
| 17 | index + 9 | ||
| 18 | } else { | ||
| 19 | return Err(format!( | ||
| 20 | "Cannot find channel id from string `{}`", | ||
| 21 | identifier | ||
| 22 | )); | ||
| 23 | }; | ||
| 24 | |||
| 25 | Ok(identifier[index..index + 24].to_string()) | ||
| 26 | } | ||
| 27 | } | ||
| 28 | |||
| 29 | pub fn from_video_url(identifier: &str) -> Result<String, String> { | ||
| 30 | if identifier.len() == 11 { | ||
| 31 | Ok(identifier.to_string()) | ||
| 32 | } else { | ||
| 33 | let index = if let Some(index) = identifier.find("?v=") { | ||
| 34 | if identifier.len() < index + 15 { | ||
| 35 | return Err(format!("Cannot find video id from string `{}`", identifier)); | ||
| 36 | } | ||
| 37 | index + 3 | ||
| 38 | } else if let Some(index) = identifier.find("youtu.be/") { | ||
| 39 | if identifier.len() < index + 21 { | ||
| 40 | return Err(format!("Cannot find video id from string `{}`", identifier)); | ||
| 41 | } | ||
| 42 | index + 9 | ||
| 43 | } else { | ||
| 44 | return Err(format!("Cannot find video id from string `{}`", identifier)); | ||
| 45 | }; | ||
| 46 | |||
| 47 | Ok(identifier[index..index + 11].to_string()) | ||
| 48 | } | ||
| 49 | } | ||
| 50 | |||
| 51 | pub fn from_playlist_url(identifier: &str) -> Result<String, String> { | ||
| 52 | if identifier.len() == 34 { | ||
| 53 | Ok(identifier.to_string()) | ||
| 54 | } else { | ||
| 55 | let index = if let Some(index) = identifier.find("playlist?list=") { | ||
| 56 | if identifier.len() < index + 48 { | ||
| 57 | return Err(format!( | ||
| 58 | "Cannot find plalyist id from string `{}`", | ||
| 59 | identifier | ||
| 60 | )); | ||
| 61 | } | ||
| 62 | index + 14 | ||
| 63 | } else { | ||
| 64 | return Err(format!( | ||
| 65 | "Cannot find playlist id from string `{}`", | ||
| 66 | identifier | ||
| 67 | )); | ||
| 68 | }; | ||
| 69 | |||
| 70 | Ok(identifier[index..index + 34].to_string()) | ||
| 71 | } | ||
| 72 | } | ||
src/global/functions/mod.rs +2
| @@ -19,3 +19,5 @@ mod clipboard; | |||
| 19 | pub use self::clipboard::*; | 19 | pub use self::clipboard::*; |
| 20 | mod type_name_of_val; | 20 | mod type_name_of_val; |
| 21 | pub use type_name_of_val::*; | 21 | pub use type_name_of_val::*; |
| 22 | mod from_url; | ||
| 23 | pub use from_url::*; | ||
src/global/functions/run_command.rs +66 −37
| @@ -1,8 +1,8 @@ | |||
| 1 | use crate::{ | 1 | use crate::{ |
| 2 | config::Search, | 2 | config::Search, |
| 3 | global::structs::{ | 3 | global::structs::{ |
| 4 | ChannelDisplayPage, ChannelDisplayPageType, MainMenuPage, Message, Page, Status, Task, | 4 | ChannelDisplayPage, ChannelDisplayPageType, MainMenuPage, Message, Page, SingleItemPage, |
| 5 | Tasks, | 5 | Status, Task, Tasks, |
| 6 | }, | 6 | }, |
| 7 | load_configs, | 7 | load_configs, |
| 8 | }; | 8 | }; |
| @@ -10,7 +10,7 @@ use std::io::Stdout; | |||
| 10 | use tui::{backend::CrosstermBackend, Terminal}; | 10 | use tui::{backend::CrosstermBackend, Terminal}; |
| 11 | use tui_additions::framework::Framework; | 11 | use tui_additions::framework::Framework; |
| 12 | 12 | ||
| 13 | use super::fake_rand_range; | 13 | use super::{fake_rand_range, from_channel_url, from_video_url, from_playlist_url}; |
| 14 | 14 | ||
| 15 | /// WIP text command support | 15 | /// WIP text command support |
| 16 | pub fn run_command( | 16 | pub fn run_command( |
| @@ -35,47 +35,57 @@ pub fn run_command( | |||
| 35 | let page = match *page { | 35 | let page = match *page { |
| 36 | "popular" => Some(Page::MainMenu(MainMenuPage::Popular)), | 36 | "popular" => Some(Page::MainMenu(MainMenuPage::Popular)), |
| 37 | "trending" => Some(Page::MainMenu(MainMenuPage::Trending)), | 37 | "trending" => Some(Page::MainMenu(MainMenuPage::Trending)), |
| 38 | "history" => Some(Page::MainMenu(MainMenuPage::History)), | 38 | "watchhistory" => Some(Page::MainMenu(MainMenuPage::History)), |
| 39 | "channel" => { | 39 | "channel" => { |
| 40 | if command.len() == 2 { | 40 | if command.len() == 2 { |
| 41 | *framework.data.global.get_mut::<Message>().unwrap() = | 41 | *framework.data.global.get_mut::<Message>().unwrap() = |
| 42 | Message::Message(String::from( | 42 | Message::Message(String::from("Usage: `loadpage channel {id/url}`")); |
| 43 | "Usage: `loadpage channel {id/url}` or `channel {id/url}`", | ||
| 44 | )); | ||
| 45 | return; | 43 | return; |
| 46 | } | 44 | } |
| 47 | // a youtube channel id is exactly 24 characters long, so if the identifier to 24 chars | 45 | |
| 48 | // long, then just assume its the channel id | 46 | match from_channel_url(command[2]) { |
| 49 | let id = if command[2].len() == 24 { | 47 | Ok(id) => Some(Page::ChannelDisplay(ChannelDisplayPage { |
| 50 | command[2].to_string() | 48 | id, |
| 51 | } else { | 49 | r#type: ChannelDisplayPageType::Main, |
| 52 | // the channel id comes after `/channel/` in an url | 50 | })), |
| 53 | let index = if let Some(index) = command[2].find("/channel/") { | 51 | Err(e) => { |
| 54 | // if there isnt 24 characters after `/channel/`, that url must not have | 52 | *framework.data.global.get_mut::<Message>().unwrap() = |
| 55 | // contained a channel id | 53 | Message::Error(e); |
| 56 | if command[2].len() < index + 33 { | ||
| 57 | *framework.data.global.get_mut::<Message>().unwrap() = | ||
| 58 | Message::Error(format!( | ||
| 59 | "Cannot find channel id from string `{}`", | ||
| 60 | command[2] | ||
| 61 | )); | ||
| 62 | return; | ||
| 63 | } | ||
| 64 | index + 9 | ||
| 65 | } else { | ||
| 66 | *framework.data.global.get_mut::<Message>().unwrap() = Message::Error( | ||
| 67 | format!("Cannot find channel id from string `{}`", command[2]), | ||
| 68 | ); | ||
| 69 | return; | 54 | return; |
| 70 | }; | 55 | } |
| 56 | } | ||
| 57 | } | ||
| 58 | "video" => { | ||
| 59 | if command.len() == 2 { | ||
| 60 | *framework.data.global.get_mut::<Message>().unwrap() = | ||
| 61 | Message::Message(String::from("Usage: `loadpage video {id/url}`")); | ||
| 62 | return; | ||
| 63 | } | ||
| 71 | 64 | ||
| 72 | command[2][index..index + 24].to_string() | 65 | match from_video_url(command[2]) { |
| 73 | }; | 66 | Ok(id) => Some(Page::SingleItem(SingleItemPage::Video(id))), |
| 67 | Err(e) => { | ||
| 68 | *framework.data.global.get_mut::<Message>().unwrap() = | ||
| 69 | Message::Error(e); | ||
| 70 | return; | ||
| 71 | } | ||
| 72 | } | ||
| 73 | } | ||
| 74 | "playlist" => { | ||
| 75 | if command.len() == 2 { | ||
| 76 | *framework.data.global.get_mut::<Message>().unwrap() = | ||
| 77 | Message::Message(String::from("Usage: `loadpage playlist {id/url}`")); | ||
| 78 | return; | ||
| 79 | } | ||
| 74 | 80 | ||
| 75 | Some(Page::ChannelDisplay(ChannelDisplayPage { | 81 | match from_playlist_url(command[2]) { |
| 76 | id, | 82 | Ok(id) => Some(Page::SingleItem(SingleItemPage::Playlist(id))), |
| 77 | r#type: ChannelDisplayPageType::Main, | 83 | Err(e) => { |
| 78 | })) | 84 | *framework.data.global.get_mut::<Message>().unwrap() = |
| 85 | Message::Error(e); | ||
| 86 | return; | ||
| 87 | } | ||
| 88 | } | ||
| 79 | } | 89 | } |
| 80 | "search" => { | 90 | "search" => { |
| 81 | if command.len() == 2 { | 91 | if command.len() == 2 { |
| @@ -109,6 +119,9 @@ pub fn run_command( | |||
| 109 | } | 119 | } |
| 110 | } | 120 | } |
| 111 | // redirects to the relevant `loadpage` command | 121 | // redirects to the relevant `loadpage` command |
| 122 | ["popular"] => run_command(&["loadpage", "popular"], framework, terminal), | ||
| 123 | ["trending"] => run_command(&["loadpage", "trending"], framework, terminal), | ||
| 124 | ["watchhistory"] => run_command(&["loadpage", "watchhistory"], framework, terminal), | ||
| 112 | ["search"] => run_command(&["loadpage", "search"], framework, terminal), | 125 | ["search"] => run_command(&["loadpage", "search"], framework, terminal), |
| 113 | ["search", ..] => run_command( | 126 | ["search", ..] => run_command( |
| 114 | &format!("loadpage search {}", command[1..].join(" ")) | 127 | &format!("loadpage search {}", command[1..].join(" ")) |
| @@ -121,7 +134,22 @@ pub fn run_command( | |||
| 121 | ["channel", identifier] => { | 134 | ["channel", identifier] => { |
| 122 | run_command(&["loadpage", "channel", *identifier], framework, terminal) | 135 | run_command(&["loadpage", "channel", *identifier], framework, terminal) |
| 123 | } | 136 | } |
| 137 | ["video"] => run_command(&["loadpage", "video"], framework, terminal), | ||
| 138 | ["video", identifier] => { | ||
| 139 | run_command(&["loadpage", "video", *identifier], framework, terminal) | ||
| 140 | } | ||
| 141 | ["playlist"] => run_command(&["loadpage", "playlist"], framework, terminal), | ||
| 142 | ["playlist", identifier] => { | ||
| 143 | run_command(&["loadpage", "playlist", *identifier], framework, terminal) | ||
| 144 | } | ||
| 124 | ["history"] => { /* help message */ } | 145 | ["history"] => { /* help message */ } |
| 146 | ["history", "back"] | ["back"] => { | ||
| 147 | let _ = framework.revert_last_history(); | ||
| 148 | framework.data.state.get_mut::<Tasks>().unwrap().priority.push(Task::ClearPage); | ||
| 149 | framework.data.state.get_mut::<Tasks>().unwrap().priority.push(Task::RenderAll); | ||
| 150 | run_command(&["flush"], framework, terminal); | ||
| 151 | framework.data.global.get_mut::<Status>().unwrap().render_image = true; | ||
| 152 | }, | ||
| 125 | ["history", "clear"] => framework.clear_history(), | 153 | ["history", "clear"] => framework.clear_history(), |
| 126 | ["flush"] => loop { | 154 | ["flush"] => loop { |
| 127 | // runs all stacked actions | 155 | // runs all stacked actions |
| @@ -131,7 +159,8 @@ pub fn run_command( | |||
| 131 | } | 159 | } |
| 132 | break; | 160 | break; |
| 133 | }, | 161 | }, |
| 134 | ["reload", "config"] | ["reload", "configs"] => { | 162 | ["reload"] | ["r"] => framework.data.state.get_mut::<Tasks>().unwrap().priority.push(Task::Reload), |
| 163 | ["reload", "config"] | ["reload", "configs"] | ["r", "config"] | ["r", "configs"] => { | ||
| 135 | *framework.data.global.get_mut::<Message>().unwrap() = | 164 | *framework.data.global.get_mut::<Message>().unwrap() = |
| 136 | match load_configs(&mut framework.split_clean().0) { | 165 | match load_configs(&mut framework.split_clean().0) { |
| 137 | Ok(()) => Message::Success(String::from("Config files have been reloaded")), | 166 | Ok(()) => Message::Success(String::from("Config files have been reloaded")), |
src/global/structs/item.rs +1 −1
| @@ -310,7 +310,7 @@ impl Item { | |||
| 310 | title: original.title, | 310 | title: original.title, |
| 311 | id: original.id, | 311 | id: original.id, |
| 312 | thumbnail_url: original.thumbnails[image_index].url.clone(), | 312 | thumbnail_url: original.thumbnails[image_index].url.clone(), |
| 313 | length: secs_display_string(original.length as u32), | 313 | length: secs_display_string(original.length), |
| 314 | views: viewcount_text(original.views), | 314 | views: viewcount_text(original.views), |
| 315 | channel: original.author, | 315 | channel: original.author, |
| 316 | channel_id: original.author_id, | 316 | channel_id: original.author_id, |
src/global/structs/watchhistory.rs +1 −1
| @@ -27,7 +27,7 @@ impl WatchHistory { | |||
| 27 | .write(true) | 27 | .write(true) |
| 28 | .create(true) | 28 | .create(true) |
| 29 | .truncate(true) | 29 | .truncate(true) |
| 30 | .open(&path)?; | 30 | .open(path)?; |
| 31 | 31 | ||
| 32 | file.write_all(save_string.as_bytes())?; | 32 | file.write_all(save_string.as_bytes())?; |
| 33 | 33 | ||
src/init.rs +3 −1
| @@ -7,7 +7,7 @@ use crate::{ | |||
| 7 | functions::run_command, | 7 | functions::run_command, |
| 8 | structs::{InvidiousClient, Message, Page, Status, Tasks, WatchHistory}, | 8 | structs::{InvidiousClient, Message, Page, Status, Tasks, WatchHistory}, |
| 9 | traits::ConfigTrait, | 9 | traits::ConfigTrait, |
| 10 | }, | 10 | }, egg, |
| 11 | }; | 11 | }; |
| 12 | use home::home_dir; | 12 | use home::home_dir; |
| 13 | use std::{error::Error, fs, io::Stdout}; | 13 | use std::{error::Error, fs, io::Stdout}; |
| @@ -96,5 +96,7 @@ pub fn load_configs(framework: &mut FrameworkClean) -> Result<(), Box<dyn Error> | |||
| 96 | .insert::<KeyBindingsConfig>(KeyBindingsConfig::load()?); | 96 | .insert::<KeyBindingsConfig>(KeyBindingsConfig::load()?); |
| 97 | framework.data.state.insert::<Search>(*Search::load()?); | 97 | framework.data.state.insert::<Search>(*Search::load()?); |
| 98 | 98 | ||
| 99 | egg(); | ||
| 100 | |||
| 99 | Ok(()) | 101 | Ok(()) |
| 100 | } | 102 | } |
src/lib.rs +2
| @@ -8,3 +8,5 @@ mod run; | |||
| 8 | pub use run::*; | 8 | pub use run::*; |
| 9 | mod exit; | 9 | mod exit; |
| 10 | pub use exit::*; | 10 | pub use exit::*; |
| 11 | mod eggs; | ||
| 12 | pub use eggs::*; | ||
src/run.rs +4 −7
| @@ -47,15 +47,12 @@ pub fn run( | |||
| 47 | 47 | ||
| 48 | *framework.data.global.get_mut::<Message>().unwrap() = Message::None; | 48 | *framework.data.global.get_mut::<Message>().unwrap() = Message::None; |
| 49 | 49 | ||
| 50 | let status = framework.data.global.get_mut::<Status>().unwrap(); | ||
| 51 | status.command_capture = None; | ||
| 52 | |||
| 50 | // check if the search filter popup is clicked | 53 | // check if the search filter popup is clicked |
| 51 | let mut searchfilter_clicked = false; | 54 | let mut searchfilter_clicked = false; |
| 52 | if framework | 55 | if status.search_filter_opened { |
| 53 | .data | ||
| 54 | .global | ||
| 55 | .get::<Status>() | ||
| 56 | .unwrap() | ||
| 57 | .search_filter_opened | ||
| 58 | { | ||
| 59 | let (mut frameworkclean, state) = framework.split_clean(); | 56 | let (mut frameworkclean, state) = framework.split_clean(); |
| 60 | for row in state.0.iter_mut() { | 57 | for row in state.0.iter_mut() { |
| 61 | for item in row.items.iter_mut() { | 58 | for item in row.items.iter_mut() { |