From 57fccd01d487284bb317fb1ff778e0fd2e140c12 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 23 Oct 2023 18:51:17 +0200 Subject: release date from infojson and sorting --- import/src/main.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'import/src/main.rs') diff --git a/import/src/main.rs b/import/src/main.rs index 57e6b99..c274e54 100644 --- a/import/src/main.rs +++ b/import/src/main.rs @@ -11,7 +11,7 @@ pub mod tmdb; use anyhow::Context; use base64::Engine; use clap::{Parser, Subcommand}; -use infojson::YVideo; +use infojson::{parse_upload_date, YVideo}; use jellycommon::{ config::GlobalConfig, AssetLocation, LocalTrack, MediaInfo, MediaSource, Node, NodeKind, NodePrivate, NodePublic, Rating, @@ -22,6 +22,7 @@ use log::{info, warn}; use rand::random; use std::{ collections::BTreeMap, + fmt::Debug, fs::{remove_file, File}, io::{stdin, BufReader, Write}, path::PathBuf, @@ -354,6 +355,9 @@ fn main() -> anyhow::Result<()> { duration: m.duration, tracks: m.tracks.clone(), }), + release_date: infojson + .as_ref() + .and_then(|j| ok_or_warn(parse_upload_date(&j.upload_date))), ..Default::default() }, }; @@ -399,3 +403,13 @@ fn make_ident(s: &str) -> String { } out } + +fn ok_or_warn(r: Result) -> Option { + match r { + Ok(t) => Some(t), + Err(e) => { + warn!("{e:?}"); + None + } + } +} -- cgit v1.2.3-70-g09d2