Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: m-TAGS component (foo_tags) (Read 160768 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

Re: m-TAGS component (foo_tags)

Reply #325
PSA In case anyone else arrived at this component the same way I did: be warned that this component is not a solution for foobar losing/forgetting midi file tags (it even just makes it worse, in a way). Mtags can generate its manifest file from tagged midis perfectly, but using the "write tags back to media files" feature does nothing to 90% of the files and writes tags to the wrong files for the remaining 10%. Makes sense because mtags still relies on foobar's midi tag handling, so if the latter is error-prone then mtags on midi is just as error-prone.

Re: m-TAGS component (foo_tags)

Reply #326
If someone wants to implement database tagging properly for foo_midi, be my guest. It's not working properly at this point, and definitely does not support writing RIFF MIDI tags, either.

Re: m-TAGS component (foo_tags)

Reply #327
Oh. So back in 2014 I nagged the dev. about a write-back functionality, and with that missing I dropped everything about m-tags - just to find out now, that it was implemented in 2015. Well, my loss ... until now. I think I want this, but I could use a crash course:
* For files referenced by a tags file: how to make the media library see "only one copy"?
* Is there a way to quickly scan for orphans?

Re: m-TAGS component (foo_tags)

Reply #328
* For files referenced by a tags file: how to make the media library see "only one copy"?
* Is there a way to quickly scan for orphans?
1) You might be able to exclude mtagged files by giving them a filename pattern (like .mtag.<extension>) that you can exclude through foobar's library filtering settings (the option that says "*.mpc;*.ogg" as example). Or it might be possible to generate your mtag file, then move the audio files to a path outside your library and patch the paths in the mtag file accordingly. I don't think there's a pretty solution.
2) didn't come across any. Only option I see is to parse the json file and check for orphans with an external tool/script. Very basic job if you're already into that sort of work. Using per-file mtag files would make this easier since you wouldn't even need to parse the json, just check for incomplete pairs of files.

Disclaimer: I'm not a foo_mtag expert, just a guy who checked it out, tried to make it work for his needs, tested some use cases.

Re: m-TAGS component (foo_tags)

Reply #329
I think I have found a bug in the component.

I have some albums whose tracks are in separate FLAC files named as "[tracknumber] Title.flac"

As the square brackets are special JSON character, I understand I should escape them with \[ or \]. This works when escaping the quotation marks (\"), but when the square brackets are escaped, foobar2k hangs when adding the m-tags file.

According to the JSON specifications, these characters should be automatically escaped as long as they are inside a string (i.e. enclosed by quotation marks), but that's not the case with foo_tags. I've even tried escaping with unicode character codes (\u005b and \u005d for [ and ]), but foobar still couldn't see my tracks.

Can anyone confirm?

Re: m-TAGS component (foo_tags)

Reply #330
I think I have found a bug in the component.

I have some albums whose tracks are in separate FLAC files named as "[tracknumber] Title.flac"

As the square brackets are special JSON character, I understand I should escape them with \[ or \]. This works when escaping the quotation marks (\"), but when the square brackets are escaped, foobar2k hangs when adding the m-tags file.

According to the JSON specifications, these characters should be automatically escaped as long as they are inside a string (i.e. enclosed by quotation marks), but that's not the case with foo_tags. I've even tried escaping with unicode character codes (\u005b and \u005d for [ and ]), but foobar still couldn't see my tracks.

Can anyone confirm?


m-TAGS always uses forward slashes as the directory separator as far as I can tell, so I'm gonna assume you're manually creating your JSON files.

I don't think you're actually supposed to escape square brackets either. When I generate a .tags file from a source file with a custom tag containing an actual backslash character (\) followed by a square opening bracket ([), the output in the .tags file looks like so:

Code: [Select]
"TEST" : "test\\[01] title.flac"

Only the backslash character (directory separator) is escaped.

Re: m-TAGS component (foo_tags)

Reply #331
I wish it could show the codec of playlist item on Codec columns instead of TAGS. I also wish the SDK will be updated so its not shown as unnamed legacy decoders on Decoding preferences. Regards :)

Re: m-TAGS component (foo_tags)

Reply #332
Hi everybody,

Is there a way to access the M-TAGS "@" tag field from within foobar ?
I can see it in the Properties dialog ("Details" tab), but how can I access it, in a titleformat string / masstagger script / etc. ?

FYI I'm trying to display a file's filename. That filename is of course present in the M-TAGS "@" tag field.
But I can't just type %filename%, because if will display the filename of the M-TAGS file ("!"), which is of course useless.
So what must I type ? Thanks.

EDIT - the answer is $info(@). Maybe it could be added to the OP or something, so new users don't waste their time looking for it. :)

Re: m-TAGS component (foo_tags)

Reply #333
Another question :

Let's assume that foobar is configured in the "Media Libraty" section with "*.tags" as filter. So all that foobar has in its library are now the *.tags files, not the audio files themselves.

What if we change via Windows Explorer the filename of an audio file ? How can we have M-TAGS update the corresponding *.tags file to reflect the new filename ?

Re: m-TAGS component (foo_tags)

Reply #334
I have one wish to this plugin: from selection of physical files > context menu > Tagging > Create default m-TAGS file and replace content

This command works similar like Create m-TAGS file, but autosaves the m-TAGS file into same folder with physical files under predefined name (folder.mtags, album.mtags or similar, can be defined by user prefs), then removes the selection from playlist and replaces it by opening the saved mTAGS file in one step. Then all changes into tags (including embedded artwork) would be stored to mTAGS file and the physical files remain untouched. Is possible?

Re: m-TAGS component (foo_tags)

Reply #335
So how can we currently do to find orphans ? (.tags files that don't point to the right files anymore)

Re: m-TAGS component (foo_tags)

Reply #336
* For files referenced by a tags file: how to make the media library see "only one copy"?
I wanted to be able to edit both the media files and tags in the same layout, so instead of using the "restrict file types to only see .tags" option in fb2k preferences, I instead have two tabs in the layout - '♫ Library (Tags)' and '♪ Library (Files)' - and then filter the results for genre, artist, album artist, etc (I'm using Facets plug-in for that).

So under the '♫ Library (Tags)' tab, I have one instance of Facets -
Code: [Select]
Genre / Style : $if($strstr(%filename_ext%,.tags),%<genre>%)|$if($strstr(%filename_ext%,.tags),[%<style>%])
Artist : $if($strstr(%filename_ext%,.tags),$if3(%<artist>%,%<album artist>%,'('Unknown Artist')'))

Then under the '♪ Library (Files)' tab, I have a second instance of Facets using different columns -
Code: [Select]
Genre : $if($greater(%filesize%,100000),%<genre>%)
Album Artist : $if($greater(%filesize%,100000),$if3(%<album artist>%,%<artist>%,'('Unknown Artist')'))

I'm sure there is a more elegant way of filtering that last one (tag files not likely to be over 100000 bytes, whereas most media files would be), but hey it works!  ;) (I could never figure out how to get an $if NOT statement working)

* Is there a way to quickly scan for orphans?
So how can we currently do to find orphans ? (.tags files that don't point to the right files anymore)

No easy way that I can see. However I noticed if you have a %codec% column in your tags-based playlist, and if there is an orphaned track, it sometimes displays "TAGS" instead of the codec. And you can even search the library for it (%codec% HAS tags). But this only seems to happen on occasion and I'm not sure when - perhaps after the filenames have been changed with the usual right-click > File Operations > Rename (on my Files tab above). Following that, you can right-click > Open Containing Folder, and open the .tags file in Wordpad to edit in the correct filename for that track. (Which I find is faster than making a new .tags file, because I keep my media files to only the basic tags)

Hope that helps 8)


Re: m-TAGS component (foo_tags)

Reply #337
Maybe somebody with the right skills could write a script that would :
- Scan recursively a directory for .tags files
- Scan every .tags file for all the "@" fields
- Look for the corresponding media files in the same directory as the .tags file
- If a given media file seems to be missing (either because it has been deleted or because its physical name has been changed), just add its path to a log that will be produced at the end of the scan

If only somebody could achieve this... :)

Re: m-TAGS component (foo_tags)

Reply #338
Hello!

I have a problem with streams. Tags are not displayed dynamically. They are fixed by. that are written in the m-tag file. Is it possible to show the values from the file when the stream is not running and display tags from stream when it is launched?

Yes it is. I already responded to this, but, in order to save you time, here is how:

You have create a "shadow" set of tags. For example, if the TITLE metadata is subject to change dynamically, do NOT create an m-TAGS file with that tag. Rather, use something like DEFAULT_TITLE (it could be the station name). Then use $if2(%TITLE%,%DEFAULT_TITLE%) to display the dynamic information when available and the m-TAGS value when not. If you use ColumnsUI, for example, the above is what you would write in the Column/Display field. And don't forget to make DEFAULT_TITLE and not TITLE the Linked Meta Field for online editing!!!

Please note that dynamic technical tags (non-metadata tags, like dynamic bit rate, etc.) are always transparently relayed by m-TAGS.

Hello!

I have a problem with streams. Tags are not displayed dynamically. They are fixed by. that are written in the m-tag file. Is it possible to show the values from the file when the stream is not running and display tags from stream when it is launched?

@Semyon:
to the previous reply I would to addition
at Columns UI/Playlist view/Columns/Scripts/Display I made this script for column "Title" for display song name during playback from stream radio (for playlists created by m-TAGS):
$if($strcmp($right(%filename_ext%,5),.tags),$if(%isplaying%,%title%,$meta(default_title)),%title%)
you can try that.

Re: m-TAGS component (foo_tags)

Reply #339
What was changed ion version 1.2?

Re: m-TAGS component (foo_tags)

Reply #340
how did you find!?  :) 
I don't see new version if I try "Check for updated component" in fb2k.

Re: m-TAGS component (foo_tags)

Reply #341
There is indeed a 1.2 version, available through the official foobar components page.
But I see no changelog.
And foobar can't see the update via the "Check for updated components" option.

Re: m-TAGS component (foo_tags)

Reply #342
Question : how can we get the actual file size ?
%filesize% and %filesize_natural% don't seem to work well with M-TAGS.
Thanks.


Re: m-TAGS component (foo_tags)

Reply #344
Thanks Luigi for this awesome component! It is a perfect solution to a problem I gave up on solving many years ago. It's especially handy that the !.tags file is simply JSON, as this makes it easy to build other applications and scripts on top of it.

Maybe somebody with the right skills could write a script that would :
- Scan recursively a directory for .tags files
- Scan every .tags file for all the "@" fields
- Look for the corresponding media files in the same directory as the .tags file
- If a given media file seems to be missing (either because it has been deleted or because its physical name has been changed), just add its path to a log that will be produced at the end of the scan

I've done this – check out m-tags-find-orphans.ps1 (hopefully this is a convenient language, considering that foobar2000 is a Windows app, but since PowerShell supports UNC paths you can easily run it on a NAS with SMB). You will need jq installed and available on your $PATH to use this.

Code: [Select]
# Set this to $true if you want the script to print successfully-located
# files in green. Useful to check that the script is working properly,
# but will make it harder to figure out which files are broken.
$showLocatedFiles = $false

# Find all !.tags files in the folder hierarchy starting in the current directory.
ls -rec "!.tags" | % {
  # Save a reference to the parent directory of each !.tags file.
  $parent = $_.Directory
  # Extract the relative filenames of each source file.
  gc -literal $_ | jq -r '.[] | .\"@\"' | `
  # Turn these into full paths, and drop the | suffix for *.cue files.
  % {"$parent\$(($_ -split "\|")[0])"}} | `
  % {
    if (test-path -LiteralPath $_) {if ($showLocatedFiles) {write-host -ForegroundColor Green $_}}
    else {write-host -ForegroundColor Red $_}
}

Running this script revealed a few issues with the !.tags files generated by foo_tags, when accessing UTF-8 filenames over SMB (non-ASCII characters became ? in the !.tags file, which therefore contains orphaned entries). I'm going to try to stick to ASCII filenames from now on, unless I'm just using foo_tags incorrectly.

I also found that running foo_tags over a directory that contained both .flac and .cue files would produce duplicates, and that if there were any subdirectories containing no audio files at all (eg. cover art only), foo_tags would still generate a useless !.tags file which cluttered up my foobar2000 library. I've resolved these problems using the m-tags-edit-remove-non-flac.ps1 and m-tags-remove-where-no-flac.ps1 scripts, respectively.

Re: m-TAGS component (foo_tags)

Reply #345
Is foo_tags the only software that supports m-TAGS? (Also, can we just call them mtags?)

I'm happy with foobar2000 as my main player and tag editor, mtags as the metadata storage format, and using my own scripts to generate lossy files with embedded metadata based on the mtags for mobile devices. But some of these scripts are becoming quite complex, and I am wondering if I am reinventing the wheel.

I've added my mtags library to a git repository and I can see that some other people have put theirs on GitHub, which is neat. I've also seen this mtags sync script and somebody has requested that mtags support be implemented in DeaDBeeF. But that seems to be about it.

Some of the problems that mtags can solve can also be solved by using beets in read-only mode, where tag metadata is stored in beets' database. I am thinking about trying to add mtags support to beets, because it would be nice to be able to use beets' querying and auto-tagging features. But mtags' killer feature for me is its integration with foobar2000 – I'd have to come up with another way to get my metadata to appear in foobar2000 if I migrated to beets.

Alternatively, maybe I should look at developing an alternative to foo_tags that integrates with beets. I don't think the source to foo_tags is available and it would be a shame if Luigi stopped distributing it in the future. An alternative free software implementation might be good to have as a backup plan.

Re: m-TAGS component (foo_tags)

Reply #346
@sjy , have you seen the PM that I sent you a couple weeks ago ? Thanks.

Re: m-TAGS component (foo_tags)

Reply #347
Thanks to this plugin I finally could create a separate list for each radio.

As from video: https://www.youtube.com/watch?v=SwBhRqEeA6A

I have only one problem with the VHS Panel Biography, Albums, Similar and title artist info.

If I throw in an empty playlist an m3u, m3u8 etc... And I go in the panel Biography I have in real time also the cover of the artist that at that time the radio is airing.

With m-tags, unfortunately I can't get the same result.

Can you do something?

Re: m-TAGS component (foo_tags)

Reply #348
And I go in the panel Biography I have in real time also the cover of the artist that at that time the radio is airing. With m-tags, unfortunately I can't get the same result.
This works fine for me with m-TAGs tagged internet radio and the Biography 1.0.1 by WilB (for Spider Monkey Panel) - when there are dynamic title/artist updates, it shows biography and artist pictures. (Not album covers, but nor do I know a station that streams album titles).

So I think the problem is not m-TAGs. Make sure you have not tagged title/artist fields, otherwise they cannot be dynamic. ;)

Cheers

Re: m-TAGS component (foo_tags)

Reply #349
And I go in the panel Biography I have in real time also the cover of the artist that at that time the radio is airing. With m-tags, unfortunately I can't get the same result.
This works fine for me with m-TAGs tagged internet radio and the Biography 1.0.1 by WilB (for Spider Monkey Panel) - when there are dynamic title/artist updates, it shows biography and artist pictures. (Not album covers, but nor do I know a station that streams album titles).

So I think the problem is not m-TAGs. Make sure you have not tagged title/artist fields, otherwise they cannot be dynamic. ;)

Cheers

I managed to get a certain result, pairing the plugin m-tags + the plugin External tags and then doing wrap mode as from video:

https://youtu.be/nH43sB4Dpcw

But so I have a variety of radios and no longer divided individually as in the video:
https://www.youtube.com/watch?v=SwBhRqEeA6A

I haven't been able to find a single solution yet.