|
|
@@ -0,0 +1,58 @@ |
|
|
import requests |
|
|
|
|
|
#----------------base64 page processing------------ |
|
|
import base64 |
|
|
import re |
|
|
|
|
|
doBase64Decoding = True |
|
|
|
|
|
def fix_base64_string(encoded_string): |
|
|
missing_padding = len(encoded_string) % 4 |
|
|
if missing_padding != 0: |
|
|
encoded_string += '=' * (4 - missing_padding) |
|
|
return encoded_string |
|
|
|
|
|
def decode_base64_in_backticks(input_string): |
|
|
def base64_decode(match): |
|
|
encoded_data = match.group(0)[1:-1] # Extract content within backticks |
|
|
decoded_bytes = base64.b64decode( fix_base64_string(encoded_data) ) |
|
|
return decoded_bytes.decode() |
|
|
|
|
|
pattern = r"`[^`]+`" # Regex pattern to find substrings within backticks |
|
|
decoded_string = re.sub(pattern, base64_decode, input_string) |
|
|
return decoded_string |
|
|
|
|
|
def remove_empty_lines(text): |
|
|
lines = text.split('\n') # Split the text into lines |
|
|
non_empty_lines = [line for line in lines if line.strip()] # Filter out empty lines |
|
|
return '\n'.join(non_empty_lines) # Join non-empty lines back together |
|
|
|
|
|
def extract_base64_sections(base64_page): |
|
|
sections = base64_page.split("***") # Split the input string by "***" to get sections |
|
|
formatted_sections = [] |
|
|
for section in sections: |
|
|
formatted_section = remove_empty_lines( section.strip().replace("#### ", "").replace("\n\n", " - ").replace("\n", ", ") ) |
|
|
if doBase64Decoding: formatted_section = decode_base64_in_backticks(formatted_section) |
|
|
#formatted_section = '[🔑Base64](https://fmhy.pages.dev/base64) ► ' + formatted_section |
|
|
formatted_sections.append(formatted_section) |
|
|
lines = formatted_sections |
|
|
return lines |
|
|
#----------------</end>base64 page processing------------ |
|
|
|
|
|
doLocally = False |
|
|
|
|
|
def main(): |
|
|
if doLocally: |
|
|
with open('base64.md', 'r') as file: |
|
|
base64_page = file.read() |
|
|
sections_list = extract_base64_sections(base64_page) |
|
|
with open("base64_decoded.md", "w") as file: |
|
|
file.write( "\n".join(sections_list) ) |
|
|
|
|
|
else: |
|
|
base64_page = requests.get("https://raw.githubusercontent.com/nbats/FMHYedit/main/" + 'base64.md').text |
|
|
sections_list = extract_base64_sections(base64_page) |
|
|
print( "\n\n".join(sections_list) ) |
|
|
|
|
|
if __name__ == "__main__": |
|
|
main() |