dvingerh / PyInstaLive

Python script to download Instagram livestreams.
MIT License
547 stars 111 forks source link

can't create a new cookie file #68

Closed seoulshi closed 5 years ago

seoulshi commented 5 years ago

Fill in this template completely. Issues not following this template will be closed and ignored.

Check the boxes below by filling [ ] with an x so it looks like [x].

Use the Preview button to ensure the template is filled in correctly.

I am using:

To report a bug, fill in the information below.

PyInstaLive information

[I] PyInstaLive version: 3.1.6 [I] Python version: 3.7.4 [I] FFmpeg framework: Available [I] Cookie files: None found [I] CLI supports color: Yes [I] Command to run at start: None [I] Command to run at finish: None [I] Config file contents:

[pyinstalive] username = USER password = PASS download_path = /Users/seoulshi download_lives = True download_replays = True download_comments = true show_cookie_expiry = True log_to_file = True ffmpeg_path = run_at_start = run_at_finish = use_locks = True clear_temp_files = False do_heartbeat = True proxy = verbose = False skip_merge = False

[I] End of PyInstaLive information screen.



###### Command used
pyinstalive -df

###### Behavior
[I] PYINSTALIVE (SCRIPT V3.1.6 - PYTHON V3.7.4) - 07-26-2019 04:45:31 PM
---------------------------------------------------------------------------
[W] Unable to find cookie file: USER.json
[I] Creating a new one.
---------------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/bin/pyinstalive", line 11, in <module>
    load_entry_point('pyinstalive==3.1.6', 'console_scripts', 'pyinstalive')()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyinstalive/startup.py", line 321, in run
    pil.ig_api = auth.authenticate(username=pil.ig_user, password=pil.ig_pass)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyinstalive/auth.py", line 92, in authenticate
    json.loads(e.error_response).get("error_title", e.error_response)))
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
qsniyg commented 5 years ago

Check #57 :)

dvingerh commented 5 years ago

I think an error is occuring while logging in, and it's trying to output the login error message to the console: json.loads(e.error_response).get("error_title", e.error_response)))

But the json response is likely malformed so PyInstaLive crashes while trying to parse it.
I can't personally reproduce the issue but I've made some changes so that now the raw error response is being logged instead.

Please update to version 3.1.7 and try again to see if you can get some more useful information now.

seoulshi commented 5 years ago
---------------------------------------------------------------------------

[I] PYINSTALIVE (SCRIPT V3.1.7 - PYTHON V3.7.4) - 07-27-2019 11:41:35 PM
---------------------------------------------------------------------------
[W] Unable to find cookie file: USER.json
[I] Creating a new one.
---------------------------------------------------------------------------
[E] Could not login: 
---------------------------------------------------------------------------
dvingerh commented 5 years ago

I think Instagram is returning a response (if anything at all) that's not understood by the API dependency, so it won't show anything of use.

Can you reinstall the last version and try once more? It should print the full error stacktrace now although I don't think I can solve whatever the problem is.

Try logging in with a different account or on a different network to see if that makes any difference.

CrypticSignal commented 5 years ago

I think Instagram is returning a response (if anything at all) that's not understood by the API dependency, so it won't show anything of use.

Can you reinstall the last version and try once more? It should print the full error stacktrace now although I don't think I can solve whatever the problem is.

Try logging in with a different account or on a different network to see if that makes any difference.

I always get this:

[W] Unable to find cookie file: <username>.json
[I] Creating a new one.
---------------------------------------------------------------------------
[E] Could not login: {"message": "challenge_required", "challenge": {"url": "https://i.instagram.com/challenge/13560800897/Fi9fCIuZKO/", "api_path": "/challenge/13560800897/Fi9fCIuZKO/", "hide_webview_header": true, "lock": true, "logout": false, "native_flow": true}, "status": "fail", "error_type": "checkpoint_challenge_required"}
[E] challenge_required

EDIT: Just tested with another account and it works.

seoulshi commented 5 years ago

tried your suggestion which is to reinstall the 3.1.7 version and to login with a different account or a different network but the problem still persists :(


[I] PYINSTALIVE (SCRIPT V3.1.7 - PYTHON V3.7.4) - 07-30-2019 07:35:46 PM
---------------------------------------------------------------------------
[W] Unable to find cookie file: USER.json
[I] Creating a new one.
---------------------------------------------------------------------------
[E] Could not login: 
---------------------------------------------------------------------------
dvingerh commented 5 years ago

I don't see any stacktrace, something probably went wrong on my part changing the version tag. Please reinstall once again and output the full stacktrace here. I've never encountered this problem before though and since I can't reproduce it whatsoever there's not much I can do to help you.

seoulshi commented 5 years ago

how do i "reinstall" it? just enter this command on terminal?

pip install git+https://github.com/notcammy/PyInstaLive.git@3.1.7 --process-dependency-links --upgrade

dvingerh commented 5 years ago

Yes.

seoulshi commented 5 years ago

reinstalled it and i always get this after i enter "pyinstalive -df" or pyinstalive -d


[I] PYINSTALIVE (SCRIPT V3.1.7 - PYTHON V3.7.4) - 07-30-2019 10:23:08 PM
---------------------------------------------------------------------------
[W] Unable to find cookie file: USER.json
[I] Creating a new one.
---------------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1317, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1244, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1290, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1239, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 966, in send
    self.connect()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1414, in connect
    server_hostname=server_hostname)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 423, in wrap_socket
    session=session
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 870, in _create
    self.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1139, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/instagram_private_api/client.py", line 523, in _call_api
    response = self.opener.open(req, timeout=self.timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1360, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1319, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyinstalive/auth.py", line 67, in authenticate
    on_login=lambda x: onlogin_callback(x, cookie_file), proxy=pil.proxy)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/instagram_private_api/client.py", line 208, in __init__
    self.login()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/instagram_private_api/endpoints/accounts.py", line 31, in login
    return_response=True)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/instagram_private_api/client.py", line 534, in _call_api
    connection_error.__class__.__name__, str(connection_error)))
instagram_private_api.errors.ClientConnectionError: URLError <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)>
---------------------------------------------------------------------------
dvingerh commented 5 years ago

I believe this is an issue with Python's certificates and MacOS. Not a problem with my script. Try following some of the solutions presented here: https://stackoverflow.com/questions/40684543/how-to-make-python-use-ca-certificates-from-mac-os-truststore

Downgrading to a lower Python version such as 3.5 might also work but don't quote me on that.

seoulshi commented 5 years ago

it finally worked!! thanks for the link it finally solved the problem. thank you notcammy! :)


[I] PYINSTALIVE (SCRIPT V3.1.7 - PYTHON V3.7.4) - 07-30-2019 11:12:00 PM
---------------------------------------------------------------------------
[I] Overriding configuration file login with -u and -p arguments.
---------------------------------------------------------------------------
[I] Successfully logged into account: USER
---------------------------------------------------------------------------
[I] Checking following users for any livestreams or replays.
---------------------------------------------------------------------------
[I] There are currently no available livestreams or replays.
---------------------------------------------------------------------------
dvingerh commented 5 years ago

👍 good to hear. I'd do a test live/replay download to ensure everything else is working fine as well.