Skip to content

Commit 7fc995a

Browse files
committed
fix: tmdb_poster_parser下载海报到本地并用番剧名命名
1 parent 7c7c170 commit 7fc995a

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

backend/src/module/parser/title_parser.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
tmdb_parser,
1111
torrent_parser,
1212
)
13+
from module.utils import save_image
14+
from module.utils.request import RequestContent
1315

1416
logger = logging.getLogger(__name__)
1517

@@ -49,7 +51,21 @@ async def tmdb_poster_parser(bangumi: Bangumi):
4951
)
5052
if tmdb_info:
5153
logger.debug("TMDB Matched, official title is %s", tmdb_info.title)
52-
bangumi.poster_link = tmdb_info.poster_link
54+
poster_url = tmdb_info.poster_link
55+
if poster_url:
56+
try:
57+
async with RequestContent() as req:
58+
img = await req.get_content(poster_url)
59+
suffix = poster_url.split(".")[-1].split("?")[0]
60+
img_path = save_image(img, suffix, bangumi.official_title)
61+
bangumi.poster_link = img_path
62+
except Exception as e:
63+
logger.warning(
64+
f"[Poster] Failed to download poster for {bangumi.official_title}: {e}"
65+
)
66+
bangumi.poster_link = poster_url
67+
else:
68+
bangumi.poster_link = None
5369
else:
5470
logger.warning(
5571
f"Cannot match {bangumi.official_title} in TMDB. Use raw title instead."

0 commit comments

Comments
 (0)