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
@@ -0,0 +1,38 @@
|
||||
# Generated by tools/generate_api_types.gd from server/openapi.json.
|
||||
# Do not edit; change the server and generate again.
|
||||
class_name Upload
|
||||
extends RefCounted
|
||||
## The [code]Upload[/code] schema of the MusicServer API.
|
||||
|
||||
## The songs received so far, sorted by name
|
||||
var files: Array[UploadFile]
|
||||
var id: String
|
||||
## Name of the new soundtrack, also its folder name
|
||||
var name: String
|
||||
var started: String
|
||||
## Size of all songs received so far, in bytes
|
||||
var total_size: int
|
||||
|
||||
|
||||
## Reads the fields from parsed JSON. Missing fields keep their defaults.
|
||||
static func from_dict(data: Dictionary) -> Upload:
|
||||
var result: Upload = Upload.new()
|
||||
for item: Variant in ApiJson.get_array(data, "files"):
|
||||
if item is Dictionary:
|
||||
result.files.append(UploadFile.from_dict(item))
|
||||
result.id = ApiJson.get_string(data, "id", "")
|
||||
result.name = ApiJson.get_string(data, "name", "")
|
||||
result.started = ApiJson.get_string(data, "started", "")
|
||||
result.total_size = ApiJson.get_int(data, "total_size", 0)
|
||||
return result
|
||||
|
||||
|
||||
## Returns the fields under their JSON names, ready for [method JSON.stringify].
|
||||
func to_dict() -> Dictionary:
|
||||
return {
|
||||
"files": files.map(func(item: UploadFile) -> Dictionary: return item.to_dict()),
|
||||
"id": id,
|
||||
"name": name,
|
||||
"started": started,
|
||||
"total_size": total_size,
|
||||
}
|
||||
Reference in new issue
Block a user