Closed glawler closed 9 years ago
Here's the URL: https://boardgamegeek.com/xmlapi2/search?exact=1&query=illuminati and the returned XML:
<items total="2" termsofuse="http://boardgamegeek.com/xmlapi/termsofuse">
<item type="boardgame" id="859">
<name type="primary" value="Illuminati"/>
<yearpublished value="1982"/>
</item>
<item type="boardgame" id="17687">
<name type="alternate" value="Illuminati"/>
<yearpublished value="2005"/>
</item>
</items>
The library should probably check against primary name if it has a choice of two or more entries.
Another suggestion I've heard is to sort the games by rank if the exact search returns more than one as that's usually the one people want.
Looks like the problem is that when the library does an exact search, it assumes only one response, which is usually the case, but not always.
Can you check out the latest release? I added a few features that might help you:
-i
if you want to get game info using the id instead of game nameWhen there are more games with the same name:
--most-recent
used in combination with -g
will return information about the most recently published game--most-popular
used in combination with -g
will return information about the most popular (by rank) gameThe default behaviour is --most-recent
(since --most-popular
could require more API calls and it'd be slower).
Let me know how this works out for you.
I'm using the boardgamegeek.game() API though and not the command line. I was just using the command line as an example. Is it possible to add those arguments to the game() call as parameters?
Oh, I thought your problem was with the command line tool.
Of course it's possible to add extra parameters to game()
, but I'm not convinced it's a good idea :-/ I'll have to think about it.
For most cases, the function performs ok as it is, as there are not many games with the same name. But when there are, which does the user want? Highest BGG rank might be the right one for most use cases, but certainly not all, and that would mean implementing a bunch of parameters for game()
for all possible behaviours. If "best rank" wasn't costly to implement (extra API calls), I'd be ok with it, but with the extra calls, I don't know...
In the mean while, you can use the a piece of code like https://github.com/lcosmin/boardgamegeek/blob/master/boardgamegeek/main.py#L103 to get the behaviour you want.
If you won't put it in that's fine. I'll just have to put it in my code as that's the behavior I need. It seems to me that having the extra code in the library at the cost of library complexity makes more sense than having library users all implement the same thing, but I can understand if you want to keep the API clean.
I can also make the argument that the most popular, by definition!, is usually the game that people are after. :)
Can you give the develop
branch a try? I added a parameter choose
to game()
. When dealing with multiple games with the same name, you can use it to determine which one is used.
"first"
- the first result, as returned by the api (default, for the time being)"recent"
- the most recent game, according to the year of publishing"best-rank"
- the best rankReleased in 0.13.0
Does not return the first in the list at BGG, game 859. It returns game 17687, which is only connected to the game "Illuminati" because that is listed as one of it's alternate names.