diff --git a/crates/bili_sync/src/utils/nfo.rs b/crates/bili_sync/src/utils/nfo.rs index 5915444..b996d2b 100644 --- a/crates/bili_sync/src/utils/nfo.rs +++ b/crates/bili_sync/src/utils/nfo.rs @@ -43,7 +43,7 @@ impl NFOSerializer<'_> { .write_inner_content_async::<_, _, Error>(|writer| async move { writer .create_element("plot") - .write_cdata_content_async(BytesCData::new(&v.intro)) + .write_cdata_content_async(BytesCData::new(Self::format_plot(v))) .await?; writer.create_element("outline").write_empty_async().await?; writer @@ -100,7 +100,7 @@ impl NFOSerializer<'_> { .write_inner_content_async::<_, _, Error>(|writer| async move { writer .create_element("plot") - .write_cdata_content_async(BytesCData::new(&v.intro)) + .write_cdata_content_async(BytesCData::new(Self::format_plot(v))) .await?; writer.create_element("outline").write_empty_async().await?; writer @@ -202,6 +202,14 @@ impl NFOSerializer<'_> { tokio_buffer.flush().await?; Ok(String::from_utf8(buffer)?) } + + #[inline] + fn format_plot(model: &video::Model) -> String { + format!( + r#"原始视频:{}

{}"#, + model.bvid, model.bvid, model.intro + ) + } } #[cfg(test)] @@ -223,7 +231,7 @@ mod tests { chrono::NaiveDate::from_ymd_opt(2033, 3, 3).unwrap(), chrono::NaiveTime::from_hms_opt(3, 3, 3).unwrap(), ), - bvid: "bvid".to_string(), + bvid: "BV1nWcSeeEkV".to_string(), tags: Some(serde_json::json!(["tag1", "tag2"])), ..Default::default() }; @@ -234,7 +242,7 @@ mod tests { .unwrap(), r#" - + BV1nWcSeeEkV

intro]]>
name @@ -244,7 +252,7 @@ mod tests { 2033 tag1 tag2 - bvid + BV1nWcSeeEkV 2033-03-03
"#, ); @@ -255,7 +263,7 @@ mod tests { .unwrap(), r#" - + BV1nWcSeeEkV

intro]]>
name @@ -265,7 +273,7 @@ mod tests { 2022 tag1 tag2 - bvid + BV1nWcSeeEkV 2022-02-02
"#, );