From 118371b819955ffa23de1b1b26d515098c74fc13 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Sun, 15 Jan 2017 18:47:39 -0600 Subject: [PATCH] Minor fixes to adapter_asianfanficscom. --- calibre-plugin/plugin-defaults.ini | 41 +++++++++++++++++++ .../adapters/adapter_asianfanficscom.py | 27 ++++++------ fanficfare/defaults.ini | 28 +++++++------ 3 files changed, 70 insertions(+), 26 deletions(-) diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini index f54bd106..9d91a2cb 100644 --- a/calibre-plugin/plugin-defaults.ini +++ b/calibre-plugin/plugin-defaults.ini @@ -1864,6 +1864,47 @@ continue_on_chapter_error:true ## Site dedicated to these categories/characters/ships extracategories:Star Trek +[www.asianfanfics.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 + +## 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 + +## Additional metadata entries. +extra_valid_entries:tags,characters,upvotes,subscribers,views +tags_label:Tags +characters_label:Characters +upvotes_label:Upvotes +subscribers_label:Subscribers +views_label:Views + +include_in_category:tags + +#extra_titlepage_entries:upvotes,subscribers,views + +## This is a workaround to replace AFF's abbreviated chapter titles +## present in chapter list. Uncomment this to remove the usual, +## shorter chapter title. +#chapter_start: +# +# +# +# ${chapter} +# +# +# +# +# +# +# + [www.asexstories.com] ## Some sites also require the user to confirm they are adult for ## adult content. Uncomment by removing '#' in front of is_adult. diff --git a/fanficfare/adapters/adapter_asianfanficscom.py b/fanficfare/adapters/adapter_asianfanficscom.py index 805c1012..68561836 100644 --- a/fanficfare/adapters/adapter_asianfanficscom.py +++ b/fanficfare/adapters/adapter_asianfanficscom.py @@ -23,12 +23,13 @@ class AsianFanFicsComAdapter(BaseSiteAdapter): BaseSiteAdapter.__init__(self, config, url) self.decode = ["utf8", - "Windows-1252"] # 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. - - + "Windows-1252"] # 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 = "" self.password = "" self.is_adult=False @@ -76,7 +77,7 @@ class AsianFanFicsComAdapter(BaseSiteAdapter): else: params['username'] = self.getConfig("username") params['password'] = self.getConfig("password") - + params['from_url'] = url params['csrf_aff_token'] = data.split('input type="hidden" name="csrf_aff_token" value="')[1].split('"')[0] loginUrl = 'https://' + self.getSiteDomain() + '/login/check' @@ -139,7 +140,7 @@ class AsianFanFicsComAdapter(BaseSiteAdapter): ## Title a = soup.find('h1', {'id': 'story-title'}) self.story.setMetadata('title',stripHTML(a)) - + # Find authorid and URL from... author url. alist = soup.find('div', {'class': 'main-meta__sec'}) alist = alist.find('span', text='Author(s)') @@ -194,18 +195,18 @@ class AsianFanFicsComAdapter(BaseSiteAdapter): a = a.find('span',text='Characters') if a: self.story.addToList('characters', a.nextSibling) - + # published on a = soup.find('span', text='Published') a = a.parent.find('time') self.story.setMetadata('datePublished', makeDate(a['datetime'], self.dateformat)) - + # updated on a = soup.find('span', text='Updated') if a: a = a.parent.find('time') self.story.setMetadata('dateUpdated', makeDate(a['datetime'], self.dateformat)) - + # upvote, subs, and views a = soup.find('div',{'class':'title-meta'}) spans = a.findAll('span', recursive=False) @@ -213,7 +214,7 @@ class AsianFanFicsComAdapter(BaseSiteAdapter): self.story.addToList('subscribers', re.search('\(([^)]+)', spans[1].find('span').text).group(1)) if enumerate(spans) == 2: # views can be private self.story.addToList('views', spans[2].find('span').text.split()[0]) - + # cover art in the form of a div before chapter content if get_cover: cover_url = "" @@ -243,4 +244,4 @@ class AsianFanFicsComAdapter(BaseSiteAdapter): raise exceptions.FailedToDownload("Error downloading Chapter: %s! Missing required element!" % url) if None == soup: - raise exceptions.FailedToDownload("Error downloading Chapter: %s! Missing required element!" % url) \ No newline at end of file + raise exceptions.FailedToDownload("Error downloading Chapter: %s! Missing required element!" % url) diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini index 0157767f..6c0ca6a5 100644 --- a/fanficfare/defaults.ini +++ b/fanficfare/defaults.ini @@ -1907,19 +1907,21 @@ include_in_category:tags #extra_titlepage_entries:upvotes,subscribers,views -## This is a workaround to replace AFF's abbreviated chapter titles present in chapter list -chapter_start: - - - - ${chapter} - - - - - - - +## This is a workaround to replace AFF's abbreviated chapter titles +## present in chapter list. Uncomment this to remove the usual, +## shorter chapter title. +#chapter_start: +# +# +# +# ${chapter} +# +# +# +# +# +# +# [www.asexstories.com] ## Some sites also require the user to confirm they are adult for