mirror of
https://github.com/fmhy/edit.git
synced 2026-02-18 01:01:23 +11:00
comment
This commit is contained in:
parent
33c9cf789b
commit
d3114c53fe
1 changed files with 9 additions and 83 deletions
92
.github/add-headers.py
vendored
92
.github/add-headers.py
vendored
|
|
@ -1,96 +1,22 @@
|
|||
import os
|
||||
|
||||
import os # Import the os module to interact with the operating system.
|
||||
|
||||
# Define a dictionary that maps file names to their respective titles and descriptions.
|
||||
headers = {
|
||||
"AdblockVPNGuide.md": [
|
||||
"Adblocking / Privacy",
|
||||
"Adblocking, Privacy, VPN's, Proxies, Antivirus",
|
||||
],
|
||||
"AI.md": [
|
||||
"Artificial Intelligence",
|
||||
"Chat Bots, Text Generators, Image Generators, ChatGPT Tools",
|
||||
],
|
||||
"Android-iOSGuide.md": ["Android / iOS", "Apps, Jailbreaking, Android Emulators"],
|
||||
"AudioPiracyGuide.md": [
|
||||
"Music / Podcasts / Radio",
|
||||
"Stream Audio, Download Audio, Torrent Audio",
|
||||
],
|
||||
"Beginners-Guide.md": ["Beginners Guide", "A Guide for Beginners to Piracy"],
|
||||
"DownloadPiracyGuide.md": [
|
||||
"Downloading",
|
||||
"Download Sites, Software Sites, Open Directories",
|
||||
],
|
||||
"EDUPiracyGuide.md": ["Educational", "Courses, Documentaries, Learning Resources"],
|
||||
"GamingPiracyGuide.md": [
|
||||
"Gaming / Emulation",
|
||||
"Download Games, ROMs, Gaming Tools",
|
||||
],
|
||||
"LinuxGuide.md": ["Linux / MacOS", "Apps, Software Sites, Gaming"],
|
||||
"MISCGuide.md": ["Miscellaneous", "Extensions, Indexes, News, Health, Food, Fun"],
|
||||
"NSFWPiracy.md": ["NSFW", "NSFW Indexes, Streaming, Downloading"],
|
||||
"Non-English.md": ["Non-English", "International Piracy Sites"],
|
||||
"ReadingPiracyGuide.md": [
|
||||
"Books / Comics / Manga",
|
||||
"Books, Comics, Magazines, Newspapers",
|
||||
],
|
||||
"game-tools.md": ["Gaming Tools", "Gaming Optimization, Game Launchers, Multiplayer"],
|
||||
"DEVTools.md": ["Developer Tools", "Git, Hosting, App Dev, Software Dev"],
|
||||
"img-tools.md": ["Image Tools", "Image Editors, Generators, Compress"],
|
||||
"Audio-Tools.md": [
|
||||
"Audio Tools",
|
||||
"Audio Players, Audio Editors, Audio Downloaders",
|
||||
],
|
||||
"System-Tools.md": [
|
||||
"System Tools",
|
||||
"System Tools, Hardware Tools, Windows ISOs, Customization",
|
||||
],
|
||||
"File-Tools.md": ["File Tools", "Download Managers, File Hosting, File Archivers"],
|
||||
"Video-Tools.md": [
|
||||
"Video Tools",
|
||||
"Video Players, Video Editors, Live Streaming, Animation",
|
||||
],
|
||||
"Text-Tools.md": ["Text Tools", "Text Editors, Pastebins, Fonts, Translators"],
|
||||
# "Internet-Tools.md": ["Internet Tools", "Browsers, Extensions, Search Engines"],
|
||||
"Social-Media-Tools.md": [
|
||||
"Social Media Tools",
|
||||
"Discord Tools, Reddit Tools, YouTube Tools",
|
||||
],
|
||||
"STORAGE.md": ["Storage", "Sections too big to fit on main pages"],
|
||||
"TorrentPiracyGuide.md": ["Torrenting", "Torrent Clients, Torrent Sites, Trackers"],
|
||||
"VideoPiracyGuide.md": [
|
||||
"Movies / TV / Anime",
|
||||
"Stream Videos, Download Videos, Torrent Videos",
|
||||
],
|
||||
"base64.md": ["Base64", "Base64 storage"],
|
||||
"UnsafeSites.md": ["Unsafe Sites", "Unsafe/harmful sites to avoid."],
|
||||
# ...
|
||||
}
|
||||
|
||||
# Create the title and description string variables that will be used to format the header.
|
||||
title = '<div class="space-y-2 not-prose"><h1 class="text-4xl font-extrabold tracking-tight text-primary underline lg:text-5xl lg:leading-[3.5rem]">'
|
||||
|
||||
description = '<p class="text-black dark:text-text-2">'
|
||||
|
||||
|
||||
# Define the getHeader function that takes a file name as an argument, retrieves its corresponding title and description from the headers dictionary, and generates the header as a string.
|
||||
def getHeader(page: str):
|
||||
data = headers[page]
|
||||
header = "---\n"
|
||||
header += f'title: "{data[0]}"\n'
|
||||
header += f"description: {data[1]}\n"
|
||||
header += "---\n"
|
||||
header += f"{title}{data[0]}</h1>\n"
|
||||
header += f"{description}{data[1]}</p></div>\n\n"
|
||||
# ...
|
||||
return header
|
||||
|
||||
|
||||
# Define the main function that lists the files in the current directory, checks if each file is in the headers dictionary, and if so, reads the file's content. If the content does not start with "---" (indicating a header is missing), the function writes the generated header to the file.
|
||||
def main():
|
||||
files = os.listdir(".")
|
||||
for file in files:
|
||||
if file in headers:
|
||||
with open(file, "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
if not content.startswith("---"):
|
||||
with open(file, "w", encoding="utf-8") as f2:
|
||||
header = getHeader(file)
|
||||
f2.write(header + content)
|
||||
|
||||
# ...
|
||||
|
||||
# Call the main function to execute the script.
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue