telethon : download photos and AuthKeyError

Paul Zakharov

Probably a silly question. Certainly it's a problem with my code, but actually I got stuck and even not understand where to search.

I want to get the messages and the photos from a channel using telethon. No problem with messages I got them. Now, I try to get the photos (if there is any in the message).

All messages stored in a list called messages.

Here is my code to download photos :

for i, cur_mes in enumerate(messages) :
    print(i)
    print(cur_mes.date)
    print(cur_mes.message)
    if cur_mes.photo :
        print(cur_mes.photo)
        with client :
            try :
                client.download_media(cur_mes.photo,"./img/"+str(cur_mes.date)+".jpg")
            except FloodWaitError as ee:
                e = str(ee)
                time.sleep(int(re.search(r'\d+', e).group()))
                client.download_media(cur_mes.photo,"./img/"+str(cur_mes.date)+".jpg")

This code download the first photo. And then it stops with error :

telethon.errors.rpcbaseerrors.AuthKeyError: RPCError 406: FILEREF_UPGRADE_NEEDED (caused by GetFileRequest)

I don't understand "AuthKeyError: RPCError 406: FILEREF_UPGRADE_NEEDED". If I try to catch it (cause it's indicated that RPCErrors could be even on the server side), the code will continue to work, but all the photos (except first) are empties.

UPDATE: As @Lonami supposed in the comments, it was a problem of version. I was so sure to ave the laest that I did not think to check it.

pip3 install telethon --upgrade

solved the problem.

Paul Zakharov

As @Lonami supposed in the comments, it was a problem of version. I was so sure to ave the latest that I did not think to check it.

pip3 install telethon --upgrade

solved the problem.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to download a video using telethon

sending x photos after i click a button in a bot telethon telegram

How do I scrape photos and videos with Pyrogram or Telethon?

Telethon get media size before download

Download photos and videos from iPhone

Naming File When Using Download_Media in Telethon

Rename photos during download from camera - on Linux?

Download all photos from Facebook album

Download picasa web photos without picasa

Picasso sometimes not download photos and crash my application

Firebase Storage download multiple photos Urls

Download HEIC file in Google Photos as JPG

How to correctly use the iter_download functionality for multi connection downloads in Telethon

How to download photos from Flickr by Flickr API in Python 3

How to connect external camera to iPhone and take/download photos?

Download full resolution video from Google Photos API

Is it possible to download the photos from the weathercams on the FAA's website?

How to download photos attached to a message sent to my Telegram bot

How can I download all photos of the current user in the Facebook Graph PHP SDK?

digiKam 4.14.0 cannot download photos from my PTP camera in Kubuntu 16.10

Telethon: Same entity type for a group and channel in telethon

Telethon: OperationalError: database is locked

Telethon, how to get an entity?

add contact with telethon in python

Telethon change session in @client

Add new Event in Telethon

ModuleNotFoundError: No module named 'telethon'

Telethon asyncio type hint

Telethon IDs uniqueness