diff options
author | Jesús <heckyel@hyperbola.info> | 2020-06-14 17:03:36 -0500 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2020-06-14 17:03:36 -0500 |
commit | 6760bb2e3505240acbbf2326e47f21c5c6c6a477 (patch) | |
tree | 19fe01b01dac7175bb6ea80f9ba587a907ecd21d | |
parent | 41f34ce402a77df40465df2d63662c3427ae0270 (diff) | |
download | libretube-6760bb2e3505240acbbf2326e47f21c5c6c6a477.tar.lz libretube-6760bb2e3505240acbbf2326e47f21c5c6c6a477.tar.xz libretube-6760bb2e3505240acbbf2326e47f21c5c6c6a477.zip |
tipue_search: fix description and add descriptionHtml
-rw-r--r-- | plugins/tipue-search/tipue_search.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/plugins/tipue-search/tipue_search.py b/plugins/tipue-search/tipue_search.py index 5928576..788a8b9 100644 --- a/plugins/tipue-search/tipue_search.py +++ b/plugins/tipue-search/tipue_search.py @@ -62,9 +62,21 @@ class Tipue_Search_JSON_Generator(object): soup_title = BeautifulSoup(article.title.replace(' ', ' '), 'html.parser') video_title = soup_title.get_text(' ', strip=True).replace('“', '"').replace('”', '"').replace('’', "'").replace('^', '^') - soup_text = BeautifulSoup(article.content, 'html.parser') - video_text = soup_text.get_text(' ', strip=True).replace('“', '"').replace('”', '"').replace('’', "'").replace('¶', ' ').replace('^', '^') - video_text = ' '.join(video_text.split()) + # description + art_desc = BeautifulSoup(article.content, 'html.parser') + + # 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 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)) node = {'title': video_title, - 'description': video_text, + 'description': video_desc_text, + 'descriptionHtml': video_desc_html, 'videoThumbnail': url_image, 'formatStreams': { 'url': video_src, |