fix api
This commit is contained in:
parent
f20b1bcfe9
commit
9daff87f2f
@ -260,7 +260,7 @@ class ChainBase(metaclass=ABCMeta):
|
|||||||
"""
|
"""
|
||||||
return self.run_module("search_medias", meta=meta)
|
return self.run_module("search_medias", meta=meta)
|
||||||
|
|
||||||
def search_persons(self, name: str) -> Optional[List[TmdbPerson, DoubanPerson]]:
|
def search_persons(self, name: str) -> Optional[List[Union[TmdbPerson, DoubanPerson]]]:
|
||||||
"""
|
"""
|
||||||
搜索人物信息
|
搜索人物信息
|
||||||
:param name: 人物名称
|
:param name: 人物名称
|
||||||
|
@ -38,6 +38,7 @@ class DoubanApi(metaclass=Singleton):
|
|||||||
"tv_search": "/search/movie",
|
"tv_search": "/search/movie",
|
||||||
"book_search": "/search/book",
|
"book_search": "/search/book",
|
||||||
"group_search": "/search/group",
|
"group_search": "/search/group",
|
||||||
|
"person_search": "/search/celebrity",
|
||||||
|
|
||||||
# 各类主题合集
|
# 各类主题合集
|
||||||
# start: int = 0&count: int = 20
|
# start: int = 0&count: int = 20
|
||||||
@ -137,9 +138,6 @@ class DoubanApi(metaclass=Singleton):
|
|||||||
# doulist
|
# doulist
|
||||||
"doulist": "/doulist/",
|
"doulist": "/doulist/",
|
||||||
"doulist_items": "/doulist/%s/items",
|
"doulist_items": "/doulist/%s/items",
|
||||||
|
|
||||||
# personlist
|
|
||||||
"person_search": "/person/search",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_user_agents = [
|
_user_agents = [
|
||||||
@ -193,11 +191,11 @@ class DoubanApi(metaclass=Singleton):
|
|||||||
'_ts': ts,
|
'_ts': ts,
|
||||||
'_sig': self.__sign(url=req_url, ts=ts)
|
'_sig': self.__sign(url=req_url, ts=ts)
|
||||||
})
|
})
|
||||||
resp = RequestUtils(
|
with RequestUtils(
|
||||||
ua=choice(self._user_agents),
|
ua=choice(self._user_agents),
|
||||||
session=self._session
|
session=self._session
|
||||||
).get_res(url=req_url, params=params)
|
).get_res(url=req_url, params=params) as resp:
|
||||||
if resp.status_code == 400 and "rate_limit" in resp.text:
|
if resp is not None and resp.status_code == 400 and "rate_limit" in resp.text:
|
||||||
return resp.json()
|
return resp.json()
|
||||||
return resp.json() if resp else {}
|
return resp.json() if resp else {}
|
||||||
|
|
||||||
@ -230,6 +228,13 @@ class DoubanApi(metaclass=Singleton):
|
|||||||
return resp.json()
|
return resp.json()
|
||||||
return resp.json() if resp else {}
|
return resp.json() if resp else {}
|
||||||
|
|
||||||
|
def imdbid(self, imdbid: str,
|
||||||
|
ts=datetime.strftime(datetime.now(), '%Y%m%d')):
|
||||||
|
"""
|
||||||
|
IMDBID搜索
|
||||||
|
"""
|
||||||
|
return self.__post(self._urls["imdbid"] % imdbid, _ts=ts)
|
||||||
|
|
||||||
def search(self, keyword: str, start: int = 0, count: int = 20,
|
def search(self, keyword: str, start: int = 0, count: int = 20,
|
||||||
ts=datetime.strftime(datetime.now(), '%Y%m%d')) -> dict:
|
ts=datetime.strftime(datetime.now(), '%Y%m%d')) -> dict:
|
||||||
"""
|
"""
|
||||||
@ -238,13 +243,6 @@ class DoubanApi(metaclass=Singleton):
|
|||||||
return self.__invoke(self._urls["search"], q=keyword,
|
return self.__invoke(self._urls["search"], q=keyword,
|
||||||
start=start, count=count, _ts=ts)
|
start=start, count=count, _ts=ts)
|
||||||
|
|
||||||
def imdbid(self, imdbid: str,
|
|
||||||
ts=datetime.strftime(datetime.now(), '%Y%m%d')):
|
|
||||||
"""
|
|
||||||
IMDBID搜索
|
|
||||||
"""
|
|
||||||
return self.__post(self._urls["imdbid"] % imdbid, _ts=ts)
|
|
||||||
|
|
||||||
def movie_search(self, keyword: str, start: int = 0, count: int = 20,
|
def movie_search(self, keyword: str, start: int = 0, count: int = 20,
|
||||||
ts=datetime.strftime(datetime.now(), '%Y%m%d')):
|
ts=datetime.strftime(datetime.now(), '%Y%m%d')):
|
||||||
"""
|
"""
|
||||||
|
@ -101,13 +101,7 @@ class TmdbApi:
|
|||||||
"""
|
"""
|
||||||
if not name:
|
if not name:
|
||||||
return []
|
return []
|
||||||
ret_infos = []
|
return self.search.people(term=name) or []
|
||||||
persons = self.person.search(query=name) or []
|
|
||||||
for person in persons:
|
|
||||||
if name in person.get("name"):
|
|
||||||
person['media_type'] = MediaType.PERSON
|
|
||||||
ret_infos.append(person)
|
|
||||||
return ret_infos
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __compare_names(file_name: str, tmdb_names: list) -> bool:
|
def __compare_names(file_name: str, tmdb_names: list) -> bool:
|
||||||
|
@ -14,7 +14,6 @@ class Person(TMDb):
|
|||||||
"translations": "/person/%s/translations",
|
"translations": "/person/%s/translations",
|
||||||
"latest": "/person/latest",
|
"latest": "/person/latest",
|
||||||
"popular": "/person/popular",
|
"popular": "/person/popular",
|
||||||
"search_people": "/search/person",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def details(self, person_id, append_to_response="videos,images"):
|
def details(self, person_id, append_to_response="videos,images"):
|
||||||
@ -136,16 +135,3 @@ class Person(TMDb):
|
|||||||
params="page=%s" % page,
|
params="page=%s" % page,
|
||||||
key="results"
|
key="results"
|
||||||
)
|
)
|
||||||
|
|
||||||
def search(self, query, page=1):
|
|
||||||
"""
|
|
||||||
Search for people.
|
|
||||||
:param query: str
|
|
||||||
:param page: int
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
return self._request_obj(
|
|
||||||
self._urls["search_people"],
|
|
||||||
params="query=%s&page=%s" % (query, page),
|
|
||||||
key="results"
|
|
||||||
)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user