mirror of
https://github.com/bestnite/go-igdb.git
synced 2025-07-04 16:32:33 +08:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
dab30b4938 | |||
4be44c4eb2 | |||
e01d9805c6 | |||
76a3e977ba |
57
README.md
57
README.md
@ -1,14 +1,61 @@
|
|||||||
# go-igdb
|
# go-igdb
|
||||||
|
|
||||||
a go library to access IGDB API
|
A Go client library for the IGDB (Internet Game Database) API v4. This library provides a simple and efficient way to interact with IGDB's protobuf-based API.
|
||||||
|
|
||||||
## Usage
|
## Features
|
||||||
|
|
||||||
|
- Full support for IGDB API v4
|
||||||
|
- Protobuf-based communication for better performance
|
||||||
|
- Automatic token management for Twitch authentication
|
||||||
|
- Built-in retry mechanism for failed requests
|
||||||
|
- Optional Cloudflare bypass support via FlareSolverr
|
||||||
|
- All endpoints are supported
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go get github.com/bestnite/go-igdb
|
||||||
|
```
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
```go
|
```go
|
||||||
g := igdb.New("clientID", "clientSecret")
|
// Create a new IGDB client
|
||||||
game, err := g.GetGameByID(325594)
|
client := igdb.New("your-client-id", "your-client-secret")
|
||||||
|
|
||||||
|
// Get a game by ID
|
||||||
|
game, err := client.GetGameByID(1942)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
fmt.Printf("Game: %s\n", game.Name)
|
||||||
|
|
||||||
|
// Search games with custom query
|
||||||
|
games, err := client.GetGames("search \"Zelda\"; fields name,rating,release_dates.*;")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
fmt.Println(game.Name)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Advanced Usage
|
||||||
|
|
||||||
|
### Query Format
|
||||||
|
|
||||||
|
The library uses IGDB's query syntax. For example:
|
||||||
|
|
||||||
|
```go
|
||||||
|
// Get games released in 2023
|
||||||
|
games, err := client.GetGames("where release_dates.y = 2023; fields name,rating;")
|
||||||
|
|
||||||
|
// Get specific fields for a company
|
||||||
|
companies, err := client.GetCompanies("where id = 1234; fields name,description,country;")
|
||||||
|
```
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- Go 1.24 or higher
|
||||||
|
- IGDB/Twitch API credentials (Client ID and Client Secret)
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Contributions are welcome! Please feel free to submit a Pull Request.
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,3 +62,12 @@ func (g *igdb) GetAgeRatingCategoriesByOrganizationIDs(ids []uint64) ([]*pb.AgeR
|
|||||||
|
|
||||||
return g.GetAgeRatingCategories(idStr)
|
return g.GetAgeRatingCategories(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetAgeRatingCategoriesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
ageRatingCategories, err := g.GetAgeRatingCategories(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(ageRatingCategories[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetAgeRatingContentDescriptionsByIDs(ids []uint64) ([]*pb.AgeRati
|
|||||||
|
|
||||||
return g.GetAgeRatingContentDescriptions(idStr)
|
return g.GetAgeRatingContentDescriptions(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetAgeRatingContentDescriptionsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
ageRatingContentDescriptions, err := g.GetAgeRatingContentDescriptions(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(ageRatingContentDescriptions[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,3 +62,12 @@ func (g *igdb) GetAgeRatingContentDescriptionsV2ByOrganizationIDs(ids []uint64)
|
|||||||
|
|
||||||
return g.GetAgeRatingContentDescriptionsV2(idStr)
|
return g.GetAgeRatingContentDescriptionsV2(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetAgeRatingContentDescriptionsV2Length() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
ageRatingContentDescriptions, err := g.GetAgeRatingContentDescriptionsV2(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(ageRatingContentDescriptions[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetAgeRatingOrganizationsByIDs(ids []uint64) ([]*pb.AgeRatingOrga
|
|||||||
|
|
||||||
return g.GetAgeRatingOrganizations(idStr)
|
return g.GetAgeRatingOrganizations(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetAgeRatingOrganizationsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
ageRatingOrganizations, err := g.GetAgeRatingOrganizations(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(ageRatingOrganizations[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -77,3 +78,12 @@ func (g *igdb) GetAgeRatingsByAgeRatingCategoryIDs(ids []uint64) ([]*pb.AgeRatin
|
|||||||
|
|
||||||
return g.GetAgeRatings(idStr)
|
return g.GetAgeRatings(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetAgeRatingsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
ageRatings, err := g.GetAgeRatings(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(ageRatings[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,3 +62,12 @@ func (g *igdb) GetAlternativeNamesByGameIDs(ids []uint64) ([]*pb.AlternativeName
|
|||||||
|
|
||||||
return g.GetAlternativeNames(idStr)
|
return g.GetAlternativeNames(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetAlternativeNamesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
alternativeNames, err := g.GetAlternativeNames(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(alternativeNames[0].Id), nil
|
||||||
|
}
|
||||||
|
11
artworks.go
11
artworks.go
@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
pb "github/bestnite/go-igdb/proto"
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
@ -62,3 +62,12 @@ func (g *igdb) GetArtworksByGameIDs(ids []uint64) ([]*pb.Artwork, error) {
|
|||||||
|
|
||||||
return g.GetArtworks(idStr)
|
return g.GetArtworks(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetArtworksLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
artworks, err := g.GetArtworks(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(artworks[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetCharacterGendersByIDs(ids []uint64) ([]*pb.CharacterGender, er
|
|||||||
|
|
||||||
return g.GetCharacterGenders(idStr)
|
return g.GetCharacterGenders(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetCharacterGendersLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
characterGenders, err := g.GetCharacterGenders(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(characterGenders[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetCharacterMugShotsByIDs(ids []uint64) ([]*pb.CharacterMugShot,
|
|||||||
|
|
||||||
return g.GetCharacterMugShots(idStr)
|
return g.GetCharacterMugShots(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetCharacterMugShotsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
characterMugShots, err := g.GetCharacterMugShots(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(characterMugShots[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetCharacterSpeciesByIDs(ids []uint64) ([]*pb.CharacterSpecie, er
|
|||||||
|
|
||||||
return g.GetCharacterSpecies(idStr)
|
return g.GetCharacterSpecies(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetCharacterSpeciesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
characterSpecies, err := g.GetCharacterSpecies(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(characterSpecies[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
pb "github/bestnite/go-igdb/proto"
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
@ -94,3 +94,12 @@ func (g *igdb) GetCharactersByMugShotIDs(ids []uint64) ([]*pb.Character, error)
|
|||||||
|
|
||||||
return g.GetCharacters(idStr)
|
return g.GetCharacters(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetCharactersLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
characters, err := g.GetCharacters(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(characters[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,3 +62,12 @@ func (g *igdb) GetCollectionMembershipTypesByAllowedCollectionTypeIDs(ids []uint
|
|||||||
|
|
||||||
return g.GetCollectionMembershipTypes(idStr)
|
return g.GetCollectionMembershipTypes(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetCollectionMembershipTypesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
collectionMembershipTypes, err := g.GetCollectionMembershipTypes(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(collectionMembershipTypes[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -82,3 +83,12 @@ func (g *igdb) GetCollectionMembershipsByCollectionMembershipTypeIDs(ids []uint6
|
|||||||
|
|
||||||
return g.GetCollectionMemberships(idStr)
|
return g.GetCollectionMemberships(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetCollectionMembershipsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
collectionMemberships, err := g.GetCollectionMemberships(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(collectionMemberships[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -77,3 +78,12 @@ func (g *igdb) GetCollectionRelationTypesByAllowedParentTypeIDs(ids []uint64) ([
|
|||||||
|
|
||||||
return g.GetCollectionRelationTypes(idStr)
|
return g.GetCollectionRelationTypes(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetCollectionRelationTypesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
collectionRelationTypes, err := g.GetCollectionRelationTypes(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(collectionRelationTypes[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -93,3 +94,12 @@ func (g *igdb) GetCollectionRelationsByCollectionRelationTypeIDs(ids []uint64) (
|
|||||||
|
|
||||||
return g.GetCollectionRelations(idStr)
|
return g.GetCollectionRelations(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetCollectionRelationsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
collectionRelations, err := g.GetCollectionRelations(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(collectionRelations[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetCollectionTypesByIDs(ids []uint64) ([]*pb.CollectionType, erro
|
|||||||
|
|
||||||
return g.GetCollectionTypes(idStr)
|
return g.GetCollectionTypes(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetCollectionTypesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
collectionTypes, err := g.GetCollectionTypes(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(collectionTypes[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
pb "github/bestnite/go-igdb/proto"
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
@ -62,3 +62,12 @@ func (g *igdb) GetCollectionsByCollectionTypeIDs(ids []uint64) ([]*pb.Collection
|
|||||||
|
|
||||||
return g.GetCollections(idStr)
|
return g.GetCollections(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetCollectionsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
collections, err := g.GetCollections(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(collections[0].Id), nil
|
||||||
|
}
|
||||||
|
11
companies.go
11
companies.go
@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
pb "github/bestnite/go-igdb/proto"
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
@ -143,3 +143,12 @@ func (g *igdb) GetCompanyByStatusIDs(ids []uint64) ([]*pb.Company, error) {
|
|||||||
|
|
||||||
return g.GetCompanies(idStr)
|
return g.GetCompanies(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetCompaniesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
companies, err := g.GetCompanies(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(companies[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetCompanyLogosByIDs(ids []uint64) ([]*pb.CompanyLogo, error) {
|
|||||||
|
|
||||||
return g.GetCompanyLogos(idStr)
|
return g.GetCompanyLogos(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetCompanyLogosLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
companyLogos, err := g.GetCompanyLogos(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(companyLogos[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetCompanyStatusesByIDs(ids []uint64) ([]*pb.CompanyStatus, error
|
|||||||
|
|
||||||
return g.GetCompanyStatuses(idStr)
|
return g.GetCompanyStatuses(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetCompanyStatusesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
companyStatuses, err := g.GetCompanyStatuses(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(companyStatuses[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,3 +62,12 @@ func (g *igdb) GetCompanyWebsitesByTypeIDs(ids []uint64) ([]*pb.CompanyWebsite,
|
|||||||
|
|
||||||
return g.GetCompanyWebsites(idStr)
|
return g.GetCompanyWebsites(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetCompanyWebsitesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
companyWebsites, err := g.GetCompanyWebsites(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(companyWebsites[0].Id), nil
|
||||||
|
}
|
||||||
|
12
covers.go
12
covers.go
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -77,3 +78,12 @@ func (g *igdb) GetCoversByGameLocalizationIDs(ids []uint64) ([]*pb.Cover, error)
|
|||||||
|
|
||||||
return g.GetCovers(idStr)
|
return g.GetCovers(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) 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
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetDateFormatsByIDs(ids []uint64) ([]*pb.DateFormat, error) {
|
|||||||
|
|
||||||
return g.GetDateFormats(idStr)
|
return g.GetDateFormats(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetDateFormatsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
dateFormats, err := g.GetDateFormats(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(dateFormats[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,3 +62,12 @@ func (g *igdb) GetEventLogosByEventIDs(ids []uint64) ([]*pb.EventLogo, error) {
|
|||||||
|
|
||||||
return g.GetEventLogos(idStr)
|
return g.GetEventLogos(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetEventLogosLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
eventLogos, err := g.GetEventLogos(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(eventLogos[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -77,3 +78,12 @@ func (g *igdb) GetEventNetworksByNetworkTypeIDs(ids []uint64) ([]*pb.EventNetwor
|
|||||||
|
|
||||||
return g.GetEventNetworks(idStr)
|
return g.GetEventNetworks(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetEventNetworksLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
eventNetworks, err := g.GetEventNetworks(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(eventNetworks[0].Id), nil
|
||||||
|
}
|
||||||
|
11
events.go
11
events.go
@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
pb "github/bestnite/go-igdb/proto"
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
@ -62,3 +62,12 @@ func (g *igdb) GetEventsByEventLogoIDs(ids []uint64) ([]*pb.Event, error) {
|
|||||||
|
|
||||||
return g.GetEvents(idStr)
|
return g.GetEvents(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetEventsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
events, err := g.GetEvents(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(events[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetExternalGameSourcesByIDs(ids []uint64) ([]*pb.ExternalGameSour
|
|||||||
|
|
||||||
return g.GetExternalGameSources(idStr)
|
return g.GetExternalGameSources(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetExternalGameSourcesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
externalGameSources, err := g.GetExternalGameSources(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(externalGameSources[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,10 +2,11 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -117,3 +118,12 @@ func (g *igdb) GetExternalGamesByPlatformVersionIDs(ids []uint64) ([]*pb.Externa
|
|||||||
|
|
||||||
return g.GetExternalGames(idStr)
|
return g.GetExternalGames(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetExternalGamesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
externalGames, err := g.GetExternalGames(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(externalGames[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
pb "github/bestnite/go-igdb/proto"
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
@ -46,3 +46,12 @@ func (g *igdb) GetFranchisesByIDs(ids []uint64) ([]*pb.Franchise, error) {
|
|||||||
|
|
||||||
return g.GetFranchises(idStr)
|
return g.GetFranchises(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetFranchisesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
franchises, err := g.GetFranchises(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(franchises[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetGameEngineLogosByIDs(ids []uint64) ([]*pb.GameEngineLogo, erro
|
|||||||
|
|
||||||
return g.GetGameEngineLogos(idStr)
|
return g.GetGameEngineLogos(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetGameEngineLogosLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
gameEngineLogos, err := g.GetGameEngineLogos(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(gameEngineLogos[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
pb "github/bestnite/go-igdb/proto"
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
@ -78,3 +78,12 @@ func (g *igdb) GetGameEnginesByLogoIDs(ids []uint64) ([]*pb.GameEngine, error) {
|
|||||||
|
|
||||||
return g.GetGameEngines(idStr)
|
return g.GetGameEngines(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetGameEnginesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
gameEngines, err := g.GetGameEngines(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(gameEngines[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -93,3 +94,12 @@ func (g *igdb) GetGameLocalizationsByRegionIDs(ids []uint64) ([]*pb.GameLocaliza
|
|||||||
|
|
||||||
return g.GetGameLocalizations(idStr)
|
return g.GetGameLocalizations(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetGameLocalizationsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
gameLocalizations, err := g.GetGameLocalizations(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(gameLocalizations[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetGameModesByIDs(ids []uint64) ([]*pb.GameMode, error) {
|
|||||||
|
|
||||||
return g.GetGameModes(idStr)
|
return g.GetGameModes(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetGameModesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
gameModes, err := g.GetGameModes(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(gameModes[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetGameReleaseFormatsByIDs(ids []uint64) ([]*pb.GameReleaseFormat
|
|||||||
|
|
||||||
return g.GetGameReleaseFormats(idStr)
|
return g.GetGameReleaseFormats(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetGameReleaseFormatsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
gameReleaseFormats, err := g.GetGameReleaseFormats(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(gameReleaseFormats[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetGameStatusesByIDs(ids []uint64) ([]*pb.GameStatus, error) {
|
|||||||
|
|
||||||
return g.GetGameStatuses(idStr)
|
return g.GetGameStatuses(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetGameStatusesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
gameStatuses, err := g.GetGameStatuses(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(gameStatuses[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,28 @@ func (g *igdb) GetGameTimeToBeatsByIDs(ids []uint64) ([]*pb.GameTimeToBeat, erro
|
|||||||
|
|
||||||
return g.GetGameTimeToBeats(idStr)
|
return g.GetGameTimeToBeats(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetGameTimeToBeatsByGameID(id uint64) ([]*pb.GameTimeToBeat, error) {
|
||||||
|
query := fmt.Sprintf(`where game = %d; fields *;`, id)
|
||||||
|
return g.GetGameTimeToBeats(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetGameTimeToBeatsByGameIDs(ids []uint64) ([]*pb.GameTimeToBeat, 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.GetGameTimeToBeats(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetGameTimeToBeatsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
gameTimeToBeats, err := g.GetGameTimeToBeats(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(gameTimeToBeats[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetGameTypesByIDs(ids []uint64) ([]*pb.GameType, error) {
|
|||||||
|
|
||||||
return g.GetGameTypes(idStr)
|
return g.GetGameTypes(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetGameTypesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
gameTypes, err := g.GetGameTypes(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(gameTypes[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -77,3 +78,12 @@ func (g *igdb) GetGameVersionFeatureValuesByGameVersionFeatureIDs(ids []uint64)
|
|||||||
|
|
||||||
return g.GetGameVersionFeatureValues(idStr)
|
return g.GetGameVersionFeatureValues(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetGameVersionFeatureValuesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
gameVersionFeatureValues, err := g.GetGameVersionFeatureValues(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(gameVersionFeatureValues[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetGameVersionFeaturesByIDs(ids []uint64) ([]*pb.GameVersionFeatu
|
|||||||
|
|
||||||
return g.GetGameVersionFeatures(idStr)
|
return g.GetGameVersionFeatures(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetGameVersionFeaturesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
gameVersionFeatures, err := g.GetGameVersionFeatures(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(gameVersionFeatures[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,3 +62,12 @@ func (g *igdb) GetGameVersionsByGameIDs(ids []uint64) ([]*pb.GameVersion, error)
|
|||||||
|
|
||||||
return g.GetGameVersions(idStr)
|
return g.GetGameVersions(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetGameVersionsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
gameVersions, err := g.GetGameVersions(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(gameVersions[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,3 +62,12 @@ func (g *igdb) GetGameVideosByGameIDs(ids []uint64) ([]*pb.GameVideo, error) {
|
|||||||
|
|
||||||
return g.GetGameVideos(idStr)
|
return g.GetGameVideos(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetGameVideosLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
gameVideos, err := g.GetGameVideos(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(gameVideos[0].Id), nil
|
||||||
|
}
|
||||||
|
11
games.go
11
games.go
@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
pb "github/bestnite/go-igdb/proto"
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
@ -158,3 +158,12 @@ func (g *igdb) GetGamesByVersionParentGameIDs(ids []uint64) ([]*pb.Game, error)
|
|||||||
|
|
||||||
return g.GetGames(idStr)
|
return g.GetGames(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetGamesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
games, err := g.GetGames(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(games[0].Id), nil
|
||||||
|
}
|
||||||
|
12
genres.go
12
genres.go
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetGenresByIDs(ids []uint64) ([]*pb.Genre, error) {
|
|||||||
|
|
||||||
return g.GetGenres(idStr)
|
return g.GetGenres(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetGenresLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
genres, err := g.GetGenres(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(genres[0].Id), nil
|
||||||
|
}
|
||||||
|
2
go.mod
2
go.mod
@ -1,4 +1,4 @@
|
|||||||
module github/bestnite/go-igdb
|
module github.com/bestnite/go-igdb
|
||||||
|
|
||||||
go 1.24.1
|
go 1.24.1
|
||||||
|
|
||||||
|
5
igdb.go
5
igdb.go
@ -11,11 +11,13 @@ type igdb struct {
|
|||||||
clientID string
|
clientID string
|
||||||
token *twitchToken
|
token *twitchToken
|
||||||
flaresolverr *flaresolverr.Flaresolverr
|
flaresolverr *flaresolverr.Flaresolverr
|
||||||
|
limiter *rateLimiter
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(clientID, clientSecret string) *igdb {
|
func New(clientID, clientSecret string) *igdb {
|
||||||
return &igdb{
|
return &igdb{
|
||||||
clientID: clientID,
|
clientID: clientID,
|
||||||
|
limiter: newRateLimiter(4),
|
||||||
token: NewTwitchToken(clientID, clientSecret),
|
token: NewTwitchToken(clientID, clientSecret),
|
||||||
flaresolverr: nil,
|
flaresolverr: nil,
|
||||||
}
|
}
|
||||||
@ -24,12 +26,15 @@ func New(clientID, clientSecret string) *igdb {
|
|||||||
func NewWithFlaresolverr(clientID, clientSecret string, f *flaresolverr.Flaresolverr) *igdb {
|
func NewWithFlaresolverr(clientID, clientSecret string, f *flaresolverr.Flaresolverr) *igdb {
|
||||||
return &igdb{
|
return &igdb{
|
||||||
clientID: clientID,
|
clientID: clientID,
|
||||||
|
limiter: newRateLimiter(4),
|
||||||
token: NewTwitchToken(clientID, clientSecret),
|
token: NewTwitchToken(clientID, clientSecret),
|
||||||
flaresolverr: f,
|
flaresolverr: f,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *igdb) Request(URL string, dataBody any) (*resty.Response, error) {
|
func (g *igdb) Request(URL string, dataBody any) (*resty.Response, error) {
|
||||||
|
g.limiter.wait()
|
||||||
|
|
||||||
t, err := g.token.getToken()
|
t, err := g.token.getToken()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to get twitch token: %w", err)
|
return nil, fmt.Errorf("failed to get twitch token: %w", err)
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -77,3 +78,12 @@ func (g *igdb) GetInvolvedCompaniesByCompanyIDs(ids []uint64) ([]*pb.InvolvedCom
|
|||||||
|
|
||||||
return g.GetInvolvedCompanies(idStr)
|
return g.GetInvolvedCompanies(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetInvolvedCompaniesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
involvedCompanies, err := g.GetInvolvedCompanies(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(involvedCompanies[0].Id), nil
|
||||||
|
}
|
||||||
|
12
keywords.go
12
keywords.go
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetKeywordsByIDs(ids []uint64) ([]*pb.Keyword, error) {
|
|||||||
|
|
||||||
return g.GetKeywords(idStr)
|
return g.GetKeywords(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetKeywordsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
keywords, err := g.GetKeywords(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(keywords[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetLanguageSupportTypesByIDs(ids []uint64) ([]*pb.LanguageSupport
|
|||||||
|
|
||||||
return g.GetLanguageSupportTypes(idStr)
|
return g.GetLanguageSupportTypes(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetLanguageSupportTypesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
languageSupportTypes, err := g.GetLanguageSupportTypes(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(languageSupportTypes[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -93,3 +94,12 @@ func (g *igdb) GetLanguageSupportsByLanguageSupportTypeIDs(ids []uint64) ([]*pb.
|
|||||||
|
|
||||||
return g.GetLanguageSupports(idStr)
|
return g.GetLanguageSupports(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetLanguageSupportsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
languageSupports, err := g.GetLanguageSupports(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(languageSupports[0].Id), nil
|
||||||
|
}
|
||||||
|
12
languages.go
12
languages.go
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetLanguagesByIDs(ids []uint64) ([]*pb.Language, error) {
|
|||||||
|
|
||||||
return g.GetLanguages(idStr)
|
return g.GetLanguages(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetLanguagesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
languages, err := g.GetLanguages(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(languages[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -77,3 +78,12 @@ func (g *igdb) GetMultiplayerModesByPlatformIDs(ids []uint64) ([]*pb.Multiplayer
|
|||||||
|
|
||||||
return g.GetMultiplayerModes(idStr)
|
return g.GetMultiplayerModes(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetMultiplayerModesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
multiplayerModes, err := g.GetMultiplayerModes(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(multiplayerModes[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetNetworkTypesByIDs(ids []uint64) ([]*pb.NetworkType, error) {
|
|||||||
|
|
||||||
return g.GetNetworkTypes(idStr)
|
return g.GetNetworkTypes(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetNetworkTypesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
networkTypes, err := g.GetNetworkTypes(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(networkTypes[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetPlatformFamiliesByIDs(ids []uint64) ([]*pb.PlatformFamily, err
|
|||||||
|
|
||||||
return g.GetPlatformFamilies(idStr)
|
return g.GetPlatformFamilies(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetPlatformFamiliesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
platformFamilies, err := g.GetPlatformFamilies(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(platformFamilies[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetPlatformLogosByIDs(ids []uint64) ([]*pb.PlatformLogo, error) {
|
|||||||
|
|
||||||
return g.GetPlatformLogos(idStr)
|
return g.GetPlatformLogos(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetPlatformLogosLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
platformLogos, err := g.GetPlatformLogos(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(platformLogos[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
pb "github/bestnite/go-igdb/proto"
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
@ -46,3 +46,12 @@ func (g *igdb) GetPlatformTypesByIDs(ids []uint64) ([]*pb.PlatformType, error) {
|
|||||||
|
|
||||||
return g.GetPlatformTypes(idStr)
|
return g.GetPlatformTypes(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetPlatformTypesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
platformTypes, err := g.GetPlatformTypes(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(platformTypes[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,3 +62,12 @@ func (g *igdb) GetPlatformVersionCompaniesByCompanyIDs(ids []uint64) ([]*pb.Plat
|
|||||||
|
|
||||||
return g.GetPlatformVersionCompanies(idStr)
|
return g.GetPlatformVersionCompanies(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetPlatformVersionCompaniesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
platformVersionCompanies, err := g.GetPlatformVersionCompanies(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(platformVersionCompanies[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -93,3 +94,12 @@ func (g *igdb) GetPlatformVersionReleaseDatesByDateFormatIDs(ids []uint64) ([]*p
|
|||||||
|
|
||||||
return g.GetPlatformVersionReleaseDates(idStr)
|
return g.GetPlatformVersionReleaseDates(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetPlatformVersionReleaseDatesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
platformVersionReleaseDates, err := g.GetPlatformVersionReleaseDates(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(platformVersionReleaseDates[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -77,3 +78,12 @@ func (g *igdb) GetPlatformVersionsByPlatformLogoIDs(ids []uint64) ([]*pb.Platfor
|
|||||||
|
|
||||||
return g.GetPlatformVersions(idStr)
|
return g.GetPlatformVersions(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetPlatformVersionsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
platformVersions, err := g.GetPlatformVersions(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(platformVersions[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetPlatformWebsitesByIDs(ids []uint64) ([]*pb.PlatformWebsite, er
|
|||||||
|
|
||||||
return g.GetPlatformWebsites(idStr)
|
return g.GetPlatformWebsites(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetPlatformWebsitesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
platformWebsites, err := g.GetPlatformWebsites(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(platformWebsites[0].Id), nil
|
||||||
|
}
|
||||||
|
12
platforms.go
12
platforms.go
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -92,3 +93,12 @@ func (g *igdb) GetPlatformsByPlatformTypeIDs(ids []uint64) ([]*pb.Platform, erro
|
|||||||
|
|
||||||
return g.GetPlatforms(idStr)
|
return g.GetPlatforms(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetPlatformsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
platforms, err := g.GetPlatforms(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(platforms[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetPlayerPerspectivesByIDs(ids []uint64) ([]*pb.PlayerPerspective
|
|||||||
|
|
||||||
return g.GetPlayerPerspectives(idStr)
|
return g.GetPlayerPerspectives(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetPlayerPerspectivesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
playerPerspectives, err := g.GetPlayerPerspectives(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(playerPerspectives[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -71,3 +72,12 @@ func (g *igdb) GetPopularityPrimitivesByExternalPopularitySourceIDs(ids []uint64
|
|||||||
|
|
||||||
return g.GetPopularityPrimitives(idStr)
|
return g.GetPopularityPrimitives(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetPopularityPrimitivesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
popularityPrimitives, err := g.GetPopularityPrimitives(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(popularityPrimitives[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,3 +62,12 @@ func (g *igdb) GetPopularityTypesByExternalPopularitySourceIDs(ids []uint64) ([]
|
|||||||
|
|
||||||
return g.GetPopularityTypes(idStr)
|
return g.GetPopularityTypes(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetPopularityTypesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
popularityTypes, err := g.GetPopularityTypes(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(popularityTypes[0].Id), nil
|
||||||
|
}
|
||||||
|
48
rate_limiter.go
Normal file
48
rate_limiter.go
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type rateLimiter struct {
|
||||||
|
mu sync.Mutex
|
||||||
|
rate int
|
||||||
|
interval time.Duration
|
||||||
|
tokens int
|
||||||
|
lastRefill time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
func newRateLimiter(rate int) *rateLimiter {
|
||||||
|
return &rateLimiter{
|
||||||
|
rate: rate,
|
||||||
|
interval: time.Second,
|
||||||
|
tokens: rate,
|
||||||
|
lastRefill: time.Now(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *rateLimiter) wait() {
|
||||||
|
r.mu.Lock()
|
||||||
|
defer r.mu.Unlock()
|
||||||
|
|
||||||
|
now := time.Now()
|
||||||
|
elapsed := now.Sub(r.lastRefill)
|
||||||
|
|
||||||
|
if elapsed >= r.interval {
|
||||||
|
r.tokens = r.rate
|
||||||
|
r.lastRefill = now
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.tokens <= 0 {
|
||||||
|
waitTime := r.interval - elapsed
|
||||||
|
r.mu.Unlock()
|
||||||
|
time.Sleep(waitTime)
|
||||||
|
r.mu.Lock()
|
||||||
|
r.tokens = r.rate - 1
|
||||||
|
r.lastRefill = time.Now()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
r.tokens--
|
||||||
|
}
|
12
regions.go
12
regions.go
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetRegionsByIDs(ids []uint64) ([]*pb.Region, error) {
|
|||||||
|
|
||||||
return g.GetRegions(idStr)
|
return g.GetRegions(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetRegionsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
regions, err := g.GetRegions(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(regions[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetReleaseDateRegionsByIDs(ids []uint64) ([]*pb.ReleaseDateRegion
|
|||||||
|
|
||||||
return g.GetReleaseDateRegions(idStr)
|
return g.GetReleaseDateRegions(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetReleaseDateRegionsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
releaseDateRegions, err := g.GetReleaseDateRegions(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(releaseDateRegions[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetReleaseDateStatusesByIDs(ids []uint64) ([]*pb.ReleaseDateStatu
|
|||||||
|
|
||||||
return g.GetReleaseDateStatuses(idStr)
|
return g.GetReleaseDateStatuses(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetReleaseDateStatusesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
releaseDateStatuses, err := g.GetReleaseDateStatuses(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(releaseDateStatuses[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -109,3 +110,12 @@ func (g *igdb) GetReleaseDatesByStatusIDs(ids []uint64) ([]*pb.ReleaseDate, erro
|
|||||||
|
|
||||||
return g.GetReleaseDates(idStr)
|
return g.GetReleaseDates(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetReleaseDatesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
releaseDates, err := g.GetReleaseDates(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(releaseDates[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,3 +62,12 @@ func (g *igdb) GetScreenshotsByGameIDs(ids []uint64) ([]*pb.Screenshot, error) {
|
|||||||
|
|
||||||
return g.GetScreenshots(idStr)
|
return g.GetScreenshots(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetScreenshotsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
screenshots, err := g.GetScreenshots(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(screenshots[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
pb "github/bestnite/go-igdb/proto"
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
"github.com/bestnite/go-flaresolverr"
|
"github.com/bestnite/go-flaresolverr"
|
||||||
|
12
themes.go
12
themes.go
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetThemesByIDs(ids []uint64) ([]*pb.Theme, error) {
|
|||||||
|
|
||||||
return g.GetThemes(idStr)
|
return g.GetThemes(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetThemesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
themes, err := g.GetThemes(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(themes[0].Id), nil
|
||||||
|
}
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github/bestnite/go-igdb/endpoint"
|
"github.com/bestnite/go-igdb/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *igdb) ActiveWebhook(endpoint endpoint.Endpoint, secret, callbackUrl string) error {
|
func (g *igdb) ActiveWebhook(endpoint endpoint.Endpoint, secret, callbackUrl string) error {
|
||||||
|
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ func (g *igdb) GetWebsiteTypesByIDs(ids []uint64) ([]*pb.WebsiteType, error) {
|
|||||||
|
|
||||||
return g.GetWebsiteTypes(idStr)
|
return g.GetWebsiteTypes(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetWebsiteTypesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
websiteTypes, err := g.GetWebsiteTypes(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(websiteTypes[0].Id), nil
|
||||||
|
}
|
||||||
|
12
websites.go
12
websites.go
@ -2,9 +2,10 @@ package igdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
pb "github/bestnite/go-igdb/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -77,3 +78,12 @@ func (g *igdb) GetWebsitesByTypeIDs(ids []uint64) ([]*pb.Website, error) {
|
|||||||
|
|
||||||
return g.GetWebsites(idStr)
|
return g.GetWebsites(idStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *igdb) GetWebsitesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
websites, err := g.GetWebsites(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(websites[0].Id), nil
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user