mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-09 11:39:46 +08:00
feat: code refactor and support season pack write .plexmatch file
This commit is contained in:
@@ -61,15 +61,25 @@ func (c *Client) checkTasks() {
|
||||
}
|
||||
log.Infof("task is done: %v", t.Name())
|
||||
c.sendMsg(fmt.Sprintf(message.DownloadComplete, t.Name()))
|
||||
go func() {
|
||||
if err := c.moveCompletedTask(id); err != nil {
|
||||
log.Infof("post tasks for id %v fail: %v", id, err)
|
||||
}
|
||||
}()
|
||||
|
||||
go c.postTaskProcessing(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) postTaskProcessing(id int) {
|
||||
if err := c.findEpisodeFilesPreMoving(id); err != nil {
|
||||
log.Errorf("finding all episode file error: %v", err)
|
||||
} else {
|
||||
if err := c.writePlexmatch(id); err != nil {
|
||||
log.Errorf("write plexmatch file error: %v", err)
|
||||
}
|
||||
}
|
||||
if err := c.moveCompletedTask(id); err != nil {
|
||||
log.Infof("post tasks for id %v fail: %v", id, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) moveCompletedTask(id int) (err1 error) {
|
||||
torrent := c.tasks[id]
|
||||
r := c.db.GetHistory(id)
|
||||
@@ -119,11 +129,6 @@ func (c *Client) moveCompletedTask(id int) (err1 error) {
|
||||
return err
|
||||
}
|
||||
|
||||
// .plexmatch file
|
||||
if err := c.writePlexmatch(r.MediaID, r.EpisodeID, r.TargetDir, torrentName); err != nil {
|
||||
log.Errorf("create .plexmatch file error: %v", err)
|
||||
}
|
||||
|
||||
//如果种子是路径,则会把路径展开,只移动文件,类似 move dir/* dir2/, 如果种子是文件,则会直接移动文件,类似 move file dir/
|
||||
if err := stImpl.Copy(filepath.Join(c.db.GetDownloadDir(), torrentName), r.TargetDir); err != nil {
|
||||
return errors.Wrap(err, "move file")
|
||||
|
||||
Reference in New Issue
Block a user