diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 67f81894..8aff1189 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -7,16 +7,6 @@ A lot of users spent much time on helping us adding more translations to this re --- -[TehZombiJesus](https://github.com/TehZombiJesus)[timokueck](https://github.com/timokueck)[DAmNRelentless](https://github.com/DAmNRelentless)[Greazi-Timesk](https://github.com/Greazi-Times)[Serviettesky](https://github.com/Serviettesky)[Hitman477](https://github.com/Hitman477) - -[ItsWagPvP](https://github.com/ItsWagPvP)[EazyFTW](https://github.com/EazyFTW)[TechsCode](https://github.com/TechsCode)[MeepTortoise](https://github.com/MeepTortoise)[PanOkurka](https://github.com/PanOkurka)[editon96](https://github.com/editon96) - -[Fedee0](https://github.com/Fedee0)[Crosby601](https://github.com/Crosby601)[CREEPERGAMER138](https://github.com/CREEPERGAMER138)[NE137](https://github.com/NE137)[Kraineff](https://github.com/Kraineff)[Mellisen](https://github.com/Mellisen) - -[CraftJunkies](https://github.com/CraftJunkies)[iFlyinq](https://github.com/iFlyinq)[mrodz](https://github.com/mrodz)[faab007](https://github.com/faab007)[Im-Fran](https://github.com/Im-Fran)[codebyxemu](https://github.com/codebyxemu) - -[JamesBach93](https://github.com/JamesBach93)[Larskrs](https://github.com/Larskrs)[chickiyeah](https://github.com/chickiyeah)[Polda18](https://github.com/Polda18)[reussy](https://github.com/reussy)[dlsf](https://github.com/dlsf) - -[Mitricum](https://github.com/Mitricum) +[Greazi-Times](https://github.com/Greazi-Times)[Fedee0](https://github.com/Fedee0)[slaapkopamy](https://github.com/slaapkopamy)[TehZombiJesus](https://github.com/TehZombiJesus)[rlnt](https://github.com/rlnt)[timomatrix](https://github.com/timomatrix)[Serviettesky](https://github.com/Serviettesky)[OnlyMatty](https://github.com/OnlyMatty)[Hitman477](https://github.com/Hitman477)[PanOkurka](https://github.com/PanOkurka)[gabrielecabrini](https://github.com/gabrielecabrini)[SrLink16](https://github.com/SrLink16)[editon96](https://github.com/editon96)[chencu5958](https://github.com/chencu5958)[faab007nl](https://github.com/faab007nl)[Josesillo94](https://github.com/Josesillo94)[NE137](https://github.com/NE137)[Im-Fran](https://github.com/Im-Fran)[CraftJunkies](https://github.com/CraftJunkies)[Irowynn](https://github.com/Irowynn)[KahpotVanilla](https://github.com/KahpotVanilla)[Crosby601](https://github.com/Crosby601)[iFlyinq](https://github.com/iFlyinq)[WEBTER](https://github.com/WEBTER)[timokueck](https://github.com/timokueck)[Wolf-Organisation](https://github.com/Wolf-Organisation)[mrodz](https://github.com/mrodz)[enterih](https://github.com/enterih)[JamesBach93](https://github.com/JamesBach93)[ImYenil](https://github.com/ImYenil)[blixy77](https://github.com/blixy77)[YoshiiKun](https://github.com/YoshiiKun)[EazyFTW](https://github.com/EazyFTW)[MeepTortoise](https://github.com/MeepTortoise)[codebyxemu](https://github.com/codebyxemu)[MineTommy](https://github.com/MineTommy) --- diff --git a/utils/contributorsUpdater b/utils/contributorsUpdater new file mode 100644 index 00000000..9a4f1f94 --- /dev/null +++ b/utils/contributorsUpdater @@ -0,0 +1,74 @@ +import requests + +# Constants +GITHUB_API_URL = "https://api.github.com" +OUTPUT_FILE = "contributors.md" + + +def fetch_contributors_with_stats(owner, repo): + """Fetch contributors of the GitHub repository with their stats.""" + url = f"{GITHUB_API_URL}/repos/{owner}/{repo}/stats/contributors" + response = requests.get(url) + + if response.status_code != 200: + print(f"Failed to fetch contributors: {response.status_code} {response.text}") + return [] + + data = response.json() + if not data: + print("No contributors or stats data available.") + return [] + + contributors = [ + { + "login": contributor["author"]["login"], + "avatar_url": contributor["author"]["avatar_url"], + "lines_changed": sum(week["a"] + week["d"] for week in contributor["weeks"]), + } + for contributor in data + ] + + # Sort contributors by lines changed, descending + contributors.sort(key=lambda x: x["lines_changed"], reverse=True) + return contributors + + +def update_contributors_file(contributors): + """Update the Contributors file with the list of contributors.""" + with open(OUTPUT_FILE, "w") as file: + file.write("# **Contributors**\n\n") + file.write("This page is for crediting work of other people.\n\n") + file.write( + "Since this repository moved multiple times, a lot of contribution credits were lost.
\n" + ) + file.write( + "A lot of users spent much time on helping us adding more translations to this repository, we want to thank them with this list.\n\n" + ) + file.write("---\n\n") + + for contributor in contributors: + file.write( + f"[\"{contributor['login']}\"](https://github.com/{contributor['login']})" + ) + file.write("\n\n---\n") + + print(f"Contributors have been written to {OUTPUT_FILE}.") + + +def main(): + """Main function to execute the tool.""" + owner = "TechsCode" + repo = "PluginTranslations" + + print(f"Fetching contributors for {owner}/{repo}...") + contributors = fetch_contributors_with_stats(owner, repo) + + if contributors: + print(f"Fetched {len(contributors)} contributors.") + update_contributors_file(contributors) + else: + print("No contributors found or failed to fetch contributors.") + + +if __name__ == "__main__": + main()