Add author_avatar_cover option for base_xenforoforum.

This commit is contained in:
Jim Miller 2017-01-14 15:45:04 -06:00
parent fea4cef885
commit 69acd90c8b
4 changed files with 26 additions and 3 deletions

View file

@ -426,7 +426,11 @@ bulk_load:true
[base_xenforoforum]
cover_exclusion_regexp:/styles/
## exclude emoji and default avatars.
cover_exclusion_regexp:(/styles/|xenforo/avatars/avatar.*\.png)
## use author(original poster)'s avatar as cover image when true.
author_avatar_cover:false
## I saw lots of chapters name simply '1.1' etc during testing.
strip_chapter_numbers:false

View file

@ -273,9 +273,22 @@ class BaseXenForoForumAdapter(BaseSiteAdapter):
# author moved down here to take from post URLs.
a = souptag.find('h3',{'class':'userText'}).find('a')
self.story.addToList('authorId',a['href'].split('/')[1])
self.story.addToList('authorUrl',self.getURLPrefix()+'/'+a['href'])
authorUrl = self.getURLPrefix()+'/'+a['href']
self.story.addToList('authorUrl',authorUrl)
self.story.addToList('author',a.text)
if self.getConfig('author_avatar_cover'):
authorcard = self.make_soup(self._fetchUrl(authorUrl+"?card=1"))
coverurl = '/'+authorcard.find('div',{'class':'avatarCropper'}).find('img')['src']
self.setCoverImage(self.url,coverurl)
## https://forums.spacebattles.com/members/mp3-1415player.322925/?card=1
## <div class="avatarCropper">
## <a class="avatar NoOverlay Av322925l" href="members/mp3-1415player.322925/">
## <img src="data/avatars/l/322/322925.jpg?1471421076" alt="" style="left: 0px; top: -92px; " />
## </a>
##
## </div>
# Now go hunting for the 'chapter list'.
bq = souptag.find('blockquote') # assume first posting contains TOC urls.

View file

@ -201,6 +201,7 @@ def get_valid_set_options():
'always_reload_first_chapter':(base_xenforo_list,None,boollist),
'always_use_forumtags':(base_xenforo_list,None,boollist),
'use_reader_mode':(base_xenforo_list,None,boollist),
'author_avatar_cover':(base_xenforo_list,None,boollist),
'remove_spoilers':(base_xenforo_list,None,boollist),
'legend_spoilers':(base_xenforo_list,None,boollist),
}
@ -382,6 +383,7 @@ def get_valid_keywords():
'always_reload_first_chapter',
'always_use_forumtags',
'use_reader_mode',
'author_avatar_cover',
'reader_posts_per_page',
'remove_spoilers',
'legend_spoilers',

View file

@ -464,7 +464,11 @@ bulk_load:true
[base_xenforoforum]
cover_exclusion_regexp:/styles/
## exclude emoji and default avatars.
cover_exclusion_regexp:(/styles/|xenforo/avatars/avatar.*\.png)
## use author(original poster)'s avatar as cover image when true.
author_avatar_cover:false
## I saw lots of chapters name simply '1.1' etc during testing.
strip_chapter_numbers:false