Add a soundtrack by picking or dropping a folder (#50)
"Add soundtrack…" in the statistics toolbar, or a folder dropped anywhere on the window, opens a popup that lists the folder's songs and uploads them to the server, which adds the soundtrack at once (Sansan/MusicServer#33). - The name comes from the folder and can be changed; characters the server refuses are replaced. - Only MP3s are uploaded, as the server takes no other; other song files are listed greyed out as left out. Hidden files are skipped. - Disc folders are flattened with the disc's number first ("1-01 Title.mp3"), as the server wants one folder. With one disc folder, names stay as they are. - Songs are sent one at a time with a progress bar, reading one file at a time. A failed song is sent again twice, then the upload is cancelled and the server's reason shown. Closing the popup cancels it too. - Not offered while the server syncs, offline, or without MP3s. - Afterwards search, the inspiration list and the statistics reload. The API types come from the server's spec (Upload, UploadFile, UploadRequest). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f39865fffc
commit
c86dacb890
25 files changed
+3306
-4314
No files matched your search
@@ -43,6 +43,7 @@ var queue_id: String = ""
|
||||
|
||||
var _responses: Dictionary = {}
|
||||
var _successes_left: Dictionary = {}
|
||||
var _failures_left: Dictionary = {}
|
||||
var _held_paths: Dictionary = {}
|
||||
var _previous_transport: HttpTransport
|
||||
var _previous_queue_ids: Dictionary[String, String]
|
||||
@@ -89,6 +90,11 @@ func respond_bytes(path: String, body: PackedByteArray, response_code: int = 200
|
||||
_successes_left.erase(path)
|
||||
|
||||
|
||||
## Answers the next [param failures] requests to [param path] with a 503, then as usual.
|
||||
func fail_first(path: String, failures: int) -> void:
|
||||
_failures_left[path] = failures
|
||||
|
||||
|
||||
## Lets [param successes] more requests to [param path] succeed, then answers 503 until
|
||||
## a new response is registered for the path.
|
||||
func fail_after(path: String, successes: int) -> void:
|
||||
@@ -156,6 +162,10 @@ func _answer(path: String, on_complete: Callable, follow_redirects: bool = true)
|
||||
var headers: PackedStringArray = []
|
||||
if !queue_id.is_empty() && path != "/token":
|
||||
headers.append("X-Queue-Id: " + queue_id)
|
||||
if _failures_left.get(path, 0) > 0:
|
||||
_failures_left[path] -= 1
|
||||
on_complete.call(503, PackedByteArray(), headers)
|
||||
return
|
||||
if _successes_left.has(path):
|
||||
if _successes_left[path] == 0:
|
||||
on_complete.call(503, PackedByteArray(), headers)
|
||||
|
||||
Reference in new issue
Block a user