Nekmo / telegram-upload

Upload and download files from Telegram up to 4 GiB using your account
MIT License
1.09k stars 237 forks source link

Error uploading corrupt or unsupported video file #110

Closed HessamMosleh closed 3 years ago

HessamMosleh commented 3 years ago

Hi I tried to send an mp4 file that its size is 985M but the response of

telegram-upload test.mp4

is

Traceback (most recent call last):
  File "/usr/local/bin/telegram-upload", line 8, in <module>
    sys.exit(upload_cli())
  File "/usr/local/lib/python3.8/dist-packages/telegram_upload/exceptions.py", line 50, in wrap
    return fn(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/telegram_upload/management.py", line 101, in upload
    client.send_files(to, files, delete_on_success, print_file_id, force_file, forward, caption, thumbnail)
  File "/usr/local/lib/python3.8/dist-packages/telegram_upload/client.py", line 123, in send_files
    thumb = get_file_thumb(file)
  File "/usr/local/lib/python3.8/dist-packages/telegram_upload/files.py", line 51, in get_file_thumb
    return get_video_thumb(file)
  File "/usr/local/lib/python3.8/dist-packages/telegram_upload/video.py", line 49, in get_video_thumb
    duration = metadata.get('duration').seconds if metadata.has('duration') else 0
AttributeError: 'NoneType' object has no attribute 'has'

I read #82 but couldn't understand what should I do to fix it.

Nekmo commented 3 years ago

This problem will be fixed in version 0.5.0 of telegram-upload. This failure occurs because the mimetypes on your computer are wrong. Read this comment to correct the mimetype in the meantime:

https://github.com/Nekmo/telegram-upload/issues/82#issuecomment-751881631

You can also install version 0.5.0 in the meantime:

pip install https://github.com/Nekmo/telegram-upload/archive/master.zip

More info in: https://docs.nekmo.org/telegram-upload/installation.html

HessamMosleh commented 3 years ago

pip install https://github.com/Nekmo/telegram-upload/archive/master.zip

I installed it but the same error still exists.

Nekmo commented 3 years ago

Please paste the new traceback.

HessamMosleh commented 3 years ago
Traceback (most recent call last):                                                                                        File "/usr/local/bin/telegram-upload", line 8, in <module>                                                                sys.exit(upload_cli())                                                                                                File "/usr/local/lib/python3.8/dist-packages/telegram_upload/exceptions.py", line 54, in wrap                             return fn(*args, **kwargs)                                                                                            File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__                                                return self.main(*args, **kwargs)                                                                                     File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main                                                    rv = self.invoke(ctx)                                                                                                 File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke                                                  return ctx.invoke(self.callback, **ctx.params)                                                                        File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke                                                  return callback(*args, **kwargs)                                                                                      File "/usr/local/lib/python3.8/dist-packages/telegram_upload/management.py", line 111, in upload                          client.send_files(to, files, delete_on_success, print_file_id, forward)                                               File "/usr/local/lib/python3.8/dist-packages/telegram_upload/client.py", line 167, in send_files                          thumb = file.get_thumbnail()                                                                                          File "/usr/local/lib/python3.8/dist-packages/telegram_upload/files.py", line 165, in get_thumbnail                        thumb = get_file_thumb(self.path)                                                                                     File "/usr/local/lib/python3.8/dist-packages/telegram_upload/files.py", line 65, in get_file_thumb                        return get_video_thumb(file)                                                                                          File "/usr/local/lib/python3.8/dist-packages/telegram_upload/video.py", line 49, in get_video_thumb                       duration = metadata.get('duration').seconds if metadata.has('duration') else 0                                      AttributeError: 'NoneType' object has no attribute 'has'

one thing that is weird is I installed telegram-upload from the below command pip3 install https://github.com/Nekmo/telegram-upload/archive/master.zip but pip3 freeze still shows me telegram-upload version is 0.4.0.

Nekmo commented 3 years ago

Ok the mimetypes seem to be correct but there is a problem with the video. Hachoir cannot obtain the properties. Maybe the file is corrupt or badly formed.

Videos with errors will be supported, thanks!

Nekmo commented 3 years ago

Fixed in release v0.5.0. Install It using:

pip3 install https://github.com/Nekmo/telegram-upload/archive/master.zip

Thanks!

Nideapum commented 3 years ago

I try uninstall and reinstall (v0.4.0) and now it's working fine.