Skip to content

Commit

Permalink
update unique result parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorhobenshield committed Jun 7, 2023
1 parent 938bad8 commit 00f6325
Show file tree
Hide file tree
Showing 6 changed files with 222 additions and 31 deletions.
2 changes: 1 addition & 1 deletion scripts/clean.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import shutil;import pathlib;[shutil.rmtree(p) for p in pathlib.Path().iterdir() if p.name in {'env', 'dist', 'twitter_api_client.egg-info'}]
import shutil;import pathlib;[shutil.rmtree(p) for p in pathlib.Path('../').iterdir() if p.name in {'env', 'dist', 'twitter_api_client.egg-info'}]
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setup(
name="twitter-api-client",
version="0.9.1",
version="0.9.2",
python_requires=">=3.10.10",
description="Twitter API",
long_description=dedent('''
Expand Down
12 changes: 12 additions & 0 deletions twitter/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@
}
}

ID_MAP = {
'Followers': '^user-\d+$',
'Following': '^user-\d+$',
'UserTweets': '^tweet-\d+$',
'Likes': '^tweet-\d+$',
'UserMedia': '^tweet-\d+$',
'TweetsAndReplies': '^profile-conversation-\d+-tweet-\d+$',
'TweetDetail': '^conversationthread-\d+-tweet-\d+$', # if another key after tweet-\d+, it's an ad
'Retweeters': '^user-\d+$',
'Favoriters': '^user-\d+$'
}


@dataclass
class SpaceCategory:
Expand Down
6 changes: 3 additions & 3 deletions twitter/login.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
import time

from httpx import Client

from .constants import GREEN, YELLOW, RED, BOLD, RESET
from .util import find_key # ,get_confirmation_code, get_inbox, init_protonmail_session

Expand Down Expand Up @@ -162,15 +162,15 @@ def login(email: str, username: str, password: str, **kwargs) -> Client:
headers={
'authorization': 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
'content-type': 'application/json',
'user-agent': 'Mozilla/5.0 (Linux; Android 11; Nokia G20) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.88 Mobile Safari/537.36',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36',
'x-twitter-active-user': 'yes',
'x-twitter-client-language': 'en',
})

# client.protonmail = kwargs.get('protonmail')

client = execute_login_flow(client)
if kwargs.get('debug', True):
if kwargs.get('debug'):
if not client or client.cookies.get('flow_errors') == 'true':
print(f'[{RED}error{RESET}] {BOLD}{username}{RESET} login failed')
else:
Expand Down
Loading

0 comments on commit 00f6325

Please sign in to comment.