Fix for fimf images not including protocol in url.

This commit is contained in:
Jim Miller 2014-11-13 14:26:25 -06:00
parent 4139b9eba1
commit 6d492a2281
3 changed files with 7 additions and 14 deletions

View file

@ -318,10 +318,4 @@ class FimFictionNetSiteAdapter(BaseSiteAdapter):
if soup == None:
raise exceptions.FailedToDownload("Error downloading Chapter: %s! Missing required element!" % url)
# fix for img urls missing 'http:'
images = soup.findAll('img')
for imagetag in images:
if 'src' in imagetag.attrs and imagetag['src'].startswith('//'):
imagetag['src'] = "http:"+imagetag['src']
return self.utf8FromSoup(url,soup)

View file

@ -493,9 +493,8 @@ class BaseSiteAdapter(Configurable):
for img in soup.findAll('img'):
# some pre-existing epubs have img tags that had src stripped off.
if img.has_key('src'):
img['longdesc']=img['src']
img['src']=self.story.addImgUrl(url,img['src'],fetch,
coverexclusion=self.getConfig('cover_exclusion_regexp'))
(img['src'],img['longdesc'])=self.story.addImgUrl(url,img['src'],fetch,
coverexclusion=self.getConfig('cover_exclusion_regexp'))
for attr in soup._getAttrMap().keys():
if attr not in acceptable_attributes:

View file

@ -741,7 +741,7 @@ class Story(Configurable):
# otherwise it saves the image in the epub even though it
# isn't used anywhere.
if cover and self.getConfig('never_make_cover'):
return
return (None,None)
url = url.strip() # ran across an image with a space in the
# src. Browser handled it, so we'd better, too.
@ -749,7 +749,7 @@ class Story(Configurable):
# appengine (web version) isn't allowed to do images--just
# gets too big too fast and breaks things.
if is_appengine:
return
return (None,None)
if url.startswith("http") or url.startswith("file") or parenturl == None:
imgurl = url
@ -782,7 +782,7 @@ class Story(Configurable):
# apply coverexclusion to explicit covers, too. Primarily for ffnet imageu.
if cover and coverexclusion and re.search(coverexclusion,imgurl):
return
return (None,None)
prefix='ffdl'
if imgurl not in self.imgurls:
@ -812,7 +812,7 @@ class Story(Configurable):
background="#"+self.getConfig('background_color'))
except Exception, e:
logger.info("Failed to load or convert image, skipping:\n%s\nException: %s"%(imgurl,e))
return "failedtoload"
return ("failedtoload","failedtoload")
# explicit cover, make the first image.
if cover:
@ -852,7 +852,7 @@ class Story(Configurable):
#print("===============\n%s\nimg url:%s\n============"%(newsrc,self.imgurls[-1]))
return newsrc
return (newsrc, imgurl)
def getImgUrls(self):
retlist = []