diff options
author | metamuffin <metamuffin@disroot.org> | 2025-02-03 12:09:37 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-02-03 12:09:37 +0100 |
commit | bb86ed2ad041aa310be5c736d571c14295bf5ce2 (patch) | |
tree | 778ab84604ae735a2bb9fd4c11fc8e449a94c67c /import | |
parent | 78a1632e2f5d75a212a85a0da24bf325a1153426 (diff) | |
download | jellything-bb86ed2ad041aa310be5c736d571c14295bf5ce2.tar jellything-bb86ed2ad041aa310be5c736d571c14295bf5ce2.tar.bz2 jellything-bb86ed2ad041aa310be5c736d571c14295bf5ce2.tar.zst |
re-add infojson import
Diffstat (limited to 'import')
-rw-r--r-- | import/src/lib.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/import/src/lib.rs b/import/src/lib.rs index bc4b2ee..a4f3668 100644 --- a/import/src/lib.rs +++ b/import/src/lib.rs @@ -415,6 +415,48 @@ fn import_media_file( }) .collect::<Vec<_>>(); + if let Some(infojson) = m.infojson { + node.kind = if !tracks + .iter() + .any(|t| matches!(t.kind, SourceTrackKind::Video { .. })) + { + NodeKind::Music + } else if infojson.duration.unwrap_or(0.) < 600. + && infojson.aspect_ratio.unwrap_or(2.) < 1. + { + NodeKind::ShortFormVideo + } else { + NodeKind::Video + }; + node.title = Some(infojson.title); + if let Some(desc) = infojson.description { + node.description = Some(desc) + } + node.tagline = Some(infojson.webpage_url); + if let Some(date) = &infojson.upload_date { + node.release_date = + Some(infojson::parse_upload_date(date).context("parsing upload date")?); + } + match infojson.extractor.as_str() { + "youtube" => { + node.external_ids + .insert("youtube:video".to_string(), infojson.id); + node.ratings.insert( + Rating::YoutubeViews, + infojson.view_count.unwrap_or_default() as f64, + ); + if let Some(lc) = infojson.like_count { + node.ratings.insert(Rating::YoutubeLikes, lc as f64); + } + } + "Bandcamp" => drop( + node.external_ids + .insert("bandcamp".to_string(), infojson.id), + ), + _ => (), + } + } + node.media = Some(MediaInfo { chapters: m .chapters |