From 7c514b2dccb9ec2211aa9542d8a78a4a144e2167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=80=E1=B4=8D=E1=B4=9B=E1=B4=8F=E1=B4=80=E1=B4=87?= =?UTF-8?q?=CA=80?= Date: Tue, 4 Feb 2025 23:25:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B0=86=E8=A7=86=E9=A2=91=E7=9A=84?= =?UTF-8?q?=E5=8E=9F=E5=A7=8B=20URL=20=E6=94=BE=E5=88=B0=E7=AE=80=E4=BB=8B?= =?UTF-8?q?=E4=B8=AD=20(#241)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/bili_sync/src/utils/nfo.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) 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
"#, );