2023-02-15 20:50:50 +01: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-30 04:46:43 +05:30
|
|
|
import json
|
2024-06-20 13:04:30 +02:00
|
|
|
import os
|
2019-01-27 15:01:55 +05:30
|
|
|
|
2023-02-15 20:50:50 +01:00
|
|
|
# Read the data.json file
|
2024-08-11 12:07:39 +02:00
|
|
|
with open("sherlock_project/resources/data.json", "r", encoding="utf-8") as data_file:
|
2024-05-06 00:09:00 -04:00
|
|
|
data: dict = json.load(data_file)
|
|
|
|
|
|
|
|
# Removes schema-specific keywords for proper processing
|
|
|
|
social_networks: dict = dict(data)
|
2024-05-08 00:08:45 -04:00
|
|
|
social_networks.pop('$schema', None)
|
2018-12-30 04:46:43 +05:30
|
|
|
|
2023-02-15 20:50:50 +01:00
|
|
|
# Sort the social networks in alphanumeric order
|
2024-05-06 00:09:00 -04:00
|
|
|
social_networks: list = sorted(social_networks.items())
|
2019-01-24 11:01:34 +00:00
|
|
|
|
2024-06-20 13:04:30 +02:00
|
|
|
# Make output dir where the site list will be written
|
|
|
|
os.mkdir("output")
|
|
|
|
|
2023-02-15 20:50:50 +01:00
|
|
|
# Write the list of supported sites to sites.md
|
2024-06-20 13:04:30 +02:00
|
|
|
with open("output/sites.mdx", "w") as site_file:
|
2024-06-24 15:42:08 -04:00
|
|
|
site_file.write("---\ntitle: 'List of supported sites'\nsidebarTitle: 'Supported sites'\nicon: 'globe'\ndescription: 'Sherlock currently supports **400+** sites'\n---\n\n")
|
2023-02-15 20:50:50 +01:00
|
|
|
for social_network, info in social_networks:
|
|
|
|
url_main = info["urlMain"]
|
2023-02-26 11:51:56 +01:00
|
|
|
is_nsfw = "**(NSFW)**" if info.get("isNSFW") else ""
|
2024-06-20 13:04:30 +02:00
|
|
|
site_file.write(f"1. [{social_network}]({url_main}) {is_nsfw}\n")
|
2019-01-23 14:14:37 +00:00
|
|
|
|
2023-02-15 20:50:50 +01:00
|
|
|
# Overwrite the data.json file with sorted data
|
2024-05-31 10:50:42 +02:00
|
|
|
with open("sherlock/resources/data.json", "w") as data_file:
|
2023-02-15 20:50:50 +01:00
|
|
|
sorted_data = json.dumps(data, indent=2, sort_keys=True)
|
|
|
|
data_file.write(sorted_data)
|
2021-12-11 17:34:35 +01:00
|
|
|
data_file.write("\n")
|
2019-01-23 14:14:37 +00:00
|
|
|
|
2020-08-07 21:55:33 +02:00
|
|
|
print("Finished updating supported site listing!")
|
2024-06-20 13:04:30 +02:00
|
|
|
|