Change output folder to media
This commit is contained in:
parent
9e619c004a
commit
4b8cccf29f
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,9 +1,7 @@
|
||||
/target
|
||||
*.db*
|
||||
.env
|
||||
almond.toml
|
||||
|
||||
# almond media folders
|
||||
# almond
|
||||
*.db*
|
||||
almond.toml
|
||||
/media
|
||||
/channels
|
||||
/videos
|
||||
|
@ -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?;
|
||||
|
@ -38,7 +38,7 @@ pub struct Comment {
|
||||
}
|
||||
|
||||
pub async fn get_comments_from_video(id: &str) -> Result<Vec<Comment>, 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() {
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user