From b2ea9c3e738063aa0b312c07db0bfbf1644884f7 Mon Sep 17 00:00:00 2001 From: wsuetholz Date: Wed, 10 Nov 2010 11:18:48 -0600 Subject: [PATCH] Changed the title page generation to allow for easily adding and removing entries from the table of information shown. Modified ffnet.py to use the mangled story title if given instead of the name portion of the URL. As part of this, the Name and chapter number are now optional in the URL passed in. --- adapter.py | 3 +++ constants.py | 18 +++++++----------- ffnet.py | 34 ++++++++++++++++++++++++---------- fictionalley.py | 4 ++++ ficwad.py | 4 ++++ hpfiction.py | 4 ++++ output.py | 21 ++++++++++++++++++++- twilighted.py | 4 ++++ 8 files changed, 70 insertions(+), 22 deletions(-) diff --git a/adapter.py b/adapter.py index 246f417..b7708f4 100644 --- a/adapter.py +++ b/adapter.py @@ -29,6 +29,9 @@ class FanfictionSiteAdapter: def setPassword(self, password): pass + def getHost(self): + pass + def getStoryURL(self): pass diff --git a/constants.py b/constants.py index 89b0ef0..294ae4b 100644 --- a/constants.py +++ b/constants.py @@ -27,20 +27,16 @@ h7 { text-align: left; font-size: large; font-weight: bold; } MIMETYPE = '''application/epub+zip''' -TITLE_PAGE = ''' +TITLE_HEADER = ''' %s - %s

%s by %s

- - - - - - - - -
Category:%s
Genre:%s
Status:%s
Published:%s
Updated:%s
Packaged:%s
Rating Age/User:%s / %s
Chapters/Words:%s / %s
-

URL:


%s

+''' + +TITLE_ENTRY = '''%s%s +''' + +TITLE_FOOTER = '''

Summary:
%s

''' diff --git a/ffnet.py b/ffnet.py index 7320ec5..3f9f41e 100644 --- a/ffnet.py +++ b/ffnet.py @@ -68,21 +68,29 @@ class FFNet(FanfictionSiteAdapter): logging.debug('self.path=%s' % self.path) - spl = self.path.split('/') - logging.debug('spl=%s' % spl) - if len(spl) == 5: - self.path = "/".join(spl[1:-1]) - self.outputName = spl[4] + '-ffnet_' + spl[2] - if self.path.startswith('/'): self.path = self.path[1:] + spl = self.path.split('/') + logging.debug('spl=%s' % spl) + if spl is not None: + if len(spl) > 0 and spl[0] != 's': + logging.error("Error URL \"%s\" is not a story." % self.url) + exit (20) + if len(spl) > 1: + self.storyId = spl[1] + if len(spl) > 2: + chapter = spl[1] + else: + chapter = '1' + if len(spl) == 5: + self.path = "/".join(spl[1:-1]) + self.outputName = spl[4] + '-ffnet_' + spl[2] + if self.path.endswith('/'): self.path = self.path[:-1] logging.debug('self.path=%s' % self.path) - - (s, self.storyId, chapter) = self.path.split('/') self.uuid = 'urn:uuid:' + self.host + '-u.' + self.authorId + '-s.' + self.storyId logging.debug('self.uuid=%s' % self.uuid) @@ -190,12 +198,14 @@ class FFNet(FanfictionSiteAdapter): if l.find("»") != -1 and l.find('') != -1: s2 = bs.BeautifulStoneSoup(l) self.storyName = str(s2.find('b').string) - logging.debug('self.storyId=%s self.storyName=%s' % (self.storyId, self.storyName)) + # mangling storyName replaces url for outputName + self.outputName = self.storyName.replace(" ", "_") + '-ffnet_' + self.storyId + logging.debug('self.storyId=%s, self.storyName=%s, self.outputName=%s' % (self.storyId, self.storyName, self.outputName)) elif l.find("