douyuapi

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2020 License: MIT Imports: 2 Imported by: 0

README

斗鱼-api

Build Status Go Report Card codecov

开发者中心

引入方式

go get github.com/birjemin/douyuapi

接口列表

使用方式

  • 示例
httpClient := &utils.HTTPClient{
    Client: &http.Client{
        Timeout: 5 * time.Second,
    },
}

token := &Token{
    BaseClient: BaseClient{
        Client: httpClient,
        Secret: "test-secret",
        AID:    "test-aid",
    },
}

timestamp := cast.ToString(utils.GetCurrTime())
if ret, err := token.Handle(timestamp); err != nil {
    // handle err
} else {
    if ret.Code != 0 {
        // handle err
    }
    // get ret.Data.Token
}

live := &Live{
    BaseClient: BaseClient{
        Client: httpClient,
        Secret: "test-secret",
        AID:    "test-aid",
    },
    Token: "test-token",
}

msg := `{"cid_type":1,"cid":1,"limit":10,"offset":0}`

if ret, err := live.Handle(msg, cast.ToString(timestamp)); err != nil {
    // handle err
} else {
    if ret.Code != 0 {
        // handle err
    }
    // handle
}

备注

后续会补足新接口

Documentation

Index

Constants

View Source
const DouYuDomain = "https://openapi.douyu.com"

DouYuDomain ...

Variables

This section is empty.

Functions

func GetSign

func GetSign(secret, uri string, params map[string]string) string

GetSign ...

Types

type AllLive

type AllLive struct {
	BaseClient
	Token string
}

AllLive ...

func (*AllLive) Handle

func (p *AllLive) Handle(postJSON, timestamp string) (*AllLiveResponse, error)

Handle ...

type AllLiveResponse

type AllLiveResponse struct {
	ErrorResponse
	Data []struct {
		RID      int    `json:"rid"`
		RoomName string `json:"room_name"`
		RoomSrc  string `json:"room_src"`
		Hn       int    `json:"hn"`
		Nickname string `json:"nickname"`
		Avatar   string `json:"avatar"`
		Cid1     int    `json:"cid1"`
		Cname1   string `json:"cname1"`
		Cid2     int    `json:"cid2"`
		Cname2   string `json:"cname2"`
		Cid3     int    `json:"cid3"`
		Cname3   string `json:"cname3"`
	} `json:"data"`
}

AllLiveResponse ...

type BaseClient

type BaseClient struct {
	Client *utils.HTTPClient
	Secret string
	AID    string
}

BaseClient base client

type BatchGetRoomInfo

type BatchGetRoomInfo struct {
	BaseClient
	Token string
}

BatchGetRoomInfo ...

func (*BatchGetRoomInfo) Handle

func (p *BatchGetRoomInfo) Handle(postJSON, timestamp string) (*BatchGetRoomInfoResponse, error)

Handle ...

type BatchGetRoomInfoResponse

type BatchGetRoomInfoResponse struct {
	ErrorResponse
	Data []struct {
		RID        int    `json:"rid"`
		RoomSrc    string `json:"room_src"`
		RoomSrcMax string `json:"room_src_max"`
		RoomName   string `json:"room_name"`
		Hn         int    `json:"hn"`
		Nickname   string `json:"nickname"`
		Avatar     string `json:"avatar"`
		Cid1       int    `json:"cid1"`
		Cname1     string `json:"cname1"`
		Cid2       int    `json:"cid2"`
		Cname2     string `json:"cname2"`
		Cid3       int    `json:"cid3"`
		Cname3     string `json:"cname3"`
		ShowStatus int    `json:"show_status"`
		RoomNotice string `json:"room_notice"`
		IsVertical int    `json:"is_vertical"`
	} `json:"data"`
}

BatchGetRoomInfoResponse ...

type BatchRoomShowStream

type BatchRoomShowStream struct {
	BaseClient
	Token string
}

BatchRoomShowStream ...

func (*BatchRoomShowStream) Handle

func (p *BatchRoomShowStream) Handle(postJSON, timestamp string) (*BatchRoomShowStreamResponse, error)

Handle ...

type BatchRoomShowStreamResponse

type BatchRoomShowStreamResponse struct {
	ErrorResponse
	Data struct {
		RtmpID int    `json:"rtmp_id"`
		RID    int    `json:"rid"`
		Nfv    string `json:"nfv"`
	} `json:"data"`
}

BatchRoomShowStreamResponse ...

type Cid1Info

type Cid1Info struct {
	BaseClient
	Token string
}

Cid1Info ...

func (*Cid1Info) Handle

func (p *Cid1Info) Handle(timestamp string) (*Cid1InfoResponse, error)

Handle ...

type Cid1InfoResponse

type Cid1InfoResponse struct {
	ErrorResponse
	Data []struct {
		CID1   int    `json:"cid1"`
		CName1 string `json:"cname1"`
	} `json:"data"`
}

Cid1InfoResponse ...

type Cid2Info

type Cid2Info struct {
	BaseClient
	Token string
}

Cid2Info ...

func (*Cid2Info) Handle

func (p *Cid2Info) Handle(timestamp string) (*Cid2InfoResponse, error)

Handle ...

type Cid2InfoResponse

type Cid2InfoResponse struct {
	ErrorResponse
	Data []struct {
		CID2   int    `json:"cid2"`
		CName2 string `json:"cname2"`
		PicURL string `json:"pic_url"`
	} `json:"data"`
}

Cid2InfoResponse ...

type Cid3Info

type Cid3Info struct {
	BaseClient
	Token string
}

Cid3Info ...

func (*Cid3Info) Handle

func (p *Cid3Info) Handle(timestamp string) (*Cid3InfoResponse, error)

Handle ...

type Cid3InfoResponse

type Cid3InfoResponse struct {
	ErrorResponse
	Data []struct {
		CID3   int    `json:"cid3"`
		CName3 string `json:"cname3"`
	} `json:"data"`
}

Cid3InfoResponse ...

type ErrorResponse

type ErrorResponse struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

ErrorResponse ...

func (*ErrorResponse) GetErrResponse

func (e *ErrorResponse) GetErrResponse() error

GetErrResponse ...

type GetAudioPlay

type GetAudioPlay struct {
	BaseClient
	Token string
}

GetAudioPlay ...

func (*GetAudioPlay) Handle

func (p *GetAudioPlay) Handle(postJSON, timestamp string) (*GetAudioPlayResponse, error)

Handle ...

type GetAudioPlayResponse

type GetAudioPlayResponse struct {
	ErrorResponse
	Data []struct {
		RID      int    `json:"rid"`
		UID      int    `json:"uid"`
		RtmpCdn  string `json:"rtmpCdn"`
		RtmpLive string `json:"rtmpLive"`
		RtmpURL  string `json:"rtmpURL"`
	} `json:"data"`
}

GetAudioPlayResponse ...

type GetDanMuList

type GetDanMuList struct {
	BaseClient
	Token string
}

GetDanMuList ...

func (*GetDanMuList) Handle

func (p *GetDanMuList) Handle(postJSON, timestamp string) (*GetDanMuListResponse, error)

Handle ...

type GetDanMuListResponse

type GetDanMuListResponse struct {
	ErrorResponse
	Data struct {
		List []struct {
			RoomID    int    `json:"room_id"`
			UID       int    `json:"uid"`
			Nickname  string `json:"nickname"`
			Content   string `json:"content"`
			Timestamp int    `json:"timestamp"`
			IP        string `json:"ip"`
		} `json:"list"`
		Cnt         int `json:"cnt"`
		PageContext int `json:"page_context"`
	} `json:"data"`
}

GetDanMuListResponse ...

type GetPlay

type GetPlay struct {
	BaseClient
	Token string
}

GetPlay ...

func (*GetPlay) Handle

func (p *GetPlay) Handle(postJSON, timestamp string) (*GetPlayResponse, error)

Handle ...

type GetPlayResponse

type GetPlayResponse struct {
	ErrorResponse
	Data struct {
		RID        int         `json:"rid"`
		RoomName   string      `json:"room_name"`
		LiveURL    string      `json:"live_url"`
		HlsURL     string      `json:"hls_url"`
		MixURL     string      `json:"mix_url"`
		RateSwitch int         `json:"rate_switch"`
		ShowStatus int         `json:"show_status"`
		HlsMul     interface{} `json:"hls_mul"`
		FlvMul     interface{} `json:"flv_mul"`
	} `json:"data"`
}

GetPlayResponse ...

type GetRoomInfo

type GetRoomInfo struct {
	BaseClient
	Token string
}

GetRoomInfo ...

func (*GetRoomInfo) Handle

func (p *GetRoomInfo) Handle(postJSON, timestamp string) (*GetRoomInfoResponse, error)

Handle ...

type GetRoomInfoResponse

type GetRoomInfoResponse struct {
	ErrorResponse
	Data struct {
		RID        int    `json:"rid"`
		RoomSrc    string `json:"room_src"`
		RoomSrcMax string `json:"room_src_max"`
		RoomName   string `json:"room_name"`
		Hn         int    `json:"hn"`
		Nickname   string `json:"nickname"`
		Avatar     string `json:"avatar"`
		Cid1       int    `json:"cid1"`
		Cname1     string `json:"cname1"`
		Cid2       int    `json:"cid2"`
		Cname2     string `json:"cname2"`
		Cid3       int    `json:"cid3"`
		Cname3     string `json:"cname3"`
		ShowStatus int    `json:"show_status"`
		ShowTime   int    `json:"show_time"`
		Unuid      string `json:"unuid"`
		RoomNotice string `json:"room_notice"`
		IsVertical int    `json:"is_vertical"`
		Fans       int    `json:"fans"`
	} `json:"data"`
}

GetRoomInfoResponse ...

type IDFAInfo

type IDFAInfo struct {
	BaseClient
	Token string
}

IDFAInfo ...

func (*IDFAInfo) Handle

func (p *IDFAInfo) Handle(idfa, timestamp string) (*IDFAResponse, error)

Handle ...

type IDFAResponse

type IDFAResponse struct {
	ErrorResponse
	Data map[string]int `json:"data"`
}

IDFAResponse ...

type Live

type Live struct {
	BaseClient
	Token string
}

Live ...

func (*Live) Handle

func (p *Live) Handle(postJSON, timestamp string) (*LiveResponse, error)

Handle ...

type LiveResponse

type LiveResponse struct {
	ErrorResponse
	Data []struct {
		RID      int    `json:"rid"`
		RoomName string `json:"room_name"`
		RoomSrc  string `json:"room_src"`
		Hn       int    `json:"hn"`
		Nickname string `json:"nickname"`
		Avatar   string `json:"avatar"`
		Cid1     int    `json:"cid1"`
		Cname1   string `json:"cname1"`
		Cid2     int    `json:"cid2"`
		Cname2   string `json:"cname2"`
		Cid3     int    `json:"cid3"`
		Cname3   string `json:"cname3"`
	} `json:"data"`
}

LiveResponse ...

type OuterChat

type OuterChat struct {
	BaseClient
	Token string
}

OuterChat ...

func (*OuterChat) Handle

func (p *OuterChat) Handle(chat, timestamp string) (*OuterChatResponse, error)

Handle ...

type OuterChatResponse

type OuterChatResponse struct {
	ErrorResponse
	Data string `json:"data"`
}

OuterChatResponse ...

type RecompoolVodList

type RecompoolVodList struct {
	BaseClient
	Token string
}

RecompoolVodList ...

func (*RecompoolVodList) Handle

func (p *RecompoolVodList) Handle(postJSON, timestamp string) (*RecompoolVodListResponse, error)

Handle ...

type RecompoolVodListResponse

type RecompoolVodListResponse struct {
	ErrorResponse
	Data []struct {
		HashID             string `json:"hash_id"`
		Cid1               int    `json:"cid1"`
		Cid2               int    `json:"cid2"`
		UpID               string `json:"up_id"`
		Nickname           string `json:"nickname"`
		IsVertical         int    `json:"is_vertical"`
		VideoTitle         string `json:"video_title"`
		VideoCover         string `json:"video_cover"`
		VideoVerticalCover string `json:"video_vertical_cover"`
		VideoDuration      int    `json:"video_duration"`
		ViewNum            int    `json:"view_num"`
		UTime              int    `json:"utime"`
		OwnerAvatar        string `json:"owner_avatar"`
		VideoCollectNum    int    `json:"video_collect_num"`
		VideoUpNum         int    `json:"video_up_num"`
		BarrageNum         int    `json:"barrage_num"`
		VideoURL           string `json:"video_url"`
		H5VideoURL         string `json:"h5_video_url"`
		ShareURL           string `json:"share_url"`
	} `json:"data"`
}

RecompoolVodListResponse ...

type SmartCateList

type SmartCateList struct {
	BaseClient
	Token string
}

SmartCateList ...

func (*SmartCateList) Handle

func (p *SmartCateList) Handle(postJSON, timestamp string) (*SmartCateListResponse, error)

Handle ...

type SmartCateListResponse

type SmartCateListResponse struct {
	ErrorResponse
	Data []struct {
		Tag1ID    int    `json:"tag1_id"`
		Tag1Name  string `json:"tag1_name"`
		Tag1Icon  string `json:"tag1_icon"`
		Tag2ID    int    `json:"tag2_id"`
		Tag2Name  string `json:"tag2_name"`
		Tag2Icon  string `json:"tag2_icon"`
		RoomCount int    `json:"room_count"`
	} `json:"data"`
}

SmartCateListResponse ...

type SmartCateRoomList

type SmartCateRoomList struct {
	BaseClient
	Token string
}

SmartCateRoomList ...

func (*SmartCateRoomList) Handle

func (p *SmartCateRoomList) Handle(postJSON, timestamp string) (*SmartCateRoomListResponse, error)

Handle ...

type SmartCateRoomListResponse

type SmartCateRoomListResponse struct {
	ErrorResponse
	Data []struct {
		RID        int    `json:"rid"`
		RoomSrc    string `json:"room_src"`
		RoomSrcMax string `json:"room_src_max"`
		RoomName   string `json:"room_name"`
		Hn         int    `json:"hn"`
		Nickname   string `json:"nickname"`
		Avatar     string `json:"avatar"`
		Cid1       int    `json:"cid1"`
		Cname1     string `json:"cname1"`
		Cid2       int    `json:"cid2"`
		Cname2     string `json:"cname2"`
		Cid3       int    `json:"cid3"`
		Cname3     string `json:"cname3"`
		RoomNotice string `json:"room_notice"`
		IsVertical int    `json:"is_vertical"`
		ShowStatus int    `json:"show_status"`
		Tag2ID     int    `json:"tag2_id"`
		Tag2Name   string `json:"tag2_name"`
		Tag2Icon   string `json:"tag2_icon"`
		Count      int    `json:"count"`
	} `json:"data"`
}

SmartCateRoomListResponse ...

type ThirdVodStreamList

type ThirdVodStreamList struct {
	BaseClient
	Token string
}

ThirdVodStreamList ...

func (*ThirdVodStreamList) Handle

func (p *ThirdVodStreamList) Handle(postJSON, timestamp string) (*ThirdVodStreamListResponse, error)

Handle ...

type ThirdVodStreamListResponse

type ThirdVodStreamListResponse struct {
	ErrorResponse
	Data struct {
		Timestamp int    `json:"timestamp"`
		Normal    string `json:"normal"`
		High      string `json:"high"`
	} `json:"data"`
}

ThirdVodStreamListResponse ...

type Token

type Token struct {
	BaseClient
}

Token ...

func (*Token) Handle

func (t *Token) Handle(timestamp string) (*TokenResponse, error)

Handle ...

type TokenResponse

type TokenResponse struct {
	ErrorResponse
	Data struct {
		Token  string `json:"token"`
		Expire int    `json:"expire"`
	} `json:"data"`
}

TokenResponse ...

type VideoCateList

type VideoCateList struct {
	BaseClient
	Token string
}

VideoCateList ...

func (*VideoCateList) Handle

func (p *VideoCateList) Handle(timestamp string) (*VideoCateListResponse, error)

Handle ...

type VideoCateListResponse

type VideoCateListResponse struct {
	ErrorResponse
	Data []struct {
		Cid2   int    `json:"cid2"`
		Cname2 string `json:"cname2"`
	} `json:"data"`
}

VideoCateListResponse ...

type VideoCateVodList

type VideoCateVodList struct {
	BaseClient
	Token string
}

VideoCateVodList ...

func (*VideoCateVodList) Handle

func (p *VideoCateVodList) Handle(postJSON, timestamp string) (*VideoCateVodListResponse, error)

Handle ...

type VideoCateVodListResponse

type VideoCateVodListResponse struct {
	ErrorResponse
	Data []struct {
		HashID             string `json:"hash_id"`
		Cid1               int    `json:"cid1"`
		Cid2               int    `json:"cid2"`
		UpID               string `json:"up_id"`
		Nickname           string `json:"nickname"`
		IsVertical         int    `json:"is_vertical"`
		VideoTitle         string `json:"video_title"`
		VideoCover         string `json:"video_cover"`
		VideoVerticalCover string `json:"video_vertical_cover"`
		VideoDuration      int    `json:"video_duration"`
		ViewNum            int    `json:"view_num"`
		UTime              int    `json:"utime"`
		OwnerAvatar        string `json:"owner_avatar"`
		VideoCollectNum    int    `json:"video_collect_num"`
		VideoUpNum         int    `json:"video_up_num"`
		BarrageNum         int    `json:"barrage_num"`
		VideoURL           string `json:"video_url"`
		H5VideoURL         string `json:"h5_video_url"`
		ShareURL           string `json:"share_url"`
	} `json:"data"`
}

VideoCateVodListResponse ...

type VideoUperVodList

type VideoUperVodList struct {
	BaseClient
	Token string
}

VideoUperVodList ...

func (*VideoUperVodList) Handle

func (p *VideoUperVodList) Handle(postJSON, timestamp string) (*VideoUperVodListResponse, error)

Handle ...

type VideoUperVodListResponse

type VideoUperVodListResponse struct {
	ErrorResponse
	Data []struct {
		HashID             string `json:"hash_id"`
		Cid1               int    `json:"cid1"`
		Cid2               int    `json:"cid2"`
		UpID               string `json:"up_id"`
		Nickname           string `json:"nickname"`
		IsVertical         int    `json:"is_vertical"`
		VideoTitle         string `json:"video_title"`
		VideoCover         string `json:"video_cover"`
		VideoVerticalCover string `json:"video_vertical_cover"`
		VideoDuration      int    `json:"video_duration"`
		ViewNum            int    `json:"view_num"`
		UTime              int    `json:"utime"`
		OwnerAvatar        string `json:"owner_avatar"`
		VideoCollectNum    int    `json:"video_collect_num"`
		VideoUpNum         int    `json:"video_up_num"`
		BarrageNum         int    `json:"barrage_num"`
		VideoURL           string `json:"video_url"`
		H5VideoURL         string `json:"h5_video_url"`
		ShareURL           string `json:"share_url"`
	} `json:"data"`
}

VideoUperVodListResponse ...

type VodDownURL

type VodDownURL struct {
	BaseClient
	Token string
}

VodDownURL ...

func (*VodDownURL) Handle

func (p *VodDownURL) Handle(postJSON, timestamp string) (*VodDownURLResponse, error)

Handle ...

type VodDownURLResponse

type VodDownURLResponse struct {
	ErrorResponse
	Data struct {
		URL string `json:"url"`
	} `json:"data"`
}

VodDownURLResponse ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL