| import sqlite3
|
| import re
|
| import yaml
|
|
|
| def generate_readme():
|
| conn = sqlite3.connect('state.db')
|
| cursor = conn.cursor()
|
| cursor.execute('SELECT site, COUNT(*) FROM pages GROUP BY site ORDER BY COUNT(*) DESC')
|
| stats = cursor.fetchall()
|
| conn.close()
|
|
|
| with open('sites.yaml') as f:
|
| content = f.read()
|
|
|
|
|
|
|
| url_map = dict(re.findall(r'site:\s*(\w+),\s*url:\s*\"([^\"]+)\"', content))
|
|
|
| total_links = sum(count for _, count in stats)
|
|
|
| table_rows = []
|
| for site, count in stats:
|
| url = url_map.get(site, "N/A")
|
| table_rows.append(f"| {site} | {url} | {count:,} |")
|
|
|
| table_content = "\n".join(table_rows)
|
|
|
| readme_template = f"""---
|
| license: odc-by
|
| task_categories:
|
| - text-retrieval
|
| language:
|
| - en
|
| tags:
|
| - mtg
|
| - magic-the-gathering
|
| - web-archive
|
| ---
|
|
|
| # mtg-links
|
|
|
| This dataset contains {total_links:,} URLs pointing to Magic: The Gathering (MTG) content. These links come from the Internet Archive's Wayback Machine. They cover major MTG community sites, strategy blogs, and official news outlets.
|
|
|
| This dataset is the index for a project to build a complete text corpus of Magic: The Gathering strategy, lore, and history.
|
|
|
| ## Content breakdown
|
|
|
| | Site | Domain | Link Count |
|
| | :--- | :--- | :--- |
|
| {table_content}
|
|
|
| ## Dataset structure
|
|
|
| The dataset is a single CSV file, `links.csv`, with the following columns:
|
|
|
| - `url`: The full URL found in the Internet Archive CDX index.
|
| - `site`: The identifier for the source website (e.g., `mtggoldfish`, `edhrec_articles`).
|
| - `http_code`: The HTTP status code returned by the Wayback Machine for that URL.
|
|
|
| ## Collection method
|
|
|
| URLs were pulled using the Internet Archive CDX API. The crawler targeted specific domains known to host Magic: The Gathering content, searching for all unique URLs indexed by the Wayback Machine.
|
|
|
| This specific snapshot covers URLs indexed between **2025 and 2026**.
|
|
|
| To replicate the discovery process, use the provided `fetch.py` script:
|
|
|
| ```bash
|
| python fetch.py discover --from-year 2025 --to-year 2026
|
| ```
|
|
|
| ## License
|
|
|
| The list of URLs is provided under the Open Data Commons Attribution License (ODC-By). You must follow the terms of service and robots.txt of the source websites if you use these links to download content.
|
| """
|
| with open('README.md', 'w', encoding='utf-8') as f:
|
| f.write(readme_template)
|
|
|
| if __name__ == "__main__":
|
| generate_readme()
|
|
|