Last active
July 8, 2020 20:08
-
-
Save FoamyGuy/e7f84ee62763cc180d0fdb1c668e9331 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from adabot.lib.common_funcs import list_repos | |
import json | |
README_URL_TEMPLATE = "https://raw.githubusercontent.com/adafruit/{}/master/README.rst" | |
RESULTS = { | |
"readme_not_found": [], | |
"readme_has_bad_discord_link": [], | |
"readme_has_good_discord_link": [], | |
"readme_has_no_discord_link": [], | |
} | |
#print("Fetching Repos List") | |
#all_repos = list_repos() | |
#print("Got Repos List") | |
f = open("repos.json", "r") | |
#f.write(json.dumps(all_repos)) | |
all_repos = json.loads(f.read()) | |
f.close() | |
print(len(all_repos)) | |
for repo in all_repos: | |
print("getting readme for: {}".format(repo["name"])) | |
response = requests.get(README_URL_TEMPLATE.format(repo["name"])) | |
if response.status_code == 404: | |
RESULTS['readme_not_found'].append(repo["html_url"]) | |
else: | |
if "https://discord.gg/" in response.text: | |
print("found bad link") | |
RESULTS['readme_has_bad_discord_link'].append(repo["html_url"]) | |
if "https://adafru.it/discord" in response.text: | |
print("found good link") | |
RESULTS["readme_has_good_discord_link"].append(repo["html_url"]) | |
if "discord" not in response.text: | |
print("did not find link") | |
RESULTS["readme_has_no_discord_link"].append(repo["html_url"]) | |
f = open ("find_discord_links_results.json", "w") | |
f.write(json.dumps(RESULTS)) | |
f.close() | |
#print(response.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment