From 9e0a102355ea427655a4beafc3b666c7cc5b5b3d Mon Sep 17 00:00:00 2001 From: Andy Diamondstein Date: Fri, 27 Oct 2017 17:07:40 -0400 Subject: [PATCH] For list action, video may not have localizations --- python/video_localizations.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/python/video_localizations.py b/python/video_localizations.py index 3412923a..20778c8e 100644 --- a/python/video_localizations.py +++ b/python/video_localizations.py @@ -129,12 +129,14 @@ def list_video_localizations(youtube, args): id=args.video_id ).execute() - localizations = results['items'][0]['localizations'] - - for language, localization in localizations.iteritems(): - print ('Video title is \'%s\' and description is \'%s\' in language \'%s\'' - % (localization['title'], localization['description'], language)) - + if 'localizations' in results['items'][0]: + localizations = results['items'][0]['localizations'] + + for language, localization in localizations.iteritems(): + print ('Video title is \'%s\' and description is \'%s\' in language \'%s\'' + % (localization['title'], localization['description'], language)) + else: + print 'There aren\'t any localizations for this video yet.' if __name__ == '__main__': parser = argparse.ArgumentParser()