narbehaj / telegram-audio-download

Download forwarded audio files to your bot from Telegram and store them in their related directory.
21 stars 4 forks source link

Broken dependency #1

Closed idoo closed 5 years ago

idoo commented 5 years ago

After install, I have such issue on running

Traceback (most recent call last):
  File "tg_audio.py", line 3, in <module>
    from requests import get
ModuleNotFoundError: No module named 'requests'
narbehaj commented 5 years ago

Thank you for the feedback. You should install requests module. I will update the README.md file.

Do this: pip3 install requests

idoo commented 5 years ago

Thanks for the quick response :) I did it but looks that script doing nothing :(

python3 tg_audio.py returns empty and looks like freezes '

Any ideas how to debug it?

narbehaj commented 5 years ago

Alright. Have you created a bot and set the token into the tg_audio.py? After doing this, the script won't have output as you should forward MP3 files to the bot. It will then download all the forwarded MP3 files one by one.

idoo commented 5 years ago

yep, I did it

I got logs

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/telepot/__init__.py", line 1183, in get_from_telegram_server
    allowed_updates=allowed_upd)
  File "/usr/local/lib/python3.7/site-packages/telepot/__init__.py", line 1000, in getUpdates
    return self._api_request('getUpdates', _rectify(p))
  File "/usr/local/lib/python3.7/site-packages/telepot/__init__.py", line 491, in _api_request
    return api.request((self._token, method, params, files), **kwargs)
  File "/usr/local/lib/python3.7/site-packages/telepot/api.py", line 154, in request
    r = fn(*args, **kwargs)  # `fn` must be thread-safe
  File "/usr/local/lib/python3.7/site-packages/urllib3/request.py", line 150, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/usr/local/lib/python3.7/site-packages/urllib3/poolmanager.py", line 323, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 367, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/local/lib/python3.7/site-packages/urllib3/packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 344, in connect
    ssl_context=context)
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 344, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 412, in wrap_socket
    session=session
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 853, in _create
    self.do_handshake()
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1117, in do_handshake
    self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 344, in connect
    ssl_context=context)
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 344, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 412, in wrap_socket
    session=session
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 853, in _create
    self.do_handshake()
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1117, in do_handshake
    self._sslobj.do_handshake()
ConnectionResetError: [Errno 54] Connection reset by peer
narbehaj commented 5 years ago

Well, I believe it's the network issue on your side. I tried and it works fine. What the error shows, is that the python complains about the connection between telepot module and the telegram server. Would you check this on another server?

idoo commented 5 years ago

I connected via VPN and got

Working on --> Unknown Name_Of_track
'result'
Traceback (most recent call last):
  File "tg_audio.py", line 18, in get_file_path
    file_path = json_doc['result']['file_path']
KeyError: 'result'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/telepot/__init__.py", line 1158, in collector
    callback(item)
  File "tg_audio.py", line 76, in handle
    get_file(usermsg, chat_id)
  File "tg_audio.py", line 57, in get_file
    download_url = get_file_path(bot_token, mp3id)
  File "tg_audio.py", line 21, in get_file_path
    bot.sendMessage(chat_id, 'Failed for {}'.format(singer, song_name))
NameError: name 'chat_id' is not defined
narbehaj commented 5 years ago

Yeah, just because telegram might be censored in your country just like us. So it works. Now the script complains about the file type I think. Are there any non-mp3 files?

idoo commented 5 years ago

there is mp3 only

narbehaj commented 5 years ago

Check the new commit.

narbehaj commented 5 years ago

Fixed in 637ab5e4fbd8f04853ef99b11984946b491deadc Thanks