fix: 修复类型错误,加入部分日志

This commit is contained in:
amtoaer
2023-12-02 00:40:35 +08:00
parent f10fc9dd97
commit 6ef25d6409
2 changed files with 15 additions and 12 deletions
+13 -10
View File
@@ -41,19 +41,22 @@ async def upper_thumb():
makedir_tasks = [] makedir_tasks = []
other_tasks = [] other_tasks = []
for upper in await Upper.all(): for upper in await Upper.all():
if not all( if all(
await asyncio.gather( await asyncio.gather(
aexists(upper.thumb_path), aexists(upper.meta_path) aexists(upper.thumb_path), aexists(upper.meta_path)
) )
): ):
makedir_tasks.append( logger.info("Upper {} {} already exists, skipped.", upper.mid, upper.name)
amakedirs(upper.thumb_path.parent, exist_ok=True) makedir_tasks.append(
) amakedirs(upper.thumb_path.parent, exist_ok=True)
other_tasks.extend( )
[ logger.info("Saving metadata for upper {} {}...", upper.mid, upper.name)
upper.save_metadata(), other_tasks.extend(
download_content(upper.thumb_url, upper.thumb_path), [
] upper.save_metadata(),
) download_content(upper.thumb_url, upper.thumb_path),
]
)
await asyncio.gather(*makedir_tasks) await asyncio.gather(*makedir_tasks)
await asyncio.gather(*other_tasks) await asyncio.gather(*other_tasks)
logger.info("All done.")
+2 -2
View File
@@ -41,13 +41,13 @@ class Upper(Model):
@property @property
def thumb_path(self) -> Path: def thumb_path(self) -> Path:
return ( return (
DEFAULT_THUMB_PATH / f"{self.mid[0]}" / f"{self.mid}" / "folder.jpg" DEFAULT_THUMB_PATH / str(self.mid)[0] / f"{self.mid}" / "folder.jpg"
) )
@property @property
def meta_path(self) -> Path: def meta_path(self) -> Path:
return ( return (
DEFAULT_THUMB_PATH / f"{self.mid[0]}" / f"{self.mid}" / "person.nfo" DEFAULT_THUMB_PATH / str(self.mid)[0] / f"{self.mid}" / "person.nfo"
) )
async def save_metadata(self): async def save_metadata(self):