Add twilighted.net(not com) to downaloder.py so it actually *works*. Add one-shot support for twilighted.net.

This commit is contained in:
retiefjimm
2010-09-28 19:52:30 -05:00
parent 3be9b3331e
commit 9434431c7b
2 changed files with 12 additions and 7 deletions
+2 -1
View File
@@ -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
+10 -6
View File
@@ -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