carderne / signal-export

Export your Signal chats to markdown files with attachments
Other
481 stars 50 forks source link

Orphaned attachments seem to throw an error #50

Closed rponline closed 2 years ago

rponline commented 2 years ago

Thanks for this handy tool!

i found some issue where the script gets stuck.

It seems that Signal Desktop has some references to attachments where it fails to load. In the App is just a loading indicator (spinner) instead of the image or audio visible: image

docker run --rm -it --name signal-export   -v ${SIGNAL_INPUT}:/Signal   -v ${SIGNAL_OUTPUT}:/output   carderne/signal-export:latest
Copying and renaming attachments
Creating markdown files
Traceback (most recent call last):
  File "/usr/local/bin/sigexport", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/site-packages/sigexport/main.py", line 648, in cli
    run(main)
  File "/usr/local/lib/python3.9/site-packages/typer/main.py", line 864, in run
    app()
  File "/usr/local/lib/python3.9/site-packages/typer/main.py", line 214, in __call__
    return get_command(self)(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/typer/main.py", line 500, in wrapper
    return callback(**use_params)  # type: ignore
  File "/usr/local/lib/python3.9/site-packages/sigexport/main.py", line 635, in main
    make_simple(dest, convos, contacts, quote)
  File "/usr/local/lib/python3.9/site-packages/sigexport/main.py", line 199, in make_simple
    if add_quote and "quote" in msg and msg["quote"] and msg["quote"]["text"]:
KeyError: 'text'

... or when using Verbose Mode:

docker run --rm -it --name signal-export   -v ${SIGNAL_INPUT}:/Signal   -v ${SIGNAL_OUTPUT}:/output   carderne/signal-export:latest -v
Fetching data from /Signal/sql/db.sqlite
    [TRUCATED] (loading a lot of contacts)
    Loading SQL results for: [REDACTED]
Copying and renaming attachments
    Copying attachments for: [REDACTED]
    Copying attachments for: [REDACTED]
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/sigexport/main.py", line 78, in copy_attachments
    att_path = str(att["path"]).replace("\\", "/")
KeyError: 'path'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/sigexport", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/site-packages/sigexport/main.py", line 648, in cli
    run(main)
  File "/usr/local/lib/python3.9/site-packages/typer/main.py", line 864, in run
    app()
  File "/usr/local/lib/python3.9/site-packages/typer/main.py", line 214, in __call__
    return get_command(self)(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/typer/main.py", line 500, in wrapper
    return callback(**use_params)  # type: ignore
  File "/usr/local/lib/python3.9/site-packages/sigexport/main.py", line 633, in main
    copy_attachments(src, dest, convos, contacts)
  File "/usr/local/lib/python3.9/site-packages/sigexport/main.py", line 82, in copy_attachments
    secho(f"\t\tBroken attachment:\t{name}\t{att['path']}")
KeyError: 'path'
carderne commented 2 years ago

Both of these issues should be fixed now, let me know!

Make sure to pull the latest image with

docker pull carderne/signal-export:latest
rponline commented 2 years ago

This solved it, thank you for adding the handling of broken attachments :)