stackoverflow. I beginer python developter and need help.
I want download foto on my serwer from different telegram chenals. Have htis code, but it download all media including video. How i can chenge code to download only photo? I’ve read the documentation, but don’t found the answer. Thank you!
from telethon.sync import TelegramClient, events
from telethon.tl.functions.messages import GetDialogsRequest
from tqdm import tqdm
with TelegramClient('name', api_id, api_hash) as client:
result = client(GetDialogsRequest(
offset_date=None,
offset_id=0,
offset_peer="username",
limit=500,
hash=0,
))
title = 'Новинки Margaret❤'
for chat in result.chats:
print(chat)
if chat.title == title:
messages = client.get_messages(chat, limit=1000)
for message in tqdm(messages):
message.download_media('./' + title + '/') #I think the problem is right here.
2
Answers
I added a file check. This solved my problem.
Good Morning, I try to help you.
I think your problem is how do you read the line:
Think that in the Telethon documentation it is shown as follows:
I have found a similar bug, try from this already solved question:
All credits to the user who solved it
Have a great day!