1

I have a simple function to download images from Telegram messages by using Pyrogram, but the download_media method doesn't download anything for me, and the returned file_path is always None. The received message object and its photo attribute do have some data in them, but still, the download won't work for me. I tried passing message, m_photo and file_id to download_media to no avail.

async def download_photo(message):
    m_photo = message.photo
    file_id = m_photo.file_id
    file_unique_id = m_photo.file_unique_id
    width = m_photo.width
    height = m_photo.height
    file_size = m_photo.file_size
    date = m_photo.date

    print(m_photo)  
    print(f"Photo details - File ID: {file_id}, File Unique ID: {file_unique_id}, Width: {width}, Height: {height}, File Size: {file_size}, Date: {date}")

    file_path = await app.download_media(m_photo, file_name=f'{message.chat.id}_{file_unique_id}.jpg')

    return file_path

asyncio.run(download_photo(message))
abdus_salam
  • 738
  • 2
  • 7
  • 19

1 Answers1

0

Is your pyrogram client in the group or channel from where you want to download? If this is not the case, I think you should try it that way, something that would resolve the conflict is to try with filters

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/34830874) – doneforaiur Aug 17 '23 at 07:56