package com.yutou.biliapi.api;

import com.alibaba.fastjson2.JSONObject;
import com.yutou.biliapi.bean.live.*;
import com.yutou.common.okhttp.BaseBean;
import com.yutou.common.okhttp.FileBody;
import com.yutou.common.okhttp.HttpBody;
import retrofit2.Call;
import retrofit2.http.*;

import java.util.List;
import java.util.Map;

/**
 * 直播间相关API
 * <a href="https://socialsisteryi.github.io/bilibili-API-collect/docs/live/info.html#%E8%8E%B7%E5%8F%96%E7%9B%B4%E6%92%AD%E9%97%B4%E4%BF%A1%E6%81%AF">文档地址</a>
 */
public interface LiveApi {
    /**
     * 获取直播间信息
     * @param roomId 直播间号	必要	可以为短号
     */
    @GET("/room/v1/Room/get_info")
    Call<HttpBody<LiveRoomInfo>> getRoomInfo(@Query("room_id")String roomId);
    @GET("/room/v1/Room/getRoomInfoOld")
    Call<HttpBody<LiveRoomStatus>> getRoomStatus(@Query("mid")String mid);

    /**
     * 获取主播信息
     */
    @GET("/live_user/v1/Master/info")
    Call<HttpBody<MasterInfoBean>> getMasterInfo(@Query("uid")String uid);

    /**
     * 获取直播间信息
     * @param id 直播间id
     * @param protocol 直播协议 {@link com.yutou.biliapi.enums.LiveProtocol}
     * @param format 格式 {@link com.yutou.biliapi.enums.LiveVideoFormat}
     * @param codec 编码 {@link com.yutou.biliapi.enums.LiveVideoCodec}
     * @param qn 清晰度 {@link com.yutou.biliapi.enums.LiveVideoDefinition}
     * @return
     */
    @GET("/xlive/web-room/v2/index/getRoomPlayInfo")
    Call<HttpBody<LiveRoomPlayInfo>> getLiveRoomPlayInfo(
            @Query("room_id")String id,
            @Query("protocol")String protocol,
            @Query("format")String format,
            @Query("codec")String codec,
            @Query("qn")int qn
    );
    @Streaming
    @GET()
    Call<FileBody<LiveRoomPlayInfo>> downloadLive(@Url String url);

    @GET("/xlive/web-room/v1/index/getDanmuInfo")
    Call<HttpBody<LiveDanmuInfo>> getLiveRoomDanmuInfo(@Query("id")String id);

    @GET("/xlive/web-room/v1/giftPanel/giftConfig?platform=pc")
    Call<HttpBody<BaseBean>> getLiveGiftConfig();

    /**
     * 批量查询直播间状态
     * @param uids 要查询的主播 mid
     * @return <a href="https://socialsisteryi.github.io/bilibili-API-collect/docs/live/info.html#%E6%89%B9%E9%87%8F%E6%9F%A5%E8%AF%A2%E7%9B%B4%E6%92%AD%E9%97%B4%E7%8A%B6%E6%80%81">文档</a>
     */
    @POST("/room/v1/Room/get_status_info_by_uids")
    Call<HttpBody<Map<String,LiveAnchorInfo>>> getLiveRoomStatus(@Body
                                                JSONObject uids);
    @GET("/xlive/web-ucenter/v1/xfetter/GetWebList")
    Call<HttpBody<FollowLive>> getUserFollowLive(
            @Query("hit_ab")boolean hit_ab,
            @Query("_")long time
    );
}
