yannforget / landsatxplore

Search and download Landsat scenes from EarthExplorer.
MIT License
223 stars 99 forks source link

"KeyError: 'content-disposition'" #24

Closed Aeteia closed 4 years ago

Aeteia commented 4 years ago

I'm getting a weird content disposition error with my output, not entirely sure where I've gone wrong. I'm using a similar code to that which has been posted before:

from landsatxplore.earthexplorer import EarthExplorer

ee = EarthExplorer("UUUUNNNN", "PPPPPPPP")
i = 1
with open("tiles.txt", 'r') as input_data:
    for scene in input_data:
        ee.download(
            scene_id=str(scene),
            output_dir='./output'
        )
ee.logout()

The error is as follows:

Traceback (most recent call last):
  File "LSX_DL.py", line 10, in <module>
    output_dir=r'./output'
  File "/home/user/.local/lib/python3.7/site-packages/landsatxplore/earthexplorer.py", line 96, in download
    filename = self._download(url, output_dir)
  File "/home/user/.local/lib/python3.7/site-packages/landsatxplore/earthexplorer.py", line 77, in _download
    local_filename = r.headers['Content-Disposition'].split('=')[-1]
  File "/home/user/.local/lib/python3.7/site-packages/requests/structures.py", line 54, in __getitem__
    return self._store[key.lower()][1]
KeyError: 'content-disposition'
Aeteia commented 4 years ago

Ah I found the issue, I changed:

scene_id=str(scene)

to

scene_id=scene[:-1]