From 0cbf45f9b957a1a29a74c43e449122a656d4ad97 Mon Sep 17 00:00:00 2001 From: sxnan Date: Tue, 30 Apr 2024 15:55:10 +0800 Subject: [PATCH] Cast tmdbid to int type after getting metainfo from title --- app/core/metainfo.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/core/metainfo.py b/app/core/metainfo.py index 6fe7a58b..fe28e4f8 100644 --- a/app/core/metainfo.py +++ b/app/core/metainfo.py @@ -1,3 +1,4 @@ +import logging from pathlib import Path from typing import Tuple @@ -6,6 +7,7 @@ import regex as re from app.core.config import settings from app.core.meta import MetaAnime, MetaVideo, MetaBase from app.core.meta.words import WordsMatcher +from app.log import logger from app.schemas.types import MediaType @@ -37,9 +39,12 @@ def MetaInfo(title: str, subtitle: str = None) -> MetaBase: meta.apply_words = apply_words or [] # 修正媒体信息 if metainfo.get('tmdbid'): - meta.tmdbid = metainfo['tmdbid'] + try: + meta.tmdbid = int(metainfo['tmdbid']) + except ValueError as _: + logger.warn("tmdbid 必须是数字") if metainfo.get('doubanid'): - meta.tmdbid = metainfo['doubanid'] + meta.doubanid = metainfo['doubanid'] if metainfo.get('type'): meta.type = metainfo['type'] if metainfo.get('begin_season'):