Skip to content

Commit

Permalink
Add v3 APIs and remove Legends.GG
Browse files Browse the repository at this point in the history
  • Loading branch information
1lann committed Sep 4, 2017
1 parent 26ce48d commit f647ebf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 39 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.glr
.DS_Store
2 changes: 1 addition & 1 deletion server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func writeLastGames(skip int, games int, r *http.Request, w io.Writer) {
" " + info.GameID + " " + info.Platform

thisRecording := apiRecording{
Region: platformToRegion[info.Platform],
Region: info.Platform,
RecordTime: info.RecordTime,
LastWriteTime: rec.LastWriteTime(),
IsRecording: sortedRecordings[i].recording,
Expand Down
7 changes: 4 additions & 3 deletions server/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path"
"runtime/debug"
"strconv"
"strings"
"time"

"github.com/1lann/lol-replay/record"
Expand Down Expand Up @@ -246,9 +247,9 @@ func recordGame(info gameInfoMetadata, resume bool) {
}

func (p configPlayer) currentGameInfo(apiKey string) (gameInfoMetadata, bool) {
url := "https://" + platformToRegion[p.Platform] + ".api.pvp.net/observer-mode/rest" +
"/consumer/getSpectatorGameInfo/" + p.Platform + "/" + p.ID +
"?api_key=" + apiKey
url := "https://" + strings.ToLower(p.Platform) +
".api.riotgames.com/lol/spectator/v3/active-games/by-summoner/" +
"/consumer/getSpectatorGameInfo/" + p.Platform + "/" + p.ID

for i := 0; i < 3; i++ {
resp, err := http.Get(url)
Expand Down
35 changes: 0 additions & 35 deletions server/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ type recordingArg struct {
Region string
AQueue string
Code string
LegendsGG string
}

type renderArg struct {
Expand Down Expand Up @@ -96,36 +95,6 @@ func serveView(w http.ResponseWriter, r *http.Request) {
}
}

func getLegendsGGLink(recording bool, recRenderArg recordingArg,
info recording.GameInfo, game gameInfoMetadata) string {
if recording {
if len(recRenderArg.Players) > 0 {
return "http://www.legends.gg/current/" +
platformToRegion[info.Platform] + "/" +
recRenderArg.Players[0].Summoner
} else if len(game.Participants) > 0 {
return "http://www.legends.gg/current/" +
platformToRegion[info.Platform] + "/" +
game.Participants[0].SummonerName
} else {
return ""
}
} else {
if len(recRenderArg.Players) > 0 {
return "http://www.legends.gg/" +
platformToRegion[info.Platform] + "/" +
recRenderArg.Players[0].Summoner + "/match/" + info.GameID
} else if len(game.Participants) > 0 {
return "http://www.legends.gg/" +
platformToRegion[info.Platform] + "/" +
game.Participants[0].SummonerName + "/match/" + info.GameID
} else {
return "http://www.legends.gg/" +
platformToRegion[info.Platform] + "/_/match/" + info.GameID
}
}
}

func getPlayerArg(summonerID int64, summonerName string, championID int,
info recording.GameInfo) (playerArg, bool) {
var thisPlayer playerArg
Expand Down Expand Up @@ -254,9 +223,6 @@ func getRenderArg(r *http.Request, currentPage int) renderArg {
staticDataMutex.Unlock()
}

recRenderArg.LegendsGG = getLegendsGGLink(rec.recording,
recRenderArg, info, game)

renderTemplateArg.Recordings =
append(renderTemplateArg.Recordings, recRenderArg)
}
Expand Down Expand Up @@ -416,7 +382,6 @@ var pageSource = `<!DOCTYPE html>
{{- if not .Recording}}
<a class="card-footer-item" onclick="copyCode(this)">Copy to clipboard</a>
{{- end}}
<a class="card-footer-item" href="{{.LegendsGG}}" target="_blank">Show on Legends.GG<i class="fa fa-external-link"></i></a>
</footer>
</div>
</div>
Expand Down

0 comments on commit f647ebf

Please sign in to comment.