Skip to content

Commit

Permalink
handle possible IndexError when trying to get channel id of 'mine'
Browse files Browse the repository at this point in the history
  • Loading branch information
anxdpanic committed Feb 29, 2020
1 parent 63e35e7 commit ed1e160
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions resources/lib/youtube_plugin/youtube/helper/resource_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,17 @@ def _update_channels(self, channel_ids):
if channel_id == 'mine':
json_data = function_cache.get(FunctionCache.ONE_DAY, self._youtube_client.get_channel_by_username, channel_id)
items = json_data.get('items', [{'id': 'mine'}])
channel_id = items[0]['id']

try:
channel_id = items[0]['id']
except IndexError:
self._context.log_debug('Channel "mine" not found: %s' % json_data)
channel_id = None

json_data = dict()
updated_channel_ids.append(channel_id)

if channel_id:
updated_channel_ids.append(channel_id)

channel_ids = updated_channel_ids

Expand Down

0 comments on commit ed1e160

Please sign in to comment.