mirror of
https://codeberg.org/YGGverse/ytd.git
synced 2026-04-08 12:55:32 +00:00
implement custom invidious instance support
This commit is contained in:
parent
6afac2f85f
commit
22e3c301a2
4 changed files with 12 additions and 6 deletions
|
|
@ -21,9 +21,11 @@ sleep = 1
|
|||
# exec = ""
|
||||
# stdout_contains = [""]
|
||||
|
||||
# Supported values: youtube | invidious
|
||||
# Video instance provider
|
||||
|
||||
provider = "youtube"
|
||||
provider = "Youtube"
|
||||
# provider = "Invidious"
|
||||
# provider = { Invidious = "https://tux.rs" }
|
||||
|
||||
# Channels queue config
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use std::{collections::HashMap, path::PathBuf};
|
|||
#[derive(Deserialize)]
|
||||
pub enum Provider {
|
||||
Youtube,
|
||||
Invidious,
|
||||
Invidious(Option<String>),
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ async fn main() {
|
|||
let mut database = Database::new(&config.database).unwrap();
|
||||
let client = match config.provider {
|
||||
config::Provider::Youtube => Provider::youtube(),
|
||||
config::Provider::Invidious => Provider::invidious(),
|
||||
config::Provider::Invidious(instance) => Provider::invidious(instance),
|
||||
};
|
||||
let channel_item_id_regex = Regex::new(r"^[A-z0-9_-]{11}$").unwrap();
|
||||
|
||||
|
|
|
|||
|
|
@ -19,8 +19,12 @@ impl Provider {
|
|||
pub fn youtube() -> Self {
|
||||
Self::Youtube(RustyPipe::new())
|
||||
}
|
||||
pub fn invidious() -> Self {
|
||||
Self::Invidious(ClientSync::default())
|
||||
pub fn invidious(instance: Option<String>) -> Self {
|
||||
let mut client = ClientSync::default();
|
||||
if let Some(i) = instance {
|
||||
client.set_instance(i)
|
||||
}
|
||||
Self::Invidious(client)
|
||||
}
|
||||
pub async fn videos(&self, channel_id: &str) -> Result<Vec<Video>> {
|
||||
let mut videos = Vec::new();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue