Python script to export frames by tag

Hi there,

I’m working on a Python script to export individual frames into individual folders.
I managed to get the files in their respective folder, but I am having trouble getting the name right.
I would like each frame to be named after the tag they are in :

I can’t find a way to get this result.

I’m using python to have a nice UI to work with (this tool will be use daily for months).