diff --git a/sites/fictionlive.py b/sites/fictionlive.py
index 280204e..9d23f9d 100644
--- a/sites/fictionlive.py
+++ b/sites/fictionlive.py
@@ -52,28 +52,40 @@ class FictionLive(Site):
updated = max(updated, segment['ct'])
# TODO: work out if this is actually enough types handled
# There's at least also a reader post type, which mostly seems to be used for die rolls.
- if segment['nt'] == 'chapter':
- html.extend(('
', segment['b'].replace('
', '
'), '
'))
- elif segment['nt'] == 'choice':
- if 'votes' not in segment:
- # Somehow, sometime, we end up with a choice without votes (or choices)
- continue
- votes = {}
- for vote in segment['votes']:
- votechoices = segment['votes'][vote]
- if type(votechoices) == int:
- votechoices = (votechoices,)
- for choice in votechoices:
- if int(choice) < len(segment['choices']):
- # sometimes someone has voted for a presumably-deleted choice
- choice = segment['choices'][int(choice)]
- votes[choice] = votes.get(choice, 0) + 1
- choices = [(votes[v], v) for v in votes]
- choices.sort(reverse=True)
- html.append('
')
- for votecount, choice in choices:
- html.append(f'- {choice}: {votecount}
')
- html.append('
')
+ try:
+ if segment['nt'] == 'chapter':
+ html.extend(('', segment['b'].replace('
', '
'), '
'))
+ elif segment['nt'] == 'choice':
+ if 'votes' not in segment:
+ # Somehow, sometime, we end up with a choice without votes (or choices)
+ continue
+ votes = {}
+ for vote in segment['votes']:
+ votechoices = segment['votes'][vote]
+ if type(votechoices) == str:
+ # This caused issue #30, where for some reason one
+ # choice on a story was a string rather than an
+ # index into the choices array.
+ continue
+ if type(votechoices) == int:
+ votechoices = (votechoices,)
+ for choice in votechoices:
+ if int(choice) < len(segment['choices']):
+ # sometimes someone has voted for a presumably-deleted choice
+ choice = segment['choices'][int(choice)]
+ votes[choice] = votes.get(choice, 0) + 1
+ choices = [(votes[v], v) for v in votes]
+ choices.sort(reverse=True)
+ html.append('
')
+ for votecount, choice in choices:
+ html.append(f'- {choice}: {votecount}
')
+ html.append('
')
+ elif segment['nt'] == 'readerPost':
+ pass
+ else:
+ logger.info("Skipped chapter-segment of unhandled type: %s", segment['nt'])
+ except Exception as e:
+ logger.error("Skipped chapter-segment due to parsing error", exc_info=e)
story.add(Chapter(
title=currc['title'],