Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Script crashes when key 'geoDataExif' not found #377

Open
ebunders opened this issue Feb 15, 2025 · 1 comment
Open

Script crashes when key 'geoDataExif' not found #377

ebunders opened this issue Feb 15, 2025 · 1 comment

Comments

@ebunders
Copy link

It turns out that in my google takeout data 'geoData' is much more present than 'geoDataExif'. But the script seems to assume this key is always present, or else:

    sys.exit(main())
  File "/Users/E.Bunders/.local/pipx/venvs/google-photos-takeout-helper/lib/python3.13/site-packages/google_photos_takeout_helper/__main__.py", line 698, in main
    for_all_files_recursive(
  File "/Users/E.Bunders/.local/pipx/venvs/google-photos-takeout-helper/lib/python3.13/site-packages/google_photos_takeout_helper/__main__.py", line 159, in for_all_files_recursive
    file_function(file)
  File "/Users/E.Bunders/.local/pipx/venvs/google-photos-takeout-helper/lib/python3.13/site-packages/google_photos_takeout_helper/__main__.py", line 700, in <lambda>
    file_function=lambda f: _walk_with_tqdm(fix_metadata(f), _metadata_bar),
  File "/Users/E.Bunders/.local/pipx/venvs/google-photos-takeout-helper/lib/python3.13/site-packages/google_photos_takeout_helper/__main__.py", line 613, in fix_metadata
    set_file_geo_data(file, google_json)
  File "/Users/E.Bunders/.local/pipx/venvs/google-photos-takeout-helper/lib/python3.13/site-packages/google_photos_takeout_helper/__main__.py", line 524, in set_file_geo_data
    longitude = _str_to_float(json['geoDataExif']['longitude'])

KeyError: 'geoDataExif'

So I had to make a little change to google-photos-takeout-helper/lib/python3.13/site-packages/google_photos_takeout_helper/__main__.py

on line 523:

        try:
            if longitude == 0 and latitude == 0:
                longitude = _str_to_float(json['geoDataExif']['longitude'])
                latitude = _str_to_float(json['geoDataExif']['latitude'])
                altitude = _str_to_float(json['geoDataExif']['altitude'])
        except Exception:
            pass

Than it worked.

Thanks for the script!

@DanZee
Copy link

DanZee commented Feb 16, 2025

Thanks @ebunders - same issue & your fix worked.

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

No branches or pull requests

2 participants