-
-
Notifications
You must be signed in to change notification settings - Fork 228
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
Add the bookmarks count to tweet #286
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
lib/ | ||
__pycache__/ | ||
.DS_Store | ||
twikit.egg-info/ | ||
pyvenv.cfg | ||
build/ | ||
bin/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import asyncio | ||
from twikit import Client | ||
|
||
async def main(): | ||
client = Client() | ||
|
||
# Load your saved cookies if you have them | ||
client.load_cookies('path/to/cookies.json') | ||
|
||
# Or login directly | ||
# await client.login(auth_info_1='...', auth_info_2='...', password='...') | ||
|
||
# Get a tweet and check its bookmark count | ||
tweet = await client.get_tweet_by_id('1519480761749016577') | ||
print(f"Tweet bookmark count: {tweet.bookmark_count}") | ||
Comment on lines
+14
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add error handling and make tweet ID configurable. The script needs proper error handling for API calls and should make the tweet ID configurable. - tweet = await client.get_tweet_by_id('1519480761749016577')
- print(f"Tweet bookmark count: {tweet.bookmark_count}")
+ tweet_id = os.getenv('TWEET_ID', '1519480761749016577')
+ try:
+ tweet = await client.get_tweet_by_id(tweet_id)
+ print(f"Tweet bookmark count: {tweet.bookmark_count}")
+ except Exception as e:
+ print(f"Error fetching tweet: {e}")
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import re | ||
|
||
from setuptools import setup | ||
from setuptools import setup, find_packages | ||
|
||
with open('README.md', encoding='utf-8') as f: | ||
long_description = f.read() | ||
|
@@ -10,6 +10,7 @@ | |
|
||
setup( | ||
name='twikit', | ||
packages=find_packages(), | ||
version=version, | ||
install_requires=[ | ||
'httpx[socks]', | ||
|
@@ -24,5 +25,5 @@ | |
long_description_content_type='text/markdown', | ||
license='MIT', | ||
url='https://github.com/d60/twikit', | ||
package_data={'twikit': ['py.typed']} | ||
include_package_data=True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Remove The codebase doesn't contain any non-Python package data files that need to be included in the distribution. The existing non-Python files are development-related (documentation, requirements, linter config) and don't need to be packaged. You can safely remove this setting from setup.py. 🔗 Analysis chainVerify MANIFEST.in file exists. The 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Check if MANIFEST.in exists and contains necessary include statements
if [ -f "MANIFEST.in" ]; then
echo "MANIFEST.in contents:"
cat MANIFEST.in
else
echo "Warning: MANIFEST.in file not found"
fi
Length of output: 105 Script: #!/bin/bash
# Search for non-Python files that might need to be included in distribution
fd --type f \
--exclude '*.py' \
--exclude '*.pyc' \
--exclude '__pycache__' \
--exclude '.git' \
--exclude '.github' \
--exclude 'tests' \
--exclude '*.md' \
--exclude 'LICENSE' \
--exclude '.gitignore' \
--exclude 'setup.py' \
--exclude 'setup.cfg' \
--exclude 'pyproject.toml' \
--exclude '*.ini'
Length of output: 365 |
||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from .client import Client | ||
from .gql import GQLClient, Endpoint | ||
|
||
__all__ = ['Client', 'GQLClient', 'Endpoint'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use environment variables or command-line arguments for the cookies path.
Hardcoded paths reduce flexibility and portability. Consider using environment variables or command-line arguments.