mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
fix scraping upload
This commit is contained in:
+14
-6
@@ -365,14 +365,22 @@ class MediaChain(ChainBase, metaclass=Singleton):
|
|||||||
"""
|
"""
|
||||||
if not _fileitem or not _content or not _path:
|
if not _fileitem or not _content or not _path:
|
||||||
return
|
return
|
||||||
|
# 保存文件到临时目录
|
||||||
tmp_file = settings.TEMP_PATH / _path.name
|
tmp_file = settings.TEMP_PATH / _path.name
|
||||||
tmp_file.write_bytes(_content)
|
tmp_file.write_bytes(_content)
|
||||||
_fileitem.path = str(_path.parent)
|
# 获取文件的父目录
|
||||||
item = self.storagechain.upload_file(fileitem=_fileitem, path=tmp_file)
|
try:
|
||||||
if item:
|
parent_item = self.storagechain.get_parent_item(_fileitem)
|
||||||
logger.info(f"已保存文件:{Path(item.path) / item.name}")
|
if not parent_item:
|
||||||
if tmp_file.exists():
|
return
|
||||||
tmp_file.unlink()
|
item = self.storagechain.upload_file(fileitem=parent_item, path=tmp_file, new_name=_path.name)
|
||||||
|
if item:
|
||||||
|
logger.info(f"已保存文件:{Path(parent_item.path) / item.name}")
|
||||||
|
else:
|
||||||
|
logger.warn(f"文件保存失败:{Path(parent_item.path) / _path.name}")
|
||||||
|
finally:
|
||||||
|
if tmp_file.exists():
|
||||||
|
tmp_file.unlink()
|
||||||
|
|
||||||
def __download_image(_url: str) -> Optional[bytes]:
|
def __download_image(_url: str) -> Optional[bytes]:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user