add soundcloud module
This commit is contained in:
parent
1f32c21363
commit
6b25a5f2a1
4 changed files with 116 additions and 0 deletions
11
config.toml
11
config.toml
|
@ -14,6 +14,17 @@ output_format = "%(title)s [%(id)s].%(ext)s"
|
||||||
# Channel Mappings
|
# Channel Mappings
|
||||||
MentalOutlaw = "https://www.youtube.com/@MentalOutlaw"
|
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]]
|
[[yt_dlp]]
|
||||||
# Module Name
|
# Module Name
|
||||||
name = "Custom-yt_dlp"
|
name = "Custom-yt_dlp"
|
||||||
|
|
|
@ -18,6 +18,8 @@ pub struct GlobalConfig {
|
||||||
pub hoard: HoardConfig,
|
pub hoard: HoardConfig,
|
||||||
// Configuration for the YouTube Module
|
// Configuration for the YouTube Module
|
||||||
pub youtube: Option<crate::youtube::YouTubeConfig>,
|
pub youtube: Option<crate::youtube::YouTubeConfig>,
|
||||||
|
// Configuration for the SoundCloud Module
|
||||||
|
pub soundcloud: Option<crate::soundcloud::SoundCloudConfig>,
|
||||||
// Custom instances of yt-dlp
|
// Custom instances of yt-dlp
|
||||||
pub yt_dlp: Option<Vec<YtDlpConfig>>,
|
pub yt_dlp: Option<Vec<YtDlpConfig>>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
mod db;
|
mod db;
|
||||||
|
mod soundcloud;
|
||||||
mod youtube;
|
mod youtube;
|
||||||
mod yt_dlp;
|
mod yt_dlp;
|
||||||
|
|
||||||
|
@ -52,6 +53,14 @@ fn main() {
|
||||||
config.hoard.data_dir.join("youtube"),
|
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() {
|
for yt_dlp_mod in config.yt_dlp.unwrap_or_default() {
|
||||||
let mod_name = yt_dlp_mod
|
let mod_name = yt_dlp_mod
|
||||||
.name
|
.name
|
||||||
|
|
94
src/soundcloud/mod.rs
Normal file
94
src/soundcloud/mod.rs
Normal file
|
@ -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<u64>,
|
||||||
|
// Items to check
|
||||||
|
pub artists: HashMap<String, String>,
|
||||||
|
// Output Template for yt-dlp
|
||||||
|
pub output_format: Option<String>,
|
||||||
|
// Download comments
|
||||||
|
pub write_comments: Option<bool>,
|
||||||
|
// Download description
|
||||||
|
pub write_description: Option<bool>,
|
||||||
|
// Download cover
|
||||||
|
pub write_cover: Option<bool>,
|
||||||
|
// Download subtitles
|
||||||
|
pub write_subs: Option<bool>,
|
||||||
|
// Audio Format
|
||||||
|
pub audio_format: Option<String>,
|
||||||
|
// Embed thumbnail
|
||||||
|
pub embed_thumbnail: Option<bool>,
|
||||||
|
// Embed metadata
|
||||||
|
pub embed_metadata: Option<bool>,
|
||||||
|
// Embed chapters
|
||||||
|
pub embed_chapters: Option<bool>,
|
||||||
|
// Embed info.json
|
||||||
|
pub embed_info_json: Option<bool>,
|
||||||
|
// Split by chapter
|
||||||
|
pub split_chapters: Option<bool>,
|
||||||
|
// Format Selection
|
||||||
|
pub format: Option<String>,
|
||||||
|
// Cookie File
|
||||||
|
pub cookie: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[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();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue