fix(backend): proper types for yt-dlp metadata

This commit is contained in:
Tomáš Mládek 2024-07-02 20:11:20 +02:00
parent 29fe6d8864
commit e027e399e5

View file

@ -137,7 +137,13 @@ impl Extractor for YtDlpExtractor {
Entry { Entry {
entity: address.clone(), entity: address.clone(),
attribute: attribute.clone(), attribute: attribute.clone(),
value: EntryValue::guess_from(value.to_string()), value: match value {
serde_json::Value::String(s) => s.clone().into(),
serde_json::Value::Number(n) => n
.as_f64()
.map_or_else(|| n.to_string().into(), |f| f.into()),
_ => value.to_string().into(),
},
provenance: context.provenance.clone() + "EXTRACTOR yt-dlp", provenance: context.provenance.clone() + "EXTRACTOR yt-dlp",
user: context.user.clone(), user: context.user.clone(),
timestamp: chrono::Utc::now().naive_utc(), timestamp: chrono::Utc::now().naive_utc(),