From 1d93c7db685587e141f95464dfb3740e5c84afc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D1=8F=D1=87=D0=B5=D1=81=D0=BB=D0=B0=D0=B2=20=D0=91?= =?UTF-8?q?=D0=B0=D0=B6=D0=B5=D0=BD=D0=BE=D0=B2?= Date: Sun, 16 Jun 2019 18:38:44 +0300 Subject: [PATCH] telethon==0.19.1 --- download_service.py | 10 ++++++---- requirements.txt | 2 +- telegram_client_x.py | 7 ++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/download_service.py b/download_service.py index 0a72a29..daa975a 100644 --- a/download_service.py +++ b/download_service.py @@ -13,6 +13,7 @@ from telethon.tl.types import Document from telethon.utils import get_input_media from telethon.errors.rpc_error_list import LocationInvalidError from telegram_client_x import TelegramClientX +# from telethon.telegram_client import TelegramClient from telethon.tl.types import Message from tg_access import * from io import BytesIO @@ -61,7 +62,8 @@ client.set_upload_threads_count(24)#24 client.set_download_threads_count(8)#8 last_call_time_sent = time.time() last_call_time_receive = time.time() - +if not client.is_connected(): + client.start() def on_download_progress(recv_bytes, total_bytes): global last_call_time_receive @@ -79,7 +81,7 @@ def on_upload_progress(send_bytes, total_bytes): # print(f"sent {send_bytes}/{total_bytes}", end="\r") return 0 - +# def download_block(chat_id, hash_uid): try: hash_uid = str(hash_uid) @@ -89,7 +91,7 @@ def download_block(chat_id, hash_uid): client.start() chat_id = int(chat_id) if chat_id.isdigit() else chat_id entity = client.get_entity(chat_id) - messages = client.get_messages(entity, limit=40) + messages = client.get_messages(entity, limit=40,search=hash_uid) for i in range(len(messages)): msg = messages[i] if msg.message == hash_uid: @@ -158,4 +160,4 @@ if __name__ == '__main__': main(sys.argv[0:]) -# download_block("slavikmr","660f320161344649cd5447986a9f68fb60eb9734") \ No newline at end of file +# download_block("slavikmr","d46610254a0afb93228832bdb6122d27e4bcb6c8") \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index a998911..0672ff3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -Telethon==0.18.3 +Telethon==0.19.1 cryptg \ No newline at end of file diff --git a/telegram_client_x.py b/telegram_client_x.py index f3916ab..dac64b7 100644 --- a/telegram_client_x.py +++ b/telegram_client_x.py @@ -33,13 +33,13 @@ from threading import Thread import random import time from queue import Queue -from telethon.network import ConnectionMode +from telethon.network import ConnectionTcpFull from datetime import timedelta class TelegramClientX(TelegramClient): def __init__(self, session, api_id, api_hash, - connection_mode=ConnectionMode.TCP_FULL, + connection=ConnectionTcpFull, use_ipv6=False, proxy=None, update_workers=None, @@ -49,7 +49,7 @@ class TelegramClientX(TelegramClient): **kwargs): super().__init__( session, api_id, api_hash, - connection_mode=connection_mode, + connection=connection, use_ipv6=use_ipv6, proxy=proxy, update_workers=update_workers, @@ -347,6 +347,7 @@ class TelegramClientX(TelegramClient): # The used client will change if FileMigrateError occurs client = self cdn_decrypter = None + input_location = utils.get_input_loction(input_location) download_thread = [] q_request = []