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

Commit

Permalink
Properly process binary tags
Browse files Browse the repository at this point in the history
  • Loading branch information
rupor-github committed May 13, 2018
1 parent 7509421 commit d6ad5fb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion fb2mobi.py
Expand Up @@ -92,7 +92,10 @@ def rm_tmp_files(dest, deleteroot=True):
os.rmdir(os.path.join(root, name))

if deleteroot:
os.rmdir(dest)
try:
os.rmdir(dest)
except:
pass


def process_file(config, infile, outfile=None):
Expand Down Expand Up @@ -564,6 +567,8 @@ def process(myargs):
if myargs.transliterateauthorandtitle is not None:
config.transliterate_author_and_title = myargs.transliterateauthorandtitle

config.log.info(' ')
config.log.info('**********************************************')
config.log.info('Using configuration "{0}".'.format(config_file))

if myargs.inputdir:
Expand Down
6 changes: 3 additions & 3 deletions modules/fb2html.py
Expand Up @@ -593,11 +593,11 @@ def parse_description(self, elem):
self.book_date = etree.tostring(t, method='text', encoding='utf-8').decode('utf-8').strip()

def parse_binary(self, elem):
if elem.attrib['id'] and elem.attrib['content-type']:
have_file = False
if 'id' in elem.attrib:
self.log.debug('Parsing binary {0}'.format(elem.attrib))
have_file = False
elid = elem.attrib['id']
decl_type = elem.attrib['content-type'].lower()
decl_type = elem.attrib['content-type'].lower() if 'content-type' in elem.attrib else '---empty---'
buff = base64.b64decode(elem.text.encode('ascii'))
try:
img = Image.open(io.BytesIO(buff))
Expand Down
2 changes: 1 addition & 1 deletion version.py
Expand Up @@ -4,4 +4,4 @@

WINDOWS = sys.platform == 'win32'

VERSION = u'3.6.59'
VERSION = u'3.6.60'

0 comments on commit d6ad5fb

Please sign in to comment.