mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 08:44:59 +00:00
feat: Add GitHub stars fetching to badges script
This commit is contained in:
parent
5b9464ed31
commit
6687cc9465
1 changed files with 30 additions and 1 deletions
|
@ -28,12 +28,32 @@ def get_total_downloads(api_key, package_name="aider-chat"):
|
|||
sys.exit(1)
|
||||
|
||||
|
||||
def get_github_stars(repo="paul-gauthier/aider"):
|
||||
"""
|
||||
Fetch the number of GitHub stars for a repository
|
||||
"""
|
||||
url = f"https://api.github.com/repos/{repo}"
|
||||
headers = {"Accept": "application/vnd.github.v3+json"}
|
||||
|
||||
try:
|
||||
response = requests.get(url, headers=headers)
|
||||
response.raise_for_status() # Raise an exception for HTTP errors
|
||||
|
||||
data = response.json()
|
||||
stars = data.get("stargazers_count", 0)
|
||||
|
||||
return stars
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"Error fetching GitHub stars: {e}", file=sys.stderr)
|
||||
return None
|
||||
|
||||
|
||||
def main():
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Get total downloads for a Python package from pepy.tech"
|
||||
description="Get total downloads and GitHub stars for aider"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--api-key",
|
||||
|
@ -45,6 +65,9 @@ def main():
|
|||
parser.add_argument(
|
||||
"--package", default="aider-chat", help="Package name (default: aider-chat)"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--github-repo", default="paul-gauthier/aider", help="GitHub repository (default: paul-gauthier/aider)"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
# Get API key from args or environment variable (which may be loaded from .env)
|
||||
|
@ -56,8 +79,14 @@ def main():
|
|||
)
|
||||
sys.exit(1)
|
||||
|
||||
# Get PyPI downloads
|
||||
total_downloads = get_total_downloads(api_key, args.package)
|
||||
print(f"Total downloads for {args.package}: {total_downloads:,}")
|
||||
|
||||
# Get GitHub stars
|
||||
stars = get_github_stars(args.github_repo)
|
||||
if stars is not None:
|
||||
print(f"GitHub stars for {args.github_repo}: {stars:,}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue