OmniSaleGmbH / lalalai

109 stars 10 forks source link

[Bug] Python example does not match with API docs #2

Open jingfelix opened 10 months ago

jingfelix commented 10 months ago

In lalalai API doc, the json returned by POST /api/check apperently has no task arguments, which diifers from the Python example

Doc:

Returns (json):
    {
        "status": "success" | "error"
        "result": {
            "file_id_1": {
                "status": "success" | "error"
                "name": the file name if the status is "success"
                "size": the file size in bytes if the status is "success"
                "duration": estimated file duration in seconds if the status is "success"
                "splitter": "phoenix" | "orion"
                "stem": stem option if the status is "success".
                        one of ("vocals", "drum", "bass", "piano", "electric_guitar", "acoustic_guitar", "synthesizer").
                        "vocals" by default.

                "preview" (nullable): {
                    "duration": actual duration in seconds for preview
                    "stem": stem option for preview,
                    "stem_track": a url of preview stem,
                    "stem_track_size" (int): stem file size in bytes,
                    "back_track": a url of preview back track,
                    "back_track_size" (int): back track file size in bytes,
                }: if the status is "success" and the preview task has successfully completed

                "split" (nullable): {
                    "duration": actual duration in seconds for split
                    "stem": stem option for split,
                    "stem_track": a url of stem,
                    "stem_track_size" (int): stem file size in bytes,
                    "back_track": a url of back track,
                    "back_track_size" (int): back track file size in bytes
                } if the status is "success" and the split task with PAID license has successfully completed

                "player" (nullable): {
                    "stem_track": a url of preview stem,
                    "stem_track_size" (int): stem file size in bytes,
                    "back_track": a url of preview back track,
                    "back_track_size" (int): back track file size in bytes
                }: if the status is "success" and the split task with FREE license has successfully completed

                "task" (nullable): {
                    "state": "success" | "error" | "progress" | "cancelled",
                    "error" (nullable): Error description if the state is "error",
                    "progress" (int, nullable): a task progress (0..100) if the state is "progress",
                } if the status is "success" and some task has been invoked

                "error": Error description if the status is "error"
            },
            "file_id_2": {
                ...
            },
            "archive" (nullable): {
                "status": "waiting" | "success" | "error"
                "url": url to download the archive
                "size": archive file size
                "error": if the status is "error"
            } if user uses website
        }
    }

Example code:

def check_file(file_id):
    url_for_check = URL_API + "check/?"
    query_args = {'id': file_id}
    encoded_args = urlencode(query_args)

    is_queueup = False

    while True:
        with urlopen(url_for_check + encoded_args) as response:
            check_result = json.load(response)

        if check_result["status"] == "error":
            raise RuntimeError(check_result["error"])

        task_state = check_result["task"]["state"]
jingfelix commented 10 months ago

Well, I do follow the instructions in docs, but it seems that both split and player is empty.

{
    'status': 'success',
    'name': 'test_.mp3',
    'size': 54720,
    'duration': 1,
    'stem': 'vocals',
    'splitter': 'phoenix',
    'preview': None,
    'split': None,
    'player': None,
    'task': {
        'id': [
            '662a6238-e373-4da2-b1d8-782bdaf00905',
            '8ea056c1-7e55-4d24-bfec-c907c4fa98d7',
            '99b90b6a-7fe9-402c-aa7a-e23325625b7b',
            '688f00c0-787c-4f7f-98b7-f9102f324b39'
        ],
        'state': 'success',
        'progress': 0,
        'split_id': '99b90b6a-7fe9-402c-aa7a-e23325625b7b'
    }
}