Skip to content

Instantly share code, notes, and snippets.

@TheExpertNoob
Created February 25, 2024 07:17
Show Gist options
  • Save TheExpertNoob/4772fd2ac2a129910fc74114fd21f37a to your computer and use it in GitHub Desktop.
Save TheExpertNoob/4772fd2ac2a129910fc74114fd21f37a to your computer and use it in GitHub Desktop.
Peppa Pig Shop Generator
import os
import json
import requests
import zstandard
import subprocess
import shutil
file_url = "http://tinfoil.media/repo/db/db.bin"
download_path = "db.bin"
decompressed_path = "db.nsp"
input_subdirectory = 'db'
input_file_name = 'ranks.txt'
gdrivelink = '1cyGjLQWTFHx6tDSFDHS0UKSXJQR49mBS'
json_output_file_path = 'output.json'
encrypted_output_file_path = 'index.tfl'
public_key_path = 'public.key'
motd = 'Welcome to Peppa Pig Shop'
input_file_path = os.path.join(input_subdirectory, input_file_name)
# Download the file
response = requests.get(file_url)
if response.status_code == 200:
with open(download_path, 'wb') as f:
f.write(response.content)
print(f"File downloaded successfully to {download_path}")
else:
print(f"Failed to download file. Status code: {response.status_code}")
exit()
# Decompress the file with zstd
with open(download_path, 'rb') as compressed_file, open(decompressed_path, 'wb') as decompressed_file:
decompressor = zstandard.ZstdDecompressor()
decompress_stream = decompressor.stream_reader(compressed_file)
while True:
chunk = decompress_stream.read(8192)
if not chunk:
break
decompressed_file.write(chunk)
print(f"File decompressed successfully to {decompressed_path}")
subprocess.run(['python', 'nspx.py', '-xf', 'db.nsp', 'ranks.txt'])
# Create a list to store the file entries
file_entries = []
with open(input_file_path, 'r') as input_file:
# Skip the first line
next(input_file)
for line in input_file:
# Encapsulate each line with square brackets and remove "|" and everything after it
modified_line = f'[{line.split("|")[0].strip()}]'
# Constructing the file entry in the desired format
file_entry = f'gdrive:/{gdrivelink}#{modified_line}.nsp'
# Adding the file entry to the list
file_entries.append(file_entry)
# Create a dictionary with the "files" key and the list of file entries
output_dict = {"files": file_entries, "success": motd}
# Write the dictionary to a JSON file with indentation
with open(json_output_file_path, 'w') as json_output_file:
json.dump(output_dict, json_output_file, indent=2)
# Call the encrypt.py script using subprocess
subprocess.run(['python', 'encrypt.py', '--zstd', '-k', public_key_path, '-i', json_output_file_path, '-o', encrypted_output_file_path])
# Print the generated JSON file path
print(f"Generated JSON file: {json_output_file_path}")
print(f"Encrypted output file: {encrypted_output_file_path}")
# Cleanup
os.remove(download_path)
os.remove(decompressed_path)
shutil.rmtree(input_subdirectory)
shutil.rmtree("__pycache__")

python3 fakeshop.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment