log youtube API usage
This commit is contained in:
parent
8d932ccc34
commit
4dc44720e8
1 changed files with 11 additions and 1 deletions
|
@ -24,6 +24,8 @@ ARROW_DOWN = "↓"
|
||||||
"Turn safe search off/on"))
|
"Turn safe search off/on"))
|
||||||
class Module(ModuleManager.BaseModule):
|
class Module(ModuleManager.BaseModule):
|
||||||
def get_video_page(self, video_id):
|
def get_video_page(self, video_id):
|
||||||
|
self.log.debug("youtube API request: "
|
||||||
|
"videos.list [contentDetails,snippet,statistics]")
|
||||||
return utils.http.request(URL_YOUTUBEVIDEO, get_params={
|
return utils.http.request(URL_YOUTUBEVIDEO, get_params={
|
||||||
"part": "contentDetails,snippet,statistics",
|
"part": "contentDetails,snippet,statistics",
|
||||||
"id": video_id, "key": self.bot.config["google-api-key"]}).json()
|
"id": video_id, "key": self.bot.config["google-api-key"]}).json()
|
||||||
|
@ -76,7 +78,10 @@ class Module(ModuleManager.BaseModule):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_playlist_page(self, playlist_id):
|
def get_playlist_page(self, playlist_id):
|
||||||
return utils.http.request(URL_YOUTUBEPLAYLIST, get_params={
|
self.log.debug("youtube API request: "
|
||||||
|
"playlists.list [contentDetails,snippet]")
|
||||||
|
|
||||||
|
return utils.http.request(URL_YOUTUBEPLAYLIST, get_params={
|
||||||
"part": "contentDetails,snippet", "id": playlist_id,
|
"part": "contentDetails,snippet", "id": playlist_id,
|
||||||
"key": self.bot.config["google-api-key"]}).json()
|
"key": self.bot.config["google-api-key"]}).json()
|
||||||
def playlist_details(self, playlist_id):
|
def playlist_details(self, playlist_id):
|
||||||
|
@ -109,6 +114,8 @@ class Module(ModuleManager.BaseModule):
|
||||||
def _search_youtube(self, query):
|
def _search_youtube(self, query):
|
||||||
video_id = ""
|
video_id = ""
|
||||||
|
|
||||||
|
self.log.debug("youtube API request: search.list (A) [snippet]")
|
||||||
|
|
||||||
search_page = utils.http.request(URL_YOUTUBESEARCH,
|
search_page = utils.http.request(URL_YOUTUBESEARCH,
|
||||||
get_params={"q": query, "part": "snippet",
|
get_params={"q": query, "part": "snippet",
|
||||||
"maxResults": "1", "type": "video",
|
"maxResults": "1", "type": "video",
|
||||||
|
@ -144,6 +151,9 @@ class Module(ModuleManager.BaseModule):
|
||||||
if not url:
|
if not url:
|
||||||
safe_setting = event["target"].get_setting("youtube-safesearch", True)
|
safe_setting = event["target"].get_setting("youtube-safesearch", True)
|
||||||
safe = "moderate" if safe_setting else "none"
|
safe = "moderate" if safe_setting else "none"
|
||||||
|
|
||||||
|
self.log.debug("youtube API request: search.list (B) [snippet]")
|
||||||
|
|
||||||
search_page = utils.http.request(URL_YOUTUBESEARCH,
|
search_page = utils.http.request(URL_YOUTUBESEARCH,
|
||||||
get_params={"q": search, "part": "snippet", "maxResults": "1",
|
get_params={"q": search, "part": "snippet", "maxResults": "1",
|
||||||
"type": "video", "key": self.bot.config["google-api-key"],
|
"type": "video", "key": self.bot.config["google-api-key"],
|
||||||
|
|
Loading…
Reference in a new issue