Skip to content

Commit

Permalink
Except inaccessible error
Browse files Browse the repository at this point in the history
  • Loading branch information
BurnySc2 committed Aug 21, 2023
1 parent 4dede66 commit 5d8cb1c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Status(enum.Enum):
NO_MEDIA = 5
ERROR_DOWNLOADING = 7
ERROR_EXTRACTING_AUDIO = 8
ERROR_CHANNEL_INACCESSIBLE = 9


# pyre-fixme[11]
Expand Down
19 changes: 13 additions & 6 deletions transcribe_website/transcriber_backend/src/telegram_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,19 @@ async def download_one(worker_id: int | None = None) -> None:
two_hundred_message_ids: list[int] = TelegramMessage.get_n_queued_by_channel(message.channel_id)
if len(two_hundred_message_ids) > 200:
raise ValueError("The api does not allow more than 200 messages to be downloaded at once.")
# pyre-fixme[9]
up_to_date_messages: list[Message] = await DownloadWorker.client.get_messages(
chat_id=message.channel_id,
message_ids=two_hundred_message_ids,
replies=0,
)
try:
# pyre-fixme[9]
up_to_date_messages: list[Message] = await DownloadWorker.client.get_messages(
chat_id=message.channel_id,
message_ids=two_hundred_message_ids,
replies=0,
)
except UsernameNotOccupied:
# Error when trying to download from channel that is inaccessible
with orm.db_session():
message = TelegramMessage[message.id]
message.download_status = Status.ERROR_CHANNEL_INACCESSIBLE.name
return
update_file_ids_cache(message.channel_id, up_to_date_messages, two_hundred_message_ids)
file_id = get_from_file_ids_cache(message.channel_id, message.message_id)
if file_id is None or file_id == "UNKNOWN":
Expand Down

0 comments on commit 5d8cb1c

Please sign in to comment.