本文整理匯總了Python中resources.lib.TheMovieDB.handle_multi_search方法的典型用法代碼示例。如果您正苦於以下問題:Python TheMovieDB.handle_multi_search方法的具體用法?Python TheMovieDB.handle_multi_search怎麽用?Python TheMovieDB.handle_multi_search使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類resources.lib.TheMovieDB
的用法示例。
在下文中一共展示了TheMovieDB.handle_multi_search方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: fetch_data
# 需要導入模塊: from resources.lib import TheMovieDB [as 別名]
# 或者: from resources.lib.TheMovieDB import handle_multi_search [as 別名]
def fetch_data(self, force=False): # TODO: rewrite
sort_by = self.sort + "." + self.order
temp = "tv" if self.type == "tv" else "movies"
if self.mode == "search":
params = {"query": self.search_str,
"include_adult": include_adult,
"page": self.page}
url = "search/multi"
self.filter_label = addon.LANG(32146) % self.search_str if self.search_str else ""
elif self.mode == "list":
params = {"language": addon.setting("LanguageID")}
url = "list/%s" % (self.list_id)
# self.filter_label = addon.LANG(32036)
elif self.mode == "favorites":
params = {"sort_by": sort_by,
"language": addon.setting("LanguageID"),
"page": self.page,
"session_id": tmdb.Login.get_session_id()}
url = "account/%s/favorite/%s" % (tmdb.Login.get_account_id(), temp)
self.filter_label = addon.LANG(32144) if self.type == "tv" else addon.LANG(32134)
elif self.mode == "rating":
force = True # workaround, should be updated after setting rating
if self.logged_in:
session_id = tmdb.Login.get_session_id()
if not session_id:
utils.notify("Could not get session id")
return {"listitems": [],
"results_per_page": 0,
"total_results": 0}
params = {"sort_by": sort_by,
"language": addon.setting("LanguageID"),
"page": self.page,
"session_id": session_id}
url = "account/%s/rated/%s" % (tmdb.Login.get_account_id(), temp)
else:
session_id = tmdb.Login.get_guest_session_id()
if not session_id:
utils.notify("Could not get session id")
return {"listitems": [],
"results_per_page": 0,
"total_results": 0}
params = {"language": addon.setting("LanguageID")}
url = "guest_session/%s/rated_movies" % (session_id)
self.filter_label = addon.LANG(32145) if self.type == "tv" else addon.LANG(32135)
else:
self.set_filter_label()
params = {"sort_by": sort_by,
"language": addon.setting("LanguageID"),
"page": self.page,
"include_adult": include_adult}
filters = {item["type"]: item["id"] for item in self.filters}
params = utils.merge_dicts(params, filters)
url = "discover/%s" % (self.type)
response = tmdb.get_data(url=url,
params=params,
cache_days=0 if force else 2)
if not response:
return None
if self.mode == "list":
info = {"listitems": tmdb.handle_movies(results=response["items"],
local_first=True,
sortkey=None),
"results_per_page": 1,
"total_results": len(response["items"])}
return info
if "results" not in response:
# self.close()
return {"listitems": [],
"results_per_page": 0,
"total_results": 0}
if not response["results"]:
utils.notify(addon.LANG(284))
if self.mode == "search":
listitems = tmdb.handle_multi_search(response["results"])
elif self.type == "movie":
listitems = tmdb.handle_movies(results=response["results"],
local_first=False,
sortkey=None)
else:
listitems = tmdb.handle_tvshows(results=response["results"],
local_first=False,
sortkey=None)
info = {"listitems": listitems,
"results_per_page": response["total_pages"],
"total_results": response["total_results"]}
return info