Skip to content

Commit 6ae05f7

Browse files
author
Foxlet
committed
Better Messages for YouTube and Translate
1 parent faef1b6 commit 6ae05f7

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

plugins/google_translate.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@ def goog_trans(api_key, text, source, target):
2525
request = requests.get(url, params=params)
2626
parsed = request.json()
2727

28-
if 'error' in parsed:
29-
return "Google API error."
28+
if parsed.get('error'):
29+
if parsed['error']['code'] == 403:
30+
return "The Translate API is off in the Google Developers Console."
31+
else:
32+
return "Google API error."
3033

3134
if not source:
3235
return '(%(detectedSourceLanguage)s) %(translatedText)s' % (parsed['data']['translations'][0])

plugins/youtube.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
search_api_url = base_url + 'search?part=id&maxResults=1'
1818
playlist_api_url = base_url + 'playlists?part=snippet%2CcontentDetails%2Cstatus'
1919
video_url = "http://youtu.be/%s"
20-
err_noapi = "You did not turn on the Youtube API in the Google Developers Console."
20+
err_noapi = "The YouTube API is off in the Google Developers Console."
2121

2222

2323
def get_video_description(video_id, key):

0 commit comments

Comments
 (0)