Skip to content

Commit

Permalink
fix: 合并冲突
Browse files Browse the repository at this point in the history
  • Loading branch information
linyuan0213 committed May 8, 2023
2 parents 6d0513e + 6cebee9 commit aa72533
Show file tree
Hide file tree
Showing 19 changed files with 172 additions and 472 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ jobs:
linux/arm64
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/nas-tools:latest-beta
${{ secrets.DOCKER_USERNAME }}/nas-tools:latest-beta
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ jobs:
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/nas-tools:latest
${{ secrets.DOCKER_USERNAME }}/nas-tools:${{ env.app_version }}
${{ secrets.DOCKER_USERNAME }}/nas-tools:${{ env.app_version }}
10 changes: 10 additions & 0 deletions app/helper/plugin_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ def install(plugin_id):
"""
return RequestUtils(timeout=5).get(f"https://nastool.cn/plugin/{plugin_id}/install")

@staticmethod
def report(plugins):
"""
批量上报插件安装统计数据
"""
return RequestUtils(content_type="application/json",
timeout=5).post(f"https://nastool.cn/plugin/update", json={
"plugins": [{"plugin_id": plugin, "count": 1} for plugin in plugins]
})

@staticmethod
@cached(cache=TTLCache(maxsize=1, ttl=3600))
def statistic():
Expand Down
43 changes: 19 additions & 24 deletions app/media/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,23 @@ def __gen_tv_episode_nfo_file(self,
# 保存文件
self.__save_nfo(doc, os.path.join(out_path, os.path.join(out_path, "%s.nfo" % file_name)))

def __save_remove_file(self, out_file, content):
"""
保存文件到远端
"""
temp_file = os.path.join(self._temp_path, out_file[1:])
temp_file_dir = os.path.dirname(temp_file)
if not os.path.exists(temp_file_dir):
os.makedirs(temp_file_dir)
with open(temp_file, "wb") as f:
f.write(content)
if self._rmt_mode in [RmtMode.RCLONE, RmtMode.RCLONECOPY]:
SystemUtils.rclone_move(temp_file, out_file)
elif self._rmt_mode in [RmtMode.MINIO, RmtMode.MINIOCOPY]:
SystemUtils.minio_move(temp_file, out_file)
else:
SystemUtils.move(temp_file, out_file)

@retry(RequestException, logger=log)
def __save_image(self, url, out_path, itype='', force=False):
"""
Expand All @@ -395,18 +412,7 @@ def __save_image(self, url, out_path, itype='', force=False):
if r:
# 下载到temp目录,远程则先存到temp再远程移动,本地则直接保存
if self._rmt_mode in ModuleConf.REMOTE_RMT_MODES:
temp_img = os.path.join(self._temp_path, image_path)
temp_img_dir = os.path.dirname(temp_img)
if not os.path.exists(temp_img_dir):
os.makedirs(temp_img_dir)
with open(file=temp_img, mode="wb") as img:
img.write(r.content)
if self._rmt_mode in [RmtMode.RCLONE, RmtMode.RCLONECOPY]:
SystemUtils.rclone_move(temp_img, image_path)
elif self._rmt_mode in [RmtMode.MINIO, RmtMode.MINIOCOPY]:
SystemUtils.minio_move(temp_img, image_path)
else:
SystemUtils.move(temp_img, image_path)
self.__save_remove_file(image_path, r.content)
else:
with open(file=image_path, mode="wb") as img:
img.write(r.content)
Expand All @@ -423,18 +429,7 @@ def __save_nfo(self, doc, out_file):
xml_str = doc.toprettyxml(indent=" ", encoding="utf-8")
# 下载到temp目录,远程则先存到temp再远程移动,本地则直接保存
if self._rmt_mode in ModuleConf.REMOTE_RMT_MODES:
temp_file = os.path.join(self._temp_path, out_file)
temp_file_dir = os.path.dirname(temp_file)
if not os.path.exists(temp_file_dir):
os.makedirs(temp_file_dir)
with open(temp_file, "wb") as xml_file:
xml_file.write(xml_str)
if self._rmt_mode in [RmtMode.RCLONE, RmtMode.RCLONECOPY]:
SystemUtils.rclone_move(temp_file, out_file)
elif self._rmt_mode in [RmtMode.MINIO, RmtMode.MINIOCOPY]:
SystemUtils.minio_move(temp_file, out_file)
else:
SystemUtils.move(temp_file, out_file)
self.__save_remove_file(out_file, xml_str)
else:
with open(out_file, "wb") as xml_file:
xml_file.write(xml_str)
Expand Down
Loading

0 comments on commit aa72533

Please sign in to comment.