Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
b53357aad7 | |||
fee92259b1 | |||
c964c73824 | |||
c2882857a4 | |||
f207f57536 | |||
30fbf1b611 | |||
70900ea2c7 | |||
322e908147 | |||
308f853b81 | |||
d5de8568dd | |||
8b80a73452 | |||
20366ed3e4 |
25
.drone.yml
25
.drone.yml
@ -24,7 +24,6 @@ steps:
|
|||||||
- ARCH=amd64 packaging/build-package.sh
|
- ARCH=amd64 packaging/build-package.sh
|
||||||
- ARCH=armv7 packaging/build-package.sh
|
- ARCH=armv7 packaging/build-package.sh
|
||||||
- ARCH=arm64 packaging/build-package.sh
|
- ARCH=arm64 packaging/build-package.sh
|
||||||
- packaging/package-upload.sh
|
|
||||||
volumes:
|
volumes:
|
||||||
- name: build
|
- name: build
|
||||||
path: /build
|
path: /build
|
||||||
@ -44,7 +43,29 @@ steps:
|
|||||||
environment:
|
environment:
|
||||||
PLUGIN_API_KEY:
|
PLUGIN_API_KEY:
|
||||||
from_secret: gitea_token
|
from_secret: gitea_token
|
||||||
|
- name: docker
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
repo: registry.meow.tf/ow-api/ow-api
|
||||||
|
registry: registry.meow.tf
|
||||||
|
tags:
|
||||||
|
- latest
|
||||||
|
- name: repo
|
||||||
|
image: tystuyfzand/drone-deb-simple
|
||||||
|
volumes:
|
||||||
|
- name: build
|
||||||
|
path: /build
|
||||||
|
settings:
|
||||||
|
url:
|
||||||
|
from_secret: upload_url
|
||||||
|
key:
|
||||||
|
from_secret: upload_key
|
||||||
|
distro: stable
|
||||||
|
files: [ '/build/*/owapi_*.deb' ]
|
||||||
volumes:
|
volumes:
|
||||||
- name: build
|
- name: build
|
||||||
temp: {}
|
temp: {}
|
11
Dockerfile
Normal file
11
Dockerfile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
FROM golang:alpine AS builder
|
||||||
|
|
||||||
|
ADD . /build
|
||||||
|
|
||||||
|
RUN cd /build && go build -o ow-api
|
||||||
|
|
||||||
|
FROM golang:alpine
|
||||||
|
|
||||||
|
COPY --from=builder /build/ow-api /usr/bin/ow-api
|
||||||
|
|
||||||
|
CMD [ "/usr/bin/ow-api" ]
|
10
endpoints.go
10
endpoints.go
@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func stats(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
func stats(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
data, err := statsResponse(w, ps, nil)
|
data, err := statsResponse(w, r, ps, nil)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeError(w, err)
|
writeError(w, err)
|
||||||
@ -25,7 +25,7 @@ func stats(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func profile(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
func profile(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
cacheKey := generateCacheKey(ps) + "-profile"
|
cacheKey := generateCacheKey(r, ps) + "-profile"
|
||||||
|
|
||||||
res, err := cacheProvider.Get(cacheKey)
|
res, err := cacheProvider.Get(cacheKey)
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ func profile(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cache result for profile specifically
|
// Cache result for profile specifically
|
||||||
data, err := statsResponse(w, ps, profilePatch)
|
data, err := statsResponse(w, r, ps, profilePatch)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeError(w, err)
|
writeError(w, err)
|
||||||
@ -63,7 +63,7 @@ func heroes(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|||||||
|
|
||||||
sort.Strings(names)
|
sort.Strings(names)
|
||||||
|
|
||||||
cacheKey := generateCacheKey(ps) + "-heroes-" + hex.EncodeToString(md5.New().Sum([]byte(strings.Join(names, ","))))
|
cacheKey := generateCacheKey(r, ps) + "-heroes-" + hex.EncodeToString(md5.New().Sum([]byte(strings.Join(names, ","))))
|
||||||
|
|
||||||
res, err := cacheProvider.Get(cacheKey)
|
res, err := cacheProvider.Get(cacheKey)
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ func heroes(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a patch to remove all but specified heroes
|
// Create a patch to remove all but specified heroes
|
||||||
data, err := statsResponse(w, ps, patch)
|
data, err := statsResponse(w, r, ps, patch)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeError(w, err)
|
writeError(w, err)
|
||||||
|
14
go.mod
14
go.mod
@ -2,21 +2,17 @@ module git.meow.tf/ow-api/ow-api
|
|||||||
|
|
||||||
go 1.12
|
go 1.12
|
||||||
|
|
||||||
|
replace s32x.com/ovrstat => github.com/tystuyfzand/ovrstat v0.0.0-20201003203341-5f1ad8502a8f
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/PuerkitoBio/goquery v1.5.1-0.20190109230704-3dcf72e6c17f
|
github.com/PuerkitoBio/goquery v1.5.1-0.20190109230704-3dcf72e6c17f
|
||||||
github.com/andybalholm/cascadia v1.1.0 // indirect
|
|
||||||
github.com/bluele/gcache v0.0.0-20190518031135-bc40bd653833
|
github.com/bluele/gcache v0.0.0-20190518031135-bc40bd653833
|
||||||
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b
|
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b
|
||||||
github.com/go-redis/redis v6.15.6+incompatible
|
github.com/go-redis/redis v6.15.6+incompatible
|
||||||
github.com/julienschmidt/httprouter v1.3.0
|
github.com/julienschmidt/httprouter v1.3.0
|
||||||
github.com/kr/pretty v0.1.0 // indirect
|
|
||||||
github.com/miekg/dns v1.1.26
|
github.com/miekg/dns v1.1.26
|
||||||
github.com/onsi/ginkgo v1.8.0 // indirect
|
|
||||||
github.com/onsi/gomega v1.5.0 // indirect
|
|
||||||
github.com/rs/cors v1.7.0
|
github.com/rs/cors v1.7.0
|
||||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 // indirect
|
github.com/stoewer/go-strcase v1.2.0
|
||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect
|
golang.org/x/net v0.0.0-20190923162816-aa69164e4478
|
||||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
|
s32x.com/ovrstat v0.0.0-20201003203341-5f1ad8502a8f
|
||||||
gopkg.in/yaml.v2 v2.2.2 // indirect
|
|
||||||
s32x.com/ovrstat v0.0.0-20200131231416-4cb42edd331d
|
|
||||||
)
|
)
|
||||||
|
5
go.sum
5
go.sum
@ -63,10 +63,15 @@ github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik=
|
|||||||
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
|
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
|
||||||
github.com/seilem/ovrstat v0.0.0-20200123200456-7b7e24d39506 h1:xAdnQYUFimq8Uiz4Io7QlnNGV+4BtagWGC+DDxVG3Fo=
|
github.com/seilem/ovrstat v0.0.0-20200123200456-7b7e24d39506 h1:xAdnQYUFimq8Uiz4Io7QlnNGV+4BtagWGC+DDxVG3Fo=
|
||||||
github.com/seilem/ovrstat v0.0.0-20200123200456-7b7e24d39506/go.mod h1:UzsLSEoY8B4FByz4e+5GGKebJio+H+axo3RxLr7d7Mw=
|
github.com/seilem/ovrstat v0.0.0-20200123200456-7b7e24d39506/go.mod h1:UzsLSEoY8B4FByz4e+5GGKebJio+H+axo3RxLr7d7Mw=
|
||||||
|
github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU=
|
||||||
|
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
|
github.com/tystuyfzand/ovrstat v0.0.0-20201003203341-5f1ad8502a8f h1:vjYPeN0jt5TJ1vP4teWyTLGbkufQoPi0bhYE9wzg/4w=
|
||||||
|
github.com/tystuyfzand/ovrstat v0.0.0-20201003203341-5f1ad8502a8f/go.mod h1:UzsLSEoY8B4FByz4e+5GGKebJio+H+axo3RxLr7d7Mw=
|
||||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||||
github.com/valyala/fasttemplate v1.0.1 h1:tY9CJiPnMXf1ERmG2EyK7gNUd+c6RKGD0IfU8WdUSz8=
|
github.com/valyala/fasttemplate v1.0.1 h1:tY9CJiPnMXf1ERmG2EyK7gNUd+c6RKGD0IfU8WdUSz8=
|
||||||
|
120
main.go
120
main.go
@ -4,10 +4,14 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
"git.meow.tf/ow-api/ow-api/cache"
|
"git.meow.tf/ow-api/ow-api/cache"
|
||||||
"git.meow.tf/ow-api/ow-api/json-patch"
|
"git.meow.tf/ow-api/ow-api/json-patch"
|
||||||
|
"github.com/PuerkitoBio/goquery"
|
||||||
"github.com/julienschmidt/httprouter"
|
"github.com/julienschmidt/httprouter"
|
||||||
"github.com/rs/cors"
|
"github.com/rs/cors"
|
||||||
|
"github.com/stoewer/go-strcase"
|
||||||
|
"golang.org/x/net/context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
@ -17,12 +21,20 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Version = "2.3.3"
|
Version = "2.4.3"
|
||||||
|
|
||||||
OpAdd = "add"
|
OpAdd = "add"
|
||||||
OpRemove = "remove"
|
OpRemove = "remove"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ApiVersion int
|
||||||
|
|
||||||
|
const (
|
||||||
|
VersionOne ApiVersion = iota
|
||||||
|
VersionTwo
|
||||||
|
VersionThree
|
||||||
|
)
|
||||||
|
|
||||||
type gamesStats struct {
|
type gamesStats struct {
|
||||||
Played int64 `json:"played"`
|
Played int64 `json:"played"`
|
||||||
Won int64 `json:"won"`
|
Won int64 `json:"won"`
|
||||||
@ -115,41 +127,74 @@ func registerVersionTwo(router *httprouter.Router) {
|
|||||||
router.GET("/v2/stats/"+platform+"/:tag/heroes/:heroes", injectPlatform(platform, heroes))
|
router.GET("/v2/stats/"+platform+"/:tag/heroes/:heroes", injectPlatform(platform, heroes))
|
||||||
router.GET("/v2/stats/"+platform+"/:tag/profile", injectPlatform(platform, profile))
|
router.GET("/v2/stats/"+platform+"/:tag/profile", injectPlatform(platform, profile))
|
||||||
router.GET("/v2/stats/"+platform+"/:tag/complete", injectPlatform(platform, stats))
|
router.GET("/v2/stats/"+platform+"/:tag/complete", injectPlatform(platform, stats))
|
||||||
|
router.GET("/v3/stats/"+platform+"/:tag/heroes/:heroes", injectPlatform(platform, heroes))
|
||||||
|
router.GET("/v3/stats/"+platform+"/:tag/profile", injectPlatform(platform, profile))
|
||||||
|
router.GET("/v3/stats/"+platform+"/:tag/complete", injectPlatform(platform, stats))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Version
|
// Version
|
||||||
router.GET("/v2/version", versionHandler)
|
router.GET("/v2/version", versionHandler)
|
||||||
|
router.GET("/v3/version", versionHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadHeroNames() {
|
func loadHeroNames() {
|
||||||
stats, err := ovrstat.PCStats("cats-11481")
|
res, err := http.Get("https://playoverwatch.com/en-us/heroes/")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
m := make(map[string]bool)
|
defer res.Body.Close()
|
||||||
|
|
||||||
for k := range stats.QuickPlayStats.TopHeroes {
|
doc, err := goquery.NewDocumentFromReader(res.Body)
|
||||||
m[k] = true
|
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for k := range stats.QuickPlayStats.CareerStats {
|
links := doc.Find(".hero-portrait-detailed")
|
||||||
m[k] = true
|
|
||||||
}
|
|
||||||
|
|
||||||
heroNames = make([]string, 0)
|
heroNames = make([]string, 0)
|
||||||
|
|
||||||
for k := range m {
|
links.Each(func(_ int, s *goquery.Selection) {
|
||||||
heroNames = append(heroNames, k)
|
val, exists := s.Attr("data-hero-id")
|
||||||
}
|
|
||||||
|
if !exists {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
heroNames = append(heroNames, strcase.LowerCamelCase(val))
|
||||||
|
})
|
||||||
|
|
||||||
|
log.Println("Loaded heroes", heroNames)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
versionRegexp = regexp.MustCompile("^/(v\\d+)/")
|
||||||
|
)
|
||||||
|
|
||||||
func injectPlatform(platform string, handler httprouter.Handle) httprouter.Handle {
|
func injectPlatform(platform string, handler httprouter.Handle) httprouter.Handle {
|
||||||
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
ps = append(ps, httprouter.Param{Key: "platform", Value: platform})
|
ps = append(ps, httprouter.Param{Key: "platform", Value: platform})
|
||||||
|
|
||||||
handler(w, r, ps)
|
ctx := context.Background()
|
||||||
|
|
||||||
|
m := versionRegexp.FindStringSubmatch(r.RequestURI)
|
||||||
|
|
||||||
|
if m != nil {
|
||||||
|
version := VersionOne
|
||||||
|
|
||||||
|
switch m[1] {
|
||||||
|
case "v2":
|
||||||
|
version = VersionTwo
|
||||||
|
case "v3":
|
||||||
|
version = VersionThree
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx = context.WithValue(ctx, "version", version)
|
||||||
|
}
|
||||||
|
|
||||||
|
handler(w, r.WithContext(ctx), ps)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,15 +202,21 @@ var (
|
|||||||
tagRegexp = regexp.MustCompile("-(\\d+)$")
|
tagRegexp = regexp.MustCompile("-(\\d+)$")
|
||||||
)
|
)
|
||||||
|
|
||||||
func statsResponse(w http.ResponseWriter, ps httprouter.Params, patch *jsonpatch.Patch) ([]byte, error) {
|
func statsResponse(w http.ResponseWriter, r *http.Request, ps httprouter.Params, patch *jsonpatch.Patch) ([]byte, error) {
|
||||||
var stats *ovrstat.PlayerStats
|
var stats *ovrstat.PlayerStats
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
version := VersionOne
|
||||||
|
|
||||||
|
if v := r.Context().Value("version"); v != nil {
|
||||||
|
version = v.(ApiVersion)
|
||||||
|
}
|
||||||
|
|
||||||
tag := ps.ByName("tag")
|
tag := ps.ByName("tag")
|
||||||
|
|
||||||
tag = strings.Replace(tag, "#", "-", -1)
|
tag = strings.Replace(tag, "#", "-", -1)
|
||||||
|
|
||||||
cacheKey := generateCacheKey(ps)
|
cacheKey := generateCacheKey(r, ps)
|
||||||
|
|
||||||
platform := ps.ByName("platform")
|
platform := ps.ByName("platform")
|
||||||
|
|
||||||
@ -262,11 +313,36 @@ func statsResponse(w http.ResponseWriter, ps httprouter.Params, patch *jsonpatch
|
|||||||
iconUrl = rating.RankIcon
|
iconUrl = rating.RankIcon
|
||||||
}
|
}
|
||||||
|
|
||||||
rating = int(totalRating / len(stats.Ratings))
|
rating = totalRating / len(stats.Ratings)
|
||||||
|
|
||||||
urlBase := iconUrl[0 : strings.Index(iconUrl, "rank-icons/")+11]
|
urlBase := iconUrl[0 : strings.Index(iconUrl, "rank-icons/")+11]
|
||||||
|
|
||||||
ratingIcon = urlBase + iconFor(rating)
|
ratingIcon = urlBase + iconFor(rating)
|
||||||
|
|
||||||
|
if version == VersionThree {
|
||||||
|
m := make(map[string]ovrstat.Rating)
|
||||||
|
|
||||||
|
ratingsPatches := make([]patchOperation, len(stats.Ratings))
|
||||||
|
|
||||||
|
for i, rating := range stats.Ratings {
|
||||||
|
m[rating.Role] = rating
|
||||||
|
ratingsPatches[i] = patchOperation{
|
||||||
|
Op: OpRemove,
|
||||||
|
Path: "/ratings/" + rating.Role + "/role",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extra = append(extra, patchOperation{
|
||||||
|
Op: OpRemove,
|
||||||
|
Path: "/ratings",
|
||||||
|
}, patchOperation{
|
||||||
|
Op: OpAdd,
|
||||||
|
Path: "/ratings",
|
||||||
|
Value: m,
|
||||||
|
})
|
||||||
|
|
||||||
|
extra = append(extra, ratingsPatches...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extra = append(extra, patchOperation{
|
extra = append(extra, patchOperation{
|
||||||
@ -330,6 +406,16 @@ func iconFor(rating int) string {
|
|||||||
return "rank-BronzeTier.png"
|
return "rank-BronzeTier.png"
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateCacheKey(ps httprouter.Params) string {
|
func generateCacheKey(r *http.Request, ps httprouter.Params) string {
|
||||||
return ps.ByName("platform") + "-" + ps.ByName("tag")
|
version := VersionOne
|
||||||
|
|
||||||
|
if v := r.Context().Value("version"); v != nil {
|
||||||
|
version = v.(ApiVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
return versionToString(version) + "-" + ps.ByName("platform") + "-" + ps.ByName("tag")
|
||||||
|
}
|
||||||
|
|
||||||
|
func versionToString(version ApiVersion) string {
|
||||||
|
return fmt.Sprintf("v%d", version)
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
fpm -s dir -t deb -p /build/$ARCH/owapi_${VERSION}_${ARCH}.deb \
|
fpm -s dir -t deb -p /build/$ARCH/owapi_${VERSION}_${ARCH}.deb \
|
||||||
-n ow-api -v $VERSION \
|
-n ow-api -v $VERSION -a $ARCH \
|
||||||
--deb-priority optional --force \
|
--deb-priority optional --force \
|
||||||
--deb-compression bzip2 \
|
--deb-compression bzip2 \
|
||||||
--description "Overwatch API Server" \
|
--description "Overwatch API Server" \
|
||||||
|
@ -1 +1,3 @@
|
|||||||
curl -X POST "$UPLOAD_URL" -F "file_i386=@/build/i386/owapi_${VERSION}_i386.deb" -F "file_amd64=@/build/amd64/owapi_${VERSION}_amd64.deb" -F "file_armv7=@/build/armv7/owapi_${VERSION}_armv7.deb"
|
curl -X POST "$UPLOAD_URL" -F "file_i386=@/build/i386/owapi_${VERSION}_i386.deb" \
|
||||||
|
-F "file_amd64=@/build/amd64/owapi_${VERSION}_amd64.deb" \
|
||||||
|
-F "file_armv7=@/build/armv7/owapi_${VERSION}_armv7.deb"
|
@ -7,12 +7,13 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
baseURL = "https://playoverwatch.com/en-us/career"
|
baseURL = "https://playoverwatch.com/en-us/career"
|
||||||
|
|
||||||
apiURL = "https://playoverwatch.com/en-us/career/platforms/"
|
apiURL = "https://playoverwatch.com/en-us/search/account-by-name/"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Platform struct {
|
type Platform struct {
|
||||||
@ -86,20 +87,12 @@ func ValidateEndpoint() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
code, err := pd.Html()
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
split := careerInitRegexp.FindStringSubmatch(code)
|
|
||||||
|
|
||||||
if split == nil || len(split) < 2 {
|
|
||||||
return errNoCareerInit
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate API response
|
// Validate API response
|
||||||
if err := validateApi(split[1]); err != nil {
|
if err := validateApi(strings.Replace(url[strings.LastIndex(url, "/")+1:], "-", "%23", -1)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,13 +147,13 @@ func validateCareerStats(careerStatsSelector *goquery.Selection, parent string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectors := []string{
|
selectors := []string{
|
||||||
"div.row div.js-stats", // Top level
|
"div.row div.js-stats", // Top level
|
||||||
"div.row div.js-stats div.column.xs-12", // stat boxes
|
"div.row div.js-stats div.column", // stat boxes
|
||||||
"div.row div.js-stats div.column.xs-12 .stat-title", // stat boxes
|
"div.row div.js-stats div.column .stat-title", // stat boxes
|
||||||
"div.row div.js-stats div.column.xs-12 table.DataTable", // data table
|
"div.row div.js-stats div.column table.DataTable", // data table
|
||||||
"div.row div.js-stats div.column.xs-12 table.DataTable tbody", // data table tbody
|
"div.row div.js-stats div.column table.DataTable tbody", // data table tbody
|
||||||
"div.row div.js-stats div.column.xs-12 table.DataTable tbody tr", // data table tbody tr
|
"div.row div.js-stats div.column table.DataTable tbody tr", // data table tbody tr
|
||||||
"div.row div.js-stats div.column.xs-12 table.DataTable tbody tr td", // data table tbody tr td
|
"div.row div.js-stats div.column table.DataTable tbody tr td", // data table tbody tr td
|
||||||
}
|
}
|
||||||
|
|
||||||
return validateElementsExist(careerStatsSelector, parent, selectors...)
|
return validateElementsExist(careerStatsSelector, parent, selectors...)
|
||||||
|
Reference in New Issue
Block a user