浏览代码

新增启动 flag setconfigselfpath 允许指定自定义的 config 目录

Signed-off-by: allan716 <[email protected]>
allan716 3 年之前
父节点
当前提交
73845b2e56
共有 54 个文件被更改,包括 426 次插入182 次删除
  1. 13 0
      .github/workflows/release.yml
  2. 93 0
      .goreleaser-ChineseSubFinder-lite.yml
  3. 7 8
      cmd/GetCAPTCHA/main.go
  4. 32 15
      cmd/chinesesubfinder/main.go
  5. 3 2
      cmd/subtimelinefixer/main.go
  6. 5 4
      internal/backend/controllers/base/controller_base.go
  7. 4 3
      internal/backend/controllers/base/system_status.go
  8. 3 2
      internal/backend/controllers/v1/jobs_things.go
  9. 3 2
      internal/dao/init.go
  10. 6 5
      pkg/cache_center/cache_center.go
  11. 3 2
      pkg/cache_center/task_queue_info.go
  12. 2 2
      pkg/debug_view/debug_view.go
  13. 4 3
      pkg/downloader/cache_info.go
  14. 4 3
      pkg/downloader/downloader_things.go
  15. 2 2
      pkg/downloader/queue_cloud.go
  16. 4 4
      pkg/downloader/queue_local.go
  17. 3 2
      pkg/ffmpeg_helper/ffmpeg_helper.go
  18. 2 2
      pkg/ffmpeg_helper/ffmpeg_info.go
  19. 10 2
      pkg/folder.go
  20. 1 1
      pkg/folder_test.go
  21. 20 9
      pkg/global_value.go
  22. 3 2
      pkg/hot_fix/hot_fix_005.go
  23. 5 4
      pkg/imdb_helper/imdb.go
  24. 4 3
      pkg/log_helper/log_hub.go
  25. 6 5
      pkg/log_helper/loghelper.go
  26. 2 2
      pkg/logic/cron_helper/cron_helper.go
  27. 3 3
      pkg/logic/cron_helper/upload_played_video_sub.go
  28. 2 2
      pkg/logic/forced_scan_and_down_sub/forced_scan_and_down_sub.go
  29. 5 6
      pkg/logic/pre_download_process/pre_download_proces.go
  30. 2 2
      pkg/logic/restore_fix_timeline_bk/restore_fix_timeline_bk.go
  31. 5 4
      pkg/logic/scan_played_video_subinfo/scan_played_video_subinfo.go
  32. 5 4
      pkg/logic/sub_supplier/a4k/a4k_test.go
  33. 3 2
      pkg/logic/sub_supplier/assrt/assrt.go
  34. 5 4
      pkg/logic/sub_supplier/assrt/assrt_test.go
  35. 3 3
      pkg/logic/sub_supplier/csf/csf.go
  36. 5 4
      pkg/logic/sub_supplier/csf/csf_test.go
  37. 5 4
      pkg/logic/sub_supplier/shooter/shooter_test.go
  38. 4 3
      pkg/logic/sub_supplier/subhd/subhd.go
  39. 8 7
      pkg/logic/sub_supplier/subhd/subhd_test.go
  40. 5 4
      pkg/logic/sub_supplier/xunlei/xunlei_test.go
  41. 3 2
      pkg/logic/sub_supplier/zimuku/zimuku.go
  42. 4 4
      pkg/logic/sub_supplier/zimuku/zimuku_test.go
  43. 5 4
      pkg/my_util/custom_file.go
  44. 6 6
      pkg/rod_helper/rod_base.go
  45. 2 2
      pkg/settings/settings.go
  46. 4 3
      pkg/sub_helper/sub_helper.go
  47. 3 3
      pkg/sub_helper/sub_helper_test.go
  48. 3 2
      pkg/sub_share_center/share_sub_cache_helper.go
  49. 2 2
      pkg/subtitle_best_api/subtitle_best_api.go
  50. 5 4
      pkg/subtitle_best_api/subtitle_best_api_test.go
  51. 3 2
      pkg/task_control/task_control_test.go
  52. 6 5
      pkg/task_queue/task_queue.go
  53. 74 0
      pkg/video_list_helper/video_list_helper.go
  54. 2 2
      pkg/video_scan_and_refresh_helper/video_scan_and_refresh_helper.go

+ 13 - 0
.github/workflows/release.yml

@@ -44,6 +44,19 @@ jobs:
           AESKEY16: ${{ secrets.AESKEY16 }}
           AESIV16: ${{ secrets.AESIV16 }}
 
+      - name: Run GoReleaser-lite
+        uses: goreleaser/goreleaser-action@v2
+        with:
+          # either 'goreleaser' (default) or 'goreleaser-pro'
+          distribution: goreleaser
+          version: latest
+          args: release -f .goreleaser-ChineseSubFinder-lite.yml --rm-dist
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN  }}
+          BASEKEY: ${{ secrets.BASEKEY }}
+          AESKEY16: ${{ secrets.AESKEY16 }}
+          AESIV16: ${{ secrets.AESIV16 }}
+
   buildx:
     runs-on: ubuntu-latest
     needs: goreleaser

+ 93 - 0
.goreleaser-ChineseSubFinder-lite.yml

@@ -0,0 +1,93 @@
+project_name: chinesesubfinder
+
+env:
+  - GO111MODULE=on
+
+before:
+  hooks:
+    - go mod tidy
+    - sudo apt-get update -y
+    - sudo apt-get install gcc-multilib
+    - sudo apt-get install -y *-w64-x86-*
+    - sudo apt-get install gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu gcc-arm-linux-gnueabi g++-arm-linux-gnueabihf g++-aarch64-linux-gnu g++-arm-linux-gnueabi
+    # https://github.com/goreleaser/goreleaser-cross 交叉编译的文档
+#    - sudo apt-get install libc6-armel-cross libc6-dev-armel-cross binutils-arm-linux-gnueabi libncurses5-dev
+#    - sudo apt-get install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
+#    - sudo apt-get install -y aarch64-linux-gnu-gcc
+#    - sudo apt-get install -y aarch64-linux-gnu-g++
+#    - sudo apt-get install -y arm-linux-gnueabihf-gcc
+#    - sudo apt-get install -y arm-linux-gnueabihf-g++
+builds:
+
+  - id: linux-amd64-build-synology
+    env:
+      - CGO_ENABLED=1
+    goos:
+      - linux
+    goarch:
+      - amd64
+    main: ./cmd/chinesesubfinder/main.go
+    ldflags:
+      - -s -w --extldflags "-static -fpic" -X main.LiteMode=true -X main.AppVersion=v{{ .Version }} -X main.BaseKey={{ .Env.BASEKEY }} -X main.AESKey16={{ .Env.AESKEY16 }} -X main.AESIv16={{ .Env.AESIV16 }}
+
+  - id: linux-armv7-build-synology
+    env:
+      - CGO_ENABLED=1
+      - CC=arm-linux-gnueabihf-gcc
+      - CXX=arm-linux-gnueabihf-g++
+    goos:
+      - linux
+    goarch:
+      - arm
+    goarm:
+      - 7
+    main: ./cmd/chinesesubfinder/main.go
+    ldflags:
+      - -s -w --extldflags "-static -fpic" -X main.LiteMode=true -X main.AppVersion=v{{ .Version }} -X main.BaseKey={{ .Env.BASEKEY }} -X main.AESKey16={{ .Env.AESKEY16 }} -X main.AESIv16={{ .Env.AESIV16 }}
+
+  - id: linux-arm64-build-synology
+    env:
+      - CGO_ENABLED=1
+      - CC=aarch64-linux-gnu-gcc
+      - CXX=aarch64-linux-gnu-g++
+    goos:
+      - linux
+    goarch:
+      - arm64
+    main: ./cmd/chinesesubfinder/main.go
+    ldflags:
+      - -s -w --extldflags "-static -fpic" -X main.LiteMode=true -X main.AppVersion=v{{ .Version }} -X main.BaseKey={{ .Env.BASEKEY }} -X main.AESKey16={{ .Env.AESKEY16 }} -X main.AESIv16={{ .Env.AESIV16 }}
+
+  - id: windows-build
+    env:
+      - CGO_ENABLED=1
+      - CXX=x86_64-w64-mingw32-g++
+      - CC=x86_64-w64-mingw32-gcc
+    goos:
+      - windows
+    goarch:
+      - amd64
+    main: ./cmd/chinesesubfinder/main.go
+    ldflags:
+      - -s -w --extldflags "-static -fpic" -X main.LiteMode=true -X main.AppVersion=v{{ .Version }} -X main.BaseKey={{ .Env.BASEKEY }} -X main.AESKey16={{ .Env.AESKEY16 }} -X main.AESIv16={{ .Env.AESIV16 }}
+
+archives:
+  - id: archive
+    name_template: "{{ .ProjectName }}-lite-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
+    replacements:
+      darwin: Darwin
+      linux: Linux
+      windows: Windows
+      amd64: x86_64
+checksum:
+  name_template: "checksums.txt"
+snapshot:
+  name_template: "{{ .Tag }}-next"
+changelog:
+  sort: asc
+  filters:
+    exclude:
+      - "^docs:"
+      - "^test:"
+      - "^TestData:"
+      - "^TestCode:"

+ 7 - 8
cmd/GetCAPTCHA/main.go

@@ -5,13 +5,12 @@ import (
 	"path/filepath"
 	"time"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
+	"github.com/allanpk716/ChineseSubFinder/pkg"
 
 	"github.com/allanpk716/ChineseSubFinder/pkg/random_auth_key"
 
 	"github.com/allanpk716/ChineseSubFinder/cmd/GetCAPTCHA/backend"
 	"github.com/allanpk716/ChineseSubFinder/cmd/GetCAPTCHA/backend/config"
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/pkg/log_helper"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/pkg/notify_center"
@@ -25,13 +24,13 @@ func newLog() *logrus.Logger {
 	// --------------------------------------------------
 	// 之前是读取配置文件,现在改为,读取当前目录下,是否有一个特殊的文件,有则启动 Debug 日志级别
 	// 那么怎么写入这个文件,就靠额外的逻辑控制了
-	if my_util.IsFile(filepath.Join(global_value.ConfigRootDirFPath(), log_helper.DebugFileName)) == true {
+	if my_util.IsFile(filepath.Join(pkg.ConfigRootDirFPath(), log_helper.DebugFileName)) == true {
 		level = logrus.DebugLevel
 	} else {
 		level = logrus.InfoLevel
 	}
 	logger := log_helper.NewLogHelper(log_helper.LogNameGetCAPTCHA,
-		global_value.ConfigRootDirFPath(),
+		pkg.ConfigRootDirFPath(),
 		level, time.Duration(7*24)*time.Hour, time.Duration(24)*time.Hour)
 	logger.AddHook(log_helper.NewLoggerHub())
 
@@ -98,7 +97,7 @@ func Process(proxySettings *settings.ProxySettings) error {
 
 		notify_center.Notify.Send()
 
-		err = my_folder.ClearRodTmpRootFolder()
+		err = pkg.ClearRodTmpRootFolder()
 		if err != nil {
 			loggerBase.Errorln(err.Error())
 			return
@@ -112,9 +111,9 @@ func Process(proxySettings *settings.ProxySettings) error {
 		return fmt.Errorf("ReadCustomAuthFile failed")
 	}
 	AuthKey := random_auth_key.AuthKey{
-		BaseKey:  global_value.BaseKey(),
-		AESKey16: global_value.AESKey16(),
-		AESIv16:  global_value.AESIv16(),
+		BaseKey:  pkg.BaseKey(),
+		AESKey16: pkg.AESKey16(),
+		AESIv16:  pkg.AESIv16(),
 	}
 	randomAuthKey := random_auth_key.NewRandomAuthKey(5, AuthKey)
 	nowAuthKey, err := randomAuthKey.GetAuthKey()

+ 32 - 15
cmd/chinesesubfinder/main.go

@@ -1,6 +1,7 @@
 package main
 
 import (
+	"flag"
 	"fmt"
 	"net/http"
 	_ "net/http/pprof"
@@ -8,6 +9,8 @@ import (
 	"strings"
 	"time"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/internal/dao"
 
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/cron_helper"
@@ -19,7 +22,6 @@ import (
 	"github.com/allanpk716/ChineseSubFinder/internal/backend"
 	"github.com/allanpk716/ChineseSubFinder/pkg/cache_center"
 	"github.com/allanpk716/ChineseSubFinder/pkg/common"
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/pkg/log_helper"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/pkg/settings"
@@ -31,14 +33,14 @@ func newLog() *logrus.Logger {
 	// --------------------------------------------------
 	// 之前是读取配置文件,现在改为,读取当前目录下,是否有一个特殊的文件,有则启动 Debug 日志级别
 	// 那么怎么写入这个文件,就靠额外的逻辑控制了
-	if my_util.IsFile(filepath.Join(global_value.ConfigRootDirFPath(), log_helper.DebugFileName)) == true {
+	if my_util.IsFile(filepath.Join(pkg.ConfigRootDirFPath(), log_helper.DebugFileName)) == true {
 		level = logrus.DebugLevel
 	} else {
 		level = logrus.InfoLevel
 	}
 	logger := log_helper.NewLogHelper(
 		log_helper.LogNameChineseSubFinder,
-		global_value.ConfigRootDirFPath(),
+		pkg.ConfigRootDirFPath(),
 		level, time.Duration(7*24)*time.Hour, time.Duration(24)*time.Hour,
 		settings.GetSettings().ExperimentalFunction.ExtendLog)
 	logger.AddHook(log_helper.NewLoggerHub())
@@ -47,24 +49,27 @@ func newLog() *logrus.Logger {
 }
 
 func init() {
+	// 要先进行 flag 的读取,并且写入全局变量中,否则后续的逻辑由于顺序问题故障
+	flag.Parse()
+	pkg.SetLinuxConfigPathInSelfPath(*SetLinuxConfigPathInSelfPathFlag)
+
 	loggerBase = newLog()
 	// --------------------------------------------------
 	if strings.ToLower(LiteMode) == "true" {
 		loggerBase.Info("LiteMode is true")
 		AppVersion += " Lite"
-		global_value.SetLiteMode(true)
+		pkg.SetLiteMode(true)
 	} else {
-		global_value.SetLiteMode(false)
+		pkg.SetLiteMode(false)
 	}
 
 	loggerBase.Infoln("ChineseSubFinder Version:", AppVersion)
-
-	global_value.SetAppVersion(AppVersion)
-	global_value.SetExtEnCode(ExtEnCode)
+	pkg.SetAppVersion(AppVersion)
+	pkg.SetExtEnCode(ExtEnCode)
 	if my_util.ReadCustomAuthFile(loggerBase) == false {
-		global_value.SetBaseKey(BaseKey)
-		global_value.SetAESKey16(AESKey16)
-		global_value.SetAESIv16(AESIv16)
+		pkg.SetBaseKey(BaseKey)
+		pkg.SetAESKey16(AESKey16)
+		pkg.SetAESIv16(AESIv16)
 	}
 	// --------------------------------------------------
 	if my_util.OSCheck() == false {
@@ -94,6 +99,15 @@ func main() {
 		loggerBase = newLog()
 		loggerBase.Infoln("Reload Log Settings, level = Info")
 	}
+	if pkg.LinuxConfigPathInSelfPath() != "" {
+
+		loggerBase.Infoln("SetLinuxConfigPathInSelfPath:", pkg.LinuxConfigPathInSelfPath())
+
+		if my_util.IsDir(pkg.LinuxConfigPathInSelfPath()) == false {
+			// 如果设置了这个路径,但是不存在则会崩溃
+			loggerBase.Panicln("LinuxConfigPathInSelfPath", pkg.LinuxConfigPathInSelfPath(), "is not dir")
+		}
+	}
 
 	// ------------------------------------------------------------------------
 	// 设置接口的 API TOKEN
@@ -124,7 +138,7 @@ func main() {
 	if settings.GetSettings().SpeedDevMode == false {
 		pj := pre_job.NewPreJob(settings.GetSettings(), loggerBase)
 
-		if global_value.LiteMode() == true {
+		if pkg.LiteMode() == true {
 			// 不启用 Chrome 相关操作
 			err := pj.HotFix().ChangeSubNameFormat().Wait()
 			if err != nil {
@@ -143,9 +157,9 @@ func main() {
 	fileDownloader := file_downloader.NewFileDownloader(
 		cache_center.NewCacheCenter("local_task_queue", settings.GetSettings(), loggerBase),
 		random_auth_key.AuthKey{
-			BaseKey:  global_value.BaseKey(),
-			AESKey16: global_value.AESKey16(),
-			AESIv16:  global_value.AESIv16(),
+			BaseKey:  pkg.BaseKey(),
+			AESKey16: pkg.AESKey16(),
+			AESIv16:  pkg.AESIv16(),
 		})
 	// ----------------------------------------------
 	cronHelper := cron_helper.NewCronHelper(fileDownloader)
@@ -180,6 +194,9 @@ var AppVersion = "unknow"
 // go build -ldflags="-X main.AppVersion=aabb -X main.ExtEnCode=ccdd" .
 var ExtEnCode = "abcdefg1234567890"
 
+// 针对制作群晖的 SPK 应用,无法写入默认的 /config 目录而给出的新的编译条件,直接指向这个目录到当前程序的目录
+var SetLinuxConfigPathInSelfPathFlag = flag.String("setconfigselfpath", "", "针对制作群晖的 SPK 应用,无法写入默认的 /config 目录而给出的新的编译条件,直接指向这个目录到当前程序的目录")
+
 var (
 	BaseKey  = "0123456789123456789" // 基础的密钥,密钥会基于这个基础的密钥生成
 	AESKey16 = "1234567890123456"    // AES密钥

+ 3 - 2
cmd/subtimelinefixer/main.go

@@ -6,9 +6,10 @@ import (
 	"strings"
 	"time"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/sub_timeline_fixer"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/pkg/log_helper"
 	"github.com/allanpk716/ChineseSubFinder/pkg/settings"
 	"github.com/sirupsen/logrus"
@@ -34,7 +35,7 @@ var loggerBase *logrus.Logger
 
 func newLog() *logrus.Logger {
 	logger := log_helper.NewLogHelper(log_helper.LogNameCliSubTimelineFixer,
-		global_value.ConfigRootDirFPath(),
+		pkg.ConfigRootDirFPath(),
 		logrus.InfoLevel, time.Duration(7*24)*time.Hour, time.Duration(24)*time.Hour)
 	return logger
 }

+ 5 - 4
internal/backend/controllers/base/controller_base.go

@@ -3,10 +3,11 @@ package base
 import (
 	"net/http"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/lock"
 
 	"github.com/allanpk716/ChineseSubFinder/pkg/cache_center"
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/pkg/random_auth_key"
 	"github.com/allanpk716/ChineseSubFinder/pkg/settings"
 	"github.com/sirupsen/logrus"
@@ -28,9 +29,9 @@ func NewControllerBase(loggerBase *logrus.Logger, restartSignal chan interface{}
 		fileDownloader: file_downloader.NewFileDownloader(
 			cache_center.NewCacheCenter("local_task_queue", settings.GetSettings(), loggerBase),
 			random_auth_key.AuthKey{
-				BaseKey:  global_value.BaseKey(),
-				AESKey16: global_value.AESKey16(),
-				AESIv16:  global_value.AESIv16(),
+				BaseKey:  pkg.BaseKey(),
+				AESKey16: pkg.AESKey16(),
+				AESIv16:  pkg.AESIv16(),
 			}),
 		proxyCheckLocker: lock.NewLock(),
 		restartSignal:    restartSignal,

+ 4 - 3
internal/backend/controllers/base/system_status.go

@@ -1,11 +1,12 @@
 package base
 
 import (
-	"github.com/allanpk716/ChineseSubFinder/pkg/types/backend"
 	"net/http"
 	"runtime"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+	"github.com/allanpk716/ChineseSubFinder/pkg/types/backend"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/settings"
 	running "github.com/allanpk716/is_running_in_docker"
 	"github.com/gin-gonic/gin"
@@ -28,7 +29,7 @@ func (cb *ControllerBase) SystemStatusHandler(c *gin.Context) {
 
 	c.JSON(http.StatusOK, backend.ReplySystemStatus{
 		IsSetup:           isSetup,
-		Version:           global_value.AppVersion(),
+		Version:           pkg.AppVersion(),
 		OS:                runtime.GOOS,
 		ARCH:              runtime.GOARCH,
 		IsRunningInDocker: running.IsRunningInDocker()})

+ 3 - 2
internal/backend/controllers/v1/jobs_things.go

@@ -8,11 +8,12 @@ import (
 	"os"
 	"path/filepath"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	backend2 "github.com/allanpk716/ChineseSubFinder/pkg/types/backend"
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/common"
 	task_queue3 "github.com/allanpk716/ChineseSubFinder/pkg/types/task_queue"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	task_queue2 "github.com/allanpk716/ChineseSubFinder/pkg/task_queue"
 	"github.com/gin-gonic/gin"
@@ -104,7 +105,7 @@ func (cb *ControllerBase) JobLogHandler(c *gin.Context) {
 		return
 	}
 
-	pathRoot := filepath.Join(global_value.ConfigRootDirFPath(), "Logs")
+	pathRoot := filepath.Join(pkg.ConfigRootDirFPath(), "Logs")
 	fileFPath := filepath.Join(pathRoot, common.OnceLogPrefix+reqJobLog.Id+".log")
 	if my_util.IsFile(fileFPath) == true {
 		// 存在

+ 3 - 2
internal/dao/init.go

@@ -7,8 +7,9 @@ import (
 	"path/filepath"
 	"sync"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/internal/models"
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"gorm.io/driver/sqlite"
 	"gorm.io/gorm"
@@ -81,7 +82,7 @@ func InitDb() error {
 }
 
 func getDbName() string {
-	return filepath.Join(my_folder.GetConfigRootDirFPath(), dbFileName)
+	return filepath.Join(pkg.GetConfigRootDirFPath(), dbFileName)
 }
 
 var (

+ 6 - 5
pkg/cache_center/cache_center.go

@@ -6,8 +6,9 @@ import (
 	"path/filepath"
 	"sync"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/cache_center/models"
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/pkg/settings"
 	"github.com/sirupsen/logrus"
@@ -33,7 +34,7 @@ func NewCacheCenter(cacheName string, Settings *settings.Settings, Log *logrus.L
 	c.Settings = Settings
 	c.Log = Log
 	var err error
-	c.centerFolder, err = my_folder.GetRootCacheCenterFolder()
+	c.centerFolder, err = pkg.GetRootCacheCenterFolder()
 	if err != nil {
 		panic(err)
 	}
@@ -76,7 +77,7 @@ func (c *CacheCenter) Close() {
 
 func DelDb(cacheName string) {
 
-	centerFolder, err := my_folder.GetRootCacheCenterFolder()
+	centerFolder, err := pkg.GetRootCacheCenterFolder()
 	if err != nil {
 		return
 	}
@@ -89,13 +90,13 @@ func DelDb(cacheName string) {
 	}
 
 	taskQueueSaveRootPath := filepath.Join(centerFolder, taskQueueFolderName, cacheName)
-	err = my_folder.ClearFolder(taskQueueSaveRootPath)
+	err = pkg.ClearFolder(taskQueueSaveRootPath)
 	if err != nil {
 		return
 	}
 
 	downloadFileSaveRootPath := filepath.Join(centerFolder, downloadFilesFolderName, cacheName)
-	err = my_folder.ClearFolder(downloadFileSaveRootPath)
+	err = pkg.ClearFolder(downloadFileSaveRootPath)
 	if err != nil {
 		return
 	}

+ 3 - 2
pkg/cache_center/task_queue_info.go

@@ -5,15 +5,16 @@ import (
 	"os"
 	"path/filepath"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/cache_center/models"
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 )
 
 func (c *CacheCenter) TaskQueueClear() error {
 
 	// 没有必要删除 DB 中的数据,直接删除外部的缓存文件即可
-	err := my_folder.ClearFolder(c.taskQueueSaveRootPath)
+	err := pkg.ClearFolder(c.taskQueueSaveRootPath)
 	if err != nil {
 		return err
 	}

+ 2 - 2
pkg/debug_view/debug_view.go

@@ -2,10 +2,10 @@ package debug_view
 
 import (
 	"fmt"
+	"github.com/allanpk716/ChineseSubFinder/pkg"
 	"os"
 	"path/filepath"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/pkg/sub_helper"
 	"github.com/allanpk716/ChineseSubFinder/pkg/vad"
 	"github.com/go-echarts/go-echarts/v2/charts"
@@ -44,7 +44,7 @@ func SaveDebugChartBase(vadList []vad.VADInfo, title, subTitle string) error {
 		AddSeries("VAD", lineData)
 
 	// Where the magic happens
-	f, err := os.Create(filepath.Join(global_value.DefDebugFolder, title+".html"))
+	f, err := os.Create(filepath.Join(pkg.DefDebugFolder, title+".html"))
 	if err != nil {
 		return err
 	}

+ 4 - 3
pkg/downloader/cache_info.go

@@ -3,11 +3,12 @@ package downloader
 import (
 	"path/filepath"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	backend2 "github.com/allanpk716/ChineseSubFinder/pkg/types/backend"
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/common"
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/task_queue"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/pkg/strcut_json"
 	"github.com/allanpk716/ChineseSubFinder/pkg/sub_helper"
@@ -195,7 +196,7 @@ func (d *Downloader) getMovieInfoAndSeasonInfo(AllorFrontorEnd int) ([]backend2.
 func (d *Downloader) saveVideoListCache(movieInfos []backend2.MovieInfo, seasonInfos []backend2.SeasonInfo) error {
 
 	// 缓存下来
-	cacheCenterFolder, err := my_folder.GetRootCacheCenterFolder()
+	cacheCenterFolder, err := pkg.GetRootCacheCenterFolder()
 	if err != nil {
 		return err
 	}
@@ -223,7 +224,7 @@ func (d *Downloader) saveVideoListCache(movieInfos []backend2.MovieInfo, seasonI
 func (d *Downloader) loadVideoListCache() error {
 
 	// 缓存下来
-	cacheCenterFolder, err := my_folder.GetRootCacheCenterFolder()
+	cacheCenterFolder, err := pkg.GetRootCacheCenterFolder()
 	if err != nil {
 		return err
 	}

+ 4 - 3
pkg/downloader/downloader_things.go

@@ -6,6 +6,8 @@ import (
 	"os"
 	"path/filepath"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/common"
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/series"
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/subparser"
@@ -13,7 +15,6 @@ import (
 	"github.com/allanpk716/ChineseSubFinder/pkg/change_file_encode"
 	"github.com/allanpk716/ChineseSubFinder/pkg/chs_cht_changer"
 	"github.com/allanpk716/ChineseSubFinder/pkg/decode"
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	subcommon "github.com/allanpk716/ChineseSubFinder/pkg/sub_formatter/common"
 	"github.com/allanpk716/ChineseSubFinder/pkg/sub_helper"
@@ -34,7 +35,7 @@ func (d *Downloader) oneVideoSelectBestSub(oneVideoFullPath string, organizeSubF
 	// 调试缓存,把下载好的字幕写到对应的视频目录下,方便调试
 	if d.settings.AdvancedSettings.DebugMode == true {
 
-		err = my_folder.CopyFiles2DebugFolder([]string{videoFileName}, organizeSubFiles)
+		err = pkg.CopyFiles2DebugFolder([]string{videoFileName}, organizeSubFiles)
 		if err != nil {
 			// 这个错误可以忍
 			d.log.Errorln("copySubFile2DesFolder", err)
@@ -138,7 +139,7 @@ func (d *Downloader) saveFullSeasonSub(seriesInfo *series.SeriesInfo, organizeSu
 		for _, sub := range subs {
 			subFileName := filepath.Base(sub)
 
-			newSeasonSubRootPath, err := my_folder.GetDebugFolderByName([]string{
+			newSeasonSubRootPath, err := pkg.GetDebugFolderByName([]string{
 				filepath.Base(seriesInfo.DirPath),
 				"Sub_" + seasonKey})
 			if err != nil {

+ 2 - 2
pkg/downloader/queue_cloud.go

@@ -1,12 +1,12 @@
 package downloader
 
 import (
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
+	"github.com/allanpk716/ChineseSubFinder/pkg"
 )
 
 func (d *Downloader) queueDownloaderCloud() {
 
-	if global_value.LiteMode() == true ||
+	if pkg.LiteMode() == true ||
 		d.settings.ExperimentalFunction.ShareSubSettings.ShareSubEnabled == false ||
 		d.needSkipCloudTask == true {
 		// Lite 版本无法执行复杂的任务,因为没有浏览器

+ 4 - 4
pkg/downloader/queue_local.go

@@ -3,10 +3,10 @@ package downloader
 import (
 	"fmt"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/decode"
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/pkg/log_helper"
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/pkg/task_queue"
 	common2 "github.com/allanpk716/ChineseSubFinder/pkg/types/common"
@@ -234,12 +234,12 @@ func (d *Downloader) queueDownloaderLocal() {
 			close(done)
 			close(panicChan)
 			// 每下载完毕一次,进行一次缓存和 Chrome 的清理
-			err = my_folder.ClearRootTmpFolder()
+			err = pkg.ClearRootTmpFolder()
 			if err != nil {
 				d.log.Error("ClearRootTmpFolder", err)
 			}
 
-			if global_value.LiteMode() == false {
+			if pkg.LiteMode() == false {
 				my_util.CloseChrome(d.log)
 			}
 		}()

+ 3 - 2
pkg/ffmpeg_helper/ffmpeg_helper.go

@@ -9,12 +9,13 @@ import (
 	"path/filepath"
 	"strconv"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/common"
 
 	"github.com/allanpk716/ChineseSubFinder/pkg/language"
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/sub_parser/ass"
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/sub_parser/srt"
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/pkg/sub_parser_hub"
 	"github.com/sirupsen/logrus"
@@ -104,7 +105,7 @@ func (f *FFMPEGHelper) GetFFMPEGInfo(videoFileFullPath string, exportType Export
 		// 说明缓存不存在,需要导出,这里需要注意,如果导出失败了,这个文件夹要清理掉
 		if my_util.IsDir(nowCacheFolderPath) == true {
 			// 如果存在则,先清空一个这个文件夹
-			err = my_folder.ClearFolder(nowCacheFolderPath)
+			err = pkg.ClearFolder(nowCacheFolderPath)
 			if err != nil {
 				bok = false
 				return bok, nil, err

+ 2 - 2
pkg/ffmpeg_helper/ffmpeg_info.go

@@ -1,13 +1,13 @@
 package ffmpeg_helper
 
 import (
+	"github.com/allanpk716/ChineseSubFinder/pkg"
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/common"
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/subparser"
 	"os"
 	"path/filepath"
 	"strings"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/pkg/sub_helper"
 	"github.com/allanpk716/ChineseSubFinder/pkg/sub_parser_hub"
@@ -37,7 +37,7 @@ func NewFFMPEGInfo(log *logrus.Logger, videoFullPath string) *FFMPEGInfo {
 // csf-cache/当前的视频文件名(不带后缀)
 func (f *FFMPEGInfo) GetCacheFolderFPath() (string, error) {
 	noExtVideoName := strings.ReplaceAll(filepath.Base(f.VideoFullPath), filepath.Ext(f.VideoFullPath), "")
-	return my_folder.GetSubFixCacheFolderByName(noExtVideoName)
+	return pkg.GetSubFixCacheFolderByName(noExtVideoName)
 }
 
 // IsExported 是否已经导出过,如果没有导出或者导出不完整为 false

+ 10 - 2
pkg/my_folder/folder.go → pkg/folder.go

@@ -1,4 +1,4 @@
-package my_folder
+package pkg
 
 import (
 	"fmt"
@@ -380,7 +380,15 @@ func GetConfigRootDirFPath() string {
 	nowConfigFPath := ""
 	sysType := runtime.GOOS
 	if sysType == "linux" {
-		nowConfigFPath = configDirRootFPathLinux
+
+		if LinuxConfigPathInSelfPath() != "" {
+			// 跟 Windows 一样直接在当前程序目录下的 .
+			nowConfigFPath = LinuxConfigPathInSelfPath()
+		} else {
+			// 专用目录,与 Docker 设置一致
+			nowConfigFPath = configDirRootFPathLinux
+		}
+
 	} else if sysType == "windows" {
 		nowConfigFPath = configDirRootFPathWindows
 	} else if sysType == "darwin" {

+ 1 - 1
pkg/my_folder/folder_test.go → pkg/folder_test.go

@@ -1,4 +1,4 @@
-package my_folder
+package pkg
 
 import (
 	"testing"

+ 20 - 9
pkg/global_value/global_value.go → pkg/global_value.go

@@ -1,10 +1,8 @@
-package global_value
+package pkg
 
 import (
 	"strconv"
 	"strings"
-
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
 )
 
 // SetAppVersion ---------------------------------------------
@@ -82,7 +80,7 @@ func AESIv16() string {
 func ConfigRootDirFPath() string {
 
 	if _configRootDirFPath == "" {
-		_configRootDirFPath = my_folder.GetConfigRootDirFPath()
+		_configRootDirFPath = GetConfigRootDirFPath()
 	}
 	return _configRootDirFPath
 }
@@ -90,7 +88,7 @@ func ConfigRootDirFPath() string {
 func DefDebugFolder() string {
 	var err error
 	if _defDebugFolder == "" {
-		_defDebugFolder, err = my_folder.GetRootDebugFolder()
+		_defDebugFolder, err = GetRootDebugFolder()
 		if err != nil {
 			panic(err)
 		}
@@ -102,7 +100,7 @@ func DefDebugFolder() string {
 func DefTmpFolder() string {
 	var err error
 	if _defTmpFolder == "" {
-		_defTmpFolder, err = my_folder.GetRootTmpFolder()
+		_defTmpFolder, err = GetRootTmpFolder()
 		if err != nil {
 			panic(err)
 		}
@@ -114,7 +112,7 @@ func DefTmpFolder() string {
 func DefRodTmpRootFolder() string {
 	var err error
 	if _defRodTmpRootFolder == "" {
-		_defRodTmpRootFolder, err = my_folder.GetRodTmpRootFolder()
+		_defRodTmpRootFolder, err = GetRodTmpRootFolder()
 		if err != nil {
 			panic(err)
 		}
@@ -126,7 +124,7 @@ func DefRodTmpRootFolder() string {
 func DefSubFixCacheFolder() string {
 	var err error
 	if _defSubFixCacheFolder == "" {
-		_defSubFixCacheFolder, err = my_folder.GetRootSubFixCacheFolder()
+		_defSubFixCacheFolder, err = GetRootSubFixCacheFolder()
 		if err != nil {
 			panic(err)
 		}
@@ -138,7 +136,7 @@ func DefSubFixCacheFolder() string {
 func AdblockTmpFolder() string {
 	var err error
 	if _adblockTmpFolder == "" {
-		_adblockTmpFolder, err = my_folder.GetPluginFolderByName(my_folder.Plugin_Adblock)
+		_adblockTmpFolder, err = GetPluginFolderByName(Plugin_Adblock)
 		if err != nil {
 			panic(err)
 		}
@@ -156,6 +154,19 @@ func SetLiteMode(liteMode bool) {
 	_liteMode = liteMode
 }
 
+// LinuxConfigPathInSelfPath ---------------------------------------------
+// 针对制作群晖的 SPK 应用,无法写入默认的 /config 目录而给出的新的编译条件,直接指向这个目录到当前程序的目录
+func LinuxConfigPathInSelfPath() string {
+	return setLinuxConfigPathInSelfPath
+}
+
+func SetLinuxConfigPathInSelfPath(setPath string) {
+
+	setLinuxConfigPathInSelfPath = setPath
+}
+
+var setLinuxConfigPathInSelfPath = ""
+
 // ---------------------------------------------
 // util.go
 var (

+ 3 - 2
pkg/hot_fix/hot_fix_005.go

@@ -4,11 +4,12 @@ import (
 	"os"
 	"path/filepath"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"gorm.io/gorm"
 
 	"github.com/allanpk716/ChineseSubFinder/internal/dao"
 	"github.com/allanpk716/ChineseSubFinder/internal/models"
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/sirupsen/logrus"
 )
@@ -42,7 +43,7 @@ func (h HotFix005) Process() (interface{}, error) {
 
 func (h HotFix005) process() (bool, error) {
 
-	shareRootDir, err := my_folder.GetShareSubRootFolder()
+	shareRootDir, err := pkg.GetShareSubRootFolder()
 	if err != nil {
 		h.log.Errorln("GetShareSubRootFolder error:", err.Error())
 		return false, err

+ 5 - 4
pkg/imdb_helper/imdb.go

@@ -6,11 +6,12 @@ import (
 	"strings"
 	"sync"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/decode"
 
 	"github.com/allanpk716/ChineseSubFinder/pkg/subtitle_best_api"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/pkg/random_auth_key"
 
 	"github.com/StalkR/imdb"
@@ -244,9 +245,9 @@ func getReady(log *logrus.Logger, proxySettings *settings.ProxySettings) {
 	locker.Lock()
 	if randomAuthKey == nil {
 		randomAuthKey = &random_auth_key.AuthKey{
-			BaseKey:  global_value.BaseKey(),
-			AESKey16: global_value.AESKey16(),
-			AESIv16:  global_value.AESIv16(),
+			BaseKey:  pkg.BaseKey(),
+			AESKey16: pkg.AESKey16(),
+			AESIv16:  pkg.AESIv16(),
 		}
 
 		subtitleBestApi = subtitle_best_api.NewSubtitleBestApi(log, *randomAuthKey, proxySettings)

+ 4 - 3
pkg/log_helper/log_hub.go

@@ -8,10 +8,11 @@ import (
 	"sync"
 	"time"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/common"
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/log_hub"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	"github.com/huandu/go-clone"
 	"github.com/sirupsen/logrus"
 	easy "github.com/t-tomalak/logrus-easy-formatter"
@@ -153,7 +154,7 @@ func newOnceLogger(logFileName string) *logrus.Logger {
 		TimestampFormat: "2006-01-02 15:04:05",
 		LogFormat:       "[%lvl%]: %time% - %msg%\n",
 	}
-	pathRoot := filepath.Join(global_value.ConfigRootDirFPath(), "Logs")
+	pathRoot := filepath.Join(pkg.ConfigRootDirFPath(), "Logs")
 	fileName := fmt.Sprintf(common.OnceLogPrefix+"%v.log", logFileName)
 	fileAbsPath := filepath.Join(pathRoot, fileName)
 
@@ -182,7 +183,7 @@ func cleanAndLoadOnceLogs() {
 
 	onceLogsLock.Lock()
 
-	pathRoot := filepath.Join(global_value.ConfigRootDirFPath(), "Logs")
+	pathRoot := filepath.Join(pkg.ConfigRootDirFPath(), "Logs")
 	// 扫描当前日志存储目录下有多少个符合要求的 Once- 日志
 	// 确保有且仅有最近的 20 次扫描日志记录存在即可
 	matches, err := filepath.Glob(filepath.Join(pathRoot, common.OnceLogPrefix+"*.log"))

+ 6 - 5
pkg/log_helper/loghelper.go

@@ -6,11 +6,12 @@ import (
 	"path/filepath"
 	"time"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/settings"
 
 	"github.com/allanpk716/ChineseSubFinder/pkg/extend_log"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	rotatelogs "github.com/lestrrat-go/file-rotatelogs"
 	"github.com/sirupsen/logrus"
 
@@ -58,10 +59,10 @@ func isFile(filePath string) bool {
 
 // WriteDebugFile 写入开启 Debug 级别日志记录的特殊文件,注意这个最好是在主程序中调用,这样就跟主程序在一个目录下生成,log 去检测是否存在才有意义
 func WriteDebugFile() error {
-	if isFile(filepath.Join(global_value.ConfigRootDirFPath(), DebugFileName)) == true {
+	if isFile(filepath.Join(pkg.ConfigRootDirFPath(), DebugFileName)) == true {
 		return nil
 	}
-	f, err := os.Create(filepath.Join(global_value.ConfigRootDirFPath(), DebugFileName))
+	f, err := os.Create(filepath.Join(pkg.ConfigRootDirFPath(), DebugFileName))
 	defer func() {
 		_ = f.Close()
 	}()
@@ -74,10 +75,10 @@ func WriteDebugFile() error {
 // DeleteDebugFile 删除开启 Debug 级别日志记录的特殊文件
 func DeleteDebugFile() error {
 
-	if isFile(filepath.Join(global_value.ConfigRootDirFPath(), DebugFileName)) == false {
+	if isFile(filepath.Join(pkg.ConfigRootDirFPath(), DebugFileName)) == false {
 		return nil
 	}
-	err := os.Remove(filepath.Join(global_value.ConfigRootDirFPath(), DebugFileName))
+	err := os.Remove(filepath.Join(pkg.ConfigRootDirFPath(), DebugFileName))
 	if err != nil {
 		return err
 	}

+ 2 - 2
pkg/logic/cron_helper/cron_helper.go

@@ -2,7 +2,7 @@ package cron_helper
 
 import (
 	"github.com/allanpk716/ChineseSubFinder/internal/dao"
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
+	"github.com/allanpk716/ChineseSubFinder/pkg"
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/file_downloader"
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/scan_played_video_subinfo"
 
@@ -249,7 +249,7 @@ func (ch *CronHelper) Stop() {
 func (ch *CronHelper) scanPlayedVideoSub() {
 
 	ch.log.Infoln("Update Info...")
-	nowInfo := dao.UpdateInfo(global_value.AppVersion(), ch.Settings)
+	nowInfo := dao.UpdateInfo(pkg.AppVersion(), ch.Settings)
 	_, err := ch.FileDownloader.SubtitleBestApi.FeedBack(
 		nowInfo.Id,
 		nowInfo.Version, nowInfo.MediaServer,

+ 3 - 3
pkg/logic/cron_helper/upload_played_video_sub.go

@@ -3,6 +3,7 @@ package cron_helper
 import (
 	"errors"
 	"fmt"
+	"github.com/allanpk716/ChineseSubFinder/pkg"
 	"path/filepath"
 	"strconv"
 	"strings"
@@ -13,7 +14,6 @@ import (
 	"github.com/allanpk716/ChineseSubFinder/internal/dao"
 	"github.com/allanpk716/ChineseSubFinder/internal/models"
 	"github.com/allanpk716/ChineseSubFinder/pkg/mix_media_info"
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
 	"github.com/jinzhu/now"
 )
 
@@ -76,7 +76,7 @@ func (ch *CronHelper) uploadPlayedVideoSub() {
 	}
 	// 在这之前,需要进行一次判断,这个字幕是否是有效的,因为可能会有是 1kb 的错误字幕
 	// 如果解析这个字幕是错误的,那么也可以标记完成
-	shareRootDir, err := my_folder.GetShareSubRootFolder()
+	shareRootDir, err := pkg.GetShareSubRootFolder()
 	if err != nil {
 		ch.log.Errorln("GetShareSubRootFolder error:", err.Error())
 		return
@@ -271,7 +271,7 @@ func (ch *CronHelper) uploadLowTrustVideoSub() {
 	}
 	// 在这之前,需要进行一次判断,这个字幕是否是有效的,因为可能会有是 1kb 的错误字幕
 	// 如果解析这个字幕是错误的,那么也可以标记完成
-	shareRootDir, err := my_folder.GetShareSubRootFolder()
+	shareRootDir, err := pkg.GetShareSubRootFolder()
 	if err != nil {
 		ch.log.Errorln("GetShareSubRootFolder error:", err.Error())
 		return

+ 2 - 2
pkg/logic/forced_scan_and_down_sub/forced_scan_and_down_sub.go

@@ -3,10 +3,10 @@ package forced_scan_and_down_sub
 import (
 	"errors"
 	"fmt"
+	"github.com/allanpk716/ChineseSubFinder/pkg"
 	"os"
 	"path/filepath"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 )
 
@@ -32,7 +32,7 @@ you needd implement getSpeFileName() in internal/logic/forced_scan_and_down_sub/
 
 func getSpeFileName() string {
 
-	return filepath.Join(my_folder.GetConfigRootDirFPath(), specialFileNameWindows)
+	return filepath.Join(pkg.GetConfigRootDirFPath(), specialFileNameWindows)
 }
 
 /*

+ 5 - 6
pkg/logic/pre_download_process/pre_download_proces.go

@@ -5,6 +5,8 @@ import (
 	"fmt"
 	"time"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	common2 "github.com/allanpk716/ChineseSubFinder/pkg/types/common"
 
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/file_downloader"
@@ -15,9 +17,6 @@ import (
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/sub_supplier/shooter"
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/sub_supplier/xunlei"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
-
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/pkg/notify_center"
 	"github.com/allanpk716/ChineseSubFinder/pkg/settings"
@@ -65,7 +64,7 @@ func (p *PreDownloadProcess) Init() *PreDownloadProcess {
 	notify_center.Notify.Clear()
 	// ------------------------------------------------------------------------
 	// 获取验证码
-	if global_value.LiteMode() == false {
+	if pkg.LiteMode() == false {
 
 		nowTT := time.Now()
 		nowTimeFileNamePrix := fmt.Sprintf("%d%d%d", nowTT.Year(), nowTT.Month(), nowTT.Day())
@@ -125,7 +124,7 @@ func (p *PreDownloadProcess) Init() *PreDownloadProcess {
 			p.SubSupplierHub.AddSubSupplier(assrt.NewSupplier(p.fileDownloader))
 		}
 
-		if global_value.LiteMode() == false {
+		if pkg.LiteMode() == false {
 			// 如果不是 Lite 模式,那么就可以开启这个功能
 			if common2.SubhdCode != "" {
 				// 如果找到 code 了,那么就可以继续用这个实例
@@ -135,7 +134,7 @@ func (p *PreDownloadProcess) Init() *PreDownloadProcess {
 	}
 	// ------------------------------------------------------------------------
 	// 清理自定义的 rod 缓存目录
-	err := my_folder.ClearRodTmpRootFolder()
+	err := pkg.ClearRodTmpRootFolder()
 	if err != nil {
 		p.gError = errors.New("ClearRodTmpRootFolder " + err.Error())
 		return p

+ 2 - 2
pkg/logic/restore_fix_timeline_bk/restore_fix_timeline_bk.go

@@ -1,10 +1,10 @@
 package restore_fix_timeline_bk
 
 import (
+	"github.com/allanpk716/ChineseSubFinder/pkg"
 	"os"
 	"path/filepath"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 )
 
@@ -26,7 +26,7 @@ func CheckSpeFile() (bool, error) {
 }
 
 func getSpeFileName() string {
-	return filepath.Join(my_folder.GetConfigRootDirFPath(), specialFileName)
+	return filepath.Join(pkg.GetConfigRootDirFPath(), specialFileName)
 }
 
 /*

+ 5 - 4
pkg/logic/scan_played_video_subinfo/scan_played_video_subinfo.go

@@ -8,6 +8,8 @@ import (
 	"strings"
 	"sync"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/ifaces"
 	common2 "github.com/allanpk716/ChineseSubFinder/pkg/types/common"
 
@@ -21,7 +23,6 @@ import (
 	"github.com/allanpk716/ChineseSubFinder/pkg/decode"
 	"github.com/allanpk716/ChineseSubFinder/pkg/imdb_helper"
 	"github.com/allanpk716/ChineseSubFinder/pkg/language"
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/pkg/settings"
 	"github.com/allanpk716/ChineseSubFinder/pkg/sub_file_hash"
@@ -84,7 +85,7 @@ func NewScanPlayedVideoSubInfo(log *logrus.Logger, _settings *settings.Settings,
 	// 字幕命名格式解析器
 	scanPlayedVideoSubInfo.subFormatter = emby.NewFormatter()
 	// 缓存目录的根目录
-	shareRootDir, err := my_folder.GetShareSubRootFolder()
+	shareRootDir, err := pkg.GetShareSubRootFolder()
 	if err != nil {
 		return nil, err
 	}
@@ -235,7 +236,7 @@ func (s *ScanPlayedVideoSubInfo) Scan() error {
 		// TODO 暂时屏蔽掉 http api 提交的已看字幕的接口上传
 		if false {
 			// 下面需要把给出外部的 HTTP API 提交的视频和字幕信息(ThirdPartSetVideoPlayedInfo)进行判断,存入数据库
-			shareRootDir, err := my_folder.GetShareSubRootFolder()
+			shareRootDir, err := pkg.GetShareSubRootFolder()
 			if err != nil {
 				return err
 			}
@@ -313,7 +314,7 @@ func (s *ScanPlayedVideoSubInfo) scan(ctx context.Context, inData interface{}) e
 	s.log.Infoln("-----------------------------------------------")
 	s.log.Infoln("ScanPlayedVideoSubInfo", videoTypes, "Sub Start...")
 
-	shareRootDir, err := my_folder.GetShareSubRootFolder()
+	shareRootDir, err := pkg.GetShareSubRootFolder()
 	if err != nil {
 		return err
 	}

+ 5 - 4
pkg/logic/sub_supplier/a4k/a4k_test.go

@@ -4,13 +4,14 @@ import (
 	"path/filepath"
 	"testing"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/file_downloader"
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/series_helper"
 	"github.com/allanpk716/ChineseSubFinder/pkg/sub_helper"
 	"github.com/allanpk716/ChineseSubFinder/pkg/unit_test_helper"
 
 	"github.com/allanpk716/ChineseSubFinder/pkg/cache_center"
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/pkg/log_helper"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/pkg/random_auth_key"
@@ -88,9 +89,9 @@ func defInstance() {
 	my_util.ReadCustomAuthFile(log_helper.GetLogger4Tester())
 
 	authKey := random_auth_key.AuthKey{
-		BaseKey:  global_value.BaseKey(),
-		AESKey16: global_value.AESKey16(),
-		AESIv16:  global_value.AESIv16(),
+		BaseKey:  pkg.BaseKey(),
+		AESKey16: pkg.AESKey16(),
+		AESIv16:  pkg.AESIv16(),
 	}
 
 	nowSettings := settings.GetSettings()

+ 3 - 2
pkg/logic/sub_supplier/assrt/assrt.go

@@ -10,6 +10,8 @@ import (
 	"strconv"
 	"time"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	common2 "github.com/allanpk716/ChineseSubFinder/pkg/types/common"
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/series"
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/supplier"
@@ -20,7 +22,6 @@ import (
 
 	"github.com/allanpk716/ChineseSubFinder/pkg/mix_media_info"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/pkg/notify_center"
 	"github.com/allanpk716/ChineseSubFinder/pkg/settings"
@@ -357,7 +358,7 @@ func (s *Supplier) getSubDetail(subID int) (OneSubDetail, error) {
 			notify_center.Notify.Add(s.GetSupplierName()+" NewHttpClient", fmt.Sprintf("subID: %d, resp: %s, error: %s", subID, resp.String(), err.Error()))
 
 			// 输出调试文件
-			cacheCenterFolder, err := my_folder.GetRootCacheCenterFolder()
+			cacheCenterFolder, err := pkg.GetRootCacheCenterFolder()
 			if err != nil {
 				s.log.Errorln(s.GetSupplierName(), "GetRootCacheCenterFolder", err)
 			}

+ 5 - 4
pkg/logic/sub_supplier/assrt/assrt_test.go

@@ -3,9 +3,10 @@ package assrt
 import (
 	"testing"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/file_downloader"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 
 	"github.com/allanpk716/ChineseSubFinder/pkg/cache_center"
@@ -21,9 +22,9 @@ func defInstance() {
 	my_util.ReadCustomAuthFile(log_helper.GetLogger4Tester())
 
 	authKey := random_auth_key.AuthKey{
-		BaseKey:  global_value.BaseKey(),
-		AESKey16: global_value.AESKey16(),
-		AESIv16:  global_value.AESIv16(),
+		BaseKey:  pkg.BaseKey(),
+		AESKey16: pkg.AESKey16(),
+		AESIv16:  pkg.AESIv16(),
 	}
 
 	assrtInstance = NewSupplier(file_downloader.NewFileDownloader(

+ 3 - 3
pkg/logic/sub_supplier/csf/csf.go

@@ -10,6 +10,8 @@ import (
 	"strings"
 	"time"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	common2 "github.com/allanpk716/ChineseSubFinder/pkg/types/common"
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/series"
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/subparser"
@@ -17,8 +19,6 @@ import (
 
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/file_downloader"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
-
 	"github.com/allanpk716/ChineseSubFinder/pkg/subtitle_best_api"
 
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
@@ -240,7 +240,7 @@ func (s *Supplier) findAndDownload(videoFPath string, isMovie bool, Season, Epis
 		bestOneSub = s.findBestSub(findSubReply.Subtitle)
 	}
 
-	tmpFolder, err := my_folder.GetRootTmpFolder()
+	tmpFolder, err := pkg.GetRootTmpFolder()
 	if err != nil {
 		return nil, errors.New(fmt.Sprintf("GetRootTmpFolder Error: %s", err.Error()))
 	}

+ 5 - 4
pkg/logic/sub_supplier/csf/csf_test.go

@@ -3,8 +3,9 @@ package csf
 import (
 	"testing"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/cache_center"
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/pkg/log_helper"
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/file_downloader"
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/series_helper"
@@ -70,9 +71,9 @@ func defInstance() {
 	my_util.ReadCustomAuthFile(log_helper.GetLogger4Tester())
 
 	authKey := random_auth_key.AuthKey{
-		BaseKey:  global_value.BaseKey(),
-		AESKey16: global_value.AESKey16(),
-		AESIv16:  global_value.AESIv16(),
+		BaseKey:  pkg.BaseKey(),
+		AESKey16: pkg.AESKey16(),
+		AESIv16:  pkg.AESIv16(),
 	}
 
 	nowSettings := settings.GetSettings()

+ 5 - 4
pkg/logic/sub_supplier/shooter/shooter_test.go

@@ -4,8 +4,9 @@ import (
 	"path/filepath"
 	"testing"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/cache_center"
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/pkg/log_helper"
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/file_downloader"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
@@ -18,9 +19,9 @@ func TestNewSupplier(t *testing.T) {
 
 	my_util.ReadCustomAuthFile(log_helper.GetLogger4Tester())
 	authKey := random_auth_key.AuthKey{
-		BaseKey:  global_value.BaseKey(),
-		AESKey16: global_value.AESKey16(),
-		AESIv16:  global_value.AESIv16(),
+		BaseKey:  pkg.BaseKey(),
+		AESKey16: pkg.AESKey16(),
+		AESIv16:  pkg.AESIv16(),
 	}
 
 	//movie1 := "X:\\电影\\The Devil All the Time (2020)\\The Devil All the Time (2020) WEBDL-1080p.mkv"

+ 4 - 3
pkg/logic/sub_supplier/subhd/subhd.go

@@ -13,6 +13,8 @@ import (
 	"strings"
 	"time"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/common"
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/language"
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/series"
@@ -26,7 +28,6 @@ import (
 	"github.com/PuerkitoBio/goquery"
 	"github.com/Tnze/go.num/v2/zh"
 	"github.com/allanpk716/ChineseSubFinder/pkg/decode"
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/pkg/notify_center"
 	"github.com/allanpk716/ChineseSubFinder/pkg/settings"
@@ -578,7 +579,7 @@ func (s *Supplier) downloadSubFile(browser *rod.Browser, page *rod.Page, subDown
 	fileName := ""
 	fileByte := []byte{0}
 	err = rod.Try(func() {
-		tmpDir := filepath.Join(global_value.DefTmpFolder(), "downloads")
+		tmpDir := filepath.Join(pkg.DefTmpFolder(), "downloads")
 		wait := browser.Timeout(30 * time.Second).WaitDownload(tmpDir)
 		getDownloadFile := func() ([]byte, string, error) {
 			info := wait()
@@ -783,7 +784,7 @@ search:
 
 	if s.debugMode == true {
 		//截圖保存
-		page.MustScreenshot(global_value.DefDebugFolder(), "result.png")
+		page.MustScreenshot(pkg.DefDebugFolder(), "result.png")
 	}
 }
 

+ 8 - 7
pkg/logic/sub_supplier/subhd/subhd_test.go

@@ -6,13 +6,14 @@ import (
 	"testing"
 	"time"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	commonValue "github.com/allanpk716/ChineseSubFinder/pkg/types/common"
 
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/file_downloader"
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/series_helper"
 
 	"github.com/allanpk716/ChineseSubFinder/pkg/cache_center"
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/pkg/log_helper"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/pkg/random_auth_key"
@@ -26,9 +27,9 @@ var authKey random_auth_key.AuthKey
 func defInstance() {
 	my_util.ReadCustomAuthFile(log_helper.GetLogger4Tester())
 	authKey = random_auth_key.AuthKey{
-		BaseKey:  global_value.BaseKey(),
-		AESKey16: global_value.AESKey16(),
-		AESIv16:  global_value.AESIv16(),
+		BaseKey:  pkg.BaseKey(),
+		AESKey16: pkg.AESKey16(),
+		AESIv16:  pkg.AESIv16(),
 	}
 }
 
@@ -130,9 +131,9 @@ func getCode() {
 	fileDownloader := file_downloader.NewFileDownloader(
 		cache_center.NewCacheCenter("local_task_queue", settings.GetSettings(), log_helper.GetLogger4Tester()),
 		random_auth_key.AuthKey{
-			BaseKey:  global_value.BaseKey(),
-			AESKey16: global_value.AESKey16(),
-			AESIv16:  global_value.AESIv16(),
+			BaseKey:  pkg.BaseKey(),
+			AESKey16: pkg.AESKey16(),
+			AESIv16:  pkg.AESIv16(),
 		})
 
 	nowTT := time.Now()

+ 5 - 4
pkg/logic/sub_supplier/xunlei/xunlei_test.go

@@ -4,10 +4,11 @@ import (
 	"path/filepath"
 	"testing"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/file_downloader"
 
 	"github.com/allanpk716/ChineseSubFinder/pkg/cache_center"
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/pkg/log_helper"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/pkg/random_auth_key"
@@ -59,9 +60,9 @@ func defInstance() {
 	my_util.ReadCustomAuthFile(log_helper.GetLogger4Tester())
 
 	authKey := random_auth_key.AuthKey{
-		BaseKey:  global_value.BaseKey(),
-		AESKey16: global_value.AESKey16(),
-		AESIv16:  global_value.AESIv16(),
+		BaseKey:  pkg.BaseKey(),
+		AESKey16: pkg.AESKey16(),
+		AESIv16:  pkg.AESIv16(),
 	}
 
 	xunleiInstance = NewSupplier(file_downloader.NewFileDownloader(

+ 3 - 2
pkg/logic/sub_supplier/zimuku/zimuku.go

@@ -11,6 +11,8 @@ import (
 	"strings"
 	"time"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/common"
 	language2 "github.com/allanpk716/ChineseSubFinder/pkg/types/language"
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/series"
@@ -23,7 +25,6 @@ import (
 	"github.com/PuerkitoBio/goquery"
 	"github.com/Tnze/go.num/v2/zh"
 	"github.com/allanpk716/ChineseSubFinder/pkg/decode"
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/pkg/language"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/pkg/notify_center"
@@ -701,7 +702,7 @@ func (s *Supplier) DownFile(browser *rod.Browser, subDownloadPageUrl string, Top
 	fileByte := []byte{0}
 	downloadSuccess := false
 	err = rod.Try(func() {
-		tmpDir := filepath.Join(global_value.DefTmpFolder(), "downloads")
+		tmpDir := filepath.Join(pkg.DefTmpFolder(), "downloads")
 		wait := browser.Timeout(30 * time.Second).WaitDownload(tmpDir)
 		getDownloadFile := func() ([]byte, string, error) {
 			info := wait()

+ 4 - 4
pkg/logic/sub_supplier/zimuku/zimuku_test.go

@@ -1,13 +1,13 @@
 package zimuku
 
 import (
+	"github.com/allanpk716/ChineseSubFinder/pkg"
 	"path/filepath"
 	"testing"
 
 	"github.com/allanpk716/ChineseSubFinder/pkg/rod_helper"
 
 	"github.com/allanpk716/ChineseSubFinder/pkg/cache_center"
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/pkg/log_helper"
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/file_downloader"
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/series_helper"
@@ -179,9 +179,9 @@ func defInstance() {
 	my_util.ReadCustomAuthFile(log_helper.GetLogger4Tester())
 
 	authKey := random_auth_key.AuthKey{
-		BaseKey:  global_value.BaseKey(),
-		AESKey16: global_value.AESKey16(),
-		AESIv16:  global_value.AESIv16(),
+		BaseKey:  pkg.BaseKey(),
+		AESKey16: pkg.AESKey16(),
+		AESIv16:  pkg.AESIv16(),
 	}
 
 	zimukuInstance = NewSupplier(file_downloader.NewFileDownloader(

+ 5 - 4
pkg/my_util/custom_file.go

@@ -5,7 +5,8 @@ import (
 	"strconv"
 	"strings"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/sirupsen/logrus"
 )
 
@@ -49,9 +50,9 @@ func ReadCustomAuthFile(log *logrus.Logger) bool {
 			return false
 		}
 
-		global_value.SetBaseKey(authStings[0])
-		global_value.SetAESKey16(authStings[1])
-		global_value.SetAESIv16(authStings[2])
+		pkg.SetBaseKey(authStings[0])
+		pkg.SetAESKey16(authStings[1])
+		pkg.SetAESIv16(authStings[2])
 
 		log.Infoln("Use CustomAuth")
 		return true

+ 6 - 6
pkg/rod_helper/rod_base.go

@@ -12,10 +12,10 @@ import (
 	"sync"
 	"time"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/regex_things"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/pkg/random_useragent"
 	"github.com/allanpk716/ChineseSubFinder/pkg/settings"
@@ -63,7 +63,7 @@ func NewBrowserBase(log *logrus.Logger, localChromeFPath, httpProxyURL string, l
 	})
 
 	// 随机的 rod 子文件夹名称
-	nowUserData := filepath.Join(global_value.DefRodTmpRootFolder(), my_util.RandStringBytesMaskImprSrcSB(20))
+	nowUserData := filepath.Join(pkg.DefRodTmpRootFolder(), my_util.RandStringBytesMaskImprSrcSB(20))
 	var browser *rod.Browser
 
 	if localChromeFPath != "" {
@@ -435,7 +435,7 @@ func ReloadBrowser(log *logrus.Logger) {
 
 // Clear 清理缓存
 func Clear(log *logrus.Logger) {
-	err := my_folder.ClearRodTmpRootFolder()
+	err := pkg.ClearRodTmpRootFolder()
 	if err != nil {
 		log.Errorln("ClearRodTmpRootFolder", err)
 		return
@@ -461,14 +461,14 @@ func releaseAdblock(log *logrus.Logger) (string, error) {
 
 	log.Infoln("releaseAdblock start")
 
-	adblockFolderPath := global_value.AdblockTmpFolder()
+	adblockFolderPath := pkg.AdblockTmpFolder()
 	err := os.MkdirAll(filepath.Join(adblockFolderPath), os.ModePerm)
 	if err != nil {
 		return "", err
 	}
 	desPath := filepath.Join(adblockFolderPath, "RunAdblock")
 	// 清理之前缓存的信息
-	_ = my_folder.ClearFolder(desPath)
+	_ = pkg.ClearFolder(desPath)
 	// 具体把 adblock zip 解压下载到哪里
 	outZipFileFPath := filepath.Join(adblockFolderPath, "adblock.zip")
 	adblockZipFile, err := os.Create(outZipFileFPath)

+ 2 - 2
pkg/settings/settings.go

@@ -1,13 +1,13 @@
 package settings
 
 import (
+	"github.com/allanpk716/ChineseSubFinder/pkg"
 	"net/url"
 	"os"
 	"path/filepath"
 	"strings"
 	"sync"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/pkg/strcut_json"
 	"github.com/huandu/go-clone"
 )
@@ -71,7 +71,7 @@ func SetFullNewSettings(inSettings *Settings) error {
 
 func NewSettings() *Settings {
 
-	nowConfigFPath := filepath.Join(global_value.ConfigRootDirFPath(), configName)
+	nowConfigFPath := filepath.Join(pkg.ConfigRootDirFPath(), configName)
 
 	return &Settings{
 		configFPath:           nowConfigFPath,

+ 4 - 3
pkg/sub_helper/sub_helper.go

@@ -9,6 +9,8 @@ import (
 	"strings"
 	"time"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/common"
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/subparser"
 	"github.com/allanpk716/ChineseSubFinder/pkg/types/supplier"
@@ -17,7 +19,6 @@ import (
 	"github.com/allanpk716/ChineseSubFinder/pkg/decode"
 	"github.com/allanpk716/ChineseSubFinder/pkg/filter"
 	"github.com/allanpk716/ChineseSubFinder/pkg/language"
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/pkg/regex_things"
 	"github.com/allanpk716/ChineseSubFinder/pkg/sub_parser_hub"
@@ -31,7 +32,7 @@ func OrganizeDlSubFiles(log *logrus.Logger, tmpFolderName string, subInfos []sup
 	// 缓存列表,整理后的字幕列表
 	// SxEx - []string 字幕的路径
 	var siteSubInfoDict = make(map[string][]string)
-	tmpFolderFullPath, err := my_folder.GetTmpFolderByName(tmpFolderName)
+	tmpFolderFullPath, err := pkg.GetTmpFolderByName(tmpFolderName)
 	if err != nil {
 		return nil, err
 	}
@@ -369,7 +370,7 @@ func SearchVideoMatchSubFileAndRemoveExtMark(l *logrus.Logger, oneVideoFullPath
 // DeleteOneSeasonSubCacheFolder 删除一个连续剧中的所有一季字幕的缓存文件夹
 func DeleteOneSeasonSubCacheFolder(seriesDir string) error {
 
-	debugFolderByName, err := my_folder.GetDebugFolderByName([]string{filepath.Base(seriesDir)})
+	debugFolderByName, err := pkg.GetDebugFolderByName([]string{filepath.Base(seriesDir)})
 	if err != nil {
 		return err
 	}

+ 3 - 3
pkg/sub_helper/sub_helper_test.go

@@ -2,13 +2,13 @@ package sub_helper
 
 import (
 	"fmt"
+	"github.com/allanpk716/ChineseSubFinder/pkg"
 	"path/filepath"
 	"testing"
 
 	"github.com/allanpk716/ChineseSubFinder/pkg/log_helper"
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/sub_parser/ass"
 	"github.com/allanpk716/ChineseSubFinder/pkg/logic/sub_parser/srt"
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/pkg/sub_parser_hub"
 	"github.com/allanpk716/ChineseSubFinder/pkg/unit_test_helper"
@@ -18,11 +18,11 @@ func TestDeleteOneSeasonSubCacheFolder(t *testing.T) {
 	const testSerName = "XXX"
 	const needDelFolderName = "Sub_S1E0"
 	testRootDir := unit_test_helper.GetTestDataResourceRootPath([]string{"sub_helper", "org", needDelFolderName}, 4, false)
-	desSerFullPath, err := my_folder.GetDebugFolderByName([]string{testSerName})
+	desSerFullPath, err := pkg.GetDebugFolderByName([]string{testSerName})
 	if err != nil {
 		t.Fatal(err)
 	}
-	desSeasonFullPath, err := my_folder.GetDebugFolderByName([]string{testSerName, filepath.Base(testRootDir)})
+	desSeasonFullPath, err := pkg.GetDebugFolderByName([]string{testSerName, filepath.Base(testRootDir)})
 	if err != nil {
 		t.Fatal(err)
 	}

+ 3 - 2
pkg/sub_share_center/share_sub_cache_helper.go

@@ -4,7 +4,8 @@ import (
 	"os"
 	"path/filepath"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/sirupsen/logrus"
 )
@@ -12,7 +13,7 @@ import (
 // CopySub2Cache 检测原有字幕是否存在,然后放到缓存目录中
 func CopySub2Cache(log *logrus.Logger, orgSubFileFPath, imdbID string, year int, lowTrust bool) (bool, string) {
 
-	nowFolderDir, err := my_folder.GetShareFolderByYear(year)
+	nowFolderDir, err := pkg.GetShareFolderByYear(year)
 	if err != nil {
 		log.Errorln("CheckOrgSubFileExistAndCopy2Cache.GetShareFolderByYear", err)
 		return false, ""

+ 2 - 2
pkg/subtitle_best_api/subtitle_best_api.go

@@ -12,7 +12,7 @@ import (
 	"strconv"
 	"time"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
+	"github.com/allanpk716/ChineseSubFinder/pkg"
 
 	"github.com/allanpk716/ChineseSubFinder/pkg/common"
 
@@ -715,7 +715,7 @@ func (s *SubtitleBestApi) AskDownloadTask(id string) (*AskDownloadTaskReply, err
 		return nil, err
 	}
 
-	major, minor, patch := global_value.AppVersionInt()
+	major, minor, patch := pkg.AppVersionInt()
 	var askDownloadTaskReply AskDownloadTaskReply
 	resp, err := httpClient.R().
 		SetHeader("Authorization", "beer "+authKey).

+ 5 - 4
pkg/subtitle_best_api/subtitle_best_api_test.go

@@ -3,9 +3,10 @@ package subtitle_best_api
 import (
 	"testing"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/settings"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/pkg/log_helper"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 
@@ -18,9 +19,9 @@ func TestSubtitleBestApi_GetMediaInfo(t *testing.T) {
 	bapi := NewSubtitleBestApi(
 		log_helper.GetLogger4Tester(),
 		random_auth_key.AuthKey{
-			BaseKey:  global_value.BaseKey(),
-			AESKey16: global_value.AESKey16(),
-			AESIv16:  global_value.AESIv16(),
+			BaseKey:  pkg.BaseKey(),
+			AESKey16: pkg.AESKey16(),
+			AESIv16:  pkg.AESIv16(),
 		}, settings.GetSettings().AdvancedSettings.ProxySettings)
 
 	downloadTaskReply, err := bapi.AskDownloadTask("123")

+ 3 - 2
pkg/task_control/task_control_test.go

@@ -7,7 +7,8 @@ import (
 	"testing"
 	"time"
 
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/log_helper"
 	"github.com/sirupsen/logrus"
 	"golang.org/x/net/context"
@@ -268,7 +269,7 @@ func process(name string, timeTester TimeTester) ([]int, []int, []int, error) {
 
 	once := sync.Once{}
 
-	tc, err := NewTaskControl(timeTester.ConcurrentCount, log_helper.NewLogHelper(name, global_value.ConfigRootDirFPath(), logrus.DebugLevel, time.Duration(7*24)*time.Hour, time.Duration(24)*time.Hour))
+	tc, err := NewTaskControl(timeTester.ConcurrentCount, log_helper.NewLogHelper(name, pkg.ConfigRootDirFPath(), logrus.DebugLevel, time.Duration(7*24)*time.Hour, time.Duration(24)*time.Hour))
 	if err != nil {
 		return nil, nil, nil, err
 	}

+ 6 - 5
pkg/task_queue/task_queue.go

@@ -3,16 +3,17 @@ package task_queue
 import (
 	"encoding/json"
 	"errors"
-	"github.com/allanpk716/ChineseSubFinder/pkg/types/common"
-	"github.com/allanpk716/ChineseSubFinder/pkg/types/emby"
-	task_queue2 "github.com/allanpk716/ChineseSubFinder/pkg/types/task_queue"
 	"os"
 	"path/filepath"
 	"sync"
 	"time"
 
+	"github.com/allanpk716/ChineseSubFinder/pkg"
+	"github.com/allanpk716/ChineseSubFinder/pkg/types/common"
+	"github.com/allanpk716/ChineseSubFinder/pkg/types/emby"
+	task_queue2 "github.com/allanpk716/ChineseSubFinder/pkg/types/task_queue"
+
 	"github.com/allanpk716/ChineseSubFinder/pkg/cache_center"
-	"github.com/allanpk716/ChineseSubFinder/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/pkg/settings"
 	"github.com/emirpasic/gods/maps/treemap"
@@ -289,7 +290,7 @@ func (t *TaskQueue) del(jobId string) (bool, error) {
 		return false, err
 	}
 	// 删除任务的时候也需要删除对应的日志
-	pathRoot := filepath.Join(global_value.ConfigRootDirFPath(), "Logs")
+	pathRoot := filepath.Join(pkg.ConfigRootDirFPath(), "Logs")
 	fileFPath := filepath.Join(pathRoot, common.OnceLogPrefix+jobId+".log")
 	if my_util.IsFile(fileFPath) == true {
 		err = os.Remove(fileFPath)

+ 74 - 0
pkg/video_list_helper/video_list_helper.go

@@ -0,0 +1,74 @@
+package video_list_helper
+
+import (
+	"sync"
+
+	"github.com/allanpk716/ChineseSubFinder/pkg/settings"
+	vsh "github.com/allanpk716/ChineseSubFinder/pkg/video_scan_and_refresh_helper"
+
+	seriesHelper "github.com/allanpk716/ChineseSubFinder/pkg/logic/series_helper"
+	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
+	"github.com/sirupsen/logrus"
+)
+
+type VideoListHelper struct {
+	settings *settings.Settings // 设置的实例
+	log      *logrus.Logger     // 日志实例
+}
+
+// RefreshMainList 获取到电影、连续剧一级目录信息,不包含 Season 及其以下信息
+// 只给出 Movie 的FullPath,Series 的 RootDirPath
+func (v *VideoListHelper) RefreshMainList() (*vsh.NormalScanVideoResult, error) {
+
+	defer func() {
+		v.log.Infoln("ScanNormalMovieAndSeries End")
+	}()
+	v.log.Infoln("ScanNormalMovieAndSeries Start...")
+
+	// ------------------------------------------------------------------------------
+	// 由于需要进行视频信息的缓存,用于后续的逻辑,那么本地视频的扫描默认都会进行
+	normalScanResult := vsh.NormalScanVideoResult{}
+	// 直接由本程序自己去扫描视频视频有哪些
+	// 全扫描
+	wg := sync.WaitGroup{}
+	var errMovie, errSeries error
+	wg.Add(1)
+	go func() {
+		defer func() {
+			wg.Done()
+		}()
+		// --------------------------------------------------
+		// 电影
+		normalScanResult.MoviesDirMap, errMovie = my_util.SearchMatchedVideoFileFromDirs(v.log, v.settings.CommonSettings.MoviePaths)
+	}()
+	wg.Add(1)
+	go func() {
+
+		defer func() {
+			wg.Done()
+		}()
+		// --------------------------------------------------
+		// 连续剧
+		// 遍历连续剧总目录下的第一层目录
+		normalScanResult.SeriesDirMap, errSeries = seriesHelper.GetSeriesListFromDirs(v.log, v.settings.CommonSettings.SeriesPaths)
+		// ------------------------------------------------------------------------------
+		// 输出调试信息,有那些连续剧文件夹名称
+		if normalScanResult.SeriesDirMap == nil {
+			return
+		}
+		normalScanResult.SeriesDirMap.Each(func(key interface{}, value interface{}) {
+			for i, s := range value.([]string) {
+				v.log.Debugln("embyHelper == nil GetSeriesList", i, s)
+			}
+		})
+	}()
+	wg.Wait()
+	if errMovie != nil {
+		return nil, errMovie
+	}
+	if errSeries != nil {
+		return nil, errSeries
+	}
+
+	return &normalScanResult, nil
+}

+ 2 - 2
pkg/video_scan_and_refresh_helper/video_scan_and_refresh_helper.go

@@ -1,6 +1,7 @@
 package video_scan_and_refresh_helper
 
 import (
+	"github.com/allanpk716/ChineseSubFinder/pkg"
 	"path/filepath"
 	"strings"
 	"sync"
@@ -31,7 +32,6 @@ import (
 	"github.com/allanpk716/ChineseSubFinder/pkg/imdb_helper"
 	"github.com/allanpk716/ChineseSubFinder/pkg/language"
 	"github.com/allanpk716/ChineseSubFinder/pkg/mix_media_info"
-	"github.com/allanpk716/ChineseSubFinder/pkg/my_folder"
 	"github.com/allanpk716/ChineseSubFinder/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/pkg/settings"
 	"github.com/allanpk716/ChineseSubFinder/pkg/sort_things"
@@ -331,7 +331,7 @@ func (v *VideoScanAndRefreshHelper) scanLowVideoSubInfo(scanVideoResult *ScanVid
 		return
 	}
 
-	shareRootDir, err := my_folder.GetShareSubRootFolder()
+	shareRootDir, err := pkg.GetShareSubRootFolder()
 	if err != nil {
 		v.log.Errorln("scanLowVideoSubInfo.GetShareSubRootFolder", err)
 		return