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: AutoWrite a value in a "parent" tag depending on the "child" value: possible? (Read 3069 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

AutoWrite a value in a "parent" tag depending on the "child" value: possible?

Example: is it possible to automatically add a "Jazz" value to the %parent_genre% tag
whenever one adds the value "Hard bop" to a %child_genre% tag so that I don't have
to go and manually add the value in the parent too?

The tags can be written in the files or in a DB. In this last case it would be useful
being able to manually copy the DB values into the files in bulk.

Thanks.

Re: AutoWrite a value in a "parent" tag depending on the "child" value: possible?

Reply #1
So you want one field to be automatically filled based on the value used in a different tag?
You can do that but not directly and it requires a system and a masstagger script. I do this myself but It's going to require some explaining.
First thing to do is to have all genres in one tag arranged from most detailed to most broad (child to parent):
Hard Bop/ Jazz (I call this tag GENRE_STRING). It doesn't have to be in this order, it's just the way I do it.
note this field is an autocomplete field so this makes it if you start typing "Ha.." every genre present in your library starting with that will be given. See image

Masstagger component can then split up this GENRE_STRING into a multivalue tag and then assign each seperate value to a specific field. I can share my script if you're interested. You can also choose to keep the multivalue version tag of this GENRE_STRING or have it removed by masstagger within the series of actions performed within the script.
Why not use a multivalue field to autocomplete from the start and avoid this masstagger thing you say? The reason here is because using autocomplete on a multivalue doesn't fill in the entire series of values but merely one value within the multi value tag so you'd be seeing "Hard Bop" and not "Hard Bop; Jazz".

Re: AutoWrite a value in a "parent" tag depending on the "child" value: possible?

Reply #2
Thanks for your answer.

Yes, one can setup the genre_string with index values for the different levels:
(reversing the order you use) 1.Jazz; 2.Hard bop; 2.Vocal jazz.
Do you know if with a masstagger script it could be possible to fill a multivalue %genre%
with the value(s) indexed with 1 and %subgenre% with the value(s) with the index 2,
and so on, if you want to use a three level system?

But IMHO relying on autocomplete would not be good.
With the use of multivalues you can end up with a lot
of different strings where a long section from the beginning
is the same and in this case you will have to write most part
of the string before you can pick up a string from autocomplete list.

The best solution would be having a component that
let you build a table with the associations between
the different levels strings, so you could define the
parent value for each child value.
A few examples:

finest detailcoarser detail
subgenregenre
Hard bopJazz
Vocal jazzJazz
VocaleseJazz
SwingJazz
Vocal popPop
Singer songwriter rockRock
So if I put "Swing; Vocal pop" into %subgenre%, the system should
fill %genre% with "Jazz; Pop", the parents of the two children.

Maybe it's a bit overkill...
but as the relation between each detailed level and it's corse value is rigid,
it could be automated.

Thanks.

Re: AutoWrite a value in a "parent" tag depending on the "child" value: possible?

Reply #3
But IMHO relying on autocomplete would not be good.
With the use of multivalues you can end up with a lot
of different strings where a long section from the beginning
is the same and in this case you will have to write most part
of the string before you can pick up a string from autocomplete list.

I guess that depends on your approach on organizing genres. It seems by your example Hard bop, vocal jazz, jazz you make it random while I adhere to strict ordering just like RYM does it (while I do sometimes use  some parallel subgenre jumping such as Pop-Rock/ Pop and Pop-Rock/ Rock, same subgenre, different main genre). Hard Bop/ Jazz would always be Hard Bop/ Jazz with me. Vocal Jazz has nothing to do with Bop music imho so I don't mix those. But I guess if you reason Vocal Bop music is at the same time Vocal Jazz and Bebop than yes hard bop/ vocal jazz/ jazz would be valid (but then you'd also sit with the difficulty of order variance which not something I have to worry about). Random is more flexible but like this my system isn't as effective and not as interesting to you.

So, in short, have rigid order and then you'd have the advantage of autocomplete picker to choose your strictly ordered strings, if you don't want to use rigid order then autocomplete is less effective and probably not worth the trouble (too many options as you said).

You can try my masstagger script and see what it does. Create a field named %GL_STRING% and fill it like this: Hard Bop/ Vocal Jazz/ Jazz
It will assign Hard Bop to field %GL3%, Vocal Jazz to %genre% and Jazz to %style%. It will also create a multivalue field named %GL_ARRAY%. If you don't want that it's easy to set a remove field action as the last action within the masstagger script to remove the multi value field.

I use 4 levels of genres so if you want you can fill in a fourth genre in %GL_STRING% it will assign the first to %GL4% if not it will not fill it in, the same goes for %GL3% However the script expects there to be a at least 2 genres in %GL_STRING%.
Btw, just in case it wasn't clear, you'll be needing the foo_masstagger component.

Re: AutoWrite a value in a "parent" tag depending on the "child" value: possible?

Reply #4
Example: is it possible to automatically add a "Jazz" value to the %parent_genre% tag
whenever one adds the value "Hard bop" to a %child_genre% tag so that I don't have
to go and manually add the value in the parent too?

That's also possible with masstagger but requires a formatting action for each possible value.

Format field %parent_genre%
Code: [Select]
$if($strcmp(%child_genre%,Hard Bop),Jazz,)

You can extend with $or to include other genres where the parent should be jazz
Additionally you can make an autoplaylist %parent_genre% MISSSING and just run the script on whatever pops up in that playlist.


Re: AutoWrite a value in a "parent" tag depending on the "child" value: possible?

Reply #5
Example: is it possible to automatically add a "Jazz" value to the %parent_genre% tag
whenever one adds the value "Hard bop" to a %child_genre% tag so that I don't have
to go and manually add the value in the parent too?

The system I set up with foo_customdb, as explained here, does exactly that.


The best solution would be having a component that
let you build a table with the associations between
the different levels strings, so you could define the
parent value for each child value.
A few examples:

finest detailcoarser detail
subgenregenre
Hard bopJazz
Vocal jazzJazz
VocaleseJazz
SwingJazz
Vocal popPop
Singer songwriter rockRock
So if I put "Swing; Vocal pop" into %subgenre%, the system should
fill %genre% with "Jazz; Pop", the parents of the two children.

Maybe it's a bit overkill...
but as the relation between each detailed level and it's corse value is rigid,
it could be automated.

Thanks.

Take a look at the attached pic: it's the first rows of the quicktag table where foo_customdb stores the values of my genre-tree. foo_customdb looks up the "url" and when it matches the key of the "fieldname" it returns "value" in the "fieldname" virtual tag.
I'm late

Re: AutoWrite a value in a "parent" tag depending on the "child" value: possible?

Reply #6
That's also possible with masstagger but requires a formatting action for each possible value.

That's why a lookout table would be welcome.


@davideleo
As you know I created your system but couldn't see it working for me
so please be patient and help me adapt it to my exixting tagging starting
from scratch.

I have a %genre% field with the "coarser" level and a %sunbgenre% for the finer one.
Both are multivalue.

Let's take Ella Fitzgerald's rendition of "Honeysuckle Rose" backed by Count Basie orchestra.
To me this is undoubtedly Swing and Vocal jazz, at least, so I tagged it like this:
%genre% = Jazz
%subgenre% = Swing; Vocal jazz

My goal is to be able to add Swing and Vocal jazz to the %subgenre% field
and having automatically filled the %genre% field with Jazz.

Will your system do that (or something like that but on customdb fields instead of %genre%)?

Thanks.

Re: AutoWrite a value in a "parent" tag depending on the "child" value: possible?

Reply #7
@davideleo How would such a system deal with crossover genre that run parallel? For example Singer-Songwriter as secondary which can be under parent Country or Rock or Pop or even Folk? Or Boogie which falls either under RnB or Dance (in the form of Disco). There are some other that come to mind such as Pop-Rock or Fusion forms of music.

Re: AutoWrite a value in a "parent" tag depending on the "child" value: possible?

Reply #8
My goal is to be able to add Swing and Vocal jazz to the %subgenre% field
and having automatically filled the %genre% field with Jazz.

Will your system do that (or something like that but on customdb fields instead of %genre%)?

Yes!
foo_customdb doesn't edit existing metadata, but rather returns calculated values, like in a SQL query. So, sticking to your example, you should set the subgenre field as the key value for the virtual field "genre". Whenever you enter a value in the subgenre field, the custom database component will look it up in its recordset and return the corresponding genre value, which will be available in titleformatting expressions, despite not being a real ID3 field.
Of course foo_customdb will only be able to do this if there is a corresponding genre value. The custom database actions you set up, are nothing but commands for adding and editing records to the custom database recordset from within foobar2000 (if you have sqlite studio installed, you can actually view and edit the "quicktag" table in the customdb_sqlite db file, which is in the main foobar2000 directory).
As far as I understand (correct me if I'm wrong) you skipped this last step: you set up the custom fields and the related actions, but never entered any value in the recordset. That's why it doesn't seem to work.
The only drawback, concerning your example, is that as far as I know foo_customdb cannot split values in the key field. So, if you have multiple subgenres, you will have to choose one with the $meta function.
I'm late

Re: AutoWrite a value in a "parent" tag depending on the "child" value: possible?

Reply #9
@davideleo How would such a system deal with crossover genre that run parallel? For example Singer-Songwriter as secondary which can be under parent Country or Rock or Pop or even Folk? Or Boogie which falls either under RnB or Dance (in the form of Disco). There are some other that come to mind such as Pop-Rock or Fusion forms of music.

Well, my system cannot handle overlapping categories like yours does. I actually thought about this issue before adopting the system, but I chose referential integrity over fuzzy categorization.
Honestly I don't believe there should be any overlaps in music genre classification. I'm always able to make a choice (e.g. in my tree, singer-songrwriter is under pop and I don't use the boogie tag, usually replaced by electro, which is under r&b) and when I'm not, it means I need to readjust my music genre definitions.
I'm late

Re: AutoWrite a value in a "parent" tag depending on the "child" value: possible?

Reply #10
I really like your system, it's the more efficient route. But some few core concerns, this being one of them and extra dependency on a component, stop me from switching up.

Re: AutoWrite a value in a "parent" tag depending on the "child" value: possible?

Reply #11
I really like your system, it's the more efficient route. But some few core concerns, this being one of them and extra dependency on a component, stop me from switching up.

Astonishingly, foo_customdb was not thought for this kind of use, but mainly for storing metadata without editing the file. I guess a new component, explicitly focused on one-to-many relationships only, could handle those issues. If I ever learned C++, this would be my first project.
I'm late

Re: AutoWrite a value in a "parent" tag depending on the "child" value: possible?

Reply #12
The only drawback, concerning your example, is that as far as I know foo_customdb cannot split values in the key field. So, if you have multiple subgenres, you will have to choose one with the $meta function.
Thanks for you help. Things are starting to work, now.
I downloaded DB Browser for SQLite so now I can see the quicktag table.
I also tried to export it, edit it with Excel and then re-import it and I could see it works
so things could get easier.

Now my only concern is about multivalues.

Do you know if it is possible to use something like this in the key field?
$meta(subgenre, 0) OR $meta(subgenre, 1) OR $meta(subgenre, 2) OR $meta(subgenre, 3)

Or it is a formatting field and not a filtering one?

Thanks.

Re: AutoWrite a value in a "parent" tag depending on the "child" value: possible?

Reply #13
Now my only concern is about multivalues.

Do you know if it is possible to use something like this in the key field?
$meta(subgenre, 0) OR $meta(subgenre, 1) OR $meta(subgenre, 2) OR $meta(subgenre, 3)

Or it is a formatting field and not a filtering one?

No query syntax, titleformatting only.
I'm late

Re: AutoWrite a value in a "parent" tag depending on the "child" value: possible?

Reply #14
After some testing, I see I can get the single values with $meta(subgenre,0-3) so I setup four fields:

display: genre_family_1
name: GENRE_FAMILY_1
key: $meta(subgenre,0) (custom option)


display: genre_family_2
name: GENRE_FAMILY_2
key: $meta(subgenre,1) (custom option)


display: genre_family_3
name: GENRE_FAMILY_3
key: $meta(subgenre,2) (custom option)


display: genre_family_4
name: GENRE_FAMILY_4
key: $meta(subgenre,3) (custom option)

and four actions:

Display: remap genre 1
Field: genre_family_1
Update: ContextMenu -> Dialog
Set value: (leave this blank)

Display: remap genre 2
Field: genre_family_2
Update: ContextMenu -> Dialog
Set value: (leave this blank)

Display: remap genre 3
Field: genre_family_3
Update: ContextMenu -> Dialog
Set value: (leave this blank)

Display: remap genre 4
Field: genre_family_4
Update: ContextMenu -> Dialog
Set value: (leave this blank)

After firing all of them, in the quicktag view I can see this:



Then I created these four fields:

display: genre_class_1
name: GENRE_CLASS
key: %genre_family_1%

display: genre_class_2
name: GENRE_CLASS
key: %genre_family_2%

display: genre_class_3
name: GENRE_CLASS
key: %genre_family_3%

display: genre_class_4
name: GENRE_CLASS
key: %genre_family_4%

and this actions:

Display: remap family 1
Field: genre_class
Update: ContextMenu -> Dialog
Set value: (leave this blank)

Display: remap family 2
Field: genre_class
Update: ContextMenu -> Dialog
Set value: (leave this blank)

Display: remap family 3
Field: genre_class
Update: ContextMenu -> Dialog
Set value: (leave this blank)

Display: remap family 4
Field: genre_class
Update: ContextMenu -> Dialog
Set value: (leave this blank)

in the hope I would be able to "add" to the genre_class field,
but after firing all of them with the values from "gc1" to "gc4", this is what I get:



Clearly, only the value from the last action gets stored into genre_class,
wiping out whatever there was before.

To me it seem a lost battle but if anybody have any suggestion on how to go on from here
in order to end up with a good management of a multivalues field it will be welcome.

Thanks.

 

Re: AutoWrite a value in a "parent" tag depending on the "child" value: possible?

Reply #15
Then I created these four [...] actions:

Display: remap family 1
Field: genre_class
Update: ContextMenu -> Dialog
Set value: (leave this blank)

Display: remap family 2
Field: genre_class
Update: ContextMenu -> Dialog
Set value: (leave this blank)

Display: remap family 3
Field: genre_class
Update: ContextMenu -> Dialog
Set value: (leave this blank)

Display: remap family 4
Field: genre_class
Update: ContextMenu -> Dialog
Set value: (leave this blank)

in the hope I would be able to "add" to the genre_class field,
but after firing all of them with the values from "gc1" to "gc4", this is what I get:



Clearly, only the value from the last action gets stored into genre_class,
wiping out whatever there was before.


I I never tested it, so have no idea if and how it works, but this is from the wiki:
Quote
Use # in front of field name to add new value, instead of replacing existing values.


I'm late

Re: AutoWrite a value in a "parent" tag depending on the "child" value: possible?

Reply #16
I tried with these four fields:

display: genre_class_1
name: GENRE_CLASS
key: #%genre_family_1%

display: genre_class_2
name: GENRE_CLASS
key: #%genre_family_2%

display: genre_class_3
name: GENRE_CLASS
key: #%genre_family_3%

display: genre_class_4
name: GENRE_CLASS
key: #%genre_family_4%

but after firing all of them, puttin in values from gc1 to gc4 I end up with this:



When I fire genre_class_4 in the value pane I see the value I put there previously,
when I launched genre_class_3.

Do you know if is there any wiki of the actual foo_customdb?

Thanks.

Re: AutoWrite a value in a "parent" tag depending on the "child" value: possible?

Reply #17
Do you know if is there any wiki of the actual foo_customdb?
No, the one I linked is the closest we have. As far as I understood, foo_customdb is in fact a replacement of the foo_custominfo plug-in after this was outdated by a foobar2000 upgrade, but it works basically in the same way and I always relied on that wiki. Maybe someone who was here at the time knows better.
I spotted some inconsistency in your last post, though: the supposed four fields are actually one, you are using four different display names for the instructions, but the field name is always GENRE_CLASS and one field cannot have four different key values. I shall make some tests myself in the next days, because I'm really interested in your attempt, but I don't have the time right away,
I'm late

Re: AutoWrite a value in a "parent" tag depending on the "child" value: possible?

Reply #18
I did that because I don't see any other way to add different values to the SAME field.
Unless it is possible to add from many fields at once.

I will test something like the example in the wiki: field1|#field2|#field3|#field4
and then I will let you know.

Thanks.

Re: AutoWrite a value in a "parent" tag depending on the "child" value: possible?

Reply #19
I will test something like the example in the wiki: field1|#field2|#field3|#field4
and then I will let you know.

Did you come up with anything eventually? After some playing around I realized there's a broader issue upstream, due to the fact that - as I have said before - the foo_customdb component was not originally thought for one-to-many relationships. That is, even if you were able to merge into one field multiple genre families, each one of them would rely on a separate genre tree, thus breaking the referential integrity, which is the purpose of the whole setup.
I'm late

Re: AutoWrite a value in a "parent" tag depending on the "child" value: possible?

Reply #20
No, after some unsatisfying trials I gave up.
I wasn't able to get to any useful point and
I was spending too much time for a thing
not so high in my priority list.

I think the only way to be sure to get to a consistent
tagging and eventually to be able to get some of it
done automatically, would be to have globally a sort of "dictionaries"
fillable with the "legal" values for each tag and a central "manager"
where to define the rules and the relations between values in different fields.
Autocomplete should take the values from there, too.

Thanks.