Fixed music.db problem of script for PyInstaller
This commit is contained in:
parent
a3d4756f85
commit
0dfca7e316
1 changed files with 10 additions and 1 deletions
|
@ -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")
|
||||||
|
|
Loading…
Reference in a new issue