diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini
index a1b7ad2..7a42a3a 100644
--- a/calibre-plugin/plugin-defaults.ini
+++ b/calibre-plugin/plugin-defaults.ini
@@ -1117,8 +1117,6 @@ extracategories:West Wing
## Site dedicated to these categories/characters/ships
extracategories:NCIS
-[netraptor.org]
-
[nfacommunity.com]
## Some sites do not require a login, but do require the user to
## confirm they are adult for adult content. In commandline version,
@@ -1280,10 +1278,6 @@ reviews_label:Reviews
extracharacters:Spike,Buffy
extracategories:Buffy the Vampire Slayer
-[stargate-atlantis.org]
-## Site dedicated to these categories/characters/ships
-extracategories:Stargate: Atlantis
-
[storiesonline.net]
## Some sites require login (or login for some rated stories) The
## program can prompt you, or you can save it in config. In
@@ -1471,17 +1465,6 @@ extraships:Draco Malfoy/Ginny Weasley
## Site dedicated to these categories/characters/ships
extracategories:Stargate: SG-1
-[www.checkmated.com]
-## Some sites require login (or login for some rated stories) The
-## program can prompt you, or you can save it in config. In
-## commandline version, this should go in your personal.ini, not
-## defaults.ini.
-#username:YourName
-#password:yourpassword
-
-## Site dedicated to these categories/characters/ships
-extracategories:Harry Potter
-
[www.destinysgateway.com]
## Some sites do not require a login, but do require the user to
## confirm they are adult for adult content. In commandline version,
@@ -1501,14 +1484,6 @@ extracategories:InuYasha
extracharacters:Sesshoumaru,Kagome
extraships:Sesshoumaru/Kagome
-[www.dotmoon.net]
-## Some sites require login (or login for some rated stories) The
-## program can prompt you, or you can save it in config. In
-## commandline version, this should go in your personal.ini, not
-## defaults.ini.
-#username:YourName
-#password:yourpassword
-
[www.efpfanfic.net]
## Some sites require login (or login for some rated stories) The
## program can prompt you, or you can save it in config. In
@@ -1683,10 +1658,6 @@ make_linkhtml_entries:prequel,sequels,groups,coverSource
## Site dedicated to these categories/characters/ships
extracategories:Harry Potter
-[www.henneth-annun.net]
-## Site dedicated to these categories/characters/ships
-extracategories:The Hobbit
-
[www.hpfandom.net]
## Some sites do not require a login, but do require the user to
## confirm they are adult for adult content. In commandline version,
@@ -1822,17 +1793,6 @@ extragenres:Erotica
extracategories:Glee
extracharacters:Kurt Hummel,Blaine Anderson
-[www.simplyundeniable.com]
-## Some sites require login (or login for some rated stories) The
-## program can prompt you, or you can save it in config. In
-## commandline version, this should go in your personal.ini, not
-## defaults.ini.
-#username:YourName
-#password:yourpassword
-
-## Site dedicated to these categories/characters/ships
-extracategories:Harry Potter
-
[www.sinful-desire.org]
## Some sites do not require a login, but do require the user to
## confirm they are adult for adult content. In commandline version,
@@ -1924,20 +1884,6 @@ extracategories:Twilight
## twilighted.net (ab)uses series as personal reading lists.
collect_series: false
-[www.twiwrite.net]
-## Some sites require login (or login for some rated stories) The
-## program can prompt you, or you can save it in config. In
-## commandline version, this should go in your personal.ini, not
-## defaults.ini.
-#username:YourName
-#password:yourpassword
-
-## Site dedicated to these categories/characters/ships
-extracategories:Twilight
-
-## twiwrite.net (ab)uses series as personal reading lists.
-collect_series: false
-
[www.walkingtheplank.org]
## Some sites do not require a login, but do require the user to
## confirm they are adult for adult content. In commandline version,
@@ -1951,19 +1897,6 @@ extraships:Severus Snape/Harry Potter
[www.whofic.com]
-[www.wizardtales.net]
-## Some sites require login (or login for some rated stories) The
-## program can prompt you, or you can save it in config. In
-## commandline version, this should go in your personal.ini, not
-## defaults.ini.
-#username:YourName
-#password:yourpassword
-
-## Some sites also require the user to confirm they are adult for
-## adult content. In commandline version, this should go in your
-## personal.ini, not defaults.ini.
-#is_adult:true
-
[www.wolverineandrogue.com]
## Site dedicated to these categories/characters/ships
extracategories:X-Men Movie
diff --git a/calibre-plugin/plugin-example.ini b/calibre-plugin/plugin-example.ini
index 4f1b4dd..1de7613 100644
--- a/calibre-plugin/plugin-example.ini
+++ b/calibre-plugin/plugin-example.ini
@@ -76,12 +76,6 @@
#username:YourUsername
#password:YourPassword
-[www.twiwrite.net]
-#username:YourName
-#password:yourpassword
-## default is false
-#collect_series: true
-
[www.adastrafanfic.com]
## Some sites do not require a login, but do require the user to
## confirm they are adult for adult content.
diff --git a/fanficfare/adapters/__init__.py b/fanficfare/adapters/__init__.py
index 127d5b7..3faca9f 100644
--- a/fanficfare/adapters/__init__.py
+++ b/fanficfare/adapters/__init__.py
@@ -42,7 +42,6 @@ import adapter_adastrafanficcom
import adapter_twcslibrarynet
import adapter_tthfanficorg
import adapter_twilightednet
-import adapter_twiwritenet
import adapter_whoficcom
import adapter_siyecouk
import adapter_archiveofourownorg
@@ -58,7 +57,6 @@ import adapter_archiveskyehawkecom
import adapter_squidgeorgpeja
import adapter_libraryofmoriacom
import adapter_wraithbaitcom
-import adapter_checkmatedcom
import adapter_chaossycophanthexcom
import adapter_dramioneorg
import adapter_erosnsapphosycophanthexcom
@@ -75,7 +73,6 @@ import adapter_storiesofardacom
import adapter_samdeanarchivenu
import adapter_destinysgatewaycom
import adapter_ncisfictionnet
-import adapter_stargateatlantisorg
import adapter_thealphagatecom
import adapter_fanfiktionde
import adapter_ponyfictionarchivenet
@@ -88,7 +85,6 @@ import adapter_darksolaceorg
import adapter_finestoriescom
import adapter_hpfanficarchivecom
import adapter_twilightarchivescom
-import adapter_wizardtalesnet
import adapter_nhamagicalworldsus
import adapter_hlfictionnet
import adapter_grangerenchantedcom
@@ -105,19 +101,15 @@ import adapter_qafficcom
import adapter_efpfanficnet
import adapter_potterficscom
import adapter_efictionestelielde
-import adapter_dotmoonnet
import adapter_pommedesangcom
import adapter_restrictedsectionorg
import adapter_imagineeficcom
import adapter_buffynfaithnet
import adapter_psychficcom
-import adapter_hennethannunnet
import adapter_tokrafandomnetcom
-import adapter_netraptororg
import adapter_asr3slashzoneorg
import adapter_nickandgregnet
import adapter_potterheadsanonymouscom
-import adapter_simplyundeniablecom
import adapter_scarheadnet
import adapter_fictionpadcom
import adapter_storiesonlinenet
diff --git a/fanficfare/adapters/adapter_checkmatedcom.py b/fanficfare/adapters/adapter_checkmatedcom.py
deleted file mode 100644
index 7083710..0000000
--- a/fanficfare/adapters/adapter_checkmatedcom.py
+++ /dev/null
@@ -1,238 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Copyright 2011 Fanficdownloader team, 2015 FanFicFare team
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-import time
-import logging
-logger = logging.getLogger(__name__)
-import re
-import urllib2
-
-from .. import BeautifulSoup as bs
-from ..htmlcleanup import stripHTML
-from .. import exceptions as exceptions
-
-from base_adapter import BaseSiteAdapter, makeDate
-
-
-def getClass():
- return CheckmatedComAdapter
-
-
-class CheckmatedComAdapter(BaseSiteAdapter):
-
- def __init__(self, config, url):
- BaseSiteAdapter.__init__(self, config, url)
-
- self.decode = ["Windows-1252",
- "utf8"] # 1252 is a superset of iso-8859-1.
- # Most sites that claim to be
- # iso-8859-1 (and some that claim to be
- # utf8) are really windows-1252.
- self.username = "" # if left empty, site doesn't return any message at all.
- self.password = ""
- self.is_adult=False
-
- # get storyId from url--url validation guarantees query is only sid=1234
- self.story.setMetadata('storyId',self.parsedUrl.query.split('=',)[1])
-
-
- self._setURL('http://' + self.getSiteDomain() + '/story.php?story='+self.story.getMetadata('storyId'))
-
- # Each adapter needs to have a unique site abbreviation.
- self.story.setMetadata('siteabbrev','chm')
-
- # The date format will vary from site to site.
- # http://docs.python.org/library/datetime.html#strftime-strptime-behavior
- self.dateformat = "%b %d, %Y"
-
- @staticmethod # must be @staticmethod, don't remove it.
- def getSiteDomain():
- # The site domain. Does have www here, if it uses it.
- return 'www.checkmated.com'
-
- @classmethod
- def getSiteExampleURLs(cls):
- return "http://"+cls.getSiteDomain()+"/story.php?story=1234"
-
- def getSiteURLPattern(self):
- return re.escape("http://"+self.getSiteDomain()+"/story.php?story=")+r"\d+$"
-
- ## Login seems to be reasonably standard across eFiction sites. This story is in The Bedchamber
- def needToLoginCheck(self, data):
- if 'This story is in The Bedchamber' in data \
- or 'That username is not in our database' in data \
- or "That password is not correct, please try again" in data:
- return True
- else:
- return False
-
- def performLogin(self, url):
- params = {}
-
- if self.password:
- params['name'] = self.username
- params['pass'] = self.password
- else:
- params['name'] = self.getConfig("username")
- params['pass'] = self.getConfig("password")
- params['login'] = 'yes'
- params['submit'] = 'login'
-
- loginUrl = 'http://' + self.getSiteDomain()+'/login.php'
- d = self._fetchUrl(loginUrl,params)
- e = self._fetchUrl(url)
-
- if "Welcome back," not in d : #Member Account
- logger.info("Failed to login to URL %s as %s" % (loginUrl,
- params['name']))
- raise exceptions.FailedToLogin(url,params['name'])
- return False
- elif "This story is in The Bedchamber" in e:
- raise exceptions.FailedToDownload(self.getSiteDomain() +" says: Your account does not have sufficient priviliges to read this story.")
- return False
- else:
- return True
-
-
- ## Getting the chapter list and the meta data, plus 'is adult' checking.
- def extractChapterUrlsAndMetadata(self):
-
- # index=1 makes sure we see the story chapter index. Some
- # sites skip that for one-chapter stories.
- url = self.url
- logger.debug("URL: "+url)
-
- try:
- data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
- if e.code == 404:
- raise exceptions.StoryDoesNotExist(self.url)
- else:
- raise e
-
- if self.needToLoginCheck(data):
- # need to log in for this one.
- self.performLogin(url)
- data = self._fetchUrl(url)
-
- # The actual text that is used to announce you need to be an
- # adult varies from site to site. Again, print data before
- # the title search to troubleshoot.
-
- if "Access denied. This story has not been validated by the adminstrators of this site." in data:
- raise exceptions.FailedToDownload(self.getSiteDomain() +" says: Access denied. This story has not been validated by the adminstrators of this site.")
-
- # use BeautifulSoup HTML parser to make everything easier to find.
- soup = bs.BeautifulSoup(data)
- # print data
-
- # Now go hunting for all the meta data and the chapter list.
-
- ## Title
- a = soup.find('span', {'class' : 'storytitle'})
- self.story.setMetadata('title',stripHTML(a))
-
- # Find authorid and URL from... author url.
- a = a.parent.find('a', href=re.compile(r"authors.php\?name\=\w+"))
- self.story.setMetadata('authorId',a['href'].split('=')[1])
- self.story.setMetadata('authorUrl','http://'+self.host+'/'+a['href'])
- self.story.setMetadata('author',a.string)
-
- a = soup.find('select', {'name' : 'chapter'})
- if a == None:
- self.chapterUrls.append((self.story.getMetadata('title'),url))
- else:
- for chapter in a.findAll('option'):
- self.chapterUrls.append((stripHTML(chapter),'http://'+self.host+'/story.php?story='+self.story.getMetadata('storyId')+'&chapter='+chapter['value']))
-
- self.story.setMetadata('numChapters',len(self.chapterUrls))
-
- # eFiction sites don't help us out a lot with their meta data
- # formating, so it's a little ugly.
-
- # utility method
- def defaultGetattr(d,k):
- try:
- return d[k]
- except:
- return ""
-
-
- # website does not keep track of word count, and there is no convenient way to calculate it
-
- summary = soup.find('fieldset')
- summary.find('legend').extract()
- summary.name='div'
- self.setDescription(url,summary)
-
-
- # Rated: NC-17
etc
- table = soup.findAll('div', {'class' : 'text'})[1]
- for labels in table.findAll('tr'):
- value = labels.findAll('td')[1]
- label = labels.findAll('td')[0]
-
-
- if 'Rating' in stripHTML(label):
- self.story.setMetadata('rating', stripHTML(value))
-
- if 'Ship' in stripHTML(label):
- if value.string != "none/none":
- self.story.addToList('ships',value.string)
- for char in value.string.split('/'):
- if char != 'none':
- self.story.addToList('characters',char)
-
- if 'Status' in stripHTML(label):
- if value.find('img', {'src' : 'img/incomplete.gif'}) == None:
- self.story.setMetadata('status', 'Completed')
- else:
- self.story.setMetadata('status', 'In-Progress')
-
- if 'Published' in stripHTML(label):
- self.story.setMetadata('datePublished', makeDate(stripHTML(value), self.dateformat))
-
- if 'Updated' in stripHTML(label):
- self.story.setMetadata('dateUpdated', makeDate(stripHTML(value), self.dateformat))
-
- a = self._fetchUrl(self.story.getMetadata('authorUrl')+'&cat=stories')
- for story in bs.BeautifulSoup(a).findAll('table', {'class' : 'storyinfo'}):
- a = story.find('a', href=re.compile(r"review.php\?s\="+self.story.getMetadata('storyId')+'&act=view'))
- if a != None:
- for labels in story.findAll('tr'):
- value = labels.findAll('td')[1]
- label = labels.findAll('td')[0]
- if 'genre' in stripHTML(label):
- for genre in value.findAll('img'):
- self.story.addToList('genre',genre['title'])
-
-
- # grab the text for an individual chapter.
- def getChapterText(self, url):
-
- logger.debug('Getting chapter text from: %s' % url)
-
- soup = bs.BeautifulSoup(self._fetchUrl(url),
- selfClosingTags=('br','hr')) # otherwise soup eats the br/hr tags.
-
- div = soup.find('div', {'id' : 'resizeableText'})
- div.find('div', {'class' : 'storyTools'}).extract()
-
- if None == div:
- raise exceptions.FailedToDownload("Error downloading Chapter: %s! Missing required element!" % url)
-
- return self.utf8FromSoup(url,div)
diff --git a/fanficfare/adapters/adapter_dotmoonnet.py b/fanficfare/adapters/adapter_dotmoonnet.py
deleted file mode 100644
index bb72082..0000000
--- a/fanficfare/adapters/adapter_dotmoonnet.py
+++ /dev/null
@@ -1,217 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Copyright 2013 Fanficdownloader team, 2015 FanFicFare team
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-import time
-import logging
-logger = logging.getLogger(__name__)
-import re
-import urllib2
-
-from .. import BeautifulSoup as bs
-from ..htmlcleanup import stripHTML
-from .. import exceptions as exceptions
-
-from base_adapter import BaseSiteAdapter, makeDate
-
-def getClass():
- return DotMoonNetAdapter
-
-# Class name has to be unique. Our convention is camel case the
-# sitename with Adapter at the end. www is skipped.
-class DotMoonNetAdapter(BaseSiteAdapter):
-
- def __init__(self, config, url):
- BaseSiteAdapter.__init__(self, config, url)
-
- self.decode = ["Windows-1252",
- "utf8"] # 1252 is a superset of iso-8859-1.
- # Most sites that claim to be
- # iso-8859-1 (and some that claim to be
- # utf8) are really windows-1252.
- self.username = "NoneGiven" # if left empty, site doesn't return any message at all.
- self.password = ""
- self.is_adult=False
-
- # get storyId from url--url validation guarantees query is only sid=1234
- self.story.setMetadata('storyId',self.parsedUrl.query.split('=',)[1])
-
-
- # normalized story URL. www.dotmoon.net/library_view.php?storyid=3
- self._setURL('http://' + self.getSiteDomain() + '/library_view.php?storyid='+self.story.getMetadata('storyId'))
-
- # Each adapter needs to have a unique site abbreviation.
- self.story.setMetadata('siteabbrev','dotm')
-
- # The date format will vary from site to site.
- # http://docs.python.org/library/datetime.html#strftime-strptime-behavior
- self.dateformat = "%Y-%m-%d"
-
- @staticmethod # must be @staticmethod, don't remove it.
- def getSiteDomain():
- # The site domain. Does have www here, if it uses it.
- return 'www.dotmoon.net'
-
- @classmethod
- def getSiteExampleURLs(cls):
- return "http://"+cls.getSiteDomain()+"/library_view.php?storyid=1234"
-
- def getSiteURLPattern(self):
- return re.escape("http://"+self.getSiteDomain()+"/library_view.php?storyid=")+r"\d+$"
-
- ## Login seems to be reasonably standard across eFiction sites.
- def needToLoginCheck(self, data):
- if 'You must be logged in to read adult-rated stories' in data \
- or 'Password incorrect' in data \
- or "That username does not exist" in data:
- return True
- else:
- return False
-
- def performLogin(self, url):
- params = {}
-
- if self.password:
- params['user'] = self.username
- params['passwrd'] = self.password
- else:
- params['user'] = self.getConfig("username")
- params['passwrd'] = self.getConfig("password")
-
- loginUrl = 'http://' + self.getSiteDomain() + '/board/index.php'
-
- logger.debug("Will now login to URL (%s) as (%s)" % (loginUrl,
- params['user']))
-
- d = self._fetchUrl(loginUrl+'?action=login2&user='+params['user']+'&passwrd='+params['passwrd'])
- d = self._fetchUrl(loginUrl)
-
- if "Show unread posts since last visit" not in d : #Member Account
- logger.info("Failed to login to URL %s as %s" % (loginUrl,
- params['user']))
- raise exceptions.FailedToLogin(url,params['user'])
- return False
- else:
- return True
-
- ## Getting the chapter list and the meta data, plus 'is adult' checking.
- def extractChapterUrlsAndMetadata(self):
-
- # index=1 makes sure we see the story chapter index. Some
- # sites skip that for one-chapter stories.
- url = self.url
- logger.debug("URL: "+url)
-
- try:
- data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
- if e.code == 404:
- raise exceptions.StoryDoesNotExist(self.url)
- else:
- raise e
-
- if self.needToLoginCheck(data):
- # need to log in for this one.
- self.performLogin(url)
- data = self._fetchUrl(url)
-
- if "Invalid story ID" in data:
- raise exceptions.FailedToDownload(self.getSiteDomain() +" says: Invalid story ID.")
-
- # use BeautifulSoup HTML parser to make everything easier to find.
- soup = bs.BeautifulSoup(data)
- # print data
-
- # Now go hunting for all the meta data and the chapter list.
- body=soup.findAll('body')[1]
- body.find('table').extract()
-
- ## Title
- a = body.find('b')
- self.story.setMetadata('title',stripHTML(a))
-
- # Find authorid and URL from... author url. http://www.dotmoon.net/board/index.php?action=profile;u=1'
- a = body.find('a', href=re.compile(r"index.php\?action=profile;u=\d+"))
- self.story.setMetadata('authorId',a['href'].split('=')[2])
- self.story.setMetadata('authorUrl','http://'+self.host+'/'+a['href'])
- self.story.setMetadata('author',a.string)
-
- # Find the chapters: 'library_storyview.php?chapterid=3
- chapters=body.findAll('a', href=re.compile(r"library_storyview.php\?chapterid=\d+$"))
- if len(chapters)==0:
- raise exceptions.FailedToDownload(self.getSiteDomain() +" says: No php/html chapters found.")
- if len(chapters)==1:
- self.chapterUrls.append((self.story.getMetadata('title'),'http://'+self.host+'/'+chapters[0]['href']))
- else:
- for chapter in chapters:
- # just in case there's tags, like in chapter titles.
- self.chapterUrls.append((stripHTML(chapter),'http://'+self.host+'/'+chapter['href']))
-
- self.story.setMetadata('numChapters',len(self.chapterUrls))
-
- # other tags
-
- labels = body.find('table', {'width':'390'}).findAll('td')
- for labelspan in labels:
- value = labelspan.nextSibling
- label = labelspan.string
-
- if label != None:
- if 'Fandom' in label:
- self.story.addToList('category',value.string)
-
- if 'Setting' in label:
- self.story.addToList('genre',value.string)
-
- if 'Genre' in label:
- self.story.addToList('genre',value.string)
-
- if 'Style' in label:
- self.story.addToList('genre',value.string)
-
- if 'Rating' in label:
- self.story.addToList('rating',value.string)
-
- if 'Created' in label:
- self.story.setMetadata('datePublished', makeDate(stripHTML(value), self.dateformat))
-
- if 'Updated' in label:
- self.story.setMetadata('dateUpdated', makeDate(stripHTML(value), self.dateformat))
-
- if 'Status' in label:
- if 'Completed' in value.string:
- self.story.setMetadata('status', 'Completed')
- else:
- self.story.setMetadata('status', 'In-Progress')
-
- table=body.findAll('table', {'width':'400'})[1].find('td')
- self.setDescription(url,stripHTML(table).split('Summary: ')[1])
-
- # grab the text for an individual chapter.
- def getChapterText(self, url):
-
- logger.debug('Getting chapter text from: %s' % url)
-
- soup = bs.BeautifulStoneSoup(self._fetchUrl(url),
- selfClosingTags=('br','hr')) # otherwise soup eats the br/hr tags.
-
- div = soup.find('blockquote')
- div.name='div'
-
- if None == div:
- raise exceptions.FailedToDownload("Error downloading Chapter: %s! Missing required element!" % url)
-
- return self.utf8FromSoup(url,div)
diff --git a/fanficfare/adapters/adapter_hennethannunnet.py b/fanficfare/adapters/adapter_hennethannunnet.py
deleted file mode 100644
index 302be86..0000000
--- a/fanficfare/adapters/adapter_hennethannunnet.py
+++ /dev/null
@@ -1,172 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Copyright 2013 Fanficdownloader team, 2015 FanFicFare team
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-import time
-import logging
-logger = logging.getLogger(__name__)
-import re
-import urllib2
-
-from .. import BeautifulSoup as bs
-from ..htmlcleanup import stripHTML
-from .. import exceptions as exceptions
-
-from base_adapter import BaseSiteAdapter, makeDate
-
-def getClass():
- return HennethAnnunNetAdapter
-
-# Class name has to be unique. Our convention is camel case the
-# sitename with Adapter at the end. www is skipped.
-class HennethAnnunNetAdapter(BaseSiteAdapter):
-
- def __init__(self, config, url):
- BaseSiteAdapter.__init__(self, config, url)
-
- self.decode = ["Windows-1252",
- "utf8"] # 1252 is a superset of iso-8859-1.
- # Most sites that claim to be
- # iso-8859-1 (and some that claim to be
- # utf8) are really windows-1252.
- self.username = "NoneGiven" # if left empty, site doesn't return any message at all.
- self.password = ""
- self.is_adult=False
-
- # get storyId from url--url validation guarantees query is only sid=1234
- self.story.setMetadata('storyId',self.parsedUrl.query.split('=',)[1])
-
-
- # normalized story URL.
- self._setURL('http://' + self.getSiteDomain() + '/stories/chapter.cfm?stid='+self.story.getMetadata('storyId'))
-
- # Each adapter needs to have a unique site abbreviation.
- self.story.setMetadata('siteabbrev','htan')
-
- # The date format will vary from site to site.
- # http://docs.python.org/library/datetime.html#strftime-strptime-behavior
- self.dateformat = "%m/%d/%y"
-
- @staticmethod # must be @staticmethod, don't remove it.
- def getSiteDomain():
- # The site domain. Does have www here, if it uses it.
- return 'www.henneth-annun.net'
-
- @classmethod
- def getSiteExampleURLs(cls):
- return "http://"+cls.getSiteDomain()+"/stories/chapter.cfm?stid=1234"
-
- def getSiteURLPattern(self):
- return "http://"+self.getSiteDomain()+"/stories/chapter(_view)?.cfm\?stid="+r"\d+$"
-
- ## Getting the chapter list and the meta data, plus 'is adult' checking.
- def extractChapterUrlsAndMetadata(self):
-
-
- # index=1 makes sure we see the story chapter index. Some
- # sites skip that for one-chapter stories.
- url = self.url
- logger.debug("URL: "+url)
-
- try:
- data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
- if e.code == 404:
- raise exceptions.StoryDoesNotExist(self.url)
- else:
- raise e
-
-
- if "We're sorry. This story is not available." in data:
- raise exceptions.FailedToDownload(self.getSiteDomain() +" says: This story is not available.")
-
- # use BeautifulSoup HTML parser to make everything easier to find.
- soup = bs.BeautifulSoup(data)
- # print data
-
- # Now go hunting for all the meta data and the chapter list.
-
- ## Title
- a = soup.find('h2', {'id':'page_heading'})
- self.story.setMetadata('title',stripHTML(a))
-
- # Find the chapters: chapter_view.cfm?stid=6663&spordinal=1"
- for chapter in soup.findAll('a', href=re.compile(r'chapter_view.cfm\?stid='+self.story.getMetadata('storyId')+"&spordinal=\d+$")):
- # just in case there's tags, like in chapter titles.
- self.chapterUrls.append((stripHTML(chapter),'http://'+self.host+'/stories/'+chapter['href']))
-
- self.story.setMetadata('numChapters',len(self.chapterUrls))
-
- self.story.setMetadata('numWords', soup.find('tr', {'class':'foot'}).findAll('td')[1].text)
-
- self.setDescription(url,soup.find('div', {'id':'summary'}))
-
- # Rated: NC-17
etc
- info = soup.find('div', {'id':'storyinformation'})
- labels=info.findAll('b')
- for labelspan in labels:
- value = labelspan.nextSibling
- label = labelspan.string
-
- if 'Completion' in label:
- if 'Complete' in value.string:
- self.story.setMetadata('status', 'Completed')
- else:
- self.story.setMetadata('status', 'In-Progress')
-
- if 'Rating' in label:
- self.story.setMetadata('rating', value.string)
-
- if 'Era:' in label:
- self.story.addToList('category',value.string)
-
- if 'Genre' in label:
- self.story.addToList('genre',value.string)
-
- labels=info.findAll('strong')
- for labelspan in labels:
- value = labelspan.nextSibling
- label = labelspan.string
-
- if 'Author' in label:
- value=value.nextSibling
- self.story.setMetadata('authorId',value['href'].split('=')[1])
- self.story.setMetadata('authorUrl','http://'+self.host+'/'+value['href'])
- self.story.setMetadata('author',value.string)
-
- if 'Post' in label:
- self.story.setMetadata('datePublished', makeDate(stripHTML(value), self.dateformat))
-
- if 'Updated:' in label:
- self.story.setMetadata('dateUpdated', makeDate(stripHTML(value), self.dateformat))
-
- for char in soup.findAll('a', href=re.compile(r"/resources/bios_view.cfm\?scid=\d+")):
- self.story.addToList('characters',stripHTML(char))
-
- # grab the text for an individual chapter.
- def getChapterText(self, url):
-
- logger.debug('Getting chapter text from: %s' % url)
-
- soup = bs.BeautifulStoneSoup(self._fetchUrl(url),
- selfClosingTags=('br','hr')) # otherwise soup eats the br/hr tags.
-
- div = soup.find('div', {'class' : 'block chapter'})
-
- if None == div:
- raise exceptions.FailedToDownload("Error downloading Chapter: %s! Missing required element!" % url)
-
- return self.utf8FromSoup(url,div)
diff --git a/fanficfare/adapters/adapter_netraptororg.py b/fanficfare/adapters/adapter_netraptororg.py
deleted file mode 100644
index cf94463..0000000
--- a/fanficfare/adapters/adapter_netraptororg.py
+++ /dev/null
@@ -1,213 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Copyright 2013 Fanficdownloader team, 2015 FanFicFare team
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# Software: eFiction
-import time
-import logging
-logger = logging.getLogger(__name__)
-import re
-import urllib2
-
-from .. import BeautifulSoup as bs
-from ..htmlcleanup import stripHTML
-from .. import exceptions as exceptions
-
-from base_adapter import BaseSiteAdapter, makeDate
-
-def getClass():
- return NetRaptorOrgAdapter
-
-class NetRaptorOrgAdapter(BaseSiteAdapter):
-
- def __init__(self, config, url):
- BaseSiteAdapter.__init__(self, config, url)
-
- self.decode = ["Windows-1252",
- "utf8"] # 1252 is a superset of iso-8859-1.
- # Most sites that claim to be
- # iso-8859-1 (and some that claim to be
- # utf8) are really windows-1252.
- self.username = "NoneGiven" # if left empty, site doesn't return any message at all.
- self.password = ""
- self.is_adult=False
-
- # get storyId from url--url validation guarantees query is only sid=1234
- self.story.setMetadata('storyId',self.parsedUrl.query.split('=',)[1])
-
-
- # normalized story URL.
- self._setURL('http://' + self.getSiteDomain() + '/fanfiction/viewstory.php?sid='+self.story.getMetadata('storyId'))
-
- # Each adapter needs to have a unique site abbreviation.
- self.story.setMetadata('siteabbrev','netrap')
-
- # The date format will vary from site to site.
- # http://docs.python.org/library/datetime.html#strftime-strptime-behavior
- self.dateformat = "%d/%m/%y"
-
- @staticmethod # must be @staticmethod, don't remove it.
- def getSiteDomain():
- # The site domain. Does have www here, if it uses it.
- return 'netraptor.org'
-
- @classmethod
- def getSiteExampleURLs(cls):
- return "http://"+cls.getSiteDomain()+"/fanfiction/viewstory.php?sid=1234"
-
- def getSiteURLPattern(self):
- return re.escape("http://"+self.getSiteDomain()+"/fanfiction/viewstory.php?sid=")+r"\d+$"
-
- ## Getting the chapter list and the meta data, plus 'is adult' checking.
- def extractChapterUrlsAndMetadata(self):
-
- url = self.url+'&index=1'
- logger.debug("URL: "+url)
-
- try:
- data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
- if e.code == 404:
- raise exceptions.StoryDoesNotExist(self.url)
- else:
- raise e
-
-
- if "Access denied. This story has not been validated by the adminstrators of this site." in data:
- raise exceptions.FailedToDownload(self.getSiteDomain() +" says: Access denied. This story has not been validated by the adminstrators of this site.")
-
- # use BeautifulSoup HTML parser to make everything easier to find.
- soup = bs.BeautifulSoup(data)
- # print data
-
- # Now go hunting for all the meta data and the chapter list.
-
- ## Title
- pagetitle = soup.find('div',{'id':'pagetitle'})
- a = pagetitle.find('a', href=re.compile(r'viewstory.php\?sid='+self.story.getMetadata('storyId')+"$"))
- self.story.setMetadata('title',stripHTML(a))
-
- # Find authorid and URL from... author url.
- a = pagetitle.find('a', href=re.compile(r"viewuser.php\?uid=\d+"))
- self.story.setMetadata('authorId',a['href'].split('=')[1])
- self.story.setMetadata('authorUrl','http://'+self.host+'/fanfiction/'+a['href'])
- self.story.setMetadata('author',a.string)
-
- # Find the chapters:
- for chapter in soup.findAll('a', href=re.compile(r'viewstory.php\?sid='+self.story.getMetadata('storyId')+"&chapter=\d+$")):
- # just in case there's tags, like in chapter titles.
- self.chapterUrls.append((stripHTML(chapter),'http://'+self.host+'/fanfiction/'+chapter['href']))
-
- self.story.setMetadata('numChapters',len(self.chapterUrls))
-
- # eFiction sites don't help us out a lot with their meta data
- # formating, so it's a little ugly.
-
- # utility method
- def defaultGetattr(d,k):
- try:
- return d[k]
- except:
- return ""
-
- labels = soup.findAll('span',{'class':'label'})
- for labelspan in labels:
- value = labelspan.nextSibling
- label = labelspan.string
-
- if 'Summary' in label:
- ## Everything until the next span class='label'
- svalue = ""
- while not defaultGetattr(value,'class') == 'label':
- svalue += str(value)
- value = value.nextSibling
- self.setDescription(url,svalue)
- #self.story.setMetadata('description',stripHTML(svalue))
-
- if 'Rated' in label:
- self.story.setMetadata('rating', value)
-
- if 'Word count' in label:
- self.story.setMetadata('numWords', value)
-
- if 'Categories' in label:
- cats = labelspan.parent.findAll('a',href=re.compile(r'browse.php\?type=categories'))
- catstext = [cat.string for cat in cats]
- for cat in catstext:
- self.story.addToList('category',cat.string)
-
- if 'Characters' in label:
- chars = labelspan.parent.findAll('a',href=re.compile(r'browse.php\?type=characters'))
- charstext = [char.string for char in chars]
- for char in charstext:
- self.story.addToList('characters',char.string)
-
- if 'Genre' in label:
- genres = labelspan.parent.findAll('a',href=re.compile(r'browse.php\?type=class&type_id=1'))
- for genre in genres:
- self.story.addToList('genre',genre.string)
-
- if 'Warnings' in label:
- warnings = labelspan.parent.findAll('a',href=re.compile(r'browse.php\?type=class&type_id=2')) # XXX
- for warning in warnings:
- self.story.addToList('warnings',warning.string)
-
- if 'Completed' in label:
- if 'Yes' in value:
- self.story.setMetadata('status', 'Completed')
- else:
- self.story.setMetadata('status', 'In-Progress')
-
- if 'Published' in label:
- self.story.setMetadata('datePublished', makeDate(stripHTML(value), self.dateformat))
-
- if 'Updated' in label:
- self.story.setMetadata('dateUpdated', makeDate(stripHTML(value), self.dateformat))
-
- try:
- # Find Series name from series URL.
- a = soup.find('a', href=re.compile(r"viewseries.php\?seriesid=\d+"))
- series_name = a.string
- series_url = 'http://'+self.host+'/fanfiction/'+a['href']
-
- # use BeautifulSoup HTML parser to make everything easier to find.
- seriessoup = bs.BeautifulSoup(self._fetchUrl(series_url))
- storyas = seriessoup.findAll('a', href=re.compile(r'^viewstory.php\?sid=\d+$'))
- i=1
- for a in storyas:
- if a['href'] == ('viewstory.php?sid='+self.story.getMetadata('storyId')):
- self.setSeries(series_name, i)
- self.story.setMetadata('seriesUrl',series_url)
- break
- i+=1
-
- except:
- # I find it hard to care if the series parsing fails
- pass
-
- # grab the text for an individual chapter.
- def getChapterText(self, url):
-
- logger.debug('Getting chapter text from: %s' % url)
-
- soup = bs.BeautifulSoup(self._fetchUrl(url))
-
- div = soup.find('div', {'id' : 'story'})
-
- if None == div:
- raise exceptions.FailedToDownload("Error downloading Chapter: %s! Missing required element!" % url)
-
- return self.utf8FromSoup(url,div)
diff --git a/fanficfare/adapters/adapter_simplyundeniablecom.py b/fanficfare/adapters/adapter_simplyundeniablecom.py
deleted file mode 100644
index 16e2fa0..0000000
--- a/fanficfare/adapters/adapter_simplyundeniablecom.py
+++ /dev/null
@@ -1,220 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Copyright 2013 Fanficdownloader team, 2015 FanFicFare team
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# Software: eFiction
-import time
-import logging
-logger = logging.getLogger(__name__)
-import re
-import urllib2
-
-from .. import BeautifulSoup as bs
-from ..htmlcleanup import stripHTML
-from .. import exceptions as exceptions
-
-from base_adapter import BaseSiteAdapter, makeDate
-
-def getClass():
- return SimplyUndeniableComAdapter
-
-# Class name has to be unique. Our convention is camel case the
-# sitename with Adapter at the end. www is skipped.
-class SimplyUndeniableComAdapter(BaseSiteAdapter):
-
- def __init__(self, config, url):
- BaseSiteAdapter.__init__(self, config, url)
-
- self.decode = ["Windows-1252",
- "utf8"] # 1252 is a superset of iso-8859-1.
- # Most sites that claim to be
- # iso-8859-1 (and some that claim to be
- # utf8) are really windows-1252.
- self.username = "NoneGiven" # if left empty, site doesn't return any message at all.
- self.password = ""
- self.is_adult=False
-
- # get storyId from url--url validation guarantees query is only sid=1234
- self.story.setMetadata('storyId',self.parsedUrl.query.split('=',)[1])
-
-
- # normalized story URL.
- self._setURL('http://' + self.getSiteDomain() + '/viewstory.php?sid='+self.story.getMetadata('storyId'))
-
- # Each adapter needs to have a unique site abbreviation.
- self.story.setMetadata('siteabbrev','sud')
-
- # The date format will vary from site to site.
- # http://docs.python.org/library/datetime.html#strftime-strptime-behavior
- self.dateformat = "%m/%d/%Y"
-
- @staticmethod # must be @staticmethod, don't remove it.
- def getSiteDomain():
- # The site domain. Does have www here, if it uses it.
- return 'www.simplyundeniable.com'
-
- @classmethod
- def getSiteExampleURLs(cls):
- return "http://"+cls.getSiteDomain()+"/viewstory.php?sid=1234"
-
- def getSiteURLPattern(self):
- return re.escape("http://"+self.getSiteDomain()+"/viewstory.php?sid=")+r"\d+$"
-
- ## Login seems to be reasonably standard across eFiction sites.
- def needToLoginCheck(self, data):
- if 'Please log in now' in data \
- or 'There is no such account on our website' in data \
- or "That password doesn't match the one in our database" in data:
- return True
- else:
- return False
-
- def performLogin(self, url):
- params = {}
-
- if self.password:
- params['penname'] = self.username
- params['password'] = self.password
- else:
- params['penname'] = self.getConfig("username")
- params['password'] = self.getConfig("password")
- params['cookiecheck'] = '1'
- params['submit'] = 'Submit'
-
- loginUrl = 'http://' + self.getSiteDomain() + '/user.php?action=login'
- logger.debug("Will now login to URL (%s) as (%s)" % (loginUrl,
- params['penname']))
-
- d = self._fetchUrl(loginUrl, params)
-
- if "My Account" not in d : #Member Account
- logger.info("Failed to login to URL %s as %s" % (loginUrl,
- params['penname']))
- raise exceptions.FailedToLogin(url,params['penname'])
- return False
- else:
- return True
-
- ## Getting the chapter list and the meta data, plus 'is adult' checking.
- def extractChapterUrlsAndMetadata(self):
-
- # index=1 makes sure we see the story chapter index. Some
- # sites skip that for one-chapter stories.
- url = self.url
- logger.debug("URL: "+url)
-
- try:
- data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
- if e.code == 404:
- raise exceptions.StoryDoesNotExist(self.url)
- else:
- raise e
-
- if self.needToLoginCheck(data):
- # need to log in for this one.
- self.performLogin(url)
- data = self._fetchUrl(url)
-
-
- if "Access denied. This story has not been validated by the adminstrators of this site." in data:
- raise exceptions.FailedToDownload(self.getSiteDomain() +" says: Access denied. This story has not been validated by the adminstrators of this site.")
-
- if "Please log in now" in data:
- raise exceptions.FailedToDownload(self.getSiteDomain() +" says: You need to have access to the restricted section.")
-
- # use BeautifulSoup HTML parser to make everything easier to find.
- soup = bs.BeautifulSoup(data)
- # print data
-
- # Now go hunting for all the meta data and the chapter list.
-
- ## Title
- a = soup.find('h1')
- self.story.setMetadata('title',stripHTML(a))
-
- # Find authorid and URL from... author url.
- a = soup.find('a', href=re.compile(r"viewuser.php\?uid=\d+"))
- self.story.setMetadata('authorId',a['href'].split('=')[1])
- self.story.setMetadata('authorUrl','http://'+self.host+'/'+a['href'])
- self.story.setMetadata('author',a.string)
- asoup = bs.BeautifulSoup(self._fetchUrl(self.story.getMetadata('authorUrl')))
-
- for info in asoup.findAll('table', {'cellpadding' : '5'}):
- a = info.find('a', href=re.compile(r'viewstory.php\?sid='+self.story.getMetadata('storyId')+"$"))
- if a != None:
- self.story.setMetadata('title',stripHTML(a))
- break
-
- # Find the chapters:
- if "Disclaimer" in data:
- self.chapterUrls.append((self.story.getMetadata('title'),url))
- else:
- for chapter in soup.findAll('a', href=re.compile(r'viewstory.php\?sid=\d+&i=1$')):
- # just in case there's tags, like in chapter titles.
- self.chapterUrls.append((stripHTML(chapter),'http://'+self.host+'/'+chapter['href']))
-
- self.story.setMetadata('numChapters',len(self.chapterUrls))
-
- # eFiction sites don't help us out a lot with their meta data
- # formating, so it's a little ugly.
-
- a = info.find('td', {'valign' : 'top'}).find('p')
- self.setDescription(url,a)
-
- a = info.find('td', {'class' : 'greysm'}).findAll('b')
- self.story.setMetadata('datePublished', makeDate(stripHTML(a[0].nextSibling), self.dateformat))
- self.story.setMetadata('dateUpdated', makeDate(stripHTML(a[1].nextSibling), self.dateformat))
- if 'Yes' in a[2].nextSibling:
- self.story.setMetadata('status', 'Completed')
- else:
- self.story.setMetadata('status', 'In-Progress')
- self.story.setMetadata('rating', a[3].nextSibling)
- self.story.setMetadata('numWords', a[4].nextSibling)
-
-
- warnings = info.find('td', {'width' : '45'}).nextSibling.nextSibling.text.split(', ')
- for warning in warnings:
- if 'none' not in warning:
- self.story.addToList('warnings',warning)
- chars = info.find('td', {'width' : '51'}).nextSibling.nextSibling.text.split(', ')
- for char in chars:
- if '&' in char:
- self.story.addToList('ships',char)
- else:
- self.story.addToList('characters',char)
- genres = info.find('td', {'width' : '36'}).nextSibling.nextSibling.text.split(', ')
- for genre in genres:
- self.story.addToList('genre',genre)
-
- cat = info.find('a', href=re.compile(r'categories.php'))
- self.story.addToList('category',cat.string)
-
- # grab the text for an individual chapter.
- def getChapterText(self, url):
-
- logger.debug('Getting chapter text from: %s' % url)
-
- soup = bs.BeautifulStoneSoup(self._fetchUrl(url),
- selfClosingTags=('br','hr')) # otherwise soup eats the br/hr tags.
-
- div = soup.find('span', {'class' : 'style'})
-
- if None == div:
- raise exceptions.FailedToDownload("Error downloading Chapter: %s! Missing required element!" % url)
- div.name='div'
-
- return self.utf8FromSoup(url,div)
diff --git a/fanficfare/adapters/adapter_stargateatlantisorg.py b/fanficfare/adapters/adapter_stargateatlantisorg.py
deleted file mode 100644
index a022b24..0000000
--- a/fanficfare/adapters/adapter_stargateatlantisorg.py
+++ /dev/null
@@ -1,230 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Copyright 2012 Fanficdownloader team, 2015 FanFicFare team
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# Software: eFiction
-import time
-import logging
-logger = logging.getLogger(__name__)
-import re
-import urllib2
-
-from .. import BeautifulSoup as bs
-from ..htmlcleanup import stripHTML
-from .. import exceptions as exceptions
-
-from base_adapter import BaseSiteAdapter, makeDate
-
-def getClass():
- return StargateAtlantisOrgAdapter
-
-# Class name has to be unique. Our convention is camel case the
-# sitename with Adapter at the end. www is skipped.
-class StargateAtlantisOrgAdapter(BaseSiteAdapter):
-
- def __init__(self, config, url):
- BaseSiteAdapter.__init__(self, config, url)
-
- self.decode = ["Windows-1252",
- "utf8"] # 1252 is a superset of iso-8859-1.
- # Most sites that claim to be
- # iso-8859-1 (and some that claim to be
- # utf8) are really windows-1252.
- self.username = "NoneGiven" # if left empty, site doesn't return any message at all.
- self.password = ""
- self.is_adult=False
-
- # get storyId from url--url validation guarantees query is only sid=1234
- self.story.setMetadata('storyId',self.parsedUrl.query.split('=',)[1])
-
-
- # normalized story URL.
- self._setURL('http://' + self.getSiteDomain() + '/fanfics/viewstory.php?sid='+self.story.getMetadata('storyId'))
-
- # Each adapter needs to have a unique site abbreviation.
- self.story.setMetadata('siteabbrev','stat')
-
- # The date format will vary from site to site.
- # http://docs.python.org/library/datetime.html#strftime-strptime-behavior
- self.dateformat = "%B %d %Y"
-
- @staticmethod # must be @staticmethod, don't remove it.
- def getSiteDomain():
- # The site domain. Does have www here, if it uses it.
- return 'stargate-atlantis.org'
-
- @classmethod
- def getSiteExampleURLs(cls):
- return "http://"+cls.getSiteDomain()+"/fanfics/viewstory.php?sid=1234"
-
- def getSiteURLPattern(self):
- return re.escape("http://"+self.getSiteDomain()+"/fanfics/viewstory.php?sid=")+r"\d+$"
-
- ## Getting the chapter list and the meta data, plus 'is adult' checking.
- def extractChapterUrlsAndMetadata(self):
-
- # index=1 makes sure we see the story chapter index. Some
- # sites skip that for one-chapter stories.
- url = self.url+'&index=1'
- logger.debug("URL: "+url)
-
- try:
- data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
- if e.code == 404:
- raise exceptions.StoryDoesNotExist(self.url)
- else:
- raise e
-
- if "Access denied. This story has not been validated by the adminstrators of this site." in data:
- raise exceptions.FailedToDownload(self.getSiteDomain() +" says: Access denied. This story has not been validated by the adminstrators of this site.")
-
- # use BeautifulSoup HTML parser to make everything easier to find.
- soup = bs.BeautifulSoup(data)
- # print data
-
- # Now go hunting for all the meta data and the chapter list.
-
- ## Title and author
- a = soup.find('div', {'id' : 'pagetitle'})
-
- aut = a.find('a', href=re.compile(r"viewuser.php\?uid=\d+"))
- self.story.setMetadata('authorId',aut['href'].split('=')[1])
- self.story.setMetadata('authorUrl','http://'+self.host+'/fanfics/'+aut['href'])
- self.story.setMetadata('author',aut.string)
- aut.extract()
-
- self.story.setMetadata('title',stripHTML(a)[:(len(stripHTML(a))-3)])
-
- # Find the chapters:
- chapters=soup.findAll('div', {'class' : 'content'})
- if len(chapters) > 1:
- for chapter in chapters:
- # just in case there's tags, like in chapter titles.
- link = chapter.find('a')
- self.chapterUrls.append((stripHTML(link),'http://'+self.host+'/fanfics/'+link['href']))
- else:
- self.chapterUrls.append((self.story.getMetadata('title'),url))
-
- self.story.setMetadata('numChapters',len(self.chapterUrls))
-
- asoup = bs.BeautifulSoup(self._fetchUrl(self.story.getMetadata('authorUrl')))
-
- for list in asoup.findAll('div', {'class' : re.compile('listbox\s+')}):
- a = list.find('a', href=re.compile(r'viewstory.php\?sid='+self.story.getMetadata('storyId')+"$"))
- if a != None:
- break
-
- # eFiction sites don't help us out a lot with their meta data
- # formating, so it's a little ugly.
-
- # utility method
- def defaultGetattr(d,k):
- try:
- return d[k]
- except:
- return ""
-
- # Rated: NC-17
etc
- labels = list.findAll('span', {'class' : 'classification'})
- for labelspan in labels:
- label = labelspan.string
- value = labelspan.nextSibling
-
- if 'Summary' in label:
- ## Everything until the next span class='label'
- svalue = ""
- while not defaultGetattr(value,'class') == 'tail' and value != None:
- svalue += str(value)
- value = value.nextSibling
- self.setDescription(url,svalue)
- #self.story.setMetadata('description',stripHTML(svalue))
-
- if 'Rated' in label:
- self.story.setMetadata('rating', value[:len(value)-2])
-
- if 'Word count' in label:
- self.story.setMetadata('numWords', value)
-
- if 'Categories' in label:
- cats = labelspan.parent.findAll('a',href=re.compile(r'categories.php\?catid=\d+'))
- for cat in cats:
- self.story.addToList('category',cat.string)
-
- if 'Characters' in label:
- for char in value.string.split(', '):
- if not 'None' in char:
- self.story.addToList('characters',char)
-
- if 'Genre' in label:
- for genre in value.string.split(', '):
- if not 'None' in genre:
- self.story.addToList('genre',genre)
-
- if 'Warnings' in label:
- for warning in value.string.split(', '):
- if not 'None' in warning:
- self.story.addToList('warnings',warning)
-
- if 'Completed' in label:
- if 'Yes' in value:
- self.story.setMetadata('status', 'Completed')
- else:
- self.story.setMetadata('status', 'In-Progress')
-
- if 'Published' in label:
- self.story.setMetadata('datePublished', makeDate(stripHTML(value.split(' ::')[0]), self.dateformat))
-
- if 'Updated' in label:
- # there's a stray [ at the end.
- #value = value[0:-1]
- self.story.setMetadata('dateUpdated', makeDate(stripHTML(value), self.dateformat))
-
- try:
- # Find Series name from series URL.
- a = list.find('a', href=re.compile(r"series.php\?seriesid=\d+"))
- series_name = a.string
- series_url = 'http://'+self.host+'/fanfics/'+a['href']
-
- # use BeautifulSoup HTML parser to make everything easier to find.
- seriessoup = bs.BeautifulSoup(self._fetchUrl(series_url))
- storyas = seriessoup.findAll('a', href=re.compile(r'^viewstory.php\?sid=\d+$'))
- i=1
- for a in storyas:
- if a['href'] == ('viewstory.php?sid='+self.story.getMetadata('storyId')):
- self.setSeries(series_name, i)
- self.story.setMetadata('seriesUrl',series_url)
- break
- i+=1
-
- except:
- # I find it hard to care if the series parsing fails
- pass
-
- # grab the text for an individual chapter.
- def getChapterText(self, url):
-
- logger.debug('Getting chapter text from: %s' % url)
-
- soup = bs.BeautifulSoup(self._fetchUrl(url),
- selfClosingTags=('br','hr')) # otherwise soup eats the br/hr tags.
-
- div = soup.find('div', {'id' : 'story'})
-
- if None == div:
- raise exceptions.FailedToDownload("Error downloading Chapter: %s! Missing required element!" % url)
-
- return self.utf8FromSoup(url,div)
diff --git a/fanficfare/adapters/adapter_twiwritenet.py b/fanficfare/adapters/adapter_twiwritenet.py
deleted file mode 100644
index eedb0da..0000000
--- a/fanficfare/adapters/adapter_twiwritenet.py
+++ /dev/null
@@ -1,281 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Copyright 2011 Fanficdownloader team, 2015 FanFicFare team
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# Software: eFiction
-import time
-import logging
-logger = logging.getLogger(__name__)
-import re
-import urllib
-import urllib2
-
-from .. import BeautifulSoup as bs
-from ..htmlcleanup import stripHTML
-from .. import exceptions as exceptions
-
-from base_adapter import BaseSiteAdapter, makeDate
-
-class TwiwriteNetSiteAdapter(BaseSiteAdapter):
-
- def __init__(self, config, url):
- BaseSiteAdapter.__init__(self, config, url)
- self.story.setMetadata('siteabbrev','twrt')
- self.decode = ["Windows-1252",
- "utf8"] # 1252 is a superset of iso-8859-1.
- # Most sites that claim to be
- # iso-8859-1 (and some that claim to be
- # utf8) are really windows-1252.
- self.is_adult = False
- self.username = "NoneGiven" # if left empty, twiwrite.net doesn't return any message at all.
- self.password = ""
-
- # get storyId from url--url validation guarantees query is only sid=1234
- self.story.setMetadata('storyId',self.parsedUrl.query.split('=',)[1])
-
-
- # normalized story URL.
- self._setURL('http://' + self.getSiteDomain() + '/viewstory.php?sid='+self.story.getMetadata('storyId'))
-
-
- @staticmethod
- def getSiteDomain():
- return 'www.twiwrite.net'
-
- @classmethod
- def getAcceptDomains(cls):
- return ['www.twiwrite.net','twiwrite.net']
-
- @classmethod
- def getSiteExampleURLs(cls):
- return "http://www.twiwrite.net/viewstory.php?sid=1234"
-
- def getSiteURLPattern(self):
- return re.escape("http://")+r"(www\.)?"+re.escape("twiwrite.net/viewstory.php?sid=")+r"\d+$"
-
- def needToLoginCheck(self, data):
- if 'Registered Users Only' in data \
- or 'There is no such account on our website' in data \
- or "That password doesn't match the one in our database" in data:
- return True
- else:
- return False
-
- def performLogin(self, url):
- params = {}
-
- if self.password:
- params['penname'] = self.username
- params['password'] = self.password
- else:
- params['penname'] = self.getConfig("username")
- params['password'] = self.getConfig("password")
- params['cookiecheck'] = '1'
- params['submit'] = 'Submit'
-
- loginUrl = 'http://' + self.getSiteDomain() + '/user.php?action=login'
- logger.info("Will now login to URL (%s) as (%s)" % (loginUrl,
- params['penname']))
-
- d = self._fetchUrl(loginUrl, params)
-
- if "Member Account" not in d : #Member Account
- logger.info("Failed to login to URL %s as %s" % (loginUrl,
- params['penname']))
- raise exceptions.FailedToLogin(url,params['penname'])
- return False
- else:
- return True
-
- def extractChapterUrlsAndMetadata(self):
-
- if self.is_adult or self.getConfig("is_adult"):
- # Weirdly, different sites use different warning numbers.
- # If the title search below fails, there's a good chance
- # you need a different number. print data at that point
- # and see what the 'click here to continue' url says.
- addurl = "&ageconsent=ok&warning=1" # XXX
- else:
- addurl=""
-
- url = self.url+'&index=1'+addurl
- logger.debug("URL: "+url)
-
- try:
- data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
- if e.code == 404:
- raise exceptions.StoryDoesNotExist(self.url)
- else:
- raise e
-
- if self.needToLoginCheck(data):
- # need to log in for this one.
- self.performLogin(url)
- data = self._fetchUrl(url)
-
- if "Access denied. This story has not been validated by the adminstrators of this site." in data:
- raise exceptions.FailedToDownload(self.getSiteDomain() +" says: Access denied. This story has not been validated by the adminstrators of this site.")
-
- if "Contains Explicit Content for mature adults only! May contain graphic violence, mature sexual situations, and explicit language. Read with caution." in data:
- raise exceptions.AdultCheckRequired(self.url)
-
- # problems with some stories, but only in calibre. I suspect
- # issues with different SGML parsers in python. This is a
- # nasty hack, but it works.
- data = data[data.index(" in chapter titles.
- self.chapterUrls.append((stripHTML(chapter),'http://'+self.host+'/'+chapter['href']+addurl))
-
- self.story.setMetadata('numChapters',len(self.chapterUrls))
-
- ##
- ## Summary, strangely, is in the content attr of a tag
- ## which is escaped HTML. Unfortunately, we can't use it because they don't
- ## escape (') chars in the desc, breakin the tag.
- #meta_desc = soup.find('meta',{'name':'description'})
- #metasoup = bs.BeautifulStoneSoup(meta_desc['content'])
- #self.story.setMetadata('description',stripHTML(metasoup))
-
- def defaultGetattr(d,k):
- try:
- return d[k]
- except:
- return ""
-
- # Rated: NC-17
etc
- labels = soup.findAll('span',{'class':'label'})
- for labelspan in labels:
- value = labelspan.nextSibling
- label = labelspan.string
-
- if 'Summary' in label:
- ## Everything until the next span class='label'
- svalue = ""
- while not defaultGetattr(value,'class') == 'label':
- svalue += str(value)
- value = value.nextSibling
- self.setDescription(url,svalue)
- #self.story.setMetadata('description',stripHTML(svalue))
-
- if 'Rated' in label:
- self.story.setMetadata('rating', value)
-
- if 'Word count' in label:
- self.story.setMetadata('numWords', value)
-
- if 'Categories' in label:
- cats = labelspan.parent.findAll('a',href=re.compile(r'browse.php\?type=categories'))
- catstext = [cat.string for cat in cats]
- for cat in catstext:
- self.story.addToList('category',cat.string)
-
- if 'Characters' in label:
- chars = labelspan.parent.findAll('a',href=re.compile(r'browse.php\?type=characters'))
- charstext = [char.string for char in chars]
- for char in charstext:
- self.story.addToList('characters',char.string)
-
- if 'Genre' in label:
- genres = labelspan.parent.findAll('a',href=re.compile(r'browse.php\?type=class&type_id=3'))
- genrestext = [genre.string for genre in genres]
- self.genre = ', '.join(genrestext)
- for genre in genrestext:
- self.story.addToList('genre',genre.string)
-
- if 'Warnings' in label:
- warnings = labelspan.parent.findAll('a',href=re.compile(r'browse.php\?type=class&type_id=8'))
- warningstext = [warning.string for warning in warnings]
- self.warning = ', '.join(warningstext)
- for warning in warningstext:
- self.story.addToList('warning',warning.string)
-
- if 'Completed' in label:
- if 'Yes' in value:
- self.story.setMetadata('status', 'Completed')
- else:
- self.story.setMetadata('status', 'In-Progress')
-
- if 'Published' in label:
- self.story.setMetadata('datePublished', makeDate(value.strip(), "%B %d, %Y"))
-
- if 'Updated' in label:
- # there's a stray [ at the end.
- value = value[0:-1]
- self.story.setMetadata('dateUpdated', makeDate(value.strip(), "%B %d, %Y"))
-
- try:
- # Find Series name from series URL.
- a = soup.find('a', href=re.compile(r"viewseries.php\?seriesid=\d+"))
- series_name = a.string
- series_url = 'http://'+self.host+'/'+a['href']
-
- # use BeautifulSoup HTML parser to make everything easier to find.
- seriessoup = bs.BeautifulSoup(self._fetchUrl(series_url))
- storyas = seriessoup.findAll('a', href=re.compile(r'^viewstory.php\?sid=\d+$'))
- i=1
- for a in storyas:
- if a['href'] == ('viewstory.php?sid='+self.story.getMetadata('storyId')):
- self.setSeries(series_name, i)
- self.story.setMetadata('seriesUrl',series_url)
- break
- i+=1
-
- except:
- # I find it hard to care if the series parsing fails
- pass
-
- def getChapterText(self, url):
-
- logger.debug('Getting chapter text from: %s' % url)
-
- data = self._fetchUrl(url)
- # problems with some stories, but only in calibre. I suspect
- # issues with different SGML parsers in python. This is a
- # nasty hack, but it works.
- data = data[data.index(" in chapter titles.
- self.chapterUrls.append((stripHTML(chapter),'http://'+self.host+'/'+chapter['href']+addurl))
-
- self.story.setMetadata('numChapters',len(self.chapterUrls))
-
- # eFiction sites don't help us out a lot with their meta data
- # formating, so it's a little ugly.
-
- # Rated: NC-17
etc
- content=soup.find('div',{'class' : 'content'})
-
- for genre in content.findAll('a',href=re.compile(r'browse.php\?type=class&type_id=1')):
- self.story.addToList('genre',genre.string)
-
- for warning in content.findAll('a',href=re.compile(r'browse.php\?type=class&type_id=2')):
- self.story.addToList('warnings',warning.string)
-
- labels = content.findAll('b')
-
- value = labels[0].previousSibling
- svalue = ""
- while value != None:
- val = value
- value = value.previousSibling
- while "Categories" not in val:
- svalue += str(val)
- val = val.nextSibling
- self.setDescription(url,svalue)
-
-
-
- for labelspan in labels:
- value = labelspan.nextSibling
- label = labelspan.string
-
- if 'Summary' in label:
- ## Everything until the next span class='label'
- svalue = ""
- while not defaultGetattr(value,'class') == 'label':
- svalue += str(value)
- value = value.nextSibling
- self.setDescription(url,svalue)
-
- if 'Word count' in label:
- self.story.setMetadata('numWords', stripHTML(value).split(': ')[1].split(';')[0])
-
- if 'Categories' in label:
- cats = labelspan.parent.findAll('a',href=re.compile(r'browse.php\?type=categories'))
- for cat in cats:
- self.story.addToList('category',cat.string)
-
- if 'Characters' in label:
- chars = labelspan.parent.findAll('a',href=re.compile(r'browse.php\?type=characters'))
- for char in chars:
- self.story.addToList('characters',char.string)
-
- if 'Genre' in label:
- genres = labelspan.parent.findAll('a',href=re.compile(r'browse.php\?type=class&type_id=1'))
- for genre in genres:
- self.story.addToList('genre',genre.string)
-
- if 'Warnings' in label:
- warnings = labelspan.parent.findAll('a',href=re.compile(r'browse.php\?type=class&type_id=2'))
- for warning in warnings:
- self.story.addToList('warnings',warning.string)
-
- if 'Completed' in label:
- if 'Yes' in value:
- self.story.setMetadata('status', 'Completed')
- else:
- self.story.setMetadata('status', 'In-Progress')
-
- if 'Published' in label:
- self.story.setMetadata('datePublished', makeDate(stripHTML(value).split(': ')[1].split(';')[0], self.dateformat))
-
- if 'Updated' in label:
- self.story.setMetadata('dateUpdated', makeDate(stripHTML(value).split(': ')[1], self.dateformat))
-
- try:
- # Find Series name from series URL.
- a = soup.find('a', href=re.compile(r"viewseries.php\?seriesid=\d+"))
- series_name = a.string
- series_url = 'http://'+self.host+'/'+a['href']
-
- # use BeautifulSoup HTML parser to make everything easier to find.
- seriessoup = bs.BeautifulSoup(self._fetchUrl(series_url))
- # can't use ^viewstory...$ in case of higher rated stories with javascript href.
- storyas = seriessoup.findAll('a', href=re.compile(r'viewstory.php\?sid=\d+'))
- i=1
- for a in storyas:
- # skip 'report this' and 'TOC' links
- if 'contact.php' not in a['href'] and 'index' not in a['href']:
- if a['href'] == ('viewstory.php?sid='+self.story.getMetadata('storyId')):
- self.setSeries(series_name, i)
- self.story.setMetadata('seriesUrl',series_url)
- break
- i+=1
-
- except:
- # I find it hard to care if the series parsing fails
- pass
-
- # grab the text for an individual chapter.
- def getChapterText(self, url):
-
- logger.debug('Getting chapter text from: %s' % url)
-
- soup = bs.BeautifulStoneSoup(self._fetchUrl(url),
- selfClosingTags=('br','hr')) # otherwise soup eats the br/hr tags.
-
- div = soup.findAll('div', {'id' : 'story'})[1]
-
- if None == div:
- raise exceptions.FailedToDownload("Error downloading Chapter: %s! Missing required element!" % url)
-
- return self.utf8FromSoup(url,div)
diff --git a/fanficfare/cli.py b/fanficfare/cli.py
index 5c6485d..d399125 100644
--- a/fanficfare/cli.py
+++ b/fanficfare/cli.py
@@ -116,7 +116,7 @@ def main(argv=None, parser=None, passed_defaultsini=None, passed_personalini=Non
if options.siteslist:
for site, examples in adapters.getSiteExamples():
- print '\n====%s====\n\nExample URLs:' % site
+ print '\n#### %s\nExample URLs:' % site
for u in examples:
print ' * %s' % u
return
diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini
index 7b6f581..22378e7 100644
--- a/fanficfare/defaults.ini
+++ b/fanficfare/defaults.ini
@@ -1123,8 +1123,6 @@ extracategories:West Wing
## Site dedicated to these categories/characters/ships
extracategories:NCIS
-[netraptor.org]
-
[nfacommunity.com]
## Some sites do not require a login, but do require the user to
## confirm they are adult for adult content. In commandline version,
@@ -1286,10 +1284,6 @@ reviews_label:Reviews
extracharacters:Spike,Buffy
extracategories:Buffy the Vampire Slayer
-[stargate-atlantis.org]
-## Site dedicated to these categories/characters/ships
-extracategories:Stargate: Atlantis
-
[storiesonline.net]
## Some sites require login (or login for some rated stories) The
## program can prompt you, or you can save it in config. In
@@ -1477,17 +1471,6 @@ extraships:Draco Malfoy/Ginny Weasley
## Site dedicated to these categories/characters/ships
extracategories:Stargate: SG-1
-[www.checkmated.com]
-## Some sites require login (or login for some rated stories) The
-## program can prompt you, or you can save it in config. In
-## commandline version, this should go in your personal.ini, not
-## defaults.ini.
-#username:YourName
-#password:yourpassword
-
-## Site dedicated to these categories/characters/ships
-extracategories:Harry Potter
-
[www.destinysgateway.com]
## Some sites do not require a login, but do require the user to
## confirm they are adult for adult content. In commandline version,
@@ -1507,14 +1490,6 @@ extracategories:InuYasha
extracharacters:Sesshoumaru,Kagome
extraships:Sesshoumaru/Kagome
-[www.dotmoon.net]
-## Some sites require login (or login for some rated stories) The
-## program can prompt you, or you can save it in config. In
-## commandline version, this should go in your personal.ini, not
-## defaults.ini.
-#username:YourName
-#password:yourpassword
-
[www.efpfanfic.net]
## Some sites require login (or login for some rated stories) The
## program can prompt you, or you can save it in config. In
@@ -1683,10 +1658,6 @@ make_linkhtml_entries:prequel,sequels,groups,coverSource
## Site dedicated to these categories/characters/ships
extracategories:Harry Potter
-[www.henneth-annun.net]
-## Site dedicated to these categories/characters/ships
-extracategories:The Hobbit
-
[www.hpfandom.net]
## Some sites do not require a login, but do require the user to
## confirm they are adult for adult content. In commandline version,
@@ -1822,17 +1793,6 @@ extragenres:Erotica
extracategories:Glee
extracharacters:Kurt Hummel,Blaine Anderson
-[www.simplyundeniable.com]
-## Some sites require login (or login for some rated stories) The
-## program can prompt you, or you can save it in config. In
-## commandline version, this should go in your personal.ini, not
-## defaults.ini.
-#username:YourName
-#password:yourpassword
-
-## Site dedicated to these categories/characters/ships
-extracategories:Harry Potter
-
[www.sinful-desire.org]
## Some sites do not require a login, but do require the user to
## confirm they are adult for adult content. In commandline version,
@@ -1924,20 +1884,6 @@ extracategories:Twilight
## twilighted.net (ab)uses series as personal reading lists.
collect_series: false
-[www.twiwrite.net]
-## Some sites require login (or login for some rated stories) The
-## program can prompt you, or you can save it in config. In
-## commandline version, this should go in your personal.ini, not
-## defaults.ini.
-#username:YourName
-#password:yourpassword
-
-## Site dedicated to these categories/characters/ships
-extracategories:Twilight
-
-## twiwrite.net (ab)uses series as personal reading lists.
-collect_series: false
-
[www.walkingtheplank.org]
## Some sites do not require a login, but do require the user to
## confirm they are adult for adult content. In commandline version,
@@ -1951,19 +1897,6 @@ extraships:Severus Snape/Harry Potter
[www.whofic.com]
-[www.wizardtales.net]
-## Some sites require login (or login for some rated stories) The
-## program can prompt you, or you can save it in config. In
-## commandline version, this should go in your personal.ini, not
-## defaults.ini.
-#username:YourName
-#password:yourpassword
-
-## Some sites also require the user to confirm they are adult for
-## adult content. In commandline version, this should go in your
-## personal.ini, not defaults.ini.
-#is_adult:true
-
[www.wolverineandrogue.com]
## Site dedicated to these categories/characters/ships
extracategories:X-Men Movie
diff --git a/fanficfare/example.ini b/fanficfare/example.ini
index f8cd376..b31984c 100644
--- a/fanficfare/example.ini
+++ b/fanficfare/example.ini
@@ -57,12 +57,6 @@
#username:YourUsername
#password:YourPassword
-[www.twiwrite.net]
-#username:YourName
-#password:yourpassword
-## default is false
-#collect_series: true
-
[www.adastrafanfic.com]
## Some sites do not require a login, but do require the user to
## confirm they are adult for adult content.