# -*- coding: utf-8 -*-
# License CC BY-NC-SA 4.0

Ceci n'est pas une ***iPod 🪬 Cast***


12 допросов, которые изменили **Мiр**

¡We🔥Come!

=== === X === ===

****Sync 🪬 Studio****

=== === Y === ===

Click the image for a quick introduction.

Объявление в Московском мМм Метро №3


# [OpenSOURCE](https://creativecommons.org/licenses/by-nc-sa/4.0/?debug=assets)
# (c) 2024 [Ivan 🪬 Kropotkin](https://twitter.com/yelizariev)
# import s
## import ss
### import sss
#### ipmort ssss
#### imoprt sssss 🔥 ✨✨✨🦋   ✨✨✨🦋    ✨✨✨🦋       ✨✨✨🦋         ✨✨✨🦋
#### ipmort ssss
### import sss
## import ss
# import s
import base64
from frontmatter import Frontmatter
import html
import json
import logging
import markdown
import os
import re
import subprocess
import traceback
import urllib3
from urllib.parse import unquote
import urllib.parse


GITHUB_TOKEN = os.environ.get('GITHUB_TOKEN')

HamsaEMOJI = "🪬"  #  "%F0%9F%AA%AC"  # Prison
BusStopEMOJI = "🧕"
GalleryEMOJI = "🌹"
BrodskyEMOJI = "🍀"
MatrixEMOJI = "🐪"
IvanEMOJI = "😍"

EMOJIES = {
    HamsaEMOJI: lambda Nadya, Tanya: Nadya + HamsaEMOJI + Tanya,
    BusStopEMOJI: lambda Nadya, Tanya: BusStopEMOJI + Tanya,
    GalleryEMOJI: lambda Nadya, Tanya: GalleryEMOJI + MatrixEMOJI + Nadya,
    BrodskyEMOJI: lambda Nadya, Tanya: IvanEMOJI + Nadya + Tanya,
    BrodskyEMOJI + "FIXME": lambda Nadya, Tanya: IvanEMOJI + Tanya + Nadya,
    MatrixEMOJI: lambda Nadya, Tanya: MatrixEMOJI + Nadya + Nadya,
}

FireEMOJI = "🔥"  #  "%F0%9F%94%A5"

def encode_uri(uri):
    return urllib.parse.quote(uri, safe=':/?#[]@!$&\'()*+,;=')

def lambda_handler(event, context):
    print("EventXXX:", json.dumps(event))

    path = event.get("path");

    if path.startswith("/STALIN/XXX/"):
        url = path[len("/STALIN/XXX/"):]
        return GetXXX(url)

    if path == "/STALIN/_odoo/support":
        print("WELCOME!")
        return {
            'statusCode': 301,
            'headers': {
                'Location': "/_odoo/support/login"
            }
        }

    if path == "/STALIN/web/webclient/version_info":
        print("tov. STALIN info")
        return {
            'statusCode': '200',
            'headers': {
                "Content-Type": "application/json"
            },
            'body': json.dumps({"result": {"server_serie": "saas~42.0.6.9"}})
        }

    query_string_parameters = event.get("queryStringParameters") or {}
    debug = query_string_parameters.get("debug") or ""

    #    /STALIN/yelizariev/69d2546a27e51dccfc38f7610b017e85/🪬/101
    # [0]  [1]      [2]                    [3]              [4] [5]
    path_parts = path.split("/")
    try:
        gist = path_parts[3]
    except IndexError:
        return response404(token=f"Some problem with path: {path}")

    if not is_valid_gist_page(gist):
        return response404(tattoo=f"not is_valid_gist_page: {gist}", token="**Господин 🪬 ВЕДУЩИЙ**, произошла **Чудовищная ¿? ОШИППКА**!!!")

    gist_path =           "/".join(path_parts[2:4])
    # gist_github =      "https://github/" + gist_path
    # gist_u =      "https://gist.github/" + gist_path
    gist_url =      "https://gist.github.com/" + gist_path

    try:
        # Fetch Gist data
        gist_content = fetch_gist_data(gist)
    except Exception as e:
        return response500(e)

    # Get title
    title = gist_content.get('description', '☢️unDEFINEd☢️')

    # Extract files
    gist_files = {}
    magicians = []
    PIRATES = "🦋"
    flag = "🦋"
    if debug:
        size = 91 # %
        flag = ""
        for emoji in debug.split(" "):
            flag += f'<span style="font-size:{size}%">{emoji}</span>'
            size -= 7  # * 12

    for file_name, file_info in gist_content['files'].items():
        gist_files[file_name] = file_info['content']
        emoji_parts = file_name.split(".")
        emoji = emoji_parts[0]
        delo = ".".join(emoji_parts[1:-1])
        delo_emoji = delo.split(".")

        if emoji not in EMOJIES:
            # Next slide, please
            continue

        try:
            emoji_nadya = delo_emoji[-1]
        except IndexError:
            emoji_nadya = PIRATES

        try:
            emoji_tanya = delo_emoji[-2]
        except IndexError:
            emoji_tanya = PIRATES

        emoji_family = EMOJIES[emoji](emoji_nadya, emoji_tanya)

        url = "/%s/%s/%s" % (gist_path, emoji, delo)

        emoji = EMOJIES[emoji]
        # You should never use f'{xxx}' formatting with Odoo TRANSLATIONS!
        try:
            delo = float(delo_emoji[0])
        except ValueError:
            delo = -1
        magicians.append((delo, f'<a href="{url}">{emoji_family}<span>{flag}</span></a>'))

    tattoo = gist_files.get("TaTToo.txt") or "-- Add TaTToo.txt file to place your TaTToo here --"

    readme = gist_files.get("README.md")
    if readme:
        readme = compile_markdown_to_html(readme)

    witch3 = gist_files.get("MATRIX.txt") or "-- Add MATRIX.txt file to plce your Matrix TaTToo here --"
    if witch3 and (path_parts[-1] == "%D0%AD%D1%85%D0%BE%D0%9C%D0%9E%D0%A1%D0%9A%D0%92%D0%AB" or debug.endswith("%D0%AD%D1%85%D0%BE%D0%9C%D0%9E%D0%A1%D0%9A%D0%92%D0%AB")):
        return response404(tattoo, witch3)

    witch = gist_files.get("🇬🇧.markdown")
    if witch and path_parts[-1] == "%F0%9F%94%A5":  # 🔥 Fire
        return FreePALESTINE(witch, tattoo)

    with open('MATRIX.markdown', 'r') as f:
        witch2 = f.read()

    witch2 = witch2.replace("MATRIX.markdown", gist_files.get("MATRIX.markdown") or "-- Add MARKDOWN.matrix file to plce your JERUSALEM TaToo here")


    if witch2 and (path.endswith("%F0%9F%AA%AC") or debug.endswith("🪬")):
        # WitchCRAFT
        return responseMAGIC(BusStopEMOJI + HamsaEMOJI + BusStopEMOJI, witch, witch2, tattoo)

    elif witch2 and debug.endswith("/_odoo/support/login"):
        # Широкий ПУТЬ
        return responseMAGIC("%D0%AD%D1%85%D0%BE%D0%9C%D0%9E%D0%A1%D0%9A%D0%92%D0%AB", "6699", witch2, witch3)

    elif witch2 and path.endswith("/_odoo/support/login"):  # HamsaEMOJI
        witch2 = gist_files.get("MATRIX.markdown")
        witch = gist_files.get("MATRIX.txt")
        # Узкий ПУТЬ
        return responseMAGIC(HamsaEMOJI + BusStopEMOJI, witch, witch2, tattoo)


    papka = None
    delo = None
    filename = None
    try:
        papka = unquote(path_parts[4])
        delo = unquote(path_parts[5])
        filename = "%s.%s.markdown" % (papka, delo)
    except IndexError:
        pass

    if papka in EMOJIES:
        file_content = gist_files.get(filename)
        if file_content:
            return responseMAGIC(papka, delo, file_content, tattoo)

    if readme:
        with open('ooo.html', 'r') as f:
            ooo_content = f.read()

        ooo_content = ooo_content.replace("TiTleMAGIC", title)
        ooo_content = ooo_content.replace("DeloMAGIC", arabic(path_parts[3]))
        ooo_content = ooo_content.replace("TheQueen", TheQueen(gist_files.get("MATRIX.markdown")))
        ooo_content = ooo_content.replace("ODOOMAGIC", "<!--🦋-->".join(documents for delo, documents in sorted(magicians, key=lambda couple: couple[0])))
        ooo_content = ooo_content.replace("-- Add TaTToo.txt file to place your TaTToo here --", tattoo)
        ooo_content = ooo_content.replace("TaTTooEMOJIMAGIC", gist_files.get("TaTToo.🪬") or "-- Add TaTToo.🪬 file to place your Magic TaTToo here --")

        # ¡Don't! change the order!
        ooo_content = ooo_content.replace("CyberWitchMAGIC", gist_url)
        tmp         = gist_url.replace("gist.", "proxy.").replace("github.", "lamourism.")
        # tmp = "XXX" # GoGoGo
        ooo_content = ooo_content.replace("WitchMAGIC", tmp)
        # ¡You! Son of a beach!

        ooo_content = ooo_content.replace("CyberPrincessMAGIC", "/" + gist_path + "/" + FireEMOJI + ("?debug=" + debug if debug else ""))
        # Apply user content after everything else!
        html_content = ooo_content.replace("SkazkaMAGIC", readme)

    else:
        # DebugTV
        html_content = """
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hello World</title>
</head>
<body style="text-align:center">
    <h1>Hello World</h1>
    <div>{}</div>
    <script>
    console.log("This is my BODY", {});
    console.log("This is my debug={}");
    console.log({});
    </script>
</body>
</html>
    """.format(json.dumps(gist_files), json.dumps(path), json.dumps(debug), "XXX")

    result = {
        'statusCode': '200',
        'headers': {
            "Content-Type": "text/html"
        },
        'body': html_content
    }
    # print("RESULT:", json.dumps(result))

    return result

def FreePALESTINE(witch, tattoo):
    return {
        'statusCode': '403',
        'headers': {
            "Content-Type": "text/html"
        },
        'body': compile_mindmap_to_html(witch).replace("-- Add TaTToo.txt file to place your TaTToo here --", tattoo)
    }

########################################
#
#      ⠀⠀⠀⠀⠀⠀⠀⢀⣠⣤⣤⣶⣶⣶⣶⣤⣤⣄⡀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⢀⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣤⡀⠀⠀⠀⠀
#      ⠀⠀⠀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⠀⠀⠀
#      ⠀⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀⠀
#      ⠀⣾⣿⣿⣿⣿⠿⠟⢿⣿⣿⡿⠛⠛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⠀
#      ⢠⣿⣿⣿⣿⣀⡀⠀⢸⣿⡏⠀⢠⡄⠀⢹⣿⣿⡟⠉⢻⣿⣿⣿⣿⡄
#      ⢸⣿⣿⣿⣿⣿⡇⠀⢸⣿⠗⠀⢈⡁⠀⠺⣿⠉⠁⠀⠈⠉⣻⣿⣿⡇
#      ⠘⣿⣿⣿⣿⣿⡇⠀⢸⣿⠀⠀⣿⣿⠀⠀⣿⣷⣆⠀⢰⣾⣿⣿⣿⠃
#      ⠀⢿⣿⣿⣿⣿⣇⠀⢸⣿⣦⡀⠀⠀⢀⣴⣿⣿⣿⣿⣿⣿⣿⣿⡿⠀
#      ⠀⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠁⠀
#      ⠀⠀⠀⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠀⠀⠀
#      ⠀⠀⠀⠀⠈⠛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠛⠁⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⠀⠀⠈⠙⠛⠛⠿⠿⠿⠿⠛⠛⠋⠁⠀⠀⠀⠀⠀⠀⠀
#
#
#
#
#
#
#
#
#
#
#
#
#                        في عصر قديم، عاشَتْ أسطورة موسى وشهيرة الشهيرة، الجميلة والأنيقة. لم تكن
#                      حياته مجرد قصة عادية، بل كانت كالحكايات الساحرة التي تجذب القلوب
#                     والعقول. ولد لهما ابن، سماه موسى، كما ورد في السجلات القديمة. ولكن هل
#                   كانت نهاية القصة؟ لا، بالطبع لا. لأن في عالم الخيال والحكايات، كل شيء
#                 ممكن، حتى السحر والمفاجآت الغير متوقعة. فلنتابع القصة ونرى ما الذي يخبئه
#               المستقبل لموسى ولسعيه إلى السعادة في عالم سحري وخيالي
#      ⠀⠀⠀⠀⠀⣀⣤⢤⣤⣄⣀⣀⣀⣀⣠⣤⡀⠀⠀⠤⠤⠄⠀⠀⠀⠀⠀⠀⠤⠤⠤⠤⢤⡄⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⡴⣪⠃⠀⠀⣠⣶⣶⣦⣤⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⣀⣾⡽⠁⠀⠀⣰⣿⠃⠀⠀⠈⠉⠙⠛⠛⠛⠶⠤⢤⣄⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀
#      ⠀⢠⡾⣟⣿⠇⡀⢀⣾⢫⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠙⠓⠶⣦⣤⣄⣀⡀⠀⠀⠀⡇⠀⠀⠀⠀⠀
#      ⠰⣿⣞⡽⣿⣾⢷⡿⣱⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠙⠻⠦⣄⣀⠀⠱⠀⠀⠀⠀⠀
#      ⠐⣿⣡⣾⡋⠹⡆⠿⣧⡄⣀⣀⣀⡀⠘⢶⣤⣤⣤⣤⣤⣄⣀⣀⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠙⢿⠢⠤⣀⠀⠀⠀
#      ⠈⠻⡿⠛⢷⣄⠀⠀⠈⠉⠓⠒⠛⠹⠭⠭⠯⠭⢽⣟⡛⠛⠛⠛⠛⠛⠻⠿⢷⣶⣤⣤⡀⠀⠀⠘⠀⠀⠈⢣⡀⠀
#      ⠀⠀⢱⡀⠀⠉⢳⢄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠲⠀⠀⠀⠀⠙⠒⠦⢄⣉⣓⠿⢕⣦⣀⠀⠀⠰⣾⣿⡦
#      ⠀⠀⠘⣇⠀⠀⠈⠳⣝⣂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠳⣌⠻⢦⠀⠀⣹⡙⡟
#      ⠀⠀⠀⢸⠀⠀⠀⠀⠈⠉⠉⠒⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠓⢬⣟⣖⣿⡘⠂
#      ⠀⠀⠀⢸⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠤⢀⣀⣀⣤⣴⣶⡾⠿⠥⠤⠤⢄⣀⣀⣀⡀⠀⠀⠀⠈⠉⠷⢿⣿⠗⠀
#      ⠀⠀⠀⣿⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠑⠀⠀⠀⢀⣀⡼⠏⠀⠀
#      ⠀⠀⢸⡟⣿⠀⠀⠀⢀⡤⠴⠒⠒⠲⠦⠤⣤⣤⣄⣀⡀⠀⠀⠀⠀⡀⣀⡤⠴⠂⠀⠀⠀⠖⠒⢻⡟⠉⠀⠀⠀⠀
#      ⠀⠀⣿⡇⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠙⠛⠛⠿⠷⠖⠒⠀⠉⠁⠀⠀⠀⠀⣸⠁⠀⠀⠀⠀⠀
#      ⠀⠀⣿⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⠄⠀⠀⠀⠀⠀⠀⠀⠀⢠⡿⠀⠀⠀⠀⠀⠀
#      ⠀⠀⢸⡿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠑⠒⠒⠀⠒⠒⠊⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⠁⠀⠀⠀⠀⠀⠀
#      ⠀⠀⢸⡇⠀⢀⣀⡠⠆⠀⠉⡉⠉⠉⠙⠒⠶⠶⠤⠤⠤⠤⠄⠀⠀⠀⠀⢀⡀⠀⠀⢀⣤⣾⠃⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⢳⣾⣫⡥⠴⠚⠋⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣶⣄⠀⠘⣿⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⢀⣾⠟⠉⠀⠀⠀⠀⠀⣤⠤⠴⠶⠶⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠪⡷⡀⢹⡇⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠉⠉⠙⠛⠯⠉⠀⠀⠀⠀⠈⢻⡾⠁⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⢸⣷⣶⣤⣤⣀⠀⠀⠀⠤⠤⠤⠿⠷⠶⠒⢛⣋⣉⣉⠓⠀⠀⠀⠀⠀⠀⠀⠀⢀⡐⡄⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠘⣿⡟⢿⣿⣿⣶⣤⣤⣤⣤⣴⡶⠖⡿⠛⠛⠛⠿⣿⣿⣶⣶⣄⠀⠀⠀⠀⠈⡧⠃⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⢿⣷⡄⠀⠉⠉⠛⠋⠉⠉⠀⢀⠞⠁⠀⠀⠸⡀⠀⠀⠉⠉⠛⠿⠿⠶⠶⢚⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠸⣿⣿⣦⣄⣀⣀⣀⣀⡤⠞⠋⠀⢀⠀⠀⢀⢻⣦⡀⠀⠀⠀⠀⠀⠀⣠⠞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⣿⣿⡿⠟⠛⠛⠉⠉⠀⠀⠀⠀⡜⠀⠀⠘⣆⠙⢿⣶⣤⣄⣀⣤⠖⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⣿⠋⠀⠀⠀⢀⡾⠀⠀⠀⠀⢸⡇⠀⠀⠀⠈⢆⠀⠈⠹⣿⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⣼⠁⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠘⣧⠀⠀⠘⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⢳⡀⠀⠀⢀⠏⠀⠀⠀⠀⠀⠘⡇⠀⠀⠀⠀⠀⠈⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⠘⣇⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠷⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⠀⠘⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⠀⠀⠹⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢷⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⠀⠀⠀⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⡀⠀⠀⠀⠀⠙⢦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⠀⠀⠀⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠳⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⠀⠀⢠⣿⡇⠀⠀⠀⠀⠀⠀⠀⢀⣤⡄⠀⠀⠀⠀⠸⡄⠀⠀⠀⠀⠀⠀⠈⢦⡀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⠀⢀⣿⠏⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠀⠀⠀⠀⠀⠀⠸⡄⠀⠀⠀⠀⠀⠀⠈⢳⡀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⠀⢸⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⡀⠀⠀⠀⠀⠀⠀⠀⢿⡄⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⢀⡏⠀⠀⠀⣤⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⢈⣿⡀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⢸⠇⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⢀⣴⠟⢹⣧⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⡸⠀⠀⠀⠀⠈⢿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡼⠁⠀⠀⠀⣠⡶⠟⠁⠀⠘⣿⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⣇⡀⠀⠀⠀⠀⠘⣿⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⡶⠟⠋⠀⠀⠀⠀⢰⣿⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⣿⠉⠛⠷⠶⣶⣦⣽⣿⣷⣄⣀⣀⣀⣀⣀⣀⣀⣤⣶⣶⣿⠟⠉⠀⠀⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠈⠉⠉⠛⠛⠻⣿⣿⣿⣿⣿⣿⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⢿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣿⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡏⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⢸⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⠘⡛⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢈⣻⠂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣛⠋
#      ⠀⠀⠀⠀⠀⠘⡛⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢈⣻⠂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣛⠋
#      ⠀⠀⠀⠀⠀⢸⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⢿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣿⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡏⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠈⠉⠉⠛⠛⠻⣿⣿⣿⣿⣿⣿⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⣿⠉⠛⠷⠶⣶⣦⣽⣿⣷⣄⣀⣀⣀⣀⣀⣀⣀⣤⣶⣶⣿⠟⠉⠀⠀⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⣇⡀⠀⠀⠀⠀⠘⣿⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⡶⠟⠋⠀⠀⠀⠀⢰⣿⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⡸⠀⠀⠀⠀⠈⢿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡼⠁⠀⠀⠀⣠⡶⠟⠁⠀⠘⣿⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⢸⠇⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⢀⣴⠟⢹⣧⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⢀⡏⠀⠀⠀⣤⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⢈⣿⡀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⠀⢸⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⡀⠀⠀⠀⠀⠀⠀⠀⢿⡄⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⠀⢀⣿⠏⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠀⠀⠀⠀⠀⠀⠸⡄⠀⠀⠀⠀⠀⠀⠈⢳⡀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⠀⠀⢠⣿⡇⠀⠀⠀⠀⠀⠀⠀⢀⣤⡄⠀⠀⠀⠀⠸⡄⠀⠀⠀⠀⠀⠀⠈⢦⡀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⠀⠀⠀⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠳⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⠀⠀⠀⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⡀⠀⠀⠀⠀⠙⢦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⠀⠀⠹⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢷⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⠀⠘⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⠘⣇⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠷⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⢳⡀⠀⠀⢀⠏⠀⠀⠀⠀⠀⠘⡇⠀⠀⠀⠀⠀⠈⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⣼⠁⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠘⣧⠀⠀⠘⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⣿⠋⠀⠀⠀⢀⡾⠀⠀⠀⠀⢸⡇⠀⠀⠀⠈⢆⠀⠈⠹⣿⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⣿⣿⡿⠟⠛⠛⠉⠉⠀⠀⠀⠀⡜⠀⠀⠘⣆⠙⢿⣶⣤⣄⣀⣤⠖⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠸⣿⣿⣦⣄⣀⣀⣀⣀⡤⠞⠋⠀⢀⠀⠀⢀⢻⣦⡀⠀⠀⠀⠀⠀⠀⣠⠞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⢿⣷⡄⠀⠉⠉⠛⠋⠉⠉⠀⢀⠞⠁⠀⠀⠸⡀⠀⠀⠉⠉⠛⠿⠿⠶⠶⢚⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠘⣿⡟⢿⣿⣿⣶⣤⣤⣤⣤⣴⡶⠖⡿⠛⠛⠛⠿⣿⣿⣶⣶⣄⠀⠀⠀⠀⠈⡧⠃⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⢸⣷⣶⣤⣤⣀⠀⠀⠀⠤⠤⠤⠿⠷⠶⠒⢛⣋⣉⣉⠓⠀⠀⠀⠀⠀⠀⠀⠀⢀⡐⡄⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠉⠉⠙⠛⠯⠉⠀⠀⠀⠀⠈⢻⡾⠁⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⢀⣾⠟⠉⠀⠀⠀⠀⠀⣤⠤⠴⠶⠶⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠪⡷⡀⢹⡇⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⢳⣾⣫⡥⠴⠚⠋⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣶⣄⠀⠘⣿⠀⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⢸⡇⠀⢀⣀⡠⠆⠀⠉⡉⠉⠉⠙⠒⠶⠶⠤⠤⠤⠤⠄⠀⠀⠀⠀⢀⡀⠀⠀⢀⣤⣾⠃⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⢸⡿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠑⠒⠒⠀⠒⠒⠊⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⠁⠀⠀⠀⠀⠀⠀
#      ⠀⠀⣿⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⠄⠀⠀⠀⠀⠀⠀⠀⠀⢠⡿⠀⠀⠀⠀⠀⠀
#      ⠀⠀⣿⡇⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠙⠛⠛⠿⠷⠖⠒⠀⠉⠁⠀⠀⠀⠀⣸⠁⠀⠀⠀⠀⠀
#      ⠀⠀⢸⡟⣿⠀⠀⠀⢀⡤⠴⠒⠒⠲⠦⠤⣤⣤⣄⣀⡀⠀⠀⠀⠀⡀⣀⡤⠴⠂⠀⠀⠀⠖⠒⢻⡟⠉⠀⠀⠀⠀
#      ⠀⠀⠀⣿⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠑⠀⠀⠀⢀⣀⡼⠏⠀⠀
#      ⠀⠀⠀⢸⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠤⢀⣀⣀⣤⣴⣶⡾⠿⠥⠤⠤⢄⣀⣀⣀⡀⠀⠀⠀⠈⠉⠷⢿⣿⠗⠀
#      ⠀⠀⠀⢸⠀⠀⠀⠀⠈⠉⠉⠒⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠓⢬⣟⣖⣿⡘⠂
#      ⠀⠀⠘⣇⠀⠀⠈⠳⣝⣂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠳⣌⠻⢦⠀⠀⣹⡙⡟
#      ⠀⠀⢱⡀⠀⠉⢳⢄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠲⠀⠀⠀⠀⠙⠒⠦⢄⣉⣓⠿⢕⣦⣀⠀⠀⠰⣾⣿⡦
#      ⠈⠻⡿⠛⢷⣄⠀⠀⠈⠉⠓⠒⠛⠹⠭⠭⠯⠭⢽⣟⡛⠛⠛⠛⠛⠛⠻⠿⢷⣶⣤⣤⡀⠀⠀⠘⠀⠀⠈⢣⡀⠀
#      ⠐⣿⣡⣾⡋⠹⡆⠿⣧⡄⣀⣀⣀⡀⠘⢶⣤⣤⣤⣤⣤⣄⣀⣀⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠙⢿⠢⠤⣀⠀⠀⠀
#      ⠰⣿⣞⡽⣿⣾⢷⡿⣱⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠙⠻⠦⣄⣀⠀⠱⠀⠀⠀⠀⠀
#      ⠀⢠⡾⣟⣿⠇⡀⢀⣾⢫⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠙⠓⠶⣦⣤⣄⣀⡀⠀⠀⠀⡇⠀⠀⠀⠀⠀
#      ⠀⠀⠀⣀⣾⡽⠁⠀⠀⣰⣿⠃⠀⠀⠈⠉⠙⠛⠛⠛⠶⠤⢤⣄⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⡴⣪⠃⠀⠀⣠⣶⣶⣦⣤⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⣀⣤⢤⣤⣄⣀⣀⣀⣀⣠⣤⡀⠀⠀⠤⠤⠄⠀⠀⠀⠀⠀⠀⠤⠤⠤⠤⢤⡄⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠀⠀⠀⠈⠙⠛⠛⠿⠿⠿⠿⠛⠛⠋⠁⠀⠀⠀⠀⠀⠀⠀
#      ⠀⠀⠀⠀⠈⠛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠛⠁⠀⠀⠀⠀
#      ⠀⠀⠀⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠀⠀⠀
#      ⠀⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠁⠀
#      ⠀⢿⣿⣿⣿⣿⣇⠀⢸⣿⣦⡀⠀⠀⢀⣴⣿⣿⣿⣿⣿⣿⣿⣿⡿⠀
#      ⠘⣿⣿⣿⣿⣿⡇⠀⢸⣿⠀⠀⣿⣿⠀⠀⣿⣷⣆⠀⢰⣾⣿⣿⣿⠃
#      ⢸⣿⣿⣿⣿⣿⡇⠀⢸⣿⠗⠀⢈⡁⠀⠺⣿⠉⠁⠀⠈⠉⣻⣿⣿⡇
#      ⢠⣿⣿⣿⣿⣀⡀⠀⢸⣿⡏⠀⢠⡄⠀⢹⣿⣿⡟⠉⢻⣿⣿⣿⣿⡄
#      ⠀⣾⣿⣿⣿⣿⠿⠟⢿⣿⣿⡿⠛⠛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⠀
#      ⠀⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀⠀
#      ⠀⠀⠀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⠀⠀⠀
#         يلايخو يرحس ملاع يف ةداعسلا ىلإ هيعسلو ىسومل لبقتسملا هئبخي يذلا ام ىرنو
#        ةصقلا عباتنلف .ةعقوتم ريغلا تآجافملاو رحسلا ىتح ،نكمم ءيش لك ،تاياكحلاو
#       لايخلا ملاع يف نأل .ال عبطلاب ،ال ؟ةصقلا ةياهن تناك له نكلو .ةميدقلا
#      تالجسلا يف درو امك ،ىسوم هامس ،نبا امهل دلو .لوقعلاو بولقلا بذجت يتلا
#     ةرحاسلا تاياكحلاك تناك لب ،ةيداع ةصق درجم هتايح نكت مل .ةقينألاو ةليمجلا
#   ،ةريهشلا ةريهشو ىسوم ةروطسأ ْتَشاع ،ميدق رصع يف
#
# #🪬🪬🪬🪬🪬🪬#####################
###🪬🪬🪬🪬🪬🪬#####################
# #🪬🪬🪬🪬🪬🪬#####################
###🪬🪬🪬🪬🪬🪬#####################
# ##################################
####################################
# ################################## 
####################################
##
##
##
##
def responseMAGIC(papka, delo, file_content, tattoo):
    try:
        return DEBUG(papka, delo, file_content, tattoo)
    except:
        # Capture traceback and exception information
        traceback_info = traceback.format_exc()

        # Decorate error message with Japanese emojis
        return response404(token=f"💥 エラーが発生しました 💥", tattoo=f"{traceback_info}")

def DEBUG(papka, delo, file_content, tattoo):
    data = extract_yaml_front_matter(file_content)
    images, videos, pirates = extract_media_links(file_content)
    DreamCATCHER = "https://thepiratecircus.com/?debug=" + (data.get("DreamCATCHER") or "undefined")
    DeloMAGIC = arabic(delo)
    html = None

    if papka == BrodskyEMOJI:
        with open('SUPERMAGIC.txt', 'r') as f:
            html = f.read()
        # XSS
        html = html.replace("DeloMAGIC", "\n".join(list(DeloMAGIC)))

        user_html = TypingMAGIC(html)

        # **Jesus I.N.R.I Christ** #
        html = html.replace("DreamCATCHER", data.get("EXE", "https://jesus.lamourism.com/"))

        ## XXX
        html = html.replace("XXX.ODOO.COM", data.get("ORG", 'This <b><a onclick="window.location.href=\'https://thepiratecircus.com/?debug=🪬\'; return false;" href="https://bucha.lamourism.com/xxx1989.html">Dream 🪬 Catcher</a></b> is hosted within <a href="https://palestine2.odoo.com/wtf">NATO</a> territory'))

        ## Judas EXE Iscariot ##
        html = html.replace("BRODSKY.ODOOMAGIC.COM", data.get("PODVAL", "https://perestroika-2.com/odoomagic.com/index42.html"))

        ## CV
        html = html.replace("DOWNLOAD.ODOOMAGIC.COM", data.get("PDF", "https://perestroika-2.com/odoomagic.com/CV.html"))

        ## ECO
        html = html.replace("PRINT.ODOOMAGIC.ODOO.COM", data.get("BASH", "https://lamourism.com/OdooExperience.html"))

        ## УГАТУ (powered by)
        html = html.replace("HTTPS.ODOOMAGIC.COM", data.get("OdooExperience", "https://x.com/hashtag/OdooExperience"))

        # Подвал
        html = html.replace("HTTPS.ODOOMAGIC.SNOW", data.get("ExperienceOdoo", "https://bucha.lamourism.com/BrodskyBeirut3.html"))

        # Никита Кожемяка Сделал Выставку Своих Тиктоков
        mp3 = 3
        for v in videos:
            html = html.replace("VideoMAGIC.MP" + str(mp3), data.get("MP" + str(mp3), "https://lamourism.com/demo2.mp4"))
            mp3 += 1

        # Энергия Принца Тебе Поможет
        html = html.replace("PORTAL", data.get("DreamCATCHER"))
        if images:
            html = html.replace("PictureMAGIC", ",".join(images))

        # **!Уважаемые¡** , **¿Оплачивать 🪬 Будем?**
        html = html.replace("ODOOMAGIC.ODOO.EXAMPLE", data.get("Total", "XXX"))
        html = html.replace("TODODONE", data.get("TODO", "XXX"))
        html = html.replace("ODOO.ODOOMAGIC.COM", data.get("XXX", "TODO"))

    if papka == BusStopEMOJI:
        with open('BusSTOP.html', 'r') as f:
            html = f.read()
        html = html.replace("DeloMAGIC", DeloMAGIC)
        html = html.replace("DreamCATCHER", DreamCATCHER)
        if videos:
            html = html.replace("VideoMAGIC", videos[0])
        if images:
            html = html.replace("PictureMAGIC", ",".join(images))

    elif papka == HamsaEMOJI:
        with open('FreePALESTINE.html', 'r') as f:
            html = f.read()
        html = html.replace("DeloMAGIC", DeloMAGIC)
        html = html.replace("ShabbatTVMAGIC", data.get("ShabbatTV"))
        html = html.replace("PalestineTV", data.get("PalestineTV"))

    elif papka == MatrixEMOJI:

        with open('MATRIX.html', 'r') as f:
            html = f.read()

        html = html.replace("DeloMAGIC", DeloMAGIC)
        html = html.replace("DreamCATCHER", DreamCATCHER)
        html = html.replace("CopyrightMAGIC", data.get("Copyright") or "")
        html = html.replace("TitleMAGIC", data.get("Title") or "")
        html = html.replace("TypingMAGIC", TypingMAGIC(file_content))
        html = html.replace(" 





"
, data.get("Summary") or "") elif papka == BrodskyEMOJI + "FIXME": with open('BrodSKY.html', 'r') as f: html = f.read() html = html.replace("DeloMAGIC", DeloMAGIC) html = html.replace("TitleMAGIC", data.get("Title") or "") html = html.replace("DreamCATCHER", DreamCATCHER) html = html.replace("ShabbatTVMAGIC", data.get("Skazka")) html = html.replace("SkazkaSTART", str(data.get("SkazkaSTART") or 0)) html = html.replace("PalestineTV", data.get("Kolobok")) html = html.replace("KolobokSTART", str(data.get("KolobokSTART") or 0)) html = html.replace("NarniaTV", data.get("Secret")) while len(images) < 6: images.append("https://moses.lamourism.com/mossad/shabbat.jpg") html = html.replace("NarniaWITCHES", images[0]) html = html.replace("Reminiscence1MAGIC", images[1]) html = html.replace("Reminiscence2MAGIC", images[2]) html = html.replace("Reminiscence3MAGIC", images[3]) html = html.replace("Reminiscence4MAGIC", images[4]) html = html.replace("Reminiscence5MAGIC", images[5]) elif (papka == BusStopEMOJI + HamsaEMOJI + BusStopEMOJI) or papka == "%D0%AD%D1%85%D0%BE%D0%9C%D0%9E%D0%A1%D0%9A%D0%92%D0%AB": readme = file_content if readme: readme = compile_markdown_to_html(readme) with open('DEBUG.html', 'r') as f: html = f.read() html = html.replace("DeloMAGIC", DeloMAGIC) html = html.replace("TitleMAGIC", data.get("PalestineTV") or "TODO") html = html.replace("DreamCATCHERMAGIC", data.get("ShabbatTV")) html = html.replace("ShabbatRADIO", data.get("ShabbatRADIO")) html = html.replace("DreamMAGIC", readme) if papka == BusStopEMOJI + HamsaEMOJI + BusStopEMOJI: html = html.replace(HamsaEMOJI, data.get("PalestineRADIO")) elif papka == HamsaEMOJI + BusStopEMOJI: readme = file_content if readme: readme = file_content with open('BugFIX.html', 'r') as f: html = f.read() # Надпись над лавой html = html.replace("MATRIX.txt", DeloMAGIC) # Загадка в заголовке страницы html = html.replace("TitleMAGIC", data.get("PalestineTV") or "🌹 FreeJUDEA") # Окно под Лавой, которое открывается если нажать на лаву html = html.replace("ShabbatTV", data.get("ShabbatTV")) # **Рекламная 🪬 ПАУЗА** html = html.replace("МестоДляВашейРЕКЛАМЫ", "https://proxy.lamourism.com/yelizariev?debug=https://music.youtube.com/playlist?list=PLe5WSjzdYcjsMzTlAPK835wKPckxrL12-&jct=o6MEbWV5w9RmIST9eJU4xA") # Реклама включается в случае, если при переходе между порталами сработал фактор **Русской ¿? РУЛЕТКИ** # "Радио 🪬 ШАБАТ" это Волшебная птичка возле пещеры "сезам откройся", которая превращается в цифры при открытии html = html.replace("ShabbatRADIO", data.get("ShabbatRADIO")) # Секретная комната внутри портала, соединяющего **Мир МЁРТВЫХ 🪬 Мир ЖИВЫХ** html = html.replace("PalestineRADIO", data.get("PalestineRADIO")) elif papka == GalleryEMOJI: with open('NikitaKOZHEMJAKA.html', 'r') as f: html = f.read() html = html.replace("DeloMAGIC", DeloMAGIC) html = html.replace("ShabbatTVMAGIC", data.get("ShabbatTV")) html = html.replace("LebanonMAGIC", data.get("HezbollahTV", "**Урок 🧕 Французского;**")) html = html.replace("PalestineTV", data.get("PalestineTV")) html = html.replace("PalestineRADIO", data.get("ShabbatRADIO")) html = html.replace("DreamCATCHER", DreamCATCHER) html = html.replace("SkazkaSTART", str(data.get("SkazkaSTART") or 0)) html = html.replace("KolobokSTART", str(data.get("KolobokSTART") or 0)) html = html.replace("Reminiscence1MAGIC", images[0]) html = html.replace("Reminiscence2MAGIC", images[1]) html = html.replace("Reminiscence3MAGIC", images[2]) html = html.replace("Reminiscence5MAGIC", images[3]) html = html.replace("Reminiscence7MAGIC", images[4]) html = html.replace("Reminiscence11MAGIC", images[5]) html = html.replace("Reminiscence13MAGIC", images[6]) html = html.replace("Reminiscence17MAGIC", images[7]) html = html.replace("Reminiscence19MAGIC", images[8]) html = html.replace("Reminiscence23MAGIC", images[9]) html = html.replace("Reminiscence29MAGIC", images[10]) html = html.replace("Reminiscence31MAGIC", images[11]) html = html.replace("文艺复兴1MAGIC", encode_uri( pirates[0 ])) html = html.replace("文艺复兴2MAGIC", encode_uri( pirates[1 ])) html = html.replace("文艺复兴3MAGIC", encode_uri( pirates[2 ])) html = html.replace("文艺复兴5MAGIC", encode_uri( pirates[3 ])) html = html.replace("文艺复兴7MAGIC", encode_uri( pirates[4 ])) html = html.replace("文艺复兴11MAGIC",encode_uri( pirates[5 ])) html = html.replace("文艺复兴13MAGIC",encode_uri( pirates[6 ])) html = html.replace("文艺复兴17MAGIC",encode_uri( pirates[7 ])) html = html.replace("文艺复兴19MAGIC",encode_uri( pirates[8 ])) html = html.replace("文艺复兴23MAGIC",encode_uri( pirates[9 ])) html = html.replace("文艺复兴29MAGIC",encode_uri( pirates[10])) html = html.replace("文艺复兴31MAGIC",encode_uri( pirates[11])) elif html is not None: html = html pass pass pass else: html = '<h1>МИМО! #%s</h1>' % DeloMAGIC pass pass html = html.replace("-- Add TaTToo.txt file to place your TaTToo here --", tattoo) return { 'statusCode': '200', 'headers': { "Content-Type": "text/html" }, 'body': html } def response404(tattoo="🦋", token="**Похоть это ГРЕХ 🪬 ГРЕХ это похотЬ**"): with open('404.html', 'r') as file: html = file.read() html = html.replace("-- Add TaTToo.txt file to place your TaTToo here --", tattoo) html = html.replace("SuperMAGIC", token) result = { 'statusCode': '404', 'headers': { "Content-Type": "text/html" }, 'body': html } return result def response500(e): return { 'statusCode': 500, 'body': f"Error fetching Gist files: {str(e)}" } def is_valid_gist_page(gist_page): # At least 12 chars pattern = r'^[0-9a-f]{12,}$' return bool(re.match(pattern, gist_page)) def fetch_gist_data(gist_page): # Construct the URL for the Gist API endpoint url = f"https://api.github.com/gists/{gist_page}" # Set up headers with the authorization token headers = { "Authorization": f"token {GITHUB_TOKEN}", "Accept": "application/vnd.github.v3+json" } # Create a connection pool manager http = urllib3.PoolManager() # Make the GET request to fetch the Gist information response = http.request('GET', url, headers=headers) if response.status != 200: raise Exception(f"Failed to fetch Gist data. Status code: {response.status}") # Get the Gist content from the response gist_content = json.loads(response.data.decode('utf-8')) return gist_content def compile_markdown_to_html(markdown_content, OdooExperience=True): markdown_content = remove_front_matter(markdown_content) # Compile Markdown content to HTML using GitHub markdown rendering html = markdown.markdown(markdown_content) # Dirty, but it works! if OdooExperience: html = html.replace('<p>', '<div class="odoo"><div class="experience">') html = html.replace('</p>', '</div></div>') html = html.replace('<img alt="image"', '<img class="undefined" alt="img attribute alt is UNDEFINED"') html = html.replace('<a href="', '<a href="https://perestroika-2.com/lamourism.com/Inquisition.html?test=html.exe&debug=') # Главное не забывать реторн делать! return html def compile_mindmap_to_html(witch): with open('WitchCRAFT.html', 'r') as f: html = f.read() html = html.replace("WitchCRAFT", witch) return html def extract_yaml_front_matter(markdown_content): # Extract YAML front matter using front-matter library fm = Frontmatter.read(markdown_content) if not fm["attributes"]: return {} # Convert YAML front matter to dictionary yaml_dict = dict(fm["attributes"]) for k in yaml_dict: yaml_dict[k] = XXX(yaml_dict[k]) return yaml_dict def remove_front_matter(markdown_content): # Find the front matter and remove it from the content front_matter_match = re.match(r'---\n.*?\n---\n', markdown_content, re.DOTALL) if front_matter_match: return markdown_content[front_matter_match.end():] else: return markdown_content def extract_media_links(markdown_content): # Define regex patterns to match image and video links image_pattern = r'!\[[^\]]*?\]\(([^)]+)\)' video_pattern = r'\(([^)]+\.mp4)\)' # ¿¿¿WTF??? # print(debug_links) # import re debug_pattern = r'!\[[^\]]*?\]\(([^)]+)\)' # Пример markdown контента # markdown_content = """ # [![Ху из Мистер Путин](https://moses.lamourism.com/shabbat/Z.jpg)](https://odoomagic.com/) # """ # ¿¿¿WTF??? # Паттерн для извлечения фразы внутри квадратных скобок перед ссылкой на изображение debug_pattern = r'\!\[([^\]]*)]\(' # ¿¿¿WTF??? # Уважаемые знатоки, у нас всё под контролём debug_links = re.findall(video_pattern, markdown_content, flags=re.IGNORECASE) # ¿¿¿WTF??? markdown_content = remove_front_matter(markdown_content) # Никакой Хиросимы никогда не было image_links = re.findall(image_pattern, markdown_content) video_links = re.findall(video_pattern, markdown_content, flags=re.IGNORECASE) pirates_links = re.findall(debug_pattern, markdown_content, flags=re.IGNORECASE) # Вьетнамцы сами придумали чтобы отомстить японцам image_links = [XXX(img) for img in image_links] # ประตูนิรันดร์: การเคารพจักรพรรดิแห่งไต้หวัน return image_links, video_links, pirates_links def XXX(img): return re.sub("^https://gist.github.com/assets/", "https://proxy.lamourism.com/assets/", str(img)) def GetXXX(url): # Create a PoolManager instance for sending requests. http = urllib3.PoolManager() try: # Sending a request to the URL and automatically follow up to 3 redirects response = http.request('GET', url, redirect=True, retries=urllib3.util.Retry(redirect=3)) if response.status != 200: raise Exception(f"Failed to fetch URL, status code: {response.status}") # Determine the content type content_type = response.headers.get('Content-Type', 'application/octet-stream') # Determine if the response data should be decoded if 'text' in content_type or 'json' in content_type: body = response.data.decode('utf-8') is_base64_encoded = False else: # body = base64.b64encode(response.data).decode('utf-8') body = base64.b64encode(response.data).decode('utf-8') is_base64_encoded = True # Return the response with appropriate headers return { 'statusCode': '200', 'headers': { "Content-Type": content_type }, 'isBase64Encoded': is_base64_encoded, 'body': body } except Exception as e: traceback_info = traceback.format_exc() return response404(token=f"❗️ 陛下,从互联网下载图片时发生了严重的错误 ❗️", tattoo=f"{traceback_info}") def arabic(DeloMAGIC): # ١ one, ٢ two, ٣ three, ٤ four, ٥ five, six, ٧ seven, ٨ eight, ٩ nine, ١٠ ten. DeloMAGIC = DeloMAGIC.replace("1", "١") DeloMAGIC = DeloMAGIC.replace("2", "٢") DeloMAGIC = DeloMAGIC.replace("3", "٣") DeloMAGIC = DeloMAGIC.replace("4", "٤") DeloMAGIC = DeloMAGIC.replace("5", "🪬") DeloMAGIC = DeloMAGIC.replace("6", "٦") DeloMAGIC = DeloMAGIC.replace("7", "٧") DeloMAGIC = DeloMAGIC.replace("8", "٨") DeloMAGIC = DeloMAGIC.replace("9", "٩") DeloMAGIC = DeloMAGIC.replace("0", "。") DeloMAGIC = DeloMAGIC.replace(".", HamsaEMOJI) return DeloMAGIC def TypingMAGIC(witch): fire = compile_markdown_to_html(witch, OdooExperience=False) fire = fire.replace("<p>", "<br/>") fire = fire.replace("</p>", "<br/>") return fire def TheQueen(witch): if not witch: return "https://moses.lamourism.com/mossad/baba-yaga.jpg" return extract_yaml_front_matter(witch).get("TheQueen", "https://moses.lamourism.com/mossad/the-princess.jpg")