From 3dfa3cfff7ed0f276e81c71cf031def332fe1fd4 Mon Sep 17 00:00:00 2001 From: blank X Date: Wed, 9 Mar 2022 20:56:39 +0700 Subject: [PATCH] Hide native spoiler tags --- sukuinote/slave-plugins/anilist.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sukuinote/slave-plugins/anilist.py b/sukuinote/slave-plugins/anilist.py index 7fa8b69..7401a61 100644 --- a/sukuinote/slave-plugins/anilist.py +++ b/sukuinote/slave-plugins/anilist.py @@ -82,9 +82,6 @@ CHARACTER_QUERY = '''query ($id: Int, $search: String) { } }''' -def hide_spoiler(match): - return re.sub(r'\S', '█', match.group(1)) - async def generate_media(anilist): title_romaji = anilist['title']['romaji'] title_english = anilist['title']['english'] @@ -96,7 +93,7 @@ async def generate_media(anilist): format = anilist['format'] format = FORMAT_NAMES.get(format, format) status = (anilist['status'] or 'Unknown').replace('_', ' ').title() - description = re.sub(r"(.+)", hide_spoiler, (anilist.get('description') or '').strip()) + description = re.sub(r"([\s\S]+?)", r'\1', (anilist.get('description') or '').strip()) episodes = anilist['episodes'] duration = anilist['duration'] chapters = anilist['chapters'] @@ -153,7 +150,7 @@ async def generate_character(anilist): title_full = anilist['name']['full'] title_native = anilist['name']['native'] title_alternative = ', '.join(anilist['name']['alternative']) - description = re.sub(r"(.+)", hide_spoiler, (anilist.get('description') or '').strip()) + description = re.sub(r"([\s\S]+?)", r'\1', (anilist.get('description') or '').strip()) site_url = anilist['siteUrl'] image = anilist['image']['large'] media = anilist['media']