diff --git a/downaloder.py b/downaloder.py index de93c79..e16dab4 100644 --- a/downaloder.py +++ b/downaloder.py @@ -20,6 +20,7 @@ import output import adapter import fictionalley import hpfiction +import twilighted import time @@ -88,7 +89,7 @@ if __name__ == '__main__': adapter = ffnet.FFNet(url) elif url.find('harrypotterfanfiction.com') != -1: adapter = hpfiction.HPFiction(url) - elif url.find('twilighted.com') != -1: + elif url.find('twilighted.net') != -1: adapter = twilighted.Twilighted(url) else: print >> sys.stderr, "Oi! I can haz not appropriate adapter for URL %s!" % url diff --git a/twilighted.py b/twilighted.py index 54ff35d..03bb08c 100644 --- a/twilighted.py +++ b/twilighted.py @@ -74,13 +74,17 @@ class Twilighted(FanfictionSiteAdapter): self.authorName = title.split(' by ')[1].strip() select = soup.find('select', { 'name' : 'chapter' } ) - - allOptions = select.findAll('option') + result = [] - for o in allOptions: - url = self.url + "&chapter=%s" % o['value'] - title = o.string - result.append((url,title)) + if select is None: + # no chapters found, try url by itself. + result.append((self.url,self.storyName)) + else: + allOptions = select.findAll('option') + for o in allOptions: + url = self.url + "&chapter=%s" % o['value'] + title = o.string + result.append((url,title)) return result