diff --git a/fanficdownloader/adapters/base_adapter.py b/fanficdownloader/adapters/base_adapter.py index 0d3f7d82..b530daa5 100644 --- a/fanficdownloader/adapters/base_adapter.py +++ b/fanficdownloader/adapters/base_adapter.py @@ -284,8 +284,10 @@ class BaseSiteAdapter(Configurable): if self.getConfig('include_images'): acceptable_attributes.extend(('src','alt','longdesc')) for img in soup.findAll('img'): - img['longdesc']=img['src'] - img['src']=self.story.addImgUrl(self,url,img['src'],fetch) + # some pre-existing epubs have img tags that had src stripped off. + if 'src' in img: + img['longdesc']=img['src'] + img['src']=self.story.addImgUrl(self,url,img['src'],fetch) for attr in soup._getAttrMap().keys(): if attr not in acceptable_attributes: diff --git a/fanficdownloader/epubutils.py b/fanficdownloader/epubutils.py index 27d5257c..8fcf30f1 100644 --- a/fanficdownloader/epubutils.py +++ b/fanficdownloader/epubutils.py @@ -56,6 +56,8 @@ def get_update_data(inputio, if getsoups: soup = bs.BeautifulSoup(epub.read(href).decode("utf-8")) for img in soup.findAll('img'): + newsrc='' + longdesc='' try: newsrc=get_path_part(href)+img['src'] # remove all .. and the path part above it, if present.