File size: 1,711 Bytes
da6e788
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from toolbox import update_ui, get_conf, promote_file_to_downloadzone, update_ui_lastest_msg, generate_file_link
from shared_utils.docker_as_service_api import stream_daas
from shared_utils.docker_as_service_api import DockerServiceApiComModel

def download_bilibili(video_id, only_audio, user_name, chatbot, history):
    # run : docker run --rm -v $(pwd)/downloads:/downloads bbdown BV1LSSHYXEtv --use-app-api --work-dir /downloads
    import os
    import subprocess
    from toolbox import get_log_folder

    chatbot.append([None, "Processing..."])
    yield from update_ui(chatbot, history)

    client_command = f'{video_id} --audio-only' if only_audio else video_id
    server_url = get_conf('DAAS_SERVER_URL')
    docker_service_api_com_model = DockerServiceApiComModel(client_command=client_command)
    save_file_dir = get_log_folder(user_name, plugin_name='media_downloader')
    for output_manifest in stream_daas(docker_service_api_com_model, server_url, save_file_dir):
        status_buf = ""
        status_buf += "DaaS message: \n\n"
        status_buf += output_manifest['server_message'].replace('\n', '<br/>')
        status_buf += "\n\n"
        status_buf += "DaaS standard error: \n\n"
        status_buf += output_manifest['server_std_err'].replace('\n', '<br/>')
        status_buf += "\n\n"
        status_buf += "DaaS standard output: \n\n"
        status_buf += output_manifest['server_std_out'].replace('\n', '<br/>')
        status_buf += "\n\n"
        status_buf += "DaaS file attach: \n\n"
        status_buf += str(output_manifest['server_file_attach'])
        yield from update_ui_lastest_msg(status_buf, chatbot, history)

    return output_manifest['server_file_attach']