import flask import datetime import random import string import os import re app = flask.Flask(__name__) app.config['LYRICS_DIR'] = 'lyrics' code = "" history = [] def is_youtube_id(a): return re.match(r'^[a-zA-Z0-9_-]{11}$', a) is not None @app.route('/musicstatus.html', methods=['GET', 'POST']) def musicstatus(): global code, history if flask.request.method == 'POST': data = flask.request.get_json() if code != data.get('verificationcode'): return "Verification failed", 403 entry = ( data['music'], data['time'], data['resetstatus'], data['videoid'] # Tam URL saklanıyor ) if data.get('resetstatus', '').lower() == "true": history.clear() history.append(entry) return "Entry added successfully" current_playing = history[-1] if history else None lyrics_content = [] if current_playing: lrc_path = os.path.join(app.config['LYRICS_DIR'], f"{current_playing[0]}.lrc") if os.path.exists(lrc_path): with open(lrc_path, 'r') as f: lyrics = [line.split("]")[-1].strip() for line in f if "]" in line] lyrics_content = [line for line in lyrics if line] return flask.render_template_string(''' Halhadus' Music Status

🎵 Halhadus' Music Status

← Main Page Source Code → {% if current_playing %}
{% if is_youtube(current_playing[3]) %} {{ current_playing[0] }} cover {% else %}
No thumbnail available
{% endif %}

{{ current_playing[0] }}

🕒 Last Updated: {{ format_timestamp(current_playing[1]) }}

{% if is_youtube(current_playing[3]) %} ▶ YouTube ▶ YT Music {% else %} ▶ Play Source {% endif %}
{% if lyrics_content %}

Lyrics

{% for line in lyrics_content %}

{{ line }}

{% endfor %}
{% endif %}
{% else %}

No music currently playing

{% endif %}

Play History

{% for entry in history|reverse %} {% endfor %}
Cover Title Time Play
{% if is_youtube(entry[3]) %} {{ entry[0] }} thumbnail {% else %}
N/A
{% endif %}
{{ entry[0] }} {{ format_timestamp(entry[1]) }} {% if is_youtube(entry[3]) %}
''', current_playing=current_playing, history=history, format_timestamp=lambda ts: datetime.datetime.fromtimestamp(int(ts), datetime.timezone.utc).strftime("%Y-%m-%d %H:%M UTC"), is_youtube=is_youtube_id, lyrics_content=lyrics_content) @app.route('/verifykey', methods=['POST']) def verifycert(): global code data = flask.request.get_json() with open("key.txt", "r") as f: if data.get('key') == f.read(): code = ''.join(random.choices(string.ascii_uppercase + string.digits, k=64)) return code return "0" @app.route('/') def catch_all(path): return flask.redirect(f'https://halhadus.rocks/{path}') @app.route('/') def index(): return flask.redirect('https://halhadus.rocks') if __name__ == '__main__': if not os.path.exists(app.config['LYRICS_DIR']): os.makedirs(app.config['LYRICS_DIR'], exist_ok=True) app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 8080)))