now it remembers the queue

This commit is contained in:
cool.gitter.choco
2025-02-03 12:15:37 -06:00
parent 2eaf4d3105
commit c77006a3e0
7 changed files with 273 additions and 93 deletions

View File

@@ -19,7 +19,7 @@ download_processes = {}
def generate_random_filename(length=6):
chars = string.ascii_lowercase + string.digits
return ''.join(random.choice(chars) for _ in range(length)) + '.prg'
return ''.join(random.choice(chars) for _ in range(length)) + '.artist.prg'
class FlushingFileWrapper:
def __init__(self, file):
@@ -28,7 +28,16 @@ class FlushingFileWrapper:
def write(self, text):
# Only write lines that start with '{'
for line in text.split('\n'):
if line.startswith('{'):
line = line.strip()
if line and line.startswith('{'):
try:
obj = json.loads(line)
# Skip writing if the JSON object has type "track"
if obj.get("type") == "track":
continue
except ValueError:
# If not valid JSON, write the line as is.
pass
self.file.write(line + '\n')
self.file.flush()