-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
57 lines (55 loc) · 1.48 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"embyRenamer/renamer"
"encoding/json"
"fmt"
"os"
"strings"
"time"
)
func main() {
println("运行中,请勿终止程序...")
startTime := time.Now().UnixNano() / 1e6
var config *renamer.Config
if b, err := os.ReadFile("config.json"); err == nil && len(b) > 0 {
err = json.Unmarshal(b, &config)
if err == nil {
renamer.LoadConfig(config)
}
}
if config == nil {
panic("无法获取正确的配置")
}
if err := config.Check(); err != nil {
panic(err)
}
if config.MovieRename && config.MovieDirPath != "" {
// 电影
if clients, err := renamer.DeepScan(strings.TrimRight(config.MovieRootPath, string(os.PathSeparator)), strings.TrimRight(config.MovieDirPath, string(os.PathSeparator)), -1); err == nil {
for _, client := range clients {
client.Rename()
}
} else {
panic(err)
}
}
if config.TvRename && config.TvDirPath != "" {
// 电视剧
if clients, err := renamer.DeepScan(strings.TrimRight(config.TvRootPath, string(os.PathSeparator)), strings.TrimRight(config.TvDirPath, string(os.PathSeparator)), -1); err == nil {
for _, client := range clients {
client.Rename()
}
} else {
panic(err)
}
}
endTime := time.Now().UnixNano() / 1e6
if invalidNfoPath := renamer.InvalidNfoPath(); len(invalidNfoPath) > 0 {
println("无法识别的nfo文件列表:\r\n")
for path := range invalidNfoPath {
println(" ", path)
}
}
println()
fmt.Printf("转换完毕,总花费时间:%dms\r\n", endTime-startTime)
}