This commit is contained in:
jxxghp
2023-07-30 13:12:17 +08:00
parent 220dede9c4
commit f21c46edba
6 changed files with 17 additions and 15 deletions

View File

@ -1105,7 +1105,7 @@ class TmdbHelper:
info = self.movie.credits(movie_id=tmdbid) or {}
cast = info.get('cast') or []
if cast:
return [c.to_dict() for c in cast][(page - 1) * count: page * count]
return cast[(page - 1) * count: page * count]
return []
except Exception as e:
print(str(e))
@ -1122,7 +1122,7 @@ class TmdbHelper:
info = self.tv.credits(tv_id=tmdbid) or {}
cast = info.get('cast') or []
if cast:
return [c.to_dict() for c in cast][(page - 1) * count: page * count]
return cast[(page - 1) * count: page * count]
return []
except Exception as e:
print(str(e))
@ -1136,11 +1136,7 @@ class TmdbHelper:
return {}
try:
logger.info(f"正在获取人物详情:{person_id}...")
info = self.person.details(person_id=person_id)
if info:
info_dict = info.to_dict()
return info_dict
return {}
return self.person.details(person_id=person_id) or {}
except Exception as e:
print(str(e))
return {}
@ -1156,7 +1152,7 @@ class TmdbHelper:
info = self.person.movie_credits(person_id=person_id) or {}
cast = info.get('cast') or []
if cast:
return [c.to_dict() for c in cast][(page - 1) * count: page * count]
return cast[(page - 1) * count: page * count]
return []
except Exception as e:
print(str(e))

View File

@ -68,8 +68,8 @@ class AsObj:
return reversed(self._dict())
if sys.version_info >= (3, 9):
def __class_getitem__(self, key):
return self.__dict__.__class_getitem__(key)
def __class_getitem__(cls, key):
return cls.__dict__.__class_getitem__(key)
def __ior__(self, value):
return self._dict().__ior__(value)

View File

@ -3,13 +3,12 @@
import logging
import os
import time
from functools import lru_cache
import requests
import requests.exceptions
from .as_obj import AsObj
from .exceptions import TMDbException
from functools import lru_cache
logger = logging.getLogger(__name__)
@ -196,4 +195,6 @@ class TMDb(object):
if "success" in json and json["success"] is False:
raise TMDbException(json["status_message"])
return AsObj(json, key=key)
if key:
return json.get(key)
return json