From f3822dd536ec39c6786ebcb75e61d7841d00be14 Mon Sep 17 00:00:00 2001 From: Naomi <33375791+Henvy-Mango@users.noreply.github.com> Date: Sat, 29 Nov 2025 01:22:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E5=96=84nfo=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E3=80=81=E6=BC=94=E5=91=98=E7=BC=A9=E7=95=A5?= =?UTF-8?q?=E5=9B=BE=20(#542)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/bili_sync/src/utils/nfo.rs | 39 +++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/crates/bili_sync/src/utils/nfo.rs b/crates/bili_sync/src/utils/nfo.rs index 2a86649..92053c8 100644 --- a/crates/bili_sync/src/utils/nfo.rs +++ b/crates/bili_sync/src/utils/nfo.rs @@ -22,7 +22,8 @@ pub struct Movie<'a> { pub bvid: &'a str, pub upper_id: i64, pub upper_name: &'a str, - pub aired: NaiveDateTime, + pub upper_thumb: &'a str, + pub premiered: NaiveDateTime, pub tags: Option>, } @@ -32,7 +33,8 @@ pub struct TVShow<'a> { pub bvid: &'a str, pub upper_id: i64, pub upper_name: &'a str, - pub aired: NaiveDateTime, + pub upper_thumb: &'a str, + pub premiered: NaiveDateTime, pub tags: Option>, } @@ -96,12 +98,16 @@ impl NFO<'_> { .create_element("role") .write_text_content_async(BytesText::new(movie.upper_name)) .await?; + writer + .create_element("thumb") + .write_text_content_async(BytesText::new(movie.upper_thumb)) + .await?; Ok(writer) }) .await?; writer .create_element("year") - .write_text_content_async(BytesText::new(&movie.aired.format("%Y").to_string())) + .write_text_content_async(BytesText::new(&movie.premiered.format("%Y").to_string())) .await?; if let Some(tags) = movie.tags { for tag in tags { @@ -117,8 +123,8 @@ impl NFO<'_> { .write_text_content_async(BytesText::new(movie.bvid)) .await?; writer - .create_element("aired") - .write_text_content_async(BytesText::new(&movie.aired.format("%Y-%m-%d").to_string())) + .create_element("premiered") + .write_text_content_async(BytesText::new(&movie.premiered.format("%Y-%m-%d").to_string())) .await?; Ok(writer) }) @@ -150,12 +156,16 @@ impl NFO<'_> { .create_element("role") .write_text_content_async(BytesText::new(tvshow.upper_name)) .await?; + writer + .create_element("thumb") + .write_text_content_async(BytesText::new(tvshow.upper_thumb)) + .await?; Ok(writer) }) .await?; writer .create_element("year") - .write_text_content_async(BytesText::new(&tvshow.aired.format("%Y").to_string())) + .write_text_content_async(BytesText::new(&tvshow.premiered.format("%Y").to_string())) .await?; if let Some(tags) = tvshow.tags { for tag in tags { @@ -171,8 +181,8 @@ impl NFO<'_> { .write_text_content_async(BytesText::new(tvshow.bvid)) .await?; writer - .create_element("aired") - .write_text_content_async(BytesText::new(&tvshow.aired.format("%Y-%m-%d").to_string())) + .create_element("premiered") + .write_text_content_async(BytesText::new(&tvshow.premiered.format("%Y-%m-%d").to_string())) .await?; Ok(writer) }) @@ -252,6 +262,7 @@ mod tests { name: "name".to_string(), upper_id: 1, upper_name: "upper_name".to_string(), + upper_face: "https://i1.hdslb.com/bfs/face/72e8f33cadc72e022fc34624cc69e1b12ebb72c0.jpg".to_string(), favtime: chrono::NaiveDateTime::new( chrono::NaiveDate::from_ymd_opt(2022, 2, 2).unwrap(), chrono::NaiveTime::from_hms_opt(2, 2, 2).unwrap(), @@ -277,12 +288,13 @@ mod tests { 1 upper_name + https://i1.hdslb.com/bfs/face/72e8f33cadc72e022fc34624cc69e1b12ebb72c0.jpg 2022 tag1 tag2 BV1nWcSeeEkV - 2022-02-02 + 2022-02-02 "#, ); assert_eq!( @@ -298,12 +310,13 @@ mod tests { 1 upper_name + https://i1.hdslb.com/bfs/face/72e8f33cadc72e022fc34624cc69e1b12ebb72c0.jpg 2022 tag1 tag2 BV1nWcSeeEkV - 2022-02-02 + 2022-02-02 "#, ); assert_eq!( @@ -355,7 +368,8 @@ impl<'a> ToNFO<'a, Movie<'a>> for &'a video::Model { bvid: &self.bvid, upper_id: self.upper_id, upper_name: &self.upper_name, - aired: match nfo_time_type { + upper_thumb: &self.upper_face, + premiered: match nfo_time_type { NFOTimeType::FavTime => self.favtime, NFOTimeType::PubTime => self.pubtime, }, @@ -372,7 +386,8 @@ impl<'a> ToNFO<'a, TVShow<'a>> for &'a video::Model { bvid: &self.bvid, upper_id: self.upper_id, upper_name: &self.upper_name, - aired: match nfo_time_type { + upper_thumb: &self.upper_face, + premiered: match nfo_time_type { NFOTimeType::FavTime => self.favtime, NFOTimeType::PubTime => self.pubtime, },