jmathai / elodie

An EXIF-based photo assistant, organizer and workflow automation tool.
https://bit.ly/introducing-elodie
Apache License 2.0
1.25k stars 137 forks source link

Unknown Location - invalid AppKey #446

Closed grimmett closed 1 year ago

grimmett commented 1 year ago

Apologies if this is covered in past issues, I spent a fair bit of time looking for the same issue in the open and closed issues, but couldn't find it.

I just downloaded Elodie, and I'm getting the following error when I try and run the first test:


MacBook-Air elodie % python3 ./elodie.py import --debug --destination="~/desktop/test" ~/desktop/import/IMG_3513.jpeg
/Users/dg/desktop/import/IMG_3513.jpeg matched checksum but file not found at /Users/dg/desktop/test/2023-03-Mar/Unknown Location/2023-03-02_17-45-49-img_3513.jpeg.
The AppKey submitted with this request is invalid.
Expecting value: line 1 column 1 (char 0)
/Users/dg/desktop/import/IMG_3513.jpeg -> /Users/dg/desktop/test/2023-03-Mar/Unknown Location/2023-03-02_17-45-49-img_3513.jpeg
****** SUMMARY ******
Metric      Count
--------  -------
Success         1
Error           0

Is my Mapquest key invalid? Or is the JSON output not being understood?

jmathai commented 1 year ago

Can you run the command with --debug? I think that will output the MapQuest URL that you can open to get more information.

That sounds like a response from the MapQuest API though so I lean towards it being an invalid key.

grimmett commented 1 year ago

Can you run the command with --debug? I think that will output the MapQuest URL that you can open to get more information.

That sounds like a response from the MapQuest API though so I lean towards it being an invalid key.

Isn't the command I ran with the --debug? The code I used was import --debug --destination=...

grimmett commented 1 year ago

Can you run the command with --debug? I think that will output the MapQuest URL that you can open to get more information.

That sounds like a response from the MapQuest API though so I lean towards it being an invalid key.

Key is ok, if I use it directly in the Mapquest API sample URL, it works. So not an invalid key. Must be something else?

jmathai commented 1 year ago

Is the key correct in config.ini? Could you share the URL with the key stripped?

grimmett commented 1 year ago

Is the key correct in config.ini? Could you share the URL with the key stripped?

Key is correct in config.ini

This is the URL from the test online that worked with part of my key stripped

https://www.mapquestapi.com/geocoding/v1/reverse?key=JKUE**********9kYLzneaoLiWxFl9rU&location=49.268363,-123.113666&includeRoadMetadata=true&includeNearestIntersection=true

jmathai commented 1 year ago

I just reran tests from the master branch and everything passed. https://app.circleci.com/pipelines/github/jmathai/elodie/91/workflows/6e2eecfb-4d5e-401a-bd0c-4c521be9c983/jobs/77

You can try the test key which can be found here: https://github.com/jmathai/elodie/blob/master/elodie/tests/run_tests.py#L30

grimmett commented 1 year ago

I just reran tests from the master branch and everything passed. https://app.circleci.com/pipelines/github/jmathai/elodie/91/workflows/6e2eecfb-4d5e-401a-bd0c-4c521be9c983/jobs/77

You can try the test key which can be found here: https://github.com/jmathai/elodie/blob/master/elodie/tests/run_tests.py#L30

Hmmm... I get the same error with the test key.

I'm going to try and do a fresh download and see if that works, maybe I changed something without knowing/realizing it?

jmathai commented 1 year ago

You could add a log.info here. If it helps then feel free to submit as a pull request against this issue. https://github.com/jmathai/elodie/blob/3e88440d2393915c15f037a4ac7200a08a945d00/elodie/geolocation.py#L214

        url = '%s%s?%s' % (
                    constants.mapquest_base_url,
                    path,
                    urllib.parse.urlencode(params)
              )
        # log the MapQuest url
        log.info('MapQuest url: %s' % (url))
        r = requests.get(url, headers=headers)
grimmett commented 1 year ago

I changed it to the following

'''try: headers = {} params = {'format': 'json', 'key': key} if(prefer_english_names): headers = {'Accept-Language':'en-EN,en;q=0.8'} params['locale'] = 'en_US' params.update(kwargs) path = '/geocoding/v1/address' if('lat' in kwargs and 'lon' in kwargs): path = '/geocoding/v1/reverse' url = '%s%s?%s' % ( constants.mapquest_base_url, path, urllib.parse.urlencode(params) )

    # Save the MapQuest URL to a variable
    mapquest_url = url

    # log the MapQuest url
    log.info('MapQuest url: %s' % (url))

    # Write the MapQuest URL to a file
    with open('results.txt', 'a') as f:
        f.write(url + '\n')

    r = requests.get(url, headers=headers)
    return parse_result(r.json())'''

And the results.txt file is as follows

https://www.mapquestapi.com/geocoding/v1/reverse?format=json&key=your-api-key-goes-here&locale=en_US&lat=49.2760722222222&lon=-123.130730555556&location=49.2760722222222%2C-123.130730555556

Where is it getting the key=your-api-key-goes-here from? I have checked my config.ini file, the API key is correct

grimmett commented 1 year ago

Sorry, I'm new to this, I don't know how to make all the code above post as code it seems!

I appreciate your help, and am really excited to start using Elodie to sort out my photos, I've got about 200,000 that are all over the place

jmathai commented 1 year ago

Can you paste the following?

  1. Location of config.ini
  2. Contents of config.ini (subtract key)
grimmett commented 1 year ago

Location is ~elodie/.elodie/config.ini

And the contents are

[MapQuest]
key=********
prefer_english_names=False
jmathai commented 1 year ago

Can you move your .elodie folder up one directory into the root of your home directory ~ and try again?

grimmett commented 1 year ago

Bingo! Thank you so much for working through this with me! I appreciate it. And now feel a little silly, as this was one of the errors that was resolved before, it just seemed to be presenting itself a bit different to me for some reason.

Thanks!