From 9212357fedfd683b5608d430d390856857280331 Mon Sep 17 00:00:00 2001
From: Jim Miller
Date: Tue, 30 Oct 2012 15:35:24 -0500
Subject: [PATCH] New site: www.efpfanfic.net
---
defaults.ini | 15 +
fanficdownloader/adapters/__init__.py | 1 +
.../adapters/adapter_efpfanficnet.py | 296 ++++++++++++++++++
index.html | 21 +-
plugin-defaults.ini | 15 +
5 files changed, 335 insertions(+), 13 deletions(-)
create mode 100644 fanficdownloader/adapters/adapter_efpfanficnet.py
diff --git a/defaults.ini b/defaults.ini
index 0e74405..47bd261 100644
--- a/defaults.ini
+++ b/defaults.ini
@@ -905,6 +905,21 @@ extracategories:InuYasha
extracharacters:Sesshoumaru,Kagome
extraships:Sesshoumaru/Kagome
+[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
+## commandline version, this should go in your personal.ini, not
+## defaults.ini.
+#username:YourName
+#password:yourpassword
+
+## Extra metadata that this adapter knows about. See [dramione.org]
+## for examples of how to use them.
+extra_valid_entries:notes,context,type
+notes_label:Notes
+context_label:Context
+type_label:Type of Couple
+
[www.fanfiction.net]
## fanfiction.net's 'cover' images are really just tiny thumbnails.
## Change this to false to use them anyway.
diff --git a/fanficdownloader/adapters/__init__.py b/fanficdownloader/adapters/__init__.py
index ce589f4..011c5b4 100644
--- a/fanficdownloader/adapters/__init__.py
+++ b/fanficdownloader/adapters/__init__.py
@@ -105,6 +105,7 @@ import adapter_bloodtiesfancom
import adapter_indeathnet
import adapter_jlaunlimitedcom
import adapter_qafficcom
+import adapter_efpfanficnet
## This bit of complexity allows adapters to be added by just adding
diff --git a/fanficdownloader/adapters/adapter_efpfanficnet.py b/fanficdownloader/adapters/adapter_efpfanficnet.py
new file mode 100644
index 0000000..55e60fd
--- /dev/null
+++ b/fanficdownloader/adapters/adapter_efpfanficnet.py
@@ -0,0 +1,296 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2012 Fanficdownloader 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 EFPFanFicNet
+
+# Class name has to be unique. Our convention is camel case the
+# sitename with Adapter at the end. www is skipped.
+class EFPFanFicNet(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])
+ logger.debug("storyId: (%s)"%self.story.getMetadata('storyId'))
+
+ # 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','efp')
+
+ # 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 'www.efpfanfic.net'
+
+ def getSiteExampleURLs(self):
+ return "http://"+self.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 'Fai il login e leggi la storia!' 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'] = 'Invia'
+
+ loginUrl = 'http://' + self.getSiteDomain() + '/user.php?sid='+self.story.getMetadata('storyId')
+ logger.debug("Will now login to URL (%s) as (%s)" % (loginUrl,
+ params['penname']))
+
+ d = self._fetchUrl(loginUrl, params)
+
+ if '
- New Sites:
+ New Site:
- Two new sites thanks to besnef:
+ New Italian language site:
-
- New Fixes:
-
-
- - Fixes for changes to fanfiktion.de formatting.
- - Fix for bad author on twiwritenet with some skins.
- - Change from www.ncisfiction.com to www.ncisfiction.net due to the ncisfiction.com domain expiring.
+ - www.efpfanfic.net
@@ -570,8 +561,12 @@
Use the URL of the story's first chapter, such as
http://www.jlaunlimited.com/eFiction1.1/viewstory.php?sid=1234
+
www.efpfanfic.net
+
+ Use the URL of any story chapter, such as
+
http://www.efpfanfic.net/viewstory.php?sid=12345
+
-
A few additional things to know, which will make your life substantially easier:
diff --git a/plugin-defaults.ini b/plugin-defaults.ini
index 64e5c0e..c8b7b7f 100644
--- a/plugin-defaults.ini
+++ b/plugin-defaults.ini
@@ -896,6 +896,21 @@ extracategories:InuYasha
extracharacters:Sesshoumaru,Kagome
extraships:Sesshoumaru/Kagome
+[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
+## commandline version, this should go in your personal.ini, not
+## defaults.ini.
+#username:YourName
+#password:yourpassword
+
+## Extra metadata that this adapter knows about. See [dramione.org]
+## for examples of how to use them.
+extra_valid_entries:notes,context,type
+notes_label:Notes
+context_label:Context
+type_label:Type of Couple
+
[www.fanfiction.net]
## fanfiction.net's 'cover' images are really just tiny thumbnails.
## Change this to false to use them anyway.