MestreLion / humblebundle

API for managing Humble Bundle games library
GNU General Public License v3.0
211 stars 38 forks source link

Better matching of type is needed #3

Closed wolfgangkarall closed 9 years ago

wolfgangkarall commented 9 years ago

I can't choose to download 'PDF' if there's also 'PDF (HD)':

$ ./humblebundle --type 'PDF' -p ebook --download xkcdvolume0 -f /home/humbledownload/downloads/
2015-01-28 14:24:35,297 ERROR           Too many download candidates for 'xkcd: volume 0' [xkcdvolume0]. Improve criteria to narrow it down.
        'PDF'   35 MB   xkcd-volume0-low.pdf
        'PDF (HD)'      132.7 MB        xkcd-volume0-high.pdf
MestreLion commented 9 years ago

That happens because --type match types starting with the given string. Changing that behavior to an exact match would fix it, but I'm not sure if it's the best approach. Perhaps adding an --exact or --type-exact option? Any ideas?

wolfgangkarall commented 9 years ago

Yeah, doesn't have to be exact matching all the time. A --type-exact flag switch would be better I guess.

MestreLion commented 9 years ago

Yeah, looking at the source and at gamedata.json I realized it's a bit more tricky than I imagined. Current matching is not starting with but containing, which is far less strict. And the game data expect that in its download fields. Otherwise, a small change in how Humble Bundle labels their download buttons (say, from Download .deb to DEB version would break things.

Oh the other hand, an extra argument (say --type-exact) would make an already quite complex algorithm even move messy, not to mention it seems (well, it is) a lazy UI.

A 3rd option would be to successively try more restrictive rules (containing, starting with, is) if (and only if) the user specified a --type and there are too many candidates after exhausting all other rules.

While this may be the best option (user and compatibility wise), it is also quite complex and hard to implement, so I'm still open to suggestions .

MestreLion commented 9 years ago

3rd option done :) Wasn't as hard as I thought...

wolfgangkarall commented 9 years ago

Great! :+1: