Skip to content

Commit

Permalink
[YouTube]Remove 'something went wrong' error, print the correct varia…
Browse files Browse the repository at this point in the history
…ble.
  • Loading branch information
tyrope committed May 21, 2014
1 parent f9b9559 commit 29a385d
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,18 @@ def setup(bot):


def ytget(bot, trigger, uri):
try:
bytes = web.get(uri)
result = json.loads(bytes)
if 'feed' in result:
try:
video_entry = result['feed']['entry'][0]
except KeyError:
#Issue 544, caused by searches with a hyphen.
bot.say('Something went wrong when reading YouTube '+
'API data.')
bot.debug('YT','Search result from %s: %s' %
(trigger.sender, video_entry), 'info')
return 'err'
else:
video_entry = result['entry']
except:
bot.say('Something went wrong when accessing the YouTube API.')
return 'err'
bytes = web.get(uri)
result = json.loads(bytes)
if 'feed' in result:
try:
video_entry = result['feed']['entry'][0]
except KeyError:
#Issue 544, caused by searches with a hyphen.
bot.debug('YT','Search result from %s: %s' %
(trigger.sender, result['feed']), 'info')
raise
else:
video_entry = result['entry']
vid_info = {}
try:
# The ID format is tag:youtube.com,2008:video:RYlCVwxoL_g
Expand Down

0 comments on commit 29a385d

Please sign in to comment.