TRip: capitalize RQ job statuses in related endpoints, order job list, other: minor/typing
This commit is contained in:
@@ -101,7 +101,7 @@ def bulk_download(track_list: list, quality: str = "FLAC"):
|
||||
job.meta["tracks"] = [] # will hold per-track dicts
|
||||
job.meta["progress"] = 0
|
||||
job.meta["tarball"] = None
|
||||
job.meta["status"] = "started"
|
||||
job.meta["status"] = "Started"
|
||||
job.save_meta()
|
||||
except Exception as e:
|
||||
logging.warning("Failed to init job.meta: %s", e)
|
||||
@@ -123,7 +123,7 @@ def bulk_download(track_list: list, quality: str = "FLAC"):
|
||||
for i, track_id in enumerate(track_list or []):
|
||||
track_info = {
|
||||
"track_id": str(track_id),
|
||||
"status": "pending", # pending | success | failed
|
||||
"status": "Pending", # Pending | Success | Failed
|
||||
"file_path": None, # str | None
|
||||
"error": None, # str | None
|
||||
"attempts": 0, # int
|
||||
@@ -177,7 +177,7 @@ def bulk_download(track_list: list, quality: str = "FLAC"):
|
||||
tmp_file = None # consumed
|
||||
|
||||
# Track success
|
||||
track_info["status"] = "success"
|
||||
track_info["status"] = "Success"
|
||||
track_info["file_path"] = str(final_file)
|
||||
track_info["error"] = None
|
||||
all_final_files.append(final_file)
|
||||
@@ -193,7 +193,7 @@ def bulk_download(track_list: list, quality: str = "FLAC"):
|
||||
)
|
||||
track_info["error"] = str(e)
|
||||
if attempt >= MAX_RETRIES:
|
||||
track_info["status"] = "failed"
|
||||
track_info["status"] = "Failed"
|
||||
# small backoff before next attempt (or next track)
|
||||
await asyncio.sleep(random.uniform(THROTTLE_MIN, THROTTLE_MAX))
|
||||
finally:
|
||||
@@ -223,7 +223,7 @@ def bulk_download(track_list: list, quality: str = "FLAC"):
|
||||
if job:
|
||||
try:
|
||||
job.meta["tarball"] = None
|
||||
job.meta["status"] = "failed"
|
||||
job.meta["status"] = "Failed"
|
||||
job.save_meta()
|
||||
except Exception:
|
||||
pass
|
||||
@@ -232,7 +232,7 @@ def bulk_download(track_list: list, quality: str = "FLAC"):
|
||||
# Pick artist with the most tracks
|
||||
artist_counts: dict[str, int] = {}
|
||||
for t in per_track_meta:
|
||||
if t["status"] == "success" and t.get("file_path"):
|
||||
if t["status"] == "Success" and t.get("file_path"):
|
||||
try:
|
||||
artist = Path(t["file_path"]).relative_to(ROOT_DIR).parts[0]
|
||||
except Exception:
|
||||
@@ -256,7 +256,7 @@ def bulk_download(track_list: list, quality: str = "FLAC"):
|
||||
|
||||
if job:
|
||||
try:
|
||||
job.meta["status"] = "compressing"
|
||||
job.meta["status"] = "Compressing"
|
||||
job.save_meta()
|
||||
except Exception:
|
||||
pass
|
||||
@@ -303,7 +303,7 @@ def bulk_download(track_list: list, quality: str = "FLAC"):
|
||||
if job:
|
||||
job.meta["tarball"] = str(final_tarball)
|
||||
job.meta["progress"] = 100
|
||||
job.meta["status"] = "completed"
|
||||
job.meta["status"] = "Completed"
|
||||
job.save_meta()
|
||||
|
||||
return [str(final_tarball)]
|
||||
@@ -315,7 +315,7 @@ def bulk_download(track_list: list, quality: str = "FLAC"):
|
||||
return loop.run_until_complete(process_tracks())
|
||||
except Exception as e:
|
||||
if job:
|
||||
job.meta["status"] = "failed"
|
||||
job.meta["status"] = "Failed"
|
||||
job.save_meta()
|
||||
logging.critical("Exception: %s", str(e))
|
||||
finally:
|
||||
|
Reference in New Issue
Block a user