diff --git a/willie/modules/youtube.py b/willie/modules/youtube.py index 1e534bdf9d..1d8e6c9b94 100644 --- a/willie/modules/youtube.py +++ b/willie/modules/youtube.py @@ -45,18 +45,18 @@ def ytget(willie, trigger, uri): vid_id = video_entry['id']['$t'].split(':') vid_id = vid_id[len(vid_id)-1] #last item is the actual ID vid_info['link'] = 'http://youtu.be/' + vid_id - except AttributeError as e: + except KeyError as e: vid_info['link'] = 'N/A' try: vid_info['title'] = video_entry['title']['$t'] - except AttributeError as e: + except KeyError as e: vid_info['title'] = 'N/A' #get youtube channel try: vid_info['uploader'] = video_entry['author'][0]['name']['$t'] - except AttributeError as e: + except KeyError as e: vid_info['uploader'] = 'N/A' #get upload time in format: yyyy-MM-ddThh:mm:ss.sssZ @@ -66,7 +66,7 @@ def ytget(willie, trigger, uri): vid_info['uploaded'] = '%s/%s/%s, %s:%s' % (upraw[8:10], upraw[5:7], upraw[0:4], upraw[11:13], upraw[14:16]) - except AttributeError as e: + except KeyError as e: vid_info['uploaded'] = 'N/A' #get duration in seconds @@ -90,33 +90,33 @@ def ytget(willie, trigger, uri): vid_info['length'] = vid_info['length'] + ' ' if seconds: vid_info['length'] = vid_info['length'] + str(seconds) + 'secs' - except AttributeError as e: + except KeyError as e: vid_info['length'] = 'N/A' #get views try: views = video_entry['yt$statistics']['viewCount'] vid_info['views'] = str('{0:20,d}'.format(int(views))).lstrip(' ') - except AttributeError as e: + except KeyError as e: vid_info['views'] = 'N/A' #get comment count try: comments = video_entry['gd$comments']['gd$feedLink']['countHint'] vid_info['comments'] = str('{0:20,d}'.format(int(comments))).lstrip(' ') - except AttributeError as e: + except KeyError as e: vid_info['comments'] = 'N/A' #get likes & dislikes try: likes = video_entry['yt$rating']['numLikes'] vid_info['likes'] = str('{0:20,d}'.format(int(likes))).lstrip(' ') - except AttributeError as e: + except KeyError as e: vid_info['likes'] = 'N/A' try: dislikes = video_entry['yt$rating']['numDislikes'] vid_info['dislikes'] = str('{0:20,d}'.format(int(dislikes))).lstrip(' ') - except AttributeError as e: + except KeyError as e: vid_info['dislikes'] = 'N/A' return vid_info