Skip to content

Commit

Permalink
added icon_url and hyperlink to create_chapter_embed
Browse files Browse the repository at this point in the history
  • Loading branch information
MooshiMochi committed Feb 20, 2024
1 parent d8512ce commit 9156f0c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
47 changes: 23 additions & 24 deletions src/core/scanlators/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ def create_chapter_embed(
embed = discord.Embed(
title=f"{manga.title} - {chapter.name}",
url=chapter.url)
embed.set_author(name=self.name.title())
embed.set_author(
name=self.name.title(),
url=self.json_tree.properties.base_url,
icon_url=self.json_tree.properties.icon_url
)
embed.description = f"Read {manga.title} online for free on {self.name.title()}!"
if self.json_tree.properties.can_render_cover:
embed.set_image(url=manga.cover_url if not image_url else image_url)
Expand Down Expand Up @@ -384,29 +388,24 @@ async def check_updates(
MangaNotFoundError - If the manga is not found in the scanlator's website.
URLAccessFailed - If the scanlator's website is blocked by Cloudflare.
"""
try:
all_chapters = await self.get_all_chapters(manga.url)
status: str = await self.get_status(manga.url)
cover_url: str = await self.get_cover(manga.url)
if all_chapters is None:
return ChapterUpdate(manga.id, [], manga.scanlator, cover_url, status)
if manga.last_chapter:
new_chapters: list[Chapter] = [
chapter for chapter in all_chapters if chapter.index > manga.last_chapter.index
]
else:
new_chapters: list[Chapter] = all_chapters
return ChapterUpdate(
manga.id, new_chapters, manga.scanlator, cover_url, status,
[
{"embed": self.create_chapter_embed(manga, chapter)}
for chapter in new_chapters
] if self.json_tree.properties.requires_update_embed else None
)
except Exception as e:
tb = "".join(traceback.format_exception(type(e), e, e.__traceback__))
await self.bot.log_to_discord(tb)
raise e
all_chapters = await self.get_all_chapters(manga.url)
status: str = await self.get_status(manga.url)
cover_url: str = await self.get_cover(manga.url)
if all_chapters is None:
return ChapterUpdate(manga.id, [], manga.scanlator, cover_url, status)
if manga.last_chapter:
new_chapters: list[Chapter] = [
chapter for chapter in all_chapters if chapter.index > manga.last_chapter.index
]
else:
new_chapters: list[Chapter] = all_chapters
return ChapterUpdate(
manga.id, new_chapters, manga.scanlator, cover_url, status,
[
{"embed": self.create_chapter_embed(manga, chapter)}
for chapter in new_chapters
] if self.json_tree.properties.requires_update_embed else None
)

async def report_error(
self,
Expand Down
4 changes: 3 additions & 1 deletion src/core/scanlators/lookup_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -2429,7 +2429,9 @@
"ajax": "https://soft.epsilonscan.fr/manga/{url_name}/ajax/chapters"
},
"latest_updates_url": "https://soft.epsilonscan.fr/",
"dynamicURL": false
"dynamicURL": false,
"requires_update_embed": true,
"can_render_cover": true
},
"selectors": {
"title": [
Expand Down

0 comments on commit 9156f0c

Please sign in to comment.