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

[instagram] An unexpected error occurred: TypeError - the JSON object must be str, bytes or bytearray, not NoneType. #2644

Closed
viceroycowboy opened this issue May 31, 2022 · 23 comments

Comments

@viceroycowboy
Copy link

viceroycowboy commented May 31, 2022

[gallery-dl][debug] Version 1.22.0 - Git HEAD: 30e3d8883
[gallery-dl][debug] Python 3.9.13 - macOS-12.4-arm64-arm-64bit
[gallery-dl][debug] requests 2.27.1 - urllib3 1.26.9
[gallery-dl][debug] Starting DownloadJob for 'https://www.instagram.com/instagram/'
[instagram][debug] Using InstagramUserExtractor for 'https://www.instagram.com/instagram/'
[instagram][debug] Using InstagramPostsExtractor for 'https://www.instagram.com/instagram/posts/'
[urllib3.connectionpool][debug] Starting new HTTPS connection (1): www.instagram.com:443
[urllib3.connectionpool][debug] https://www.instagram.com:443 "GET /instagram/ HTTP/1.1" 200 None
[instagram][error] An unexpected error occurred: TypeError - the JSON object must be str, bytes or bytearray, not NoneType. Please run gallery-dl again with the --verbose flag, copy its output and report this issue on https://github.com/mikf/gallery-dl/issues .
[instagram][debug] 
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.9/site-packages/gallery_dl/job.py", line 77, in run
    for msg in extractor:
  File "/opt/homebrew/lib/python3.9/site-packages/gallery_dl/extractor/instagram.py", line 49, in items
    for post in self.posts():
  File "/opt/homebrew/lib/python3.9/site-packages/gallery_dl/extractor/instagram.py", line 475, in posts
    user = self._extract_profile_page(url)
  File "/opt/homebrew/lib/python3.9/site-packages/gallery_dl/extractor/instagram.py", line 388, in _extract_profile_page
    data = self._extract_shared_data(page)["entry_data"]
  File "/opt/homebrew/lib/python3.9/site-packages/gallery_dl/extractor/instagram.py", line 380, in _extract_shared_data
    data = json.loads(shared_data)
  File "/opt/homebrew/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 339, in loads
    raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType
[instagram][debug] Using InstagramStoriesExtractor for 'https://www.instagram.com/stories/instagram/'
[instagram][debug] Sleeping for 8.996 seconds
@rorgoroth
Copy link

I'm getting the same, must be a site update because I've had to allow a new 3rd party cdn in uBlock for the site to work today.

@romainlavisse
Copy link

I got the same error when i try to download using cookies

@mikf
Copy link
Owner

mikf commented Jun 1, 2022

Instagram is still working for me. Probably a geolocation-dependent change.
Could someone with this error do a run with --write-pages and post the generated 01_https_www.instagram.com_instagram_.dump file here, so that I can see what is different?

$ gallery-dl https://www.instagram.com/instagram/
/tmp/instagram/instagram/2850451812694367232.mp4
/tmp/instagram/instagram/2850399139174555561_2850398181513369749.mp4
...

@rorgoroth
Copy link

Interesting, it does work but like romainlavisse says it is when using cookies the error occurs.

Here is the dump anyway: 01_https_www.instagram.com_instagram_.dump

@mikf
Copy link
Owner

mikf commented Jun 1, 2022

Thanks for the dump.

Being logged in or not doesn't matter for me, it still works all the same:

$ gallery-dl --cookies cookies-instagram-com.txt https://www.instagram.com/instagram/
/tmp/instagram/instagram/2850451812694367232.mp4
...
$ gallery-dl -u MYUSERNAME https://www.instagram.com/instagram/
/tmp/instagram/instagram/2850451812694367232.mp4
...

@rorgoroth
Copy link

Hm, I have no idea what's going on.

Logging in with -u -p works fine (although incredibly slow) but then fails with the same error as when using cookies.

@romainlavisse
Copy link

On my side i got the error when i download a full instagram, ive not try to dl only one image

@rorgoroth
Copy link

On my side i got the error when i download a full instagram, ive not try to dl only one image

Yeah I'm going for the full page too.
It works fine when specifying the post, for example:

>> gdl https://www.instagram.com/instagram/
[instagram][error] An unexpected error occurred: TypeError - the JSON object must be str, bytes or bytearray, not NoneType. Please run gallery-dl again with the --verbose flag, copy its output and report this issue on https://github.com/mikf/gallery-dl/issues .

>> gdl https://www.instagram.com/p/CdqlFNiF58H/
./instagram/instagram/2840245600859430663.jpg

>>

mikf added a commit that referenced this issue Jun 1, 2022
- use different way to fetch user IDs
- use new API endpoints for /tagged/ and single posts
@mikf
Copy link
Owner

mikf commented Jun 1, 2022

This should be fixed with 2fb0193. I hope I haven't broken anything else ...

It no longer tries to fetch user IDs from a user's main profile page and uses some API endpoint instead.

@rorgoroth
Copy link

rorgoroth commented Jun 1, 2022

Thanks, that seems to fix the issue although the problem still persists on stories.

Slightly different results than before as both full profile story and specific story url are both broken.

@romainlavisse
Copy link

If i download once again the binary, it will have the update ?

@ethanforvest
Copy link

The error only gets when I try to download stories.

mikf added a commit that referenced this issue Jun 3, 2022
@mikf
Copy link
Owner

mikf commented Jun 3, 2022

Stories are fixed as well (d0dc29f)

On an unrelated note: It is now possible to use user IDs instead of screen names (ee7cea8)

If i download once again the binary, it will have the update ?

The executables from https://github.com/mikf/gallery-dl/actions/workflows/executables.yml will.

@rorgoroth
Copy link

Unfortunately it's still kinda broken for me, now the error is as follows:

>> gallery-dl --verbose --cookies ~/.config/cookies.txt https://www.instagram.com/stories/username
[gallery-dl][debug] Version 1.22.1-dev - Git HEAD: 65ec766
[gallery-dl][debug] Python 3.10.4 - Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with
[gallery-dl][debug] requests 2.27.1 - urllib3 1.26.9
[gallery-dl][debug] Starting DownloadJob for 'https://www.instagram.com/stories/username'
[instagram][debug] Using InstagramStoriesExtractor for 'https://www.instagram.com/stories/username'
[instagram][error] An unexpected error occurred: AttributeError - 'NoneType' object has no attribute 'startswith'. Please run gallery-dl again with the --verbose flag, copy its output and report this issue on https://github.com/mikf/gallery-dl/issues .
[instagram][debug]
Traceback (most recent call last):
  File "/home/ray/.local/lib/python3.10/site-packages/gallery_dl/job.py", line 77, in run
    for msg in extractor:
  File "/home/ray/.local/lib/python3.10/site-packages/gallery_dl/extractor/instagram.py", line 49, in items
    for post in self.posts():
  File "/home/ray/.local/lib/python3.10/site-packages/gallery_dl/extractor/instagram.py", line 753, in posts
    reel_id = self._uid_by_screen_name(self.item)
  File "/home/ray/.local/lib/python3.10/site-packages/gallery_dl/extractor/instagram.py", line 155, in _uid_by_screen_name
    if screen_name.startswith("id:"):
AttributeError: 'NoneType' object has no attribute 'startswith'

mikf added a commit that referenced this issue Jun 3, 2022
@mikf
Copy link
Owner

mikf commented Jun 3, 2022

Sorry about that: 46d171c

@rorgoroth
Copy link

Ah, it's working great again.
Thank you so much!

@ShadwDrgn
Copy link

ShadwDrgn commented Jun 3, 2022

still crashing (for me) with the latest commit from master which seems to include that one:

    ~/tmp/gallery-dl/bin/instagram    master  ~/tmp/gallery-dl/bin/gallery-dl "https://www.instagram.com/instagram/" --cookies-from_browser brave -D . --verbose
[gallery-dl][debug] Version 1.22.0
[gallery-dl][debug] Python 3.10.4 - Linux-5.15.41-1-MANJARO-x86_64-with-glibc2.35
[gallery-dl][debug] requests 2.27.1 - urllib3 1.26.9
[gallery-dl][debug] Starting DownloadJob for 'https://www.instagram.com/instagram/'
[cookies][debug] Extracting cookies from /home/user/.config/BraveSoftware/Brave-Browser/Default/Cookies
[cookies][debug] Detected desktop environment: kde
[cookies][debug] Chosen keyring: kwallet
[cookies][debug] using kwallet-query to obtain password from kwallet
[cookies][debug] NetworkWallet = 'kdewallet'
[cookies][debug] Failed to read password from kwallet. Using empty string instead
[cookies][info] Extracted 3027 cookies from brave
[cookies][debug] cookie version breakdown: {'v10': 0, 'v11': 2970, 'other': 0, 'unencrypted': 57}
[instagram][debug] Using InstagramUserExtractor for 'https://www.instagram.com/instagram/'
[cookies][debug] Extracting cookies from /home/user/.config/BraveSoftware/Brave-Browser/Default/Cookies
[cookies][debug] Detected desktop environment: kde
[cookies][debug] Chosen keyring: kwallet
[cookies][debug] using kwallet-query to obtain password from kwallet
[cookies][debug] NetworkWallet = 'kdewallet'
[cookies][debug] Failed to read password from kwallet. Using empty string instead
[cookies][info] Extracted 3027 cookies from brave
[cookies][debug] cookie version breakdown: {'v10': 0, 'v11': 2970, 'other': 0, 'unencrypted': 57}
[instagram][debug] Using InstagramPostsExtractor for 'https://www.instagram.com/instagram/posts/'
[urllib3.connectionpool][debug] Starting new HTTPS connection (1): www.instagram.com:443
[urllib3.connectionpool][debug] https://www.instagram.com:443 "GET /instagram/ HTTP/1.1" 200 None
[instagram][error] An unexpected error occurred: TypeError - the JSON object must be str, bytes or bytearray, not NoneType. Please run gallery-dl again with the --verbose flag, copy its output and report this issue on https://github.com/mikf/gallery-dl/issues .
[instagram][debug] 
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/gallery_dl/job.py", line 77, in run
    for msg in extractor:
  File "/home/user/.local/lib/python3.10/site-packages/gallery_dl/extractor/instagram.py", line 49, in items
    for post in self.posts():
  File "/home/user/.local/lib/python3.10/site-packages/gallery_dl/extractor/instagram.py", line 475, in posts
    user = self._extract_profile_page(url)
  File "/home/user/.local/lib/python3.10/site-packages/gallery_dl/extractor/instagram.py", line 388, in _extract_profile_page
    data = self._extract_shared_data(page)["entry_data"]
  File "/home/user/.local/lib/python3.10/site-packages/gallery_dl/extractor/instagram.py", line 380, in _extract_shared_data
    data = json.loads(shared_data)
  File "/usr/lib/python3.10/json/__init__.py", line 339, in loads
    raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType

@mikf
Copy link
Owner

mikf commented Jun 3, 2022

[gallery-dl][debug] Version 1.22.0

The latest commit would have [gallery-dl][debug] Version 1.22.1-dev as version string.
1.22.0 is the latest version from the Releases page, but that doesn't include 2fb0193 etc yet.

edit: git master also doesn't recognize --cookies-from_browser anymore. The option name has been fixed to --cookies-from-browser there.

@huskyhi
Copy link

huskyhi commented Jun 3, 2022

[gallery-dl][debug] Version 1.22.0

The latest commit would have [gallery-dl][debug] Version 1.22.1-dev as version string. 1.22.0 is the latest version from the Releases page, but that doesn't include 2fb0193 etc yet.

edit: git master also doesn't recognize --cookies-from_browser anymore. The option name has been fixed to --cookies-from-browser there.

Is there a way to install this version if your using a version of gallery-dl installed by pip?

@mikf
Copy link
Owner

mikf commented Jun 3, 2022

From https://github.com/mikf/gallery-dl#pip:

python3 -m pip install -U -I --no-deps --no-cache-dir https://github.com/mikf/gallery-dl/archive/master.tar.gz

I'll also publish a new release this weekend.

@FriendlyUser10
Copy link

FriendlyUser10 commented Jun 4, 2022

From https://github.com/mikf/gallery-dl#pip:

python3 -m pip install -U -I --no-deps --no-cache-dir https://github.com/mikf/gallery-dl/archive/master.tar.gz

I'll also publish a new release this weekend.

Probably a dumb question, but there is no way to do this for those of us who use the executable, right? Would it be recommended to use the pip versions instead? Bit of a noob with all this stuff, so please excuse the ignorance.

EDIT: Sorry for the inconvenience, I figured it out; the filenames on fix page confused me as they're slightly different than the "normal" exe build download. Appreciate the help you guys do.

@romainlavisse
Copy link

works fine, thanks a lot man !

@ethanforvest
Copy link

Now it's working again after the new release (v1.22.1). Thank you!

@mikf mikf closed this as completed Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants