-
Notifications
You must be signed in to change notification settings - Fork 432
Expand file tree
/
Copy pathconfig.py
More file actions
117 lines (90 loc) · 3.93 KB
/
config.py
File metadata and controls
117 lines (90 loc) · 3.93 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
from os.path import expandvars
from typing import Literal
from pydantic import BaseModel, Field, validator
class Program(BaseModel):
rss_time: int = Field(900, description="Sleep time")
rename_time: int = Field(60, description="Rename times in one loop")
webui_port: int = Field(7892, description="WebUI port")
class Downloader(BaseModel):
type: str = Field("qbittorrent", description="Downloader type")
host_: str = Field("172.17.0.1:8080", alias="host", description="Downloader host")
username_: str = Field("admin", alias="username", description="Downloader username")
password_: str = Field(
"adminadmin", alias="password", description="Downloader password"
)
path: str = Field("/downloads/Bangumi", description="Downloader path")
ssl: bool = Field(False, description="Downloader ssl")
@property
def host(self):
return expandvars(self.host_)
@property
def username(self):
return expandvars(self.username_)
@property
def password(self):
return expandvars(self.password_)
class RSSParser(BaseModel):
enable: bool = Field(True, description="Enable RSS parser")
filter: list[str] = Field(["720", r"\d+-\d"], description="Filter")
language: str = "zh"
class BangumiManage(BaseModel):
enable: bool = Field(True, description="Enable bangumi manage")
eps_complete: bool = Field(False, description="Enable eps complete")
rename_method: str = Field("pn", description="Rename method")
group_tag: bool = Field(False, description="Enable group tag")
remove_bad_torrent: bool = Field(False, description="Remove bad torrent")
class Log(BaseModel):
debug_enable: bool = Field(False, description="Enable debug")
class Proxy(BaseModel):
enable: bool = Field(False, description="Enable proxy")
type: str = Field("http", description="Proxy type")
host: str = Field("", description="Proxy host")
port: int = Field(0, description="Proxy port")
username_: str = Field("", alias="username", description="Proxy username")
password_: str = Field("", alias="password", description="Proxy password")
@property
def username(self):
return expandvars(self.username_)
@property
def password(self):
return expandvars(self.password_)
class Notification(BaseModel):
enable: bool = Field(False, description="Enable notification")
entry_: str = Field("", alias="entry", description="Notification entry(check https://github.com/caronc/apprise/wiki for details)")
@property
def entry(self):
return expandvars(self.entry_)
class ExperimentalOpenAI(BaseModel):
enable: bool = Field(False, description="Enable experimental OpenAI")
api_key: str = Field("", description="OpenAI api key")
api_base: str = Field(
"https://api.openai.com/v1", description="OpenAI api base url"
)
api_type: Literal["azure", "openai"] = Field(
"openai", description="OpenAI api type, usually for azure"
)
api_version: str = Field(
"2023-05-15", description="OpenAI api version, only for Azure"
)
model: str = Field(
"gpt-3.5-turbo", description="OpenAI model, ignored when api type is azure"
)
deployment_id: str = Field(
"", description="Azure OpenAI deployment id, ignored when api type is openai"
)
@validator("api_base")
def validate_api_base(cls, value: str):
if value == "https://api.openai.com/":
return "https://api.openai.com/v1"
return value
class Config(BaseModel):
program: Program = Program()
downloader: Downloader = Downloader()
rss_parser: RSSParser = RSSParser()
bangumi_manage: BangumiManage = BangumiManage()
log: Log = Log()
proxy: Proxy = Proxy()
notification: Notification = Notification()
experimental_openai: ExperimentalOpenAI = ExperimentalOpenAI()
def dict(self, *args, by_alias=True, **kwargs):
return super().dict(*args, by_alias=by_alias, **kwargs)