From 359b1507b8fe89fb39a73552585281213168b2f2 Mon Sep 17 00:00:00 2001 From: Halhadus Date: Sat, 8 Feb 2025 01:15:28 +0300 Subject: [PATCH] Updated website module, ypdated musiccombo binary --- combomodule-pyi.py | 3 +- magiskmodule/system/bin/musiccombo | Bin 6269776 -> 6269824 bytes musicstatus.py | 119 ------------- websitepart.py | 257 ++++++++++++++++++++++------- websitepart.py.old | 85 ++++++++++ 5 files changed, 280 insertions(+), 184 deletions(-) delete mode 100644 musicstatus.py create mode 100644 websitepart.py.old diff --git a/combomodule-pyi.py b/combomodule-pyi.py index c2a5916..32c0710 100644 --- a/combomodule-pyi.py +++ b/combomodule-pyi.py @@ -104,6 +104,7 @@ def get_db_values(url: str = "https://halhadus.rocks/assets/localwrapped/music.d for row in musicrows: musicvalues.append({ "listmusicname": row[0], + "listvideoid": row[1], "fileartistname": row[4], "filealbumname": row[5], "filemusictitle": row[6] @@ -167,7 +168,7 @@ while True: verificationcode = get_verification_code() if verificationcode == None: continue - requests.post(os.environ["MSSERVER"] + "/musicstatus.html", json={"music": i["listmusicname"], "time": str(int(time.time())), "verificationcode": verificationcode, "resetstatus": resetstatus}) + requests.post(os.environ["MSSERVER"] + "/musicstatus.html", json={"music": i["listmusicname"], "time": str(int(time.time())),"videoid":i["listvideoid"], "verificationcode": verificationcode, "resetstatus": resetstatus}) print("Data sent") resetstatus = "false" a += 1 diff --git a/magiskmodule/system/bin/musiccombo b/magiskmodule/system/bin/musiccombo index 53113a3029253fc641af4f478718722f89dfb074..e7c9660cc01e2c844f587ca7d1cc3814055c14a7 100644 GIT binary patch delta 5260 zcmW;McQ}>*AII@yuTYX4t7ApkTlU_{4yj|WB4m6CH<2S-Io&$;E+QF`Jv+!uM#!j; zoxS;e&hNgi$Mw8k@9Vn%xX&MFaP*8gZ0w9UiJvGe{6_T+qTGwnJtI~;E;G%Ol9MV& zfS8tiGCHm0`j=Q*Y4S_aV$5mdTAwfGAXO}N9GykAC~O?>6x(mqjg|)@d|p;pinL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8n^?<0J4A_AP*=2ihvTJ z45$FAfEsWYPzN-Cdw?dO1!x00fG(g1=mQ3TA#fis0*nC@z!We8%mE9)60iau0M@|6 z)=M_jtPh+R3yZZ8nukz4Fc%1xi4umTL&!{&0`}xJgw8}M!m6SAoA5ygH>Z{R5Hbr) zI|!Wx=KU3@{$|QS2RHM_JcP^!(;Y(Jgbu2|Ne^^z6M6`l10oHfZ{i2l-((s($N>-1 zeut2`V9G)0n`l7wx!^Sa6gs$>pCM!(m}W;1`li0Wp!z&;90VQQgdIZWgVT325IP^s zM5z8I8PLH^>L6qR2pxpJ2@0yei7j+c0G{Z%fRL}iWQEW-(Sz!50{+TP%pqhUNGpWC z$sMTvCf3lwO>`k-5r`Iqz6lOge-nG?pa{IZ5{RuBtP;rP|0yg6huzS`O)?-@2}nMK tEJ1O=5m*nWxmzttP&TmE?o!kvI1B-?RimW-^D9AN-TdaD)lwA8{{SU0;}ie@ diff --git a/musicstatus.py b/musicstatus.py deleted file mode 100644 index ebb5515..0000000 --- a/musicstatus.py +++ /dev/null @@ -1,119 +0,0 @@ -import subprocess -import re -import time -import sqlite3 -import os -import requests - -def get_working_directory(): - # If you see this function, that means you are using the pyinstaller. Use this command to create the executable: - # pyinstaller -s -F musicstatus-pyi.py --runtime-tmpdir /data/local/tmp - if os.path.exists("/sdcard/localwrapped"): - return "/sdcard/localwrapped" - elif os.path.exists("/storage/emulated/0/localwrapped"): - return "/storage/emulated/0/localwrapped" - elif os.path.exists("/data/media/0/localwrapped"): - return "/data/media/0/localwrapped" - elif os.path.exists("/mnt/user/0/emulated/0/localwrapped"): - return "/mnt/user/0/emulated/0/localwrapped" - else: - print("Local Wrapped directory not found.") - -if not os.path.exists(f"{get_working_directory()}/key.txt"): - print("Key not exist") - exit() - -if not os.path.exists(f"{get_working_directory()}/music.db"): - try: - getmusicdb = requests.get("https://halhadus.rocks/assets/localwrapped/music.db") - with open(f"{get_working_directory()}/music.db", "wb") as f: - f.write(getmusicdb.content) - except: - print("music.db not exist and download failed.") - -def get_verification_code(): - try: - with open(f'{get_working_directory()/key.txt}') - key = f.read() - try: - verifyrequest = requests.post(os.environ["MSSERVER"] + "/verifykey", json={"key": key}) - if verifyrequest.text == "0": - print("Verification failed") - return None - elif len(verifyrequest.text) == 64: - print("Verification success") - return verifyrequest.text - else: - print("Unexpected response") - return None - except: - print("Can't reach the server.") - time.sleep(15) - get_verification_code() - except: - print("Key not exist") - return None - -def get_music(): - dumpsys_output = subprocess.check_output("dumpsys media_session", shell=True).decode("utf-8").split("\n") - if not [line for line in dumpsys_output if "PLAYING" in line]: - return None - else: - description = [line for line in dumpsys_output if "description=" in line] - try: - return description[0].split("description=")[1] - except: - return None - -def get_db_values(): - musicconn = sqlite3.connect(f"{get_working_directory()}/music.db") - musicc = musicconn.cursor() - musicc.execute("SELECT * FROM music") - musicrows = musicc.fetchall() - musicconn.close() - musicvalues = [] - for row in musicrows: - musicvalues.append({ - "listmusicname": row[0], - "fileartistname": row[4], - "filealbumname": row[5], - "filemusictitle": row[6] - }) - return musicvalues - -a = 0 -last_written = None -resetstatus = "true" -while True: - if get_music() == None: - continue - last_music = get_music() - time.sleep(5) - if last_music == get_music(): - if last_written == last_music: - continue - a += 1 - if a == 1: - for i in get_db_values(): - if i["filealbumname"] == None: - full_name = i["filemusictitle"] + ", " + i["fileartistname"] + ", " + "Music" - else: - full_name = i["filemusictitle"] + ", " + i["fileartistname"] + ", " + i["filealbumname"] - if full_name == last_music: - try: - verificationcode = get_verification_code() - if verificationcode == None: - continue - requests.post(os.environ["MSSERVER"] + "/musicstatus.html", json={"music": i["listmusicname"], "time": str(int(time.time())), "verificationcode": verificationcode, "resetstatus": resetstatus}) - print("Sent") - resetstatus = "false" - except: - print("Can't reach the server.") - time.sleep(15) - last_written = last_music - a = 0 - continue - else: - a = 0 - continue - diff --git a/websitepart.py b/websitepart.py index 914f054..70a1ca7 100644 --- a/websitepart.py +++ b/websitepart.py @@ -3,9 +3,9 @@ import datetime import random import string import os +import re app = flask.Flask(__name__) - code = "" history = [] @@ -14,72 +14,201 @@ def musicstatus(): global code, history if flask.request.method == 'POST': data = flask.request.get_json() - if code == "": - return "Verification code not generated" - if data['verificationcode'] != code: - return "Verification failed" - else: - musicname = data['music'] - time = data['time'] - resetstatus = data['resetstatus'] - history.append((musicname, time, resetstatus)) - return f"{musicname} added to history" - elif flask.request.method == 'GET': - html = '\n\n' - html += '\n\n\n\n' - html += '\n\n' - html += 'Halhadus\' Music Status\n\n' - html += '\n\n' - html += '\n\n' - html += '\n' - html += '

Halhadus\' Music Status

\n' - html += 'Source Code\n' - html += '

Hi guys. I am too lazy to add links to song names. To find which song is it, check this link.

\n' - html += '
\n\n
\n' - if len(history) > 0: - if history[-1][2] == "true": - currentbeforereset = history[-1] - history = [] - history.append(currentbeforereset) - html += f'

Currently Playing: {history[-1][0]}

\n' - html += f'

Last Update Time: {datetime.datetime.fromtimestamp(int(history[-1][1]), datetime.timezone.utc).strftime("%Y-%m-%d %H:%M:%S")} (UTC +0)

\n' - if os.path.exists("lyrics/" + history[-1][0] + ".lrc"): - with open("lyrics/" + history[-1][0] + ".lrc", "r") as f: - lyrics = f.read().split("\n") - lyrics = [lyric.split("]")[1] for lyric in lyrics if "]" in lyric] - lyrics = [lyric for lyric in lyrics if not lyric == ""] - html += '

Lyrics:

\n' - html += '
\n' - for lyric in lyrics: - html += f'

{lyric}

\n' - html += '
\n' - html += '\n\n\n\n\n' - for music in history[::-1]: - html += '\n\n\n\n' - html += '
Music NameTime
' + music[0] + '' + datetime.datetime.fromtimestamp(int(music[1]), datetime.timezone.utc).strftime("%Y-%m-%d %H:%M:%S") + '
\n\n' - return html + if code != data['verificationcode']: + return "Verification failed", 403 + entry = ( + data['music'], + data['time'], + data['resetstatus'], + data['videoid'] + ) + if data['resetstatus'].lower() == "true": + history.clear() + history.append(entry) + return "Entry added successfully" -@app.route('/verifykey', methods=['GET', 'POST']) + elif flask.request.method == 'GET': + current_playing = history[-1] if history else None + + return flask.render_template_string(''' + + + + + + + Halhadus' Music Status + + + +
+

🎵 Music Status

+ ← Main Page + + {% if current_playing %} +
+
+ {{ current_playing[0] }} cover +
+
+

{{ current_playing[0] }}

+

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

+ +
+
+ {% else %} +
+

No music currently playing

+
+ {% endif %} + +

Play History

+ + + + + + + + + + + {% for entry in history|reverse %} + + + + + + + {% endfor %} + +
CoverTitleTimePlay
+ {{ entry[0] }} thumbnail + {{ entry[0] }}{{ format_timestamp(entry[1]) }} + + ▶ + +
+
+ + + ''', current_playing=current_playing, history=history, format_timestamp=format_timestamp) + +def format_timestamp(timestamp): + return datetime.datetime.fromtimestamp( + int(timestamp), + datetime.timezone.utc + ).strftime("%Y-%m-%d %H:%M UTC") + +@app.route('/verifykey', methods=['POST']) def verifycert(): global code - if flask.request.method == 'POST': - data = flask.request.get_json() - key = data['key'] - with open("key.txt", "r") as f: - if key == f.read(): - code = ''.join(random.choices(string.ascii_uppercase + string.digits, k=64)) - return code - else: - return "0" - elif flask.request.method == 'GET': - return "GET method not allowed" - -@app.route('/') -def catch_all(path): - if path == None: - return flask.redirect('https://halhadus.rocks') - if not path == 'musicstatus.html' or not path == 'verifykey': - return flask.redirect(f'https://halhadus.rocks/{path}') + 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" if __name__ == '__main__': app.run(host='0.0.0.0', port=int(os.environ.get('PORT'))) diff --git a/websitepart.py.old b/websitepart.py.old new file mode 100644 index 0000000..914f054 --- /dev/null +++ b/websitepart.py.old @@ -0,0 +1,85 @@ +import flask +import datetime +import random +import string +import os + +app = flask.Flask(__name__) + +code = "" +history = [] + +@app.route('/musicstatus.html', methods=['GET', 'POST']) +def musicstatus(): + global code, history + if flask.request.method == 'POST': + data = flask.request.get_json() + if code == "": + return "Verification code not generated" + if data['verificationcode'] != code: + return "Verification failed" + else: + musicname = data['music'] + time = data['time'] + resetstatus = data['resetstatus'] + history.append((musicname, time, resetstatus)) + return f"{musicname} added to history" + elif flask.request.method == 'GET': + html = '\n\n' + html += '\n\n\n\n' + html += '\n\n' + html += 'Halhadus\' Music Status\n\n' + html += '\n\n' + html += '\n\n' + html += '\n' + html += '

Halhadus\' Music Status

\n' + html += 'Source Code\n' + html += '

Hi guys. I am too lazy to add links to song names. To find which song is it, check this link.

\n' + html += '
\n\n
\n' + if len(history) > 0: + if history[-1][2] == "true": + currentbeforereset = history[-1] + history = [] + history.append(currentbeforereset) + html += f'

Currently Playing: {history[-1][0]}

\n' + html += f'

Last Update Time: {datetime.datetime.fromtimestamp(int(history[-1][1]), datetime.timezone.utc).strftime("%Y-%m-%d %H:%M:%S")} (UTC +0)

\n' + if os.path.exists("lyrics/" + history[-1][0] + ".lrc"): + with open("lyrics/" + history[-1][0] + ".lrc", "r") as f: + lyrics = f.read().split("\n") + lyrics = [lyric.split("]")[1] for lyric in lyrics if "]" in lyric] + lyrics = [lyric for lyric in lyrics if not lyric == ""] + html += '

Lyrics:

\n' + html += '
\n' + for lyric in lyrics: + html += f'

{lyric}

\n' + html += '
\n' + html += '\n\n\n\n\n' + for music in history[::-1]: + html += '\n\n\n\n' + html += '
Music NameTime
' + music[0] + '' + datetime.datetime.fromtimestamp(int(music[1]), datetime.timezone.utc).strftime("%Y-%m-%d %H:%M:%S") + '
\n\n' + return html + +@app.route('/verifykey', methods=['GET', 'POST']) +def verifycert(): + global code + if flask.request.method == 'POST': + data = flask.request.get_json() + key = data['key'] + with open("key.txt", "r") as f: + if key == f.read(): + code = ''.join(random.choices(string.ascii_uppercase + string.digits, k=64)) + return code + else: + return "0" + elif flask.request.method == 'GET': + return "GET method not allowed" + +@app.route('/') +def catch_all(path): + if path == None: + return flask.redirect('https://halhadus.rocks') + if not path == 'musicstatus.html' or not path == 'verifykey': + return flask.redirect(f'https://halhadus.rocks/{path}') + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=int(os.environ.get('PORT')))