Переглянути джерело

修复 subhd zimuku 搜索链接拼接问题 fixed #667

Signed-off-by: allan716 <[email protected]>
allan716 2 роки тому
батько
коміт
15f5479bd9
2 змінених файлів з 56 додано та 0 видалено
  1. 52 0
      pkg/hot_fix/hot_fix_007.go
  2. 4 0
      pkg/hot_fix/hot_fix_hub.go

+ 52 - 0
pkg/hot_fix/hot_fix_007.go

@@ -0,0 +1,52 @@
+package hot_fix
+
+import (
+	"github.com/ChineseSubFinder/ChineseSubFinder/pkg/settings"
+	"github.com/ChineseSubFinder/ChineseSubFinder/pkg/types/common"
+	"github.com/sirupsen/logrus"
+)
+
+/*
+	修复之前移除 subhd 和 zimuku 配置后,导致的无法获取字幕搜索链接的问题
+*/
+type HotFix007 struct {
+	log *logrus.Logger
+}
+
+func NewHotFix007(log *logrus.Logger) *HotFix007 {
+	return &HotFix007{log: log}
+}
+
+func (h HotFix007) GetKey() string {
+	return "007"
+}
+
+func (h HotFix007) Process() (interface{}, error) {
+
+	defer func() {
+		h.log.Infoln("Hotfix", h.GetKey(), "End")
+	}()
+
+	h.log.Infoln("Hotfix", h.GetKey(), "Start...")
+
+	return h.process()
+}
+
+func (h HotFix007) process() (bool, error) {
+
+	if settings.Get().AdvancedSettings.SuppliersSettings.SubHD == nil {
+		settings.Get().AdvancedSettings.SuppliersSettings.SubHD = settings.NewOneSupplierSettings(common.SubSiteSubHd, common.SubSubHDRootUrlDef, common.SubSubHDSearchUrl, 20)
+	}
+
+	if settings.Get().AdvancedSettings.SuppliersSettings.Zimuku == nil {
+		settings.Get().AdvancedSettings.SuppliersSettings.Zimuku = settings.NewOneSupplierSettings(common.SubSiteZiMuKu, common.SubZiMuKuRootUrlDef, common.SubZiMuKuSearchFormatUrl, 20)
+	}
+
+	err := settings.Get().Save()
+	if err != nil {
+		return false, err
+	}
+	settings.Get(true)
+
+	return true, nil
+}

+ 4 - 0
pkg/hot_fix/hot_fix_hub.go

@@ -24,6 +24,7 @@ func HotFixProcess(log *logrus.Logger, param types.HotFixParam) error {
 		NewHotFix004(log),
 		NewHotFix005(log),
 		NewHotFix006(log),
+		NewHotFix007(log),
 		// 注意下面的 switch case 也要相应的加
 	}
 	// -----------------------------------------------------------------------
@@ -79,6 +80,9 @@ func HotFixProcess(log *logrus.Logger, param types.HotFixParam) error {
 		case "006":
 			log.Infoln("Hotfix 006, process == ", processResult.(bool))
 			break
+		case "007":
+			log.Infoln("Hotfix 007, process == ", processResult.(bool))
+			break
 		default:
 			continue
 		}