mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
Even more logging in spotify download
Fix #1 Test fix 2 Fixing part 2 Fixing ctnd Final fix Fixing spotipy get bug Same plusy kurwa Fixing fucking spotipy test More logging
This commit is contained in:
@@ -41,41 +41,6 @@ if platform in ("linux", "linux2"):
|
||||
music_file_list = []
|
||||
priority_list = []
|
||||
|
||||
|
||||
def create_playlist():
|
||||
"""
|
||||
Reads a JSON file containing a playlist and writes the playlist items to a text file.
|
||||
|
||||
The JSON file path is '/home/pi/Conjurer/playlist.json',
|
||||
and the text file path is '/home/pi/Conjurer/all_playlist.playlist'.
|
||||
|
||||
Raises:
|
||||
JSONDecodeError: If the JSON file cannot be decoded.
|
||||
|
||||
"""
|
||||
with open("/home/pi/Conjurer/playlist.json", "r+", encoding="utf-8") as r_file:
|
||||
with open(
|
||||
"/home/pi/Conjurer/all_playlist.playlist", "w", encoding="utf-8"
|
||||
) as w_file:
|
||||
try:
|
||||
playlist = json.load(r_file)
|
||||
for item in playlist:
|
||||
w_file.write(item)
|
||||
w_file.write("\n")
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
|
||||
with open("/home/pi/Conjurer/prio_playlist.json", "r+", encoding="utf-8") as r_file:
|
||||
with open("/home/pi/Conjurer/hit.playlist", "w", encoding="utf-8") as w_file:
|
||||
try:
|
||||
playlist = json.load(r_file)
|
||||
for item in playlist:
|
||||
w_file.write(item)
|
||||
w_file.write("\n")
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
|
||||
|
||||
def rescan():
|
||||
"""
|
||||
The `rescan` function logs a message, scans for mp3 files in a specified folder,
|
||||
@@ -95,18 +60,22 @@ def rescan():
|
||||
temp_music_file = temp_music_file.replace("/", "\\")
|
||||
priority_list.append(temp_music_file)
|
||||
|
||||
with open("/home/pi/Conjurer/playlist.json", "r+", encoding="utf-8") as s_file:
|
||||
database = music_file_list
|
||||
# self.app.logger.info("DUMPING DATA")
|
||||
s_file.truncate(0)
|
||||
s_file.seek(0)
|
||||
json.dump(database, s_file)
|
||||
with open("/home/pi/Conjurer/prio_playlist.json", "r+", encoding="utf-8") as s_file:
|
||||
# self.app.logger.info("DUMPING DATA")
|
||||
s_file.truncate(0)
|
||||
s_file.seek(0)
|
||||
json.dump(priority_list, s_file)
|
||||
create_playlist()
|
||||
with open(
|
||||
"/home/pi/Conjurer/all_playlist.playlist", "w", encoding="utf-8"
|
||||
) as w_file:
|
||||
try:
|
||||
for item in music_file_list:
|
||||
w_file.write(item)
|
||||
w_file.write("\n")
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
with open("/home/pi/Conjurer/hit.playlist", "w", encoding="utf-8") as w_file:
|
||||
try:
|
||||
for item in priority_list:
|
||||
w_file.write(item)
|
||||
w_file.write("\n")
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
|
||||
|
||||
def thread_rescan():
|
||||
@@ -313,10 +282,10 @@ def clear_pr_pls():
|
||||
|
||||
:return: A JSON response indicating the success of the operation.
|
||||
"""
|
||||
with open(
|
||||
"/home/pi/Conjurer/priority_queue.playlist", "w", encoding="utf-8"
|
||||
) as s_file:
|
||||
s_file.truncate(0)
|
||||
app.logger.info("CLEARING PLAYLIST")
|
||||
with open('/home/pi/Conjurer/priority_queue.playlist', 'w', encoding='utf-8') as cleared_pl:
|
||||
cleared_pl.write('')
|
||||
|
||||
return_data = jsonify(isError=False, message="Success", statusCode=200, data=[])
|
||||
return return_data, 200
|
||||
|
||||
|
||||
Reference in New Issue
Block a user