mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2026-05-08 21:11:59 +02:00
adapter_wattpadcom: Add include_chapter_banner_images feature, defaults on
This commit is contained in:
parent
c0b6e918ad
commit
0113d07a63
4 changed files with 29 additions and 3 deletions
|
|
@ -2818,6 +2818,12 @@ add_to_comma_entries:,reads
|
|||
## are reports that sound like site throttling without it.
|
||||
slow_down_sleep_time:2
|
||||
|
||||
## wattpad.com chapters can have a banner image at the top of the
|
||||
## page. When include_chapter_banner_images:true the banner image
|
||||
## will be prepended to the chapter text during download as:
|
||||
## <img class="photoUrl banner-image" src="<img url>">
|
||||
include_chapter_banner_images:true
|
||||
|
||||
[www.adastrafanfic.com]
|
||||
use_basic_cache:true
|
||||
## Some sites do not require a login, but do require the user to
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ class WattpadComAdapter(BaseSiteAdapter):
|
|||
self.story.setMetadata('siteabbrev',self.getSiteAbbrev())
|
||||
self.story.setMetadata('storyId', self.storyId)
|
||||
self._setURL('https://www.wattpad.com/story/%s' % self.storyId)
|
||||
self.chapter_photoUrl = {}
|
||||
|
||||
# categoryDefs do not change all that often, if at all. Could be put in a constant, leaving it as a class var for now
|
||||
# note: classvar may be useless because of del adapter
|
||||
|
|
@ -98,7 +99,8 @@ class WattpadComAdapter(BaseSiteAdapter):
|
|||
def doExtractChapterUrlsAndMetadata(self, get_cover=True):
|
||||
try:
|
||||
storyInfo = json.loads(self.get_request(WattpadComAdapter.API_STORYINFO % self.storyId))
|
||||
# logger.debug('storyInfo: %s' % json.dumps(storyInfo))
|
||||
# logger.debug('storyInfo: %s' % json.dumps(storyInfo, sort_keys=True,
|
||||
# indent=2, separators=(',', ':')))
|
||||
except Exception:
|
||||
raise exceptions.InvalidStoryURL(self.url, self.getSiteDomain(), self.getSiteExampleURLs())
|
||||
|
||||
|
|
@ -126,7 +128,9 @@ class WattpadComAdapter(BaseSiteAdapter):
|
|||
self.story.setMetadata('dateUpdated', makeDate(storyInfo['modifyDate'].rstrip('Z'), "%Y-%m-%dT%H:%M:%S"))
|
||||
self.story.setMetadata('datePublished', makeDate(storyInfo['createDate'].rstrip('Z'), "%Y-%m-%dT%H:%M:%S"))
|
||||
|
||||
[self.add_chapter(part['title'], part['url']) for part in storyInfo['parts']]
|
||||
for part in storyInfo['parts']:
|
||||
self.add_chapter(part['title'], part['url'])
|
||||
self.chapter_photoUrl[part['url']] = part['photoUrl']
|
||||
self.setCoverImage(storyInfo['url'], storyInfo['cover'].replace('-256-','-512-'))
|
||||
self.story.setMetadata('language', storyInfo['language']['name'])
|
||||
|
||||
|
|
@ -145,7 +149,15 @@ class WattpadComAdapter(BaseSiteAdapter):
|
|||
def getChapterText(self, url):
|
||||
logger.debug('%s' % url)
|
||||
chapterID = re.search(r'https://www.wattpad.com/(?P<chapterID>\d+).*', url).group('chapterID')
|
||||
return self.utf8FromSoup(url,self.make_soup(self.get_request(WattpadComAdapter.API_STORYTEXT % chapterID)))
|
||||
data = self.get_request(WattpadComAdapter.API_STORYTEXT % chapterID)
|
||||
# logger.debug(self.chapter_photoUrl[url])
|
||||
imgdata = ''
|
||||
if self.chapter_photoUrl[url] and self.getConfig('include_chapter_banner_images',True):
|
||||
imgdata = '''
|
||||
<img class="photoUrl banner-image" src="%s">
|
||||
''' % self.chapter_photoUrl[url]
|
||||
# logger.debug(imgdata + data)
|
||||
return self.utf8FromSoup(url,self.make_soup(imgdata + data))
|
||||
|
||||
# adapter self-dicovery is not implemented in fanficfare (it existed for the previous project)
|
||||
def getClass():
|
||||
|
|
|
|||
|
|
@ -293,6 +293,7 @@ def get_valid_set_options():
|
|||
'use_threadmarks_cover':(base_xenforo2_list,None,boollist),
|
||||
'skip_sticky_first_posts':(base_xenforo2_list,None,boollist),
|
||||
'include_dice_rolls':(base_xenforo2_list,None,boollist+['svg']),
|
||||
'include_chapter_banner_images':(['wattpad.com'],None,boollist),
|
||||
'fix_excess_space': (['novelonlinefull.com', 'novelall.com'], ['epub', 'html'], boollist),
|
||||
'dedup_order_chapter_list': (['m.wuxiaworld.co', 'novelupdates.cc'], None, boollist),
|
||||
'show_nsfw_cover_images': (['fiction.live'], None, boollist),
|
||||
|
|
@ -541,6 +542,7 @@ def get_valid_keywords():
|
|||
'use_threadmarks_cover',
|
||||
'skip_sticky_first_posts',
|
||||
'include_dice_rolls',
|
||||
'include_chapter_banner_images',
|
||||
'datethreadmark_format',
|
||||
'fix_pseudo_html',
|
||||
'fix_excess_space',
|
||||
|
|
|
|||
|
|
@ -2839,6 +2839,12 @@ add_to_comma_entries:,reads
|
|||
## are reports that sound like site throttling without it.
|
||||
slow_down_sleep_time:2
|
||||
|
||||
## wattpad.com chapters can have a banner image at the top of the
|
||||
## page. When include_chapter_banner_images:true the banner image
|
||||
## will be prepended to the chapter text during download as:
|
||||
## <img class="photoUrl banner-image" src="<img url>">
|
||||
include_chapter_banner_images:true
|
||||
|
||||
[www.adastrafanfic.com]
|
||||
use_basic_cache:true
|
||||
## Some sites do not require a login, but do require the user to
|
||||
|
|
|
|||
Loading…
Reference in a new issue