//contributed-tobydargmuesli

contributed-to

Extract and enrich GitHub pinned repository data from profile pins HTML

0
0
0
Python

Contributed To - Profile Pins Extractor

Python
License: MIT
codecov
CI

Extract and enrich GitHub pinned repository data from profile HTML.

Why?

GitHub doesn’t provide an API to fetch pinned repositories (#39589). This tool extracts them from profile HTML and enriches with API metadata.

This allows to show a full list of projects contributed to.

Installation

uv sync

Quick Start

  1. undefinedExport pins HTML: Profile → Edit pins → DevTools (F12) → Copy HTML → Save to input/profile-pins.html

  2. undefinedConfigure:undefined

    export DEFAULT_PREFIX=your-github-username
    export GITHUB_TOKEN=ghp_xxx  # Optional, for higher rate limits
    
  3. undefinedRun:undefined

    python -m src.main
    
  4. undefinedOutput: output/repos.json

Docker

docker build -t dargmuesli/contributed-to .

docker run --rm \
  -e DEFAULT_PREFIX=your-username \
  -v "$(pwd)/input:/srv/app/input:ro" \
  -v "$(pwd)/output:/srv/app/output" \
  -v "$(pwd)/github_cache:/srv/app/github_cache" \
  dargmuesli/contributed-to

Python API

from src.main import extract_repos_and_stars

with open("input/profile-pins.html") as f:
    repos = extract_repos_and_stars(f.read())

for item in repos:
    print(f"{item['repository']['name']}: {item['repository']['stars']} stars")

Output Format

[{
  "repository": {
    "name": "repo-name",
    "description": "Description",
    "stars": 1234,
    "fork": false,
    "url": "https://github.com/owner/repo",
    "owner": {
      "name": "owner",
      "type": "User",
      "avatar_url": "https://avatars.githubusercontent.com/u/123",
      "url": "https://github.com/owner"
    }
  }
}]

Development

# Install development dependencies
uv sync

# Run tests
pytest

# Code quality
ruff format
ruff check --fix
mypy .
[beta]v0.14.0