From 31bee48eb139164eafc35b35e12d67846672ba83 Mon Sep 17 00:00:00 2001 From: Andy Diamondstein Date: Fri, 27 Oct 2017 17:09:25 -0400 Subject: [PATCH] Handle error case For list action, the channel might not have localizations. --- python/channel_localizations.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/python/channel_localizations.py b/python/channel_localizations.py index 88a8fced..a244ca6d 100644 --- a/python/channel_localizations.py +++ b/python/channel_localizations.py @@ -118,11 +118,12 @@ def list_channel_localizations(youtube, channel_id): id=channel_id ).execute() - localizations = results['items'][0]['localizations'] - - for language, localization in localizations.iteritems(): - print 'Channel description is \'%s\' in language \'%s\'' % (localization['description'], language) - + if 'localizations' in results['items'][0]: + localizations = results['items'][0]['localizations'] + for language, localization in localizations.iteritems(): + print 'Channel description is \'%s\' in language \'%s\'' % (localization['description'], language) + else: + print 'There aren\'t any localizations for this channel yet.' if __name__ == '__main__': parser = argparse.ArgumentParser()