tipue_search: fix description and add descriptionHtml
This commit is contained in:
parent
41f34ce402
commit
6760bb2e35
@ -62,9 +62,21 @@ class Tipue_Search_JSON_Generator(object):
|
|||||||
soup_title = BeautifulSoup(article.title.replace(' ', ' '), 'html.parser')
|
soup_title = BeautifulSoup(article.title.replace(' ', ' '), 'html.parser')
|
||||||
video_title = soup_title.get_text(' ', strip=True).replace('“', '"').replace('”', '"').replace('’', "'").replace('^', '^')
|
video_title = soup_title.get_text(' ', strip=True).replace('“', '"').replace('”', '"').replace('’', "'").replace('^', '^')
|
||||||
|
|
||||||
soup_text = BeautifulSoup(article.content, 'html.parser')
|
# description
|
||||||
video_text = soup_text.get_text(' ', strip=True).replace('“', '"').replace('”', '"').replace('’', "'").replace('¶', ' ').replace('^', '^')
|
art_desc = BeautifulSoup(article.content, 'html.parser')
|
||||||
video_text = ' '.join(video_text.split())
|
|
||||||
|
# fix ignore <h1> inside <figure> description
|
||||||
|
try:
|
||||||
|
art_desc = art_desc.find('figure').find_all_next('p')
|
||||||
|
art_desc_html = ''.join(map(str, art_desc))
|
||||||
|
art_desc = BeautifulSoup(art_desc_html, 'html.parser')
|
||||||
|
video_desc_html = art_desc_html.replace('\n', ' ')
|
||||||
|
except:
|
||||||
|
video_desc_html = ''.join(map(str, art_desc)).replace('\n', ' ')
|
||||||
|
pass
|
||||||
|
|
||||||
|
video_desc_text = art_desc.get_text(' ', strip=True).replace('“', '"').replace('”', '"').replace('’', "'").replace('¶', ' ').replace('^', '^')
|
||||||
|
video_desc_text = ' '.join(video_desc_text.split())
|
||||||
|
|
||||||
# base url
|
# base url
|
||||||
if self.relative_urls:
|
if self.relative_urls:
|
||||||
@ -118,7 +130,8 @@ class Tipue_Search_JSON_Generator(object):
|
|||||||
video_tags = dict((num, tag) for num, tag in enumerate(data_tags))
|
video_tags = dict((num, tag) for num, tag in enumerate(data_tags))
|
||||||
|
|
||||||
node = {'title': video_title,
|
node = {'title': video_title,
|
||||||
'description': video_text,
|
'description': video_desc_text,
|
||||||
|
'descriptionHtml': video_desc_html,
|
||||||
'videoThumbnail': url_image,
|
'videoThumbnail': url_image,
|
||||||
'formatStreams': {
|
'formatStreams': {
|
||||||
'url': video_src,
|
'url': video_src,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user