Welcome Guest

Pages: 1
Question about counting matching fields in UDTI
cpkPostMarch 12, 2015, 20:38
Advanced
Posts: 95
Registered:
March 1, 2015, 02:55
Normal topicQuestion about counting matching fields in UDTI

Hi,

So I wanted to write an action to change names of some fields by trimming off the MusicBrainz. The only problem I have though is that the only feature to match more than one field is the "Remove All". I can rerun the action repeatedly but I would need to know how many times to do that and I can't find a way to count number of matching UDTI fields or even be able to count number of UDTI fields period. I though maybe going into a list would be good but see no way to import UDTI into a list. Am I missing something or is this just not possible?

I would not be surprised if there is some good reasons to not do what I want to do, but since I'm not trying to alter or import into any database such as MusicBrainz and none of my apps use the MusicBrainz fields I figure there are just display fields anyway so why do I need them all to be prefixed with MusicBrainz?

Anyway, this is the action I have currently, it works, but only only once per execution.

Comment The purpose of this action is to remove the prefix "MusicBrainz" from all UD text fields.  It is case-insensitive and if removing the prefix results in an underscore, dash, or space leading the remaining text, it will also be trimmed.…

Export name of User Defined Text Item with prefix MusicBrainz (Case insensitive) to Variable0
Dump snapshot variables. Prompt Export name to V0
Export value of User Defined Text Item with prefix MusicBrainz (Case insensitive) to Variable1
Dump snapshot variables. Prompt Export value to V1
Find "MusicBrainz" ignoring case in Variable 0, remove it and everything before
Dump snapshot variables. Prompt Remove MusicBrainz substring.
Trim Variable 0 (Non A#) [Leading]
Dump snapshot variables. Prompt Trim leading non-alphanumeric characters.
Import name of User Defined Text Item  (Create) from Variable0
Import value of User Defined Text Item \V0 from Variable1
Remove User Defined Text Item with prefix MusicBrainz (Case insensitive)
cpkPostMarch 12, 2015, 21:16
Advanced
Posts: 95
Registered:
March 1, 2015, 02:55
Normal topicRe: Question about counting matching fields in UDTI

Well, I just discovered that the only loop that seems to exist is for iterating lists. I figured a way to work around the limitations and it is getting the job done in my quick tests but it sure is ugly. 🙁

Comment The purpose of this action is to remove the prefix "MusicBrainz" from all UD text fields.  It is case-insensitive and if removing the prefix results in an underscore, dash, or space leading the remaining text, it will also be trimmed.…

Export name of User Defined Text Item with prefix MusicBrainz (Case insensitive) to Variable0 (set state)
# Dump snapshot variables. Prompt Export name to V0 run1
if true
	Run inline action 'Modify'
	Export name of User Defined Text Item with prefix MusicBrainz (Case insensitive) to Variable0 (set state)
	# Dump snapshot variables. Prompt Export name to V0 run2
	if true
		Run inline action 'Modify'
		Export name of User Defined Text Item with prefix MusicBrainz (Case insensitive) to Variable0 (set state)
		# Dump snapshot variables. Prompt Export name to V0 run3
		if true
			Run inline action 'Modify'
			Export name of User Defined Text Item with prefix MusicBrainz (Case insensitive) to Variable0 (set state)
			if true
				Run inline action 'Modify'
				Export name of User Defined Text Item with prefix MusicBrainz (Case insensitive) to Variable0 (set state)
				if true
					Run inline action 'Modify'
					Export name of User Defined Text Item with prefix MusicBrainz (Case insensitive) to Variable0 (set state)
					if true
						Run inline action 'Modify'
						Export name of User Defined Text Item with prefix MusicBrainz (Case insensitive) to Variable0 (set state)
						if true
							Run inline action 'Modify'
							Export name of User Defined Text Item with prefix MusicBrainz (Case insensitive) to Variable0 (set state)
							if true
								Run inline action 'Modify'
								Export name of User Defined Text Item with prefix MusicBrainz (Case insensitive) to Variable0 (set state)
								if true
									Run inline action 'Modify'
									Export name of User Defined Text Item with prefix MusicBrainz (Case insensitive) to Variable0 (set state)
									if true
										Run inline action 'Modify'
										Export name of User Defined Text Item with prefix MusicBrainz (Case insensitive) to Variable0 (set state)
										if true
											Run inline action 'Modify'
											Export name of User Defined Text Item with prefix MusicBrainz (Case insensitive) to Variable0 (set state)
											if true
												Run inline action 'Modify'
											else
												Exit
											endif
										else
											Exit
										endif
									else
										Exit
									endif
								else
									Exit
								endif
							else
								Exit
							endif
						else
							Exit
						endif
					else
						Exit
					endif
				else
					Exit
				endif
			else
				Exit
			endif
		else
			Exit
		endif
	else
		Exit
	endif
else
	Exit
endif

Start Modify - This action does the actual UDTI name modification.
Export value of User Defined Text Item with prefix MusicBrainz (Case insensitive) to Variable1
# Dump snapshot variables. Prompt Export value to V1
Find "MusicBrainz" ignoring case in Variable 0, remove it and everything before
# Dump snapshot variables. Prompt Remove MusicBrainz substring.
Trim Variable 0 (Non A#) [Leading]
# Dump snapshot variables. Prompt Trim leading non-alphanumeric characters.
Import name of User Defined Text Item  (Create) from Variable0
Import value of User Defined Text Item \V0 from Variable1
Export name of User Defined Text Item with prefix MusicBrainz (Case insensitive) to Variable0 (set state)
Remove User Defined Text Item with prefix MusicBrainz (Case insensitive)
2MR2PostMarch 12, 2015, 21:17
Avatar photo
Administrator
Posts: 2085
Registered:
August 23, 2012, 19:27
Normal topicRe: Question about counting matching fields in UDTI

Just a point. If you do this you will lose the reference to the match in MusicBrainz and will have to search again if you want to get at the data in the db.

Oddly enough, the requested Artwork description stuff is partially implemented in a new function used to enumerate Artwork, UDTIs, UD URLs and Comments. This will allow you generate a list of all UDTIs which you can then pass into a Repeat With statement. In the called (inline) action you could do a User Defined statement changing the name of any key starting with MusicBrainz by importing a new name.

Your stuff will work but as you said will not repeat. Until the next release comes out you could do the following:

Force Grouped Execution
Set Variable 1 to "01234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890"
Repeat With Variable 2 for every character in field Variable 1 Run inline action 'apply'
Start apply
Export name of User Defined Text Item with case insensitive prefix 'MusicBrainz' to Variable 3 (set state)
if false
Exit Repeat
endif
Copy the Variable 3 field to Variable 4
Replace prefix of "MusicBrainz_|MusicBrainz", ignoring case, OR matching in Variable 4 with ""
Trim Variable 4 (SP) [Leading] [Trailing]
Import name of User Defined Text Item with name '\v3' from Variable 4

The above uses a dirty trick to force a loop to repeat. Because Variable 1 contains 100 characters, the loop will repeat up to 100 times. It also uses The Replace statement as opposed to the FInd, so that the '_' test can be done at the same time.

cpkPostMarch 12, 2015, 21:57
Advanced
Posts: 95
Registered:
March 1, 2015, 02:55
Normal topicRe: Question about counting matching fields in UDTI

I like that better than what I did. Since lists were the only way to get looping I should have though to make a list - too obvious after the fact. 🙁

Since I already will have done the match in MusicBrainz before this point I'm not too worried about not being able to link up (without another action to edit the appropriate ID field(s)). Once I am happy with the data then there really isn't a need that I see to link up again, it isn't like anything is would change in MusicBrainz that is all that important to me. Maybe they will someday get more aliases so that it is easier to work with English translations in song, album, artist, musicians, involved people, etc. fields. And maybe someday there will be official tags for sheet music and guitar tabs like there is for lyrics. But from what I have found so far there are only aliases for artists, labels, and works but none of my apps care about those fields anyway - so I'm forced to edit the common fields anyway and make UDTIs to store the original info anyway. So, long story short, my data is going to be different than MusicBrainz anyway so future linking is pretty much out I think. What is important to me is just to be able to easily view all the original information in Yate in the odd chance that someday I need the it and have other apps use the translated values that I enter in and other than limitations with displaying UDTI fields the way I would prefer to I see Yate as being me goto tool for organizing various data as it relates to any particular track. I'd still like to be able to automate getting all my data as well as MusicBrainz, AcousticBrainz, Discogs, VGMdb data better but I'll eventually get actions for what I can make actions for and eventually manually search for and enter in the rest that the manual wizards can't do for me. I'm having fun 😀

2MR2PostMarch 12, 2015, 22:00
Avatar photo
Administrator
Posts: 2085
Registered:
August 23, 2012, 19:27
Normal topicRe: Question about counting matching fields in UDTI

That's the way to go. Have fun! It's your data and it should look like what you want it to.

Pages: 1
Mingle Forum by Cartpauj | Version: 1.1.0beta | Page loaded in: 0.017 seconds.