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

KeyError: 'last-modified' #188

Closed
jhavens12 opened this issue Oct 11, 2018 · 5 comments
Closed

KeyError: 'last-modified' #188

jhavens12 opened this issue Oct 11, 2018 · 5 comments
Labels
bug Bug

Comments

@jhavens12
Copy link

Describe the bug
KeyError when run

To Reproduce
Steps to reproduce the behavior:
/usr/local/bin/instaloader --login=XX --sessionfile=/mnt/insta/.instaloader-session --fast-update --no-metadata-json --no-captions --stories --highlights --tagged XXX

Error messages and tracebacks
Traceback (most recent call last):
File "/usr/local/bin/instaloader", line 9, in
load_entry_point('instaloader==4.1', 'console_scripts', 'instaloader')()
File "/usr/local/lib/python3.5/dist-packages/instaloader/main.py", line 388, in main
storyitem_filter_str=args.storyitem_filter)
File "/usr/local/lib/python3.5/dist-packages/instaloader/main.py", line 171, in _main
download_stories, fast_update, post_filter, storyitem_filter)
File "/usr/local/lib/python3.5/dist-packages/instaloader/instaloader.py", line 823, in download_profiles
self.download_profilepic(profile)
File "/usr/local/lib/python3.5/dist-packages/instaloader/instaloader.py", line 281, in download_profilepic
date_object = datetime.strptime(anonymous_session.head(profile_pic_url).headers["Last-Modified"],
File "/usr/local/lib/python3.5/dist-packages/requests/structures.py", line 54, in getitem
return self._store[key.lower()][1]
KeyError: 'last-modified'

Instaloader version
4.1

@jhavens12
Copy link
Author

Also reproduce-able with 4.1.1

@aandergr
Copy link
Member

Does this problem still persist? I cannot reproduce it currently, neither did it occur during our daily unit tests.

@a1johnson
Copy link

I have the same problem using version 4.1.1. The error occurs while downloading of a lot of profile pics, during the download of a few profile pics the error never occurs.

@aandergr aandergr added the bug Bug label Nov 1, 2018
@marlosotavio
Copy link

marlosotavio commented Jan 3, 2019

It happens to me too. Ignore the instagram profile theme/photos (lol), but I receive the error only when gathering this single profile of 350. It is open to everyone so it shouldn't have any issue.

-> instaloader.exe --dirname-pattern={profile} --filename-pattern="{profile} - {shortcode}" --no-captions --no-metadata-json acrodave
Traceback (most recent call last):
File "C:\Instaloader_main_.py", line 442, in
File "C:\Instaloader_main_.py", line 438, in main
File "C:\Instaloader_main
.py", line 413, in main
File "C:\Instaloader_main
.py", line 187, in _main
File "C:\Instaloader\instaloader\instaloader.py", line 903, in download_profiles
File "C:\Instaloader\instaloader\instaloader.py", line 296, in download_profilepic
File "C:\Users\Koch-\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\structures.py", line 54, in getitem
KeyError: 'last-modified'
[11244] Failed to execute script main

Edit: Using latest windows release (4.2) and tried with other parameters, like -F.

@aandergr
Copy link
Member

aandergr commented Jan 3, 2019

@hgkmaxymus Thanks for reporting and for mentioning a profile where that happens, making it possible for us to fix the bug with commit 4bc0a94. Now, in case the last modified timestamp of the profile pic is not available, a hash is used in the profile pic filename.

Upgrade Instaloader with

pip3 install --upgrade git+https://github.com/instaloader/instaloader

wzdiyb pushed a commit to wzdiyb/instaloader that referenced this issue Feb 16, 2020
This fixes instaloader#188.

Also, this commit prevents double-requesting the profile pic URL to obtain the
Last-Modified header.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug
Projects
None yet
Development

No branches or pull requests

4 participants