diff --git a/.gitignore b/.gitignore index d7b0498..8de8286 100755 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,7 @@ /target -*.db* .env -almond.toml -# almond media folders +# almond +*.db* +almond.toml /media -/channels -/videos diff --git a/src/channel.rs b/src/channel.rs index ad7e471..5d7d947 100755 --- a/src/channel.rs +++ b/src/channel.rs @@ -44,7 +44,7 @@ impl Channel { "--skip-download", "-v", "-o", - "channels/tmp/tmp.%(ext)s", + "media/channels/tmp/tmp.%(ext)s", url, ]) .spawn()?; @@ -65,10 +65,9 @@ impl Channel { return Err(ChannelError::InvalidUrl); } - // This task is light enough so it can run on its entirety Self::yt_dlp_task(url.as_str()).await?; let info: Value = - serde_json::from_str(&fs::read_to_string("channels/tmp/tmp.info.json").await?)?; + serde_json::from_str(&fs::read_to_string("media/channels/tmp/tmp.info.json").await?)?; let get_info_value = |key: &str| { info.get(key) @@ -77,9 +76,10 @@ impl Channel { }; let youtube_id = get_info_value("channel_id").to_unquoted_string(); - let dir = format!("channels/{youtube_id}"); + let dir = format!("media/channels/{youtube_id}"); let file_stem = format!("{dir}/{youtube_id}"); + // TODO: Detect if ID exists without running yt-dlp task if Path::new(&dir).exists() { warn!("Channel already exists, skipping"); return Err(ChannelError::AlreadyExists); @@ -126,7 +126,7 @@ impl Channel { .unwrap_or_default(); fs::rename( - "channels/tmp/tmp.info.json", + "media/channels/tmp/tmp.info.json", format!("{file_stem}.info.json"), ) .await?; diff --git a/src/comment.rs b/src/comment.rs index ae2231a..f61cda3 100755 --- a/src/comment.rs +++ b/src/comment.rs @@ -38,7 +38,7 @@ pub struct Comment { } pub async fn get_comments_from_video(id: &str) -> Result, CommentsError> { - let info_json = format!("videos/{id}/{id}.info.json"); + let info_json = format!("media/videos/{id}/{id}.info.json"); let info_json = Path::new(&info_json); if !info_json.exists() { diff --git a/src/video.rs b/src/video.rs index fc0e143..055a4b8 100755 --- a/src/video.rs +++ b/src/video.rs @@ -60,7 +60,7 @@ impl Video { "-v", url, "-o", - "videos/%(id)s/%(id)s.%(ext)s", + "media/videos/%(id)s/%(id)s.%(ext)s", "-f", "bestvideo[ext=mkv]+bestaudio[ext=m4a]/bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo*+bestaudio/best", ]; @@ -82,7 +82,7 @@ impl Video { let youtube_id = query_v.1.to_string(); info!("URL is valid YouTube video, got ID '{youtube_id}'"); - let dir = format!("videos/{youtube_id}"); + let dir = format!("media/videos/{youtube_id}"); let file_stem = format!("{dir}/{youtube_id}"); // ? Uploading a video doesn't mean updating it, make a PUT route for that later