mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-11-15 04:44:39 +08:00
refactor(types): govern TMDb company response contract
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
from ..tmdb import TMDb
|
||||
from ..tmdb import TMDb, TMDbJson
|
||||
|
||||
|
||||
class Company(TMDb):
|
||||
"""提供公司详情、别名、图像和电影分页查询。"""
|
||||
|
||||
_urls = {
|
||||
"details": "/company/%s",
|
||||
"alternative_names": "/company/%s/alternative_names",
|
||||
@@ -9,7 +11,7 @@ class Company(TMDb):
|
||||
"movies": "/company/%s/movies"
|
||||
}
|
||||
|
||||
def details(self, company_id):
|
||||
def details(self, company_id: int | str) -> TMDbJson:
|
||||
"""
|
||||
Get a companies details by id.
|
||||
:param company_id: int
|
||||
@@ -17,7 +19,7 @@ class Company(TMDb):
|
||||
"""
|
||||
return self._request_obj(self._urls["details"] % company_id)
|
||||
|
||||
def alternative_names(self, company_id):
|
||||
def alternative_names(self, company_id: int | str) -> TMDbJson:
|
||||
"""
|
||||
Get the alternative names of a company.
|
||||
:param company_id: int
|
||||
@@ -25,7 +27,7 @@ class Company(TMDb):
|
||||
"""
|
||||
return self._request_obj(self._urls["alternative_names"] % company_id, key="results")
|
||||
|
||||
def images(self, company_id):
|
||||
def images(self, company_id: int | str) -> TMDbJson:
|
||||
"""
|
||||
Get the alternative names of a company.
|
||||
:param company_id: int
|
||||
@@ -33,7 +35,7 @@ class Company(TMDb):
|
||||
"""
|
||||
return self._request_obj(self._urls["images"] % company_id, key="logos")
|
||||
|
||||
def movies(self, company_id, page=1):
|
||||
def movies(self, company_id: int | str, page: int=1) -> TMDbJson:
|
||||
"""
|
||||
Get the movies of a company by id.
|
||||
:param company_id: int
|
||||
@@ -47,7 +49,7 @@ class Company(TMDb):
|
||||
)
|
||||
|
||||
# 异步版本方法
|
||||
async def async_details(self, company_id):
|
||||
async def async_details(self, company_id: int | str) -> TMDbJson:
|
||||
"""
|
||||
Get a companies details by id.(异步版本)
|
||||
:param company_id: int
|
||||
@@ -55,7 +57,7 @@ class Company(TMDb):
|
||||
"""
|
||||
return await self._async_request_obj(self._urls["details"] % company_id)
|
||||
|
||||
async def async_alternative_names(self, company_id):
|
||||
async def async_alternative_names(self, company_id: int | str) -> TMDbJson:
|
||||
"""
|
||||
Get the alternative names of a company.(异步版本)
|
||||
:param company_id: int
|
||||
@@ -63,7 +65,7 @@ class Company(TMDb):
|
||||
"""
|
||||
return await self._async_request_obj(self._urls["alternative_names"] % company_id, key="results")
|
||||
|
||||
async def async_images(self, company_id):
|
||||
async def async_images(self, company_id: int | str) -> TMDbJson:
|
||||
"""
|
||||
Get the alternative names of a company.(异步版本)
|
||||
:param company_id: int
|
||||
@@ -71,7 +73,7 @@ class Company(TMDb):
|
||||
"""
|
||||
return await self._async_request_obj(self._urls["images"] % company_id, key="logos")
|
||||
|
||||
async def async_movies(self, company_id, page=1):
|
||||
async def async_movies(self, company_id: int | str, page: int=1) -> TMDbJson:
|
||||
"""
|
||||
Get the movies of a company by id.(异步版本)
|
||||
:param company_id: int
|
||||
|
||||
Reference in New Issue
Block a user