2023-02-15 19:50:50 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# This module generates the listing of supported sites which can be found in
|
|
|
|
# sites.md. It also organizes all the sites in alphanumeric order
|
2018-12-29 23:16:43 +00:00
|
|
|
import json
|
2019-01-27 09:31:55 +00:00
|
|
|
|
2023-02-15 19:50:50 +00:00
|
|
|
# Read the data.json file
|
2019-10-27 03:42:03 +00:00
|
|
|
with open("sherlock/resources/data.json", "r", encoding="utf-8") as data_file:
|
2019-03-09 11:33:42 +00:00
|
|
|
data = json.load(data_file)
|
2018-12-29 23:16:43 +00:00
|
|
|
|
2023-02-15 19:50:50 +00:00
|
|
|
# Sort the social networks in alphanumeric order
|
|
|
|
social_networks = sorted(data.items())
|
2019-01-24 11:01:34 +00:00
|
|
|
|
2023-02-15 19:50:50 +00:00
|
|
|
# Write the list of supported sites to sites.md
|
|
|
|
with open("sites.md", "w") as site_file:
|
|
|
|
site_file.write(f"## List Of Supported Sites ({len(social_networks)} Sites In Total!)\n")
|
|
|
|
for social_network, info in social_networks:
|
|
|
|
url_main = info["urlMain"]
|
2023-02-26 10:51:56 +00:00
|
|
|
is_nsfw = "**(NSFW)**" if info.get("isNSFW") else ""
|
|
|
|
site_file.write(f"1. ![](https://www.google.com/s2/favicons?domain={url_main}) [{social_network}]({url_main}) {is_nsfw}\n")
|
2019-01-23 14:14:37 +00:00
|
|
|
|
2023-02-15 19:50:50 +00:00
|
|
|
# Overwrite the data.json file with sorted data
|
2020-05-09 04:39:41 +00:00
|
|
|
with open("sherlock/resources/data.json", "w") as data_file:
|
2023-02-15 19:50:50 +00:00
|
|
|
sorted_data = json.dumps(data, indent=2, sort_keys=True)
|
|
|
|
data_file.write(sorted_data)
|
2021-12-11 16:34:35 +00:00
|
|
|
data_file.write("\n")
|
2019-01-23 14:14:37 +00:00
|
|
|
|
2020-08-07 19:55:33 +00:00
|
|
|
print("Finished updating supported site listing!")
|