Ich versuche, Fast_download in meinem vorhandenen Code zu implementieren. Das Problem ist das Fast_download -Modul verwendet Await , mit dem ich nicht vertraut bin. Die offizielle Dokumentation reicht nicht aus, um für mein aktuelles Wissen umzusetzen. Gibt es jemanden, der mir helfen kann? < /P>
Hier ist mein Code. < /P>
from telethon.sync import TelegramClient
from telethon.tl.functions.messages import GetDialogsRequest
from telethon.tl.functions.channels import GetFullChannelRequest
from FastTelethonhelper import fast_download
from telethon.tl.types import InputPeerEmpty
from tqdm import tqdm
api_id =
api_hash = ''
def callback(current, total):
global pbar
global prev_curr
pbar.update(current - prev_curr)
prev_curr = current
def download_media(group, cl, name):
global pbar
global prev_curr
messages = cl.get_messages(group, limit=2000)
start = 0
print(start)
for i, message in enumerate(messages[start:]):
prev_curr = 0
if message.video:
print("\n{} / {} : {}".format(i + start, len(messages), message.file.name))
pbar = tqdm(total=message.document.size, unit='B', unit_scale=True)
message.download_media('./' + name + '/', progress_callback=callback)
# fast_download(client, message.video, download_folder = './' + name + '/', progress_bar_function=callback)
pbar.close()
with TelegramClient('name', api_id, api_hash) as client:
result = client(GetDialogsRequest(
offset_date=None,
offset_id=0,
offset_peer=InputPeerEmpty(),
limit=500,
hash=0,
))
title = 'channel_name' # Title for channel
channel = client(GetFullChannelRequest(title))
download_media(channel.full_chat, client, "directory_name")
< /code>
Ich hatte erwartet, die Download -Geschwindigkeit der Telethon -API zu verbessern. Die Download -Geschwindigkeit einiger Dateien ist auf 100 kB begrenzt, was für große Dateien zu langsam ist. Ich habe bereits einen Code implementiert, der mit dem integrierten Telethon-integrierten Modul "Download_Media" verwendet wird.
Wie verwende ich FastelethonHelper in einem vorhandenen Code ordnungsgemäß? ⇐ Python
-
- Similar Topics
- Replies
- Views
- Last post
-
-
Wie füge ich Dropdown-Menüs zu einem vorhandenen Navi-Menü hinzu? [geschlossen]
by Anonymous » » in HTML - 0 Replies
- 17 Views
-
Last post by Anonymous
-