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

Recursive upload nested directories does not work #49

Closed alfredonodo closed 4 years ago

alfredonodo commented 4 years ago

telegram-upload version: 0.3.2 Python version: 3.6.9 Operating System: ubuntu mate 18.04.4 64 bit The recursive upload of nested directories does not work.

telegram-upload --directories recursive dir1 dir1->{dir2,file} dir2->{file}

Traceback (most recent call last):
  File "/usr/local/bin/telegram-upload", line 11, in <module>
    sys.exit(upload_cli())
  File "/usr/local/lib/python3.6/dist-packages/telegram_upload/exceptions.py", line 42, in wrap
    fn(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/telegram_upload/management.py", line 42, in upload
    client.send_files(to, files, delete_on_success, print_file_id, force_file, forward, caption)
  File "/usr/local/lib/python3.6/dist-packages/telegram_upload/client.py", line 80, in send_files
    progress_callback=progress, attributes=attributes)
  File "/usr/local/lib/python3.6/dist-packages/telethon/sync.py", line 39, in syncified
    return loop.run_until_complete(coro)
  File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.6/dist-packages/telethon/client/uploads.py", line 377, in send_file
    return self._get_response_message(request, await self(request), entity)
  File "/usr/local/lib/python3.6/dist-packages/telethon/client/users.py", line 30, in __call__
    return await self._call(self._sender, request, ordered=ordered)
  File "/usr/local/lib/python3.6/dist-packages/telethon/client/users.py", line 77, in _call
    result = await future
telethon.errors.rpcerrorlist.FilePartsInvalidError: The number of file parts is invalid (caused by SendMediaRequest)

It works well with files.

Nekmo commented 4 years ago

The bug could not be reproduced. The same versions of Python and Telegram-upload have been used.

Created Python 3.6 virtualenv:

[nekmo@machine ~]$ mktmpenv -p /usr/bin/python3.6           
created virtual environment CPython3.6.10.final.0-64 in 276ms
  creator CPython3Posix(dest=/home/nekmo/.virtualenvs/tmp-161cccfab54f6b, clear=False, global=False)
  seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=/home/nekmo/.local/share/virtualenv/seed-app-data/v1.0.1)
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
virtualenvwrapper.user_scripts creating /home/nekmo/.virtualenvs/tmp-161cccfab54f6b/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/nekmo/.virtualenvs/tmp-161cccfab54f6b/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/nekmo/.virtualenvs/tmp-161cccfab54f6b/bin/preactivate
virtualenvwrapper.user_scripts creating /home/nekmo/.virtualenvs/tmp-161cccfab54f6b/bin/postactivate
virtualenvwrapper.user_scripts creating /home/nekmo/.virtualenvs/tmp-161cccfab54f6b/bin/get_env_details
This is a temporary environment. It will be deleted when you run 'deactivate'.

installed latest telegram-upload release:

(tmp-161cccfab54f6b) [nekmo@machine ~/.virtualenvs/tmp-161cccfab54f6b]$ pip install telegram-upload
Collecting telegram-upload
  Downloading telegram_upload-0.3.2-py2.py3-none-any.whl (11 kB)
Collecting cryptg
  Downloading cryptg-0.2.post1-cp36-cp36m-manylinux2010_x86_64.whl (40 kB)
     |████████████████████████████████| 40 kB 19 kB/s 
Collecting scandir
  Using cached scandir-1.10.0.tar.gz (33 kB)
Collecting hachoir
  Using cached hachoir-3.1.1-py3-none-any.whl (640 kB)
Collecting telethon
  Downloading Telethon-1.16.0-py3-none-any.whl (492 kB)
     |████████████████████████████████| 492 kB 6.2 MB/s 
Collecting click>=6.0
  Using cached click-7.1.2-py2.py3-none-any.whl (82 kB)
Collecting cffi>=1.0.0
  Downloading cffi-1.14.1-cp36-cp36m-manylinux1_x86_64.whl (400 kB)
     |████████████████████████████████| 400 kB 16.3 MB/s 
Collecting pycparser
  Using cached pycparser-2.20-py2.py3-none-any.whl (112 kB)
Collecting pyaes
  Using cached pyaes-1.6.1.tar.gz (28 kB)
Collecting rsa
  Downloading rsa-4.6-py3-none-any.whl (47 kB)
     |████████████████████████████████| 47 kB 3.8 MB/s 
Collecting pyasn1>=0.1.3
  Using cached pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
Building wheels for collected packages: scandir, pyaes
  Building wheel for scandir (setup.py) ... done
  Created wheel for scandir: filename=scandir-1.10.0-cp36-cp36m-linux_x86_64.whl size=38177 sha256=c267b2042a95df976cce917fcdb09f8970351fd7678da89ca81bcbf2a3dd8e1e
  Stored in directory: /home/nekmo/.cache/pip/wheels/25/3f/f2/16160a9b11830b9dde7a2a689c384b6a824cc51a636f569b39
  Building wheel for pyaes (setup.py) ... done
  Created wheel for pyaes: filename=pyaes-1.6.1-py3-none-any.whl size=26345 sha256=00f87d79fcdfb2d433ad815f99f8dd350e11d92efdcaede40904671a250b637c
  Stored in directory: /home/nekmo/.cache/pip/wheels/0b/7a/53/f1d7837e24ac5d8c0d06b7cbe2144be66dc5e7f37e02f5a164
Successfully built scandir pyaes
Installing collected packages: pycparser, cffi, cryptg, scandir, hachoir, pyaes, pyasn1, rsa, telethon, click, telegram-upload
Successfully installed cffi-1.14.1 click-7.1.2 cryptg-0.2.post1 hachoir-3.1.1 pyaes-1.6.1 pyasn1-0.4.8 pycparser-2.20 rsa-4.6 scandir-1.10.0 telegram-upload-0.3.2 telethon-1.16.0
WARNING: You are using pip version 20.1.1; however, version 20.2 is available.
You should consider upgrading via the '/home/nekmo/.virtualenvs/tmp-161cccfab54f6b/bin/python -m pip install --upgrade pip' command.

Files to upload:

(tmp-161cccfab54f6b) [nekmo@machine /tmp]$ ls -lR /tmp/Images/
/tmp/Images/:
total 1616
drwxr-xr-x 2 nekmo users      60 jul 30 01:05 sub_dir
-rw-r--r-- 1 nekmo users 1651526 may 11  2013 wallpaper1.jpg

/tmp/Images/sub_dir:
total 1524
-rw-r--r-- 1 nekmo users 1560333 may 11  2013 wallpaper2.jpg

Files uploaded successfully:

(tmp-161cccfab54f6b) [nekmo@machine /tmp]$ telegram-upload --directories recursive /tmp/Images/
Uploading wallpaper1.jpg  [####################################]  100%          
Uploading wallpaper2.jpg  [####################################]  100%          

Run pip freeze in a terminal and paste the content here to check requirements.

Nekmo commented 4 years ago

Closed due to inactivity.

alfredonodo commented 4 years ago

I'm sorry, but I missed your first reply.

pip3 freeze

acme==0.31.0
apturl==0.5.2
asn1crypto==0.24.0
async-generator==1.10
Brlapi==0.6.6
certbot==0.31.0
certbot-apache==0.31.0
certifi==2018.1.18
cffi==1.14.1
chardet==3.0.4
click==7.1.2
command-not-found==0.3
ConfigArgParse==0.11.0
configobj==5.0.6
configparser==5.0.0
cryptg==0.2.post1
cryptography==2.1.4
cupshelpers==1.0
defer==1.0.6
distro-info===0.18ubuntu0.18.04.1
docopt==0.6.2
future==0.15.2
hachoir==3.1.1
httplib2==0.11.3
idna==2.6
josepy==1.1.0
keyring==10.6.0
keyrings.alt==3.0
language-selector==0.1
launchpadlib==1.10.6
lazr.restfulclient==0.13.5
lazr.uri==1.0.3
louis==3.5.0
Mako==1.0.7
MarkupSafe==1.0
mate-hud==18.4.8
mate-tweak==18.4.16
meld==3.18.0
mock==2.0.0
ndg-httpsclient==0.4.4
netifaces==0.10.4
oauth==1.0.1
olefile==0.45.1
onboard==1.4.1
parsedatetime==2.4
pbr==3.1.1
pexpect==4.2.1
Pillow==5.1.0
protonvpn-cli==2.2.2
protonvpn-linux-gui-calexandru2018==2.0.7
psutil==5.4.2
pyaes==1.6.1
pyasn1==0.4.8
pycairo==1.16.2
pycparser==2.20
pycrypto==2.6.1
pycups==1.9.73
pygobject==3.26.1
PyICU==1.9.8
pyOpenSSL==17.5.0
pyRFC3339==1.0
python-apt==1.6.5+ubuntu0.3
python-augeas==0.5.0
python-dateutil==2.6.1
python-debian==0.1.32
python-xapp==1.0.0
python-xlib==0.20
pythondialog==3.5.1
pytz==2018.3
pyxdg==0.25
PyYAML==3.12
reportlab==3.4.0
requests==2.23.0
requests-toolbelt==0.8.0
requests-unixsocket==0.1.5
rsa==4.6
scandir==1.10.0
scour==0.36
SecretStorage==2.3.1
sessioninstaller==0.0.0
setproctitle==1.1.10
simplejson==3.13.2
six==1.11.0
systemd-python==234
telegram-upload==0.3.2
Telethon==1.15.0
ubuntu-drivers-common==0.0.0
ufw==0.36
unattended-upgrades==0.1
urllib3==1.22
usb-creator==0.3.3
wadllib==1.3.2
xkit==0.0.0
zope.component==4.3.0
zope.event==4.2.0
zope.hookable==4.0.4
zope.interface==4.3.2
alfredonodo commented 4 years ago

I tried again with: telegram-upload version: 0.3.2 Python version: 3.8.2 Operating System: ubuntu mate 20.04.1 64 bit The recursive upload of nested directories does not work.

telegram-upload --directories recursive dir1 dir1->{dir2,file} dir2->{file}

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 42, in wrap
    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 42, in upload
    client.send_files(to, files, delete_on_success, print_file_id, force_file, forward, caption)
  File "/usr/local/lib/python3.8/dist-packages/telegram_upload/client.py", line 78, in send_files
    message = self.send_file(entity, file, thumb=thumb,
  File "/usr/local/lib/python3.8/dist-packages/telethon/sync.py", line 39, in syncified
    return loop.run_until_complete(coro)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.8/dist-packages/telethon/client/uploads.py", line 385, in send_file
    return self._get_response_message(request, await self(request), entity)
  File "/usr/local/lib/python3.8/dist-packages/telethon/client/users.py", line 30, in __call__
    return await self._call(self._sender, request, ordered=ordered)
  File "/usr/local/lib/python3.8/dist-packages/telethon/client/users.py", line 77, in _call
    result = await future
telethon.errors.rpcerrorlist.FilePartsInvalidError: The number of file parts is invalid (caused by SendMediaRequest)
pip3 freeze
appdirs==1.4.4
APScheduler==3.6.3
apturl==0.5.2
argon2-cffi==20.1.0
attrs==20.1.0
backcall==0.2.0
bcrypt==3.1.7
beautifulsoup4==4.8.2
bleach==3.1.5
blinker==1.4
borgbackup==1.1.11
Brlapi==0.7.0
cajarename==19.7.15
certifi==2020.6.20
cffi==1.14.2
chardet==3.0.4
Click==7.0
colorama==0.4.3
command-not-found==0.3
configobj==5.0.6
cryptg==0.2.post1
cryptography==2.8
cupshelpers==1.0
cycler==0.10.0
dbus-python==1.2.16
decorator==4.4.2
defer==1.0.6
defusedxml==0.6.0
deja-dup-caja==0.0.6
distlib==0.3.1
distro==1.4.0
distro-info===0.23ubuntu1
dnspython==1.16.0
docopt==0.6.2
duplicity==0.8.12.0
entrypoints==0.3
fasteners==0.14.1
filelock==3.0.12
Flask==1.1.1
Flask-HTTPAuth==3.2.4
folder-color-caja==0.0.86
folder-color-common==0.0.86
future==0.18.2
gpg===1.13.1-unknown
hachoir==3.1.1
helpdev==0.7.1
html5lib==1.0.1
httplib2==0.14.0
idna==2.8
imageio==2.9.0
iotop==0.6
ipykernel==5.3.4
ipython==7.17.0
ipython-genutils==0.2.0
ipywidgets==7.5.1
itsdangerous==1.1.0
jedi==0.17.2
Jinja2==2.11.2
joblib==0.16.0
jsonschema==3.2.0
jupyter==1.0.0
jupyter-client==6.1.6
jupyter-console==6.1.0
jupyter-core==4.6.3
keyring==18.0.1
kiwisolver==1.2.0
language-selector==0.1
launchpadlib==1.10.13
lazr.restfulclient==0.14.2
lazr.uri==1.0.3
llfuse==1.3.6
lockfile==0.12.2
louis==3.12.0
lxml==4.5.0
Magnus==1.0.3
Mako==1.1.0
Markdown==3.1.1
MarkupSafe==1.1.0
mate-hud==19.10.0
mate-menu==20.4.1
mate-tweak==20.4.0
matplotlib==3.3.1
meld==3.20.2
mistune==0.8.4
monotonic==1.5
mpmath==1.1.0
nbconvert==5.6.1
nbformat==5.0.7
netifaces==0.10.4
networkx==2.5
nose==1.3.7
notebook==6.1.3
numpy==1.19.1
oauthlib==3.1.0
olefile==0.46
onboard==1.4.1
onionshare===2.2.ppa1
packaging==20.4
pandas==1.1.1
pandocfilters==1.4.2
paramiko==2.6.0
parso==0.7.1
pbr==5.4.5
peewee==3.13.3
pexpect==4.6.0
pickleshare==0.7.5
Pillow==7.0.0
prometheus-client==0.8.0
prompt-toolkit==3.0.6
protonvpn-cli==2.2.4
protonvpn-gui==2.1.1
psutil==5.5.1
ptyprocess==0.6.0
pulsemixer==1.5.0
pyaes==1.6.1
pyasn1==0.4.8
pycairo==1.16.2
pycparser==2.20
pycrypto==2.6.1
pycups==1.9.73
Pygments==2.6.1
PyGObject==3.36.0
pyinotify==0.9.6
PyJWT==1.7.1
pymacaroons==0.13.0
PyNaCl==1.3.0
pyOpenSSL==19.0.0
pyparsing==2.4.7
PyQt5==5.15.0
PyQt5-sip==12.8.0
pyrsistent==0.16.0
PySocks==1.6.8
python-apt==2.0.0+ubuntu0.20.4.1
python-dateutil==2.7.3
python-debian===0.1.36ubuntu1
python-xapp==1.8.1
python-xlib==0.23
pythondialog==3.5.1
pytz==2020.1
PyWavelets==1.1.1
pyxattr==0.6.1
pyxdg==0.26
PyYAML==5.3.1
pyzmq==19.0.2
QDarkStyle==2.8.1
qtconsole==4.7.6
QtPy==1.9.0
reportlab==3.5.34
requests==2.24.0
requests-unixsocket==0.2.0
rsa==4.6
scandir==1.10.0
scikit-image==0.17.2
scikit-learn==0.23.2
scipy==1.5.2
SecretStorage==2.3.1
Send2Trash==1.5.0
setproctitle==1.1.10
simplejson==3.16.0
sip==4.19.21
six==1.14.0
soupsieve==1.9.5
stem==1.7.1
stevedore==3.2.0
sympy==1.6.2
systemd-python==234
telegram-upload==0.3.2
Telethon==1.16.4
terminado==0.8.3
testpath==0.4.4
threadpoolctl==2.1.0
tifffile==2020.8.13
tornado==6.0.4
traitlets==4.3.3
tzlocal==2.1
ubuntu-advantage-tools==20.3
ubuntu-drivers-common==0.0.0
ufw==0.36
unattended-upgrades==0.1
urllib3==1.25.8
variety==0.8.3
vboxapi==1.0
virtualenv==20.0.31
virtualenv-clone==0.5.4
virtualenvwrapper==4.8.4
vorta==0.6.26
wadllib==1.3.3
wcwidth==0.2.5
webencodings==0.5.1
Werkzeug==0.16.1
widgetsnbextension==3.5.1
xkit==0.0.0
youtube-dl==2020.3.24