aboutsummaryrefslogtreecommitdiff
path: root/import
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-01-30 18:34:09 +0100
committermetamuffin <metamuffin@disroot.org>2025-01-30 18:34:09 +0100
commit9d6411fd92e73c204425f8dd37dc3cf567f604e4 (patch)
treed61d3e0b6bcd803e6ccb6d01669d40a1454ec009 /import
parentbfc5552a8eba07897c2ed626b49c085d97fdfa0d (diff)
downloadjellything-9d6411fd92e73c204425f8dd37dc3cf567f604e4.tar
jellything-9d6411fd92e73c204425f8dd37dc3cf567f604e4.tar.bz2
jellything-9d6411fd92e73c204425f8dd37dc3cf567f604e4.tar.zst
avoid transitive crate deps by re-export
Diffstat (limited to 'import')
-rw-r--r--import/Cargo.toml1
-rw-r--r--import/src/infojson.rs2
-rw-r--r--import/src/lib.rs44
-rw-r--r--import/src/matroska.rs2
-rw-r--r--import/src/tmdb.rs10
-rw-r--r--import/src/trakt.rs6
6 files changed, 41 insertions, 24 deletions
diff --git a/import/Cargo.toml b/import/Cargo.toml
index 988e626..645326d 100644
--- a/import/Cargo.toml
+++ b/import/Cargo.toml
@@ -4,7 +4,6 @@ version = "0.1.0"
edition = "2021"
[dependencies]
-jellycommon = { path = "../common" }
jellybase = { path = "../base" }
jellyclient = { path = "../client" }
diff --git a/import/src/infojson.rs b/import/src/infojson.rs
index 3e4667e..69c28ca 100644
--- a/import/src/infojson.rs
+++ b/import/src/infojson.rs
@@ -5,7 +5,7 @@
*/
use anyhow::Context;
use bincode::{Decode, Encode};
-use jellycommon::chrono::{format::Parsed, Utc};
+use jellybase::common::chrono::{format::Parsed, Utc};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
diff --git a/import/src/lib.rs b/import/src/lib.rs
index c841294..4203ba1 100644
--- a/import/src/lib.rs
+++ b/import/src/lib.rs
@@ -5,16 +5,20 @@
*/
use anyhow::{anyhow, Context, Result};
use infojson::YVideo;
-use jellybase::{assetfed::AssetInner, database::Database, CONF, SECRETS};
-use jellycommon::{
- Chapter, LocalTrack, MediaInfo, Node, NodeID, NodeKind, Rating, SourceTrack, SourceTrackKind,
- TrackSource,
+use jellybase::{
+ assetfed::AssetInner,
+ common::{
+ Chapter, LocalTrack, MediaInfo, Node, NodeID, NodeKind, Rating, SourceTrack,
+ SourceTrackKind, TrackSource,
+ },
+ database::Database,
+ CONF, SECRETS,
};
use matroska::matroska_metadata;
use rayon::iter::{ParallelDrainRange, ParallelIterator};
use std::{
collections::HashMap,
- fs::File,
+ fs::{read_to_string, File},
io::BufReader,
mem::swap,
path::{Path, PathBuf},
@@ -118,32 +122,37 @@ fn import_iter_inner(path: &Path, db: &Database, incremental: bool) -> Result<Ve
}
fn import_file(db: &Database, path: &Path) -> Result<()> {
- let parent_slug = path
- .parent()
- .ok_or(anyhow!("no parent"))?
- .file_name()
- .ok_or(anyhow!("parent no filename"))?
- .to_string_lossy();
+ let parent_slug = if path == CONF.media_path {
+ "library".to_string()
+ } else {
+ path.parent()
+ .ok_or(anyhow!("no parent"))?
+ .file_name()
+ .ok_or(anyhow!("parent no filename"))?
+ .to_string_lossy()
+ .to_string()
+ };
let parent = NodeID::from_slug(&parent_slug);
let filename = path.file_name().unwrap().to_string_lossy();
match filename.as_ref() {
- "poster.jpeg" | "poster.webp" => {
+ "poster.jpeg" | "poster.webp" | "poster.png" => {
db.update_node_init(parent, |node| {
node.slug = parent_slug.to_string();
node.poster = Some(AssetInner::Media(path.to_owned()).ser());
Ok(())
})?;
}
- "backdrop.jpeg" | "backdrop.webp" => {
+ "backdrop.jpeg" | "backdrop.webp" | "backdrop#.png" => {
db.update_node_init(parent, |node| {
node.slug = parent_slug.to_string();
node.backdrop = Some(AssetInner::Media(path.to_owned()).ser());
Ok(())
})?;
}
- "info.json" | "info.yaml" => {
- let data = serde_yaml::from_reader::<_, Node>(BufReader::new(File::open(path)?))?;
+ "node.json" | "node.yaml" => {
+ let raw = format!("slug: {parent_slug}\n{}", read_to_string(path)?);
+ let data = serde_yaml::from_str::<Node>(&raw)?;
db.update_node_init(parent, |node| {
node.slug = parent_slug.to_string();
fn merge_option<T>(a: &mut Option<T>, b: Option<T>) {
@@ -151,9 +160,14 @@ fn import_file(db: &Database, path: &Path) -> Result<()> {
*a = b;
}
}
+ merge_option(&mut node.kind, data.kind);
merge_option(&mut node.title, data.title);
merge_option(&mut node.tagline, data.tagline);
merge_option(&mut node.description, data.description);
+ merge_option(&mut node.index, data.index);
+ merge_option(&mut node.release_date, data.release_date);
+ node.external_ids.extend(data.external_ids);
+
Ok(())
})?;
}
diff --git a/import/src/matroska.rs b/import/src/matroska.rs
index 6a33420..f9a59ab 100644
--- a/import/src/matroska.rs
+++ b/import/src/matroska.rs
@@ -14,8 +14,8 @@ use ebml_struct::{
use jellybase::{
assetfed::AssetInner,
cache::{cache_file, cache_memory},
+ common::Asset,
};
-use jellycommon::Asset;
use log::info;
use std::{
fs::File,
diff --git a/import/src/tmdb.rs b/import/src/tmdb.rs
index 522d9d6..678ce61 100644
--- a/import/src/tmdb.rs
+++ b/import/src/tmdb.rs
@@ -5,10 +5,12 @@
*/
use anyhow::{anyhow, bail, Context};
use bincode::{Decode, Encode};
-use jellybase::cache::{async_cache_file, async_cache_memory, CachePath};
-use jellycommon::{
- chrono::{format::Parsed, Utc},
- TmdbKind,
+use jellybase::{
+ cache::{async_cache_file, async_cache_memory, CachePath},
+ common::{
+ chrono::{format::Parsed, Utc},
+ TmdbKind,
+ },
};
use log::info;
use reqwest::{
diff --git a/import/src/trakt.rs b/import/src/trakt.rs
index f37eb74..98532c5 100644
--- a/import/src/trakt.rs
+++ b/import/src/trakt.rs
@@ -4,8 +4,10 @@
Copyright (C) 2025 metamuffin <metamuffin.org>
*/
use bincode::{Decode, Encode};
-use jellybase::cache::async_cache_memory;
-use jellycommon::{Appearance, ObjectIds, PeopleGroup, Person, TraktKind};
+use jellybase::{
+ cache::async_cache_memory,
+ common::{Appearance, ObjectIds, PeopleGroup, Person, TraktKind},
+};
use reqwest::{
header::{HeaderMap, HeaderName, HeaderValue},
Client, ClientBuilder,