feat: create season subdirectory when downloading season
下载合集时创建以合集标题命名的子目录: - 前端 TaskInitData 增加 seasonTitle 字段 - 前端下载时传递合集 seasonTitle - 后端 TaskInitOption 增加 SeasonTitle 字段 - 后端创建任务时根据 seasonTitle 创建子目录 Co-Authored-By: AI
This commit is contained in:
@@ -37,6 +37,7 @@ type TaskInitOption struct {
|
||||
Video string `json:"video"`
|
||||
Duration int `json:"duration"`
|
||||
DownloadType string `json:"downloadType"`
|
||||
SeasonTitle string `json:"seasonTitle"` // 合集标题,用于创建子目录
|
||||
}
|
||||
|
||||
// TaskInDB 任务数据库中的数据
|
||||
@@ -164,6 +165,16 @@ func (task *Task) Start() {
|
||||
return
|
||||
}
|
||||
|
||||
// 如果有合集标题,创建子目录
|
||||
if task.SeasonTitle != "" {
|
||||
seasonFolder := filepath.Join(task.Folder, task.SeasonTitle)
|
||||
if err := os.MkdirAll(seasonFolder, os.ModePerm); err != nil {
|
||||
task.UpdateStatus(db, "error", fmt.Errorf("创建合集目录失败: %v", err))
|
||||
return
|
||||
}
|
||||
task.Folder = seasonFolder
|
||||
}
|
||||
|
||||
client := &bilibili.BiliClient{SESSDATA: sessdata}
|
||||
|
||||
GlobalDownloadSem.Acquire()
|
||||
|
||||
Reference in New Issue
Block a user