How to keep an up to date JSON file of all metadata in my library?

This is more of a general question, but I will be doing this for music metadata so it would be a little easier for me to explain.

Basically, I want a JSON file of all metadata in my library. Any time I make a change to metadata to any of the tracks (add/remove track, change artist, add producer, etc), I want this to update and reflect in my JSON accordingly.

From what I understand there is an export option, but I want to keep a file that is always in sync with the current metadata.

How can I make this as automated as possible?

P.S. I know mp3tag does not have anything like this built in. I am asking for any solution.

I know that there is no other data interface to other applications than the export.
The export has to be triggered by the user and usually only takes into account the currently selected files.
So I think that you would have to re-write your json export in regular intervals.
I would like to point out that changes to tag data or to the extent how many files are listed in such a file not only originate in MP3tag but can also be effected by other programs like e.g. the Explorer with which I simply delete a file.
Looking at other programs like WMP or iTunes which have their own library, then I see that the update of that library is far from automatic. Esp. in iTunes you have to delete entries manually and trigger the update of existing files either manually or by script. Adding files to iTunes also has to be triggered by the user.
So I doubt that there is an out-of-the-box solution for your requirements.

Theoretically, you could use tools to watch all your songs for changes.
If such a change is detected, your tools re-create your JSON.

The problem: There is no such ready to use tool AFAIK. You have to code it yourself.

Why do you need to have your JSON in sync with the metadata inside your songs?
You could use a tool like MediaMonkey watching over all your songs and importing every change in his own SQLite database automatically. Without JSON. But again: It depends why you use JSON at all.

Thanks @ohrenkino and @LyricsLover for the responses. Here’s a little more information.

I plan on using a Firebase database to store up to date metadata about my music library. Firebase databases are stored as JSON objects which is why I was talking about JSONs specifically.

So it’s not like I just want a JSON tree of current metadata in my documents just to have; I plan on using it as part of a Firebase database so I can access the most current information at any given time.

As far as coding goes, I have the background so let me know what needs to be done in that regard if need be.

Hopefully the next question isn’t “why would you want a Firebase database of metadata of your music library” :grinning: ... that’s just a hard requirement

thanks all, and let me know if clarification is needed on anything

I think I gave up to question the motives why some particular implementation seems to be mandatory.
I can only tell you the way it is: MP3tag usually relies on user input to "do" something. So there is nothing automatism spreading data to other locations.
I would think that it would be up to the database application to run some kind of listener that detects changes to the watched folders and/or files and then read the data from the tags and update the database.
So if you expect MP3tag to take an active role in this setup I doubt that this will go beyond the already existing export scripts.

correct, this is not about mp3tag specifically. like i said in the original post this is a more general thing which happened to be related to music metadata. perhaps i should post on a more relevant forum. not a problem if you give up as you stated, thanks for your time!

I created an export script will put all selected files in a huge JSON.
Path is the first attribute of each object then all tags are listed.
Careful! each json object has very likely different components/order.
You can use a tool to convert json to csv/excel.
--List of tagsUsed (Json).mte (2.0 KB)
enjoy.

if i wanted to do something like this my first try would be the following

  1. script ffprobe to run through my library and save the metadata for each song to a separate json file (can save in json format natively) - so you can have a file per song - i guess this is what your db needs.
    Or to a single file or what ever you need.

  2. if you need it to pick up changes in real time - than use inotify (part of .netcore) to inform a service to run you script again or run a scheduled task every x minutes/hours to pick up your changes

I created an export script will put all selected files in a huge JSON.

this seems to work nice, but how can i go about automating this? can i run this script without opening mp3tag? automatically when metadata is updated and rewrite the json file?

(also, IDK if this is your script or something else, but the same tag in different files seem to have differing capitalization. so say song 1 will say "TITLE": "song" and song 2 will say "title": "song", even though all songs have the tag as TITLE)

if you need it to pick up changes in real time - than use inotify (part of .netcore) to inform a service to run you script again or run a scheduled task every x minutes/hours to pick up your changes

  • i am on windows 10, my fault for not stating that in the OP
  • out of curiosity though, this can automatically run the script again when i edit a file in mp3tag with no other manual work?

.notify works in win10

thats the idea - .inotify will notice a file change (and report it - with a delay of say 30-60 seconds that you can set) so if you monitor for that notification then you can run further code to update you db etc etc

once you have it working it will be automatic as long as your monitoring code is running

I it not possible to export a separate (json) file per file.
Per directory it is feasible for sure.
Maybe the JSON extract combines all json files per directory and then you split them (you can surely automate it). Or have a look at splitter thread below.