Commit 89296f2325
Unsigned
Layout: unified · split
Cargo.toml +1 −1
| @@ -32,7 +32,7 @@ home = "0.5" | |||
| 32 | chrono = {version = "0.4", default-features = false, features = ["clock"]} | 32 | chrono = {version = "0.4", default-features = false, features = ["clock"]} |
| 33 | typemap = {version = "0.3", default-features = false} | 33 | typemap = {version = "0.3", default-features = false} |
| 34 | tui-additions = {version = "0.4", default-features = false, features = ["framework", "widgets"]} | 34 | tui-additions = {version = "0.4", default-features = false, features = ["framework", "widgets"]} |
| 35 | invidious = { version = "0.7", default-features = false } | 35 | invidious = { version = "0.7", default-features = false, optional = true } |
| 36 | serde_yaml_ng = {version = "0.10", default-features = false} | 36 | serde_yaml_ng = {version = "0.10", default-features = false} |
| 37 | dyn-clone = {version = "1.0", default-features = false} | 37 | dyn-clone = {version = "1.0", default-features = false} |
| 38 | serde_json = {version = "1.0", default-features = false} | 38 | serde_json = {version = "1.0", default-features = false} |
docs/src/changelogs.md +16 −3
| @@ -1,16 +1,29 @@ | |||
| 1 | # Changelogs | 1 | # Changelogs |
| 2 | 2 | ||
| 3 | ## v0.9.0 (latest) | 3 | ## v0.9.1 (Latest) |
| 4 | 4 | ||
| 5 | ### Added | 5 | ### 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 | ||
| 6 | 17 | ||
| 7 | - Support for RustyPipe in replacement of the Invidious API. | 18 | - Support for RustyPipe in replacement of the Invidious API. |
| 8 | - Separated out the code for fetching video info from the rest of the mess, making it easier to add new backends. | 19 | - Separated out the code for fetching video info from the rest of the mess, making it easier to add new backends. |
| 9 | 20 | ||
| 10 | ### Fixed | 21 | #### Fixed |
| 11 | 22 | ||
| 12 | - All Invidious issues, because no longer depends on it. | 23 | - All Invidious issues, because no longer depends on it. |
| 13 | 24 | ||
| 25 | --- | ||
| 26 | |||
| 14 | ### v0.8.3 | 27 | ### v0.8.3 |
| 15 | 28 | ||
| 16 | #### Added | 29 | #### Added |
docs/src/config/main.md +7
| @@ -21,6 +21,7 @@ limits: | |||
| 21 | watch_history: 50 | 21 | watch_history: 50 |
| 22 | search_history: 75 | 22 | search_history: 75 |
| 23 | commands_history: 75 | 23 | commands_history: 75 |
| 24 | textbar_scroll_behaviour: Word | ||
| 24 | image_index: 4 | 25 | image_index: 4 |
| 25 | provider: YouTube | 26 | provider: YouTube |
| 26 | search_provider: RustyPipe | 27 | search_provider: RustyPipe |
| @@ -120,6 +121,12 @@ The maximum length that the watch/search/command history can hold, a value highe | |||
| 120 | 121 | ||
| 121 | *Accept: positive integer below 2<sup>*your CPU architecture*</sup> - 1* | 122 | *Accept: positive integer below 2<sup>*your CPU architecture*</sup> - 1* |
| 122 | 123 | ||
| 124 | ### textbar_scroll_behaviour | ||
| 125 | |||
| 126 | What to do when mouse scrolls when the message bar or search bar is selected? | ||
| 127 | |||
| 128 | *Accept: `Character`/`Word`/`History`* | ||
| 129 | |||
| 123 | ### image_index | 130 | ### image_index |
| 124 | 131 | ||
| 125 | The index in the array of thumbnail qualities you want to download | 132 | The index in the array of thumbnail qualities you want to download |
src/global/common/common_types.rs added +200
| @@ -0,0 +1,200 @@ | |||
| 1 | use serde::{Deserialize, Serialize}; | ||
| 2 | |||
| 3 | use 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)] | ||
| 11 | pub 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)] | ||
| 19 | pub 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)] | ||
| 29 | pub 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)] | ||
| 73 | pub 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)] | ||
| 99 | pub 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)] | ||
| 123 | pub 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 | |||
| 133 | impl 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 | |||
| 156 | impl 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 | |||
| 167 | impl 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 | |||
| 186 | impl 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 @@ | |||
| 1 | use crate::global::common::{hidden::*, *}; | ||
| 2 | use serde::{Deserialize, Serialize}; | ||
| 3 | |||
| 4 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 5 | pub 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 @@ | |||
| 1 | use crate::global::common::hidden::*; | ||
| 2 | use serde::{Deserialize, Serialize}; | ||
| 3 | |||
| 4 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 5 | pub 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)] | ||
| 2 | mod channel; | ||
| 3 | mod comments; | ||
| 4 | mod playlists; | ||
| 5 | mod search; | ||
| 6 | mod videos; | ||
| 7 | |||
| 8 | pub use channel::*; | ||
| 9 | pub use comments::*; | ||
| 10 | pub use playlists::*; | ||
| 11 | pub use search::*; | ||
| 12 | pub use videos::*; | ||
src/global/common/exposed/channel/playlists.rs added +8
| @@ -0,0 +1,8 @@ | |||
| 1 | use crate::global::common::CommonPlaylist; | ||
| 2 | use serde::{Deserialize, Serialize}; | ||
| 3 | |||
| 4 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 5 | pub 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 @@ | |||
| 1 | use crate::global::common::hidden::*; | ||
| 2 | use serde::{Deserialize, Serialize}; | ||
| 3 | |||
| 4 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 5 | pub struct ChannelSearch { | ||
| 6 | pub items: Vec<SearchItem>, | ||
| 7 | } | ||
src/global/common/exposed/channel/videos.rs added +8
| @@ -0,0 +1,8 @@ | |||
| 1 | use crate::global::common::CommonVideo; | ||
| 2 | use serde::{Deserialize, Serialize}; | ||
| 3 | |||
| 4 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 5 | pub 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. | ||
| 4 | pub 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. | ||
| 8 | pub 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. | ||
| 12 | pub mod video; | ||
src/global/common/exposed/universal/mixes.rs added +10
| @@ -0,0 +1,10 @@ | |||
| 1 | use crate::global::common::hidden::*; | ||
| 2 | use serde::{Deserialize, Serialize}; | ||
| 3 | |||
| 4 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 5 | pub 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 @@ | |||
| 1 | mod mixes; | ||
| 2 | mod playlists; | ||
| 3 | mod popular; | ||
| 4 | mod search; | ||
| 5 | mod stats; | ||
| 6 | mod suggestions; | ||
| 7 | mod trending; | ||
| 8 | |||
| 9 | pub use mixes::*; | ||
| 10 | pub use playlists::*; | ||
| 11 | pub use popular::*; | ||
| 12 | pub use search::*; | ||
| 13 | pub use stats::*; | ||
| 14 | pub use suggestions::*; | ||
| 15 | pub use trending::*; | ||
src/global/common/exposed/universal/playlists.rs added +30
| @@ -0,0 +1,30 @@ | |||
| 1 | use crate::global::common::{hidden::*, CommonImage}; | ||
| 2 | use serde::{Deserialize, Serialize}; | ||
| 3 | |||
| 4 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 5 | pub 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 @@ | |||
| 1 | use crate::global::common::hidden::*; | ||
| 2 | use serde::{Deserialize, Serialize}; | ||
| 3 | |||
| 4 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 5 | pub struct Popular { | ||
| 6 | pub items: Vec<PopularItem>, | ||
| 7 | } | ||
src/global/common/exposed/universal/search.rs added +7
| @@ -0,0 +1,7 @@ | |||
| 1 | use crate::global::common::hidden::*; | ||
| 2 | use serde::{Deserialize, Serialize}; | ||
| 3 | |||
| 4 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 5 | pub struct Search { | ||
| 6 | pub items: Vec<SearchItem>, | ||
| 7 | } | ||
src/global/common/exposed/universal/stats.rs added +12
| @@ -0,0 +1,12 @@ | |||
| 1 | use crate::global::common::hidden::*; | ||
| 2 | use serde::{Deserialize, Serialize}; | ||
| 3 | |||
| 4 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 5 | pub 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 @@ | |||
| 1 | use serde::{Deserialize, Serialize}; | ||
| 2 | |||
| 3 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 4 | pub 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 @@ | |||
| 1 | use serde::{Deserialize, Serialize}; | ||
| 2 | |||
| 3 | use crate::global::common::CommonVideo; | ||
| 4 | |||
| 5 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 6 | pub struct Trending { | ||
| 7 | pub videos: Vec<CommonVideo>, | ||
| 8 | } | ||
src/global/common/exposed/video/annotations.rs added +1
| @@ -0,0 +1 @@ | |||
| 1 | pub type Annotations = String; | ||
src/global/common/exposed/video/captions.rs added +7
| @@ -0,0 +1,7 @@ | |||
| 1 | use crate::global::common::hidden::*; | ||
| 2 | use serde::{Deserialize, Serialize}; | ||
| 3 | |||
| 4 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 5 | pub struct Captions { | ||
| 6 | pub captions: Vec<Caption>, | ||
| 7 | } | ||
src/global/common/exposed/video/comments.rs added +12
| @@ -0,0 +1,12 @@ | |||
| 1 | use crate::global::common::hidden::*; | ||
| 2 | use serde::{Deserialize, Serialize}; | ||
| 3 | |||
| 4 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 5 | pub 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 @@ | |||
| 1 | mod annotations; | ||
| 2 | mod captions; | ||
| 3 | mod comments; | ||
| 4 | #[allow(clippy::module_inception)] | ||
| 5 | mod video; | ||
| 6 | |||
| 7 | pub use annotations::*; | ||
| 8 | pub use captions::*; | ||
| 9 | pub use comments::*; | ||
| 10 | pub use video::*; | ||
src/global/common/exposed/video/video.rs added +75
| @@ -0,0 +1,75 @@ | |||
| 1 | use crate::global::common::{hidden::*, CommonImage, CommonThumbnail}; | ||
| 2 | use serde::{Deserialize, Serialize}; | ||
| 3 | |||
| 4 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 5 | pub 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 @@ | |||
| 1 | use serde::{Deserialize, Serialize}; | ||
| 2 | |||
| 3 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 4 | pub 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 @@ | |||
| 1 | use serde::{Deserialize, Serialize}; | ||
| 2 | |||
| 3 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 4 | pub 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 @@ | |||
| 1 | use crate::global::common::CommonImage; | ||
| 2 | use serde::{Deserialize, Serialize}; | ||
| 3 | |||
| 4 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 5 | pub 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 @@ | |||
| 1 | use crate::global::common::CommonImage; | ||
| 2 | use serde::{Deserialize, Serialize}; | ||
| 3 | |||
| 4 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 5 | pub 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)] | ||
| 39 | pub 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)] | ||
| 47 | pub 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 @@ | |||
| 1 | use serde::{Deserialize, Serialize}; | ||
| 2 | |||
| 3 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] | ||
| 4 | pub 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 @@ | |||
| 1 | use serde::{Deserialize, Serialize}; | ||
| 2 | |||
| 3 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 4 | pub 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 @@ | |||
| 1 | use serde::{Deserialize, Serialize}; | ||
| 2 | |||
| 3 | use crate::global::common::CommonThumbnail; | ||
| 4 | |||
| 5 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 6 | pub 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 @@ | |||
| 1 | mod adaptiveformat; | ||
| 2 | mod caption; | ||
| 3 | mod channelitems; | ||
| 4 | mod comment; | ||
| 5 | mod countrycodes; | ||
| 6 | mod formatstream; | ||
| 7 | mod mix; | ||
| 8 | mod playlistvideo; | ||
| 9 | mod popularitem; | ||
| 10 | mod searchitem; | ||
| 11 | mod statitems; | ||
| 12 | mod storyboard; | ||
| 13 | mod videoshort; | ||
| 14 | |||
| 15 | pub use adaptiveformat::*; | ||
| 16 | pub use caption::*; | ||
| 17 | pub use channelitems::*; | ||
| 18 | pub use comment::*; | ||
| 19 | pub use countrycodes::*; | ||
| 20 | pub use formatstream::*; | ||
| 21 | pub use mix::*; | ||
| 22 | pub use playlistvideo::*; | ||
| 23 | pub use popularitem::*; | ||
| 24 | pub use searchitem::*; | ||
| 25 | pub use statitems::*; | ||
| 26 | pub use storyboard::*; | ||
| 27 | pub use videoshort::*; | ||
src/global/common/hidden/playlistvideo.rs added +21
| @@ -0,0 +1,21 @@ | |||
| 1 | use serde::{Deserialize, Serialize}; | ||
| 2 | |||
| 3 | use crate::global::common::CommonThumbnail; | ||
| 4 | |||
| 5 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 6 | pub 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 @@ | |||
| 1 | use serde::{Deserialize, Serialize}; | ||
| 2 | |||
| 3 | use crate::global::common::CommonThumbnail; | ||
| 4 | |||
| 5 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 6 | pub 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 @@ | |||
| 1 | use crate::global::common::*; | ||
| 2 | use serde::{Deserialize, Serialize}; | ||
| 3 | |||
| 4 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 5 | #[serde(tag = "type")] | ||
| 6 | pub 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 @@ | |||
| 1 | use serde::{Deserialize, Serialize}; | ||
| 2 | |||
| 3 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 4 | pub struct Software { | ||
| 5 | pub name: String, | ||
| 6 | pub version: String, | ||
| 7 | pub branch: String, | ||
| 8 | } | ||
| 9 | |||
| 10 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 11 | pub struct Usage { | ||
| 12 | pub users: Users, | ||
| 13 | } | ||
| 14 | |||
| 15 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 16 | pub 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)] | ||
| 25 | pub 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 @@ | |||
| 1 | use serde::{Deserialize, Serialize}; | ||
| 2 | |||
| 3 | #[derive(Debug, Clone, Serialize, Deserialize)] | ||
| 4 | pub 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 @@ | |||
| 1 | use serde::{Deserialize, Serialize}; | ||
| 2 | |||
| 3 | use crate::global::common::CommonThumbnail; | ||
| 4 | |||
| 5 | #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| 6 | pub 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 @@ | |||
| 1 | mod common_types; | ||
| 2 | mod exposed; | ||
| 3 | /// Structs that act as building blocks for other structs. | ||
| 4 | pub mod hidden; | ||
| 5 | |||
| 6 | pub use common_types::*; | ||
| 7 | pub use exposed::*; | ||
src/global/functions/run_command.rs +9 −3
| @@ -19,7 +19,7 @@ use tui_additions::framework::Framework; | |||
| 19 | /// runs text command - command from the command line (not TUI) which response is just a string | 19 | /// runs text command - command from the command line (not TUI) which response is just a string |
| 20 | pub fn text_command(command: &str) -> Option<String> { | 20 | pub fn text_command(command: &str) -> Option<String> { |
| 21 | let command_parts: Vec<&str> = command.split_ascii_whitespace().collect(); | 21 | let command_parts: Vec<&str> = command.split_ascii_whitespace().collect(); |
| 22 | 22 | ||
| 23 | match command_parts.as_slice() { | 23 | match command_parts.as_slice() { |
| 24 | ["help"] => Some(help_msg( | 24 | ["help"] => Some(help_msg( |
| 25 | &CommandsRemapConfig::load(WriteConfig::Dont).unwrap(), | 25 | &CommandsRemapConfig::load(WriteConfig::Dont).unwrap(), |
| @@ -72,12 +72,18 @@ pub fn text_command(command: &str) -> Option<String> { | |||
| 72 | } | 72 | } |
| 73 | "channel" | "video" | "playlist" => { | 73 | "channel" | "video" | "playlist" => { |
| 74 | if command_parts.len() != 2 { | 74 | 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 | )); | ||
| 76 | } | 79 | } |
| 77 | } | 80 | } |
| 78 | "search" => { | 81 | "search" => { |
| 79 | if command_parts.len() < 2 { | 82 | 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 | )); | ||
| 81 | } | 87 | } |
| 82 | } | 88 | } |
| 83 | _ => {} | 89 | _ => {} |
src/global/mod.rs +1
| @@ -1,4 +1,5 @@ | |||
| 1 | //! Structs , traits and functions for the entire app | 1 | //! Structs , traits and functions for the entire app |
| 2 | pub mod common; | ||
| 2 | pub mod functions; | 3 | pub mod functions; |
| 3 | pub mod structs; | 4 | pub mod structs; |
| 4 | pub mod traits; | 5 | pub mod traits; |
src/global/structs/item.rs +2 −2
| @@ -1,8 +1,8 @@ | |||
| 1 | use crate::global::{functions::*, traits::CollectionItem}; | 1 | use crate::global::common::{ |
| 2 | use invidious::{ | ||
| 3 | channel::Channel, hidden::*, universal::Playlist as FullPlaylist, video::Video, CommonChannel, | 2 | channel::Channel, hidden::*, universal::Playlist as FullPlaylist, video::Video, CommonChannel, |
| 4 | CommonPlaylist, CommonVideo, | 3 | CommonPlaylist, CommonVideo, |
| 5 | }; | 4 | }; |
| 5 | use crate::global::{functions::*, traits::CollectionItem}; | ||
| 6 | use serde::{Deserialize, Serialize}; | 6 | use serde::{Deserialize, Serialize}; |
| 7 | use std::fmt::Display; | 7 | use std::fmt::Display; |
| 8 | 8 | ||
src/global/structs/rustypipe.rs +18 −18
| @@ -1,4 +1,4 @@ | |||
| 1 | use invidious::{ | 1 | use crate::global::common::{ |
| 2 | channel::Channel, hidden::SearchItem, universal::Playlist, video::Video, CommonChannel, | 2 | channel::Channel, hidden::SearchItem, universal::Playlist, video::Video, CommonChannel, |
| 3 | CommonImage, CommonPlaylist, CommonThumbnail, CommonVideo, | 3 | CommonImage, CommonPlaylist, CommonThumbnail, CommonVideo, |
| 4 | }; | 4 | }; |
| @@ -49,7 +49,7 @@ fn image_convert(thumb: Thumbnail) -> CommonImage { | |||
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | fn video_item_convert(video: VideoItem) -> CommonVideo { | 51 | fn video_item_convert(video: VideoItem) -> CommonVideo { |
| 52 | invidious::CommonVideo { | 52 | crate::global::common::CommonVideo { |
| 53 | title: video.name, | 53 | title: video.name, |
| 54 | id: video.id, | 54 | id: video.id, |
| 55 | author: video | 55 | author: video |
| @@ -86,7 +86,7 @@ fn video_item_convert(video: VideoItem) -> CommonVideo { | |||
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | fn playlist_item_convert(playlist: PlaylistItem) -> CommonPlaylist { | 88 | fn playlist_item_convert(playlist: PlaylistItem) -> CommonPlaylist { |
| 89 | invidious::CommonPlaylist { | 89 | crate::global::common::CommonPlaylist { |
| 90 | title: playlist.name, | 90 | title: playlist.name, |
| 91 | id: playlist.id, | 91 | id: playlist.id, |
| 92 | thumbnail: playlist | 92 | thumbnail: playlist |
| @@ -114,7 +114,7 @@ fn playlist_item_convert(playlist: PlaylistItem) -> CommonPlaylist { | |||
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | fn channel_item_convert(channel: ChannelItem) -> CommonChannel { | 116 | fn channel_item_convert(channel: ChannelItem) -> CommonChannel { |
| 117 | invidious::CommonChannel { | 117 | crate::global::common::CommonChannel { |
| 118 | name: channel.name, | 118 | name: channel.name, |
| 119 | url: format!("https://www.youtube.com/channel/{}", channel.id), | 119 | url: format!("https://www.youtube.com/channel/{}", channel.id), |
| 120 | id: channel.id, | 120 | id: channel.id, |
| @@ -133,7 +133,10 @@ impl SearchProviderTrait for RustyPipeWrapper { | |||
| 133 | true | 133 | true |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 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>> { | ||
| 137 | let query = self.0.query(); | 140 | let query = self.0.query(); |
| 138 | let (player, details) = RUNTIME | 141 | let (player, details) = RUNTIME |
| 139 | .get() | 142 | .get() |
| @@ -210,7 +213,7 @@ impl SearchProviderTrait for RustyPipeWrapper { | |||
| 210 | fn search( | 213 | fn search( |
| 211 | &self, | 214 | &self, |
| 212 | filters: &crate::config::Search, | 215 | 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>> { |
| 214 | let date = match filters.filters.date { | 217 | let date = match filters.filters.date { |
| 215 | SearchFilterDate::None => None, | 218 | SearchFilterDate::None => None, |
| 216 | SearchFilterDate::Hour => Some(UploadDate::Hour), | 219 | SearchFilterDate::Hour => Some(UploadDate::Hour), |
| @@ -270,7 +273,10 @@ impl SearchProviderTrait for RustyPipeWrapper { | |||
| 270 | true | 273 | true |
| 271 | } | 274 | } |
| 272 | 275 | ||
| 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>> { | ||
| 274 | let q = self.0.query(); | 280 | let q = self.0.query(); |
| 275 | let (info, artist) = RUNTIME | 281 | let (info, artist) = RUNTIME |
| 276 | .get() | 282 | .get() |
| @@ -302,19 +308,13 @@ impl SearchProviderTrait for RustyPipeWrapper { | |||
| 302 | }) | 308 | }) |
| 303 | } | 309 | } |
| 304 | 310 | ||
| 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 | |||
| 313 | fn supports_trending(&self) -> bool { | 311 | fn supports_trending(&self) -> bool { |
| 314 | true | 312 | true |
| 315 | } | 313 | } |
| 316 | 314 | ||
| 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>> { | ||
| 318 | let res = RUNTIME.get().unwrap().block_on(self.0.query().trending())?; | 318 | let res = RUNTIME.get().unwrap().block_on(self.0.query().trending())?; |
| 319 | 319 | ||
| 320 | Ok(res.into_iter().map(video_item_convert).collect()) | 320 | Ok(res.into_iter().map(video_item_convert).collect()) |
| @@ -327,7 +327,7 @@ impl SearchProviderTrait for RustyPipeWrapper { | |||
| 327 | fn playlist( | 327 | fn playlist( |
| 328 | &self, | 328 | &self, |
| 329 | id: &str, | 329 | id: &str, |
| 330 | ) -> Result<invidious::universal::Playlist, Box<dyn std::error::Error>> { | 330 | ) -> Result<crate::global::common::universal::Playlist, Box<dyn std::error::Error>> { |
| 331 | let res = RUNTIME | 331 | let res = RUNTIME |
| 332 | .get() | 332 | .get() |
| 333 | .unwrap() | 333 | .unwrap() |
| @@ -365,7 +365,7 @@ impl SearchProviderTrait for RustyPipeWrapper { | |||
| 365 | .videos | 365 | .videos |
| 366 | .items | 366 | .items |
| 367 | .into_iter() | 367 | .into_iter() |
| 368 | .map(|item| invidious::hidden::PlaylistItem { | 368 | .map(|item| crate::global::common::hidden::PlaylistItem { |
| 369 | title: item.name, | 369 | title: item.name, |
| 370 | id: item.id, | 370 | id: item.id, |
| 371 | author: res | 371 | author: res |
src/global/traits/search_provider.rs +60 −18
| @@ -5,44 +5,86 @@ use std::{ | |||
| 5 | sync::OnceLock, | 5 | sync::OnceLock, |
| 6 | }; | 6 | }; |
| 7 | 7 | ||
| 8 | use dyn_clone::DynClone; | 8 | use crate::global::common::{ |
| 9 | use invidious::{ | ||
| 10 | channel::Channel, | 9 | channel::Channel, |
| 11 | hidden::{PopularItem, SearchItem}, | 10 | hidden::{PopularItem, SearchItem}, |
| 12 | universal::Playlist, | 11 | universal::Playlist, |
| 13 | video::Video, | 12 | video::Video, |
| 14 | CommonPlaylist, CommonVideo, | 13 | CommonPlaylist, CommonVideo, |
| 15 | }; | 14 | }; |
| 15 | use dyn_clone::DynClone; | ||
| 16 | 16 | ||
| 17 | use crate::{ | 17 | use crate::{ |
| 18 | config::{Search, SearchProvider}, | 18 | config::{Search, SearchProvider}, |
| 19 | MAIN_CONFIG, | 19 | MAIN_CONFIG, |
| 20 | }; | 20 | }; |
| 21 | 21 | ||
| 22 | #[allow(unused_variables)] | ||
| 22 | pub trait SearchProviderTrait: DynClone + Send { | 23 | pub trait SearchProviderTrait: DynClone + Send { |
| 23 | fn supports_channel(&self) -> bool; | 24 | fn supports_channel(&self) -> bool { |
| 24 | fn channel(&self, id: &str) -> Result<Channel, Box<dyn Error>>; | 25 | false |
| 26 | } | ||
| 27 | fn channel(&self, id: &str) -> Result<Channel, Box<dyn Error>> { | ||
| 28 | unimplemented!("channel not implemented") | ||
| 29 | } | ||
| 25 | 30 | ||
| 26 | fn supports_channel_videos(&self) -> bool; | 31 | fn supports_channel_videos(&self) -> bool { |
| 27 | fn channel_videos(&self, id: &str) -> Result<Vec<CommonVideo>, Box<dyn Error>>; | 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 | } | ||
| 28 | 51 | ||
| 29 | fn supports_channel_playlists(&self) -> bool; | 52 | fn supports_popular(&self) -> bool { |
| 30 | fn channel_playlists(&self, id: &str) -> Result<Vec<CommonPlaylist>, Box<dyn Error>>; | 53 | false |
| 54 | } | ||
| 55 | fn popular(&self) -> Result<Vec<PopularItem>, Box<dyn Error>> { | ||
| 56 | unimplemented!("popular not implemented") | ||
| 57 | } | ||
| 31 | 58 | ||
| 32 | fn supports_trending(&self) -> bool; | 59 | fn supports_search(&self) -> bool { |
| 33 | fn trending(&self) -> Result<Vec<CommonVideo>, Box<dyn Error>>; | 60 | false |
| 61 | } | ||
| 62 | fn search(&self, filters: &Search) -> Result<Vec<SearchItem>, Box<dyn Error>> { | ||
| 63 | unimplemented!("search not implemented") | ||
| 64 | } | ||
| 34 | 65 | ||
| 35 | fn supports_popular(&self) -> bool; | 66 | fn supports_video(&self) -> bool { |
| 36 | fn popular(&self) -> Result<Vec<PopularItem>, Box<dyn Error>>; | 67 | false |
| 68 | } | ||
| 69 | fn video(&self, id: &str) -> Result<Video, Box<dyn Error>> { | ||
| 70 | unimplemented!("video not implemented") | ||
| 71 | } | ||
| 37 | 72 | ||
| 38 | fn supports_search(&self) -> bool; | 73 | fn supports_playlist(&self) -> bool { |
| 39 | fn search(&self, filters: &Search) -> Result<Vec<SearchItem>, Box<dyn Error>>; | 74 | false |
| 75 | } | ||
| 76 | fn playlist(&self, id: &str) -> Result<Playlist, Box<dyn Error>> { | ||
| 77 | unimplemented!("playlist not implemented") | ||
| 78 | } | ||
| 40 | 79 | ||
| 41 | fn supports_video(&self) -> bool; | 80 | /* |
| 42 | fn video(&self, id: &str) -> Result<Video, Box<dyn Error>>; | 81 | fn supports_album(&self) -> bool { |
| 82 | false | ||
| 83 | } | ||
| 84 | fn album(&self) -> Result { | ||
| 43 | 85 | ||
| 44 | fn supports_playlist(&self) -> bool; | 86 | } |
| 45 | fn playlist(&self, id: &str) -> Result<Playlist, Box<dyn Error>>; | 87 | */ |
| 46 | } | 88 | } |
| 47 | 89 | ||
| 48 | dyn_clone::clone_trait_object!(SearchProviderTrait); | 90 | dyn_clone::clone_trait_object!(SearchProviderTrait); |