diff --git a/config.toml b/config.toml index 0e90c13..cb64e94 100644 --- a/config.toml +++ b/config.toml @@ -14,6 +14,17 @@ output_format = "%(title)s [%(id)s].%(ext)s" # Channel Mappings MentalOutlaw = "https://www.youtube.com/@MentalOutlaw" +[soundcloud] +interval = 30 +limit = 5 + +write_comments = true +write_description = true +audio_format = "opus" + +[soundcloud.artists] +Artist = "url" + [[yt_dlp]] # Module Name name = "Custom-yt_dlp" diff --git a/src/config.rs b/src/config.rs index 6df00d2..65b7e36 100644 --- a/src/config.rs +++ b/src/config.rs @@ -18,6 +18,8 @@ pub struct GlobalConfig { pub hoard: HoardConfig, // Configuration for the YouTube Module pub youtube: Option, + // Configuration for the SoundCloud Module + pub soundcloud: Option, // Custom instances of yt-dlp pub yt_dlp: Option>, } diff --git a/src/main.rs b/src/main.rs index 3b82bb1..c8cfffc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ use std::path::PathBuf; mod config; mod db; +mod soundcloud; mod youtube; mod yt_dlp; @@ -52,6 +53,14 @@ fn main() { config.hoard.data_dir.join("youtube"), ))]; + if let Some(sc_config) = config.soundcloud { + modules.push(Box::new(soundcloud::SoundCloudModule::new( + sc_config, + db.take_db(), + config.hoard.data_dir.join("youtube"), + ))); + } + for yt_dlp_mod in config.yt_dlp.unwrap_or_default() { let mod_name = yt_dlp_mod .name diff --git a/src/soundcloud/mod.rs b/src/soundcloud/mod.rs new file mode 100644 index 0000000..cb67168 --- /dev/null +++ b/src/soundcloud/mod.rs @@ -0,0 +1,94 @@ +use std::{collections::HashMap, path::PathBuf}; + +use serde::{Deserialize, Serialize}; + +use crate::{ + yt_dlp::{YtDlpConfig, YtDlpModule}, + Module, +}; + +/// Configuration for the `SoundCloud` Module +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct SoundCloudConfig { + // Interval in minutes between checks + pub interval: u64, + /// Amount of items to query + pub limit: Option, + // Items to check + pub artists: HashMap, + // Output Template for yt-dlp + pub output_format: Option, + // Download comments + pub write_comments: Option, + // Download description + pub write_description: Option, + // Download cover + pub write_cover: Option, + // Download subtitles + pub write_subs: Option, + // Audio Format + pub audio_format: Option, + // Embed thumbnail + pub embed_thumbnail: Option, + // Embed metadata + pub embed_metadata: Option, + // Embed chapters + pub embed_chapters: Option, + // Embed info.json + pub embed_info_json: Option, + // Split by chapter + pub split_chapters: Option, + // Format Selection + pub format: Option, + // Cookie File + pub cookie: Option, +} + +#[derive(Clone)] +pub struct SoundCloudModule { + yt_dlp: YtDlpModule, +} + +impl SoundCloudModule { + pub fn new(config: SoundCloudConfig, db: crate::db::Database, root_dir: PathBuf) -> Self { + Self { + yt_dlp: YtDlpModule::new( + YtDlpConfig { + name: Some("soundcloud".to_string()), + interval: config.interval, + limit: config.limit, + items: config.artists, + thumbnail_format: Some("jpg".to_string()), + output_format: config.output_format.clone(), + write_description: Some(config.write_description.unwrap_or(true)), + write_info_json: Some(false), + write_comments: config.write_comments, + write_thumbnail: Some(true), + write_subs: config.write_subs, + audio_format: config.audio_format, + embed_subs: Some(false), + embed_thumbnail: Some(config.embed_thumbnail.unwrap_or(true)), + embed_metadata: Some(config.embed_metadata.unwrap_or(true)), + embed_chapters: Some(config.embed_chapters.unwrap_or(true)), + embed_info_json: Some(config.embed_info_json.unwrap_or(true)), + split_chapters: config.split_chapters, + format: config.format, + cookie: config.cookie, + audio_only: Some(true), + }, + db, + root_dir, + ), + } + } +} + +impl Module for SoundCloudModule { + fn name(&self) -> String { + "SoundCloud".to_string() + } + + fn run(&self) { + self.yt_dlp.run(); + } +}