# import sys
# sys.path.extend(["..", "../util"])
# from util.AliyunSdk import AliyunVodSdk
# from concurrency.CommonThread import Common
from kafka import KafkaProducer
import json
import threading

topicName = 'dsp-alg-online-tasks'
# eBody = {
#     "request_id": "d4c909912ac741ce81ccef03fd1b2ec45",
#     "models": [
#     {
#         "code": "001",
#         "categories": [{
#             "id": "0",
#             "config": {}
#         },
#         {
#             "id": "1",
#             "config": {}
#         },
#         {
#             "id": "2",
#             "config": {}
#         },
#         {
#             "id": "3",
#             "config": {}
#         },
#         {
#             "id": "4",
#             "config": {}
#         },
#         {
#             "id": "5",
#             "config": {}
#         }
#         ]
#     }],
#     "command": "start",
#     "pull_url": "rtmp://live.play.t-aaron.com/live/THSAr",
#     "push_url": "rtmp://live.push.t-aaron.com/live/THSAs",
#     "results_base_dir": "P20220802133841159"
# }
# producer = KafkaProducer(bootstrap_servers=['192.168.11.242:9092'],
#                          value_serializer=lambda m: json.dumps(m).encode('utf-8'))
# future = producer.send(topicName, key=b'd4c909912ac741ce81ccef03fd1b2ec45', value=eBody)
# result = future.get(timeout=10)
# print(result)

# topicName = 'dsp-alg-image-tasks'
eBody = {
    "request_id": "d4c909912ac741ce81ccef03fd1b2ec46",
    "models": [
        {
            "code": "001",
            "categories": [
                {
                "id": "0",
                "config": {}
                },
                {
                    "id": "1",
                    "config": {}
                },
                {
                    "id": "2",
                    "config": {}
                },
                {
                    "id": "3",
                    "config": {}
                },
                {
                    "id": "4",
                    "config": {}
                },
                {
                    "id": "5",
                    "config": {}
                },
                {
                    "id": "6",
                    "config": {}
                },
                {
                    "id": "7",
                    "config": {}
                }
            ]
        }],
    "command": "start",
    "image_urls": ["https://ta-tech-image.oss-cn-shanghai.aliyuncs.com/imagedir/cmn5kvdl23l_1669862645395.bmp"],
    "results_base_dir": "P20220802133841159"
}
# topicName = 'dsp-alg-offline-tasks'
# eBody = {
#     "request_id": "d4c909912ac741ce81ccef03fd1b2ec46",
#     "models": [
#         {
#             "code": "001",
#             "categories": [
#                 {
#                     "id": "0",
#                     "config": {}
#                 },
#                 {
#                     "id": "1",
#                     "config": {}
#                 },
#                 {
#                     "id": "2",
#                     "config": {}
#                 },
#                 {
#                     "id": "3",
#                     "config": {}
#                 },
#                 {
#                     "id": "4",
#                     "config": {}
#                 },
#                 {
#                     "id": "5",
#                     "config": {}
#                 },
#                 {
#                     "id": "6",
#                     "config": {}
#                 },
#                 {
#                     "id": "7",
#                     "config": {}
#                 }
#             ]
#         }],
#     "command": "start",
#     "original_url": "https://vod.play.t-aaron.com/0bc905ef5651439da2bfba8427fe467e/a76a7ebb6e3b44ef9c0c7820c7e9c574-f2d7ee90cba11aa91971d58e06d295d2-4k.mp4",
#     "original_type": ".mp4",
#     "push_url": "rtmp://live.push.t-aaron.com/live/THSAr",
#     "results_base_dir": "P20220802133841159"
# }
producer = KafkaProducer(bootstrap_servers=['101.132.127.1:19094','101.132.127.1:29094','101.132.127.1:39094'],
                         value_serializer=lambda m: json.dumps(m).encode('utf-8'))
future = producer.send(topicName, key=b'd4c909912ac741ce81ccef03fd1b2ec46', value=eBody)
result = future.get(timeout=10)
# print(result)