<filename>script/generate_default_repositories.py
import requests
import json
import os
from github import Github

BASE = """---
id: default_repositories
title: Default repositories
description: "Default repositories in HACS"
---
<!-- The content of this file is autogenerated during build with script/generate_default_repositories.py -->
"""

github = Github(os.environ['TOKEN'])

integration_org = github.get_organization("custom-components")
plugin_org = github.get_organization("custom-cards")
theme_org = github.get_organization("home-assistant-community-themes")

blacklist = requests.get('https://raw.githubusercontent.com/hacs/default/master/blacklist')
blacklist = json.loads(blacklist.text.lower())

for category in ["integration", "plugin", "appdaemon", "python_script", "theme"]:
    response = requests.get(f'https://raw.githubusercontent.com/hacs/default/master/{category}')
    repos = json.loads(response.text.lower())
    if category == "integration":
        for repo in list(integration_org.get_repos()):
            repos.append(repo.full_name.lower())
    elif category == "plugin":
        for repo in list(plugin_org.get_repos()):
            repos.append(repo.full_name.lower())
    elif category == "theme":
        for repo in list(theme_org.get_repos()):
            repos.append(repo.full_name.lower())
    for repo in repos:
        if repo in blacklist:
            repos.remove(repo)

    title = category.replace("_", " ").title() + 's' if category != 'appdaemon' else 'AppDaemon Apps'
    BASE += f"\n## {title}\n\n"
    BASE += f"_{len(repos)} Repositories in total._\n\n"
    for repo in sorted(repos):
        BASE += f"<p className='defaultrepo'><a href='https://github.com/{repo}' target='_blank'>{repo}</a></p>\n"

with open("documentation/default_repositories.md", "w") as mdfile:
    mdfile.write(BASE)

<filename>script/generate_default_repositories.py
import requests
import json
import os
from github import Github

BASE = """---
id: default_repositories
title: Default repositories
description: "Default repositories in HACS"
---
<!-- The content of this file is autogenerated during build with script/generate_default_repositories.py -->
"""

github = Github(os.environ['TOKEN'])

integration_org = github.get_organization("custom-components")
plugin_org = github.get_organization("custom-cards")
theme_org = github.get_organization("home-assistant-community-themes")

blacklist = requests.get('https://raw.githubusercontent.com/hacs/default/master/blacklist')
blacklist = json.loads(blacklist.text.lower())

for category in ["integration", "plugin", "appdaemon", "python_script", "theme"]:
    response = requests.get(f'https://raw.githubusercontent.com/hacs/default/master/{category}')
    repos = json.loads(response.text.lower())
    if category == "integration":
        for repo in list(integration_org.get_repos()):
            repos.append(repo.full_name.lower())
    elif category == "plugin":
        for repo in list(plugin_org.get_repos()):
            repos.append(repo.full_name.lower())
    elif category == "theme":
        for repo in list(theme_org.get_repos()):
            repos.append(repo.full_name.lower())
    for repo in repos:
        if repo in blacklist:
            repos.remove(repo)

    title = category.replace("_", " ").title() + 's' if category != 'appdaemon' else 'AppDaemon Apps'
    BASE += f"\n## {title}\n\n"
    BASE += f"_{len(repos)} Repositories in total._\n\n"
    for repo in sorted(repos):
        BASE += f"<p className='defaultrepo'><a href='https://github.com/{repo}' target='_blank'>{repo}</a></p>\n"

with open("documentation/default_repositories.md", "w") as mdfile:
    mdfile.write(BASE)

--- id: default_repositories title: Default repositories description: "Default repositories in HACS" --- <!-- The content of this file is autogenerated during build with script/generate_default_repositories.py --> ## {title}\n\n"