Skip to content

Commit fd76ea5

Browse files
committed
v0.8.0
- 完善单测用例
1 parent 140b2bb commit fd76ea5

File tree

68 files changed

+6549
-678
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+6549
-678
lines changed

.github/workflows/test.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Go Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
- 'feature-*'
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Set up Go
17+
uses: actions/setup-go@v2
18+
with:
19+
go-version: 1.19
20+
- name: Run tests
21+
run: go test ./...

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
./AnimeGo
3131
```
3232

33-
### 1.1 升级后启动:升级配置、释放资源
33+
### 1.1 升级后首次启动:升级配置、释放资源
3434
```shell
3535
./AnimeGo
3636
```
@@ -93,6 +93,14 @@
9393

9494
## 开发日志
9595

96+
### v0.8.0
97+
- 支持feed订阅插件,可以自行解析rss
98+
- 支持在配置文件中设置插件变量、参数
99+
- 支持内置插件
100+
- 更改插件源码结构
101+
- 补充插件文档
102+
- 补充单测用例
103+
96104
### v0.7.4
97105
- 内部统一使用unix风格路径
98106
- 修复python插件中int类型错误

assets/plugin/feed/mikan_rss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# 每分钟第10秒执行
77
__cron__ = "10 0/1 * * * ?"
88

9-
__url__ = "https://mikanani.me/RSS/Bangumi?bangumiId=228&subgroupid=1"
9+
__url__ = "https://mikanani.me/RSS/Bangumi?bangumiId=2822&subgroupid=370"
1010

1111
def parse(args):
1212
log.info(len(args['data']))

configs/config_test.go

Lines changed: 6 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,24 @@ package configs_test
22

33
import (
44
"bytes"
5-
"fmt"
65
"github.com/wetor/AnimeGo/pkg/utils"
76
"os"
87
"testing"
98

10-
"github.com/jinzhu/copier"
11-
129
"github.com/wetor/AnimeGo/configs"
13-
"github.com/wetor/AnimeGo/internal/models"
1410
)
1511

16-
func TestDefaultConfig(t *testing.T) {
12+
func TestMain(m *testing.M) {
1713
_ = utils.CreateMutiDir("data")
18-
_ = configs.DefaultFile("data/animego_default.yaml")
14+
m.Run()
15+
_ = os.RemoveAll("data")
1916
}
2017

21-
func TestCopy(t *testing.T) {
22-
type s1 struct {
23-
A int
24-
B struct {
25-
C string
26-
D bool
27-
}
28-
}
29-
30-
type s2 struct {
31-
C string
32-
B struct {
33-
A int
34-
D bool
35-
E string
36-
}
37-
}
38-
39-
ss1 := s1{
40-
A: 10,
41-
B: struct {
42-
C string
43-
D bool
44-
}{C: "测试", D: true},
45-
}
46-
47-
ss2 := s2{}
48-
err := copier.Copy(&ss2, &ss1)
49-
if err != nil {
50-
panic(err)
51-
}
52-
fmt.Println(ss1)
53-
fmt.Println(ss2)
18+
func TestDefaultConfig(t *testing.T) {
19+
_ = configs.DefaultFile("data/animego_default.yaml")
5420
}
5521

5622
func TestUpdateConfig_120(t *testing.T) {
57-
_ = utils.CreateMutiDir("data")
5823
configs.ConfigVersion = "1.2.0"
5924
file, _ := os.ReadFile("testdata/animego_110.yaml")
6025
_ = os.WriteFile("data/animego.yaml", file, 0666)
@@ -65,13 +30,11 @@ func TestUpdateConfig_120(t *testing.T) {
6530
if !bytes.Equal(got, want) {
6631
t.Errorf("UpdateConfig() = %s, want %s", got, want)
6732
}
68-
_ = os.Remove("data/animego.yaml")
6933
}
7034

7135
func TestUpdateConfig_130(t *testing.T) {
72-
_ = utils.CreateMutiDir("data")
7336
configs.ConfigVersion = "1.3.0"
74-
file, _ := os.ReadFile("testdata/animego_120_2.yaml")
37+
file, _ := os.ReadFile("testdata/animego_120.yaml")
7538
_ = os.WriteFile("data/animego.yaml", file, 0666)
7639
configs.UpdateConfig("data/animego.yaml", false)
7740

@@ -80,11 +43,9 @@ func TestUpdateConfig_130(t *testing.T) {
8043
if !bytes.Equal(got, want) {
8144
t.Errorf("UpdateConfig() = %s, want %s", got, want)
8245
}
83-
_ = os.Remove("data/animego.yaml")
8446
}
8547

8648
func TestUpdateConfig_140(t *testing.T) {
87-
_ = utils.CreateMutiDir("data")
8849
configs.ConfigVersion = "1.4.0"
8950
file, _ := os.ReadFile("testdata/animego_130.yaml")
9051
_ = os.WriteFile("data/animego.yaml", file, 0666)
@@ -95,56 +56,4 @@ func TestUpdateConfig_140(t *testing.T) {
9556
if !bytes.Equal(got, want) {
9657
t.Errorf("UpdateConfig() = %s, want %s", got, want)
9758
}
98-
//_ = os.Remove("data/animego.yaml")
99-
}
100-
101-
func TestConvertPluginInfo(t *testing.T) {
102-
103-
plugins := configs.ConvertPluginInfo([]configs.PluginInfo{
104-
{
105-
Enable: true,
106-
Type: "python",
107-
File: "/aaa",
108-
Args: map[string]any{
109-
"Cron": "1111",
110-
"Retry": 77,
111-
},
112-
},
113-
{
114-
Enable: true,
115-
Type: "python",
116-
File: "/aaa",
117-
Args: map[string]any{
118-
"Cron": "777888",
119-
"Retry": 13,
120-
},
121-
},
122-
})
123-
fmt.Println(plugins)
124-
}
125-
126-
func TestCopy1(t *testing.T) {
127-
plugins := []*configs.PluginInfo{
128-
{
129-
Enable: true,
130-
Type: "python",
131-
File: "/aaa",
132-
Args: map[string]any{
133-
"Cron": "1111",
134-
"Retry": 77,
135-
},
136-
},
137-
{
138-
Enable: true,
139-
Type: "python",
140-
File: "/aaa",
141-
Args: map[string]any{
142-
"Cron": "777888",
143-
"Retry": 13,
144-
},
145-
},
146-
}
147-
dst := make([]*models.Plugin, len(plugins))
148-
copier.Copy(&dst, &plugins)
149-
fmt.Println(dst)
15059
}

configs/testdata/animego_110.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ setting:
2121
# 密码
2222
password: adminadmin
2323
# 下载文件夹. 下载器的下载文件夹
24-
download_path: /Users/wetor/GoProjects/AnimeGo/download/incomplete
24+
download_path: download/incomplete
2525
# 保存文件夹. 下载完成后,重命名并移动到的文件夹
26-
save_path: /Users/wetor/GoProjects/AnimeGo/download/anime
26+
save_path: download/anime
2727
# 数据文件夹. 用于保存数据库、插件等数据
28-
data_path: /Users/wetor/GoProjects/AnimeGo/data
28+
data_path: data
2929
# 过滤器设置. 用来筛选符合条件的项目进行解析下载
3030
filter:
3131
# JavaScript插件. js插件的文件名列表,依次执行。路径相对于data_path
@@ -34,6 +34,7 @@ setting:
3434
javascript:
3535
- plugin/filter/default.js
3636
- plugin/filter/regexp.js
37+
- filter/mikan_tool.py
3738
# 分类名. 仅qBittorrent有效
3839
category: AnimeGo
3940
# 标签表达式. 仅qBittorrent有效,可用通配符列表:

configs/testdata/animego_120.yaml

Lines changed: 8 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,134 +1,75 @@
1-
# 配置文件版本
21
version: 1.2.0
3-
# 常规设置
42
setting:
5-
# 自动订阅设置
63
feed:
7-
# Mikan订阅
84
mikan:
9-
# 别名
105
name: Mikan
11-
# 订阅链接. 可空,为空则不使用自动订阅
126
url: ""
13-
# 下载客户端设置
147
client:
15-
# qBittorrent客户端
168
qbittorrent:
17-
# 地址
189
url: http://127.0.0.1:8080
19-
# 用户名
2010
username: admin
21-
# 密码
2211
password: adminadmin
23-
# 下载文件夹. 下载器的下载文件夹
24-
download_path: /Users/wetor/GoProjects/AnimeGo/download/incomplete
25-
# 保存文件夹. 下载完成后,重命名并移动到的文件夹
26-
save_path: /Users/wetor/GoProjects/AnimeGo/download/anime
27-
# 数据文件夹. 用于保存数据库、插件等数据
28-
data_path: /Users/wetor/GoProjects/AnimeGo/data
29-
# 过滤器设置. 用来筛选符合条件的项目进行解析下载
12+
download_path: download/incomplete
13+
save_path: download/anime
14+
data_path: data
3015
filter:
31-
# 插件
3216
plugin:
3317
- enable: true
3418
type: js
3519
file: filter/default.js
3620
- enable: true
3721
type: js
3822
file: filter/regexp.js
39-
# 分类名. 仅qBittorrent有效
23+
- enable: true
24+
type: py
25+
file: filter/mikan_tool.py
4026
category: AnimeGo
41-
# 标签表达式. 仅qBittorrent有效,可用通配符列表:
42-
# {year} int 番剧更新年
43-
# {quarter} int 番剧季度月号,取值为[4, 7, 10, 1]分别对应[春, 夏, 秋, 冬]季番剧
44-
# {quarter_index} int 番剧季度序号,取值为[1, 2, 3, 4]分别对应春(4月)、夏(7月)、秋(10月)、冬(1月)季番剧
45-
# {quarter_name} string 番剧季度名,取值为[春, 夏, 秋, 冬]
46-
# {ep} int 番剧当前剧集序号,从1开始
47-
# {week} int 番剧更新星期数,取值为[1, 2, 3, 4, 5, 6, 7]
48-
# {week_name} string 番剧更新星期名,取值为[星期一, 星期二, 星期三, 星期四, 星期五, 星期六, 星期日]
4927
tag: '{year}年{quarter}月新番'
50-
# WebApi设置
5128
webapi:
52-
# 请求秘钥. 为空则不需要验证
5329
access_key: animego123
54-
# 域名
5530
host: localhost
56-
# 端口
5731
port: 7991
58-
# 代理设置. 开启后AnimeGo所有的网络请求都会使用代理
5932
proxy:
60-
# 启用
6133
enable: true
62-
# 代理链接
6334
url: http://127.0.0.1:7890
64-
# 秘钥设置
6535
key:
66-
# TheMovieDB的APIkey. 可以自行申请链接(需注册):https://www.themoviedb.org/settings/api?language=zh-CN
67-
# 以下为wetor的个人APIkey,仅用于AnimeGo使用
6836
themoviedb: d3d8430aefee6c19520d0f7da145daf5
69-
# 高级设置
7037
advanced:
71-
# 更新状态等待时间. 每隔这一段时间,都会更新一次下载进度、清空下载队列(添加到下载项)
38+
# 每隔这一段时间,都会更新一次下载进度、清空下载队列(添加到下载项)
7239
# 等待过程是异步的,等待期间不影响操作
7340
# 在下载项较多、等待时间过少时会出现请求超时,所以有个最小等待时间为2秒的限制
7441
# 默认为10,最小值为2
7542
update_delay_second: 10
76-
# 网络请求设置
7743
request:
78-
# 请求超时时间
7944
timeout_second: 5
80-
# 额外重试次数
8145
retry_num: 3
82-
# 重试间隔等待时间
8346
retry_wait_second: 5
84-
# 下载设置
8547
download:
86-
# 允许重复下载
8748
allow_duplicate_download: false
88-
# 做种时间
8949
seeding_time_minute: 1
90-
# 忽略小文件大小
9150
ignore_size_max_kb: 1024
92-
# 重命名方式. 下载状态顺序为: 创建下载项->下载->下载完成->做种->做种完成
51+
# 下载状态顺序为: 创建下载项->下载->下载完成->做种->做种完成
9352
# 可选值为: ['link', 'link_delete', 'move', 'wait_move']
9453
# link: 使用硬链接方式,下载完成后触发。不影响做种
9554
# link_delete: 使用硬链接方式,下载完成后触发。不影响做种,做种完成后删除原文件
9655
# move: 使用移动方式,下载完成后触发。无法做种
9756
# wait_move: 使用移动方式,做种完成后触发
9857
rename: link_delete
99-
# 订阅设置
10058
feed:
101-
# 订阅刷新时间
10259
update_delay_minute: 15
103-
# 订阅解析间隔时间
10460
delay_second: 2
105-
# 订阅多协程解析
10661
multi_goroutine:
107-
# 启用
10862
enable: false
109-
# 最大协程数量
11063
goroutine_max: 4
111-
# 解析季度默认值. 使用tmdb解析季度失败时,同类型默认值按优先级执行。数值越大,优先级越高
11264
default:
113-
# 跳过当前项. tmdb解析季度失败时,跳过当前项。优先级3
11465
tmdb_fail_skip: false
115-
# 文件名解析季度. tmdb解析季度失败时,从文件名中获取季度信息。优先级2
11666
tmdb_fail_use_title_season: true
117-
# 使用第一季. tmdb解析季度失败时,默认使用第一季。优先级1
11867
tmdb_fail_use_first_season: true
119-
# 下载客户端设置
12068
client:
121-
# 连接超时时间
12269
connect_timeout_second: 5
123-
# 连接失败重试次数
12470
retry_connect_num: 10
125-
# 检查连接状态间隔时间
12671
check_time_second: 30
127-
# 缓存设置
12872
cache:
129-
# Mikan缓存时间. 默认7*24小时(7天)。主要为mikan-id与bangumi-id的映射关系
13073
mikan_cache_hour: 168
131-
# Bangumi缓存时间. 默认3*24小时(3天)。主要为bangumi-id与详细信息的映射
13274
bangumi_cache_hour: 72
133-
# Themoviedb缓存时间. 默认14*24小时(14天)。主要为tmdb-id与季度信息的映射
13475
themoviedb_cache_hour: 336

0 commit comments

Comments
 (0)