Telethon icon indicating copy to clipboard operation
Telethon copied to clipboard

download_profile_photo doesn't work with InputChannel

Open ingria opened this issue 2 years ago • 1 comments

Since download_file is no longer accessible, I assume that the correct way to download a channel avatar is with the download_profile_photo function.

Code that causes the issue

channel = InputChannel(channel_id=xxx, access_hash=xxx)
await client.download_profile_photo(channel, thumb='c', progress_callback=None)

Traceback

Traceback (most recent call last):
  File "/home/telegram/worker/./app/controllers.py", line 71, in utils_getChannelAvatar
    print(await self.client.download_profile_photo(channel, thumb='c', progress_callback=None))
  File "/home/telegram/.venv/worker/lib/python3.8/site-packages/telethon/_client/downloads.py", line 193, in download_profile_photo
    entity = await self.get_profile(entity)
  File "/home/telegram/.venv/worker/lib/python3.8/site-packages/telethon/_client/users.py", line 201, in get_profile
    id_entity = {
  File "/home/telegram/.venv/worker/lib/python3.8/site-packages/telethon/_client/users.py", line 202, in <dictcomp>
    utils.get_peer_id(x): x
  File "/home/telegram/.venv/worker/lib/python3.8/site-packages/telethon/_misc/utils.py", line 970, in get_peer_id
    _raise_cast_fail(peer, 'int')
  File "/home/telegram/.venv/worker/lib/python3.8/site-packages/telethon/_misc/utils.py", line 138, in _raise_cast_fail
    raise TypeError('Cannot cast {} to any kind of {}.'.format(
TypeError: Cannot cast Channel to any kind of int.

ingria avatar Mar 26 '22 14:03 ingria

I do not recommend attempting to find and report issues for v2 yet. Things will still change then.

Lonami avatar Mar 26 '22 14:03 Lonami

Closing since it's v2-related and that's still way too far away.

Lonami avatar Sep 20 '22 14:09 Lonami