Skip to content

Commit

Permalink
Updated paths based on changes in c065cbb
Browse files Browse the repository at this point in the history
  • Loading branch information
sdushantha committed May 24, 2024
1 parent 7cb0065 commit 9a33ed9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
31 changes: 31 additions & 0 deletions devel/site-list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/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
import json

# Read the data.json file
with open("../sherlock/resources/data.json", "r", encoding="utf-8") as data_file:
data: dict = json.load(data_file)

# Removes schema-specific keywords for proper processing
social_networks: dict = dict(data)
social_networks.pop('$schema', None)

# Sort the social networks in alphanumeric order
social_networks: list = sorted(social_networks.items())

# 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"]
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")

# Overwrite the data.json file with sorted data
with open("../sherlock/resources/data.json", "w") as data_file:
sorted_data = json.dumps(data, indent=2, sort_keys=True)
data_file.write(sorted_data)
data_file.write("\n")

print("Finished updating supported site listing!")
6 changes: 3 additions & 3 deletions scripts/site-list.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json

# Read the data.json file
with open("sherlock/resources/data.json", "r", encoding="utf-8") as data_file:
with open("../sherlock/resources/data.json", "r", encoding="utf-8") as data_file:
data: dict = json.load(data_file)

# Removes schema-specific keywords for proper processing
Expand All @@ -15,15 +15,15 @@
social_networks: list = sorted(social_networks.items())

# Write the list of supported sites to sites.md
with open("sites.md", "w") as site_file:
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"]
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")

# Overwrite the data.json file with sorted data
with open("sherlock/resources/data.json", "w") as data_file:
with open("../sherlock/resources/data.json", "w") as data_file:
sorted_data = json.dumps(data, indent=2, sort_keys=True)
data_file.write(sorted_data)
data_file.write("\n")
Expand Down

0 comments on commit 9a33ed9

Please sign in to comment.