PyInstaLive icon indicating copy to clipboard operation
PyInstaLive copied to clipboard

Fixed an issue with csrf token not being extracted correctly

Open anasomar1 opened this issue 1 year ago • 8 comments

Fixed issue with csrf token and new error "Could not login: 'NoneType' object has no attribute 'get'"

anasomar1 avatar Dec 26 '23 12:12 anasomar1

@anasomar1 Just replaced the helpers.py with your fix and it works great, thanks alot Anas.

Since you seem to understand pyinstalive code, could you take a look for another fix which does not work on version 4.0.2 but was alright on version 3.2.4: Download only starts if the following is the host of the live, if the following is a guest it doesn't. There is probably a little tweak to do in the download.py for the get_following_livestreams/broadcast_owner/cobroadcasters/guest_username part taking inspiration from dlfuncs.py of version 3.2.4.

Jeffade1 avatar Dec 27 '23 06:12 Jeffade1

@Jeffade1 You're welcome!

By taking a look at the code in that file there seems to be a misunderstanding in how it should be implemented. In the code we check if there is a guest in the stream and if there is one, we download using "pyinstalive -d "guestname"". However, we always need to download the stream using the broadcast owner's name, even if the person we follow is a guest, the stream we'll download will be the stream of the person hosting our guest and not the stream of the guest, so we just need the owner's name.

So the code in get_following_livestreams would go from

        try:
            livestream_list = api.get_reels_tray()
            usernames_available_livestreams = []
            if livestream_list.get("broadcasts", None):
                for livestream in livestream_list.get("broadcasts", None):
                    owner_username = livestream.get("broadcast_owner", None).get("username", None)
                    try:
                        guest_username = livestream.get("cobroadcasters", None)[0].get("username", None)
                    except:
                        guest_username = None
                    if guest_username:
                        usernames_available_livestreams.append(guest_username)
                    else:
                        usernames_available_livestreams.append(owner_username)

to

        try:
            livestream_list = api.get_reels_tray()
            usernames_available_livestreams = []
            if livestream_list.get("broadcasts", None):
                for livestream in livestream_list.get("broadcasts", None):
                    owner_username = livestream.get("broadcast_owner", None).get("username", None)
                    usernames_available_livestreams.append(owner_username)

I'll need to test the code above before actually making a PR and it might take a while as the people I follow barely go live

anasomar1 avatar Dec 27 '23 19:12 anasomar1

@anasomar1 Deleting the 7 lines and aligning the last 2 makes it work. I tested it on some broadcasts. Well that's another problem fixed👍

Jeffade1 avatar Dec 27 '23 23:12 Jeffade1

@Jeffade1 thanks for testing it. I'll create a PR for that then and also push all the changes to my fork of the repo.

anasomar1 avatar Dec 28 '23 05:12 anasomar1

Thank you @anasomar1 for the PRs and your fork! It helps a lot.

kdurov avatar Dec 30 '23 12:12 kdurov

@anasomar1 Thank you veryy muchhhh, it now allows log in!!! Love you! Try use it.

Edit1: I can confirm that now all is working again, i can record the lives!!! Thank u very much @anasomar1

Milor123 avatar Jan 04 '24 13:01 Milor123