Skip to content

Commit

Permalink
Merge branch 'NAStool:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Shurelol authored May 7, 2023
2 parents b19ee6e + 397b5f2 commit aac99cd
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 29 deletions.
3 changes: 1 addition & 2 deletions app/helper/ocr_helper.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import base64

from app.utils import RequestUtils
from config import DEFAULT_OCR_SERVER


class OcrHelper:

_ocr_b64_url = "%s/captcha/base64" % DEFAULT_OCR_SERVER
_ocr_b64_url = "https://nastool.cn/captcha/base64"

def get_captcha_text(self, image_url=None, image_b64=None, cookie=None, ua=None):
"""
Expand Down
5 changes: 2 additions & 3 deletions app/helper/plugin_helper.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from cachetools import cached, TTLCache

from app.utils import RequestUtils
from config import NASTOOL_PLUGIN_INSTALL, NASTOOL_PLUGIN_STATISTIC


class PluginHelper:
Expand All @@ -11,7 +10,7 @@ def install(plugin_id):
"""
插件安装统计计数
"""
return RequestUtils(timeout=5).get(NASTOOL_PLUGIN_INSTALL % plugin_id)
return RequestUtils(timeout=5).get(f"https://nastool.cn/plugin/{plugin_id}/install")

@staticmethod
@cached(cache=TTLCache(maxsize=1, ttl=3600))
Expand All @@ -20,7 +19,7 @@ def statistic():
获取插件安装统计数据
"""
ret = RequestUtils(accept_type="application/json",
timeout=5).get_res(NASTOOL_PLUGIN_STATISTIC)
timeout=5).get_res("https://nastool.cn/plugin/statistic")
if ret:
try:
return ret.json()
Expand Down
6 changes: 3 additions & 3 deletions app/media/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from app.utils import PathUtils, EpisodeFormat, RequestUtils, NumberUtils, StringUtils, cacheman
from app.utils.types import MediaType, MatchMode
from config import Config, KEYWORD_BLACKLIST, KEYWORD_SEARCH_WEIGHT_3, KEYWORD_SEARCH_WEIGHT_2, KEYWORD_SEARCH_WEIGHT_1, \
KEYWORD_STR_SIMILARITY_THRESHOLD, KEYWORD_DIFF_SCORE_THRESHOLD, TMDB_PEOPLE_PROFILE_URL
KEYWORD_STR_SIMILARITY_THRESHOLD, KEYWORD_DIFF_SCORE_THRESHOLD


class Media:
Expand Down Expand Up @@ -1710,7 +1710,7 @@ def __dict_media_crews(crews):
"credit_id": crew.get("credit_id"),
"department": crew.get("department"),
"job": crew.get("job"),
"profile": TMDB_PEOPLE_PROFILE_URL % crew.get('id')
"profile": 'https://www.themoviedb.org/person/%s' % crew.get('id')
} for crew in crews or []]

@staticmethod
Expand All @@ -1730,7 +1730,7 @@ def __dict_media_casts(casts):
"role": cast.get("character"),
"credit_id": cast.get("credit_id"),
"order": cast.get("order"),
"profile": TMDB_PEOPLE_PROFILE_URL % cast.get('id')
"profile": 'https://www.themoviedb.org/person/%s' % cast.get('id')
} for cast in casts or []]

def get_tmdb_directors_actors(self, tmdbinfo):
Expand Down
6 changes: 3 additions & 3 deletions app/message/client/wechat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from app.message.client._base import _IMessageClient
from app.utils import RequestUtils, ExceptionUtils
from config import DEFAULT_WECHAT_PROXY

lock = threading.Lock()

Expand All @@ -17,6 +16,7 @@ class WeChat(_IMessageClient):
_expires_in = None
_access_token_time = None
_default_proxy = False
_default_proxy_url = 'https://wechat.nastool.cn'
_client_config = {}
_corpid = None
_corpsecret = None
Expand All @@ -39,8 +39,8 @@ def init_config(self):
self._default_proxy = self._client_config.get('default_proxy')
if self._default_proxy:
if isinstance(self._default_proxy, bool):
self._send_msg_url = f"{DEFAULT_WECHAT_PROXY}/cgi-bin/message/send?access_token=%s"
self._token_url = f"{DEFAULT_WECHAT_PROXY}/cgi-bin/gettoken?corpid=%s&corpsecret=%s"
self._send_msg_url = f"{self._default_proxy_url}/cgi-bin/message/send?access_token=%s"
self._token_url = f"{self._default_proxy_url}/cgi-bin/gettoken?corpid=%s&corpsecret=%s"
else:
self._send_msg_url = f"{self._default_proxy}/cgi-bin/message/send?access_token=%s"
self._token_url = f"{self._default_proxy}/cgi-bin/gettoken?corpid=%s&corpsecret=%s"
Expand Down
16 changes: 1 addition & 15 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,11 @@
FANART_TV_API_URL = 'https://webservice.fanart.tv/v3/tv/%s?api_key=d2d31f9ecabea050fc7d68aa3146015f'
# 默认背景图地址
DEFAULT_TMDB_IMAGE = 'https://s3.bmp.ovh/imgs/2022/07/10/77ef9500c851935b.webp'
# 默认微信消息代理服务器地址
DEFAULT_WECHAT_PROXY = 'https://wechat.nastool.cn'
# 默认OCR识别服务地址
DEFAULT_OCR_SERVER = 'https://nastool.cn'
# 默认TMDB代理服务地址
DEFAULT_TMDB_PROXY = 'https://tmdb.nastool.cn/3'
# 默认CookieCloud服务地址
DEFAULT_COOKIECLOUD_SERVER = 'http://nastool.cn:8088'
# TMDB API地址
# TMDB域名地址
TMDB_API_DOMAIN = 'api.themoviedb.org'
# TMDB图片地址
TMDB_IMAGE_DOMAIN = 'image.tmdb.org'
TMDB_PEOPLE_PROFILE_URL = 'https://www.themoviedb.org/person/%s'
# 检查更新的地址
NASTOOL_UPDATE_URL = "https://nastool.cn/%s/update"
# 插件安装统计地址
NASTOOL_PLUGIN_INSTALL = "https://nastool.cn/plugin/%s/install"
# 插件安装统计数据
NASTOOL_PLUGIN_STATISTIC = "https://nastool.cn/plugin/statistic"
# 添加下载时增加的标签,开始只监控NAStool添加的下载时有效
PT_TAG = "NASTOOL"
# 电影默认命名格式
Expand Down
5 changes: 2 additions & 3 deletions web/backend/web_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import io
from functools import lru_cache
from urllib.parse import quote

Expand All @@ -8,7 +7,7 @@
from app.media.meta import MetaInfo
from app.utils import StringUtils, ExceptionUtils, SystemUtils, RequestUtils, IpUtils
from app.utils.types import MediaType
from config import Config, NASTOOL_UPDATE_URL
from config import Config
from version import APP_VERSION


Expand Down Expand Up @@ -53,7 +52,7 @@ def get_latest_version():
try:
releases_update_only = Config().get_config("app").get("releases_update_only")
version_res = RequestUtils(proxies=Config().get_proxies()).get_res(
NASTOOL_UPDATE_URL % quote(WebUtils.get_current_version()))
f"https://nastool.cn/{quote(WebUtils.get_current_version())}/update")
if version_res:
ver_json = version_res.json()
version = ver_json.get("latest")
Expand Down

0 comments on commit aac99cd

Please sign in to comment.