From 0be9fb1c402d7be8a114ba2cefb70147002f7ac4 Mon Sep 17 00:00:00 2001 From: Siddharth Dushantha Date: Wed, 15 Feb 2023 20:50:50 +0100 Subject: [PATCH] Made the code simpler --- site_list.py | 32 ++++++++++++++------------------ sites.md | 10 +++++----- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/site_list.py b/site_list.py index 122d0732..4589b25c 100644 --- a/site_list.py +++ b/site_list.py @@ -1,30 +1,26 @@ -"""Sherlock: Supported Site Listing -This module generates the listing of supported sites -which can be found in sites.md -It also organizes all the sites in alphanumeric order -""" - +#!/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 -pool = [] - +# Read the data.json file with open("sherlock/resources/data.json", "r", encoding="utf-8") as data_file: data = json.load(data_file) -with open("sites.md", "w") as site_file: - data_length = len(data) - site_file.write(f"## List Of Supported Sites ({data_length} Sites In Total!)\n") +# Sort the social networks in alphanumeric order +social_networks = sorted(data.items()) - for social_network in data: - url_main = data.get(social_network).get("urlMain") - pool.append((social_network, url_main)) - - for social_network, url_main in pool: +# 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"] site_file.write(f"1. ![](https://www.google.com/s2/favicons?domain={url_main}) [{social_network}]({url_main})\n") -sorted_json_data = json.dumps(data, indent=2, sort_keys=True) +# Overwrite the data.json file with sorted data with open("sherlock/resources/data.json", "w") as data_file: - data_file.write(sorted_json_data) + 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!") diff --git a/sites.md b/sites.md index 36349b1e..b8fdecbb 100644 --- a/sites.md +++ b/sites.md @@ -158,6 +158,7 @@ 1. ![](https://www.google.com/s2/favicons?domain=https://lobste.rs/) [Lobsters](https://lobste.rs/) 1. ![](https://www.google.com/s2/favicons?domain=https://lolchess.gg/) [Lolchess](https://lolchess.gg/) 1. ![](https://www.google.com/s2/favicons?domain=https://lottiefiles.com/) [LottieFiles](https://lottiefiles.com/) +1. ![](https://www.google.com/s2/favicons?domain=https://forums.mmorpg.com/) [MMORPG Forum](https://forums.mmorpg.com/) 1. ![](https://www.google.com/s2/favicons?domain=https://mapify.travel/) [Mapify](https://mapify.travel/) 1. ![](https://www.google.com/s2/favicons?domain=https://medium.com/) [Medium](https://medium.com/) 1. ![](https://www.google.com/s2/favicons?domain=https://www.memrise.com/) [Memrise](https://www.memrise.com/) @@ -178,6 +179,7 @@ 1. ![](https://www.google.com/s2/favicons?domain=https://nextcloud.com/) [Nextcloud Forum](https://nextcloud.com/) 1. ![](https://www.google.com/s2/favicons?domain=https://nightbot.tv/) [Nightbot](https://nightbot.tv/) 1. ![](https://www.google.com/s2/favicons?domain=https://ninjakiwi.com/) [Ninja Kiwi](https://ninjakiwi.com/) +1. ![](https://www.google.com/s2/favicons?domain=https://www.nintendolife.com/) [NintendoLife](https://www.nintendolife.com/) 1. ![](https://www.google.com/s2/favicons?domain=https://notabug.org/) [NotABug.org](https://notabug.org/) 1. ![](https://www.google.com/s2/favicons?domain=https://nyaa.si/) [Nyaa.si](https://nyaa.si/) 1. ![](https://www.google.com/s2/favicons?domain=https://ogu.gg/) [OGUsers](https://ogu.gg/) @@ -243,6 +245,7 @@ 1. ![](https://www.google.com/s2/favicons?domain=https://www.sporcle.com/) [Sporcle](https://www.sporcle.com/) 1. ![](https://www.google.com/s2/favicons?domain=https://www.sportlerfrage.net/) [Sportlerfrage](https://www.sportlerfrage.net/) 1. ![](https://www.google.com/s2/favicons?domain=https://www.sports.ru/) [SportsRU](https://www.sports.ru/) +1. ![](https://www.google.com/s2/favicons?domain=https://open.spotify.com/) [Spotify](https://open.spotify.com/) 1. ![](https://www.google.com/s2/favicons?domain=https://robertsspaceindustries.com/) [Star Citizen](https://robertsspaceindustries.com/) 1. ![](https://www.google.com/s2/favicons?domain=https://steamcommunity.com/) [SteamGroup](https://steamcommunity.com/) 1. ![](https://www.google.com/s2/favicons?domain=https://www.strava.com/) [Strava](https://www.strava.com/) @@ -295,6 +298,8 @@ 1. ![](https://www.google.com/s2/favicons?domain=https://www.younow.com/) [YouNow](https://www.younow.com/) 1. ![](https://www.google.com/s2/favicons?domain=https://youpic.com/) [YouPic](https://youpic.com/) 1. ![](https://www.google.com/s2/favicons?domain=https://youporn.com) [YouPorn](https://youporn.com) +1. ![](https://www.google.com/s2/favicons?domain=https://www.youtube.com) [Youtube Channel](https://www.youtube.com) +1. ![](https://www.google.com/s2/favicons?domain=https://www.youtube.com) [Youtube User](https://www.youtube.com) 1. ![](https://www.google.com/s2/favicons?domain=https://www.zhihu.com/) [Zhihu](https://www.zhihu.com/) 1. ![](https://www.google.com/s2/favicons?domain=https://akniga.org/profile/blue/) [akniga](https://akniga.org/profile/blue/) 1. ![](https://www.google.com/s2/favicons?domain=https://aminoapps.com/) [aminoapp](https://aminoapps.com/) @@ -341,11 +346,9 @@ 1. ![](https://www.google.com/s2/favicons?domain=https://www.mercadolivre.com.br) [mercadolivre](https://www.mercadolivre.com.br) 1. ![](https://www.google.com/s2/favicons?domain=https://www.metacritic.com/) [metacritic](https://www.metacritic.com/) 1. ![](https://www.google.com/s2/favicons?domain=https://www.minds.com) [minds](https://www.minds.com) -1. ![](https://www.google.com/s2/favicons?domain=https://forums.mmorpg.com/) [MMORPG Forum](https://forums.mmorpg.com/) 1. ![](https://www.google.com/s2/favicons?domain=https://moikrug.ru/) [moikrug](https://moikrug.ru/) 1. ![](https://www.google.com/s2/favicons?domain=https://mstdn.io/) [mstdn.io](https://mstdn.io/) 1. ![](https://www.google.com/s2/favicons?domain=https://www.nairaland.com/) [nairaland.com](https://www.nairaland.com/) -1. ![](https://www.google.com/s2/favicons?domain=https://www.nintendolife.com/) [NintendoLife](https://www.nintendolife.com/) 1. ![](https://www.google.com/s2/favicons?domain=https://www.nn.ru/) [nnRU](https://www.nn.ru/) 1. ![](https://www.google.com/s2/favicons?domain=https://note.com/) [note](https://note.com/) 1. ![](https://www.google.com/s2/favicons?domain=https://www.npmjs.com/) [npm](https://www.npmjs.com/) @@ -366,6 +369,3 @@ 1. ![](https://www.google.com/s2/favicons?domain=https://wiki.vg/) [wiki.vg](https://wiki.vg/) 1. ![](https://www.google.com/s2/favicons?domain=https://xhamster.com) [xHamster](https://xhamster.com) 1. ![](https://www.google.com/s2/favicons?domain=https://znanylekarz.pl) [znanylekarz.pl](https://znanylekarz.pl) -1. ![](https://www.google.com/s2/favicons?domain=https://www.youtube.com) [Youtube Channel](https://www.youtube.com) -1. ![](https://www.google.com/s2/favicons?domain=https://www.youtube.com) [Youtube User](https://www.youtube.com) -1. ![](https://www.google.com/s2/favicons?domain=https://open.spotify.com/) [Spotify](https://open.spotify.com/)