Announcing... the IFDB Tag Manipulator!

@FLACRabbit the JSON API is ready for use!

  • search?json
  • gametags?json
  • taggame is a bit different. Do not include ?xml in the query. It has to be a POST request with a JSON body with the parameters:
    {
       "id": "123",
       "username": "myuser",
       "password": "mypass",
       "tags": ["tag1", "tag2"]
    }
    

EDIT: the gametags API has been deprecated. You can now use the search API to filter tags for a game.

The viewgame API is now the easiest way to see the list of tags for a game, if all you want to see is the public tags. (It didn’t include tags before, but now it does.)

But I see that tm.py is using mine_only, and for that, you’d use the search API, like this:

https://ifdb.org/search?json&tag&searchfor=tuid:xxx+mine:yes

Note that you’ll need to perform Basic Authentication in order to login to the search API and have it recognize who “you” are.

Here’s a sample you can use.

import base64
u = 'https://ifdb.org/search?json&tag&searchfor=mine:yes'
r = urllib.request.Request(u)
base64string = base64.b64encode(bytes('%s:%s' % (username, password), 'ascii'))
r.add_header("Authorization", "Basic %s" % base64string.decode('ascii'))
r.add_header('user-agent', 'whatever')
handle = urllib.request.urlopen(r)
c = handle.read()
handle.close()
print(c)
1 Like

Sorry to keep wandering in here with problems, but I just realized that since the update, when the tag manipulator adds a tag to a game I’ve tagged in the past, it erases all my previous tags.

Thank you, EJoyce, for uncovering this bug.

Unfortunately, I am engaged on other time-critical projects at the moment, and I don’t have the time to continue adapting an open-source project to an API that, although stable for many years, is now apparently subject to major breaking changes without either advance warning or backwards compatibility. Maybe @salty-horse or another user is interested in ensuring that community-made tools continue to work with IFDB’s changing infrastructure?

For now, my recommendation would be to quit using the tool, as I can no longer guarantee that it will work correctly or even predictably. I may return to this project in the future.

1 Like

I understand—thanks for your efforts in creating this tool in the first place!

I can update the tag manipulator, if you wish. Should I post it to github?

Maybe the moral of this story is that bulk tagging should be a feature of IFDB itself.

Can you share the exact command you’ve used? I want to test it locally.

I’d prefer that you post updated versions on this forum thread, not GitHub. Anyway, I agree with dfabulich; having a similar capability integrated into IFDB itself would be a better and more sustainable solution.

tm_0.2.2.zip (5.5 KB)

Having it in a repository makes it easier to track changes.
Here’s what I did:

  • Changed tabs to spaces, and moved import to the top, to be closer to Python conventions.
  • Used built-in Python functions for building URLs.
  • Changed the APIs to the new ones, so got rid of the XML code. Backups are now in JSON.
  • Printing the exception if it happens when saving tags.

I noticed some weird errors that don’t affect anything. Searching for a TUID “abc” will say Warning: no game found with title "abc". But everything else will work fine.

It was just -st "<name of tag>" -at "<name of other tag>". (I did several rounds of bulk tagging before I noticed the problem, so I can say that the specific tags involved do not appear to matter.)

I just tested this with tm.py -st barbarian -at 'banana2' with the version I posted above, and it worked correctly.

It added the tag to the game where I already had other tags, keeping them intact.

1 Like

Yes, version 0.2.2 seems to be working as expected in this regard for me as well. Thanks!

1 Like