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

Fixes error getting user ID when using cookies identification #232

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jleroy
Copy link

@jleroy jleroy commented Aug 31, 2024

Currently, Account.id returns an error if we’re using cookies identification method:

account = Account(cookies={
    'ct0': '…’,
    'auth_token': '…’,
    'twid': 'u%3D…’
})

print(account.id)
Traceback (most recent call last):
  File "xxxx.py", line 38, in <module>
    print(account.id())
          ^^^^^^^^^^
  File "XXXX/twitter/account.py", line 832, in id
    return int(re.findall('"u=(\d+)"', self.session.cookies.get('twid'))[0])
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

This PR fixes this issue by changing the regex pattern if session._init_with_cookies is set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant