From fe64b38339a1fc81d432cc42f5c5db600d91fccb Mon Sep 17 00:00:00 2001 From: blank X Date: Sun, 28 Mar 2021 18:22:18 +0700 Subject: [PATCH] Show featured in anime/manga/LN in character hope it's gonna work --- sukuinote/slave-plugins/anilist.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/sukuinote/slave-plugins/anilist.py b/sukuinote/slave-plugins/anilist.py index 099d85e..abdee3f 100644 --- a/sukuinote/slave-plugins/anilist.py +++ b/sukuinote/slave-plugins/anilist.py @@ -65,6 +65,18 @@ CHARACTER_QUERY = '''query ($id: Int, $search: String) { image { large } + media { + nodes { + title { + romaji + english + native + } + type + format + siteUrl + } + } siteUrl } } @@ -144,11 +156,27 @@ async def generate_character(anilist): description = re.sub(r"(.+)", hide_spoiler, (anilist.get('description') or '').strip()) site_url = anilist['siteUrl'] image = anilist['image']['large'] + media = anilist['media'] text = f'{title_full}' if title_native: text += f' ({title_native})' if title_alternative: text += f'\nSynonyms: {title_alternative}' + if media: + text += f'\nFeatured In:{" " if len(media) == 1 else "\n"}' + to_add = [] + for i in media: + atext = f'{i["title"]["romaji"]}' + if i['title']['english']: + atext += f' ({i["title"]["english"]})' + if i['title']['native']: + atext += f' ({i["title"]["native"]})' + if i['format'] == 'NOVEL': + type = 'Light Novel' + else: + type = anilist['type'].capitalize() + to_add.append(atext + f' [{type}]') + text += '\n'.join(to_add) if description: text += '\n' parser = pyrogram_html.HTML(None)