From 1b452517e36c2f074ae54b27fcdca89837e1e703 Mon Sep 17 00:00:00 2001 From: Davide Polonio Date: Tue, 31 May 2022 17:06:39 +0200 Subject: [PATCH 1/9] feat: add first Youtube search functionality --- Cargo.toml | 1 + src/main.rs | 1 + src/youtube/mod.rs | 106 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 src/youtube/mod.rs diff --git a/Cargo.toml b/Cargo.toml index 8bfef7d..c46a54d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,3 +12,4 @@ pretty_env_logger = "0.4.0" tokio = { version = "1.18.2", features = ["rt-multi-thread", "macros"] } rspotify = { version = "0.11.5", features = ["default"]} sentry = "0.26.0" +invidious = "0.2.1" diff --git a/src/main.rs b/src/main.rs index 1a8ff7c..27b24f2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,6 +11,7 @@ use crate::utils::{human_readable_duration, truncate_with_dots}; mod spotify; mod utils; +mod youtube; static MAX_ARTISTS_CHARS: usize = 140; diff --git a/src/youtube/mod.rs b/src/youtube/mod.rs new file mode 100644 index 0000000..aa7456b --- /dev/null +++ b/src/youtube/mod.rs @@ -0,0 +1,106 @@ +use invidious::asynchronous::Client; +use std::error::Error; + +#[derive(Debug, Clone)] +pub(crate) struct YoutubeClient { + client: Client, +} + +pub(crate) struct VideoSearch { + items: Vec