
import github

import json


def get_repositories():
    g = github.Github()
    rs = []
    for repo in g.get_organization("spotify").get_repos():
        rs.append({"name": repo.name, "clone_url": repo.clone_url, "fork": repo.fork,
                   "created_at": _format_date(repo.created_at), "description": repo.description})
    with open("rs.json", "w") as f:
        json.dump(rs, f, indent=2)


def _format_date(date):
    return date.strftime("%Y-%m-%dT%H:%M:%SZ")

if __name__ == '__main__':
    get_repositories()
