Commit 0a9310640f
Unsigned
Layout: unified · split
Cargo.lock −62
| @@ -326,12 +326,6 @@ dependencies = [ | ||
| 326 | 326 | "syn", |
| 327 | 327 | ] |
| 328 | 328 | |
| 329 | [[package]] | |
| 330 | name = "dunce" | |
| 331 | version = "1.0.3" | |
| 332 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 333 | checksum = "0bd4b30a6560bbd9b4620f4de34c3f14f60848e58a9b7216801afcb4c7b31c3c" | |
| 334 | ||
| 335 | 329 | [[package]] |
| 336 | 330 | name = "dyn-clone" |
| 337 | 331 | version = "1.0.10" |
| @@ -458,16 +452,6 @@ dependencies = [ | ||
| 458 | 452 | "percent-encoding", |
| 459 | 453 | ] |
| 460 | 454 | |
| 461 | [[package]] | |
| 462 | name = "fsio" | |
| 463 | version = "0.4.0" | |
| 464 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 465 | checksum = "dad0ce30be0cc441b325c5d705c8b613a0ca0d92b6a8953d41bd236dc09a36d0" | |
| 466 | dependencies = [ | |
| 467 | "dunce", | |
| 468 | "rand", | |
| 469 | ] | |
| 470 | ||
| 471 | 455 | [[package]] |
| 472 | 456 | name = "futures" |
| 473 | 457 | version = "0.3.26" |
| @@ -1136,12 +1120,6 @@ dependencies = [ | ||
| 1136 | 1120 | "miniz_oxide", |
| 1137 | 1121 | ] |
| 1138 | 1122 | |
| 1139 | [[package]] | |
| 1140 | name = "ppv-lite86" | |
| 1141 | version = "0.2.17" | |
| 1142 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1143 | checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" | |
| 1144 | ||
| 1145 | 1123 | [[package]] |
| 1146 | 1124 | name = "proc-macro2" |
| 1147 | 1125 | version = "1.0.51" |
| @@ -1160,36 +1138,6 @@ dependencies = [ | ||
| 1160 | 1138 | "proc-macro2", |
| 1161 | 1139 | ] |
| 1162 | 1140 | |
| 1163 | [[package]] | |
| 1164 | name = "rand" | |
| 1165 | version = "0.8.5" | |
| 1166 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1167 | checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" | |
| 1168 | dependencies = [ | |
| 1169 | "libc", | |
| 1170 | "rand_chacha", | |
| 1171 | "rand_core", | |
| 1172 | ] | |
| 1173 | ||
| 1174 | [[package]] | |
| 1175 | name = "rand_chacha" | |
| 1176 | version = "0.3.1" | |
| 1177 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1178 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" | |
| 1179 | dependencies = [ | |
| 1180 | "ppv-lite86", | |
| 1181 | "rand_core", | |
| 1182 | ] | |
| 1183 | ||
| 1184 | [[package]] | |
| 1185 | name = "rand_core" | |
| 1186 | version = "0.6.4" | |
| 1187 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1188 | checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" | |
| 1189 | dependencies = [ | |
| 1190 | "getrandom", | |
| 1191 | ] | |
| 1192 | ||
| 1193 | 1141 | [[package]] |
| 1194 | 1142 | name = "rayon" |
| 1195 | 1143 | version = "1.6.1" |
| @@ -1267,15 +1215,6 @@ dependencies = [ | ||
| 1267 | 1215 | "bytemuck", |
| 1268 | 1216 | ] |
| 1269 | 1217 | |
| 1270 | [[package]] | |
| 1271 | name = "run_script" | |
| 1272 | version = "0.10.0" | |
| 1273 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1274 | checksum = "7fdc55b3a7ad58e02de47eaf7a854c6791c8421da48ff296c152317d3beaf230" | |
| 1275 | dependencies = [ | |
| 1276 | "fsio", | |
| 1277 | ] | |
| 1278 | ||
| 1279 | 1218 | [[package]] |
| 1280 | 1219 | name = "rustix" |
| 1281 | 1220 | version = "0.36.8" |
| @@ -2005,7 +1944,6 @@ dependencies = [ | ||
| 2005 | 1944 | "home", |
| 2006 | 1945 | "invidious", |
| 2007 | 1946 | "reqwest", |
| 2008 | "run_script", | |
| 2009 | 1947 | "serde", |
| 2010 | 1948 | "serde_json", |
| 2011 | 1949 | "serde_yaml", |
Cargo.toml +3 −3
| @@ -16,9 +16,10 @@ exclude = ["/docs", "/LICENSE"] | ||
| 16 | 16 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html |
| 17 | 17 | |
| 18 | 18 | [features] |
| 19 | default = ["sixel", "halfblock"] | |
| 19 | default = ["sixel", "halfblock", "clipboard"] | |
| 20 | 20 | sixel = ["viuer/sixel"] |
| 21 | 21 | halfblock = ["viuer"] |
| 22 | clipboard = ["dep:clipboard"] | |
| 22 | 23 | |
| 23 | 24 | [dependencies] |
| 24 | 25 | serde = {version = "1.0", default-features = false, features = ["derive"]} |
| @@ -36,8 +37,7 @@ tokio = {version = "1.21", default-features = false} | ||
| 36 | 37 | futures = {version = "0.3", default-features = false} |
| 37 | 38 | reqwest = {version = "0.11", default-features = false} |
| 38 | 39 | serde_json = {version = "1.0", default-features = false} |
| 39 | run_script = { version = "0.10", default-features = false} | |
| 40 | clipboard = {version = "0.5"} | |
| 40 | clipboard = {version = "0.5", optional = true} | |
| 41 | 41 | |
| 42 | 42 | # tui-additions = {path = "../../Rust/Packages/tui-additions", default-features = false, features = ["framework", "widgets"]} |
| 43 | 43 | # invidious = {path = "../../Rust/Packages/invidious", default-features = false, features = ["reqwest"]} |
src/config/appearance.rs +3 −5
| @@ -1,13 +1,11 @@ | ||
| 1 | use crate::{config::serde::*, global::traits::*}; | |
| 2 | use home::home_dir; | |
| 3 | use serde::{Deserialize, Serialize}; | |
| 1 | 4 | use std::{ |
| 2 | 5 | error::Error, |
| 3 | 6 | fs::{self, OpenOptions}, |
| 4 | 7 | io::Write, |
| 5 | 8 | }; |
| 6 | ||
| 7 | use super::serde::{BorderTypeSerde, ColorSerde, ColorVariantSerde}; | |
| 8 | use crate::global::traits::{ConfigTrait, EXTENSION}; | |
| 9 | use home::home_dir; | |
| 10 | use serde::{Deserialize, Serialize}; | |
| 11 | 9 | use tui::{style::Color, widgets::BorderType}; |
| 12 | 10 | use typemap::Key; |
| 13 | 11 | |
src/config/commandbindings.rs +25 −28
| @@ -3,10 +3,7 @@ use serde::{Deserialize, Serialize}; | ||
| 3 | 3 | use std::collections::HashMap; |
| 4 | 4 | use typemap::Key; |
| 5 | 5 | |
| 6 | use crate::global::{ | |
| 7 | structs::{ChannelDisplayPage, ChannelDisplayPageType, MainMenuPage, Page, SingleItemPage}, | |
| 8 | traits::ConfigTrait, | |
| 9 | }; | |
| 6 | use crate::global::{structs::*, traits::ConfigTrait}; | |
| 10 | 7 | |
| 11 | 8 | use super::serde::KeyCodeSerde; |
| 12 | 9 | |
| @@ -179,9 +176,9 @@ fn global_default() -> HashMap<KeyCodeSerde, HashMap<u8, String>> { | ||
| 179 | 176 | |
| 180 | 177 | fn search_default() -> HashMap<KeyCodeSerde, HashMap<u8, String>> { |
| 181 | 178 | HashMap::from([ |
| 182 | (KeyCodeSerde::Char('a'), HashMap::from([(2, String::from("run ${terminal-emulator} mpv '${hover-url}' --no-video"))])), | |
| 183 | (KeyCodeSerde::Char('A'), HashMap::from([(1, String::from("run ${terminal-emulator} mpv '${hover-url}' --no-video --loop-playlist=inf --shuffle"))])), | |
| 184 | (KeyCodeSerde::Char('p'), HashMap::from([(2, String::from("run mpv '${hover-url}'"))])), | |
| 179 | (KeyCodeSerde::Char('a'), HashMap::from([(2, String::from("parrun ${terminal-emulator} mpv '${hover-url}' --no-video"))])), | |
| 180 | (KeyCodeSerde::Char('A'), HashMap::from([(1, String::from("parrun ${terminal-emulator} mpv '${hover-url}' --no-video --loop-playlist=inf --shuffle"))])), | |
| 181 | (KeyCodeSerde::Char('p'), HashMap::from([(2, String::from("parrun mpv '${hover-url}'"))])), | |
| 185 | 182 | ]) |
| 186 | 183 | } |
| 187 | 184 | |
| @@ -191,41 +188,41 @@ fn channel_main_default() -> HashMap<KeyCodeSerde, HashMap<u8, String>> { | ||
| 191 | 188 | |
| 192 | 189 | fn channel_playlists_default() -> HashMap<KeyCodeSerde, HashMap<u8, String>> { |
| 193 | 190 | HashMap::from([ |
| 194 | (KeyCodeSerde::Char('a'), HashMap::from([(2, String::from("run ${terminal-emulator} mpv '${hover-url}' --no-video"))])), | |
| 195 | (KeyCodeSerde::Char('A'), HashMap::from([(1, String::from("run ${terminal-emulator} mpv '${hover-url}' --no-video --loop-playlist=inf --shuffle"))])), | |
| 196 | (KeyCodeSerde::Char('p'), HashMap::from([(2, String::from("run mpv '${hover-url}'"))])), | |
| 191 | (KeyCodeSerde::Char('a'), HashMap::from([(2, String::from("parrun ${terminal-emulator} mpv '${hover-url}' --no-video"))])), | |
| 192 | (KeyCodeSerde::Char('A'), HashMap::from([(1, String::from("parrun ${terminal-emulator} mpv '${hover-url}' --no-video --loop-playlist=inf --shuffle"))])), | |
| 193 | (KeyCodeSerde::Char('p'), HashMap::from([(2, String::from("parrun mpv '${hover-url}'"))])), | |
| 197 | 194 | ]) |
| 198 | 195 | } |
| 199 | 196 | |
| 200 | 197 | fn channel_videos_default() -> HashMap<KeyCodeSerde, HashMap<u8, String>> { |
| 201 | 198 | HashMap::from([ |
| 202 | (KeyCodeSerde::Char('a'), HashMap::from([(2, String::from("run ${terminal-emulator} mpv '${hover-url}' --no-video"))])), | |
| 203 | (KeyCodeSerde::Char('A'), HashMap::from([(1, String::from("run ${terminal-emulator} mpv '${hover-url}' --no-video --loop-playlist=inf --shuffle"))])), | |
| 204 | (KeyCodeSerde::Char('p'), HashMap::from([(2, String::from("run mpv '${hover-url}'"))])), | |
| 199 | (KeyCodeSerde::Char('a'), HashMap::from([(2, String::from("parrun ${terminal-emulator} mpv '${hover-url}' --no-video"))])), | |
| 200 | (KeyCodeSerde::Char('A'), HashMap::from([(1, String::from("parrun ${terminal-emulator} mpv '${hover-url}' --no-video --loop-playlist=inf --shuffle"))])), | |
| 201 | (KeyCodeSerde::Char('p'), HashMap::from([(2, String::from("parrun mpv '${hover-url}'"))])), | |
| 205 | 202 | ]) |
| 206 | 203 | } |
| 207 | 204 | |
| 208 | 205 | fn playlist_default() -> HashMap<KeyCodeSerde, HashMap<u8, String>> { |
| 209 | 206 | HashMap::from([ |
| 210 | (KeyCodeSerde::Char('a'), HashMap::from([(2, String::from("run ${terminal-emulator} mpv '${hover-url}' --no-video"))])), | |
| 211 | (KeyCodeSerde::Char('A'), HashMap::from([(1, String::from("run ${terminal-emulator} mpv '${hover-url}' --no-video --loop-playlist=inf --shuffle"))])), | |
| 212 | (KeyCodeSerde::Char('p'), HashMap::from([(2, String::from("run mpv '${hover-url}'"))])), | |
| 207 | (KeyCodeSerde::Char('a'), HashMap::from([(2, String::from("parrun ${terminal-emulator} mpv '${hover-url}' --no-video"))])), | |
| 208 | (KeyCodeSerde::Char('A'), HashMap::from([(1, String::from("parrun ${terminal-emulator} mpv '${hover-url}' --no-video --loop-playlist=inf --shuffle"))])), | |
| 209 | (KeyCodeSerde::Char('p'), HashMap::from([(2, String::from("parrun mpv '${hover-url}'"))])), | |
| 213 | 210 | ]) |
| 214 | 211 | } |
| 215 | 212 | |
| 216 | 213 | fn popular_default() -> HashMap<KeyCodeSerde, HashMap<u8, String>> { |
| 217 | 214 | HashMap::from([ |
| 218 | (KeyCodeSerde::Char('a'), HashMap::from([(2, String::from("run ${terminal-emulator} mpv '${hover-url}' --no-video"))])), | |
| 219 | (KeyCodeSerde::Char('A'), HashMap::from([(1, String::from("run ${terminal-emulator} mpv '${hover-url}' --no-video --loop-playlist=inf --shuffle"))])), | |
| 220 | (KeyCodeSerde::Char('p'), HashMap::from([(2, String::from("run mpv '${hover-url}'"))])), | |
| 215 | (KeyCodeSerde::Char('a'), HashMap::from([(2, String::from("parrun ${terminal-emulator} mpv '${hover-url}' --no-video"))])), | |
| 216 | (KeyCodeSerde::Char('A'), HashMap::from([(1, String::from("parrun ${terminal-emulator} mpv '${hover-url}' --no-video --loop-playlist=inf --shuffle"))])), | |
| 217 | (KeyCodeSerde::Char('p'), HashMap::from([(2, String::from("parrun mpv '${hover-url}'"))])), | |
| 221 | 218 | ]) |
| 222 | 219 | } |
| 223 | 220 | |
| 224 | 221 | fn trending_default() -> HashMap<KeyCodeSerde, HashMap<u8, String>> { |
| 225 | 222 | HashMap::from([ |
| 226 | (KeyCodeSerde::Char('a'), HashMap::from([(2, String::from("run ${terminal-emulator} mpv '${hover-url}' --no-video"))])), | |
| 227 | (KeyCodeSerde::Char('A'), HashMap::from([(1, String::from("run ${terminal-emulator} mpv '${hover-url}' --no-video --loop-playlist=inf --shuffle"))])), | |
| 228 | (KeyCodeSerde::Char('p'), HashMap::from([(2, String::from("run mpv '${hover-url}'"))])), | |
| 223 | (KeyCodeSerde::Char('a'), HashMap::from([(2, String::from("parrun ${terminal-emulator} mpv '${hover-url}' --no-video"))])), | |
| 224 | (KeyCodeSerde::Char('A'), HashMap::from([(1, String::from("parrun ${terminal-emulator} mpv '${hover-url}' --no-video --loop-playlist=inf --shuffle"))])), | |
| 225 | (KeyCodeSerde::Char('p'), HashMap::from([(2, String::from("parrun mpv '${hover-url}'"))])), | |
| 229 | 226 | ]) |
| 230 | 227 | } |
| 231 | 228 | |
| @@ -235,9 +232,9 @@ fn video_default() -> HashMap<KeyCodeSerde, HashMap<u8, String>> { | ||
| 235 | 232 | |
| 236 | 233 | fn watchhistory_default() -> HashMap<KeyCodeSerde, HashMap<u8, String>> { |
| 237 | 234 | HashMap::from([ |
| 238 | (KeyCodeSerde::Char('a'), HashMap::from([(2, String::from("run ${terminal-emulator} mpv '${hover-url}' --no-video"))])), | |
| 239 | (KeyCodeSerde::Char('A'), HashMap::from([(1, String::from("run ${terminal-emulator} mpv '${hover-url}' --no-video --loop-playlist=inf --shuffle"))])), | |
| 240 | (KeyCodeSerde::Char('p'), HashMap::from([(2, String::from("run mpv '${hover-url}'"))])) | |
| 235 | (KeyCodeSerde::Char('a'), HashMap::from([(2, String::from("parrun ${terminal-emulator} mpv '${hover-url}' --no-video"))])), | |
| 236 | (KeyCodeSerde::Char('A'), HashMap::from([(1, String::from("parrun ${terminal-emulator} mpv '${hover-url}' --no-video --loop-playlist=inf --shuffle"))])), | |
| 237 | (KeyCodeSerde::Char('p'), HashMap::from([(2, String::from("parrun mpv '${hover-url}'"))])) | |
| 241 | 238 | ]) |
| 242 | 239 | } |
| 243 | 240 | |
| @@ -247,8 +244,8 @@ fn subscriptions_default() -> HashMap<KeyCodeSerde, HashMap<u8, String>> { | ||
| 247 | 244 | |
| 248 | 245 | fn library_default() -> HashMap<KeyCodeSerde, HashMap<u8, String>> { |
| 249 | 246 | HashMap::from([ |
| 250 | (KeyCodeSerde::Char('a'), HashMap::from([(2, String::from("run ${terminal-emulator} mpv '${hover-url}' --no-video"))])), | |
| 251 | (KeyCodeSerde::Char('A'), HashMap::from([(1, String::from("run ${terminal-emulator} mpv '${hover-url}' --no-video --loop-playlist=inf --shuffle"))])), | |
| 252 | (KeyCodeSerde::Char('p'), HashMap::from([(2, String::from("run mpv '${hover-url}'"))])) | |
| 247 | (KeyCodeSerde::Char('a'), HashMap::from([(2, String::from("parrun ${terminal-emulator} mpv '${hover-url}' --no-video"))])), | |
| 248 | (KeyCodeSerde::Char('A'), HashMap::from([(1, String::from("parrun ${terminal-emulator} mpv '${hover-url}' --no-video --loop-playlist=inf --shuffle"))])), | |
| 249 | (KeyCodeSerde::Char('p'), HashMap::from([(2, String::from("parrun mpv '${hover-url}'"))])) | |
| 253 | 250 | ]) |
| 254 | 251 | } |
src/config/commands.rs +24 −24
| @@ -94,16 +94,16 @@ fn video_default() -> Vec<HashMap<String, String>> { | ||
| 94 | 94 | )]), |
| 95 | 95 | HashMap::from([( |
| 96 | 96 | String::from("Play video"), |
| 97 | String::from("run ${video-player} '${embed-url}'"), | |
| 97 | String::from("parrun ${video-player} '${embed-url}'"), | |
| 98 | 98 | )]), |
| 99 | 99 | HashMap::from([( |
| 100 | 100 | String::from("Play audio"), |
| 101 | String::from("run ${terminal-emulator} ${video-player} '${embed-url}' --no-video"), | |
| 101 | String::from("parrun ${terminal-emulator} ${video-player} '${embed-url}' --no-video"), | |
| 102 | 102 | )]), |
| 103 | 103 | HashMap::from([( |
| 104 | 104 | String::from("Play audio (loop)"), |
| 105 | 105 | String::from( |
| 106 | "run ${terminal-emulator} ${video-player} '${embed-url}' --no-video --loop-file=inf", | |
| 106 | "parrun ${terminal-emulator} ${video-player} '${embed-url}' --no-video --loop-file=inf", | |
| 107 | 107 | ), |
| 108 | 108 | )]), |
| 109 | 109 | HashMap::from([( |
| @@ -112,7 +112,7 @@ fn video_default() -> Vec<HashMap<String, String>> { | ||
| 112 | 112 | )]), |
| 113 | 113 | HashMap::from([( |
| 114 | 114 | String::from("Open in browser"), |
| 115 | String::from("run ${browser} '${url}'"), | |
| 115 | String::from("parrun ${browser} '${url}'"), | |
| 116 | 116 | )]), |
| 117 | 117 | HashMap::from([( |
| 118 | 118 | String::from("Toggle bookmark"), |
| @@ -120,11 +120,11 @@ fn video_default() -> Vec<HashMap<String, String>> { | ||
| 120 | 120 | )]), |
| 121 | 121 | HashMap::from([( |
| 122 | 122 | String::from("Save video to library"), |
| 123 | String::from("bookmark ${id} ;; run rm -rf '${save-path}${id}.*' ;; run ${terminal-emulator} ${youtube-downloader} '${embed-url}' -o '${save-path}%(title)s[%(id)s].%(ext)s'") | |
| 123 | String::from("bookmark ${id} ;; run rm -rf '${save-path}${id}.*' ;; parrun ${terminal-emulator} ${youtube-downloader} '${embed-url}' -o '${save-path}%(title)s[%(id)s].%(ext)s'") | |
| 124 | 124 | )]), |
| 125 | 125 | HashMap::from([( |
| 126 | 126 | String::from("Save audio to library"), |
| 127 | String::from("bookmark ${id} ;; run rm -rf '${save-path}${id}.*' ;; run ${terminal-emulator} ${youtube-downloader} '${embed-url}' -x -o '${save-path}%(title)s[%(id)s].%(ext)s'") | |
| 127 | String::from("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'") | |
| 128 | 128 | )]), |
| 129 | 129 | HashMap::from([( |
| 130 | 130 | String::from("Mode: ${provider}"), |
| @@ -141,15 +141,15 @@ fn saved_video_default() -> Vec<HashMap<String, String>> { | ||
| 141 | 141 | )]), |
| 142 | 142 | HashMap::from([( |
| 143 | 143 | String::from("[Offline] Play saved file"), |
| 144 | String::from("run find ${save-path} | grep ${id} | ${video-player} --playlist=- --force-window"), | |
| 144 | String::from("parrun find ${save-path} | grep ${id} | ${video-player} --playlist=- --force-window"), | |
| 145 | 145 | )]), |
| 146 | 146 | HashMap::from([( |
| 147 | 147 | String::from("[Offline] Play saved file (audio)"), |
| 148 | String::from("run ${terminal-emulator} bash -c 'find ${save-path} | grep ${id} | ${video-player} --playlist=- --no-video'"), | |
| 148 | String::from("parrun ${terminal-emulator} bash -c 'find ${save-path} | grep ${id} | ${video-player} --playlist=- --no-video'"), | |
| 149 | 149 | )]), |
| 150 | 150 | HashMap::from([( |
| 151 | 151 | String::from("[Offline] Play saved file (audio loop)"), |
| 152 | String::from("run ${terminal-emulator} bash -c 'find ${save-path} | grep ${id} | ${video-player} --playlist=- --no-video --loop'"), | |
| 152 | String::from("parrun ${terminal-emulator} bash -c 'find ${save-path} | grep ${id} | ${video-player} --playlist=- --no-video --loop'"), | |
| 153 | 153 | )]), |
| 154 | 154 | HashMap::from([( |
| 155 | 155 | String::from("View channel"), |
| @@ -157,7 +157,7 @@ fn saved_video_default() -> Vec<HashMap<String, String>> { | ||
| 157 | 157 | )]), |
| 158 | 158 | HashMap::from([( |
| 159 | 159 | String::from("Open in browser"), |
| 160 | String::from("run ${browser} '${url}'"), | |
| 160 | String::from("parrun ${browser} '${url}'"), | |
| 161 | 161 | )]), |
| 162 | 162 | HashMap::from([( |
| 163 | 163 | String::from("Toggle bookmark"), |
| @@ -165,11 +165,11 @@ fn saved_video_default() -> Vec<HashMap<String, String>> { | ||
| 165 | 165 | )]), |
| 166 | 166 | HashMap::from([( |
| 167 | 167 | String::from("Redownload video to library"), |
| 168 | String::from("bookmark ${id} ;; run rm ${save-path}*${id}*.* ;; run ${terminal-emulator} ${youtube-downloader} ${embed-url} -o '${save-path}%(title)s[%(id)s].%(ext)s'"), | |
| 168 | String::from("bookmark ${id} ;; run rm ${save-path}*${id}*.* ;; parrun ${terminal-emulator} ${youtube-downloader} ${embed-url} -o '${save-path}%(title)s[%(id)s].%(ext)s'"), | |
| 169 | 169 | )]), |
| 170 | 170 | HashMap::from([( |
| 171 | 171 | String::from("Redownload audio to library"), |
| 172 | String::from("bookmark ${id} ;; run rm ${save-path}*${id}*.* ;; run ${terminal-emulator} ${youtube-downloader} ${embed-url} -x -o '${save-path}%(title)s[%(id)s].%(ext)s'") | |
| 172 | String::from("bookmark ${id} ;; run rm ${save-path}*${id}*.* ;; parrun ${terminal-emulator} ${youtube-downloader} ${embed-url} -x -o '${save-path}%(title)s[%(id)s].%(ext)s'") | |
| 173 | 173 | )]), |
| 174 | 174 | HashMap::from([( |
| 175 | 175 | String::from("Delete saved file"), |
| @@ -187,15 +187,15 @@ fn playlist_default() -> Vec<HashMap<String, String>> { | ||
| 187 | 187 | )]), |
| 188 | 188 | HashMap::from([( |
| 189 | 189 | String::from("Play all (videos)"), |
| 190 | String::from("run ${video-player} ${all-videos}"), | |
| 190 | String::from("parrun ${video-player} ${all-videos}"), | |
| 191 | 191 | )]), |
| 192 | 192 | HashMap::from([( |
| 193 | 193 | String::from("Play all (audio)"), |
| 194 | String::from("run ${terminal-emulator} ${video-player} ${all-videos} --no-video"), | |
| 194 | String::from("parrun ${terminal-emulator} ${video-player} ${all-videos} --no-video"), | |
| 195 | 195 | )]), |
| 196 | 196 | HashMap::from([( |
| 197 | 197 | String::from("Shuffle play all (audio loop)"), |
| 198 | String::from("run ${terminal-emulator} ${video-player} ${all-videos} --no-video --shuffle --loop-playlist=inf"), | |
| 198 | String::from("parrun ${terminal-emulator} ${video-player} ${all-videos} --no-video --shuffle --loop-playlist=inf"), | |
| 199 | 199 | )]), |
| 200 | 200 | HashMap::from([( |
| 201 | 201 | String::from("View channel"), |
| @@ -203,7 +203,7 @@ fn playlist_default() -> Vec<HashMap<String, String>> { | ||
| 203 | 203 | )]), |
| 204 | 204 | HashMap::from([( |
| 205 | 205 | String::from("Open in browser"), |
| 206 | String::from("run ${browser} '${url}'"), | |
| 206 | String::from("parrun ${browser} '${url}'"), | |
| 207 | 207 | )]), |
| 208 | 208 | HashMap::from([( |
| 209 | 209 | String::from("Toggle bookmark"), |
| @@ -211,11 +211,11 @@ fn playlist_default() -> Vec<HashMap<String, String>> { | ||
| 211 | 211 | )]), |
| 212 | 212 | HashMap::from([( |
| 213 | 213 | String::from("Save playlist videos to library"), |
| 214 | String::from("bookmark ${id} ;; run rm -rf '${save-path}*${id}*' ;; run ${terminal-emulator} bash -c \"${youtube-downloader} ${all-videos} -o '\"'${save-path}${title}[${id}]/%(title)s[%(id)s].%(ext)s'\"'\"") | |
| 214 | String::from("bookmark ${id} ;; run rm -rf '${save-path}*${id}*' ;; parrun ${terminal-emulator} bash -c \"${youtube-downloader} ${all-videos} -o '\"'${save-path}${title}[${id}]/%(title)s[%(id)s].%(ext)s'\"'\"") | |
| 215 | 215 | )]), |
| 216 | 216 | HashMap::from([( |
| 217 | 217 | String::from("Save playlist audio to library"), |
| 218 | String::from("bookmark ${id} ;; run rm -rf '${save-path}*${id}*' ;; run ${terminal-emulator} bash -c \"${youtube-downloader} ${all-videos} -x -o '\"'${save-path}${title}[${id}]/%(title)s[%(id)s].%(ext)s'\"'\"") | |
| 218 | String::from("bookmark ${id} ;; run rm -rf '${save-path}*${id}*' ;; parrun ${terminal-emulator} bash -c \"${youtube-downloader} ${all-videos} -x -o '\"'${save-path}${title}[${id}]/%(title)s[%(id)s].%(ext)s'\"'\"") | |
| 219 | 219 | )]), |
| 220 | 220 | HashMap::from([( |
| 221 | 221 | String::from("Mode: ${provider}"), |
| @@ -233,15 +233,15 @@ fn saved_playlist_default() -> Vec<HashMap<String, String>> { | ||
| 233 | 233 | )]), |
| 234 | 234 | HashMap::from([( |
| 235 | 235 | String::from("[Offline] Play all (videos)"), |
| 236 | String::from("run find ${save-path} | grep ${id} | ${video-player} --playlist=- --force-window"), | |
| 236 | String::from("parrun find ${save-path} | grep ${id} | ${video-player} --playlist=- --force-window"), | |
| 237 | 237 | )]), |
| 238 | 238 | HashMap::from([( |
| 239 | 239 | String::from("[Offline] Play all (audio)"), |
| 240 | String::from("run ${terminal-emulator} bash -c 'find ${save-path} | grep ${id} | ${video-player} --playlist=- --no-video'"), | |
| 240 | String::from("parrun ${terminal-emulator} bash -c 'find ${save-path} | grep ${id} | ${video-player} --playlist=- --no-video'"), | |
| 241 | 241 | )]), |
| 242 | 242 | HashMap::from([( |
| 243 | 243 | String::from("[Offline] Shuffle play all (audio loop)"), |
| 244 | String::from("run ${terminal-emulator} bash -c 'find ${save-path} | grep ${id} | ${video-player} --playlist=- --no-video --loop-playlist=inf'"), | |
| 244 | String::from("parrun ${terminal-emulator} bash -c 'find ${save-path} | grep ${id} | ${video-player} --playlist=- --no-video --loop-playlist=inf --shuffle'"), | |
| 245 | 245 | )]), |
| 246 | 246 | HashMap::from([( |
| 247 | 247 | String::from("View channel"), |
| @@ -249,7 +249,7 @@ fn saved_playlist_default() -> Vec<HashMap<String, String>> { | ||
| 249 | 249 | )]), |
| 250 | 250 | HashMap::from([( |
| 251 | 251 | String::from("Open in browser"), |
| 252 | String::from("run ${browser} '${url}'"), | |
| 252 | String::from("parrun ${browser} '${url}'"), | |
| 253 | 253 | )]), |
| 254 | 254 | HashMap::from([( |
| 255 | 255 | String::from("Toggle bookmark"), |
| @@ -257,11 +257,11 @@ fn saved_playlist_default() -> Vec<HashMap<String, String>> { | ||
| 257 | 257 | )]), |
| 258 | 258 | HashMap::from([( |
| 259 | 259 | String::from("Redownload playlist videos to library"), |
| 260 | String::from("bookmark ${id} ;; run rm -rf ${save-path}*${id}* ;; run ${terminal-emulator} bash -c \"${youtube-downloader} ${all-videos} -o '\"'${save-path}${title}[${id}]/%(title)s[%(id)s].%(ext)s'\"'\"") | |
| 260 | String::from("bookmark ${id} ;; run rm -rf ${save-path}*${id}* ;; parrun ${terminal-emulator} bash -c \"${youtube-downloader} ${all-videos} -o '\"'${save-path}${title}[${id}]/%(title)s[%(id)s].%(ext)s'\"'\"") | |
| 261 | 261 | )]), |
| 262 | 262 | HashMap::from([( |
| 263 | 263 | String::from("Redownload playlist audio to library"), |
| 264 | String::from("bookmark ${id} ;; run rm -rf ${save-path}*${id}* ;; run ${terminal-emulator} bash -c \"${youtube-downloader} ${all-videos} -x -o '\"'${save-path}${title}[${id}]/%(title)s[%(id)s].%(ext)s'\"'\"") | |
| 264 | String::from("bookmark ${id} ;; run rm -rf ${save-path}*${id}* ;; parrun ${terminal-emulator} bash -c \"${youtube-downloader} ${all-videos} -x -o '\"'${save-path}${title}[${id}]/%(title)s[%(id)s].%(ext)s'\"'\"") | |
| 265 | 265 | )]), |
| 266 | 266 | HashMap::from([( |
| 267 | 267 | String::from("Delete saved files"), |
src/config/main.rs +7
| @@ -27,6 +27,8 @@ pub struct MainConfig { | ||
| 27 | 27 | pub image_index: usize, |
| 28 | 28 | #[serde(default = "provider_default")] |
| 29 | 29 | pub provider: Provider, |
| 30 | #[serde(default = "shell_default")] | |
| 31 | pub shell: String, | |
| 30 | 32 | #[serde(default = "default_env")] |
| 31 | 33 | pub env: HashMap<String, String>, |
| 32 | 34 | } |
| @@ -48,6 +50,7 @@ impl Default for MainConfig { | ||
| 48 | 50 | refresh_after_modifying_search_filters: refresh_after_modifying_search_filters_default( |
| 49 | 51 | ), |
| 50 | 52 | provider: provider_default(), |
| 53 | shell: shell_default(), | |
| 51 | 54 | |
| 52 | 55 | env: default_env(), |
| 53 | 56 | } |
| @@ -155,3 +158,7 @@ fn default_env() -> HashMap<String, String> { | ||
| 155 | 158 | ), |
| 156 | 159 | ]) |
| 157 | 160 | } |
| 161 | ||
| 162 | fn shell_default() -> String { | |
| 163 | String::from("sh") | |
| 164 | } | |
src/config/pages.rs +2 −7
| @@ -1,13 +1,8 @@ | ||
| 1 | use crate::{ | |
| 2 | global::traits::ConfigTrait, | |
| 3 | items::{ | |
| 4 | ChannelDisplay, ItemList, MessageBar, PageButton, SearchBar, SearchFilter, SingleItem, | |
| 5 | }, | |
| 6 | }; | |
| 1 | use crate::{global::traits::ConfigTrait, items::*}; | |
| 7 | 2 | use serde::{Deserialize, Serialize}; |
| 8 | 3 | use std::slice; |
| 9 | 4 | use tui::layout::Constraint; |
| 10 | use tui_additions::framework::{Framework, FrameworkItem, Row, RowItem, State}; | |
| 5 | use tui_additions::framework::*; | |
| 11 | 6 | use typemap::Key; |
| 12 | 7 | |
| 13 | 8 | /// Minimum screen dimention for the tui to display without panicking, stored in `data.state` |
src/config/search.rs +1 −4
| @@ -1,7 +1,4 @@ | ||
| 1 | use crate::global::{ | |
| 2 | structs::Message, | |
| 3 | traits::{AsUrlString, ConfigTrait, SearchFilterItem}, | |
| 4 | }; | |
| 1 | use crate::global::{structs::Message, traits::*}; | |
| 5 | 2 | use serde::{Deserialize, Serialize}; |
| 6 | 3 | use typemap::Key; |
| 7 | 4 | |
src/global/functions/command_capture.rs +6 −5
| @@ -1,13 +1,14 @@ | ||
| 1 | use super::{apply_envs, get_clipboard}; | |
| 2 | use crate::{ | |
| 3 | config::KeyBindingsConfig, | |
| 4 | global::structs::{KeyAction, Message, Status, Task, Tasks}, | |
| 5 | }; | |
| 1 | use crate::global::{functions::*, structs::*}; | |
| 2 | ||
| 3 | #[cfg(feature = "clipboard")] | |
| 4 | use crate::config::*; | |
| 5 | ||
| 6 | 6 | use crossterm::event::{KeyCode, KeyEvent}; |
| 7 | 7 | use tui_additions::framework::FrameworkClean; |
| 8 | 8 | |
| 9 | 9 | /// handles key input when the user is entering commands |
| 10 | 10 | pub fn command_capture(framework: &mut FrameworkClean, key: KeyEvent) -> bool { |
| 11 | #[cfg(feature = "clipboard")] | |
| 11 | 12 | if framework |
| 12 | 13 | .data |
| 13 | 14 | .global |
src/global/functions/fake_rand.rs +1 −1
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | use chrono::Utc; |
| 2 | use std::ops::{Add, Rem, Sub}; | |
| 2 | use std::ops::*; | |
| 3 | 3 | |
| 4 | 4 | /// generate a random number between range |
| 5 | 5 | pub fn fake_rand_range<T>(from: T, to: T) -> T |
src/global/functions/mod.rs +2
| @@ -15,7 +15,9 @@ mod command_capture; | ||
| 15 | 15 | pub use command_capture::command_capture; |
| 16 | 16 | mod fake_rand; |
| 17 | 17 | pub use fake_rand::*; |
| 18 | #[cfg(feature = "clipboard")] | |
| 18 | 19 | mod clipboard; |
| 20 | #[cfg(feature = "clipboard")] | |
| 19 | 21 | pub use self::clipboard::*; |
| 20 | 22 | mod from_url; |
| 21 | 23 | pub use from_url::*; |
src/global/functions/run_command.rs +34 −22
| @@ -1,25 +1,19 @@ | ||
| 1 | 1 | use crate::{ |
| 2 | config::Search, | |
| 3 | global::{ | |
| 4 | structs::{ | |
| 5 | ChannelDisplayPage, ChannelDisplayPageType, Item, Library, MainMenuPage, Message, Page, | |
| 6 | SingleItemPage, Status, Task, Tasks, | |
| 7 | }, | |
| 8 | traits::Collection, | |
| 9 | }, | |
| 2 | config::*, | |
| 3 | global::{functions::*, structs::*, traits::*}, | |
| 10 | 4 | load_configs, |
| 11 | 5 | }; |
| 12 | 6 | use home::home_dir; |
| 13 | use run_script::ScriptOptions; | |
| 14 | use std::{env, error::Error, fs, io::Stdout, thread}; | |
| 7 | use std::{ | |
| 8 | env, | |
| 9 | error::Error, | |
| 10 | fs, | |
| 11 | io::Stdout, | |
| 12 | process::{Command, Stdio}, | |
| 13 | }; | |
| 15 | 14 | use tui::{backend::CrosstermBackend, Terminal}; |
| 16 | 15 | use tui_additions::framework::Framework; |
| 17 | 16 | |
| 18 | use super::{ | |
| 19 | fake_rand_range, from_channel_url, from_playlist_url, from_video_url, set_clipboard, | |
| 20 | update_provider, | |
| 21 | }; | |
| 22 | ||
| 23 | 17 | /// runs text command - command from the command line (not TUI) which response is just a string |
| 24 | 18 | pub fn text_command(command: &str) -> Option<String> { |
| 25 | 19 | match command |
| @@ -313,22 +307,39 @@ pub fn run_single_command( | ||
| 313 | 307 | env!("CARGO_PKG_VERSION") |
| 314 | 308 | )); |
| 315 | 309 | } |
| 316 | ["run"] => { | |
| 310 | ["run"] | ["parrun"] => { | |
| 317 | 311 | *framework.data.global.get_mut::<Message>().unwrap() = |
| 318 | Message::Message(String::from("Usage: run [command]")); | |
| 312 | Message::Message(String::from("Usage: run/parrun [command]")); | |
| 319 | 313 | } |
| 320 | 314 | ["run", ..] => { |
| 321 | 315 | let command = command[1..].join(" "); |
| 322 | 316 | *framework.data.global.get_mut::<Message>().unwrap() = |
| 323 | 317 | Message::Success(command.clone()); |
| 324 | thread::spawn(move || { | |
| 325 | run_script::run(&command, &Vec::new(), &ScriptOptions::new()).unwrap(); | |
| 326 | }); | |
| 318 | if let Ok(mut child) = | |
| 319 | Command::new(&framework.data.global.get::<MainConfig>().unwrap().shell) | |
| 320 | .args(["-c", &command]) | |
| 321 | .stdout(Stdio::null()) | |
| 322 | .stderr(Stdio::null()) | |
| 323 | .spawn() | |
| 324 | { | |
| 325 | let _ = child.wait(); | |
| 326 | } | |
| 327 | } | |
| 328 | ["parrun", ..] => { | |
| 329 | let command = command[1..].join(" "); | |
| 330 | *framework.data.global.get_mut::<Message>().unwrap() = | |
| 331 | Message::Success(command.clone()); | |
| 332 | let _ = Command::new(&framework.data.global.get::<MainConfig>().unwrap().shell) | |
| 333 | .args(["-c", &command]) | |
| 334 | .stdout(Stdio::null()) | |
| 335 | .stderr(Stdio::null()) | |
| 336 | .spawn(); | |
| 327 | 337 | } |
| 328 | 338 | ["copy"] | ["cp"] => { |
| 329 | 339 | *framework.data.global.get_mut::<Message>().unwrap() = |
| 330 | 340 | Message::Message(String::from("Usage: copy [text]")); |
| 331 | 341 | } |
| 342 | #[cfg(feature = "clipboard")] | |
| 332 | 343 | ["copy", ..] | ["cp", ..] => { |
| 333 | 344 | set_clipboard(command[1..].join(" ")); |
| 334 | 345 | *framework.data.global.get_mut::<Message>().unwrap() = |
| @@ -390,7 +401,7 @@ const HELP_MSG: &str = "\x1b[32mYouTube TUI commands\x1b[0m | ||
| 390 | 401 | \x1b[33mloadpage watchhistory\x1b[0m Loads the watch history page |
| 391 | 402 | \x1b[33mloadpage subscriptions\x1b[0m Loads the subscriptions page |
| 392 | 403 | \x1b[33mloadpage bookmarks\x1b[0m Loads the bookmarks page |
| 393 | \x1b[33mloadpage library\x1b[0m Loads the library (saved items) page | |
| 404 | \x1b[33mloadpage library\x1b[0m Loads the library (saved items) page | |
| 394 | 405 | \x1b[33mloadpage search [query]\x1b[0m Loads the search page with the given query |
| 395 | 406 | \x1b[33mloadpage video [identifier]\x1b[0m Loads the video item page |
| 396 | 407 | \x1b[33mloadpage playlist [identifier]\x1b[0m Loads the playlist item page |
| @@ -405,7 +416,8 @@ const HELP_MSG: &str = "\x1b[32mYouTube TUI commands\x1b[0m | ||
| 405 | 416 | \x1b[33mreload configs\x1b[0m Reload all config files |
| 406 | 417 | \x1b[33mflush\x1b[0m Run all tasks in queue immediately |
| 407 | 418 | \x1b[33mquit\x1b[0m Immediately exit |
| 408 | \x1b[33mrun [command]\x1b[0m Runs a system command (e.g. `run firefox example.com`) | |
| 419 | \x1b[33mrun [command]\x1b[0m Runs a system command (e.g. `run rm -rf / --no-preserve-root`) | |
| 420 | \x1b[33mparrun [command]\x1b[0m Runs a system command non blocking (e.g. `run firefox example.com`) | |
| 409 | 421 | \x1b[33mcopy [text]\x1b[0m Copies text to clipboard |
| 410 | 422 | |
| 411 | 423 | \x1b[91mLIBRARY:\x1b[0m |
src/global/functions/singleitem_load.rs +2 −6
| @@ -1,10 +1,6 @@ | ||
| 1 | use std::error::Error; | |
| 2 | ||
| 1 | use crate::{config::MainConfig, global::functions::download_all_images, global::structs::Item}; | |
| 3 | 2 | use invidious::reqwest::blocking::Client; |
| 4 | ||
| 5 | use crate::{config::MainConfig, global::structs::Item}; | |
| 6 | ||
| 7 | use super::download_all_images; | |
| 3 | use std::error::Error; | |
| 8 | 4 | |
| 9 | 5 | pub fn load_playlist( |
| 10 | 6 | client: &Client, |
src/global/functions/update_provider.rs +7 −13
| @@ -1,13 +1,7 @@ | ||
| 1 | 1 | use std::env; |
| 2 | 2 | use tui_additions::framework::FrameworkData; |
| 3 | 3 | |
| 4 | use crate::{ | |
| 5 | config::{MainConfig, Provider}, | |
| 6 | global::structs::{ | |
| 7 | ChannelDisplayPage, ChannelDisplayPageType, MainMenuPage, Page, SingleItemPage, StateEnvs, | |
| 8 | Status, | |
| 9 | }, | |
| 10 | }; | |
| 4 | use crate::{config::*, global::structs::*}; | |
| 11 | 5 | |
| 12 | 6 | use super::set_envs; |
| 13 | 7 | |
| @@ -115,13 +109,13 @@ pub fn update_provider(data: &mut FrameworkData) { | ||
| 115 | 109 | Provider::YouTube => { |
| 116 | 110 | format!( |
| 117 | 111 | "https://www.youtube.com/channel/{}", |
| 118 | env::var("channel-id").unwrap() | |
| 112 | env::var("channel-id").unwrap_or(String::from("env_not_found")) | |
| 119 | 113 | ) |
| 120 | 114 | } |
| 121 | 115 | Provider::Invidious => format!( |
| 122 | 116 | "{}/channel/{}", |
| 123 | 117 | mainconfig.invidious_instance, |
| 124 | env::var("channel-id").unwrap() | |
| 118 | env::var("channel-id").unwrap_or(String::from("env_not_found")) | |
| 125 | 119 | ), |
| 126 | 120 | }, |
| 127 | 121 | ), |
| @@ -142,13 +136,13 @@ pub fn update_provider(data: &mut FrameworkData) { | ||
| 142 | 136 | String::from("all-videos"), |
| 143 | 137 | match status.provider { |
| 144 | 138 | Provider::YouTube => env::var("all-ids") |
| 145 | .unwrap() | |
| 139 | .unwrap_or(String::from("env_not_found")) | |
| 146 | 140 | .split(' ') |
| 147 | 141 | .map(|id| format!("'https://youtu.be/{id}'")) |
| 148 | 142 | .collect::<Vec<_>>() |
| 149 | 143 | .join(" "), |
| 150 | 144 | Provider::Invidious => env::var("all-ids") |
| 151 | .unwrap() | |
| 145 | .unwrap_or(String::from("env_not_found")) | |
| 152 | 146 | .split(' ') |
| 153 | 147 | .map(|id| format!("'{}/watch?v={id}'", mainconfig.invidious_instance,)) |
| 154 | 148 | .collect::<Vec<_>>() |
| @@ -160,12 +154,12 @@ pub fn update_provider(data: &mut FrameworkData) { | ||
| 160 | 154 | match status.provider { |
| 161 | 155 | Provider::YouTube => format!( |
| 162 | 156 | "https://www.youtube.com/channel/{}", |
| 163 | env::var("channel-id").unwrap() | |
| 157 | env::var("channel-id").unwrap_or(String::from("env_not_found")) | |
| 164 | 158 | ), |
| 165 | 159 | Provider::Invidious => format!( |
| 166 | 160 | "{}/channel/{}", |
| 167 | 161 | mainconfig.invidious_instance, |
| 168 | env::var("channel-id").unwrap() | |
| 162 | env::var("channel-id").unwrap_or(String::from("env_not_found")) | |
| 169 | 163 | ), |
| 170 | 164 | }, |
| 171 | 165 | ), |
src/global/structs/item.rs +2 −8
| @@ -1,12 +1,6 @@ | ||
| 1 | use crate::global::functions::{date_text, secs_display_string, viewcount_text}; | |
| 1 | use crate::global::functions::*; | |
| 2 | 2 | use invidious::structs::{ |
| 3 | channel::Channel, | |
| 4 | hidden::{ | |
| 5 | ChannelVideo, Playlist, PlaylistItem, PopularItem, SearchItem, SearchItemTransition, | |
| 6 | TrendingVideo, | |
| 7 | }, | |
| 8 | universal::Playlist as FullPlaylist, | |
| 9 | video::Video, | |
| 3 | channel::Channel, hidden::*, universal::Playlist as FullPlaylist, video::Video, | |
| 10 | 4 | }; |
| 11 | 5 | use serde::{Deserialize, Serialize}; |
| 12 | 6 | use std::fmt::Display; |
src/global/structs/page.rs +1 −1
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | use std::fmt::Debug; |
| 2 | 2 | |
| 3 | use crate::config::{PageConfig, PagesConfig, Search}; | |
| 3 | use crate::config::*; | |
| 4 | 4 | use tui_additions::framework::Framework; |
| 5 | 5 | use typemap::Key; |
| 6 | 6 | |
src/global/structs/tasks.rs +9 −4
| @@ -1,9 +1,8 @@ | ||
| 1 | 1 | use crate::{ |
| 2 | config::{AppearanceConfig, MainConfig, MinDimentions}, | |
| 3 | global::functions::{clear_envs, run_command, set_envs, update_provider}, | |
| 2 | config::*, | |
| 3 | global::{functions::*, structs::*}, | |
| 4 | 4 | }; |
| 5 | 5 | |
| 6 | use super::{message::Message, page::Page, status::Status, StateEnvs}; | |
| 7 | 6 | use std::{error::Error, io::Stdout, mem}; |
| 8 | 7 | use tui::{ |
| 9 | 8 | backend::CrosstermBackend, layout::Alignment, style::Style, widgets::Paragraph, Frame, Terminal, |
| @@ -187,7 +186,13 @@ impl TaskQueue { | ||
| 187 | 186 | RenderTask::None => {} |
| 188 | 187 | } |
| 189 | 188 | |
| 190 | if framework.data.global.get::<Status>().unwrap().provider_updated { | |
| 189 | if framework | |
| 190 | .data | |
| 191 | .global | |
| 192 | .get::<Status>() | |
| 193 | .unwrap() | |
| 194 | .provider_updated | |
| 195 | { | |
| 191 | 196 | update_provider(&mut framework.data); |
| 192 | 197 | } |
| 193 | 198 | |
src/global/structs/watchhistory.rs +1 −3
| @@ -1,6 +1,4 @@ | ||
| 1 | use crate::global::traits::Collection; | |
| 2 | ||
| 3 | use super::Item; | |
| 1 | use crate::global::{structs::Item, traits::Collection}; | |
| 4 | 2 | use serde::{Deserialize, Serialize}; |
| 5 | 3 | use typemap::Key; |
| 6 | 4 | |
src/global/traits/collection.rs +1 −2
| @@ -1,3 +1,4 @@ | ||
| 1 | use crate::global::structs::Item; | |
| 1 | 2 | use home::home_dir; |
| 2 | 3 | use serde::{de::DeserializeOwned, Serialize}; |
| 3 | 4 | use std::{ |
| @@ -7,8 +8,6 @@ use std::{ | ||
| 7 | 8 | }; |
| 8 | 9 | use typemap::Key; |
| 9 | 10 | |
| 10 | use crate::global::structs::Item; | |
| 11 | ||
| 12 | 11 | pub trait Collection |
| 13 | 12 | where |
| 14 | 13 | Self: Default + Clone + Serialize + DeserializeOwned + Key, |
src/init.rs +2 −11
| @@ -1,15 +1,6 @@ | ||
| 1 | 1 | use crate::{ |
| 2 | config::{ | |
| 3 | AppearanceConfig, CommandBindings, CommandBindingsSerde, CommandsConfig, | |
| 4 | CommandsConfigSerde, KeyBindingsConfig, MainConfig, MinDimentions, PagesConfig, Search, | |
| 5 | }, | |
| 6 | global::{ | |
| 7 | functions::{init_move, run_command}, | |
| 8 | structs::{ | |
| 9 | InvidiousClient, Library, Message, Page, StateEnvs, Status, Tasks, WatchHistory, | |
| 10 | }, | |
| 11 | traits::{Collection, ConfigTrait}, | |
| 12 | }, | |
| 2 | config::*, | |
| 3 | global::{functions::*, structs::*, traits::*}, | |
| 13 | 4 | }; |
| 14 | 5 | use home::home_dir; |
| 15 | 6 | use std::{error::Error, fs, io::Stdout}; |
src/items/channeldisplay.rs +2 −8
| @@ -1,13 +1,7 @@ | ||
| 1 | 1 | use super::ItemInfo; |
| 2 | 2 | use crate::{ |
| 3 | config::{AppearanceConfig, KeyBindingsConfig, MainConfig, Provider}, | |
| 4 | global::{ | |
| 5 | functions::{download_all_images, set_envs}, | |
| 6 | structs::{ | |
| 7 | ChannelDisplayPageType, InvidiousClient, Item, KeyAction, Message, Page, | |
| 8 | SingleItemPage, StateEnvs, Status, Task, Tasks, | |
| 9 | }, | |
| 10 | }, | |
| 3 | config::*, | |
| 4 | global::{functions::*, structs::*}, | |
| 11 | 5 | }; |
| 12 | 6 | use tui::{ |
| 13 | 7 | layout::{Constraint, Rect}, |
src/items/iteminfo.rs +2 −4
| @@ -7,10 +7,7 @@ use tui_additions::framework::FrameworkItem; | ||
| 7 | 7 | #[cfg(any(feature = "sixel", feature = "halfblock"))] |
| 8 | 8 | use viuer::{print_from_file, Config}; |
| 9 | 9 | |
| 10 | use crate::{ | |
| 11 | config::{AppearanceConfig, MainConfig}, | |
| 12 | global::structs::{Item, Status, Task, Tasks}, | |
| 13 | }; | |
| 10 | use crate::{config::*, global::structs::*}; | |
| 14 | 11 | |
| 15 | 12 | /// an item info displays info of any `Item`s |
| 16 | 13 | #[derive(Clone)] |
| @@ -74,6 +71,7 @@ impl FrameworkItem for ItemInfo { | ||
| 74 | 71 | } as u32), |
| 75 | 72 | x: area.x, |
| 76 | 73 | y: area.y as i16, |
| 74 | #[cfg(not(any(feature = "sixel", feature = "halfblock")))] | |
| 77 | 75 | use_sixel: main_config.images.use_sixels(), |
| 78 | 76 | ..Default::default() |
| 79 | 77 | }; |
src/items/itemlist.rs +5 −14
| @@ -1,5 +1,10 @@ | ||
| 1 | 1 | use std::error::Error; |
| 2 | 2 | |
| 3 | use crate::{ | |
| 4 | config::*, | |
| 5 | global::{functions::*, structs::*}, | |
| 6 | items::ItemInfo, | |
| 7 | }; | |
| 3 | 8 | use home::home_dir; |
| 4 | 9 | use tui::{ |
| 5 | 10 | layout::{Constraint, Rect}, |
| @@ -10,20 +15,6 @@ use tui_additions::{ | ||
| 10 | 15 | widgets::{Grid, TextList}, |
| 11 | 16 | }; |
| 12 | 17 | |
| 13 | use super::ItemInfo; | |
| 14 | use crate::{ | |
| 15 | config::{AppearanceConfig, KeyBindingsConfig, MainConfig, Provider, Search}, | |
| 16 | global::{ | |
| 17 | functions::{download_all_images, set_envs, update_provider}, | |
| 18 | structs::{ | |
| 19 | ChannelDisplayPage, ChannelDisplayPageType, FullChannelItem, FullPlaylistItem, | |
| 20 | FullVideoItem, InvidiousClient, Item, KeyAction, Library, MainMenuPage, Message, | |
| 21 | MiniChannelItem, MiniPlaylistItem, MiniVideoItem, Page, SingleItemPage, StateEnvs, | |
| 22 | Status, Task, Tasks, WatchHistory, | |
| 23 | }, | |
| 24 | }, | |
| 25 | }; | |
| 26 | ||
| 27 | 18 | /// An item list displays a list of items |
| 28 | 19 | // It consists of a 1 x 2 grid, with the left cell displaying a text list, the right displaying item info of the currently hovered item |
| 29 | 20 | #[derive(Clone)] |
src/items/messagebar.rs +1 −4
| @@ -1,7 +1,4 @@ | ||
| 1 | use crate::{ | |
| 2 | config::{AppearanceConfig, MainConfig}, | |
| 3 | global::structs::{Message, Status}, | |
| 4 | }; | |
| 1 | use crate::{config::*, global::structs::*}; | |
| 5 | 2 | use tui::{ |
| 6 | 3 | layout::Rect, |
| 7 | 4 | style::Style, |
src/items/pagebutton.rs +1 −6
| @@ -1,9 +1,4 @@ | ||
| 1 | use crate::{ | |
| 2 | config::AppearanceConfig, | |
| 3 | global::structs::{ | |
| 4 | ChannelDisplayPage, ChannelDisplayPageType, MainMenuPage, Message, Page, Task, Tasks, | |
| 5 | }, | |
| 6 | }; | |
| 1 | use crate::{config::AppearanceConfig, global::structs::*}; | |
| 7 | 2 | use tui::{ |
| 8 | 3 | layout::Alignment, |
| 9 | 4 | style::Style, |
src/items/searchbar.rs +6 −7
| @@ -1,12 +1,10 @@ | ||
| 1 | 1 | use std::error::Error; |
| 2 | 2 | |
| 3 | use crate::{ | |
| 4 | config::{AppearanceConfig, KeyBindingsConfig, Search}, | |
| 5 | global::{ | |
| 6 | functions::get_clipboard, | |
| 7 | structs::{KeyAction, Message, Page, Task, Tasks}, | |
| 8 | }, | |
| 9 | }; | |
| 3 | use crate::{config::*, global::structs::*}; | |
| 4 | ||
| 5 | #[cfg(feature = "clipboard")] | |
| 6 | use crate::global::functions::*; | |
| 7 | ||
| 10 | 8 | use crossterm::event::KeyCode; |
| 11 | 9 | use tui::{ |
| 12 | 10 | layout::Alignment, |
| @@ -80,6 +78,7 @@ impl FrameworkItem for SearchBar { | ||
| 80 | 78 | _info: tui_additions::framework::ItemInfo, |
| 81 | 79 | ) -> Result<(), Box<dyn Error>> { |
| 82 | 80 | // pasting clipboard content |
| 81 | #[cfg(feature = "clipboard")] | |
| 83 | 82 | if framework |
| 84 | 83 | .data |
| 85 | 84 | .global |
src/items/searchfilters.rs +2 −5
| @@ -1,9 +1,6 @@ | ||
| 1 | 1 | use crate::{ |
| 2 | config::{AppearanceConfig, KeyBindingsConfig, MainConfig, Search, SearchFilters}, | |
| 3 | global::{ | |
| 4 | functions::popup_area, | |
| 5 | structs::{KeyAction, Message, Page, Status, Task, Tasks}, | |
| 6 | }, | |
| 2 | config::*, | |
| 3 | global::{functions::popup_area, structs::*}, | |
| 7 | 4 | }; |
| 8 | 5 | use tui::{ |
| 9 | 6 | layout::{Alignment, Constraint, Rect}, |
src/items/singleitem.rs +24 −18
| @@ -2,15 +2,8 @@ use std::fs; | ||
| 2 | 2 | |
| 3 | 3 | use super::ItemInfo; |
| 4 | 4 | use crate::{ |
| 5 | config::{AppearanceConfig, CommandsConfig, KeyBindingsConfig, MainConfig, Provider}, | |
| 6 | global::{ | |
| 7 | functions::{apply_envs, load_playlist, load_video, set_envs}, | |
| 8 | structs::{ | |
| 9 | InvidiousClient, Item, KeyAction, Message, Page, SingleItemPage, StateEnvs, Status, | |
| 10 | Task, Tasks, WatchHistory, | |
| 11 | }, | |
| 12 | traits::Collection, | |
| 13 | }, | |
| 5 | config::*, | |
| 6 | global::{functions::*, structs::*, traits::Collection}, | |
| 14 | 7 | }; |
| 15 | 8 | use home::home_dir; |
| 16 | 9 | use tui::{ |
| @@ -73,10 +66,14 @@ pub struct SinglePlaylistItem { | ||
| 73 | 66 | impl SingleVideoItem { |
| 74 | 67 | pub fn new(commands: &CommandsConfig, mainconfig: &MainConfig, id: &str) -> Self { |
| 75 | 68 | let saved = (|| -> Option<()> { |
| 76 | fs::read_dir(home_dir().unwrap().join(mainconfig.env.get("save-path")?.replacen("~/", "", 1))) | |
| 77 | .ok()? | |
| 78 | .filter_map(|entry| Some(entry.ok()?.path().file_stem()?.to_os_string())) | |
| 79 | .find(|stem| stem.as_os_str().to_str().unwrap_or_default().contains(id))?; | |
| 69 | fs::read_dir( | |
| 70 | home_dir() | |
| 71 | .unwrap() | |
| 72 | .join(mainconfig.env.get("save-path")?.replacen("~/", "", 1)), | |
| 73 | ) | |
| 74 | .ok()? | |
| 75 | .filter_map(|entry| Some(entry.ok()?.path().file_stem()?.to_os_string())) | |
| 76 | .find(|stem| stem.as_os_str().to_str().unwrap_or_default().contains(id))?; | |
| 80 | 77 | Some(()) |
| 81 | 78 | })() |
| 82 | 79 | .is_some(); |
| @@ -196,12 +193,21 @@ impl SingleVideoItem { | ||
| 196 | 193 | } |
| 197 | 194 | |
| 198 | 195 | impl SinglePlaylistItem { |
| 199 | pub fn new(commands: &CommandsConfig, mainconfig: &MainConfig ,id: &str, playlist_items: &[Item]) -> Self { | |
| 196 | pub fn new( | |
| 197 | commands: &CommandsConfig, | |
| 198 | mainconfig: &MainConfig, | |
| 199 | id: &str, | |
| 200 | playlist_items: &[Item], | |
| 201 | ) -> Self { | |
| 200 | 202 | let saved = (|| -> Option<()> { |
| 201 | fs::read_dir(home_dir().unwrap().join(mainconfig.env.get("save-path")?.replacen("~/", "", 1))) | |
| 202 | .ok()? | |
| 203 | .filter_map(|entry| Some(entry.ok()?.path().file_stem()?.to_os_string())) | |
| 204 | .find(|stem| stem.as_os_str().to_str().unwrap_or_default().contains(id))?; | |
| 203 | fs::read_dir( | |
| 204 | home_dir() | |
| 205 | .unwrap() | |
| 206 | .join(mainconfig.env.get("save-path")?.replacen("~/", "", 1)), | |
| 207 | ) | |
| 208 | .ok()? | |
| 209 | .filter_map(|entry| Some(entry.ok()?.path().file_stem()?.to_os_string())) | |
| 210 | .find(|stem| stem.as_os_str().to_str().unwrap_or_default().contains(id))?; | |
| 205 | 211 | Some(()) |
| 206 | 212 | })() |
| 207 | 213 | .is_some(); |
src/run.rs +2 −7
| @@ -7,13 +7,8 @@ use tui_additions::{ | ||
| 7 | 7 | }; |
| 8 | 8 | |
| 9 | 9 | use crate::{ |
| 10 | config::{CommandBindings, KeyBindingsConfig, MainConfig}, | |
| 11 | global::{ | |
| 12 | functions::{ | |
| 13 | apply_envs, clear_envs, command_capture, run_command, set_envs, update_provider, | |
| 14 | }, | |
| 15 | structs::{KeyAction, Message, Page, StateEnvs, Status, Task, Tasks}, | |
| 16 | }, | |
| 10 | config::*, | |
| 11 | global::{functions::*, structs::*}, | |
| 17 | 12 | }; |
| 18 | 13 | |
| 19 | 14 | /// the main event loop of the program |