refactor(types): govern TMDb network response contract

This commit is contained in:
jxxghp
2026-10-16 23:49:52 +08:00
parent 69d0f1b044
commit ac6813bc60
2 changed files with 10 additions and 7 deletions

View File

@@ -1,14 +1,16 @@
from ..tmdb import TMDb
from ..tmdb import TMDb, TMDbJson
class Network(TMDb):
"""提供电视网络详情、别名和图像查询。"""
_urls = {
"details": "/network/%s",
"alternative_names": "/network/%s/alternative_names",
"images": "/network/%s/images"
}
def details(self, network_id):
def details(self, network_id: int | str) -> TMDbJson:
"""
Get a networks details by id.
:param network_id: int
@@ -16,7 +18,7 @@ class Network(TMDb):
"""
return self._request_obj(self._urls["details"] % network_id)
async def async_details(self, network_id):
async def async_details(self, network_id: int | str) -> TMDbJson:
"""
Get a networks details by id.(异步版本)
:param network_id: int
@@ -24,7 +26,7 @@ class Network(TMDb):
"""
return await self._async_request_obj(self._urls["details"] % network_id)
def alternative_names(self, network_id):
def alternative_names(self, network_id: int | str) -> TMDbJson:
"""
Get the alternative names of a network.
:param network_id: int
@@ -35,7 +37,7 @@ class Network(TMDb):
key="results"
)
async def async_alternative_names(self, network_id):
async def async_alternative_names(self, network_id: int | str) -> TMDbJson:
"""
Get the alternative names of a network.(异步版本)
:param network_id: int
@@ -46,7 +48,7 @@ class Network(TMDb):
key="results"
)
def images(self, network_id):
def images(self, network_id: int | str) -> TMDbJson:
"""
Get the TV network logos by id.
:param network_id: int
@@ -57,7 +59,7 @@ class Network(TMDb):
key="logos"
)
async def async_images(self, network_id):
async def async_images(self, network_id: int | str) -> TMDbJson:
"""
Get the TV network logos by id.(异步版本)
:param network_id: int

View File

@@ -181,4 +181,5 @@ files =
app/modules/themoviedb/tmdbv3api/objs/provider.py,
app/modules/themoviedb/tmdbv3api/objs/credit.py,
app/modules/themoviedb/tmdbv3api/objs/group.py,
app/modules/themoviedb/tmdbv3api/objs/network.py,
scripts/architecture/async_blocking.py