log youtube API usage

This commit is contained in:
jesopo 2020-05-07 22:40:44 +01:00
parent 8d932ccc34
commit 4dc44720e8

View file

@ -24,6 +24,8 @@ ARROW_DOWN = "↓"
"Turn safe search off/on"))
class Module(ModuleManager.BaseModule):
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={
"part": "contentDetails,snippet,statistics",
"id": video_id, "key": self.bot.config["google-api-key"]}).json()
@ -76,6 +78,9 @@ class Module(ModuleManager.BaseModule):
return None
def get_playlist_page(self, playlist_id):
self.log.debug("youtube API request: "
"playlists.list [contentDetails,snippet]")
return utils.http.request(URL_YOUTUBEPLAYLIST, get_params={
"part": "contentDetails,snippet", "id": playlist_id,
"key": self.bot.config["google-api-key"]}).json()
@ -109,6 +114,8 @@ class Module(ModuleManager.BaseModule):
def _search_youtube(self, query):
video_id = ""
self.log.debug("youtube API request: search.list (A) [snippet]")
search_page = utils.http.request(URL_YOUTUBESEARCH,
get_params={"q": query, "part": "snippet",
"maxResults": "1", "type": "video",
@ -144,6 +151,9 @@ class Module(ModuleManager.BaseModule):
if not url:
safe_setting = event["target"].get_setting("youtube-safesearch", True)
safe = "moderate" if safe_setting else "none"
self.log.debug("youtube API request: search.list (B) [snippet]")
search_page = utils.http.request(URL_YOUTUBESEARCH,
get_params={"q": search, "part": "snippet", "maxResults": "1",
"type": "video", "key": self.bot.config["google-api-key"],