holwech / WhatsAppBackupFixer

Fixing restored WhatsApp image backups
MIT License
21 stars 5 forks source link

Script fails if images with different naming schema exist in the directory. #2

Closed turnbeutelvergesser closed 2 years ago

turnbeutelvergesser commented 3 years ago

The split operations https://github.com/holwech/WhatsAppBackupFixer/blob/1dbc6645c75987f959b8fea7fbc7ee42c66f9402/fix_exif.py#L10 and https://github.com/holwech/WhatsAppBackupFixer/blob/1dbc6645c75987f959b8fea7fbc7ee42c66f9402/fix_exif.py#L14 fail if there are images without a dash in their name.

Number of files: 4
Traceback (most recent call last):
  File "/home/karsten/src/WhatsAppBackupFixer/fix_exif.py", line 33, in <module>
    exif_dict = {'Exif': {piexif.ExifIFD.DateTimeOriginal: get_date(filename)}}
  File "/home/karsten/src/WhatsAppBackupFixer/fix_exif.py", line 14, in get_date
    date_str = filename.split('-')[1]
IndexError: list index out of range