dvingerh / PyInstaLive

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

READ If You Have Login Issues #57

Closed dvingerh closed 4 years ago

dvingerh commented 5 years ago

As of recently new logins may get stuck at a challenge_required error. At the time of writing there's no viable solution for this problem. Please don't create any new issues asking me how to solve this error.

Instagram requires you to verify your login as your login attempt is considered suspicious by their systems. The API dependency currently does not support challenge solving therefore there's nothing I can do.

A potential workaround is present here: https://github.com/notcammy/PyInstaLive/issues/57#issuecomment-524650248

Thanks.

CrypticSignal commented 5 years ago

At the time of writing there's no viable solution for this problem.

I see. It's a big issue though, the purpose of PyInstaLive is to download livestreams which it doesn't do anymore because it cannot log in to your account. It's not just a minor issue but rather something major that prevents this program from... working.

Do you have any idea what the cause of this is?

dvingerh commented 5 years ago

Do you have any idea what the cause of this is?

Probably some internal changes at Instagram.

github-userx commented 5 years ago

With instaloader I had similar issues but solved it by specifying the exact same useragent I also used when signing up & using the Desktop Version on my computer. So that it’s always using the same and already known/logged useragent instead of the instaloader (/pyinstalive) specific useragent.

I assume you have already considered this?

dvingerh commented 5 years ago

With instaloader I had similar issues but solved it by specifying the exact same useragent I also used when signing up & using the Desktop Version on my computer. So that it’s always using the same and already known/logged useragent instead of the instaloader (/pyinstalive) specific useragent.

I assume you have already considered this?

The problem had suddenly gone away for me personally a week after I stickied this so I haven't done any further research.

github-userx commented 5 years ago

Thanks! That’s good to know. I’ll investigate further in case it happens for me too.

IsaiahJTurner commented 5 years ago

If you create a new account on the same device you're running pyinstalive and don't verify the email, it works

marabu88 commented 5 years ago

If you create a new account on the same device you're running pyinstalive and don't verify the email, it works

i try it....and this is work for me. why i have problems with my old different accounts? :(

doodlie commented 4 years ago

@notcammy I can't install this at all with my version of pip using the command you gave or whatever is causing the issue, I don't know. Error says "pip no such option process-dependency-links" is there a quick fix for this? Another project I installed had requirements.txt and that worked for me. Thanks for any suggestions :)

dvingerh commented 4 years ago

@notcammy I can't install this at all with my version of pip using the command you gave or whatever is causing the issue, I don't know. Error says "pip no such option process-dependency-links" is there a quick fix for this? Another project I installed had requirements.txt and that worked for me. Thanks for any suggestions :)

See https://github.com/notcammy/PyInstaLive/issues/46#issuecomment-487759180 I'll look into adding a requirements.txt file some time later this week

FlyingWolFox commented 4 years ago

I got arround the "pip no such option process-dependency-links" changing some things (sorry for the poor fix with no version check, I don't know how to do that):

I changed, on setup.py:

install_requires=[ 'instagram_private_api>=%(api)s' % {'api': _api_version}, 'instagram_private_api_extensions>=%(ext)s' % {'ext': _api_extensions_version}, 'argparse', 'configparser' ], dependency_links=[ 'https://github.com/ping/instagram_private_api/archive/%(api)s.tar.gz' '#egg=instagram_private_api-%(api)s' % {'api': _api_version}, 'https://github.com/ping/instagram_private_api_extensions/archive/%(ext)s.tar.gz' '#egg=instagram_private_api_extensions-%(ext)s' % {'ext': _api_extensions_version} ],

to:

install_requires=[ 'instagram_private_api @ https://github.com/ping/instagram_private_api/archive/master.tar.gz', 'instagram_private_api_extensions @ https://github.com/ping/instagram_private_api_extensions/archive/master.tar.gz', 'argparse', 'configparser' ],

I ran python setup.py sdist to build the tar.gz and then installed by pip. pip output here: https://pastebin.com/8XBHYCL0

Creating a new account solved the "challenge" problem as stated before

Doing all this I could download a replay I used this to change the dependecies: https://stackoverflow.com/questions/12518499/pip-ignores-dependency-links-in-setup-py

Sorry for the big text and poor english. Thanks for maintaining this project!

frozenpandaman commented 4 years ago

@notcammy Can the readme be updated to address this or somehow work with the current version of pip (19.x) where the --process-dependency-links option has been removed, and will similarly remain inaccessible going forward? @FlyingWolFox's fix might work if I were to clone the repo and modify the source, but I'm still not sure how to install the script simply from the command line (and installing an old version of pip via Homebrew doesn't seem easy/possible either). Addition of a requirements.txt sounds like it'd be great addition/fix, from my understanding.

dvingerh commented 4 years ago

@FlyingWolFox @frozenpandaman I've updated setup.py to no longer use dependency_links and added a requirements.txt file as well just in case, hopefully that should resolve any problems you may have installing PyInstaLive with newer pip versions.

For the user not much has changed regarding the installation process, you simply no longer have to pass --process-dependency-links when running the install command. setup.py should take care of the required dependencies.

See https://github.com/notcammy/PyInstaLive/commit/49cfc5aff721976275a3b5c8f056a14c3f9120d4 for changes made

frozenpandaman commented 4 years ago

@notcammy Works great! Thank you!

greenzwiz commented 4 years ago

Is there any way to run the command via a cron job instead of a loop? Thanks!

dvingerh commented 4 years ago

@greenzwiz

Is there any way to run the command via a cron job instead of a loop? Thanks!

I don't see a reason why this shouldn't be working. there is enough information on the internet about cron jobs (or Task Scheduler if you use Windows) and plenty of guides on how to set one up so feel free to try

Romern commented 4 years ago

I saw the fork from https://github.com/kn0wm4d/instagram_private_api/tree/checkpoint which included an interactive way to verify your account, but the cookie wasn't written, so I readded it back: https://github.com/RomanKarwacik/instagram_private_api/tree/patch-1 . Now it works just fine, no need to create a new account.

dvingerh commented 4 years ago

I saw the fork from https://github.com/kn0wm4d/instagram_private_api/tree/checkpoint which included an interactive way to verify your account, but the cookie wasn't written, so I readded it back: https://github.com/RomanKarwacik/instagram_private_api/tree/patch-1 . Now it works just fine, no need to create a new account.

Thanks for the head's up. I will not be implementing this into my own project as it does not originate from ping's private api library until it gets merged by ping himself. If any login problems occur then this is more than likely the result of suspicious behaviour (i.e. spam) which goes against the intentions of my own project.

You are of course free to fork my project and implement the account verification yourself.

kautaleksei commented 4 years ago

I saw the fork from https://github.com/kn0wm4d/instagram_private_api/tree/checkpoint which included an interactive way to verify your account, but the cookie wasn't written, so I readded it back: https://github.com/RomanKarwacik/instagram_private_api/tree/patch-1 . Now it works just fine, no need to create a new account.

@Romern could you please describe, how to use your version of instagram_private_api with pyinstalive?

Romern commented 4 years ago

@kautaleksei This should work.

pip install git+https://github.com/Romern/instagram_private_api.git@patch-1

When logging in in pyinstalive you will then be asked which verification method you want to use, then for the pin and then pyinstalive should continue as usual.

kautaleksei commented 4 years ago

@Romern thank you, it's working. In my case I have installed instagram-private-api version from pyinstalive package, so need to do next steps:

  1. uninstall installation of instagram-private-api via command: pip uninstall instagram-private-api
  2. install your version as you wrote above: pip install git+https://github.com/Romern/instagram_private_api.git@patch-1

Then when challenge appear it's asked for code from SMS or Email: Choose a challenge mode (0 - SMS, 1 - Email): 0 Enter code received:

Thank you for your help.

jozephbrasil commented 4 years ago

I have followed these steps:

pip uninstall instagram-private-api pip install git+https://github.com/Romern/instagram_private_api.git@patch-1

but I am still unable to use it.

''' PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts\pyinstalive-script.py", line 11, in

load_entry_point('pyinstalive==3.2.2', 'console_scripts', 'pyinstalive')()

PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\pyinstalive\startup.py", line 313, in run pil.ig_api = auth.authenticate(username=pil.ig_user, password=pil.ig_pass)

PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\pyinstalive\auth.py", line 113, in authenticate datetime.datetime.fromtimestamp(cookie_expiry).strftime('%Y-%m-%d at %I:%M:%S %p'))) TypeError: an integer is required (got type NoneType) ''' Any idea about how to fix this?

dvingerh commented 4 years ago

@jozephbrasil Seems to be a problem with the API dependency trying to retrieve cookie information Please delete any existing cookie files that exist and try again. If error persists let me know

ahmadmayahi commented 4 years ago

If you create a new account on the same device you're running pyinstalive and don't verify the email, it works

It didn't work for me!

I run the script on an Ubuntu Server.

I installed OpenVPN on my server then I used this VPN to create an Instagram account, this means that I use the exact same IP address on the server to register a new Instagram account.

When I try to download a stream it says:

Could not login: {"message": "Sorry, there was a problem with your request.", "status": "fail"}
jozephbrasil commented 4 years ago

@dvingerh I have uninstalled everything and installed again. The problem persists. Do you have some idea?

jozephbrasil commented 4 years ago

@dvingerh Thank you for helping. But I am not finding where the cookies are installed in to delete it because apparently there is no cookie files in directory. I have uninstalled and installed again and the problem persists.

[I] Overriding FFmpeg binary path: C:\ffmpeg\bin\ffmpeg.exe [W] Unable to find cookie file: codeuser.json [I] Creating a new one. overrided login() unhandled exception 'NoneType' object has no attribute 'get' [I] Successfully logged into account: None Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1008.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1008.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code exec(code, run_globals)

inghean commented 4 years ago

Im troubled by the cookie file too many time. I create THE new account on the same device / IP Address / location the application but it didn‘t work. Always show the text like:

PYINSTALIVE (SCRIPT V3.2.3 - PYTHON V3.8.3) - 06-02-2020 02:51:16 PM

Unable to find cookie file: shohuko39.json Creating a new one.

Could not login:

r786786 commented 4 years ago

can someone create a dummy instagram login or send me an example of how a working cookie file looks like .

wobbleninja commented 3 years ago

When I had this challenge_required and login_required error I bypassed it by redownloading the source code and run my scripts again. I am not sure how and why that worked but since I have two IG accounts my 2nd throwaway account got stuck on login_required and I didn't pay much attention since it's a dummy account. Then my main account got stuck on challenge_required today and I had to do something.

Being stuck on that means that the actual IG finds a suspicious activity on your account and you have to go through some verification to re-enable it. They send you some kind of a code to your phone or mail or something (they even ask you to change your pass) and you can log back in. But PyInstalive still gets stuck on challenge_required. I guess the old cookie keeps that happening.

So I redownloaded the latest PyInstalive and gone through the setup process by setting up the .ini file etc etc and it works fine now for both of my accounts.

Maybe that will help you, I don't know.

Infinitay commented 3 years ago

I started to log the output to a file to see if I can find how long it takes for a challenge_required prompt. I was running my delays randomly between 30 to 60 seconds using a batch script. Note that for some reason the random method within the batch script sometimes would return values between 20-80. I do not know the occurrence of that. I am using PyInstaLive to download livestreams from users I am following rather than passing in a specific user.

I started PyInstaLive nearing 4 AM. At 7:48 AM an Instagram user I was following went live and the "[daemon process] started successfully". They ended their livestream at around 8:48 AM. I didn't see any other log between that time frame when typically IIRC there would be a message saying that a lock file has already been found for that user. The next output I received was at 8:49 AM and that was when the account was flagged with challenge_required.

I have reason to believe that accounts are being flagged with challenge_required when they run PyInstaLive with the download-following argument. Perhaps it's because they flag when we attempt to fetch other livestreams while already watching (downloading) another? Of course, this is solved by re-verifying the account, deleting the login file, and running PyInstaLive again. However, the issue is reoccurring.

Has anyone experienced something similar and can confirm this?

Shmi911 commented 3 years ago

@Infinitay I guess it's not the download-following argument. My last script checking only 1 account for running lives every 65 seconds got my account "challenge required" stuck aswell.

2 months ago i could run a script 24/7 for like 4 days until I got "challenge required" stuck. Recently I was only able to run the script for a couple hours until I got stuck. I confirmed my accounts with code by phone numerous times. And in process I probably needed to change password 20 times,

Now: Confirmed account by code and it said: We check your account in the next 24 hours. Result: Account disabled by instagram

They disabled 5 of my accounts including my "main account" where I actually put work into. I needed to send them a photo of myself with me holding a sign with a 5 digit code on it and name etc. That was 1 week ago. I hope my main account will be unbanned at some point :D . I guess using my ip (and same phone number for challenge) with pyinsta will get me banned now no matter what. Just doing the challenge isn't working anymore.

I wonder whether using specific android device id and sessionid etc. makes a difference. But I can't find any info on that and sadly there is no support/maintenance around this code anymore.

Infinitay commented 3 years ago

@Infinitay I guess it's not the download-following argument. My last script checking only 1 account for running lives every 65 seconds got my account "challenge required" stuck aswell.

2 months ago i could run a script 24/7 for like 4 days until I got "challenge required" stuck. Recently I was only able to run the script for a couple hours until I got stuck. I confirmed my accounts with code by phone numerous times. And in process I probably needed to change password 20 times,

Do you remember if by any chance you also downloaded comments? I think a few days ago I witnessed something where in the middle of the livestream I got soft banned and got "challenge required" for comments when reading my download log for a sepcific IG Live. However from what I can tell it was still downloading the stream just fine.

Shmi911 commented 3 years ago

@Infinitay I guess it's not the download-following argument. My last script checking only 1 account for running lives every 65 seconds got my account "challenge required" stuck aswell. 2 months ago i could run a script 24/7 for like 4 days until I got "challenge required" stuck. Recently I was only able to run the script for a couple hours until I got stuck. I confirmed my accounts with code by phone numerous times. And in process I probably needed to change password 20 times,

Do you remember if by any chance you also downloaded comments? I think a few days ago I witnessed something where in the middle of the livestream I got soft banned and got "challenge required" for comments when reading my download log for a sepcific IG Live. However from what I can tell it was still downloading the stream just fine.

I always download the comments. Sometimes there is a mistake and the comment downloader stops, but not because I got "soft banned". At least I don't know about that, because I don't really pay much attention to the comment downloader. And when i get "challenge required stuck" while downloaing a stream, it will finish downloading the entire video stream.

Btw.: I got my main acc back, after 2 weeks and sending 2 e-mails to ig. I won't run a "24/7" script for a while now and I'm going to test whether there is a difference to use same android device_id like my phone. Maybe it's worth changing session_id etc., but like i said, I'm clueless about programing etc.