From e9f82c334362592b7e50feda9348887fb5a74ce2 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Sat, 4 Apr 2020 10:11:17 -0500 Subject: [PATCH] New Site: scifistories.com (extends finestories.com). --- calibre-plugin/plugin-defaults.ini | 91 +++++++++++++++++-- fanficfare/adapters/__init__.py | 1 + .../adapters/adapter_scifistoriescom.py | 41 +++++++++ fanficfare/defaults.ini | 91 +++++++++++++++++-- 4 files changed, 204 insertions(+), 20 deletions(-) create mode 100644 fanficfare/adapters/adapter_scifistoriescom.py diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini index 121d66ee..9a6d1f93 100644 --- a/calibre-plugin/plugin-defaults.ini +++ b/calibre-plugin/plugin-defaults.ini @@ -1606,6 +1606,16 @@ extracategories:Harry Potter website_encodings:Windows-1252,utf8 +[fanfic.tenhawkpresents.ink] +## 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 + +website_encodings:Windows-1252,utf8 + [fanficauthors.net] ## Some sites require login (or login for some rated stories) The ## program can prompt you, or you can save it in config. In @@ -1644,16 +1654,6 @@ include_in_category:fandoms [fanfiction-junkies.de] website_encodings:Windows-1252,utf8 -[fanfic.tenhawkpresents.ink] -## 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 - -website_encodings:Windows-1252,utf8 - [fictionhunt.com] ## Some sites require login (or login for some rated stories) The ## program can prompt you, or you can save it in config. In @@ -2101,6 +2101,77 @@ extraships:Sam/Jack website_encodings:Windows-1252,utf8 +[scifistories.com:epub] +## This is a workaround to replace truncated chapter titles present in +## chapter list. Uncomment this to remove the usual, shorter chapter +## title in the chapter files only. See inject_chapter_title below. +#chapter_start: +# +# +# +# ${chapter} +# +# +# +# +# +# +# + +[scifistories.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. +## scifistories.com has started requiring login by email rather than +## pen name. +#username:youremail@yourdomain.dom +#password:yourpassword + +## dateUpdated/datePublished don't usually have time, but they do on this site. +## http://docs.python.org/library/datetime.html#strftime-strptime-behavior +## Note that ini format requires % to be escaped as %%. +dateUpdated_format:%%Y-%%m-%%d %%H:%%M:%%S +datePublished_format:%%Y-%%m-%%d %%H:%%M:%%S + +## Clear FanFiction from defaults, site is original fiction. +extratags: + +extra_valid_entries:size,universe,universeUrl,universeHTML,sitetags,notice,codes,score +#extra_titlepage_entries:size,universeHTML,sitetags,notice,score +include_in_codes:sitetags + +## adds to include_subject_tags instead of replacing it. +#extra_subject_tags:sitetags + +size_label:Size +universe_label:Universe +universeUrl_label:Universe URL +universeHTML_label:Universe +sitetags_label:Site Tags +notice_label:Notice +score_label:Score + +## Assume entryUrl, apply to "%s" to +## make entryHTML. +make_linkhtml_entries:universe + +## scifistories.com stories can be in a series and/or a universe. By +## default, series will be populated with the universe if there is +## universe but not series. +universe_as_series: true + +## some sites include images that we don't ever want becoming the +## cover image. This lets you exclude them. +cover_exclusion_regexp:/css/bir.png + +## This site uses shortened title chapters in chapter lists. When set +## true, this will inject the site's full length chapter title into +## the chapter text. Typically will be used with chapter_start to +## remove the standard chapter title, as shown above in +## [scifistories.com:epub]. +#inject_chapter_title:false + [sheppardweir.com] ## Some sites require login (or login for some rated stories) The ## program can prompt you, or you can save it in config. In diff --git a/fanficfare/adapters/__init__.py b/fanficfare/adapters/__init__.py index 698bb3f9..1828c8f4 100644 --- a/fanficfare/adapters/__init__.py +++ b/fanficfare/adapters/__init__.py @@ -167,6 +167,7 @@ from . import adapter_mugglenetfanfictioncom from . import adapter_swiorgru from . import adapter_fanficsme from . import adapter_archivehpfanfictalkcom +from . import adapter_scifistoriescom ## This bit of complexity allows adapters to be added by just adding ## importing. It eliminates the long if/else clauses we used to need diff --git a/fanficfare/adapters/adapter_scifistoriescom.py b/fanficfare/adapters/adapter_scifistoriescom.py new file mode 100644 index 00000000..1525c6b5 --- /dev/null +++ b/fanficfare/adapters/adapter_scifistoriescom.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- + +# Copyright 2013 Fanficdownloader team, 2020 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. +# + +from __future__ import absolute_import +import logging +logger = logging.getLogger(__name__) + +# py2 vs py3 transition +from ..six import text_type as unicode + +from .adapter_finestoriescom import FineStoriesComAdapter + +def getClass(): + return SciFiStoriesComAdapter + +# Class name has to be unique. Our convention is camel case the +# sitename with Adapter at the end. www is skipped. +class SciFiStoriesComAdapter(FineStoriesComAdapter): + + @classmethod + def getSiteAbbrev(cls): + return 'sfst' + + @staticmethod # must be @staticmethod, don't remove it. + def getSiteDomain(): + # The site domain. Does have www here, if it uses it. + return 'scifistories.com' diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini index b51c6213..842869c4 100644 --- a/fanficfare/defaults.ini +++ b/fanficfare/defaults.ini @@ -1639,6 +1639,16 @@ extracategories:Harry Potter website_encodings:Windows-1252,utf8 +[fanfic.tenhawkpresents.ink] +## 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 + +website_encodings:Windows-1252,utf8 + [fanficauthors.net] ## Some sites require login (or login for some rated stories) The ## program can prompt you, or you can save it in config. In @@ -1677,16 +1687,6 @@ include_in_category:fandoms [fanfiction-junkies.de] website_encodings:Windows-1252,utf8 -[fanfic.tenhawkpresents.ink] -## 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 - -website_encodings:Windows-1252,utf8 - [fictionhunt.com] ## Some sites require login (or login for some rated stories) The ## program can prompt you, or you can save it in config. In @@ -2134,6 +2134,77 @@ extraships:Sam/Jack website_encodings:Windows-1252,utf8 +[scifistories.com:epub] +## This is a workaround to replace truncated chapter titles present in +## chapter list. Uncomment this to remove the usual, shorter chapter +## title in the chapter files only. See inject_chapter_title below. +#chapter_start: +# +# +# +# ${chapter} +# +# +# +# +# +# +# + +[scifistories.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. +## scifistories.com has started requiring login by email rather than +## pen name. +#username:youremail@yourdomain.dom +#password:yourpassword + +## dateUpdated/datePublished don't usually have time, but they do on this site. +## http://docs.python.org/library/datetime.html#strftime-strptime-behavior +## Note that ini format requires % to be escaped as %%. +dateUpdated_format:%%Y-%%m-%%d %%H:%%M:%%S +datePublished_format:%%Y-%%m-%%d %%H:%%M:%%S + +## Clear FanFiction from defaults, site is original fiction. +extratags: + +extra_valid_entries:size,universe,universeUrl,universeHTML,sitetags,notice,codes,score +#extra_titlepage_entries:size,universeHTML,sitetags,notice,score +include_in_codes:sitetags + +## adds to include_subject_tags instead of replacing it. +#extra_subject_tags:sitetags + +size_label:Size +universe_label:Universe +universeUrl_label:Universe URL +universeHTML_label:Universe +sitetags_label:Site Tags +notice_label:Notice +score_label:Score + +## Assume entryUrl, apply to "%s" to +## make entryHTML. +make_linkhtml_entries:universe + +## scifistories.com stories can be in a series and/or a universe. By +## default, series will be populated with the universe if there is +## universe but not series. +universe_as_series: true + +## some sites include images that we don't ever want becoming the +## cover image. This lets you exclude them. +cover_exclusion_regexp:/css/bir.png + +## This site uses shortened title chapters in chapter lists. When set +## true, this will inject the site's full length chapter title into +## the chapter text. Typically will be used with chapter_start to +## remove the standard chapter title, as shown above in +## [scifistories.com:epub]. +#inject_chapter_title:false + [sheppardweir.com] ## Some sites require login (or login for some rated stories) The ## program can prompt you, or you can save it in config. In