Skip to content

Commit

Permalink
Handle error case
Browse files Browse the repository at this point in the history
For list action, the channel might not have localizations.
  • Loading branch information
AndyDiamondstein committed Oct 27, 2017
1 parent 9e0a102 commit 31bee48
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions python/channel_localizations.py
Expand Up @@ -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()
Expand Down

0 comments on commit 31bee48

Please sign in to comment.