Skip to content
This repository has been archived by the owner on Aug 26, 2020. It is now read-only.

Commit

Permalink
Broaden parsing exception, and a JSON tweak.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyvisser committed Feb 21, 2011
1 parent 115bbd4 commit 7858a14
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions iview/parser.py
Expand Up @@ -101,14 +101,14 @@ def parse_series_items(soup, get_meta=False):

items = []

for item in series_json[0]['f']:
for optional_key in ('d', 'r', 's', 'l'):
try:
item[optional_key]
except KeyError:
item[optional_key] = ''

try:
try:
for item in series_json[0]['f']:
for optional_key in ('d', 'r', 's', 'l'):
try:
item[optional_key]
except KeyError:
item[optional_key] = ''

items.append({
'id' : item['a'],
'title' : item['b'].replace('&', '&'), # HACK. See comment in parse_index()
Expand All @@ -119,14 +119,14 @@ def parse_series_items(soup, get_meta=False):
'date' : item['f'],
'home' : item['l'], # program website
})
except KeyError:
print 'An item we parsed had some missing info, so we skipped an episode. Maybe the ABC changed their API recently?'
except KeyError:
print 'An item we parsed had some missing info, so we skipped an episode. Maybe the ABC changed their API recently?'

if get_meta:
meta = {
'id' : series_json['a'],
'title' : series_json['b'],
'thumb' : series_json['d'],
'id' : series_json[0]['a'],
'title' : series_json[0]['b'],
'thumb' : series_json[0]['d'],
}
return (items, meta)
else:
Expand Down

0 comments on commit 7858a14

Please sign in to comment.