feat: 允许在 video_name 和 page_name 中使用对应平台的路径分隔符 (#163)

This commit is contained in:
ᴀᴍᴛᴏᴀᴇʀ
2024-08-08 23:53:22 +08:00
committed by GitHub
parent be3abab13f
commit ae05cad22f
5 changed files with 64 additions and 20 deletions

View File

@@ -9,8 +9,7 @@ use sea_orm::ActiveValue::Set;
use sea_orm::{Condition, DatabaseTransaction, QuerySelect};
use crate::bilibili::{BiliError, PageInfo, VideoInfo};
use crate::config::TEMPLATE;
use crate::utils::filenamify::filenamify;
use crate::config::{PathSafeTemplate, TEMPLATE};
use crate::utils::id_time_key;
/// 使用 condition 筛选视频,返回视频数量
@@ -66,11 +65,7 @@ pub(super) fn video_with_path(
) -> video::ActiveModel {
if let Some(fmt_args) = &video_info.to_fmt_args() {
video_model.path = Set(Path::new(base_path)
.join(filenamify(
TEMPLATE
.render("video", fmt_args)
.unwrap_or_else(|_| video_info.bvid().to_string()),
))
.join(TEMPLATE.path_safe_render("video", fmt_args).unwrap())
.to_string_lossy()
.to_string());
}