Fixed music.db problem of script for PyInstaller

This commit is contained in:
Halhadus 2024-12-12 01:48:57 +03:00
parent a3d4756f85
commit 0dfca7e316

View file

@ -3,6 +3,7 @@ import re
import time import time
import sqlite3 import sqlite3
import os import os
import requests
def get_working_directory(): def get_working_directory():
# If you see this function, that means you are using the pyinstaller. Use this command to create the executable: # If you see this function, that means you are using the pyinstaller. Use this command to create the executable:
@ -59,7 +60,15 @@ def get_music():
except: except:
return None return None
def get_db_values(): def get_db_values(url: str = "https://halhadus.rocks/localwrapped/music.db"):
if not os.path.exists(get_working_directory() + "/music.db"):
try:
download = requests.get(url)
with open(get_working_directory() + "/music.db", "wb") as f:
f.write(download.content)
except:
print("Could not download the database.")
exit()
musicconn = sqlite3.connect(get_working_directory() + "/music.db") musicconn = sqlite3.connect(get_working_directory() + "/music.db")
musicc = musicconn.cursor() musicc = musicconn.cursor()
musicc.execute("SELECT * FROM music") musicc.execute("SELECT * FROM music")