Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Unexpected int returned instead of string from metadata[part] in filesystem.py #454

Open
muxketeer opened this issue Apr 16, 2023 · 1 comment

Comments

@muxketeer
Copy link

On select images receiving this error:

  main()
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 716, in __call_
  return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 696, in main
  rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1060, in invoke
  return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 889, in invoke
  return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 534, in invoke
  return callback(*args, **kwargs)
File "./elodie.py", line 141, in _import
  trash, allow_duplicates)
File "./elodie.py", line 68, in import_file
  media, allowDuplicate=allow_duplicates, move=False)
File "/opt/elodie/elodie/filesystem.py", line 545, in process_file
  file_name = self.get_file_name(metadata)
File "/opt/elodie/elodie/filesystem.py", line 173, in get_file_name
  this_value = re.sub(self.whitespace_regex, '-', metadata[part].strip())
tributeError: 'int' object has no attribute 'strip'

Further debugging indicates that is it is due to the value of metadata[part] returning an integer, such as 106499463. Where this field typically, with other images, returns something like: jpg or mov etc..

Possibly related to #400

@muxketeer
Copy link
Author

muxketeer commented Apr 16, 2023

My current "fix"/hack to get around this is to change line 173 in elodie\filesystem.py from this:

 elif part in ('album', 'extension', 'title'):
                    if metadata[part]:
                        this_value = re.sub(self.whitespace_regex, '-', metadata[part].strip())
                        break

into this:

 elif part in ('album', 'extension', 'title'):
                    if metadata[part]:
                        this_value = re.sub(self.whitespace_regex, '-', str(metadata[part]).strip())
                        break

I.e. Preemptively casting the returned value of metadata[part] to always be interpreted as a string (ie. str).

However, this may not be best way to deal with whatever the root of the issue is.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant