diff --git a/extractor/twitch/Streamer.go b/extractor/twitch/Streamer.go index 8f5d2e2..4f9dcd2 100644 --- a/extractor/twitch/Streamer.go +++ b/extractor/twitch/Streamer.go @@ -167,3 +167,101 @@ func GetStreamerId(channelName string) (string, error) { return "", errors.New("could not find user") } } + +func GetBulkStreamerInfo(streamers []string) string { + var payload []TwitchPayload + for _, streamer := range streamers { + tmp := []TwitchPayload{ + // Streamer data + { + "operationName": "ChannelRoot_AboutPanel", + "variables": map[string]interface{}{ + "channelLogin": streamer, + "skipSchedule": false, + }, + "extensions": map[string]interface{}{ + "persistedQuery": map[string]interface{}{ + "version": 1, + "sha256Hash": "6089531acef6c09ece01b440c41978f4c8dc60cb4fa0124c9a9d3f896709b6c6", + }, + }, + }, + + // Stream metadata + { + "operationName": "StreamMetadata", + "variables": map[string]interface{}{ + "channelLogin": streamer, + }, + "extensions": map[string]interface{}{ + "persistedQuery": map[string]interface{}{ + "version": 1, + "sha256Hash": "a647c2a13599e5991e175155f798ca7f1ecddde73f7f341f39009c14dbf59962", + }, + }, + }, + + // Stream tags + { + "operationName": "StreamTagsTrackingChannel", + "variables": map[string]interface{}{ + "channel": streamer, + }, + "extensions": map[string]interface{}{ + "persistedQuery": map[string]interface{}{ + "version": 1, + "sha256Hash": "6aa3851aaaf88c320d514eb173563d430b28ed70fdaaf7eeef6ed4b812f48608", + }, + }, + }, + + // Stream preview image + { + "operationName": "VideoPreviewOverlay", + "variables": map[string]interface{}{ + "login": streamer, + }, + "extensions": map[string]interface{}{ + "persistedQuery": map[string]interface{}{ + "version": 1, + "sha256Hash": "9515480dee68a77e667cb19de634739d33f243572b007e98e67184b1a5d8369f", + }, + }, + }, + + // Current views + { + "operationName": "UseViewCount", + "variables": map[string]interface{}{ + "channelLogin": streamer, + }, + "extensions": map[string]interface{}{ + "persistedQuery": map[string]interface{}{ + "version": 1, + "sha256Hash": "00b11c9c428f79ae228f30080a06ffd8226a1f068d6f52fbc057cbde66e994c2", + }, + }, + }, + + // Get offline banner image + { + "operationName": "ChannelShell", + "variables": map[string]interface{}{ + "login": streamer, + }, + "extensions": map[string]interface{}{ + "persistedQuery": map[string]interface{}{ + "version": 1, + "sha256Hash": "580ab410bcd0c1ad194224957ae2241e5d252b2c5173d8e0cce9d32d5bb14efe", + }, + }, + }, + } + + payload = append(payload, tmp...) + } + + _, body, _ := parseResponse(payload) + + return string(body) +} diff --git a/routes/api/users/users.go b/routes/api/users/users.go index 9ff7857..165f3d1 100644 --- a/routes/api/users/users.go +++ b/routes/api/users/users.go @@ -27,4 +27,19 @@ func Routes(route *gin.Engine) { context.JSON(200, extractor.FormatMessage(data, true)) }) + + // type postData struct { + // Streamers []string `json:"streamers"` + // } + + // auth.POST("/bulk", func(context *gin.Context) { + // var f postData + // err := context.ShouldBindJSON(&f) + // if err != nil { + // context.Error(err) + // } + + // data := twitch.GetBulkStreamerInfo(f.Streamers) + // context.JSON(200, extractor.FormatMessage(data, true)) + // }) }