import path_setting
from in_common.base_request import BaseRequest


class living_request(BaseRequest):
    def __init__(self):
        self.data = self.api_load(path_setting.LIVEYAML_CONFIG)
        self.data = self.api_load(path_setting.LIVESERVICES_CONFIG)
#获取弹幕
    def danmu_v2(self,channel_id,msg_id,user_id=""):
        self.params["channel_id"] = channel_id
        self.params["msg_id"] = msg_id
        self.params["user_id"] = user_id
        return self.api_send(self.data["danmu_v2"])
#主播开播
    def pushlive_info(self,title,cover_url,notice,tag_id,clarity,device_type):
        self.params["title"] = title
        self.params["cover_url"] = cover_url
        self.params["notice"] = notice
        self.params["tag_id"] = tag_id
        self.params["clarity"] = clarity
        self.params["device_type"] = device_type
        return self.api_send(self.data["pushlive_info"])

    #主播-推荐袋美购列表展示
    def live_services(self, channel_id, stream_id, offset, size):
        self.params["channel_id"] = channel_id
        self.params["stream_id"] = stream_id
        self.params["offset"] = offset
        self.params["size"] = size
        return self.api_send(self.data["live_services"])

    #主播-推荐袋商品捜索功能
    def search_services(self, current_city_id, channel_id, query,  offset, size, trace_id, device_id='97B6764B-2135-4761-9911-701C38CBC272'):
        self.params["current_city_id"] = current_city_id
        self.params["channel_id"] = channel_id
        self.params["query"] = query
        self.params["offset"] = offset
        self.params["size"] = size
        self.params["trace_id"] = trace_id
        return self.api_send(self.data["search_services"])


if __name__ == '__main__':
    (living_request().danmu_v2("739", "1"))
    (living_request().pushlive_info("小冤家", "2021/04/22/1003/cef471cff5e6", "", "1", "1", "1"))
    print(living_request().live_services("745", "4177", "0", "10"))
    print(living_request().search_services("beijing", "745", "", "0", "20", "2021/06/28/1750/9fc690d5e66f"))