Dineshkarthik / telegram_media_downloader

Download media files from a telegram conversation/chat/channel up to 2GiB per file
MIT License
2.08k stars 359 forks source link

Show this error #21

Closed Sirfrancis18 closed 4 years ago

Sirfrancis18 commented 4 years ago

I try the program but doesnt work. image

issue-label-bot[bot] commented 4 years ago

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.61. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

Dineshkarthik commented 4 years ago

@Sirfrancis18 can you run pip freeze and check if the pyrogram package matches this ->Pyrogram===0.17.1-async

Sirfrancis18 commented 4 years ago

$ pip freeze async==0.6.2 asyncio==3.4.3 babelfish==0.5.5 cachetools==4.0.0 certifi==2019.11.28 cffi==1.14.0 chardet==3.0.4 Click==7.0 cryptg==0.2.post0 cryptography==2.9.2 feedparser==5.2.1 Flask==1.1.1 folderclone==0.5.4b1 future==0.18.2 google-api-python-client==1.7.11 google-auth==1.10.0 google-auth-httplib2==0.0.3 google-auth-oauthlib==0.4.1 guessit==3.1.0 hachoir==3.1.1 httplib2==0.15.0 httplib2shim==0.0.3 idna==2.8 itsdangerous==1.1.0 Jinja2==2.10.3 MarkupSafe==1.1.1 netcat==0.0.1a0 numpy==1.18.1 oauth2client==4.1.3 oauthlib==3.1.0 ob==29 obot==18 parsedatetime==2.5 peewee==3.13.1 Pillow==7.1.1 protobuf==3.11.2 pyaes==1.6.1 pyasn1==0.4.8 pyasn1-modules==0.2.7 pycparser==2.20 pycrypto==2.6.1 pycurl==7.43.0.5 PyDrive==1.3.1 pyreadline==2.1 Pyrogram==0.17.1 pySmartDL==1.3.3 PySocks==1.7.1 python-dateutil==2.8.1 python-telegram-bot==12.0.0b1 PyYAML==5.3.1 rebulk==2.0.0 requests==2.22.0 requests-oauthlib==1.3.0 rsa==4.0 scandir==1.10.0 scapy==2.4.3 six==1.13.0 telegram-upload==0.3.1 Telethon==1.12.0 texttable==1.6.2 tokenizer==2.0.4 tornado==6.0.4 transmissionrpc==0.11 uritemplate==3.0.1 urllib3==1.25.7 URLObject==2.4.3 vcsi==7.0.12 Werkzeug==0.16.0 youtube-dl==2020.1.1

Sirfrancis18 commented 4 years ago

`$ python media_downloader.py TgCrypto is missing! Pyrogram will work the same, but at a much slower speed. More info: https://docs.pyrogram.org/topics/tgcrypto Pyrogram v0.17.1, Copyright (C) 2017-2020 Dan https://github.com/delivrance Licensed under the terms of the GNU Lesser General Public License v3 or later (LGPLv3+)

INFO:pyrogram.connection.connection:Connecting... INFO:pyrogram.connection.connection:Connected! Production DC4 - IPv4 - TCPAbridgedO INFO:pyrogram.session.session:Session initialized: Layer 112 INFO:pyrogram.session.session:Device: CPython 3.8.2 - Pyrogram 0.17.1 INFO:pyrogram.session.session:System: Linux 4.14.117-perf+ (EN) INFO:pyrogram.client.ext.syncer:Synced "media_downloader" in 20.9422 ms Traceback (most recent call last): File "media_downloader.py", line 202, in updated_config = asyncio.get_event_loop().run_until_complete( File "/data/data/com.termux/files/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete return future.result() File "media_downloader.py", line 185, in begin_import await client.start() TypeError: object Client can't be used in 'await' expression INFO:pyrogram.client.ext.syncer:Synced "media_downloader" in 51.6341 ms INFO:pyrogram.client.ext.syncer:Synced "media_downloader" in 14.5435 ms`

Dineshkarthik commented 4 years ago

You are having a non-async variant of pyrogram installed. This project requires the async variant please run make install or pip3 install -r requirements.txt to install the async variant of pyrogram.

Sirfrancis18 commented 4 years ago

1.git+https://github.com/pyrogram/pyrogram@asyncio-dev not exist in requerriments

Dineshkarthik commented 4 years ago

can you try pip3 install -U https://github.com/pyrogram/pyrogram/archive/asyncio.zip

Sirfrancis18 commented 4 years ago

now py program start withouth errors but dont download anything .GetFile due to INFO:pyrogram.connection.connection:Disconnected INFO:pyrogram.session.session:RecvTask stopped INFO:pyrogram.session.session:NetWorkerTask stopped INFO:pyrogram.session.session:RecvTask stopped INFO:pyrogram.session.session:NetWorkerTask stopped INFO:pyrogram.session.session:Session stopped INFO:pyrogram.connection.connection:Connecting... INFO:pyrogram.session.session:PingTask stopped INFO:pyrogram.session.session:NextSaltTask stopped INFO:pyrogram.connection.connection:Disconnected INFO:pyrogram.session.session:Session stopped INFO:pyrogram.connection.connection:Connecting... INFO:pyrogram.connection.connection:Connected! Production DC4 - IPv4 - TCPAbridgedO INFO:root:NetWorkerTask started INFO:pyrogram.session.session:RecvTask started INFO:pyrogram.connection.connection:Connected! Production DC4 - IPv4 - TCPAbridgedO INFO:root:NetWorkerTask started INFO:pyrogram.session.session:RecvTask started ^CTraceback (most recent call last): File "media_downloader.py", line 202, in <module> updated_config = asyncio.get_event_loop().run_until_complete( File "/data/data/com.termux/files/usr/lib/python3.8/asyncio/base_events.py", line 603, in run_until_complete self.run_forever() File "/data/data/com.termux/files/usr/lib/python3.8/asyncio/base_events.py", line 570, in run_forever self._run_once() File "/data/data/com.termux/files/usr/lib/python3.8/asyncio/base_events.py", line 1859, in _run_once handle._run() File "/data/data/com.termux/files/usr/lib/python3.8/asyncio/events.py", line 81, in _run self._context.run(self._callback, *self._args) File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/pyrogram/session/session.py", line 344, in recv packet = await self.connection.recv() File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/pyrogram/connection/connection.py", line 83, in recv return await self.protocol.recv() File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/pyrogram/connection/transport/tcp/tcp_abridged_o.py", line 90, in recv return AES.ctr256_decrypt(data, *self.decrypt) File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/pyrogram/crypto/aes.py", line 78, in ctr256_decrypt return cls.ctr(data, key, iv, state or bytearray(1)) File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/pyrogram/crypto/aes.py", line 132, in ctr chunk = cipher.encrypt(iv) File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/pyaes/aes.py", line 221, in encrypt self.T3[(t[(i + s2) % 4] >> 8) & 0xFF] ^ KeyboardInterrupt

Sirfrancis18 commented 4 years ago

start and send files to chat `$ python media_downloader.py TgCrypto is missing! Pyrogram will work the same, but at a much slower speed. More info: https://docs.pyrogram.org/topics/tgcrypto Pyrogram v0.17.1-async, Copyright (C) 2017-2020 Dan https://github.com/delivrance Licensed under the terms of the GNU Lesser General Public License v3 or later (LGPLv3+)

INFO:pyrogram.connection.connection:Connecting... INFO:pyrogram.connection.connection:Connected! Production DC4 - IPv4 - TCPAbridgedO INFO:root:NetWorkerTask started INFO:pyrogram.session.session:RecvTask started INFO:pyrogram.session.session:NextSaltTask started INFO:pyrogram.session.session:Next salt in 42m 26s (2020-07-09 20:10:59) INFO:pyrogram.session.session:Session initialized: Layer 112 INFO:pyrogram.session.session:Device: CPython 3.8.2 - Pyrogram 0.17.1-async INFO:pyrogram.session.session:System: Linux 4.14.117-perf+ (EN) INFO:pyrogram.session.session:Session started INFO:pyrogram.session.session:PingTask started INFO:root:Started 4 UpdatesWorkerTasks INFO:root:Started 4 DownloadWorkerTasks INFO:root:Started 4 UpdateWorkerTasks INFO:pyrogram.client.ext.syncer:Synced "media_downloader" in 9.46426 ms INFO:pyrogram.session.auth:Start creating a new auth key on DC1 INFO:pyrogram.connection.connection:Connecting... INFO:pyrogram.connection.connection:Connected! Production DC1 - IPv4 - TCPAbridgedO INFO:pyrogram.session.auth:Done auth key exchange: DhGenOk INFO:pyrogram.connection.connection:Disconnected INFO:pyrogram.connection.connection:Connecting... INFO:pyrogram.connection.connection:Connected! Production DC1 - IPv4 - TCPAbridgedO INFO:root:NetWorkerTask started INFO:pyrogram.session.session:RecvTask started INFO:pyrogram.session.session:NextSaltTask started INFO:pyrogram.session.session:Next salt in 44m 58s (2020-07-09 20:13:34) INFO:pyrogram.session.session:Session initialized: Layer 112 INFO:pyrogram.session.session:Device: CPython 3.8.2 - Pyrogram 0.17.1-async INFO:pyrogram.session.session:System: Linux 4.14.117-perf+ (EN) INFO:pyrogram.session.session:Session started INFO:pyrogram.session.session:PingTask started INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.client.ext.syncer:Synced "media_downloader" in 21.1902 ms`

Sirfrancis18 commented 4 years ago

i install tgcrypto same error i get groupid from bot because the id from telegram.web adress are different and the program not start with it

Dineshkarthik commented 4 years ago

Can you check the config.yaml file that you entered the correct chat_id and last_read_message_id is 0 and make sure that the chat_id you entered has media files in it to download.

Note: Make sure the media file types shared in the chat is included in you config.yaml

Sirfrancis18 commented 4 years ago

i try with useranme and group xxxxxxxx (webmode) and id group (get from botid -323333444) chat have files and i send It but nothing happend 6.45351 ms INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.client.ext.syncer:Synced "media_downloader" in 26.7889 ms INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.client.ext.syncer:Synced "media_downloader" in 11.5154 ms INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.client.ext.syncer:Synced "media_downloader" in 22.2967 ms INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.client.ext.syncer:Synced "media_downloader" in 10.5212 ms INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.session.session:Send 8 acks INFO:pyrogram.session.session:Send 8 acks

Sirfrancis18 commented 4 years ago

last_read_message_id: 0 media_types:

Sirfrancis18 commented 4 years ago

where download files ?

Dineshkarthik commented 4 years ago

Please read the readme fully - https://github.com/Dineshkarthik/telegram_media_downloader#execution

Sirfrancis18 commented 4 years ago

i go chat from Chrome and see this https://web.telegram.org/#/im?p=s1301261670_6925449593198775360 when put 1301261670 in config this happen

$ python media_downloader.py Pyrogram v0.17.1-async, Copyright (C) 2017-2020 Dan https://github.com/delivrance Licensed under the terms of the GNU Lesser General Public License v3 or later (LGPLv3+) INFO:pyrogram.connection.connection:Connecting... INFO:pyrogram.connection.connection:Connected! Production DC4 - IPv4 - TCPAbridgedO INFO:root:NetWorkerTask started INFO:pyrogram.session.session:RecvTask started INFO:pyrogram.session.session:NextSaltTask started INFO:pyrogram.session.session:Next salt in 44m 24s (2020-07-09 20:40:59) INFO:pyrogram.session.session:Session initialized: Layer 112 INFO:pyrogram.session.session:Device: CPython 3.8.2 - Pyrogram 0.17.1-async INFO:pyrogram.session.session:System: Linux 4.14.117-perf+ (EN) INFO:pyrogram.session.session:Session started INFO:pyrogram.session.session:PingTask started INFO:root:Started 4 UpdatesWorkerTasks INFO:root:Started 4 DownloadWorkerTasks INFO:root:Started 4 UpdateWorkerTasks INFO:pyrogram.client.ext.syncer:Synced "media_downloader" in 23.1919 ms Traceback (most recent call last): File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/pyrogram/client/client.py", line 1690, in resolve_peer return self.storage.get_peer_by_id(peer_id) File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/pyrogram/client/storage/sqlite_storage.py", line 108, in get_peer_by_id raise KeyError("ID not found: {}".format(peer_id)) KeyError: 'ID not found: 1301261670' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/pyrogram/client/client.py", line 1751, in resolve_peer return self.storage.get_peer_by_id(peer_id) File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/pyrogram/client/storage/sqlite_storage.py", line 108, in get_peer_by_id raise KeyError("ID not found: {}".format(peer_id)) KeyError: 'ID not found: 1301261670' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "media_downloader.py", line 202, in updated_config = asyncio.get_event_loop().run_until_complete( File "/data/data/com.termux/files/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete return future.result() File "media_downloader.py", line 186, in begin_import last_read_message_id = await process_messages( File "media_downloader.py", line 166, in process_messages [ File "media_downloader.py", line 166, in [ File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/async_generator/_impl.py", line 366, in step return await ANextIter(self._it, start_fn, args) File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/async_generator/_impl.py", line 199, in next return self._invoke(self._it.next) File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/async_generator/_impl.py", line 209, in _invoke result = fn(args) File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/pyrogram/client/methods/messages/iter_history.py", line 82, in iter_history messages = await self.get_history( File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/pyrogram/client/methods/messages/get_history.py", line 94, in get_history peer=await self.resolve_peer(chat_id), File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/pyrogram/client/client.py", line 1753, in resolve_peer raise PeerIdInvalid pyrogram.errors.exceptions.bad_request_400.PeerIdInvalid: [400 PEER_ID_INVALID]: The id/access_hash combination is invalid $

Sirfrancis18 commented 4 years ago

my config api_hash: 47ec35xxxxxxxx api_id: 11xxxxxxx chat_id: 1301261670 etc etc

Sirfrancis18 commented 4 years ago

it is rare that using your method to get the chat number the program ends, but using the username the id number that is obtained from the botid (-17383838) the program does not end

Dineshkarthik commented 4 years ago

Can you explain more about the botid approach?

Sirfrancis18 commented 4 years ago

sorry for my poor english. if you add @myidbot To the group. the bot will tell you the id of that group. the id that the bot tells me is -1001301261670, and the Telegram web adress says its "https://web.telegram.org/#/im?p=s1301261670_6925449593198775360" I have tried both, with the bot id the program starts but does not download anything. with the id of your manual (Telegram web) the program does not start

Sirfrancis18 commented 4 years ago

it seems that the error is in the relationship between the pyrogram.errors.exceptions.bad_request_400.PeerIdInvalid: [400 PEER_ID_INVALID]: The id/access_hash combination is invalid with the chat

Dineshkarthik commented 4 years ago

Can you try with some other group?

Sirfrancis18 commented 4 years ago

i try with a new Channel and a new group. program only start (not download )with id show the bot @myidbot . with id from webadress dont work.

Dineshkarthik commented 4 years ago

can you try with a public group and share the web url of the group here?

Dineshkarthik commented 4 years ago

Hi thanks for reporting this, the issue is due to the huge number of messages in the channel. Will fix this soon.

Sirfrancis18 commented 4 years ago

i try with a public Channel with only one file and dont work

Dineshkarthik commented 4 years ago

can you share the web telegram link of that public channel?

Sirfrancis18 commented 4 years ago

@PeliculasOnline https://telegram.me/joinchat/AArJ7D6CpekzQKSldmQD7g

Sirfrancis18 commented 4 years ago

I have created a new channel with only 1 file (1 message) @test111test11

Dineshkarthik commented 4 years ago

image It is a 1GB file that you are trying to download. Based on your internet speed it will take at least 10-15 minutes to download a big file. Let the script run until the download finishes.

Sirfrancis18 commented 4 years ago

i works

What happens if I delete the messages in the telegram chat? The counter last_read_message_id: no longer work and the program would fail, right? Wouldn't it be better if the program deleted or had the option to delete chats?

Dineshkarthik commented 4 years ago

If you delete the message it won't affect anything as telegram keeps track of the id of the deleted message. And this is a downloader script one way communication not two way and you also don't have permission to delete message of someone else.

Sirfrancis18 commented 4 years ago

thanks for the help