1717search_api_url = base_url + 'search?part=id&maxResults=1'
1818playlist_api_url = base_url + 'playlists?part=snippet%2CcontentDetails%2Cstatus'
1919video_url = "http://youtu.be/%s"
20- err_noapi = "The YouTube API is off in the Google Developers Console."
20+ err_no_api = "The YouTube API is off in the Google Developers Console."
2121
2222
2323def get_video_description (video_id , key ):
2424 json = requests .get (api_url .format (video_id , key )).json ()
2525
2626 if json .get ('error' ):
2727 if json ['error' ]['code' ] == 403 :
28- return err_noapi
28+ return err_no_api
2929 else :
3030 return
3131
@@ -41,14 +41,14 @@ def get_video_description(video_id, key):
4141
4242 length = isodate .parse_duration (content_details ['duration' ])
4343 out += ' - length \x02 {}\x02 ' .format (timeformat .format_time (int (length .total_seconds ()), simple = True ))
44- totalvotes = float (statistics ['likeCount' ]) + float (statistics ['dislikeCount' ])
44+ total_votes = float (statistics ['likeCount' ]) + float (statistics ['dislikeCount' ])
4545
46- if totalvotes != 0 :
46+ if total_votes != 0 :
4747 # format
4848 likes = pluralize (int (statistics ['likeCount' ]), "like" )
4949 dislikes = pluralize (int (statistics ['dislikeCount' ]), "dislike" )
5050
51- percent = 100 * float (statistics ['likeCount' ]) / totalvotes
51+ percent = 100 * float (statistics ['likeCount' ]) / total_votes
5252 out += ' - {}, {} (\x02 {:.1f}\x02 %)' .format (likes ,
5353 dislikes , percent )
5454
@@ -75,7 +75,7 @@ def load_key(bot):
7575
7676
7777@hook .regex (youtube_re )
78- def youtube_url (match , bot ):
78+ def youtube_url (match ):
7979 return get_video_description (match .group (1 ), dev_key )
8080
8181
@@ -89,7 +89,7 @@ def youtube(text):
8989
9090 if json .get ('error' ):
9191 if json ['error' ]['code' ] == 403 :
92- return err_noapi
92+ return err_no_api
9393 else :
9494 return 'Error performing search.'
9595
@@ -111,7 +111,7 @@ def youtime(text):
111111
112112 if json .get ('error' ):
113113 if json ['error' ]['code' ] == 403 :
114- return err_noapi
114+ return err_no_api
115115 else :
116116 return 'Error performing search.'
117117
@@ -154,7 +154,7 @@ def ytplaylist_url(match):
154154
155155 if json .get ('error' ):
156156 if json ['error' ]['code' ] == 403 :
157- return err_noapi
157+ return err_no_api
158158 else :
159159 return 'Error looking up playlist.'
160160
0 commit comments