-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
169 additions
and
27 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
[package] | ||
name = "server" | ||
version = "1.1.2" | ||
version = "1.1.3" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
anyhow = "1.0.86" | ||
async_zip = { version = "0.0.17", features = ["full"] } | ||
axum = { version = "0.7.5", features = ["macros"] } | ||
chrono = { version = "0.4.38", features = ["serde"] } | ||
clap = { version = "4.5.4", features = ["derive"] } | ||
data-encoding = "2.6.0" | ||
file-format = "0.25.0" | ||
funty = "2.0.0" | ||
globwalk = "0.9.1" | ||
image = { version = "0.25.1", features = ["rayon"] } | ||
indicatif = "0.17.8" | ||
itertools = "0.13.0" | ||
lava_torrent = "0.11.1" | ||
natord = "1.0.9" | ||
once_cell = "1.19.0" | ||
rayon = "1.10.0" | ||
regex = "1.10.4" | ||
ring = "0.17.8" | ||
serde = { version = "1.0.203", features = ["derive"] } | ||
serde-inline-default = "0.2.0" | ||
serde_json = "1.0.117" | ||
serde_yaml = "0.9.34" | ||
sha2 = "0.10.8" | ||
slug = "0.1.5" | ||
sqlx = { version = "0.7", features = ["postgres", "runtime-tokio", "chrono"] } | ||
thiserror = "1.0.61" | ||
time = "0.3.36" | ||
tokio = { version = "1.38.0", features = ["full"] } | ||
zip = "2.1.2" | ||
tokio-util = { version = "0.7.11", features = ["io-util"] } | ||
axum = { version = "0.7.5", features = ["macros"] } | ||
toml = "0.8.14" | ||
tower-http = { version = "0.5.2", features = ["trace", "cors"] } | ||
tracing = "0.1" | ||
tracing-subscriber = { version = "0.3", features = ["env-filter"] } | ||
clap = { version = "4.5.4", features = ["derive"] } | ||
ring = "0.17.8" | ||
data-encoding = "2.6.0" | ||
toml = "0.8.14" | ||
serde-inline-default = "0.2.0" | ||
regex = "1.10.4" | ||
ureq = { version = "2.9.7", features = ["json"] } | ||
url = "2.5.0" | ||
file-format = "0.25.0" | ||
funty = "2.0.0" | ||
rayon = "1.10.0" | ||
image = { version = "0.25.1", features = ["rayon"] } | ||
thiserror = "1.0.61" | ||
indicatif = "0.17.8" | ||
time = "0.3.36" | ||
webp = "0.3.0" | ||
natord = "1.0.9" | ||
lava_torrent = "0.11.1" | ||
ureq = { version = "2.9.7", features = ["json"] } | ||
zip = "2.1.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
use crate::{db, utils}; | ||
use serde::Deserialize; | ||
use slug::slugify; | ||
|
||
#[derive(Deserialize)] | ||
pub struct Metadata { | ||
pub title: String, | ||
pub description: Option<String>, | ||
pub source: Option<String>, | ||
pub artist: Option<Vec<String>>, | ||
pub circle: Option<Vec<String>>, | ||
pub parody: Option<Vec<String>>, | ||
pub magazine: Option<Vec<String>>, | ||
pub event: Option<Vec<String>>, | ||
pub general: Option<Vec<String>>, | ||
pub female: Option<Vec<String>>, | ||
pub male: Option<Vec<String>>, | ||
pub mixed: Option<Vec<String>>, | ||
pub other: Option<Vec<String>>, | ||
pub language: Option<Vec<String>>, | ||
pub url: Option<String>, | ||
} | ||
|
||
pub fn add_metadata(info: Metadata, archive: &mut db::UpsertArchiveData) -> anyhow::Result<()> { | ||
archive.title = Some(info.title); | ||
archive.slug = archive.title.as_ref().map(slugify); | ||
archive.description = info.description; | ||
archive.thumbnail = Some(1); | ||
|
||
archive.artists = info.artist.map(|tags| { | ||
tags | ||
.iter() | ||
.map(|tag| utils::capitalize_words(tag)) | ||
.collect() | ||
}); | ||
archive.circles = info.circle.map(|tags| { | ||
tags | ||
.iter() | ||
.map(|tag| utils::capitalize_words(tag)) | ||
.collect() | ||
}); | ||
archive.magazines = info.magazine.map(|tags| { | ||
tags | ||
.iter() | ||
.map(|tag| utils::capitalize_words(tag)) | ||
.collect() | ||
}); | ||
archive.events = info.event.map(|tags| { | ||
tags | ||
.iter() | ||
.map(|tag| utils::capitalize_words(tag)) | ||
.collect() | ||
}); | ||
archive.parodies = info.parody.map(|tags| { | ||
tags | ||
.iter() | ||
.map(|tag| utils::capitalize_words(tag)) | ||
.collect() | ||
}); | ||
|
||
archive.language = info.language.and_then(|languages| { | ||
languages | ||
.first() | ||
.map(|language| utils::capitalize_words(language)) | ||
}); | ||
|
||
let mut tags = vec![]; | ||
|
||
if let Some(general) = info.general { | ||
general.into_iter().for_each(|tag| { | ||
tags.push((utils::capitalize_words(&tag), "".to_string())); | ||
}); | ||
} | ||
|
||
if let Some(female) = info.female { | ||
female.into_iter().for_each(|tag| { | ||
tags.push((utils::capitalize_words(&tag), "female".to_string())); | ||
}); | ||
} | ||
|
||
if let Some(male) = info.male { | ||
male.into_iter().for_each(|tag| { | ||
tags.push((utils::capitalize_words(&tag), "male".to_string())); | ||
}); | ||
} | ||
|
||
if let Some(mixed) = info.mixed { | ||
mixed.into_iter().for_each(|tag| { | ||
tags.push((utils::capitalize_words(&tag), "mixed".to_string())); | ||
}); | ||
} | ||
|
||
if let Some(other) = info.other { | ||
other.into_iter().for_each(|tag| { | ||
tags.push((utils::capitalize_words(&tag), "other".to_string())); | ||
}); | ||
} | ||
|
||
if !tags.is_empty() { | ||
archive.tags = Some(tags); | ||
} | ||
|
||
let mut sources = vec![]; | ||
|
||
if let Some(url) = info.url { | ||
sources.push(db::ArchiveSource { | ||
name: utils::parse_source_name(&url), | ||
url: Some(url), | ||
}); | ||
} | ||
|
||
if let Some(url) = info.source { | ||
sources.push(db::ArchiveSource { | ||
name: utils::parse_source_name(&url), | ||
url: Some(format!( | ||
"https://koharu.to{}", | ||
url.split(":").last().unwrap() | ||
)), | ||
}); | ||
} | ||
|
||
if !sources.is_empty() { | ||
archive.sources = Some(sources); | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "web-kit", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"private": true, | ||
"scripts": { | ||
"dev": "vite dev", | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters