carderne / signal-export

Export your Signal chats to markdown files with attachments
Other
446 stars 47 forks source link

KeyError: 'alt' #16

Closed bjeanes closed 3 years ago

bjeanes commented 3 years ago
❯ ./sigexport.py --source /home/bjeanes/.var/app/org.signal.Signal/config/Signal --overwrite out

Fetching data from /home/bjeanes/.var/app/org.signal.Signal/config/Signal/sql/db.sqlite

Copying and renaming attachments

Creating markdown files

Creating HTML files
Traceback (most recent call last):
  File "/tmp/sig-exp/signal-export/./sigexport.py", line 577, in <module>
    main()
  File "/usr/lib/python3.9/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/tmp/sig-exp/signal-export/./sigexport.py", line 571, in main
    create_html(dest)
  File "/tmp/sig-exp/signal-export/./sigexport.py", line 338, in create_html
    alt = im["alt"]
  File "/home/bjeanes/.local/lib/python3.9/site-packages/bs4/element.py", line 1406, in __getitem__
    return self.attrs[key]
KeyError: 'alt'
carderne commented 3 years ago

Should be fixed in 3483d9723772d2ce541f7b8ab82ab6195d760dee.

Let me know if it works!

bjeanes commented 3 years ago

Hmm...

It turns out somehow there is an empty img tag <img />. I don't know under what circumstances that would be happening. I chucked the whole block in if img.get("src"): and that let me continue the export, though.

carderne commented 3 years ago

Would you mind submitting that as a PR? If not no problem, I’ll get it later.

bjeanes commented 3 years ago

Hmm I'm not a Python dev and I deleted my hacky copy so I don't think I'm sure I could get that right! I would otherwise...

carderne commented 3 years ago

Should be fixed now: 94cb7d9f4a53ec5915b290f1106fed378046d660.

Not sure where those empty <img>s are coming from though...

bjeanes commented 3 years ago

Not sure where those empty <img>s are coming from though...

Neither... perhaps it happens when the original image is deleted from DB/disk some how? Perhaps there was an image I sent/received for which I chose "Delete for me"? Or maybe even if the other person chooses "Delete for everyone"?