diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 064a6064d..60b515f88 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -236,8 +236,20 @@ class BGExtract(object): while found_count < verse_count: content = content.findNext(u'sup', u'versenum') raw_verse_num = content.next - raw_verse_text = raw_verse_num.next - verse_list[int(str(raw_verse_num))] = unicode(raw_verse_text) + clean_verse_num = 0 + # Not all verses exist in all translations and may or may not be + # represented by a verse number. If they are not fine, if they are + # it will probably be in a format that breaks int(). We will then + # have no idea what garbage may be sucked in to the verse text so + # if we do not get a clean int() then ignore the verse completely. + try: + clean_verse_num = int(str(raw_verse_num)) + except ValueError: + log.exception(u'Illegal verse number in %s %s %s:%s', + version, bookname, chapter, unicode(raw_verse_num)) + if clean_verse_num: + raw_verse_text = raw_verse_num.next + verse_list[clean_verse_num] = unicode(raw_verse_text) found_count += 1 return SearchResults(bookname, chapter, verse_list)