forked from nite/go-igdb
u
This commit is contained in:
62
covers.go
62
covers.go
@@ -2,7 +2,6 @@ package igdb
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
pb "github.com/bestnite/go-igdb/proto"
|
||||
|
||||
@@ -26,64 +25,3 @@ func (g *Client) GetCovers(query string) ([]*pb.Cover, error) {
|
||||
|
||||
return data.Covers, nil
|
||||
}
|
||||
|
||||
func (g *Client) GetCoverByID(id uint64) (*pb.Cover, error) {
|
||||
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||
covers, err := g.GetCovers(query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return covers[0], nil
|
||||
}
|
||||
|
||||
func (g *Client) GetCoversByIDs(ids []uint64) ([]*pb.Cover, error) {
|
||||
idStrSlice := make([]string, len(ids))
|
||||
for i, id := range ids {
|
||||
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||
}
|
||||
|
||||
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||
|
||||
return g.GetCovers(idStr)
|
||||
}
|
||||
|
||||
func (g *Client) GetCoversByGameID(id uint64) ([]*pb.Cover, error) {
|
||||
query := fmt.Sprintf(`where game = %d; fields *;`, id)
|
||||
return g.GetCovers(query)
|
||||
}
|
||||
|
||||
func (g *Client) GetCoversByGameIDs(ids []uint64) ([]*pb.Cover, error) {
|
||||
idStrSlice := make([]string, len(ids))
|
||||
for i, id := range ids {
|
||||
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||
}
|
||||
|
||||
idStr := fmt.Sprintf(`where game = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||
|
||||
return g.GetCovers(idStr)
|
||||
}
|
||||
|
||||
func (g *Client) GetCoversByGameLocalizationID(id uint64) ([]*pb.Cover, error) {
|
||||
query := fmt.Sprintf(`where game_localization = %d; fields *;`, id)
|
||||
return g.GetCovers(query)
|
||||
}
|
||||
|
||||
func (g *Client) GetCoversByGameLocalizationIDs(ids []uint64) ([]*pb.Cover, error) {
|
||||
idStrSlice := make([]string, len(ids))
|
||||
for i, id := range ids {
|
||||
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||
}
|
||||
|
||||
idStr := fmt.Sprintf(`where game_localization = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||
|
||||
return g.GetCovers(idStr)
|
||||
}
|
||||
|
||||
func (g *Client) GetCoversLength() (int, error) {
|
||||
query := `fields *; sort id desc; limit 1;`
|
||||
covers, err := g.GetCovers(query)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return int(covers[0].Id), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user