mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-11-25 13:22:03 +08:00
fix(types): annotate TMDB person object API
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
from typing import Any
|
||||
|
||||
from ..tmdb import TMDb
|
||||
|
||||
|
||||
class Person(TMDb):
|
||||
"""提供 TMDB 人物接口的同步与异步封装。"""
|
||||
_urls = {
|
||||
"details": "/person/%s",
|
||||
"changes": "/person/%s/changes",
|
||||
@@ -16,7 +19,7 @@ class Person(TMDb):
|
||||
"popular": "/person/popular",
|
||||
}
|
||||
|
||||
def details(self, person_id, append_to_response="videos,images"):
|
||||
def details(self, person_id: int, append_to_response: str | None="videos,images") -> Any:
|
||||
"""
|
||||
Get the primary person details by id.
|
||||
:param append_to_response: str
|
||||
@@ -28,7 +31,7 @@ class Person(TMDb):
|
||||
params="append_to_response=%s" % append_to_response
|
||||
)
|
||||
|
||||
def changes(self, person_id, start_date=None, end_date=None, page=1):
|
||||
def changes(self, person_id: int, start_date: str | None=None, end_date: str | None=None, page: int=1) -> Any:
|
||||
"""
|
||||
Get the changes for a person. By default only the last 24 hours are returned.
|
||||
You can query up to 14 days in a single query by using the start_date and end_date query parameters.
|
||||
@@ -49,7 +52,7 @@ class Person(TMDb):
|
||||
key="changes"
|
||||
)
|
||||
|
||||
def movie_credits(self, person_id):
|
||||
def movie_credits(self, person_id: int) -> Any:
|
||||
"""
|
||||
Get the movie credits for a person.
|
||||
:param person_id: int
|
||||
@@ -57,7 +60,7 @@ class Person(TMDb):
|
||||
"""
|
||||
return self._request_obj(self._urls["movie_credits"] % person_id)
|
||||
|
||||
def tv_credits(self, person_id):
|
||||
def tv_credits(self, person_id: int) -> Any:
|
||||
"""
|
||||
Get the TV show credits for a person.
|
||||
:param person_id: int
|
||||
@@ -65,7 +68,7 @@ class Person(TMDb):
|
||||
"""
|
||||
return self._request_obj(self._urls["tv_credits"] % person_id)
|
||||
|
||||
def combined_credits(self, person_id):
|
||||
def combined_credits(self, person_id: int) -> Any:
|
||||
"""
|
||||
Get the movie and TV credits together in a single response.
|
||||
:param person_id: int
|
||||
@@ -73,7 +76,7 @@ class Person(TMDb):
|
||||
"""
|
||||
return self._request_obj(self._urls["combined_credits"] % person_id)
|
||||
|
||||
def external_ids(self, person_id):
|
||||
def external_ids(self, person_id: int) -> Any:
|
||||
"""
|
||||
Get the external ids for a person. We currently support the following external sources.
|
||||
IMDB ID, Facebook, Freebase MID, Freebase ID, Instagram, TVRage ID, and Twitter
|
||||
@@ -82,7 +85,7 @@ class Person(TMDb):
|
||||
"""
|
||||
return self._request_obj(self._urls["external_ids"] % person_id)
|
||||
|
||||
def images(self, person_id):
|
||||
def images(self, person_id: int) -> Any:
|
||||
"""
|
||||
Get the images for a person.
|
||||
:param person_id: int
|
||||
@@ -93,7 +96,7 @@ class Person(TMDb):
|
||||
key="profiles"
|
||||
)
|
||||
|
||||
def tagged_images(self, person_id, page=1):
|
||||
def tagged_images(self, person_id: int, page: int=1) -> Any:
|
||||
"""
|
||||
Get the images that this person has been tagged in.
|
||||
:param person_id: int
|
||||
@@ -106,7 +109,7 @@ class Person(TMDb):
|
||||
key="results"
|
||||
)
|
||||
|
||||
def translations(self, person_id):
|
||||
def translations(self, person_id: int) -> Any:
|
||||
"""
|
||||
Get a list of translations that have been created for a person.
|
||||
:param person_id: int
|
||||
@@ -117,14 +120,14 @@ class Person(TMDb):
|
||||
key="translations"
|
||||
)
|
||||
|
||||
def latest(self):
|
||||
def latest(self) -> Any:
|
||||
"""
|
||||
Get the most newly created person. This is a live response and will continuously change.
|
||||
:return:
|
||||
"""
|
||||
return self._request_obj(self._urls["latest"])
|
||||
|
||||
def popular(self, page=1):
|
||||
def popular(self, page: int=1) -> Any:
|
||||
"""
|
||||
Get the list of popular people on TMDb. This list updates daily.
|
||||
:param page: int
|
||||
@@ -137,7 +140,7 @@ class Person(TMDb):
|
||||
)
|
||||
|
||||
# 异步版本方法
|
||||
async def async_details(self, person_id, append_to_response="videos,images"):
|
||||
async def async_details(self, person_id: int, append_to_response: str | None="videos,images") -> Any:
|
||||
"""
|
||||
Get the primary person details by id.(异步版本)
|
||||
:param append_to_response: str
|
||||
@@ -149,7 +152,7 @@ class Person(TMDb):
|
||||
params="append_to_response=%s" % append_to_response
|
||||
)
|
||||
|
||||
async def async_changes(self, person_id, start_date=None, end_date=None, page=1):
|
||||
async def async_changes(self, person_id: int, start_date: str | None=None, end_date: str | None=None, page: int=1) -> Any:
|
||||
"""
|
||||
Get the changes for a person. By default only the last 24 hours are returned.
|
||||
You can query up to 14 days in a single query by using the start_date and end_date query parameters.(异步版本)
|
||||
@@ -170,7 +173,7 @@ class Person(TMDb):
|
||||
key="changes"
|
||||
)
|
||||
|
||||
async def async_movie_credits(self, person_id):
|
||||
async def async_movie_credits(self, person_id: int) -> Any:
|
||||
"""
|
||||
Get the movie credits for a person.(异步版本)
|
||||
:param person_id: int
|
||||
@@ -178,7 +181,7 @@ class Person(TMDb):
|
||||
"""
|
||||
return await self._async_request_obj(self._urls["movie_credits"] % person_id)
|
||||
|
||||
async def async_tv_credits(self, person_id):
|
||||
async def async_tv_credits(self, person_id: int) -> Any:
|
||||
"""
|
||||
Get the TV show credits for a person.(异步版本)
|
||||
:param person_id: int
|
||||
@@ -186,7 +189,7 @@ class Person(TMDb):
|
||||
"""
|
||||
return await self._async_request_obj(self._urls["tv_credits"] % person_id)
|
||||
|
||||
async def async_combined_credits(self, person_id):
|
||||
async def async_combined_credits(self, person_id: int) -> Any:
|
||||
"""
|
||||
Get the movie and TV credits together in a single response.(异步版本)
|
||||
:param person_id: int
|
||||
@@ -194,7 +197,7 @@ class Person(TMDb):
|
||||
"""
|
||||
return await self._async_request_obj(self._urls["combined_credits"] % person_id)
|
||||
|
||||
async def async_external_ids(self, person_id):
|
||||
async def async_external_ids(self, person_id: int) -> Any:
|
||||
"""
|
||||
Get the external ids for a person. We currently support the following external sources.
|
||||
IMDB ID, Facebook, Freebase MID, Freebase ID, Instagram, TVRage ID, and Twitter(异步版本)
|
||||
@@ -203,7 +206,7 @@ class Person(TMDb):
|
||||
"""
|
||||
return await self._async_request_obj(self._urls["external_ids"] % person_id)
|
||||
|
||||
async def async_images(self, person_id):
|
||||
async def async_images(self, person_id: int) -> Any:
|
||||
"""
|
||||
Get the images for a person.(异步版本)
|
||||
:param person_id: int
|
||||
@@ -214,7 +217,7 @@ class Person(TMDb):
|
||||
key="profiles"
|
||||
)
|
||||
|
||||
async def async_tagged_images(self, person_id, page=1):
|
||||
async def async_tagged_images(self, person_id: int, page: int=1) -> Any:
|
||||
"""
|
||||
Get the images that this person has been tagged in.(异步版本)
|
||||
:param person_id: int
|
||||
@@ -227,7 +230,7 @@ class Person(TMDb):
|
||||
key="results"
|
||||
)
|
||||
|
||||
async def async_translations(self, person_id):
|
||||
async def async_translations(self, person_id: int) -> Any:
|
||||
"""
|
||||
Get a list of translations that have been created for a person.(异步版本)
|
||||
:param person_id: int
|
||||
@@ -238,14 +241,14 @@ class Person(TMDb):
|
||||
key="translations"
|
||||
)
|
||||
|
||||
async def async_latest(self):
|
||||
async def async_latest(self) -> Any:
|
||||
"""
|
||||
Get the most newly created person. This is a live response and will continuously change.(异步版本)
|
||||
:return:
|
||||
"""
|
||||
return await self._async_request_obj(self._urls["latest"])
|
||||
|
||||
async def async_popular(self, page=1):
|
||||
async def async_popular(self, page: int=1) -> Any:
|
||||
"""
|
||||
Get the list of popular people on TMDb. This list updates daily.(异步版本)
|
||||
:param page: int
|
||||
|
||||
Reference in New Issue
Block a user