Code Monkey home page Code Monkey logo

igdb-swift-api's People

Contributors

husnjak avatar lephyrius avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

igdb-swift-api's Issues

IGDBWrapper.apiRequest (Achievements?) crash

I just submitted an update to my app with this wrapper and seeing a few crashes, not sure where they're coming from.

This is all I'm getting from the Xcode crash report.

#3	(null) in closure #1 in IGDBWrapper.achievements(apiCalypse:result:errorResponse:) ()
#5	0x0000000104e8ac30 in closure #1 in IGDBWrapper.apiRequest(endpoint:apicalypseQuery:dataResponse:errorResponse:) at /Pods/IGDB-SWIFT-API/IGDB-SWIFT-API/Classes/Wrapper/IGDBWrapper.swift:24

Any ideas?
(I'm not using the achievements endpoint anywhere in my code so not sure why it's mentioning that?)

GAMES endpoint doesn't return proper image id

I am fetching the games list following the provided example

wrapper.apiProtoRequest(endpoint: .GAMES, apicalypseQuery: "fields *;", dataResponse: { bytes in
let games: [Proto_Game] = try! Proto_GameResult(serializedData: bytes) // This converts Binary to a struct
}, errorResponse: { error in
// Do Something
})

Then I want to find the image ids so I can use the imageBuilder function to get the urls but the resulting url is not a valid image url. The website uses cloudinary_id for urls but those ids are missing from the reponse of games endpoint.

IGDBWrapper.apiRequest crash

Same issue as before.

IGDB_SWIFT_API: closure #1 in IGDBWrapper.ageRatings(apiCalypse:result:errorResponse:) + 376

Now referencing the ageRatings function, though again I don't use this anywhere in my code. Possibly it's just the top function in the file?

Screenshot 2020-12-11 at 17 07 48

querying for a name containing "w" gives fatal error

this is my code:

let apicalypse = APICalypse()
    .fields(fields: "id,name,category") // Specify the fields you want to retrieve
    .where(query: "name = \"w\"") // Use the "where" clause to search by name
    .limit(value: 50)

// Make the API request to search for the game by name.
wrapper.games(apiCalypse: apicalypse, result: { games in
    // Handle the retrieved games here
    for game in games {
        if game.name.lowercased() == name.lowercased() {
            print(game)
        }
    }
}) { error in
    // Handle any errors that occur during the request
    print("Error searching for the game: \(error)")
}

whenever a lowercase 'w' is queried the following error is printed:

Error searching for the game: RequestException(statusCode: 400, url: "https://api.igdb.com/v4/games.pb", msg: "[\n  {\n    \"title\": \"Syntax Error\",\n    \"status\": 400\n  }\n]")
IGDB_SWIFT_API/ProtoRequest.swift:107: Fatal error: 'try!' expression unexpectedly raised an error: SwiftProtobuf.BinaryDecodingError.truncated
image

seems to me like the force unwrap being used in that function is the issue

similar to #10

maybe fixed in moritzscholz's fork where he fixes the force unwrap, still crashes for me though

Issue while loading entries from database

I am trying to use this package with example code, I ahve setup Access Token and ClientID, but this error is raised up everytime

Fatal error: 'try!' expression unexpectedly raised an error: SwiftProtobuf.BinaryDecodingError.truncated: file IGDB_SWIFT_API/ProtoRequest.swift, line 107

Swift 5?

I'm trying to build a quick app using Swift 5 and I can't get it working. Do you have any plans of upgrading it to the last version?

Thanks for your work!

About Pictures

Hello,
I couldn't fetch the photos. Is it possible to help me about this?
let apicalypse = APICalypse()
.fields(fields: "*")
.limit(value: 50)
.sort(field: "release_dates.date", order: .DESCENDING)
.where(query: "themes != 42")

    wrapper.games(apiCalypse: apicalypse, result: { games in
        for game in games {
            self.games.append(game)
            print(game.artworks.map({$0.url}))
            if game.hasCover {
                print("GAMEURL \(game.cover)")
            }
        }
        
        DispatchQueue.main.async {
            self.tableView.reloadData()
        }
    }) { error in
        print(error.localizedDescription as Any)
    }

Swift Package

Please consider the use of the Swift Package manager. It's such a breeze compared to Cocoa Pods.

Package Resolution Failed

I got a Package Resolution Failed message when try to import it to my new project. The Xcode version is 15.3.

Screenshot 2024-03-08 at 6 23 25 PM

Search and Image Builder works ?

Hi,

I'm trying to use this wrapper but I'm not sure if I'm in right way ...

        let wrapper: IGDBWrapper = IGDBWrapper()
        wrapper.userKey = SecretConstants.tokenIGDB
        
        let params: APICalypse = APICalypse()
            .search(searchQuery: "Halo")
            .fields(fields: "*")
            .sort(field: "release_dates.date", order: .DESCENDING)

        wrapper.search(apiCalypse: params, result: { searchGames in
            let games = searchGames.map { $0.game }
            return completionHandler(games, nil)
        }) { error in
            return completionHandler(nil, "IGDB: Error parsing API")
        }

I have a crash here in your code:

    public func search(apiCalypse: APICalypse, result: @escaping ([Proto_Search]) -> (Void), errorResponse: @escaping (RequestException) -> (Void)) {
        apiRequest(endpoint: .SEARCH, apicalypseQuery: apiCalypse.buildQuery(), dataResponse: { bytes -> (Void) in
            let objects = try! Proto_SearchResult(serializedData: bytes).searches
            result(objects)
        }, errorResponse: errorResponse)
    }

In the try! : Thread 13: Fatal error: 'try!' expression unexpectedly raised an error: SwiftProtobuf.BinaryDecodingError.malformedProtobuf

So I can't make a proper search

And if I use games instead a search I'm getting some results but I can't have any cover for games or screenshots:

         if let hasCover = gameUpdate?.hasCover, hasCover, let cover = gameUpdate?.cover {
            let imageURL = imageBuilder(imageID: cover.imageID, size: .HD, imageType: .PNG)
            print(imageURL) // "https://images.igdb.com/igdb/image/upload/t_720p/.png"
            print(cover.imageID) // ""
        }

Do you have any ideas ?
Thank you

Total Number of results /count

I noticed that I can make a call to https://api.igdb.com/v4/games/count and get the total Number of results.
Is this supported currently? I'm trying to make a pagination using the offset.

Also, thanks for this great wrapper!

Add Image builder

It is hard to handle image urls and image sizes.
I should create a function that builds the urls for me

example code:

func fetchImages( for imagePref : ImagePref, doubleSize : Bool ,  image : UIImageView, _ url : String) {
        var urlBase : String = ""

        switch imagePref {
        case .cover_small :
            urlBase = "cover_small"
        case .screenshot_med :
            urlBase = "screenshot_med"
        case .cover_big :
            urlBase = "cover_big"
        case .logo_med :
            urlBase = "logo_med"
        case .screenshot_big :
            urlBase = "screenshot_big"
        case .screenshot_huge :
            urlBase = "screenshothuge"
        case .thumb :
            urlBase = "thumb"
        case .micro :
            urlBase = "micro"
        case .hd :
            urlBase = "720p"
        case .fullHd :
            urlBase = "1080p"
        }

        if doubleSize {
            let url = URL(string: "https://images.igdb.com/igdb/image/upload/t(urlBase)2x/(url).jpg")
            gameImage.kf.setImage(with: url)

        } else {
            let url = URL(string: "https://images.igdb.com/igdb/image/upload/t(urlBase)/(url).jpg")
            gameImage.kf.setImage(with: url)
        }
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.