m-TAGS component (foo_tags)
2012-09-24 03:51:08
m-TAGS (foo_tags) I created this for my own use. I am sharing it because if I have a need for it, maybe someone else does too.... The m-TAGS format offers a simple yet powerful solution to the media-metadata separation problem, which impacts the efficience of digital music collections and media distribution services alike. An m-TAGS file is media-independent. It just contains metadata (tags) describing a certain media source and a locator which identifies the source to which the metadata applies. The format of an m-TAGS file is very simple. Each tag is represented by a pair "<tag name>" : "<tag value>" , with the special "@" tag containing the location of the media resource. This format allows the defininion of any tag name and the assignment of any value to a tag. Support for multivalued tags is included, as well as for multi-part media indexing. Download the component on the foobar2000 website (http://www.foobar2000.org ) or here: http://m-tags.org/foo_tags.zip For additional information and technical details please visit http://m-tags.org Usage For a first "taste" of how the m-TAGS mechanism works, select File / m-TAGS / Create m-TAGS (in same folder) from the main menu. Then browse to a folder where you have some audio files and press OK . A new file will be created in your folder, named !.tags . If you open this file with any text editor, you will see that it contains the metadata of your audio files in plain text. You can edit the metadata directly if you wish. If you drop the file into a foobar2000 playlist, it looks like your audio files are loaded into the playlist, just as if you had dropped a playlist file. However, if you look at the properties of the playlist entries, you will notice that the !.tags file was loaded instead. Your audio files will play normally, but any changes to the metadata will be reflected in the !.tags file, and NOT in the audio files. As long as you use m-TAGS files to load your music into foobar2000, your audio files will play normally, but they never be touched by foobar2000. They will be treated as "read-only" audio sources. Even the replaygain tags will be read and written from / to the !.tags file.Note: keep in mind that also all move / copy / delete file operations will be performed on the m-TAGS files! Notes (mostly generated by feedback): 1. The component will generate UTF-8 files. It will still be able to read non-UTF-8 files. 2. You can change the default name for multi-reference m-TAGS file from "!" to another name (Preferences / Advanced / Tagging / m-TAGS / m-TAGS creator). 3. There is an option to always write all tags for each media source, without implementing the "cascading" optimization. It may simplify scripting on m-TAGS files (Preferences / Advanced / Tagging / m-TAGS / m-TAGS creator). 4. there is a command line option to create m-TAGS files "in-place" given a certain folder. It behaves exactly as if the provided folder had been selected using "File / m-TAGS / Create m-TAGS (in same folder)". The syntax is:foobar2000 /m-TAGS <folder> If you know how to create a shell context-menu script, then you can use the above command to "m-TAG" on the fly a folder and all subdirs from within Windows Explorer. Obviously, fb2k will start if it is not open. However, if you usefoobar2000 /quiet /m-TAGS <folder> then you can "m-TAG" your folders without opening fb2k's main window. ---------------------------------------------------------------------------------------- Version 1.0 now available. Main upgrades are: 1) you can now write the tags from an m-TAGS file back to the media files; 2) m-TAGS will not attempt anymore to automatically load technical information from remote media files (i.e. URI's); 3) a new predefined tag "DURATION" allows to specify the duration of a track when technical information is not automatically loaded (it is ignored otherwise); 4) a new advanced setting option was added for the m-TAGS creator to retain media file extensions (i.e. scanning "track.mp3" will generate a "track.mp3.tags" file, rather than a "track.tags" file). ---------------------------------------------------------------------------------------- Version 1.02 fixes some issues with archived (zip/rar) files. ---------------------------------------------------------------------------------------- Version 1.03 adds the ability to edit durations as a regular tag ("%DURATION%"), and fixes a small glitch regarding local vs. remote locators ----------------------------------------------------------------------------------------- Version 1.1 adds a few significant features: 1) m-TAGS files now encapsulate album art data. They reflect album art data present in the media file, and allow editing of the album art, but, abiding to m-TAGS philosophy, the album art is NOT inserted/removed into the media file until explicitely requested via the Tagging/Write m-TAGS to media files menu command. Album art is kept in binary files located in the folder where the m-TAGS file is. 2) "Pure" m-TAGS files are now supported. These are files without locators. They do not encapsulate any playable media, but they can be used by other input components to store metadata without having to write a specialized mechanism. All metadata i/o (including album art data i/o) can be deferred to the m-TAGS component. An instance of the input component may be obtained by simply calling input_entry::g_open_for_info_read(p_info_read_instance, NULL, <path to m-TAGS file>, p_abort) or input_entry::g_open_for_info_write(p_info_write_instance, NULL, <path to m-TAGS file>, p_abort). The extension for a pure m-TAGS file is ".mtags". Note that you must obtain an m-TAGS input instance to load/save tags from/into an ".mtags" file using fb2k's SDK, because these files will NOT be recognized as media files (as they are not, indeed media files, nor files encapsulating media). As such, they will be trated in a playlist context just like any other non-recognized file. When you use fb2k SDK calls, you MUST append an asterisk to the file path, because the pseudo-extension ".mtags*" IS recognized by the m-TAGS input component, while ".mtags" IS NOT (as previously explained). For example, if you want to store your metadata in a file named "C:/Music/My Album/album.mtags" then you can obtain an m-TAGS I/O instance by calling input_entry::g_open_for_info_write(p_info_write_instance, NULL, "C:/Music/My Album/album.mtags*", p_abort). Similarly, you can obtain an album art editor for the same file by calling album_art_editor::g_get_interface(p_album_art_editor, "C:/Music/My Album/album.mtags*"). 3) Input instances and album art editors may be opened for files which do not exist yet. In such case, m-TAGS automatically creates an empty, single-tracked m-TAGS component, and the file is only created if tags are edited and committed. This way, there is no need to physically create a pure m-TAGS file until it is actually needed (i.e. until tags are edited by the user or tags are insterted by the calling input component and a commit requested). This mechanism is expecially useful when writing input components which offer support for network URI's. Developers may concentrate on connection and decoding issues, leaving m-TAGS to carry out metadata and album art I/O operations on pure m-TAGS files stored in a designated folder. These files could be indexed so that if a network URI is loaded again, the metadata is automatically loaded. ----------------------------------------------------------------------------------------- Version 1.12 fixes a few nasty issues. Thanks a million to WilB and RiCON for the unvaluable help. Version 1.1 and 1.11 are deprecated. Please upgrade. ------------------------------------------------------------------------------------------ Version 1.13 fixes a nasty bug in the JSON parser which made the component crash foobar2000 on windows XP. Many many thanks to Nisto for his cooperation and his patience. Also, this version supports transcoding of streamed media.