cast JSON api values to string even when expecting string -- fixes #604

This commit is contained in:
Hazel Shanks 2020-12-11 18:32:38 +13:00 committed by Jim Miller
parent 81ec048517
commit 0f895205f6

View file

@ -282,7 +282,9 @@ class FictionLiveAdapter(BaseSiteAdapter):
text = ""
for chunk in data:
for count, chunk in enumerate(data):
# logger.debug(count) # pollutes the debug log, shows which chunk crashed the handler
text += "<div>" # chapter chunks aren't always well-delimited in their contents
@ -452,7 +454,7 @@ class FictionLiveAdapter(BaseSiteAdapter):
if index in x_outs:
crossed.append((index, choice_text, verified_votes, total_votes))
else:
output += "<tr class=\"choiceitem\"><td>" + choice_text + "</td><td class=\"votecount\">"
output += "<tr class=\"choiceitem\"><td>" + str(choice_text) + "</td><td class=\"votecount\">"
if verified_votes > 0:
output += "" + str(verified_votes) + "/"
output += str(total_votes)+ " </td></tr>\n"
@ -465,7 +467,7 @@ class FictionLiveAdapter(BaseSiteAdapter):
else:
x_reason = x_reasons[str(index)] if str(index) in x_reasons else ""
output += "<tr class=\"choiceitem\"><td colspan=\"2\"><small><strike>" \
+ choice_text + "</strike><br>" + x_reason + "</small></td></tr>"
+ str(choice_text) + "</strike><br>" + str(x_reason) + "</small></td></tr>"
output += "</table>\n"
@ -494,17 +496,17 @@ class FictionLiveAdapter(BaseSiteAdapter):
for uid, roll in dice.items():
output += '<div class="choiceitem">'
if roll: # optional. just because there's a list entry for it doesn't mean it has a value!
output += '<div class="dice">' + roll + '</div>\n'
output += '<div class="dice">' + str(roll) + '</div>\n'
if uid in posts:
post = posts[uid]
if post:
output += post
output += str(post)
del posts[uid] # it's handled here with the roll instead of later
output += '</div>'
for post in posts.values():
if post:
output += '<div class="choiceitem">' + post + '</div>\n'
output += '<div class="choiceitem">' + str(post) + '</div>\n'
return output
@ -520,9 +522,7 @@ class FictionLiveAdapter(BaseSiteAdapter):
### known bugs:
# BUG: chapters at the start of the story -- 'home' is often folded into the second chapter
# BUG: short stories can crash -- see crash-checker testing
# TODO: support chapter urls for single-chapter / chapter-range downloads
# complicated -- urls for getChapterText are API urls generated by add_chapters, not the public/website ones
# in particular, may need more API reversing to figure out how to get the *end* of the chunk range
# find in 'bm' in the metadata?