Changement du mécanisme d'attention sur les channels Radio Paradise.
This commit is contained in:
@@ -237,22 +237,27 @@ impl<C: CacheConfig> Cache<C> {
|
||||
);
|
||||
|
||||
if let Some(sr) = transform.sample_rate {
|
||||
self.db.set_a_metadata(pk, "sample_rate", serde_json::json!(sr))?;
|
||||
self.db
|
||||
.set_a_metadata(pk, "sample_rate", serde_json::json!(sr))?;
|
||||
}
|
||||
if let Some(bps) = transform.bits_per_sample {
|
||||
self.db.set_a_metadata(pk, "bits_per_sample", serde_json::json!(bps))?;
|
||||
self.db
|
||||
.set_a_metadata(pk, "bits_per_sample", serde_json::json!(bps))?;
|
||||
}
|
||||
if let Some(ch) = transform.channels {
|
||||
self.db.set_a_metadata(pk, "channels", serde_json::json!(ch))?;
|
||||
self.db
|
||||
.set_a_metadata(pk, "channels", serde_json::json!(ch))?;
|
||||
}
|
||||
if let Some(ts) = transform.total_samples {
|
||||
self.db.set_a_metadata(pk, "total_samples", serde_json::json!(ts))?;
|
||||
self.db
|
||||
.set_a_metadata(pk, "total_samples", serde_json::json!(ts))?;
|
||||
|
||||
// Calculer la durée à partir de total_samples et sample_rate
|
||||
if let Some(sr) = transform.sample_rate {
|
||||
if sr > 0 {
|
||||
let secs = (ts as f64 / sr as f64).round() as u64;
|
||||
self.db.set_a_metadata(pk, "duration_secs", serde_json::json!(secs))?;
|
||||
self.db
|
||||
.set_a_metadata(pk, "duration_secs", serde_json::json!(secs))?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +269,9 @@ fn test_get_pk_by_origin_url() {
|
||||
assert_eq!(found_pk, Some(pk.to_string()));
|
||||
|
||||
// Rechercher une URL qui n'existe pas
|
||||
let not_found = db.get_pk_by_origin_url("https://example.com/notfound.jpg").unwrap();
|
||||
let not_found = db
|
||||
.get_pk_by_origin_url("https://example.com/notfound.jpg")
|
||||
.unwrap();
|
||||
assert_eq!(not_found, None);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user