Skip to content
This repository has been archived by the owner on Oct 23, 2019. It is now read-only.
This repository has been archived by the owner on Oct 23, 2019. It is now read-only.

/usr/local/bin/telegram-export: Syntax error: word unexpected (expecting ")") #76

Closed
bytes-commerce opened this issue Aug 7, 2018 · 18 comments

Comments

@bytes-commerce
Copy link

I've installed and followed the install instructions. I installed a fresh version of pip3 and upgraded it.

After setting up the config.ini file and editing the settings correctly (I do get the verification code and added it to the console) I get this message:

➜  ~ telegram-export --config-file ~/.config/telegram-export/config.ini --context 36741326 --format html
/usr/local/bin/telegram-export: 2: /usr/local/bin/telegram-export: Syntax error: word unexpected (expecting ")")

What is this issue and how could I solve it? What more information do you need? Running on Ubuntu 16.04.

➜  ~ python3 --version
Python 3.5.2
@expectocode
Copy link
Owner

Looks like this might be a duplicate of #70. Does it work if you add the shebang line to the top of the script, as mentioned in that issue?

@bytes-commerce
Copy link
Author

If I do so, I do not get an error, instead it just like I'd normally pressing Enter in console, just with some delay. Also, no output files were generated.

@expectocode
Copy link
Owner

that's really strange, could you send a screenshot or something?

@bytes-commerce
Copy link
Author

bildschirmaufnahme_2018-08-07-01

There you go, Sir.

@expectocode
Copy link
Owner

Just tried this myself, and a file was created in OutputDirectory. Have you checked there?

@bytes-commerce
Copy link
Author

Yes.

-rw-rw-r-- 1 max max 1012 Aug  7 14:16 -1001066197625
-rw-r--r-- 1 max max  32K Aug  7 12:21 export.db
-rw-r--r-- 1 max max  14K Aug  7 12:28 exporter.session
drwxrwxr-x 3 max max 4,0K Aug  7 12:21 usermedia

What could possibly go wrong here?

@expectocode
Copy link
Owner

The file created is the top one, which is the ID of the context

@expectocode
Copy link
Owner

Formatters are not really in a good state at the moment. I'm thinking about making them a separate module

@bytes-commerce
Copy link
Author

The content of the file is not whats in the Chat with ID specified in the terminal. I've tried different IDs.

@expectocode
Copy link
Owner

Oh, I see the problem now. --contexts specifies which contexts should be dumped, but --format tells the program to go into 'formatter mode' and just format stuff that's already been dumped.
What I think you want to do is run telegram-export --contexts=YOUR CONTEXTS to save the details,
then run telegram-export --format-contexts=YOUR CONTEXTS --format html

@bytes-commerce
Copy link
Author

Now I do get the following output:

2018-08-07 14:51:12,328 - asyncio - ERROR - Task exception was never retrieved                                                                                                                                                                
future: <Task finished coro=<Downloader._media_consumer() done, defined at /usr/local/lib/python3.5/dist-packages/telegram_export/downloader.py:305> exception=error('required argument is not an integer',)>                                 
Traceback (most recent call last):                                                                                                                                                                                                            
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/usr/local/lib/python3.5/dist-packages/telegram_export/downloader.py", line 311, in _media_consumer
    bar)
  File "/usr/local/lib/python3.5/dist-packages/telegram_export/downloader.py", line 301, in _download_media
    progress_callback=progress
  File "/usr/local/lib/python3.5/dist-packages/telethon/client/downloads.py", line 231, in download_file
    input_location, offset, part_size
  File "/usr/local/lib/python3.5/dist-packages/telethon/network/mtprotosender.py", line 215, in send
    message = self.state.create_message(request)
  File "/usr/local/lib/python3.5/dist-packages/telethon/network/mtprotostate.py", line 50, in create_message
    out=True  # Pre-convert the request into bytes
  File "/usr/local/lib/python3.5/dist-packages/telethon/tl/core/tlmessage.py", line 52, in __init__
    body = GzipPacked.gzip_if_smaller(self.obj)
  File "/usr/local/lib/python3.5/dist-packages/telethon/tl/core/gzippacked.py", line 21, in gzip_if_smaller
    data = bytes(request)
  File "/usr/local/lib/python3.5/dist-packages/telethon/tl/functions/upload.py", line 113, in __bytes__
    bytes(self.location),
  File "/usr/local/lib/python3.5/dist-packages/telethon/tl/types/__init__.py", line 6716, in __bytes__
    struct.pack('<q', self.volume_id),
struct.error: required argument is not an integer

However, it seems to proceed. I also can format it to HTML, but its only plain text without timestamps. How can I achieve a readable format?

@expectocode
Copy link
Owner

Telethon error there? cc @Lonami

As for the HTML, see #18. I welcome a pull request

@bytes-commerce
Copy link
Author

bytes-commerce commented Aug 7, 2018

I'd love to contribute, but I have no clue about Python at all, even if I'm good with HTML, CSS and JS. What are my possibilities?

Telephone Error? What do you mean with that?

@Lonami
Copy link
Collaborator

Lonami commented Aug 7, 2018

To help with HTML/CSS, you can make some cool template where you could display the exported data (users, message, search by different criteria, etc).

@bytes-commerce
Copy link
Author

Is the plain template enough? I have no Idea how to implement it. I can make a wireframe with %values or such. How'd we elaborate?

@Lonami
Copy link
Collaborator

Lonami commented Aug 7, 2018

Let's move to #18.

@bytes-commerce
Copy link
Author

All right. Main problem solved, thanks!

@Lonami
Copy link
Collaborator

Lonami commented Aug 8, 2018

Telethon error there

No, I don't think so. I wish struct errors gave more information (…such as maybe saying what the type or even the value was). Most likely we tried to download something with volume_id being None.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants