Skip to content

Commit

Permalink
因为出现有 S00E20 这种前传的命名方式出现,那么之前仅仅是以 S=0 E=0 去强制表达为电影的思路会遇到瓶颈,现在新增 IsMov…
Browse files Browse the repository at this point in the history
…ie 字段来进行标注,服务器也需要对应的新增这个接口字段

Signed-off-by: allan716 <525223688@qq.com>
  • Loading branch information
allanpk716 committed Jun 10, 2022
1 parent 1f1df85 commit 829bc43
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/models/low_video_sub_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type LowVideoSubInfo struct {
StoreRPath string `json:"store_r_path"` // 字幕存在出本地的哪里相对路径上,cache/CSF-ShareSubCache
ExtraPreName string `json:"extra_pre_name" binding:"required"` // 字幕额外的命名信息,指 Emby 字幕命名格式(简英,subhd),的 subhd
SHA256 string `json:"sha_256" binding:"required"` // 当前文件的 sha256 的值
IsMovie bool `json:"is_movie"` // 不是电影就是连续剧
IsSend bool `json:"is_send"` // 是否已经发送
}

Expand Down
1 change: 1 addition & 0 deletions internal/models/video_sub_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type VideoSubInfo struct {
ExtraPreName string `json:"extra_pre_name" binding:"required"` // 字幕额外的命名信息,指 Emby 字幕命名格式(简英,subhd),的 subhd
SHA256 string `json:"sha_256" binding:"required"` // 当前文件的 sha256 的值
IsSend bool `json:"is_send"` // 是否已经发送
IsMovie bool `json:"is_movie"` // 不是电影就是连续剧
IMDBInfoID string `json:"imdb_info_id" binding:"required"` // IMDB ID
}

Expand Down
84 changes: 84 additions & 0 deletions internal/pkg/hot_fix/hot_fix_005.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package hot_fix

import (
"os"
"path/filepath"

"github.com/allanpk716/ChineseSubFinder/internal/dao"
"github.com/allanpk716/ChineseSubFinder/internal/models"
"github.com/allanpk716/ChineseSubFinder/internal/pkg/my_folder"
"github.com/allanpk716/ChineseSubFinder/internal/pkg/my_util"
"github.com/sirupsen/logrus"
)

/*
嗯···之前对于连续剧的一集的解析 Season 和 Episode 的方式是从文件名得到的,最近看到由反馈到削刮之后,命名是 S01.E01,这样的方式
那么就可能解析不对,现在需要重新改为从 nfo 或者 xml 文件中得到这个信息,就需要删除之前缓存的数据,然后重新上传,不然之前的数据可能有部分是错误的
*/
type HotFix005 struct {
log *logrus.Logger
}

func NewHotFix005(log *logrus.Logger) *HotFix005 {
return &HotFix005{log: log}
}

func (h HotFix005) GetKey() string {
return "005"
}

func (h HotFix005) Process() (interface{}, error) {

defer func() {
h.log.Infoln("Hotfix", h.GetKey(), "End")
}()

h.log.Infoln("Hotfix", h.GetKey(), "Start...")

return h.process()
}

func (h HotFix005) process() (bool, error) {

shareRootDir, err := my_folder.GetShareSubRootFolder()
if err != nil {
h.log.Errorln("GetShareSubRootFolder error:", err.Error())
return false, err
}

// 高可信字幕
var videoInfos []models.VideoSubInfo
// 把嵌套关联的 has many 的信息都查询出来
dao.GetDb().Find(&videoInfos)
for _, info := range videoInfos {

delFileFPath := filepath.Join(shareRootDir, info.StoreRPath)
if my_util.IsFile(delFileFPath) == true {
err = os.Remove(delFileFPath)
if err != nil {
h.log.Errorln("Remove file:", delFileFPath, " error:", err.Error())
continue
}
}
dao.GetDb().Delete(&info)
}
// 低可信字幕
var lowTrustVideoInfos []models.LowVideoSubInfo
// 把嵌套关联的 has many 的信息都查询出来
dao.GetDb().Find(&lowTrustVideoInfos)
for _, info := range lowTrustVideoInfos {

delFileFPath := filepath.Join(shareRootDir, info.StoreRPath)
if my_util.IsFile(delFileFPath) == true {
err = os.Remove(delFileFPath)
if err != nil {
h.log.Errorln("Remove file:", delFileFPath, " error:", err.Error())
continue
}
}

dao.GetDb().Delete(&info)
}

return true, nil
}
5 changes: 5 additions & 0 deletions internal/pkg/hot_fix/hot_fix_hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ func HotFixProcess(log *logrus.Logger, param types.HotFixParam) error {
NewHotFix002(log),
NewHotFix003(log),
NewHotFix004(log),
NewHotFix005(log),
// 注意下面的 switch case 也要相应的加
}
// -----------------------------------------------------------------------
// 找现在有多少个 hotfix 执行过了
Expand Down Expand Up @@ -69,6 +71,9 @@ func HotFixProcess(log *logrus.Logger, param types.HotFixParam) error {
case "004":
log.Infoln("Hotfix 004, process == ", processResult.(bool))
break
case "005":
log.Infoln("Hotfix 005, process == ", processResult.(bool))
break
default:
continue
}
Expand Down

0 comments on commit 829bc43

Please sign in to comment.