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_url(url): yt_patterns = [ r'youtube\.com/watch\?v=', r'music\.youtube\.com/watch\?v=', r'youtu\.be/' ] return any(re.search(pattern, url) for pattern in yt_patterns) def extract_yt_id(url): patterns = [ r'v=([a-zA-Z0-9_-]{11})', r'youtu\.be/([a-zA-Z0-9_-]{11})', r'/([a-zA-Z0-9_-]{11})$' ] for pattern in patterns: match = re.search(pattern, url) if match: return match.group(1) return 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'] ) 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('''
🕒 Last Updated: {{ format_timestamp(current_playing[1]) }}
{% if lyrics_content %}{{ line }}
{% endfor %}No music currently playing
Cover | Title | Time | Play |
---|---|---|---|
{% if is_youtube(entry[3]) %}
![]()
N/A
{% endif %}
|
{{ entry[0] }} | {{ format_timestamp(entry[1]) }} | ▶ |