From ab3ffda4209485b78086fd9394f81f331a0fb6f5 Mon Sep 17 00:00:00 2001 From: Vlad Pronsky Date: Mon, 1 May 2023 00:09:35 +0300 Subject: [PATCH] update readme; fix ci --- .github/workflows/ci.yml | 5 +---- readme.md | 9 ++++++++- twapi/__init__.py | 2 +- twapi/models.py | 4 +--- twapi/utils.py | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 386c743..b09e589 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,10 +18,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: install dependencies - run: | - python -m pip install --upgrade pip - pip install --quiet -r requirements.txt - pip install --quiet -r requirements-dev.txt + run: pip install -e .[dev] - name: lint run: make lint diff --git a/readme.md b/readme.md index 4b4d98d..467749a 100644 --- a/readme.md +++ b/readme.md @@ -6,6 +6,14 @@ Twitter GraphQL and Search API implementation with [SNScrape](https://github.com pip install https://github.com/vladkens/tw-api ``` +## Features +- Support both Search & GraphQL Twitter API +- Async / Await functions (can run multiple scrappers in parallel same time) +- Login flow (with receiving verification code from email) +- Saving / restore accounts sessions +- Raw Twitter API responses & SNScrape models +- Automatic account switching to smooth Twitter API rate limits + ## Usage ```python @@ -60,7 +68,6 @@ async def main(): doc.json() # -> json string - if __name__ == "__main__": asyncio.run(main()) ``` diff --git a/twapi/__init__.py b/twapi/__init__.py index c2e3ae9..e00efb4 100644 --- a/twapi/__init__.py +++ b/twapi/__init__.py @@ -2,5 +2,5 @@ from .account import Account from .accounts_pool import AccountsPool from .api import API -from .models import * +from .models import * # noqa: F403 from .utils import gather diff --git a/twapi/models.py b/twapi/models.py index 27543b8..1058292 100644 --- a/twapi/models.py +++ b/twapi/models.py @@ -1,12 +1,10 @@ import email.utils import json import re -from dataclasses import asdict, dataclass, field +from dataclasses import asdict, dataclass from datetime import datetime from typing import Optional -from snscrape.modules import twitter - from .logger import logger from .utils import find_item, get_or, int_or_none diff --git a/twapi/utils.py b/twapi/utils.py index 2d2404e..98627fd 100644 --- a/twapi/utils.py +++ b/twapi/utils.py @@ -83,7 +83,7 @@ def get_typed_object(obj: dict, res: defaultdict[str, list]): if obj_type is not None: res[obj_type].append(obj) - for k, v in obj.items(): + for _, v in obj.items(): if isinstance(v, dict): get_typed_object(v, res) elif isinstance(v, list):