Commit 05e733814a

05e733814a2b6d4636fc6fed63ce4b1544b8310b

parent: f7dc24b611

Unsigned

Siriusmart <71584876+Siriusmart@users.noreply.github.com> · 2022-10-22 19:48 UTC

Bug fixes & slight progress on video and playlist info page

Fixed Grid incorrect width (cause panicks and misalignments)
Fixed first history is blank issue
Using updated invidious api
Slight progress on video/playlist page

Layout: unified · split

Cargo.lock +272 −237
@@ -8,15 +8,6 @@ version = "1.0.2"
88source = "registry+https://github.com/rust-lang/crates.io-index"
99checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
1010
11[[package]]
12name = "aho-corasick"
13version = "0.5.3"
14source = "registry+https://github.com/rust-lang/crates.io-index"
15checksum = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66"
16dependencies = [
17 "memchr 0.1.11",
18]
19
2011[[package]]
2112name = "android_system_properties"
2213version = "0.1.5"
@@ -43,9 +34,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
4334
4435[[package]]
4536name = "base64"
46version = "0.13.0"
37version = "0.13.1"
4738source = "registry+https://github.com/rust-lang/crates.io-index"
48checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
39checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
4940
5041[[package]]
5142name = "bit_field"
@@ -61,9 +52,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
6152
6253[[package]]
6354name = "bumpalo"
64version = "3.11.0"
55version = "3.11.1"
6556source = "registry+https://github.com/rust-lang/crates.io-index"
66checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d"
57checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba"
6758
6859[[package]]
6960name = "bytemuck"
@@ -110,7 +101,17 @@ dependencies = [
110101 "iana-time-zone",
111102 "num-integer",
112103 "num-traits",
113 "winapi 0.3.9",
104 "winapi",
105]
106
107[[package]]
108name = "codespan-reporting"
109version = "0.11.1"
110source = "registry+https://github.com/rust-lang/crates.io-index"
111checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e"
112dependencies = [
113 "termcolor",
114 "unicode-width",
114115]
115116
116117[[package]]
@@ -121,15 +122,15 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
121122
122123[[package]]
123124name = "console"
124version = "0.15.1"
125version = "0.15.2"
125126source = "registry+https://github.com/rust-lang/crates.io-index"
126checksum = "89eab4d20ce20cea182308bca13088fecea9c05f6776cf287205d41a0ed3c847"
127checksum = "c050367d967ced717c04b65d8c619d863ef9292ce0c5760028655a2fb298718c"
127128dependencies = [
128129 "encode_unicode",
130 "lazy_static",
129131 "libc",
130 "once_cell",
131132 "terminal_size",
132 "winapi 0.3.9",
133 "winapi",
133134]
134135
135136[[package]]
@@ -180,42 +181,24 @@ dependencies = [
180181
181182[[package]]
182183name = "crossbeam-epoch"
183version = "0.9.10"
184version = "0.9.11"
184185source = "registry+https://github.com/rust-lang/crates.io-index"
185checksum = "045ebe27666471bb549370b4b0b3e51b07f56325befa4284db65fc89c02511b1"
186checksum = "f916dfc5d356b0ed9dae65f1db9fc9770aa2851d2662b988ccf4fe3516e86348"
186187dependencies = [
187188 "autocfg",
188189 "cfg-if",
189190 "crossbeam-utils",
190191 "memoffset",
191 "once_cell",
192192 "scopeguard",
193193]
194194
195195[[package]]
196196name = "crossbeam-utils"
197version = "0.8.11"
197version = "0.8.12"
198198source = "registry+https://github.com/rust-lang/crates.io-index"
199checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc"
199checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac"
200200dependencies = [
201201 "cfg-if",
202 "once_cell",
203]
204
205[[package]]
206name = "crossterm"
207version = "0.23.2"
208source = "registry+https://github.com/rust-lang/crates.io-index"
209checksum = "a2102ea4f781910f8a5b98dd061f4c2023f479ce7bb1236330099ceb5a93cf17"
210dependencies = [
211 "bitflags",
212 "crossterm_winapi",
213 "libc",
214 "mio",
215 "parking_lot",
216 "signal-hook",
217 "signal-hook-mio",
218 "winapi 0.3.9",
219202]
220203
221204[[package]]
@@ -232,7 +215,7 @@ dependencies = [
232215 "serde",
233216 "signal-hook",
234217 "signal-hook-mio",
235 "winapi 0.3.9",
218 "winapi",
236219]
237220
238221[[package]]
@@ -241,7 +224,57 @@ version = "0.9.0"
241224source = "registry+https://github.com/rust-lang/crates.io-index"
242225checksum = "2ae1b35a484aa10e07fe0638d02301c5ad24de82d310ccbd2f3693da5f09bf1c"
243226dependencies = [
244 "winapi 0.3.9",
227 "winapi",
228]
229
230[[package]]
231name = "crunchy"
232version = "0.2.2"
233source = "registry+https://github.com/rust-lang/crates.io-index"
234checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
235
236[[package]]
237name = "cxx"
238version = "1.0.80"
239source = "registry+https://github.com/rust-lang/crates.io-index"
240checksum = "6b7d4e43b25d3c994662706a1d4fcfc32aaa6afd287502c111b237093bb23f3a"
241dependencies = [
242 "cc",
243 "cxxbridge-flags",
244 "cxxbridge-macro",
245 "link-cplusplus",
246]
247
248[[package]]
249name = "cxx-build"
250version = "1.0.80"
251source = "registry+https://github.com/rust-lang/crates.io-index"
252checksum = "84f8829ddc213e2c1368e51a2564c552b65a8cb6a28f31e576270ac81d5e5827"
253dependencies = [
254 "cc",
255 "codespan-reporting",
256 "once_cell",
257 "proc-macro2",
258 "quote",
259 "scratch",
260 "syn",
261]
262
263[[package]]
264name = "cxxbridge-flags"
265version = "1.0.80"
266source = "registry+https://github.com/rust-lang/crates.io-index"
267checksum = "e72537424b474af1460806647c41d4b6d35d09ef7fe031c5c2fa5766047cc56a"
268
269[[package]]
270name = "cxxbridge-macro"
271version = "1.0.80"
272source = "registry+https://github.com/rust-lang/crates.io-index"
273checksum = "309e4fb93eed90e1e14bea0da16b209f81813ba9fc7830c20ed151dd7bc0a4d7"
274dependencies = [
275 "proc-macro2",
276 "quote",
277 "syn",
245278]
246279
247280[[package]]
@@ -273,15 +306,15 @@ dependencies = [
273306
274307[[package]]
275308name = "exr"
276version = "1.5.1"
309version = "1.5.2"
277310source = "registry+https://github.com/rust-lang/crates.io-index"
278checksum = "c9a7880199e74c6d3fe45579df2f436c5913a71405494cb89d59234d86b47dc5"
311checksum = "8eb5f255b5980bb0c8cf676b675d1a99be40f316881444f44e0462eaf5df5ded"
279312dependencies = [
280313 "bit_field",
281314 "flume",
282315 "half",
283316 "lebe",
284 "miniz_oxide",
317 "miniz_oxide 0.6.2",
285318 "smallvec",
286319 "threadpool",
287320]
@@ -302,7 +335,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
302335checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6"
303336dependencies = [
304337 "crc32fast",
305 "miniz_oxide",
338 "miniz_oxide 0.5.4",
306339]
307340
308341[[package]]
@@ -350,9 +383,9 @@ dependencies = [
350383
351384[[package]]
352385name = "futures"
353version = "0.3.24"
386version = "0.3.25"
354387source = "registry+https://github.com/rust-lang/crates.io-index"
355checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c"
388checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0"
356389dependencies = [
357390 "futures-channel",
358391 "futures-core",
@@ -365,9 +398,9 @@ dependencies = [
365398
366399[[package]]
367400name = "futures-channel"
368version = "0.3.24"
401version = "0.3.25"
369402source = "registry+https://github.com/rust-lang/crates.io-index"
370checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050"
403checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed"
371404dependencies = [
372405 "futures-core",
373406 "futures-sink",
@@ -375,15 +408,15 @@ dependencies = [
375408
376409[[package]]
377410name = "futures-core"
378version = "0.3.24"
411version = "0.3.25"
379412source = "registry+https://github.com/rust-lang/crates.io-index"
380checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf"
413checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac"
381414
382415[[package]]
383416name = "futures-executor"
384version = "0.3.24"
417version = "0.3.25"
385418source = "registry+https://github.com/rust-lang/crates.io-index"
386checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab"
419checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2"
387420dependencies = [
388421 "futures-core",
389422 "futures-task",
@@ -392,15 +425,15 @@ dependencies = [
392425
393426[[package]]
394427name = "futures-io"
395version = "0.3.24"
428version = "0.3.25"
396429source = "registry+https://github.com/rust-lang/crates.io-index"
397checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68"
430checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb"
398431
399432[[package]]
400433name = "futures-macro"
401version = "0.3.24"
434version = "0.3.25"
402435source = "registry+https://github.com/rust-lang/crates.io-index"
403checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17"
436checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d"
404437dependencies = [
405438 "proc-macro2",
406439 "quote",
@@ -409,21 +442,21 @@ dependencies = [
409442
410443[[package]]
411444name = "futures-sink"
412version = "0.3.24"
445version = "0.3.25"
413446source = "registry+https://github.com/rust-lang/crates.io-index"
414checksum = "21b20ba5a92e727ba30e72834706623d94ac93a725410b6a6b6fbc1b07f7ba56"
447checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9"
415448
416449[[package]]
417450name = "futures-task"
418version = "0.3.24"
451version = "0.3.25"
419452source = "registry+https://github.com/rust-lang/crates.io-index"
420checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1"
453checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea"
421454
422455[[package]]
423456name = "futures-util"
424version = "0.3.24"
457version = "0.3.25"
425458source = "registry+https://github.com/rust-lang/crates.io-index"
426checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90"
459checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6"
427460dependencies = [
428461 "futures-channel",
429462 "futures-core",
@@ -431,7 +464,7 @@ dependencies = [
431464 "futures-macro",
432465 "futures-sink",
433466 "futures-task",
434 "memchr 2.5.0",
467 "memchr",
435468 "pin-project-lite",
436469 "pin-utils",
437470 "slab",
@@ -439,9 +472,9 @@ dependencies = [
439472
440473[[package]]
441474name = "getrandom"
442version = "0.2.7"
475version = "0.2.8"
443476source = "registry+https://github.com/rust-lang/crates.io-index"
444checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6"
477checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
445478dependencies = [
446479 "cfg-if",
447480 "js-sys",
@@ -481,9 +514,12 @@ dependencies = [
481514
482515[[package]]
483516name = "half"
484version = "1.8.2"
517version = "2.1.0"
485518source = "registry+https://github.com/rust-lang/crates.io-index"
486checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
519checksum = "ad6a9459c9c30b177b925162351f97e7d967c7ea8bab3b8352805327daf45554"
520dependencies = [
521 "crunchy",
522]
487523
488524[[package]]
489525name = "hashbrown"
@@ -502,11 +538,11 @@ dependencies = [
502538
503539[[package]]
504540name = "home"
505version = "0.5.3"
541version = "0.5.4"
506542source = "registry+https://github.com/rust-lang/crates.io-index"
507checksum = "2456aef2e6b6a9784192ae780c0f15bc57df0e918585282325e8c8ac27737654"
543checksum = "747309b4b440c06d57b0b25f2aee03ee9b5e5397d288c60e21fc709bb98a7408"
508544dependencies = [
509 "winapi 0.3.9",
545 "winapi",
510546]
511547
512548[[package]]
@@ -582,15 +618,26 @@ dependencies = [
582618
583619[[package]]
584620name = "iana-time-zone"
585version = "0.1.50"
621version = "0.1.51"
586622source = "registry+https://github.com/rust-lang/crates.io-index"
587checksum = "fd911b35d940d2bd0bea0f9100068e5b97b51a1cbe13d13382f132e0365257a0"
623checksum = "f5a6ef98976b22b3b7f2f3a806f858cb862044cfa66805aa3ad84cb3d3b785ed"
588624dependencies = [
589625 "android_system_properties",
590626 "core-foundation-sys",
627 "iana-time-zone-haiku",
591628 "js-sys",
592629 "wasm-bindgen",
593 "winapi 0.3.9",
630 "winapi",
631]
632
633[[package]]
634name = "iana-time-zone-haiku"
635version = "0.1.1"
636source = "registry+https://github.com/rust-lang/crates.io-index"
637checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca"
638dependencies = [
639 "cxx",
640 "cxx-build",
594641]
595642
596643[[package]]
@@ -605,9 +652,9 @@ dependencies = [
605652
606653[[package]]
607654name = "image"
608version = "0.24.3"
655version = "0.24.4"
609656source = "registry+https://github.com/rust-lang/crates.io-index"
610checksum = "7e30ca2ecf7666107ff827a8e481de6a132a9b687ed3bb20bb1c144a36c00964"
657checksum = "bd8e4fb07cf672b1642304e731ef8a6a4c7891d67bb4fd4f5ce58cd6ed86803c"
611658dependencies = [
612659 "bytemuck",
613660 "byteorder",
@@ -643,9 +690,9 @@ dependencies = [
643690
644691[[package]]
645692name = "invidious"
646version = "0.3.2"
693version = "0.4.0"
647694source = "registry+https://github.com/rust-lang/crates.io-index"
648checksum = "c0768e9ab3b6d2f3ce235e6c85167d3e78cde11fb08c0811c5f320c6f5a4834e"
695checksum = "f6a0c87f44203986f9b402ef0409c1c776c5229d09be2a85cda5b53a23ba0757"
649696dependencies = [
650697 "reqwest",
651698 "serde",
@@ -660,9 +707,9 @@ checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b"
660707
661708[[package]]
662709name = "itoa"
663version = "1.0.3"
710version = "1.0.4"
664711source = "registry+https://github.com/rust-lang/crates.io-index"
665checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754"
712checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc"
666713
667714[[package]]
668715name = "jpeg-decoder"
@@ -682,22 +729,6 @@ dependencies = [
682729 "wasm-bindgen",
683730]
684731
685[[package]]
686name = "kernel32-sys"
687version = "0.2.2"
688source = "registry+https://github.com/rust-lang/crates.io-index"
689checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
690dependencies = [
691 "winapi 0.2.8",
692 "winapi-build",
693]
694
695[[package]]
696name = "lazy_static"
697version = "0.2.11"
698source = "registry+https://github.com/rust-lang/crates.io-index"
699checksum = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73"
700
701732[[package]]
702733name = "lazy_static"
703734version = "1.4.0"
@@ -712,9 +743,18 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
712743
713744[[package]]
714745name = "libc"
715version = "0.2.133"
746version = "0.2.135"
747source = "registry+https://github.com/rust-lang/crates.io-index"
748checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c"
749
750[[package]]
751name = "link-cplusplus"
752version = "1.0.7"
716753source = "registry+https://github.com/rust-lang/crates.io-index"
717checksum = "c0f80d65747a3e43d1596c7c5492d95d5edddaabd45a7fcdb02b95f644164966"
754checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369"
755dependencies = [
756 "cc",
757]
718758
719759[[package]]
720760name = "lock_api"
@@ -741,15 +781,6 @@ version = "0.1.0"
741781source = "registry+https://github.com/rust-lang/crates.io-index"
742782checksum = "a8ca8afbe8af1785e09636acb5a41e08a765f5f0340568716c18a8700ba3c0d3"
743783
744[[package]]
745name = "memchr"
746version = "0.1.11"
747source = "registry+https://github.com/rust-lang/crates.io-index"
748checksum = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20"
749dependencies = [
750 "libc",
751]
752
753784[[package]]
754785name = "memchr"
755786version = "2.5.0"
@@ -780,6 +811,15 @@ dependencies = [
780811 "adler",
781812]
782813
814[[package]]
815name = "miniz_oxide"
816version = "0.6.2"
817source = "registry+https://github.com/rust-lang/crates.io-index"
818checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa"
819dependencies = [
820 "adler",
821]
822
783823[[package]]
784824name = "mio"
785825version = "0.8.4"
@@ -789,7 +829,7 @@ dependencies = [
789829 "libc",
790830 "log",
791831 "wasi",
792 "windows-sys",
832 "windows-sys 0.36.1",
793833]
794834
795835[[package]]
@@ -807,7 +847,7 @@ version = "0.2.10"
807847source = "registry+https://github.com/rust-lang/crates.io-index"
808848checksum = "fd7e2f3618557f980e0b17e8856252eee3c97fa12c54dff0ca290fb6266ca4a9"
809849dependencies = [
810 "lazy_static 1.4.0",
850 "lazy_static",
811851 "libc",
812852 "log",
813853 "openssl",
@@ -867,9 +907,9 @@ checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1"
867907
868908[[package]]
869909name = "openssl"
870version = "0.10.41"
910version = "0.10.42"
871911source = "registry+https://github.com/rust-lang/crates.io-index"
872checksum = "618febf65336490dfcf20b73f885f5651a0c89c64c2d4a8c3662585a70bf5bd0"
912checksum = "12fc0523e3bd51a692c8850d075d74dc062ccf251c0110668cbd921917118a13"
873913dependencies = [
874914 "bitflags",
875915 "cfg-if",
@@ -899,9 +939,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
899939
900940[[package]]
901941name = "openssl-sys"
902version = "0.9.75"
942version = "0.9.77"
903943source = "registry+https://github.com/rust-lang/crates.io-index"
904checksum = "e5f9bd0c2710541a3cda73d6f9ac4f1b240de4ae261065d309dbe73d9dceb42f"
944checksum = "b03b84c3b2d099b81f0953422b4d4ad58761589d0229b5506356afca05a3670a"
905945dependencies = [
906946 "autocfg",
907947 "cc",
@@ -922,15 +962,15 @@ dependencies = [
922962
923963[[package]]
924964name = "parking_lot_core"
925version = "0.9.3"
965version = "0.9.4"
926966source = "registry+https://github.com/rust-lang/crates.io-index"
927checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929"
967checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0"
928968dependencies = [
929969 "cfg-if",
930970 "libc",
931971 "redox_syscall",
932972 "smallvec",
933 "windows-sys",
973 "windows-sys 0.42.0",
934974]
935975
936976[[package]]
@@ -986,14 +1026,14 @@ dependencies = [
9861026 "bitflags",
9871027 "crc32fast",
9881028 "flate2",
989 "miniz_oxide",
1029 "miniz_oxide 0.5.4",
9901030]
9911031
9921032[[package]]
9931033name = "proc-macro2"
994version = "1.0.44"
1034version = "1.0.47"
9951035source = "registry+https://github.com/rust-lang/crates.io-index"
996checksum = "7bd7356a8122b6c4a24a82b278680c73357984ca2fc79a0f9fa6dea7dced7c58"
1036checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
9971037dependencies = [
9981038 "unicode-ident",
9991039]
@@ -1040,32 +1080,13 @@ dependencies = [
10401080 "bitflags",
10411081]
10421082
1043[[package]]
1044name = "regex"
1045version = "0.1.80"
1046source = "registry+https://github.com/rust-lang/crates.io-index"
1047checksum = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f"
1048dependencies = [
1049 "aho-corasick",
1050 "memchr 0.1.11",
1051 "regex-syntax",
1052 "thread_local",
1053 "utf8-ranges",
1054]
1055
1056[[package]]
1057name = "regex-syntax"
1058version = "0.3.9"
1059source = "registry+https://github.com/rust-lang/crates.io-index"
1060checksum = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957"
1061
10621083[[package]]
10631084name = "remove_dir_all"
10641085version = "0.5.3"
10651086source = "registry+https://github.com/rust-lang/crates.io-index"
10661087checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
10671088dependencies = [
1068 "winapi 0.3.9",
1089 "winapi",
10691090]
10701091
10711092[[package]]
@@ -1126,8 +1147,8 @@ version = "0.1.20"
11261147source = "registry+https://github.com/rust-lang/crates.io-index"
11271148checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2"
11281149dependencies = [
1129 "lazy_static 1.4.0",
1130 "windows-sys",
1150 "lazy_static",
1151 "windows-sys 0.36.1",
11311152]
11321153
11331154[[package]]
@@ -1142,6 +1163,12 @@ version = "1.1.0"
11421163source = "registry+https://github.com/rust-lang/crates.io-index"
11431164checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
11441165
1166[[package]]
1167name = "scratch"
1168version = "1.0.2"
1169source = "registry+https://github.com/rust-lang/crates.io-index"
1170checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898"
1171
11451172[[package]]
11461173name = "security-framework"
11471174version = "2.7.0"
@@ -1165,30 +1192,20 @@ dependencies = [
11651192 "libc",
11661193]
11671194
1168[[package]]
1169name = "semver-parser"
1170version = "0.6.2"
1171source = "registry+https://github.com/rust-lang/crates.io-index"
1172checksum = "d8fff3c9c5a54636ab95acd8c1349926e04cb1eb8cd70b5adced8a1d1f703a67"
1173dependencies = [
1174 "lazy_static 0.2.11",
1175 "regex",
1176]
1177
11781195[[package]]
11791196name = "serde"
1180version = "1.0.145"
1197version = "1.0.147"
11811198source = "registry+https://github.com/rust-lang/crates.io-index"
1182checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b"
1199checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965"
11831200dependencies = [
11841201 "serde_derive",
11851202]
11861203
11871204[[package]]
11881205name = "serde_derive"
1189version = "1.0.145"
1206version = "1.0.147"
11901207source = "registry+https://github.com/rust-lang/crates.io-index"
1191checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c"
1208checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852"
11921209dependencies = [
11931210 "proc-macro2",
11941211 "quote",
@@ -1197,9 +1214,9 @@ dependencies = [
11971214
11981215[[package]]
11991216name = "serde_json"
1200version = "1.0.85"
1217version = "1.0.87"
12011218source = "registry+https://github.com/rust-lang/crates.io-index"
1202checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44"
1219checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45"
12031220dependencies = [
12041221 "itoa",
12051222 "ryu",
@@ -1220,9 +1237,9 @@ dependencies = [
12201237
12211238[[package]]
12221239name = "serde_yaml"
1223version = "0.9.13"
1240version = "0.9.14"
12241241source = "registry+https://github.com/rust-lang/crates.io-index"
1225checksum = "8613d593412a0deb7bbd8de9d908efff5a0cb9ccd8f62c641e7b2ed2f57291d1"
1242checksum = "6d232d893b10de3eb7258ff01974d6ee20663d8e833263c99409d4b13a0209da"
12261243dependencies = [
12271244 "indexmap",
12281245 "itoa",
@@ -1262,13 +1279,11 @@ dependencies = [
12621279]
12631280
12641281[[package]]
1265name = "sixel"
1266version = "0.3.2"
1282name = "sixel-rs"
1283version = "0.3.3"
12671284source = "registry+https://github.com/rust-lang/crates.io-index"
1268checksum = "51e4bcd2d65122138405b83d3f7777df6b04b0dd5222c85972ed1fb0119aeaaa"
1285checksum = "cfa95c014543113a192d906e5971d0c8d1e8b4cc1e61026539687a7016644ce5"
12691286dependencies = [
1270 "lazy_static 0.2.11",
1271 "semver-parser",
12721287 "sixel-sys",
12731288]
12741289
@@ -1292,9 +1307,9 @@ dependencies = [
12921307
12931308[[package]]
12941309name = "smallvec"
1295version = "1.9.0"
1310version = "1.10.0"
12961311source = "registry+https://github.com/rust-lang/crates.io-index"
1297checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1"
1312checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
12981313
12991314[[package]]
13001315name = "socket2"
@@ -1303,7 +1318,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
13031318checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd"
13041319dependencies = [
13051320 "libc",
1306 "winapi 0.3.9",
1321 "winapi",
13071322]
13081323
13091324[[package]]
@@ -1317,9 +1332,9 @@ dependencies = [
13171332
13181333[[package]]
13191334name = "syn"
1320version = "1.0.100"
1335version = "1.0.103"
13211336source = "registry+https://github.com/rust-lang/crates.io-index"
1322checksum = "52205623b1b0f064a4e71182c3b18ae902267282930c6d5462c91b859668426e"
1337checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d"
13231338dependencies = [
13241339 "proc-macro2",
13251340 "quote",
@@ -1337,7 +1352,7 @@ dependencies = [
13371352 "libc",
13381353 "redox_syscall",
13391354 "remove_dir_all",
1340 "winapi 0.3.9",
1355 "winapi",
13411356]
13421357
13431358[[package]]
@@ -1356,26 +1371,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
13561371checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df"
13571372dependencies = [
13581373 "libc",
1359 "winapi 0.3.9",
1360]
1361
1362[[package]]
1363name = "thread-id"
1364version = "2.0.0"
1365source = "registry+https://github.com/rust-lang/crates.io-index"
1366checksum = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03"
1367dependencies = [
1368 "kernel32-sys",
1369 "libc",
1370]
1371
1372[[package]]
1373name = "thread_local"
1374version = "0.2.7"
1375source = "registry+https://github.com/rust-lang/crates.io-index"
1376checksum = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5"
1377dependencies = [
1378 "thread-id",
1374 "winapi",
13791375]
13801376
13811377[[package]]
@@ -1415,20 +1411,19 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
14151411
14161412[[package]]
14171413name = "tokio"
1418version = "1.21.1"
1414version = "1.21.2"
14191415source = "registry+https://github.com/rust-lang/crates.io-index"
1420checksum = "0020c875007ad96677dcc890298f4b942882c5d4eb7cc8f439fc3bf813dc9c95"
1416checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099"
14211417dependencies = [
14221418 "autocfg",
14231419 "bytes",
14241420 "libc",
1425 "memchr 2.5.0",
1421 "memchr",
14261422 "mio",
14271423 "num_cpus",
1428 "once_cell",
14291424 "pin-project-lite",
14301425 "socket2",
1431 "winapi 0.3.9",
1426 "winapi",
14321427]
14331428
14341429[[package]]
@@ -1463,9 +1458,9 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52"
14631458
14641459[[package]]
14651460name = "tracing"
1466version = "0.1.36"
1461version = "0.1.37"
14671462source = "registry+https://github.com/rust-lang/crates.io-index"
1468checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307"
1463checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
14691464dependencies = [
14701465 "cfg-if",
14711466 "pin-project-lite",
@@ -1474,9 +1469,9 @@ dependencies = [
14741469
14751470[[package]]
14761471name = "tracing-core"
1477version = "0.1.29"
1472version = "0.1.30"
14781473source = "registry+https://github.com/rust-lang/crates.io-index"
1479checksum = "5aeea4303076558a00714b823f9ad67d58a3bbda1df83d8827d21193156e22f7"
1474checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a"
14801475dependencies = [
14811476 "once_cell",
14821477]
@@ -1501,7 +1496,7 @@ checksum = "ccdd26cbd674007e649a272da4475fb666d3aa0ad0531da7136db6fab0e5bad1"
15011496dependencies = [
15021497 "bitflags",
15031498 "cassowary",
1504 "crossterm 0.25.0",
1499 "crossterm",
15051500 "serde",
15061501 "unicode-segmentation",
15071502 "unicode-width",
@@ -1509,9 +1504,11 @@ dependencies = [
15091504
15101505[[package]]
15111506name = "tui-additions"
1512version = "0.1.8"
1507version = "0.1.9"
1508source = "registry+https://github.com/rust-lang/crates.io-index"
1509checksum = "19170ef3d86a5223daaa0bb449e71bdefe74676f5651ce8981e308915af64fa4"
15131510dependencies = [
1514 "crossterm 0.25.0",
1511 "crossterm",
15151512 "dyn-clone",
15161513 "tui",
15171514 "typemap",
@@ -1535,9 +1532,9 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992"
15351532
15361533[[package]]
15371534name = "unicode-ident"
1538version = "1.0.4"
1535version = "1.0.5"
15391536source = "registry+https://github.com/rust-lang/crates.io-index"
1540checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd"
1537checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
15411538
15421539[[package]]
15431540name = "unicode-normalization"
@@ -1586,12 +1583,6 @@ dependencies = [
15861583 "percent-encoding",
15871584]
15881585
1589[[package]]
1590name = "utf8-ranges"
1591version = "0.1.3"
1592source = "registry+https://github.com/rust-lang/crates.io-index"
1593checksum = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f"
1594
15951586[[package]]
15961587name = "vcpkg"
15971588version = "0.2.15"
@@ -1600,18 +1591,17 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
16001591
16011592[[package]]
16021593name = "viuer"
1603version = "0.6.1"
1594version = "0.6.2"
16041595source = "registry+https://github.com/rust-lang/crates.io-index"
1605checksum = "9db8b59a46844025fa705f65ba7d0a9ebf3369cb5fa2f10c532f1d41e0a56fa4"
1596checksum = "b511f7e9ae27b5750f12ca50c353a1179bd4cc964a47294eb0d2cdad40cb41c0"
16061597dependencies = [
16071598 "ansi_colours",
16081599 "base64",
16091600 "console",
1610 "crossterm 0.23.2",
1601 "crossterm",
16111602 "image",
1612 "lazy_static 1.4.0",
1613 "sixel",
1614 "sixel-sys",
1603 "lazy_static",
1604 "sixel-rs",
16151605 "tempfile",
16161606 "termcolor",
16171607]
@@ -1714,12 +1704,6 @@ version = "0.1.7"
17141704source = "registry+https://github.com/rust-lang/crates.io-index"
17151705checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb"
17161706
1717[[package]]
1718name = "winapi"
1719version = "0.2.8"
1720source = "registry+https://github.com/rust-lang/crates.io-index"
1721checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
1722
17231707[[package]]
17241708name = "winapi"
17251709version = "0.3.9"
@@ -1730,12 +1714,6 @@ dependencies = [
17301714 "winapi-x86_64-pc-windows-gnu",
17311715]
17321716
1733[[package]]
1734name = "winapi-build"
1735version = "0.1.1"
1736source = "registry+https://github.com/rust-lang/crates.io-index"
1737checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
1738
17391717[[package]]
17401718name = "winapi-i686-pc-windows-gnu"
17411719version = "0.4.0"
@@ -1748,7 +1726,7 @@ version = "0.1.5"
17481726source = "registry+https://github.com/rust-lang/crates.io-index"
17491727checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
17501728dependencies = [
1751 "winapi 0.3.9",
1729 "winapi",
17521730]
17531731
17541732[[package]]
@@ -1763,50 +1741,107 @@ version = "0.36.1"
17631741source = "registry+https://github.com/rust-lang/crates.io-index"
17641742checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2"
17651743dependencies = [
1766 "windows_aarch64_msvc",
1767 "windows_i686_gnu",
1768 "windows_i686_msvc",
1769 "windows_x86_64_gnu",
1770 "windows_x86_64_msvc",
1744 "windows_aarch64_msvc 0.36.1",
1745 "windows_i686_gnu 0.36.1",
1746 "windows_i686_msvc 0.36.1",
1747 "windows_x86_64_gnu 0.36.1",
1748 "windows_x86_64_msvc 0.36.1",
1749]
1750
1751[[package]]
1752name = "windows-sys"
1753version = "0.42.0"
1754source = "registry+https://github.com/rust-lang/crates.io-index"
1755checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
1756dependencies = [
1757 "windows_aarch64_gnullvm",
1758 "windows_aarch64_msvc 0.42.0",
1759 "windows_i686_gnu 0.42.0",
1760 "windows_i686_msvc 0.42.0",
1761 "windows_x86_64_gnu 0.42.0",
1762 "windows_x86_64_gnullvm",
1763 "windows_x86_64_msvc 0.42.0",
17711764]
17721765
1766[[package]]
1767name = "windows_aarch64_gnullvm"
1768version = "0.42.0"
1769source = "registry+https://github.com/rust-lang/crates.io-index"
1770checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e"
1771
17731772[[package]]
17741773name = "windows_aarch64_msvc"
17751774version = "0.36.1"
17761775source = "registry+https://github.com/rust-lang/crates.io-index"
17771776checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47"
17781777
1778[[package]]
1779name = "windows_aarch64_msvc"
1780version = "0.42.0"
1781source = "registry+https://github.com/rust-lang/crates.io-index"
1782checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4"
1783
17791784[[package]]
17801785name = "windows_i686_gnu"
17811786version = "0.36.1"
17821787source = "registry+https://github.com/rust-lang/crates.io-index"
17831788checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6"
17841789
1790[[package]]
1791name = "windows_i686_gnu"
1792version = "0.42.0"
1793source = "registry+https://github.com/rust-lang/crates.io-index"
1794checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7"
1795
17851796[[package]]
17861797name = "windows_i686_msvc"
17871798version = "0.36.1"
17881799source = "registry+https://github.com/rust-lang/crates.io-index"
17891800checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024"
17901801
1802[[package]]
1803name = "windows_i686_msvc"
1804version = "0.42.0"
1805source = "registry+https://github.com/rust-lang/crates.io-index"
1806checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246"
1807
17911808[[package]]
17921809name = "windows_x86_64_gnu"
17931810version = "0.36.1"
17941811source = "registry+https://github.com/rust-lang/crates.io-index"
17951812checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1"
17961813
1814[[package]]
1815name = "windows_x86_64_gnu"
1816version = "0.42.0"
1817source = "registry+https://github.com/rust-lang/crates.io-index"
1818checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed"
1819
1820[[package]]
1821name = "windows_x86_64_gnullvm"
1822version = "0.42.0"
1823source = "registry+https://github.com/rust-lang/crates.io-index"
1824checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028"
1825
17971826[[package]]
17981827name = "windows_x86_64_msvc"
17991828version = "0.36.1"
18001829source = "registry+https://github.com/rust-lang/crates.io-index"
18011830checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
18021831
1832[[package]]
1833name = "windows_x86_64_msvc"
1834version = "0.42.0"
1835source = "registry+https://github.com/rust-lang/crates.io-index"
1836checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5"
1837
18031838[[package]]
18041839name = "winreg"
18051840version = "0.10.1"
18061841source = "registry+https://github.com/rust-lang/crates.io-index"
18071842checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"
18081843dependencies = [
1809 "winapi 0.3.9",
1844 "winapi",
18101845]
18111846
18121847[[package]]
@@ -1814,7 +1849,7 @@ name = "youtube-tui"
18141849version = "0.5.0"
18151850dependencies = [
18161851 "chrono",
1817 "crossterm 0.25.0",
1852 "crossterm",
18181853 "dyn-clone",
18191854 "futures",
18201855 "home",
Cargo.toml +5 −3
@@ -19,13 +19,15 @@ crossterm = {version = "0.25", features = ["serde"]}
1919viuer = {version = "0.6", features = ["sixel"]}
2020home = "0.5"
2121chrono = {version = "0.4", default-features = false, features = ["clock"]}
22# tui-additions = {version = "0.1", default-features = false, features = ["framework", "widgets"]}
22tui-additions = {version = "0.1", default-features = false, features = ["framework", "widgets"]}
2323typemap = "0.3"
24invidious = {version = "0.3", default-features = false, features = ["reqwest"]}
24invidious = {version = "0.4", default-features = false, features = ["reqwest"]}
2525serde_yaml = "0.9"
2626dyn-clone = "1.0"
2727tokio = "1.21"
2828futures = "0.3"
2929reqwest = "0.11"
3030serde_json = "1.0"
31tui-additions = {path = "../../Rust/Packages/tui-additions", default-features = false, features = ["framework", "widgets"]}
31
32# tui-additions = {path = "../../Rust/Packages/tui-additions", default-features = false, features = ["framework", "widgets"]}
33# invidious = {path = "../../Rust/Packages/invidious", default-features = false, features = ["reqwest"]}
README.md +2 −2
@@ -39,13 +39,13 @@ An aesthetically pleasing YouTube TUI written in Rust.
3939>
4040> #### Done
4141>
42> - Config files (mostly, more options will be added when I get to that part)
42> - Config files
4343> - Home and search page
4444> - Search fully functional
4545>
4646> #### To do before release
4747>
48> - Item info, channels page
48> - Item info (WIP), channels page
4949> - Watch history
5050> - Basically back to where it is before the rewrite
5151
src/config/appearance.rs +39 −4
@@ -23,6 +23,14 @@ pub struct AppearanceConfig {
2323/// Includes all configurable colors
2424#[derive(Clone, Copy, Serialize, Deserialize)]
2525pub struct ColorsConfig {
26 #[serde(default = "text_default")]
27 pub text: Color,
28 #[serde(default = "text_special_default")]
29 pub text_special: Color,
30 #[serde(default = "text_secondary_default")]
31 pub text_secondary: Color,
32 #[serde(default = "text_error_default")]
33 pub text_error: Color,
2634 #[serde(default = "outline_default")]
2735 pub outline: Color,
2836 #[serde(default = "outline_selected_default")]
@@ -37,8 +45,6 @@ pub struct ColorsConfig {
3745 pub message_error_outline: Color,
3846 #[serde(default = "message_success_outline_default")]
3947 pub message_success_outline: Color,
40 #[serde(default = "error_text_default")]
41 pub error_text: Color,
4248 #[serde(default)]
4349 pub item_info: ItemInfoColors,
4450}
@@ -64,11 +70,18 @@ pub struct ItemInfoColors {
6470 pub video_count: Color,
6571 #[serde(default = "sub_count_default")]
6672 pub sub_count: Color,
73 #[serde(default = "likes_default")]
74 pub likes: Color,
75 #[serde(default = "genre_default")]
76 pub genre: Color,
6777}
6878
6979impl Default for ColorsConfig {
7080 fn default() -> Self {
7181 Self {
82 text: text_default(),
83 text_special: text_special_default(),
84 text_secondary: text_secondary_default(),
7285 outline: outline_default(),
7386 outline_selected: outline_selected_default(),
7487 outline_hover: outline_hover_default(),
@@ -76,7 +89,7 @@ impl Default for ColorsConfig {
7689 message_outline: message_outline_default(),
7790 message_error_outline: message_error_outline_default(),
7891 message_success_outline: message_success_outline_default(),
79 error_text: error_text_default(),
92 text_error: text_error_default(),
8093 item_info: ItemInfoColors::default(),
8194 }
8295 }
@@ -94,6 +107,8 @@ impl Default for ItemInfoColors {
94107 published: published_default(),
95108 video_count: video_count_default(),
96109 sub_count: sub_count_default(),
110 likes: likes_default(),
111 genre: genre_default(),
97112 }
98113 }
99114}
@@ -117,6 +132,18 @@ impl Key for AppearanceConfig {
117132
118133// defaults
119134
135fn text_default() -> Color {
136 Color::Reset
137}
138
139fn text_special_default() -> Color {
140 Color::Reset
141}
142
143fn text_secondary_default() -> Color {
144 Color::Reset
145}
146
120147fn outline_default() -> Color {
121148 Color::Reset
122149}
@@ -145,7 +172,7 @@ fn message_success_outline_default() -> Color {
145172 Color::LightGreen
146173}
147174
148fn error_text_default() -> Color {
175fn text_error_default() -> Color {
149176 Color::LightRed
150177}
151178
@@ -184,3 +211,11 @@ fn video_count_default() -> Color {
184211fn sub_count_default() -> Color {
185212 Color::LightYellow
186213}
214
215fn likes_default() -> Color {
216 Color::Rgb(200, 255, 129)
217}
218
219fn genre_default() -> Color {
220 Color::Rgb(255, 121, 215)
221}
src/config/commands.rs added +64
@@ -0,0 +1,64 @@
1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4use typemap::Key;
5
6use crate::global::traits::ConfigTrait;
7
8#[derive(Clone)]
9pub struct CommandsConfig {
10 pub video: HashMap<String, String>,
11 pub playlist: HashMap<String, String>,
12}
13
14impl Key for CommandsConfig {
15 type Value = Self;
16}
17
18impl From<CommandsConfigSerde> for CommandsConfig {
19 fn from(original: CommandsConfigSerde) -> Self {
20 Self {
21 video: HashMap::from_iter(original.video.into_iter().map(|item| item.into_iter().last().unwrap())),
22 playlist: HashMap::from_iter(original.playlist.into_iter().map(|item| item.into_iter().last().unwrap())),
23 }
24 }
25}
26
27#[derive(Serialize, Deserialize, Clone)]
28pub struct CommandsConfigSerde {
29 #[serde(default = "video_default")]
30 pub video: Vec<HashMap<String, String>>,
31 #[serde(default = "playlist_default")]
32 pub playlist: Vec<HashMap<String, String>>,
33}
34
35impl ConfigTrait for CommandsConfigSerde {
36 const LABEL: &'static str = "commands";
37}
38
39impl Default for CommandsConfigSerde {
40 fn default() -> Self {
41 Self {
42 video: video_default(),
43 playlist: playlist_default(),
44 }
45 }
46}
47
48fn video_default() -> Vec<HashMap<String, String>> {
49 vec![HashMap::from(
50 [(
51 String::from("Play video"),
52 String::from("${video-player} ${embed-url}"),
53 )])]
54}
55
56fn playlist_default() -> Vec<HashMap<String, String>> {
57 vec![
58 HashMap::from([(String::from("Switch view"), String::from("%switch-view%"))]),
59 HashMap::from([(
60 String::from("Play entire playlist"),
61 String::from("${video-player} ${embed-url}"),
62 )]),
63 ]
64}
src/config/main.rs +8
@@ -14,6 +14,8 @@ pub struct MainConfig {
1414 pub message_bar_default: String,
1515 #[serde(default = "images_default")]
1616 pub images: Images,
17 #[serde(default = "refresh_after_modifying_search_filters_default")]
18 pub refresh_after_modifying_search_filters: bool,
1719 #[serde(default = "image_index_default")]
1820 // The image to download from the array of images provided by the invidious api
1921 // 0 is usually `maxres` and 3 (default) is good enough for normal uses without having huge files sizes
@@ -35,6 +37,8 @@ impl Default for MainConfig {
3537 message_bar_default: message_bar_default_default(),
3638 images: images_default(),
3739 image_index: image_index_default(),
40 refresh_after_modifying_search_filters: refresh_after_modifying_search_filters_default(
41 ),
3842
3943 env: HashMap::default(),
4044 }
@@ -83,3 +87,7 @@ const fn image_index_default() -> usize {
8387const fn allow_unicode_default() -> bool {
8488 false
8589}
90
91const fn refresh_after_modifying_search_filters_default() -> bool {
92 true
93}
src/config/mod.rs +2
@@ -9,5 +9,7 @@ mod pages;
99pub use pages::*;
1010mod keybindings;
1111pub use keybindings::*;
12mod commands;
13pub use commands::*;
1214
1315pub mod serde;
src/config/pages.rs +21 −14
@@ -1,6 +1,6 @@
11use crate::{
22 global::traits::ConfigTrait,
3 items::{ItemList, MessageBar, PageButton, SearchBar, SearchFilter},
3 items::{ItemList, MessageBar, PageButton, SearchBar, SearchFilter, SingleItem},
44};
55use serde::{Deserialize, Serialize};
66use std::slice;
@@ -10,7 +10,7 @@ use typemap::Key;
1010
1111/// Minimum screen dimention for the tui to display without panicking, stored in `data.state`
1212// is automatically generated from PageConfig
13#[derive(Clone, Copy)]
13#[derive(Clone, Copy, Default)]
1414pub struct MinDimentions {
1515 pub width: u16,
1616 pub height: u16,
@@ -22,15 +22,6 @@ impl MinDimentions {
2222 }
2323}
2424
25impl Default for MinDimentions {
26 fn default() -> Self {
27 Self {
28 width: 0,
29 height: 0,
30 }
31 }
32}
33
3425impl Key for MinDimentions {
3526 type Value = Self;
3627}
@@ -42,6 +33,8 @@ pub struct PagesConfig {
4233 pub main_menu: PageConfig,
4334 #[serde(default = "search_default")]
4435 pub search: PageConfig,
36 #[serde(default = "singleitem_default")]
37 pub singleitem: PageConfig,
4538}
4639
4740impl Key for PagesConfig {
@@ -57,6 +50,7 @@ impl Default for PagesConfig {
5750 Self {
5851 main_menu: main_menu_default(),
5952 search: search_default(),
53 singleitem: singleitem_default(),
6054 }
6155 }
6256}
@@ -163,6 +157,7 @@ pub enum PageItems {
163157 Trending,
164158 Popular,
165159 SearchFilters,
160 SingleItemInfo,
166161}
167162
168163impl PageItems {
@@ -175,6 +170,7 @@ impl PageItems {
175170 Self::MessageBar => Box::new(MessageBar::default()),
176171 Self::ItemList => Box::new(ItemList::default()),
177172 Self::SearchFilters => Box::new(SearchFilter::default()),
173 Self::SingleItemInfo => Box::new(SingleItem::default()),
178174 }
179175 }
180176
@@ -183,7 +179,7 @@ impl PageItems {
183179 Self::Popular | Self::Trending => Constraint::Length(15),
184180 Self::SearchBar => Constraint::Min(16),
185181 Self::MessageBar => Constraint::Min(3),
186 Self::ItemList => Constraint::Min(9),
182 Self::ItemList | Self::SingleItemInfo => Constraint::Min(9),
187183 Self::SearchFilters => Constraint::Length(5),
188184 }
189185 }
@@ -195,7 +191,7 @@ impl PageItems {
195191 | Self::MessageBar
196192 | Self::SearchBar
197193 | Self::SearchFilters => Constraint::Length(3),
198 Self::ItemList => Constraint::Min(6),
194 Self::ItemList | Self::SingleItemInfo => Constraint::Min(6),
199195 }
200196 }
201197}
@@ -203,7 +199,7 @@ impl PageItems {
203199fn constraint_to_u16(constraint: &Constraint) -> u16 {
204200 match constraint {
205201 Constraint::Max(length) | Constraint::Min(length) | Constraint::Length(length) => *length,
206 _ => unreachable!(),
202 _ => unreachable!("only `Max`, `Min`, `Length` can be used as item length"),
207203 }
208204}
209205
@@ -246,3 +242,14 @@ fn search_default() -> PageConfig {
246242 message: String::from("Loading search results..."),
247243 }
248244}
245
246fn singleitem_default() -> PageConfig {
247 PageConfig {
248 layout: vec![
249 PageRow::from_vec(vec![PageItems::SearchBar, PageItems::SearchFilters], false),
250 PageRow::from_vec(vec![PageItems::SingleItemInfo], false),
251 PageRow::from_vec(vec![PageItems::MessageBar], false),
252 ],
253 message: String::from("Loading item details..."),
254 }
255}
src/config/search.rs +9 −9
@@ -7,7 +7,7 @@ use typemap::Key;
77
88// can be turned into URL Params for the search term with filters
99/// Search query & filters
10#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
10#[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq, Eq)]
1111pub struct Search {
1212 pub query: String,
1313 pub filters: SearchFilters,
@@ -35,7 +35,7 @@ impl ToString for Search {
3535}
3636
3737/// Search filters, read comments for function docs
38#[derive(Default, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
38#[derive(Default, Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq)]
3939pub struct SearchFilters {
4040 pub sort: SearchFilterSort,
4141 pub date: SearchFilterDate,
@@ -68,7 +68,7 @@ impl SearchFilters {
6868 2 => self.duration.selected_index(),
6969 3 => self.r#type.selected_index(),
7070 4 => 0,
71 _ => unreachable!(),
71 _ => unreachable!("`{index}` is not a valid index"),
7272 }
7373 }
7474
@@ -84,10 +84,10 @@ impl SearchFilters {
8484 if set_index == 0 {
8585 self.reset(message)
8686 } else {
87 unreachable!()
87 unreachable!("index can only be `0` for option `4` (reset all)")
8888 }
8989 }
90 _ => unreachable!(),
90 _ => unreachable!("`{index_at}` is not a valid index"),
9191 }
9292 }
9393
@@ -97,7 +97,7 @@ impl SearchFilters {
9797 }
9898}
9999
100#[derive(Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
100#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq)]
101101pub enum SearchFilterSort {
102102 Relevance,
103103 Rating,
@@ -105,7 +105,7 @@ pub enum SearchFilterSort {
105105 Views,
106106}
107107
108#[derive(Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
108#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq)]
109109pub enum SearchFilterDate {
110110 None,
111111 Hour,
@@ -115,7 +115,7 @@ pub enum SearchFilterDate {
115115 Year,
116116}
117117
118#[derive(Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
118#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq)]
119119pub enum SearchFilterDuration {
120120 None,
121121 Short,
@@ -123,7 +123,7 @@ pub enum SearchFilterDuration {
123123 Long,
124124}
125125
126#[derive(Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
126#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq)]
127127pub enum SearchFilterType {
128128 All,
129129 Video,
src/config/serde.rs +7 −7
@@ -18,13 +18,13 @@ impl Default for BorderTypeSerde {
1818 }
1919}
2020
21impl Into<BorderType> for BorderTypeSerde {
22 fn into(self) -> BorderType {
23 match self {
24 Self::Plain => BorderType::Plain,
25 Self::Rounded => BorderType::Rounded,
26 Self::Thick => BorderType::Thick,
27 Self::Double => BorderType::Double,
21impl From<BorderTypeSerde> for BorderType {
22 fn from(origianl: BorderTypeSerde) -> BorderType {
23 match origianl {
24 BorderTypeSerde::Plain => BorderType::Plain,
25 BorderTypeSerde::Rounded => BorderType::Rounded,
26 BorderTypeSerde::Thick => BorderType::Thick,
27 BorderTypeSerde::Double => BorderType::Double,
2828 }
2929 }
3030}
src/global/functions/download_all_images.rs +13 −12
@@ -15,17 +15,22 @@ impl From<&Item> for Option<DownloadRequest> {
1515 url: minivideo.thumbnail_url.clone(),
1616 id: minivideo.id.clone(),
1717 },
18 Item::MiniPlaylist(miniplaylist) => match &miniplaylist.thumbnail {
19 Some((id, url)) => DownloadRequest {
20 url: url.clone(),
21 id: id.clone(),
22 },
23 None => return None,
18 Item::MiniPlaylist(miniplaylist) => DownloadRequest {
19 url: miniplaylist.thumbnail_url.clone(),
20 id: miniplaylist.id.clone(),
2421 },
2522 Item::MiniChannel(minichannel) => DownloadRequest {
2623 url: minichannel.thumbnail_url.clone(),
2724 id: minichannel.id.clone(),
2825 },
26 Item::FullVideo(fullvideo) => DownloadRequest {
27 url: fullvideo.thumbnail_url.clone(),
28 id: fullvideo.id.clone(),
29 },
30 Item::FullPlaylist(fullplaylist) => DownloadRequest {
31 url: fullplaylist.thumbnail_url.clone(),
32 id: fullplaylist.id.clone(),
33 },
2934 Item::Unknown(_) => return None,
3035 })
3136 }
@@ -37,11 +42,7 @@ pub fn download_all_images(downloads: Vec<Option<DownloadRequest>>) {
3742 let rt: Runtime = tokio::runtime::Runtime::new().unwrap();
3843
3944 let _ = rt.block_on(download_all_images_async(
40 downloads
41 .into_iter()
42 .filter(|request| request.is_some())
43 .map(|request| request.unwrap())
44 .collect(),
45 downloads.into_iter().flatten().collect(),
4546 ));
4647 });
4748}
@@ -61,7 +62,7 @@ async fn download_all_images_async(downloads: Vec<DownloadRequest>) {
6162 if !path.exists() {
6263 actions.push(download_single(
6364 download.url,
64 path.clone().into_os_string().into_string().unwrap(),
65 path.to_owned().into_os_string().into_string().unwrap(),
6566 ));
6667 }
6768
src/global/functions/secs_display_string.rs +2 −2
@@ -15,11 +15,11 @@ pub fn secs_display_string(mut secs: u32) -> String {
1515 let minutes = secs / SECS_IN_MINUTE;
1616 secs -= minutes * SECS_IN_MINUTE;
1717 out.push(two_digit_num(minutes));
18 } else if out.len() != 0 {
18 } else if !out.is_empty() {
1919 out.push(String::from("00"));
2020 }
2121
22 if out.len() == 0 {
22 if out.is_empty() {
2323 out.push(String::from("00"));
2424 }
2525 out.push(two_digit_num(secs));
src/global/functions/viewcount_text.rs +1 −1
@@ -1,4 +1,4 @@
1const UNITS: &[(&'static str, f64)] = &[
1const UNITS: &[(&str, f64)] = &[
22 ("B", 1_000_000_000_f64),
33 ("M", 1_000_000_f64),
44 ("K", 1_000_f64),
src/global/structs/errors.rs +1 −1
@@ -12,7 +12,7 @@ impl Display for Errors {
1212 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1313 match self {
1414 Self::BlankError => f.write_str("Is a blank error ¯\\_(ツ)_/¯"),
15 Self::StringError(e) => f.write_str(&e),
15 Self::StringError(e) => f.write_str(e),
1616 Self::StrError(e) => f.write_str(e),
1717 }
1818 }
src/global/structs/item.rs +108 −44
@@ -1,6 +1,10 @@
11use crate::global::functions::{date_text, secs_display_string, viewcount_text};
2use invidious::structs::hidden::{
3 Playlist, PopularItem, SearchItem, SearchItemTransition, TrendingVideo,
2use invidious::structs::{
3 hidden::{
4 Playlist, PlaylistItem, PopularItem, SearchItem, SearchItemTransition, TrendingVideo,
5 },
6 universal::Playlist as FullPlaylist,
7 video::Video,
48};
59use std::fmt::Display;
610
@@ -12,10 +16,11 @@ pub enum Item {
1216 MiniVideo(MiniVideoItem),
1317 MiniPlaylist(MiniPlaylistItem),
1418 MiniChannel(MiniChannelItem),
19 FullVideo(FullVideoItem),
20 FullPlaylist(FullPlaylistItem),
1521 Unknown(SearchItemTransition),
1622}
1723
18/// info from a video from search, trending and popular page
1924#[derive(Clone)]
2025pub struct MiniVideoItem {
2126 pub title: String,
@@ -25,7 +30,7 @@ pub struct MiniVideoItem {
2530 pub views: Option<String>,
2631 pub channel: String,
2732 pub channel_id: String,
28 pub published: String,
33 pub published: Option<String>,
2934 pub description: Option<String>,
3035}
3136
@@ -36,8 +41,7 @@ pub struct MiniPlaylistItem {
3641 pub channel: String,
3742 pub channel_id: String,
3843 pub video_count: u32,
39 // (id, url)
40 pub thumbnail: Option<(String, String)>,
44 pub thumbnail_url: String,
4145}
4246
4347#[derive(Clone)]
@@ -51,12 +55,44 @@ pub struct MiniChannelItem {
5155 pub description: String,
5256}
5357
58#[derive(Clone)]
59pub struct FullVideoItem {
60 pub title: String,
61 pub id: String,
62 pub thumbnail_url: String,
63 pub length: String,
64 pub views: String,
65 pub channel: String,
66 pub channel_id: String,
67 pub sub_count: String,
68 pub published: String,
69 pub description: String,
70 pub likes: String,
71 // pub dislikes: Option<String>, TODO
72 pub genre: String,
73}
74
75#[derive(Clone)]
76pub struct FullPlaylistItem {
77 pub title: String,
78 pub id: String,
79 pub channel: String,
80 pub channel_id: String,
81 pub video_count: u32,
82 pub description: String,
83 pub views: String,
84 pub thumbnail_url: String,
85 pub videos: Vec<Item>,
86}
87
5488impl Display for Item {
5589 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5690 f.write_str(match self {
5791 Self::MiniVideo(video) => &video.title,
5892 Self::MiniPlaylist(playlist) => &playlist.title,
5993 Self::MiniChannel(channel) => &channel.name,
94 Self::FullVideo(video) => &video.title,
95 Self::FullPlaylist(playlist) => &playlist.title,
6096 Self::Unknown(_) => "Unknown item",
6197 })
6298 }
@@ -67,11 +103,10 @@ impl Item {
67103 pub fn thumbnail_id(&self) -> &str {
68104 match self {
69105 Self::MiniVideo(video) => &video.id,
70 Self::MiniPlaylist(playlist) => match &playlist.thumbnail {
71 Some((id, _)) => &id,
72 None => "invalid",
73 },
106 Self::MiniPlaylist(playlist) => &playlist.id,
74107 Self::MiniChannel(channel) => &channel.id,
108 Self::FullVideo(video) => &video.id,
109 Self::FullPlaylist(playlist) => &playlist.id,
75110 Self::Unknown(_) => "invalid",
76111 }
77112 }
@@ -86,11 +121,11 @@ impl Item {
86121 views: Some(viewcount_text(original.views)),
87122 channel: original.author,
88123 channel_id: original.author_id,
89 published: format!(
124 published: Some(format!(
90125 "{} [{}]",
91126 original.published_text,
92127 date_text(original.published)
93 ),
128 )),
94129 description: Some(original.description),
95130 })
96131 }
@@ -104,30 +139,23 @@ impl Item {
104139 views: Some(viewcount_text(original.views)),
105140 channel: original.author,
106141 channel_id: original.author_id,
107 published: format!(
142 published: Some(format!(
108143 "{} [{}]",
109144 original.published_text,
110145 date_text(original.published)
111 ),
146 )),
112147 description: None,
113148 })
114149 }
115150
116 pub fn from_mini_playlist(original: Playlist, image_index: usize) -> Self {
151 pub fn from_mini_playlist(original: Playlist) -> Self {
117152 Self::MiniPlaylist(MiniPlaylistItem {
118153 title: original.title,
119154 id: original.id,
120155 channel: original.author,
121156 channel_id: original.author_id,
122157 video_count: original.video_count,
123 thumbnail: if original.videos.len() == 0 {
124 None
125 } else {
126 Some((
127 original.videos[0].id.clone(),
128 original.videos[0].thumbnails[image_index].url.clone(),
129 ))
130 },
158 thumbnail_url: original.thumbnail,
131159 })
132160 }
133161
@@ -138,17 +166,13 @@ impl Item {
138166 id,
139167 author,
140168 author_id,
141 author_url: _,
142169 length,
143170 thumbnails,
144171 description,
145 description_html: _,
146172 views,
147173 published,
148174 published_text,
149 live: _,
150 paid: _,
151 premium: _,
175 ..
152176 } => Self::MiniVideo(MiniVideoItem {
153177 title,
154178 id,
@@ -157,7 +181,7 @@ impl Item {
157181 views: Some(viewcount_text(views)),
158182 channel: author,
159183 channel_id: author_id,
160 published: format!("{} [{}]", published_text, date_text(published)),
184 published: Some(format!("{} [{}]", published_text, date_text(published))),
161185 description: Some(description),
162186 }),
163187 SearchItem::Playlist {
@@ -165,35 +189,26 @@ impl Item {
165189 id,
166190 author,
167191 author_id,
168 author_url: _,
169192 video_count,
170 videos,
193 thumbnail,
194 ..
171195 } => Self::MiniPlaylist(MiniPlaylistItem {
172196 title,
173197 id,
174198 channel: author,
175199 channel_id: author_id,
176200 video_count,
177 thumbnail: if videos.len() == 0 {
178 None
179 } else {
180 Some((
181 videos[0].id.clone(),
182 videos[0].thumbnails[image_index].url.clone(),
183 ))
184 },
201 thumbnail_url: thumbnail,
185202 }),
186203 SearchItem::Channel {
187204 name,
188205 id,
189 url: _,
190206 thumbnails,
191207 subscribers,
192208 video_count,
193209 description,
194 description_html: _,
195 } => {
196 Self::MiniChannel(MiniChannelItem {
210 ..
211 } => Self::MiniChannel(MiniChannelItem {
197212 name,
198213 id,
199214 thumbnail_url: format!("https://{}", thumbnails[image_index].url),
@@ -201,8 +216,57 @@ impl Item {
201216 sub_count: subscribers,
202217 sub_count_text: viewcount_text(subscribers as u64),
203218 description,
204 })},
219 }),
205220 SearchItem::Unknown(searchitem_transitional) => Self::Unknown(searchitem_transitional),
206221 }
207222 }
223
224 pub fn from_full_video(original: Video, image_index: usize) -> Self {
225 Self::FullVideo(FullVideoItem {
226 title: original.title,
227 id: original.id,
228 thumbnail_url: original.thumbnails[image_index].url.clone(),
229 length: secs_display_string(original.length as u32),
230 views: viewcount_text(original.views),
231 channel: original.author,
232 channel_id: original.author_id,
233 sub_count: original.sub_count_text,
234 published: original.published_text,
235 description: original.description,
236 likes: viewcount_text(original.likes as u64),
237 genre: original.genre,
238 })
239 }
240
241 pub fn from_full_playlist(original: FullPlaylist, image_index: usize) -> Self {
242 Self::FullPlaylist(FullPlaylistItem {
243 title: original.title,
244 id: original.id,
245 channel: original.author,
246 channel_id: original.author_id,
247 video_count: original.video_count,
248 description: original.description,
249 views: viewcount_text(original.views),
250 thumbnail_url: original.thumbnail,
251 videos: original
252 .videos
253 .into_iter()
254 .map(|video| Self::from_playlist_item(video, image_index))
255 .collect(),
256 })
257 }
258
259 pub fn from_playlist_item(original: PlaylistItem, image_index: usize) -> Self {
260 Self::MiniVideo(MiniVideoItem {
261 title: original.title,
262 id: original.id,
263 thumbnail_url: original.thumbnails[image_index].url.to_owned(),
264 length: secs_display_string(original.length),
265 views: None,
266 channel: original.author,
267 channel_id: original.author_id,
268 published: None,
269 description: None,
270 })
271 }
208272}
src/global/structs/page.rs +26 −1
@@ -1,3 +1,5 @@
1use std::fmt::Debug;
2
13use crate::config::{PageConfig, PagesConfig, Search};
24use tui_additions::framework::Framework;
35use typemap::Key;
@@ -8,6 +10,20 @@ use typemap::Key;
810pub enum Page {
911 MainMenu(MainMenuPage),
1012 Search(Search),
13 SingleItem(SingleItemPage),
14}
15
16impl Debug for Page {
17 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18 f.write_fmt(format_args!(
19 "{}(_)",
20 match self {
21 Self::MainMenu(_) => "MainMenu",
22 Self::Search(_) => "Search",
23 Self::SingleItem(_) => "SingleItem",
24 }
25 ))
26 }
1127}
1228
1329impl Default for Page {
@@ -33,12 +49,20 @@ impl Default for MainMenuPage {
3349 }
3450}
3551
52/// Different items to be displayed on a single item page
53#[derive(Clone, PartialEq, Eq)]
54pub enum SingleItemPage {
55 Video(String),
56 Playlist(String),
57}
58
3659impl Page {
3760 pub fn to_page_config(&self, framework: &Framework) -> PageConfig {
3861 let pages_config = framework.data.global.get::<PagesConfig>().unwrap();
3962 match self {
4063 Self::MainMenu(_) => pages_config.main_menu.clone(),
4164 Self::Search(_) => pages_config.search.clone(),
65 Self::SingleItem(_) => pages_config.singleitem.clone(),
4266 }
4367 }
4468
@@ -47,7 +71,8 @@ impl Page {
4771 let pages_config = framework.data.global.get::<PagesConfig>().unwrap();
4872 match self {
4973 Self::MainMenu(_) => pages_config.main_menu.message.clone(),
50 Self::Search(_) => pages_config.main_menu.message.clone(),
74 Self::Search(_) => pages_config.search.message.clone(),
75 Self::SingleItem(_) => pages_config.singleitem.message.clone(),
5176 }
5277 }
5378}
src/global/structs/tasks.rs +7 −7
@@ -52,7 +52,7 @@ impl TaskQueue {
5252 }
5353 }
5454 RenderTask::None => self.render = RenderTask::Only(vec![(x, y)]),
55 _ => return,
55 _ => {}
5656 },
5757 Task::LoadPage(page) => self.load_page = Some(page),
5858 Task::ClearPage => self.clear_all = true,
@@ -80,7 +80,7 @@ impl TaskQueue {
8080 }
8181 RenderTask::Only(_locations) => {
8282 // need to file an issue to tui-rs suggesting this as a feature
83 unimplemented!();
83 unimplemented!("tui-rs does not support partial re-rendering");
8484 }
8585 RenderTask::None => {}
8686 }
@@ -104,8 +104,9 @@ impl TaskQueue {
104104 *framework.data.global.get_mut::<Message>().unwrap() =
105105 Message::Message(page.load_msg(framework));
106106 framework.push_history();
107 framework.cursor = CursorState::default();
107108
108 let page_config = page.to_page_config(&framework);
109 let page_config = page.to_page_config(framework);
109110 *framework.data.state.get_mut::<MinDimentions>().unwrap() =
110111 MinDimentions::new(page_config.min_width(), page_config.min_height());
111112
@@ -116,7 +117,6 @@ impl TaskQueue {
116117 Self::render_force_clear(framework, terminal)?;
117118 *framework.data.global.get_mut::<Message>().unwrap() = Message::None;
118119
119 framework.cursor = CursorState::default();
120120 *framework.data.global.get_mut::<Message>().unwrap() = if let Err(e) = framework.load()
121121 {
122122 Message::Error(format!("{}", e))
@@ -179,7 +179,7 @@ impl TaskQueue {
179179 .get::<AppearanceConfig>()
180180 .unwrap()
181181 .colors
182 .error_text),
182 .text_error),
183183 );
184184 frame.render_widget(paragraph, area);
185185 return;
@@ -207,11 +207,11 @@ impl Tasks {
207207 // clears and returns the `priority` task queue, if it is already cleared then returns the `last` task queue
208208 pub fn pop(&mut self) -> Option<TaskQueue> {
209209 if !self.priority.is_empty() {
210 return Some(mem::replace(&mut self.priority, TaskQueue::default()));
210 return Some(mem::take(&mut self.priority));
211211 }
212212
213213 if !self.last.is_empty() {
214 return Some(mem::replace(&mut self.last, TaskQueue::default()));
214 return Some(mem::take(&mut self.last));
215215 }
216216
217217 None
src/global/traits/configtrait.rs +2 −2
@@ -5,7 +5,7 @@ use std::{
55 io::Write,
66};
77
8const EXTENSION: &'static str = "yml";
8const EXTENSION: &str = "yml";
99
1010/// Trait for loading, saving config files
1111pub trait ConfigTrait {
@@ -57,7 +57,7 @@ pub trait ConfigTrait {
5757 .truncate(true)
5858 .open(&config_path)?;
5959
60 file.write(serde_yaml::to_string(&config)?.as_bytes())?;
60 file.write_all(serde_yaml::to_string(&config)?.as_bytes())?;
6161
6262 Ok(Box::new(config))
6363 }
src/init.rs +6 −2
@@ -1,7 +1,7 @@
11use crate::{
22 config::{
3 AppearanceConfig, AppearanceConfigSerde, KeyBindingsConfig, MainConfig, MinDimentions,
4 PagesConfig, Search,
3 AppearanceConfig, AppearanceConfigSerde, CommandsConfig, KeyBindingsConfig, MainConfig,
4 MinDimentions, PagesConfig, Search, CommandsConfigSerde,
55 },
66 global::{
77 structs::{InvidiousClient, Message, Page, Status, Tasks},
@@ -52,6 +52,10 @@ pub fn init(framework: &mut Framework) -> Result<(), Box<dyn Error>> {
5252 .global
5353 .insert::<KeyBindingsConfig>(*KeyBindingsConfig::load()?);
5454 framework.data.global.insert::<Message>(Message::None);
55 framework
56 .data
57 .global
58 .insert::<CommandsConfig>(CommandsConfig::from(*CommandsConfigSerde::load()?));
5559
5660 framework.data.state.insert::<Tasks>(Tasks::default());
5761 framework.data.state.insert::<Page>(Page::default());
src/items/iteminfo.rs +102 −35
@@ -82,22 +82,16 @@ impl FrameworkItem for ItemInfo {
8282 Style::default().fg(appearance.colors.item_info.tag),
8383 ),
8484 (
85 minivideo.title.clone(),
85 minivideo.title.to_owned(),
8686 Style::default().fg(appearance.colors.item_info.title),
8787 ),
88 ],
89 minivideo.description.as_ref().map(|description| {
8890 (
89 format!("Uploaded by {}", minivideo.channel),
90 Style::default().fg(appearance.colors.item_info.author),
91 ),
92 ],
93 if let Some(description) = &minivideo.description {
94 Some((
95 description.clone(),
91 description.to_owned(),
9692 Style::default().fg(appearance.colors.item_info.description),
97 ))
98 } else {
99 None
100 },
93 )
94 }),
10195 );
10296 if let Some(views) = &minivideo.views {
10397 out.0.push((
@@ -105,19 +99,21 @@ impl FrameworkItem for ItemInfo {
10599 Style::default().fg(appearance.colors.item_info.viewcount),
106100 ));
107101 }
108 out.0.extend(
109 vec![
110 (
111 format!("Length: {}", minivideo.length),
112 Style::default().fg(appearance.colors.item_info.length),
113 ),
114 (
115 format!("Published {}", minivideo.published),
116 Style::default().fg(appearance.colors.item_info.published),
117 ),
118 ]
119 .into_iter(),
120 );
102 out.0.push((
103 format!("Length: {}", minivideo.length),
104 Style::default().fg(appearance.colors.item_info.length),
105 ));
106 out.0.push((
107 format!("Uploaded by {}", minivideo.channel),
108 Style::default().fg(appearance.colors.item_info.author),
109 ));
110 if let Some(published) = &minivideo.published {
111 out.0.push((
112 format!("Published {}", published),
113 Style::default().fg(appearance.colors.item_info.published),
114 ));
115 }
116
121117 out
122118 }
123119 Item::MiniPlaylist(miniplaylist) => (
@@ -127,7 +123,7 @@ impl FrameworkItem for ItemInfo {
127123 Style::default().fg(appearance.colors.item_info.tag),
128124 ),
129125 (
130 miniplaylist.title.clone(),
126 miniplaylist.title.to_owned(),
131127 Style::default().fg(appearance.colors.item_info.title),
132128 ),
133129 (
@@ -156,15 +152,15 @@ impl FrameworkItem for ItemInfo {
156152 Style::default().fg(appearance.colors.item_info.tag),
157153 ),
158154 (
159 minichannel.name.clone(),
155 minichannel.name.to_owned(),
160156 Style::default().fg(appearance.colors.item_info.title),
161157 ),
162158 (
163 format!("{} subscriber{}", minichannel.sub_count_text, if minichannel.sub_count <= 1 {
164 ""
165 } else {
166 "s"
167 }),
159 format!(
160 "{} subscriber{}",
161 minichannel.sub_count_text,
162 if minichannel.sub_count <= 1 { "" } else { "s" }
163 ),
168164 Style::default().fg(appearance.colors.item_info.sub_count),
169165 ),
170166 (
@@ -181,14 +177,85 @@ impl FrameworkItem for ItemInfo {
181177 ),
182178 ],
183179 Some((
184 minichannel.description.clone(),
180 minichannel.description.to_owned(),
181 Style::default().fg(appearance.colors.item_info.description),
182 )),
183 ),
184 Item::FullVideo(fullvideo) => (
185 vec![
186 (
187 String::from("[Video]"),
188 Style::default().fg(appearance.colors.item_info.tag),
189 ),
190 (
191 fullvideo.title.to_owned(),
192 Style::default().fg(appearance.colors.item_info.title),
193 ),
194 (
195 format!("{} views", fullvideo.views),
196 Style::default().fg(appearance.colors.item_info.viewcount),
197 ),
198 (
199 format!("{} likes", fullvideo.likes),
200 Style::default().fg(appearance.colors.item_info.likes),
201 ),
202 (
203 format!("Length: {}", fullvideo.length),
204 Style::default().fg(appearance.colors.item_info.length),
205 ),
206 (
207 format!(
208 "Uploaded by {} ({} subscribers)",
209 fullvideo.channel, fullvideo.sub_count
210 ),
211 Style::default().fg(appearance.colors.item_info.author),
212 ),
213 (
214 format!("Published {}", fullvideo.published),
215 Style::default().fg(appearance.colors.item_info.published),
216 ),
217 ],
218 Some((
219 fullvideo.description.to_owned(),
220 Style::default().fg(appearance.colors.item_info.description),
221 )),
222 ),
223 Item::FullPlaylist(fullplaylist) => (
224 vec![
225 (
226 String::from("[Playlist]"),
227 Style::default().fg(appearance.colors.item_info.tag),
228 ),
229 (
230 fullplaylist.title.to_owned(),
231 Style::default().fg(appearance.colors.item_info.title),
232 ),
233 (
234 format!("Created by by {}", fullplaylist.channel),
235 Style::default().fg(appearance.colors.item_info.author),
236 ),
237 (
238 format!(
239 "{} video{}",
240 fullplaylist.video_count,
241 if fullplaylist.video_count <= 1 {
242 ""
243 } else {
244 "s"
245 }
246 ),
247 Style::default().fg(appearance.colors.item_info.video_count),
248 ),
249 ],
250 Some((
251 fullplaylist.description.to_owned(),
185252 Style::default().fg(appearance.colors.item_info.description),
186253 )),
187254 ),
188255 Item::Unknown(searchitem_transitional) => (
189256 vec![(
190257 format!("Unknown type `{}`", searchitem_transitional.r#type),
191 Style::default().fg(appearance.colors.error_text),
258 Style::default().fg(appearance.colors.text_error),
192259 )],
193260 Some((
194261 serde_json::to_string(&searchitem_transitional).unwrap(),
@@ -220,7 +287,7 @@ impl FrameworkItem for ItemInfo {
220287
221288 // renders the "text"
222289 let (text, style) = text.unwrap();
223 if text.len() == 0 {
290 if text.is_empty() {
224291 return;
225292 }
226293 let paragraph = Paragraph::new(format!("Description:\n{}", text))
src/items/itemlist.rs +63 −25
@@ -11,7 +11,9 @@ use crate::{
1111 config::{AppearanceConfig, KeyBindingsConfig, MainConfig},
1212 global::{
1313 functions::download_all_images,
14 structs::{InvidiousClient, Item, KeyAction, MainMenuPage, Page, Task, Tasks},
14 structs::{
15 InvidiousClient, Item, KeyAction, MainMenuPage, Page, SingleItemPage, Task, Tasks,
16 },
1517 },
1618};
1719
@@ -25,6 +27,42 @@ pub struct ItemList {
2527 pub grid: Grid,
2628}
2729
30impl ItemList {
31 fn update_appearance(
32 &mut self,
33 appearance: &AppearanceConfig,
34 mainconfig: &MainConfig,
35 iteminfo: &tui_additions::framework::ItemInfo,
36 ) {
37 self.textlist.set_ascii_only(!mainconfig.allow_unicode);
38 self.grid.set_border_type(appearance.borders);
39 self.textlist.set_border_type(appearance.borders);
40 self.textlist
41 .set_style(Style::default().fg(appearance.colors.text));
42
43 if iteminfo.selected {
44 self.grid
45 .set_border_style(Style::default().fg(appearance.colors.outline_selected));
46 self.textlist
47 .set_cursor_style(Style::default().fg(appearance.colors.outline_hover));
48 self.textlist
49 .set_selected_style(Style::default().fg(appearance.colors.text_special));
50 } else {
51 self.textlist
52 .set_cursor_style(Style::default().fg(appearance.colors.outline_secondary));
53 self.textlist
54 .set_selected_style(Style::default().fg(appearance.colors.text_secondary));
55 if iteminfo.hover {
56 self.grid
57 .set_border_style(Style::default().fg(appearance.colors.outline_hover));
58 } else {
59 self.grid
60 .set_border_style(Style::default().fg(appearance.colors.outline));
61 }
62 }
63 }
64}
65
2866impl Default for ItemList {
2967 fn default() -> Self {
3068 Self {
@@ -54,19 +92,12 @@ impl FrameworkItem for ItemList {
5492 }
5593
5694 let appearance = framework.data.global.get::<AppearanceConfig>().unwrap();
95 let mainconfig = framework.data.global.get::<MainConfig>().unwrap();
96 self.update_appearance(appearance, mainconfig, &info);
5797
5898 // creates the grid
59 self.grid
60 .set_border_style(Style::default().fg(if info.hover {
61 appearance.colors.outline_hover
62 } else if info.selected {
63 appearance.colors.outline_selected
64 } else {
65 appearance.colors.outline
66 }));
67
6899 let grid = self.grid.clone();
69 let chunks = &grid.chunks(area).unwrap()[0];
100 let chunks = grid.chunks(area).unwrap()[0].to_owned();
70101
71102 // creates the text list in cell (0, 1)
72103 self.textlist.set_height(chunks[0].height);
@@ -96,19 +127,6 @@ impl FrameworkItem for ItemList {
96127 framework: &mut tui_additions::framework::FrameworkClean,
97128 _info: tui_additions::framework::ItemInfo,
98129 ) -> Result<(), Box<dyn Error>> {
99 let appearance = framework.data.global.get::<AppearanceConfig>().unwrap();
100
101 self.grid.set_border_type(appearance.borders);
102 self.textlist.set_border_type(appearance.borders);
103 self.textlist.set_ascii_only(
104 !framework
105 .data
106 .global
107 .get::<MainConfig>()
108 .unwrap()
109 .allow_unicode,
110 );
111
112130 let page = framework.data.state.get::<Page>().unwrap();
113131 let image_index = framework
114132 .data
@@ -144,6 +162,7 @@ impl FrameworkItem for ItemList {
144162 .map(|item| Item::from_search_item(item, image_index))
145163 .collect();
146164 }
165 _ => unreachable!("item `ItemList` cannot be used in `{page:?}`"),
147166 }
148167
149168 if framework
@@ -194,6 +213,25 @@ impl FrameworkItem for ItemList {
194213 KeyAction::MoveDown => self.textlist.down().is_ok(),
195214 KeyAction::MoveLeft => self.textlist.first().is_ok(),
196215 KeyAction::MoveRight => self.textlist.last().is_ok(),
216 KeyAction::Select => {
217 let page_to_load = match &self.items[self.textlist.selected] {
218 Item::MiniVideo(video) => {
219 Page::SingleItem(SingleItemPage::Video(video.id.clone()))
220 }
221 Item::MiniPlaylist(playlist) => {
222 Page::SingleItem(SingleItemPage::Playlist(playlist.id.clone()))
223 }
224 _ => unimplemented!(),
225 };
226 framework
227 .data
228 .state
229 .get_mut::<Tasks>()
230 .unwrap()
231 .priority
232 .push(Task::LoadPage(page_to_load));
233 false
234 }
197235 _ => false,
198236 };
199237
@@ -216,7 +254,7 @@ impl FrameworkItem for ItemList {
216254impl ItemList {
217255 // change `self.item` to the currently selected item
218256 pub fn update(&mut self) {
219 if self.items.len() == 0 {
257 if self.items.is_empty() {
220258 self.info.item = None;
221259 return;
222260 }
src/items/mod.rs +2
@@ -11,3 +11,5 @@ mod pagebutton;
1111pub use pagebutton::*;
1212mod searchfilters;
1313pub use searchfilters::*;
14mod singleitem;
15pub use singleitem::*;
src/items/searchfilters.rs +48 −4
@@ -1,8 +1,8 @@
11use crate::{
2 config::{AppearanceConfig, KeyBindingsConfig, Search, SearchFilters},
2 config::{AppearanceConfig, KeyBindingsConfig, MainConfig, Search, SearchFilters},
33 global::{
44 functions::popup_area,
5 structs::{KeyAction, Message, Status, Task, Tasks},
5 structs::{KeyAction, Message, Page, Status, Task, Tasks},
66 },
77};
88use tui::{
@@ -29,6 +29,7 @@ pub struct SearchFilter {
2929 pub left_options: Vec<&'static str>,
3030 pub current_hover: bool,
3131 pub grid: Grid,
32 pub previous_state: Option<SearchFilters>,
3233}
3334
3435impl Default for SearchFilter {
@@ -45,6 +46,7 @@ impl Default for SearchFilter {
4546 vec![Constraint::Percentage(100)],
4647 )
4748 .unwrap(),
49 previous_state: None,
4850 }
4951 }
5052}
@@ -116,7 +118,7 @@ impl FrameworkItem for SearchFilter {
116118 POPUP_MIN_HEIGHT,
117119 ))
118120 .alignment(Alignment::Center)
119 .style(Style::default().fg(appearance.colors.error_text))
121 .style(Style::default().fg(appearance.colors.text_error))
120122 .block(block);
121123
122124 frame.render_widget(paragraph, area);
@@ -172,7 +174,7 @@ impl FrameworkItem for SearchFilter {
172174 self.right_textlist.set_border_type(appearance.borders);
173175 self.grid.set_border_type(appearance.borders);
174176
175 self.update(&framework);
177 self.update(framework);
176178
177179 self.left_textlist.set_items(&self.left_options)?;
178180 self.right_textlist
@@ -198,6 +200,22 @@ impl FrameworkItem for SearchFilter {
198200 .priority
199201 .push(Task::ClearPage);
200202 self.update(framework);
203
204 // create a clone of search options only if `refresh_after_modifying_search_filters` is true
205 // and is a search page
206 if !framework
207 .data
208 .global
209 .get::<MainConfig>()
210 .unwrap()
211 .refresh_after_modifying_search_filters
212 {
213 return true;
214 }
215
216 if let Page::Search(search_options) = framework.data.state.get::<Page>().unwrap() {
217 self.previous_state = Some(search_options.filters);
218 }
201219 true
202220 }
203221
@@ -208,6 +226,32 @@ impl FrameworkItem for SearchFilter {
208226 .get_mut::<Status>()
209227 .unwrap()
210228 .popup_opened = false;
229
230 // refresh page only if changed and enabled in options
231 let search_options = framework.data.state.get::<Search>().unwrap().clone();
232 if self.previous_state.is_none()
233 || !framework
234 .data
235 .global
236 .get::<MainConfig>()
237 .unwrap()
238 .refresh_after_modifying_search_filters
239 || self.previous_state.unwrap() == search_options.filters
240 {
241 return true;
242 }
243
244 let page = framework.data.state.get_mut::<Page>().unwrap();
245 if let Page::Search(search) = page {
246 *search = search_options;
247 framework
248 .data
249 .state
250 .get_mut::<Tasks>()
251 .unwrap()
252 .priority
253 .push(Task::Reload);
254 }
211255 true
212256 }
213257
src/items/singleitem.rs added +283
@@ -0,0 +1,283 @@
1use std::collections::HashMap;
2use tui::{layout::Constraint, style::Style};
3use tui_additions::{
4 framework::FrameworkItem,
5 widgets::{Grid, TextList},
6};
7use super::ItemInfo;
8use crate::{
9 config::{AppearanceConfig, MainConfig, CommandsConfig},
10 global::{structs::{InvidiousClient, Item, Message, Page, SingleItemPage}, functions::download_all_images}
11};
12
13impl Default for SingleItem {
14 fn default() -> Self {
15 Self {
16 item: None,
17 iteminfo: ItemInfo::default(),
18 grid: Grid::new(
19 vec![Constraint::Percentage(30), Constraint::Percentage(70)],
20 vec![Constraint::Percentage(100)],
21 )
22 .unwrap(),
23 r#type: SingleItemType::None,
24 }
25 }
26}
27
28/// main item in the `SingleItem(_)` page
29#[derive(Clone)]
30pub struct SingleItem {
31 pub item: Option<Item>,
32 pub iteminfo: ItemInfo,
33 pub grid: Grid,
34 pub r#type: SingleItemType,
35}
36
37#[derive(Clone)]
38pub enum SingleItemType {
39 None,
40 Video(SingleVideoItem),
41 Playlist(SinglePlaylistItem),
42}
43
44#[derive(Clone)]
45pub struct SingleVideoItem {
46 pub textlist: TextList,
47 pub commands: HashMap<String, String>,
48}
49
50#[derive(Clone)]
51pub struct SinglePlaylistItem {
52 pub commands_view: TextList,
53 pub videos_view: TextList,
54 pub commands: HashMap<String, String>,
55 pub is_commands_view: bool,
56 pub hovered_video: ItemInfo,
57}
58
59impl SingleVideoItem {
60 pub fn new(commands: &CommandsConfig) -> Self {
61 Self {
62 textlist: TextList::default().items(&commands.video.keys().collect()).unwrap(),
63 commands: commands.video.clone(),
64 }
65 }
66
67 pub fn update_appearance(&mut self, appearance: &AppearanceConfig, iteminfo: &tui_additions::framework::ItemInfo) {
68 self.textlist.set_border_type(appearance.borders);
69 self.textlist
70 .set_style(Style::default().fg(appearance.colors.text));
71
72 if iteminfo.selected {
73 self.textlist
74 .set_cursor_style(Style::default().fg(appearance.colors.outline_hover));
75 self.textlist
76 .set_selected_style(Style::default().fg(appearance.colors.text_special));
77 } else {
78 self.textlist
79 .set_cursor_style(Style::default().fg(appearance.colors.outline_secondary));
80 self.textlist
81 .set_selected_style(Style::default().fg(appearance.colors.text_secondary));
82 }
83 }
84}
85
86impl SinglePlaylistItem {
87 pub fn new(commands: &CommandsConfig, playlist_items: &Vec<Item>) -> Self {
88 let mut hovered_video = ItemInfo::default();
89 hovered_video.item = if playlist_items.is_empty() {
90 None
91 } else {
92 Some(playlist_items[0].clone())
93 };
94 Self {
95 commands_view: TextList::default().items(&commands.playlist.keys().collect()).unwrap(),
96 videos_view: TextList::default().items(&playlist_items).unwrap(),
97 commands: commands.playlist.clone(),
98 hovered_video,
99 is_commands_view: true,
100 }
101 }
102
103 pub fn update_appearance(&mut self, appearance: &AppearanceConfig, iteminfo: &tui_additions::framework::ItemInfo, grid: &mut Grid) {
104 if self.is_commands_view {
105 grid.widths = vec![Constraint::Percentage(30), Constraint::Percentage(70)];
106 self.commands_view.set_border_type(appearance.borders);
107 self.commands_view.set_style(Style::default().fg(appearance.colors.text));
108
109 if iteminfo.selected {
110 self.commands_view
111 .set_cursor_style(Style::default().fg(appearance.colors.outline_hover));
112 self.commands_view
113 .set_selected_style(Style::default().fg(appearance.colors.text_special));
114 } else {
115 self.commands_view
116 .set_cursor_style(Style::default().fg(appearance.colors.outline_secondary));
117 self.commands_view
118 .set_selected_style(Style::default().fg(appearance.colors.text_secondary));
119 }
120 } else {
121 grid.widths = vec![Constraint::Percentage(30), Constraint::Percentage(40), Constraint::Percentage(30)];
122 self.videos_view.set_border_type(appearance.borders);
123 self.videos_view.set_style(Style::default().fg(appearance.colors.text));
124
125 if iteminfo.selected {
126 self.videos_view
127 .set_cursor_style(Style::default().fg(appearance.colors.outline_hover));
128 self.videos_view
129 .set_selected_style(Style::default().fg(appearance.colors.text_special));
130 } else {
131 self.videos_view
132 .set_cursor_style(Style::default().fg(appearance.colors.outline_secondary));
133 self.videos_view
134 .set_selected_style(Style::default().fg(appearance.colors.text_secondary));
135 }
136 }
137 }
138}
139
140impl SingleItemType {
141 pub fn update_appearance(&mut self, appearance: &AppearanceConfig, iteminfo: &tui_additions::framework::ItemInfo, grid: &mut Grid) {
142 match self {
143 Self::None => {},
144 Self::Playlist(playlistitem) => playlistitem.update_appearance(appearance, iteminfo, grid),
145 Self::Video(videoitem) => videoitem.update_appearance(appearance, iteminfo)
146 }
147 }
148}
149
150impl SingleItem {
151 fn update_appearance(
152 &mut self,
153 appearance: &AppearanceConfig,
154 iteminfo: &tui_additions::framework::ItemInfo,
155 ) {
156 self.grid.set_border_type(appearance.borders);
157
158 if iteminfo.selected {
159 self.grid
160 .set_border_style(Style::default().fg(appearance.colors.outline_selected));
161 } else {
162 if iteminfo.hover {
163 self.grid
164 .set_border_style(Style::default().fg(appearance.colors.outline_hover));
165 } else {
166 self.grid
167 .set_border_style(Style::default().fg(appearance.colors.outline));
168 }
169 }
170
171 self.r#type.update_appearance(appearance, iteminfo, &mut self.grid);
172 }
173}
174
175impl FrameworkItem for SingleItem {
176 fn render(
177 &mut self,
178 frame: &mut tui::Frame<tui::backend::CrosstermBackend<std::io::Stdout>>,
179 framework: &mut tui_additions::framework::FrameworkClean,
180 area: tui::layout::Rect,
181 popup_render: bool,
182 info: tui_additions::framework::ItemInfo,
183 ) {
184 if popup_render {
185 return;
186 }
187
188 let appearance = framework.data.global.get::<AppearanceConfig>().unwrap();
189 self.update_appearance(appearance, &info);
190
191 let chunks = self.grid.chunks(area).unwrap()[0].to_owned();
192
193 frame.render_widget(self.grid.clone(), area);
194
195 // only continue if `self.item` is Some
196 if self.item.is_none() {
197 return;
198 }
199
200 match &mut self.r#type {
201 SingleItemType::Video(typeinfo) => {
202 self.iteminfo
203 .render(frame, framework, chunks[0], popup_render, info);
204 typeinfo.textlist.set_height(chunks[1].height);
205 frame.render_widget(typeinfo.textlist.clone(), chunks[1]);
206 }
207 SingleItemType::Playlist(typeinfo) => {
208 self.iteminfo
209 .render(frame, framework, chunks[0], popup_render, info);
210 if typeinfo.is_commands_view {
211 typeinfo.commands_view.set_height(chunks[1].height);
212 frame.render_widget(typeinfo.commands_view.clone(), chunks[1]);
213 } else {
214 typeinfo.videos_view.set_height(chunks[1].height);
215 frame.render_widget(typeinfo.videos_view.clone(), chunks[1]);
216 typeinfo.hovered_video.render(frame, framework, chunks[2], popup_render, info);
217 }
218 }
219 SingleItemType::None => {}
220 }
221 }
222
223 fn load_item(
224 &mut self,
225 framework: &mut tui_additions::framework::FrameworkClean,
226 _info: tui_additions::framework::ItemInfo,
227 ) -> Result<(), Box<dyn std::error::Error>> {
228 let page = framework.data.state.get::<Page>().unwrap();
229
230 let r#type = if let Page::SingleItem(r#type) = page {
231 r#type
232 } else {
233 unreachable!("item `SingleItem` cannot be used in {page:?}")
234 };
235
236 let client = &framework.data.global.get::<InvidiousClient>().unwrap().0;
237 let mainconfig = framework.data.global.get::<MainConfig>().unwrap();
238
239 self.item = match r#type {
240 SingleItemPage::Video(id) => match client.video(id, None) {
241 Ok(video) => {
242 self.r#type = SingleItemType::Video(SingleVideoItem::new(framework.data.global.get::<CommandsConfig>().unwrap()));
243 let video = Item::from_full_video(video, mainconfig.image_index);
244 if mainconfig.images.display() {
245 download_all_images(vec![(&video).into()]);
246 }
247 Some(video)
248 },
249 Err(e) => {
250 *self = Self::default();
251 *framework.data.global.get_mut::<Message>().unwrap() =
252 Message::Error(e.to_string());
253 None
254 }
255 },
256 SingleItemPage::Playlist(id) => match client.playlist(id, None) {
257 Ok(playlist) => {
258 let playlist = Item::from_full_playlist(playlist, mainconfig.image_index);
259 let videos = if let Item::FullPlaylist(playlist) = &playlist {
260 &playlist.videos
261 } else {
262 unreachable!();
263 };
264 self.r#type = SingleItemType::Playlist(SinglePlaylistItem::new(framework.data.global.get::<CommandsConfig>().unwrap(), videos));
265 if mainconfig.images.display() {
266 download_all_images(vec![(&playlist).into()]);
267 }
268
269 Some(playlist)
270 },
271 Err(e) => {
272 *self = Self::default();
273 *framework.data.global.get_mut::<Message>().unwrap() =
274 Message::Error(e.to_string());
275 None
276 }
277 }
278 };
279 self.iteminfo.item = self.item.clone();
280
281 Ok(())
282 }
283}
src/run.rs +13 −8
@@ -14,13 +14,15 @@ pub fn run(
1414 mut framework: Framework,
1515) -> Result<(), Box<dyn Error>> {
1616 // push the initial page load
17 framework
17 let tasks = framework
1818 .data
1919 .state
2020 .get_mut::<Tasks>()
21 .unwrap()
22 .priority
21 .unwrap();
22 tasks.priority
2323 .push(Task::LoadPage(Page::MainMenu(MainMenuPage::Trending)));
24 tasks.pop().unwrap().run(&mut framework, terminal)?;
25 framework.clear_history();
2426
2527 loop {
2628 // repeat forever until all tasks are ran (and Tasks is cleared)
@@ -44,11 +46,7 @@ pub fn run(
4446 .0
4547 .get(&key.code)
4648 {
47 if let Some(action) = keyactions.get(&key.modifiers.bits()) {
48 Some(*action)
49 } else {
50 None
51 }
49 keyactions.get(&key.modifiers.bits()).copied()
5250 } else {
5351 None
5452 };
@@ -77,6 +75,13 @@ pub fn run(
7775 KeyAction::MoveDown => framework.r#move(FrameworkDirection::Down)?,
7876 KeyAction::MoveLeft => framework.r#move(FrameworkDirection::Left)?,
7977 KeyAction::MoveRight => framework.r#move(FrameworkDirection::Right)?,
78 KeyAction::Reload => framework
79 .data
80 .state
81 .get_mut::<Tasks>()
82 .unwrap()
83 .priority
84 .push(Task::Reload),
8085 KeyAction::Back => {
8186 if framework.revert_last_history().is_err() {
8287 *framework.data.global.get_mut::<Message>().unwrap() =