aboutsummaryrefslogtreecommitdiff
path: root/import/src
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-02-16 13:25:02 +0100
committermetamuffin <metamuffin@disroot.org>2025-02-16 13:25:02 +0100
commitabe663807337faa717f9485b047c8f0e808f2a09 (patch)
treedb969df5bf119debc9e2ba6450e3fd05c2f39b0d /import/src
parent079fec9f206751047248c8c7733d7eccbd89d94b (diff)
downloadjellything-abe663807337faa717f9485b047c8f0e808f2a09.tar
jellything-abe663807337faa717f9485b047c8f0e808f2a09.tar.bz2
jellything-abe663807337faa717f9485b047c8f0e808f2a09.tar.zst
stats page
Diffstat (limited to 'import/src')
-rw-r--r--import/src/lib.rs19
1 files changed, 17 insertions, 2 deletions
diff --git a/import/src/lib.rs b/import/src/lib.rs
index 32f861e..7d1b635 100644
--- a/import/src/lib.rs
+++ b/import/src/lib.rs
@@ -335,11 +335,13 @@ fn import_media_file(
let node = NodeID::from_slug(&slug);
+ let meta = path.metadata()?;
+
db.update_node_init(node, |node| {
node.slug = slug;
node.title = info.title.or(node.title.clone());
node.visibility = visibility;
- node.poster = m.cover.clone();
+ node.poster = m.cover.or(node.poster.clone());
node.description = tags
.remove("DESCRIPTION")
.or(tags.remove("SYNOPSIS"))
@@ -438,6 +440,9 @@ fn import_media_file(
}
}
+ // TODO merge size
+ node.storage_size = meta.len();
+ // TODO merge tracks
node.media = Some(MediaInfo {
chapters: m
.chapters
@@ -462,7 +467,9 @@ fn import_media_file(
chaps
})
.unwrap_or_default(),
- duration: (info.duration.unwrap_or_default() * info.timestamp_scale as f64) * 1e-9,
+ duration: fix_invalid_runtime(
+ info.duration.unwrap_or_default() * info.timestamp_scale as f64 * 1e-9,
+ ),
tracks,
});
@@ -702,3 +709,11 @@ fn clean_uploader_name(mut s: &str) -> &str {
s = s.strip_prefix("Uploads from ").unwrap_or(s);
s
}
+
+fn fix_invalid_runtime(d: f64) -> f64 {
+ match d {
+ // Broken durations found experimentally
+ 359999.999 | 359999.000 | 86399.999 | 86399.99900000001 => 0.,
+ x => x,
+ }
+}