From 81eb00a76771526390785e00cf148601dfcf2845 Mon Sep 17 00:00:00 2001 From: msramalho <19508417+msramalho@users.noreply.github.com> Date: Thu, 16 Jun 2022 16:19:57 +0200 Subject: [PATCH] handle deleted telegram --- archivers/telethon_archiver.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/archivers/telethon_archiver.py b/archivers/telethon_archiver.py index 6407f09..efef1cc 100644 --- a/archivers/telethon_archiver.py +++ b/archivers/telethon_archiver.py @@ -29,7 +29,7 @@ class TelethonArchiver(Archiver): Returns a list of [post] where each post has media and is in the same grouped_id """ if getattr_or(original_post, "grouped_id") is None: - return [original_post] if getattr_or(original_post, "media") is not None else [] + return [original_post] if getattr_or(original_post, "media") else [] search_ids = [i for i in range(original_post.id - max_amp, original_post.id + max_amp + 1)] posts = self.client.get_messages(chat, ids=search_ids) @@ -67,6 +67,8 @@ class TelethonArchiver(Archiver): logger.error(f"Could not fetch telegram {url}. This error can be fixed if you setup a bot_token in addition to api_id and api_hash: {e}") return False + if post is None: return False + media_posts = self._get_media_posts_in_group(chat, post) logger.debug(f'got {len(media_posts)=} for {url=}') @@ -111,4 +113,4 @@ class TelethonArchiver(Archiver): return ArchiveResult(status=status, cdn_url=cdn_url, title=post.message, thumbnail=key_thumb, thumbnail_index=thumb_index, timestamp=post.date, hash=hash, screenshot=screenshot) page_cdn, page_hash, _ = self.generate_media_page_html(url, [], html.escape(str(post))) - return ArchiveResult(status=status, cdn_url=page_cdn, title=getattr_or(post, "message", ""), timestamp=getattr_or(post, "date"), hash=page_hash, screenshot=screenshot) + return ArchiveResult(status=status, cdn_url=page_cdn, title=post.message, timestamp=getattr_or(post, "date"), hash=page_hash, screenshot=screenshot)