Commit 89296f2325

89296f2325a0958e39c39c6497afcfb145963f97

parent: cfbcdce9ae

Unsigned

siriusmart <siriusmart@tuta.io> · 2025-08-16 11:11 UTC

copied invidious-rs into youtube TUI, no longer depends on invidious (note: -F invidious currently does not work)

Layout: unified · split

Cargo.toml +1 −1
@@ -32,7 +32,7 @@ home = "0.5"
3232chrono = {version = "0.4", default-features = false, features = ["clock"]}
3333typemap = {version = "0.3", default-features = false}
3434tui-additions = {version = "0.4", default-features = false, features = ["framework", "widgets"]}
35invidious = { version = "0.7", default-features = false }
35invidious = { version = "0.7", default-features = false, optional = true }
3636serde_yaml_ng = {version = "0.10", default-features = false}
3737dyn-clone = {version = "1.0", default-features = false}
3838serde_json = {version = "1.0", default-features = false}
docs/src/changelogs.md +16 −3
@@ -1,16 +1,29 @@
11# Changelogs
22
3## v0.9.0 (latest)
4
3## v0.9.1 (Latest)
4
55### Added
6- Mouse scroll behavior (configurable) for SearchBar and command capture.
7
8### Fixed
9- The `:video [url]` command unable to identify video ID.
10- Clicking on area below text list does what you expect it to.
11
12---
13
14### v0.9.0
15
16#### Added
617
718- Support for RustyPipe in replacement of the Invidious API.
819- Separated out the code for fetching video info from the rest of the mess, making it easier to add new backends.
920
10### Fixed
21#### Fixed
1122
1223- All Invidious issues, because no longer depends on it.
1324
25---
26
1427### v0.8.3
1528
1629#### Added
docs/src/config/main.md +7
@@ -21,6 +21,7 @@ limits:
2121 watch_history: 50
2222 search_history: 75
2323 commands_history: 75
24textbar_scroll_behaviour: Word
2425image_index: 4
2526provider: YouTube
2627search_provider: RustyPipe
@@ -120,6 +121,12 @@ The maximum length that the watch/search/command history can hold, a value highe
120121
121122*Accept: positive integer below 2<sup>*your CPU architecture*</sup> - 1*
122123
124### textbar_scroll_behaviour
125
126What to do when mouse scrolls when the message bar or search bar is selected?
127
128*Accept: `Character`/`Word`/`History`*
129
123130### image_index
124131
125132The index in the array of thumbnail qualities you want to download
src/global/common/common_types.rs added +200
@@ -0,0 +1,200 @@
1use serde::{Deserialize, Serialize};
2
3use crate::global::common::{
4 channel::Channel, hidden::PlaylistItem, universal::Playlist, video::Video,
5};
6
7// https://docs.invidious.io/api/common_types/#videoobject
8
9/// Shared image object as specified in <https://docs.invidious.io/api/common_types/>
10#[derive(Serialize, Deserialize, Debug, Clone)]
11pub struct CommonImage {
12 pub url: String,
13 pub width: u32,
14 pub height: u32,
15}
16
17/// Shared thumbnail object as specified in <https://docs.invidious.io/api/common_types/>
18#[derive(Serialize, Deserialize, Debug, Clone)]
19pub struct CommonThumbnail {
20 #[serde(default)]
21 pub quality: String,
22 pub url: String,
23 pub width: u32,
24 pub height: u32,
25}
26
27/// Shared video object as specified in <https://docs.invidious.io/api/common_types/>
28#[derive(Serialize, Deserialize, Debug, Clone, Default)]
29pub struct CommonVideo {
30 pub title: String,
31 #[serde(rename = "videoId")]
32 pub id: String,
33
34 pub author: String,
35 #[serde(rename = "authorId")]
36 pub author_id: String,
37 #[serde(rename = "authorUrl")]
38 pub author_url: String,
39 // #[serde(rename = "authorVerified")]
40 // #[serde(default)]
41 // pub author_verified: bool,
42 #[serde(rename = "videoThumbnails")]
43 pub thumbnails: Vec<CommonThumbnail>,
44
45 pub description: String,
46 #[serde(rename = "descriptionHtml")]
47 pub description_html: String,
48
49 #[serde(rename = "viewCount")]
50 pub views: u64,
51 // #[serde(rename = "viewCountText")]
52 // pub views_text: String,
53 #[serde(rename = "lengthSeconds")]
54 pub length: u32,
55
56 pub published: u64,
57 #[serde(rename = "publishedText")]
58 pub published_text: String,
59
60 #[serde(rename = "premiereTimestamp")]
61 #[serde(default)]
62 pub premiere_timestamp: u64,
63
64 #[serde(rename = "liveNow")]
65 pub live: bool,
66 pub premium: bool,
67 #[serde(rename = "isUpcoming")]
68 pub upcoming: bool,
69}
70
71/// Shared channel object as specified in <https://docs.invidious.io/api/common_types/>
72#[derive(Serialize, Deserialize, Debug, Clone, Default)]
73pub struct CommonChannel {
74 #[serde(rename = "author")]
75 pub name: String,
76 #[serde(rename = "authorId")]
77 pub id: String,
78 #[serde(rename = "authorUrl")]
79 pub url: String,
80 #[serde(rename = "authorVerified")]
81 #[serde(default)]
82 pub verified: bool,
83 #[serde(rename = "authorThumbnails")]
84 pub thumbnails: Vec<CommonImage>,
85 #[serde(rename = "autoGenerated")]
86 #[serde(default)]
87 pub auto_generated: bool,
88 #[serde(rename = "subCount")]
89 pub subscribers: u32,
90 #[serde(rename = "videoCount")]
91 pub video_count: u32,
92 pub description: String,
93 #[serde(rename = "descriptionHtml")]
94 pub description_html: String,
95}
96
97/// Shared playlist object as specified in <https://docs.invidious.io/api/common_types/>
98#[derive(Serialize, Deserialize, Debug, Clone, Default)]
99pub struct CommonPlaylist {
100 pub title: String,
101 #[serde(rename = "playlistId")]
102 pub id: String,
103 #[serde(rename = "playlistThumbnail")]
104 #[serde(default)]
105 pub thumbnail: String,
106
107 pub author: String,
108 #[serde(rename = "authorId")]
109 pub author_id: String,
110 // #[serde(rename = "authorUrl")]
111 // pub author_url: String,
112 #[serde(rename = "authorVerified")]
113 #[serde(default)]
114 pub author_verified: bool,
115
116 #[serde(rename = "videoCount")]
117 pub video_count: i32,
118 pub videos: Vec<CommonPlaylistVideo>,
119}
120
121/// Playlist video struct used in CommonPlaylist
122#[derive(Serialize, Deserialize, Debug, Clone)]
123pub struct CommonPlaylistVideo {
124 pub title: String,
125 #[serde(rename = "videoId")]
126 pub id: String,
127 #[serde(rename = "lengthSeconds")]
128 pub length: u32,
129 #[serde(rename = "videoThumbnails")]
130 pub thumbnails: Vec<CommonThumbnail>,
131}
132
133impl From<Video> for CommonVideo {
134 fn from(value: Video) -> Self {
135 Self {
136 title: value.title,
137 id: value.id,
138 author: value.author,
139 author_id: value.author_id,
140 author_url: value.author_url,
141 thumbnails: value.thumbnails,
142 description: value.description,
143 description_html: value.description_html,
144 views: value.views,
145 length: value.length,
146 published: value.published,
147 published_text: value.published_text,
148 premiere_timestamp: value.premiere_timestamp,
149 live: value.live,
150 premium: value.premium,
151 upcoming: value.upcoming,
152 }
153 }
154}
155
156impl From<PlaylistItem> for CommonPlaylistVideo {
157 fn from(value: PlaylistItem) -> Self {
158 Self {
159 title: value.title,
160 id: value.id,
161 length: value.length,
162 thumbnails: value.thumbnails,
163 }
164 }
165}
166
167impl From<Playlist> for CommonPlaylist {
168 fn from(value: Playlist) -> Self {
169 Self {
170 title: value.title,
171 id: value.id,
172 thumbnail: value.thumbnail,
173 author: value.author,
174 author_id: value.author_id,
175 video_count: value.video_count as i32,
176 videos: value
177 .videos
178 .into_iter()
179 .map(CommonPlaylistVideo::from)
180 .collect(),
181 ..Default::default()
182 }
183 }
184}
185
186impl From<Channel> for CommonChannel {
187 fn from(value: Channel) -> Self {
188 Self {
189 name: value.name,
190 id: value.id,
191 url: value.url,
192 thumbnails: value.thumbnails,
193 auto_generated: value.auto_generated,
194 subscribers: value.subscribers,
195 description: value.description,
196 description_html: value.description_html,
197 ..Default::default()
198 }
199 }
200}
src/global/common/exposed/channel/channel.rs added +38
@@ -0,0 +1,38 @@
1use crate::global::common::{hidden::*, *};
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct Channel {
6 #[serde(rename = "author")]
7 pub name: String,
8 #[serde(rename = "authorId")]
9 pub id: String,
10 #[serde(rename = "authorUrl")]
11 pub url: String,
12 #[serde(rename = "authorBanners")]
13 pub banners: Vec<CommonImage>,
14 #[serde(rename = "authorThumbnails")]
15 pub thumbnails: Vec<CommonImage>,
16
17 #[serde(rename = "subCount")]
18 pub subscribers: u32,
19 #[serde(rename = "totalViews")]
20 pub total_views: u64,
21 pub joined: u64,
22
23 #[serde(rename = "autoGenerated")]
24 pub auto_generated: bool,
25 #[serde(rename = "isFamilyFriendly")]
26 pub family_friendly: bool,
27 pub description: String,
28 #[serde(rename = "descriptionHtml")]
29 pub description_html: String,
30 #[serde(rename = "allowedRegions")]
31 pub allowed_regions: Vec<CountryCode>,
32
33 #[serde(rename = "latestVideos")]
34 pub lastest_videos: Vec<CommonVideo>,
35
36 #[serde(rename = "relatedChannels")]
37 pub related_channels: Vec<RelatedChannel>,
38}
src/global/common/exposed/channel/comments.rs added +12
@@ -0,0 +1,12 @@
1use crate::global::common::hidden::*;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct ChannelComments {
6 #[serde(rename = "authorId")]
7 pub author_id: String,
8 pub comments: Vec<Comment>,
9 #[serde(default)]
10 pub content: String,
11 pub continuation: Option<String>,
12}
src/global/common/exposed/channel/mod.rs added +12
@@ -0,0 +1,12 @@
1#[allow(clippy::module_inception)]
2mod channel;
3mod comments;
4mod playlists;
5mod search;
6mod videos;
7
8pub use channel::*;
9pub use comments::*;
10pub use playlists::*;
11pub use search::*;
12pub use videos::*;
src/global/common/exposed/channel/playlists.rs added +8
@@ -0,0 +1,8 @@
1use crate::global::common::CommonPlaylist;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct ChannelPlaylists {
6 pub playlists: Vec<CommonPlaylist>,
7 pub continuation: Option<String>,
8}
src/global/common/exposed/channel/search.rs added +7
@@ -0,0 +1,7 @@
1use crate::global::common::hidden::*;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct ChannelSearch {
6 pub items: Vec<SearchItem>,
7}
src/global/common/exposed/channel/videos.rs added +8
@@ -0,0 +1,8 @@
1use crate::global::common::CommonVideo;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct ChannelVideos {
6 pub videos: Vec<CommonVideo>,
7 pub continuation: Option<String>,
8}
src/global/common/exposed/mod.rs added +12
@@ -0,0 +1,12 @@
1/// Channel related structs.
2///
3/// No reasons to look in here unless you want to re-implement functions yourself. Which you can do by first disabling all fetch features, and start with just the binding structs.
4pub mod channel;
5/// Structs that doesn't belong in either of the other two categories.
6///
7/// No reasons to look in here unless you want to re-implement functions yourself. Which you can do by first disabling all fetch features, and start with just the binding structs.
8pub mod universal;
9/// Video related structs.
10///
11/// No reasons to look in here unless you want to re-implement functions yourself. Which you can do by first disabling all fetch features, and start with just the binding structs.
12pub mod video;
src/global/common/exposed/universal/mixes.rs added +10
@@ -0,0 +1,10 @@
1use crate::global::common::hidden::*;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct Mix {
6 pub title: String,
7 #[serde(rename = "midId")]
8 pub id: String,
9 pub videos: Vec<MixVideo>,
10}
src/global/common/exposed/universal/mod.rs added +15
@@ -0,0 +1,15 @@
1mod mixes;
2mod playlists;
3mod popular;
4mod search;
5mod stats;
6mod suggestions;
7mod trending;
8
9pub use mixes::*;
10pub use playlists::*;
11pub use popular::*;
12pub use search::*;
13pub use stats::*;
14pub use suggestions::*;
15pub use trending::*;
src/global/common/exposed/universal/playlists.rs added +30
@@ -0,0 +1,30 @@
1use crate::global::common::{hidden::*, CommonImage};
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct Playlist {
6 pub title: String,
7 #[serde(rename = "playlistId")]
8 pub id: String,
9 #[serde(rename = "playlistThumbnail")]
10 pub thumbnail: String,
11
12 pub author: String,
13 #[serde(rename = "authorId")]
14 pub author_id: String,
15 #[serde(rename = "authorThumbnails")]
16 pub author_thumbnails: Vec<CommonImage>,
17 pub description: String,
18 #[serde(rename = "descriptionHtml")]
19 pub description_html: String,
20
21 #[serde(rename = "videoCount")]
22 pub video_count: u32,
23 #[serde(rename = "viewCount")]
24 pub views: u64,
25 pub updated: u64,
26 #[serde(rename = "isListed")]
27 pub listed: bool,
28
29 pub videos: Vec<PlaylistItem>,
30}
src/global/common/exposed/universal/popular.rs added +7
@@ -0,0 +1,7 @@
1use crate::global::common::hidden::*;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct Popular {
6 pub items: Vec<PopularItem>,
7}
src/global/common/exposed/universal/search.rs added +7
@@ -0,0 +1,7 @@
1use crate::global::common::hidden::*;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct Search {
6 pub items: Vec<SearchItem>,
7}
src/global/common/exposed/universal/stats.rs added +12
@@ -0,0 +1,12 @@
1use crate::global::common::hidden::*;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct Stats {
6 pub version: String,
7 pub software: Software,
8 #[serde(rename = "openRegistrations")]
9 pub registrations: bool,
10 pub usage: Usage,
11 pub metadata: Metadata,
12}
src/global/common/exposed/universal/suggestions.rs added +7
@@ -0,0 +1,7 @@
1use serde::{Deserialize, Serialize};
2
3#[derive(Serialize, Deserialize, Debug, Clone)]
4pub struct Suggestions {
5 pub query: String,
6 pub suggestions: Vec<String>,
7}
src/global/common/exposed/universal/trending.rs added +8
@@ -0,0 +1,8 @@
1use serde::{Deserialize, Serialize};
2
3use crate::global::common::CommonVideo;
4
5#[derive(Serialize, Deserialize, Debug, Clone)]
6pub struct Trending {
7 pub videos: Vec<CommonVideo>,
8}
src/global/common/exposed/video/annotations.rs added +1
@@ -0,0 +1 @@
1pub type Annotations = String;
src/global/common/exposed/video/captions.rs added +7
@@ -0,0 +1,7 @@
1use crate::global::common::hidden::*;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct Captions {
6 pub captions: Vec<Caption>,
7}
src/global/common/exposed/video/comments.rs added +12
@@ -0,0 +1,12 @@
1use crate::global::common::hidden::*;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct Comments {
6 #[serde(rename = "commentCount")]
7 pub comment_count: Option<u32>,
8 #[serde(rename = "videoId")]
9 pub id: String,
10 pub comments: Vec<Comment>,
11 pub continuation: Option<String>,
12}
src/global/common/exposed/video/mod.rs added +10
@@ -0,0 +1,10 @@
1mod annotations;
2mod captions;
3mod comments;
4#[allow(clippy::module_inception)]
5mod video;
6
7pub use annotations::*;
8pub use captions::*;
9pub use comments::*;
10pub use video::*;
src/global/common/exposed/video/video.rs added +75
@@ -0,0 +1,75 @@
1use crate::global::common::{hidden::*, CommonImage, CommonThumbnail};
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct Video {
6 #[serde(rename = "type")]
7 pub r#type: String,
8 pub title: String,
9 #[serde(rename = "videoId")]
10 pub id: String,
11 #[serde(rename = "videoThumbnails")]
12 pub thumbnails: Vec<CommonThumbnail>,
13 pub storyboards: Vec<Storyboard>,
14 pub description: String,
15 #[serde(rename = "descriptionHtml")]
16 pub description_html: String,
17 pub published: u64,
18 #[serde(rename = "publishedText")]
19 pub published_text: String,
20
21 pub keywords: Vec<String>,
22 #[serde(rename = "viewCount")]
23 pub views: u64,
24 #[serde(rename = "likeCount")]
25 pub likes: u32,
26 #[serde(rename = "dislikeCount")]
27 pub dislikes: u32,
28
29 pub paid: bool,
30 pub premium: bool,
31 #[serde(rename = "isFamilyFriendly")]
32 pub family_friendly: bool,
33 #[serde(rename = "allowedRegions")]
34 pub allowed_regions: Vec<CountryCode>,
35 pub genre: String,
36 #[serde(rename = "genreUrl")]
37 pub genre_url: Option<String>,
38
39 pub author: String,
40 #[serde(rename = "authorId")]
41 pub author_id: String,
42 #[serde(rename = "authorUrl")]
43 pub author_url: String,
44 #[serde(rename = "authorThumbnails")]
45 pub author_thumbnails: Vec<CommonImage>,
46
47 #[serde(rename = "subCountText")]
48 pub sub_count_text: String,
49 #[serde(rename = "lengthSeconds")]
50 pub length: u32,
51 #[serde(rename = "allowRatings")]
52 pub allow_ratings: bool,
53 pub rating: f32,
54 #[serde(rename = "isListed")]
55 pub listed: bool,
56 #[serde(rename = "liveNow")]
57 pub live: bool,
58 #[serde(rename = "isUpcoming")]
59 pub upcoming: bool,
60 #[serde(rename = "premiereTimestamp")]
61 #[serde(default)]
62 pub premiere_timestamp: u64,
63 #[serde(rename = "dashUrl")]
64 pub dash: String,
65
66 #[serde(rename = "adaptiveFormats")]
67 pub adaptive_formats: Vec<AdaptiveFormat>,
68 #[serde(rename = "formatStreams")]
69 pub format_streams: Vec<FormatStream>,
70
71 pub captions: Vec<Caption>,
72
73 #[serde(rename = "recommendedVideos")]
74 pub recommended_videos: Vec<VideoShort>,
75}
src/global/common/hidden/adaptiveformat.rs added +45
@@ -0,0 +1,45 @@
1use serde::{Deserialize, Serialize};
2
3#[derive(Serialize, Deserialize, Debug, Clone)]
4pub struct AdaptiveFormat {
5 #[serde(default)]
6 pub index: String,
7 #[serde(default)]
8 pub bitrate: String,
9 #[serde(default)]
10 pub init: String,
11 pub url: String,
12 pub itag: String,
13 #[serde(default)]
14 pub r#type: String,
15 #[serde(default)]
16 pub clen: String,
17 #[serde(default)]
18 pub lmt: String,
19 #[serde(default)]
20 #[serde(rename = "protectionType")]
21 pub projection_type: String,
22 #[serde(default)]
23 pub fps: u8,
24 #[serde(default)]
25 pub container: String,
26 #[serde(default)]
27 pub encoding: String,
28 #[serde(default)]
29 #[serde(rename = "quality")]
30 pub quality: String,
31 #[serde(default)]
32 pub resolution: String,
33 #[serde(default)]
34 #[serde(rename = "qualityLabel")]
35 pub quality_label: String,
36 #[serde(default)]
37 #[serde(rename = "audioQuality")]
38 pub audio_quality: String,
39 #[serde(default)]
40 #[serde(rename = "audioSampleRate")]
41 pub audio_sample_rate: usize,
42 #[serde(default)]
43 #[serde(rename = "audioChannels")]
44 pub audio_channels: usize,
45}
src/global/common/hidden/caption.rs added +10
@@ -0,0 +1,10 @@
1use serde::{Deserialize, Serialize};
2
3#[derive(Serialize, Deserialize, Debug, Clone)]
4pub struct Caption {
5 pub label: String,
6 #[serde(rename = "language_code")]
7 #[serde(default)]
8 pub language: String,
9 pub url: String,
10}
src/global/common/hidden/channelitems.rs added +14
@@ -0,0 +1,14 @@
1use crate::global::common::CommonImage;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct RelatedChannel {
6 #[serde(rename(serialize = "author", deserialize = "author"))]
7 pub name: String,
8 #[serde(rename(serialize = "authorId", deserialize = "authorId"))]
9 pub id: String,
10 #[serde(rename(serialize = "authorUrl", deserialize = "authorUrl"))]
11 pub url: String,
12 #[serde(rename(serialize = "authorThumbnails", deserialize = "authorThumbnails"))]
13 pub thumbnails: Vec<CommonImage>,
14}
src/global/common/hidden/comment.rs added +51
@@ -0,0 +1,51 @@
1use crate::global::common::CommonImage;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct Comment {
6 #[serde(default)]
7 pub verified: bool,
8 #[serde(rename = "commentId")]
9 pub id: String,
10 #[serde(rename = "likeCount")]
11 pub likes: u32,
12 #[serde(rename = "isEdited")]
13 pub edited: bool,
14 pub content: String,
15 #[serde(rename = "contentHtml")]
16 pub content_html: String,
17 pub published: u64,
18 #[serde(rename = "publishedText")]
19 pub published_text: String,
20
21 pub author: String,
22 #[serde(rename = "authorThumbnails")]
23 pub author_thumbnails: Vec<CommonImage>,
24 #[serde(rename = "authorId")]
25 pub author_id: String,
26 #[serde(rename = "authorUrl")]
27 pub author_url: String,
28
29 #[serde(rename = "authorIsChannelOwner")]
30 pub channel_owner: bool,
31 #[serde(default)]
32 #[serde(rename = "createrHeart")]
33 pub heart: Option<CreatorHeart>,
34 #[serde(default)]
35 pub replies: Option<Replies>,
36}
37
38#[derive(Serialize, Deserialize, Debug, Clone)]
39pub struct CreatorHeart {
40 #[serde(rename = "creatorThumbnail")]
41 pub thumbnail: String,
42 #[serde(rename = "creatorName")]
43 pub name: String,
44}
45
46#[derive(Serialize, Deserialize, Debug, Clone)]
47pub struct Replies {
48 #[serde(rename = "replyCount")]
49 replies: u32,
50 continuation: String,
51}
src/global/common/hidden/countrycodes.rs added +254
@@ -0,0 +1,254 @@
1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
4pub enum CountryCode {
5 AD,
6 AE,
7 AF,
8 AG,
9 AI,
10 AL,
11 AM,
12 AO,
13 AQ,
14 AR,
15 AS,
16 AT,
17 AU,
18 AW,
19 AX,
20 AZ,
21 BA,
22 BB,
23 BD,
24 BE,
25 BF,
26 BG,
27 BH,
28 BI,
29 BJ,
30 BL,
31 BM,
32 BN,
33 BO,
34 BQ,
35 BR,
36 BS,
37 BT,
38 BV,
39 BW,
40 BY,
41 BZ,
42 CA,
43 CC,
44 CD,
45 CF,
46 CG,
47 CH,
48 CI,
49 CK,
50 CL,
51 CM,
52 CN,
53 CO,
54 CR,
55 CU,
56 CV,
57 CW,
58 CX,
59 CY,
60 CZ,
61 DE,
62 DJ,
63 DK,
64 DM,
65 DO,
66 DZ,
67 EC,
68 EE,
69 EG,
70 EH,
71 ER,
72 ES,
73 ET,
74 FI,
75 FJ,
76 FK,
77 FM,
78 FO,
79 FR,
80 GA,
81 GB,
82 GD,
83 GE,
84 GF,
85 GG,
86 GH,
87 GI,
88 GL,
89 GM,
90 GN,
91 GP,
92 GQ,
93 GR,
94 GS,
95 GT,
96 GU,
97 GW,
98 GY,
99 HK,
100 HM,
101 HN,
102 HR,
103 HT,
104 HU,
105 ID,
106 IE,
107 IL,
108 IM,
109 IN,
110 IO,
111 IQ,
112 IR,
113 IS,
114 IT,
115 JE,
116 JM,
117 JO,
118 JP,
119 KE,
120 KG,
121 KH,
122 KI,
123 KM,
124 KN,
125 KP,
126 KR,
127 KW,
128 KY,
129 KZ,
130 LA,
131 LB,
132 LC,
133 LI,
134 LK,
135 LR,
136 LS,
137 LT,
138 LU,
139 LV,
140 LY,
141 MA,
142 MC,
143 MD,
144 ME,
145 MF,
146 MG,
147 MH,
148 MK,
149 ML,
150 MM,
151 MN,
152 MO,
153 MP,
154 MQ,
155 MR,
156 MS,
157 MT,
158 MU,
159 MV,
160 MW,
161 MX,
162 MY,
163 MZ,
164 NA,
165 NC,
166 NE,
167 NF,
168 NG,
169 NI,
170 NL,
171 NO,
172 NP,
173 NR,
174 NU,
175 NZ,
176 OM,
177 PA,
178 PE,
179 PF,
180 PG,
181 PH,
182 PK,
183 PL,
184 PM,
185 PN,
186 PR,
187 PS,
188 PT,
189 PW,
190 PY,
191 QA,
192 RE,
193 RO,
194 RS,
195 RU,
196 RW,
197 SA,
198 SB,
199 SC,
200 SD,
201 SE,
202 SG,
203 SH,
204 SI,
205 SJ,
206 SK,
207 SL,
208 SM,
209 SN,
210 SO,
211 SR,
212 SS,
213 ST,
214 SV,
215 SX,
216 SY,
217 SZ,
218 TC,
219 TD,
220 TF,
221 TG,
222 TH,
223 TJ,
224 TK,
225 TL,
226 TM,
227 TN,
228 TO,
229 TR,
230 TT,
231 TV,
232 TW,
233 TZ,
234 UA,
235 UG,
236 UM,
237 US,
238 UY,
239 UZ,
240 VA,
241 VC,
242 VE,
243 VG,
244 VI,
245 VN,
246 VU,
247 WF,
248 WS,
249 YE,
250 YT,
251 ZA,
252 ZM,
253 ZW,
254}
src/global/common/hidden/formatstream.rs added +15
@@ -0,0 +1,15 @@
1use serde::{Deserialize, Serialize};
2
3#[derive(Serialize, Deserialize, Debug, Clone)]
4pub struct FormatStream {
5 pub url: String,
6 pub itag: String,
7 pub r#type: String,
8 pub quality: String,
9 pub container: String,
10 pub encoding: String,
11 #[serde(rename = "qualityLabel")]
12 pub quality_label: String,
13 pub resolution: String,
14 pub size: String,
15}
src/global/common/hidden/mix.rs added +19
@@ -0,0 +1,19 @@
1use serde::{Deserialize, Serialize};
2
3use crate::global::common::CommonThumbnail;
4
5#[derive(Serialize, Deserialize, Debug, Clone)]
6pub struct MixVideo {
7 title: String,
8 #[serde(rename = "mixId")]
9 id: String,
10 #[serde(rename = "audioId")]
11 audio_id: String,
12 author: String,
13 #[serde(rename = "authorUrl")]
14 author_url: String,
15 videos: Vec<CommonThumbnail>,
16 index: u32,
17 #[serde(rename = "lengthSeconds")]
18 length: u32,
19}
src/global/common/hidden/mod.rs added +27
@@ -0,0 +1,27 @@
1mod adaptiveformat;
2mod caption;
3mod channelitems;
4mod comment;
5mod countrycodes;
6mod formatstream;
7mod mix;
8mod playlistvideo;
9mod popularitem;
10mod searchitem;
11mod statitems;
12mod storyboard;
13mod videoshort;
14
15pub use adaptiveformat::*;
16pub use caption::*;
17pub use channelitems::*;
18pub use comment::*;
19pub use countrycodes::*;
20pub use formatstream::*;
21pub use mix::*;
22pub use playlistvideo::*;
23pub use popularitem::*;
24pub use searchitem::*;
25pub use statitems::*;
26pub use storyboard::*;
27pub use videoshort::*;
src/global/common/hidden/playlistvideo.rs added +21
@@ -0,0 +1,21 @@
1use serde::{Deserialize, Serialize};
2
3use crate::global::common::CommonThumbnail;
4
5#[derive(Serialize, Deserialize, Debug, Clone)]
6pub struct PlaylistItem {
7 pub title: String,
8 #[serde(rename = "videoId")]
9 pub id: String,
10 pub author: String,
11 #[serde(rename = "authorId")]
12 pub author_id: String,
13 #[serde(rename = "authorUrl")]
14 pub author_url: String,
15
16 #[serde(rename = "videoThumbnails")]
17 pub thumbnails: Vec<CommonThumbnail>,
18 pub index: u32,
19 #[serde(rename = "lengthSeconds")]
20 pub length: u32,
21}
src/global/common/hidden/popularitem.rs added +28
@@ -0,0 +1,28 @@
1use serde::{Deserialize, Serialize};
2
3use crate::global::common::CommonThumbnail;
4
5#[derive(Serialize, Deserialize, Debug, Clone)]
6pub struct PopularItem {
7 pub r#type: String,
8 pub title: String,
9 #[serde(rename = "videoId")]
10 pub id: String,
11 #[serde(rename = "videoThumbnails")]
12 pub thumbnails: Vec<CommonThumbnail>,
13
14 #[serde(rename = "lengthSeconds")]
15 pub length: u32,
16 #[serde(rename = "viewCount")]
17 pub views: u64,
18
19 pub author: String,
20 #[serde(rename = "authorId")]
21 pub author_id: String,
22 #[serde(rename = "authorUrl")]
23 pub author_url: String,
24
25 pub published: u64,
26 #[serde(rename = "publishedText")]
27 pub published_text: String,
28}
src/global/common/hidden/searchitem.rs added +13
@@ -0,0 +1,13 @@
1use crate::global::common::*;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5#[serde(tag = "type")]
6pub enum SearchItem {
7 #[serde(rename = "video")]
8 Video(CommonVideo),
9 #[serde(rename = "playlist")]
10 Playlist(CommonPlaylist),
11 #[serde(rename = "channel")]
12 Channel(CommonChannel),
13}
src/global/common/hidden/statitems.rs added +30
@@ -0,0 +1,30 @@
1use serde::{Deserialize, Serialize};
2
3#[derive(Serialize, Deserialize, Debug, Clone)]
4pub struct Software {
5 pub name: String,
6 pub version: String,
7 pub branch: String,
8}
9
10#[derive(Serialize, Deserialize, Debug, Clone)]
11pub struct Usage {
12 pub users: Users,
13}
14
15#[derive(Serialize, Deserialize, Debug, Clone)]
16pub struct Users {
17 pub total: u32,
18 #[serde(rename = "activeHalfyear")]
19 pub half_year: u32,
20 #[serde(rename = "activeMonth")]
21 pub month: u32,
22}
23
24#[derive(Serialize, Deserialize, Debug, Clone)]
25pub struct Metadata {
26 #[serde(rename = "updatedAt")]
27 pub updated: u64,
28 #[serde(rename = "lastChannelRefreshedAt")]
29 pub last_channel_refresh: u64,
30}
src/global/common/hidden/storyboard.rs added +19
@@ -0,0 +1,19 @@
1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4pub struct Storyboard {
5 pub url: String,
6 #[serde(rename = "templateUrl")]
7 pub template_url: String,
8 pub width: u32,
9 pub height: u32,
10 pub count: i32,
11 pub interval: u32,
12 #[serde(rename = "storyboardWidth")]
13 pub storyboard_width: u16,
14 #[serde(rename = "storyboardHeight")]
15 pub storyboard_height: u16,
16 #[serde(rename = "storyboardCount")]
17 #[serde(default)]
18 pub storyboard_count: i16,
19}
src/global/common/hidden/videoshort.rs added +17
@@ -0,0 +1,17 @@
1use serde::{Deserialize, Serialize};
2
3use crate::global::common::CommonThumbnail;
4
5#[derive(Serialize, Deserialize, Debug, Clone)]
6pub struct VideoShort {
7 #[serde(rename = "videoId")]
8 pub id: String,
9 pub title: String,
10 #[serde(rename = "videoThumbnails")]
11 pub thumbnails: Vec<CommonThumbnail>,
12 pub author: String,
13 #[serde(rename = "lengthSeconds")]
14 pub length: u32,
15 #[serde(rename = "viewCountText")]
16 pub views_text: String,
17}
src/global/common/mod.rs added +7
@@ -0,0 +1,7 @@
1mod common_types;
2mod exposed;
3/// Structs that act as building blocks for other structs.
4pub mod hidden;
5
6pub use common_types::*;
7pub use exposed::*;
src/global/functions/run_command.rs +9 −3
@@ -19,7 +19,7 @@ use tui_additions::framework::Framework;
1919/// runs text command - command from the command line (not TUI) which response is just a string
2020pub fn text_command(command: &str) -> Option<String> {
2121 let command_parts: Vec<&str> = command.split_ascii_whitespace().collect();
22
22
2323 match command_parts.as_slice() {
2424 ["help"] => Some(help_msg(
2525 &CommandsRemapConfig::load(WriteConfig::Dont).unwrap(),
@@ -72,12 +72,18 @@ pub fn text_command(command: &str) -> Option<String> {
7272 }
7373 "channel" | "video" | "playlist" => {
7474 if command_parts.len() != 2 {
75 return Some(format!("Usage: `{} {{id/url}}`", command_parts[0]));
75 return Some(format!(
76 "Usage: `{} {{id/url}}`",
77 command_parts[0]
78 ));
7679 }
7780 }
7881 "search" => {
7982 if command_parts.len() < 2 {
80 return Some(format!("Usage: `{} {{query}}`", command_parts[0]));
83 return Some(format!(
84 "Usage: `{} {{query}}`",
85 command_parts[0]
86 ));
8187 }
8288 }
8389 _ => {}
src/global/mod.rs +1
@@ -1,4 +1,5 @@
11//! Structs , traits and functions for the entire app
2pub mod common;
23pub mod functions;
34pub mod structs;
45pub mod traits;
src/global/structs/item.rs +2 −2
@@ -1,8 +1,8 @@
1use crate::global::{functions::*, traits::CollectionItem};
2use invidious::{
1use crate::global::common::{
32 channel::Channel, hidden::*, universal::Playlist as FullPlaylist, video::Video, CommonChannel,
43 CommonPlaylist, CommonVideo,
54};
5use crate::global::{functions::*, traits::CollectionItem};
66use serde::{Deserialize, Serialize};
77use std::fmt::Display;
88
src/global/structs/rustypipe.rs +18 −18
@@ -1,4 +1,4 @@
1use invidious::{
1use crate::global::common::{
22 channel::Channel, hidden::SearchItem, universal::Playlist, video::Video, CommonChannel,
33 CommonImage, CommonPlaylist, CommonThumbnail, CommonVideo,
44};
@@ -49,7 +49,7 @@ fn image_convert(thumb: Thumbnail) -> CommonImage {
4949}
5050
5151fn video_item_convert(video: VideoItem) -> CommonVideo {
52 invidious::CommonVideo {
52 crate::global::common::CommonVideo {
5353 title: video.name,
5454 id: video.id,
5555 author: video
@@ -86,7 +86,7 @@ fn video_item_convert(video: VideoItem) -> CommonVideo {
8686}
8787
8888fn playlist_item_convert(playlist: PlaylistItem) -> CommonPlaylist {
89 invidious::CommonPlaylist {
89 crate::global::common::CommonPlaylist {
9090 title: playlist.name,
9191 id: playlist.id,
9292 thumbnail: playlist
@@ -114,7 +114,7 @@ fn playlist_item_convert(playlist: PlaylistItem) -> CommonPlaylist {
114114}
115115
116116fn channel_item_convert(channel: ChannelItem) -> CommonChannel {
117 invidious::CommonChannel {
117 crate::global::common::CommonChannel {
118118 name: channel.name,
119119 url: format!("https://www.youtube.com/channel/{}", channel.id),
120120 id: channel.id,
@@ -133,7 +133,10 @@ impl SearchProviderTrait for RustyPipeWrapper {
133133 true
134134 }
135135
136 fn video(&self, id: &str) -> Result<invidious::video::Video, Box<dyn std::error::Error>> {
136 fn video(
137 &self,
138 id: &str,
139 ) -> Result<crate::global::common::video::Video, Box<dyn std::error::Error>> {
137140 let query = self.0.query();
138141 let (player, details) = RUNTIME
139142 .get()
@@ -210,7 +213,7 @@ impl SearchProviderTrait for RustyPipeWrapper {
210213 fn search(
211214 &self,
212215 filters: &crate::config::Search,
213 ) -> Result<Vec<invidious::hidden::SearchItem>, Box<dyn std::error::Error>> {
216 ) -> Result<Vec<crate::global::common::hidden::SearchItem>, Box<dyn std::error::Error>> {
214217 let date = match filters.filters.date {
215218 SearchFilterDate::None => None,
216219 SearchFilterDate::Hour => Some(UploadDate::Hour),
@@ -270,7 +273,10 @@ impl SearchProviderTrait for RustyPipeWrapper {
270273 true
271274 }
272275
273 fn channel(&self, id: &str) -> Result<invidious::channel::Channel, Box<dyn std::error::Error>> {
276 fn channel(
277 &self,
278 id: &str,
279 ) -> Result<crate::global::common::channel::Channel, Box<dyn std::error::Error>> {
274280 let q = self.0.query();
275281 let (info, artist) = RUNTIME
276282 .get()
@@ -302,19 +308,13 @@ impl SearchProviderTrait for RustyPipeWrapper {
302308 })
303309 }
304310
305 fn supports_popular(&self) -> bool {
306 false
307 }
308
309 fn popular(&self) -> Result<Vec<invidious::hidden::PopularItem>, Box<dyn std::error::Error>> {
310 unimplemented!("not supported")
311 }
312
313311 fn supports_trending(&self) -> bool {
314312 true
315313 }
316314
317 fn trending(&self) -> Result<Vec<invidious::CommonVideo>, Box<dyn std::error::Error>> {
315 fn trending(
316 &self,
317 ) -> Result<Vec<crate::global::common::CommonVideo>, Box<dyn std::error::Error>> {
318318 let res = RUNTIME.get().unwrap().block_on(self.0.query().trending())?;
319319
320320 Ok(res.into_iter().map(video_item_convert).collect())
@@ -327,7 +327,7 @@ impl SearchProviderTrait for RustyPipeWrapper {
327327 fn playlist(
328328 &self,
329329 id: &str,
330 ) -> Result<invidious::universal::Playlist, Box<dyn std::error::Error>> {
330 ) -> Result<crate::global::common::universal::Playlist, Box<dyn std::error::Error>> {
331331 let res = RUNTIME
332332 .get()
333333 .unwrap()
@@ -365,7 +365,7 @@ impl SearchProviderTrait for RustyPipeWrapper {
365365 .videos
366366 .items
367367 .into_iter()
368 .map(|item| invidious::hidden::PlaylistItem {
368 .map(|item| crate::global::common::hidden::PlaylistItem {
369369 title: item.name,
370370 id: item.id,
371371 author: res
src/global/traits/search_provider.rs +60 −18
@@ -5,44 +5,86 @@ use std::{
55 sync::OnceLock,
66};
77
8use dyn_clone::DynClone;
9use invidious::{
8use crate::global::common::{
109 channel::Channel,
1110 hidden::{PopularItem, SearchItem},
1211 universal::Playlist,
1312 video::Video,
1413 CommonPlaylist, CommonVideo,
1514};
15use dyn_clone::DynClone;
1616
1717use crate::{
1818 config::{Search, SearchProvider},
1919 MAIN_CONFIG,
2020};
2121
22#[allow(unused_variables)]
2223pub trait SearchProviderTrait: DynClone + Send {
23 fn supports_channel(&self) -> bool;
24 fn channel(&self, id: &str) -> Result<Channel, Box<dyn Error>>;
24 fn supports_channel(&self) -> bool {
25 false
26 }
27 fn channel(&self, id: &str) -> Result<Channel, Box<dyn Error>> {
28 unimplemented!("channel not implemented")
29 }
2530
26 fn supports_channel_videos(&self) -> bool;
27 fn channel_videos(&self, id: &str) -> Result<Vec<CommonVideo>, Box<dyn Error>>;
31 fn supports_channel_videos(&self) -> bool {
32 false
33 }
34 fn channel_videos(&self, id: &str) -> Result<Vec<CommonVideo>, Box<dyn Error>> {
35 unimplemented!("channel_videos not implemented")
36 }
37
38 fn supports_channel_playlists(&self) -> bool {
39 false
40 }
41 fn channel_playlists(&self, id: &str) -> Result<Vec<CommonPlaylist>, Box<dyn Error>> {
42 unimplemented!("channel_playlists not implemented")
43 }
44
45 fn supports_trending(&self) -> bool {
46 false
47 }
48 fn trending(&self) -> Result<Vec<CommonVideo>, Box<dyn Error>> {
49 unimplemented!("trending not implemented")
50 }
2851
29 fn supports_channel_playlists(&self) -> bool;
30 fn channel_playlists(&self, id: &str) -> Result<Vec<CommonPlaylist>, Box<dyn Error>>;
52 fn supports_popular(&self) -> bool {
53 false
54 }
55 fn popular(&self) -> Result<Vec<PopularItem>, Box<dyn Error>> {
56 unimplemented!("popular not implemented")
57 }
3158
32 fn supports_trending(&self) -> bool;
33 fn trending(&self) -> Result<Vec<CommonVideo>, Box<dyn Error>>;
59 fn supports_search(&self) -> bool {
60 false
61 }
62 fn search(&self, filters: &Search) -> Result<Vec<SearchItem>, Box<dyn Error>> {
63 unimplemented!("search not implemented")
64 }
3465
35 fn supports_popular(&self) -> bool;
36 fn popular(&self) -> Result<Vec<PopularItem>, Box<dyn Error>>;
66 fn supports_video(&self) -> bool {
67 false
68 }
69 fn video(&self, id: &str) -> Result<Video, Box<dyn Error>> {
70 unimplemented!("video not implemented")
71 }
3772
38 fn supports_search(&self) -> bool;
39 fn search(&self, filters: &Search) -> Result<Vec<SearchItem>, Box<dyn Error>>;
73 fn supports_playlist(&self) -> bool {
74 false
75 }
76 fn playlist(&self, id: &str) -> Result<Playlist, Box<dyn Error>> {
77 unimplemented!("playlist not implemented")
78 }
4079
41 fn supports_video(&self) -> bool;
42 fn video(&self, id: &str) -> Result<Video, Box<dyn Error>>;
80 /*
81 fn supports_album(&self) -> bool {
82 false
83 }
84 fn album(&self) -> Result {
4385
44 fn supports_playlist(&self) -> bool;
45 fn playlist(&self, id: &str) -> Result<Playlist, Box<dyn Error>>;
86 }
87 */
4688}
4789
4890dyn_clone::clone_trait_object!(SearchProviderTrait);