Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve downloading Telegram profile pictures #1

Open
Bibo-Joshi opened this issue Apr 13, 2022 · 0 comments
Open

Improve downloading Telegram profile pictures #1

Bibo-Joshi opened this issue Apr 13, 2022 · 0 comments

Comments

@Bibo-Joshi
Copy link
Member

According to https://github.com/pyrogram/pyrogram/issues/284#issuecomment-1098326870 the following could probably be simplified if this code is revisited at some point.

# Apparently pyrogram has no functionality to download directly to bytes
with NamedTemporaryFile(delete=False) as file:
await client.download_media(photo_id, file_name=file.name)
file.seek(0)
photo = vcard.add("photo")
photo.encoding_param = "B"
photo.type_param = "JPG"
photo.value = file.read()
file.close()
os.unlink(file.name)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant