Skip to content

Commit

Permalink
v1.9.11
Browse files Browse the repository at this point in the history
- 支持环境变量配置DOH域名和DNS服务器
- 问题修复
  • Loading branch information
jxxghp committed Jul 9, 2024
1 parent 23fe643 commit 52d0703
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions app/chain/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def post_download_message(self, meta: MetaBase, mediainfo: MediaInfo, torrent: T
msg_text = f"{msg_text}\n促销:{torrent.volume_factor}"
if torrent.hit_and_run:
msg_text = f"{msg_text}\nHit&Run:是"
if torrent.labels:
msg_text = f"{msg_text}\n标签:{' '.join(torrent.labels)}"
if torrent.description:
html_re = re.compile(r'<[^>]+>', re.S)
description = html_re.sub('', torrent.description)
Expand Down
8 changes: 4 additions & 4 deletions app/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class Settings(BaseSettings):
# Github token,提高请求api限流阈值 ghp_****
GITHUB_TOKEN: Optional[str] = None
# 指定的仓库Github token,多个仓库使用,分隔,格式:{user1}/{repo1}:ghp_****,{user2}/{repo2}:github_pat_****
GITHUB_TOKEN_FOR_REPO: Optional[str] = None
REPO_GITHUB_TOKEN: Optional[str] = None
# Github代理服务器,格式:https://mirror.ghproxy.com/
GITHUB_PROXY: Optional[str] = ''
# 自动检查和更新站点资源包(站点索引、认证等)
Expand Down Expand Up @@ -364,18 +364,18 @@ def GITHUB_HEADERS(self):
}
return {}

def GITHUB_HEADERS_FOR_REPO(self, repo: str = None):
def REPO_GITHUB_HEADERS(self, repo: str = None):
"""
Github指定的仓库请求头
:param repo: 指定的仓库名称,格式为 "user/repo"。如果为空,或者没有找到指定仓库请求头,则返回默认的请求头信息
:return: Github请求头
"""
# 如果没有传入指定的仓库名称,或没有配置指定的仓库Token,则返回默认的请求头信息
if not repo or not self.GITHUB_TOKEN_FOR_REPO:
if not repo or not self.REPO_GITHUB_TOKEN:
return self.GITHUB_HEADERS
headers = {}
# 格式:{user1}/{repo1}:ghp_****,{user2}/{repo2}:github_pat_****
token_pairs = self.GITHUB_TOKEN_FOR_REPO.split(",")
token_pairs = self.REPO_GITHUB_TOKEN.split(",")
for token_pair in token_pairs:
try:
parts = token_pair.split(":")
Expand Down
6 changes: 3 additions & 3 deletions app/helper/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def get_plugins(self, repo_url: str) -> Dict[str, dict]:
return {}
raw_url = self._base_url % (user, repo)
res = RequestUtils(proxies=self.proxies,
headers=settings.GITHUB_HEADERS_FOR_REPO(repo=f"{user}/{repo}"),
headers=settings.REPO_GITHUB_HEADERS(repo=f"{user}/{repo}"),
timeout=10).get_res(f"{raw_url}package.json")
if res:
try:
Expand Down Expand Up @@ -146,7 +146,7 @@ def __get_filelist(_p: str) -> Tuple[Optional[list], Optional[str]]:
"""
file_api = f"https://api.github.com/repos/{user_repo}/contents/plugins/{_p}"
r = RequestUtils(proxies=settings.PROXY,
headers=settings.GITHUB_HEADERS_FOR_REPO(repo=user_repo),
headers=settings.REPO_GITHUB_HEADERS(repo=user_repo),
timeout=30).get_res(file_api)
if r is None:
return None, "连接仓库失败"
Expand All @@ -169,7 +169,7 @@ def __download_files(_p: str, _l: List[dict]) -> Tuple[bool, str]:
download_url = f"{settings.GITHUB_PROXY}{item.get('download_url')}"
# 下载插件文件
res = RequestUtils(proxies=self.proxies,
headers=settings.GITHUB_HEADERS_FOR_REPO(repo=user_repo),
headers=settings.REPO_GITHUB_HEADERS(repo=user_repo),
timeout=60).get_res(download_url)
if not res:
return False, f"文件 {item.get('name')} 下载失败!"
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
APP_VERSION = 'v1.9.10-1'
APP_VERSION = 'v1.9.11'

0 comments on commit 52d0703

Please sign in to comment.