HydrogenAudio

Hosted Forums => foobar2000 => General - (fb2k) => Topic started by: Dario on 2012-10-27 19:44:22

Title: Req—Make $swapprefix+$stripprefix work on multi-value fields
Post by: Dario on 2012-10-27 19:44:22
So, the <%field%> syntax, when used in the Album List, allows a single tag with multiple values to be split and present in multiple branches.

For example, if the genre tag has is defined as Post-rock; Electronic (two genres), then <%genre%> will place it in two brances— ‘Post-rock’ and ‘Electronic,’ while just %genre% will place it under ‘Post-rock, Electronic’ (a single branch, with the items separated with a comma).

However, if you use $swapprefix(), along with <%album artist%> (or a related field where you'd want the prefixes to be swapped), you’ll experience some weird behavior. In a situation where the album artist tag is defined as We All Inherit the Moon; The Ascent of Everest (two album artists), $swapprefix(<%album artist%>) will fail to swap the prefix of the second artist, so it’ll end up under ‘The Ascent of Everest’ instead of ‘Ascent of Everest, The’ (with the prefix at the end, as it should be).

The same behavior is present with $stripprefix(), too. I’d really appreciate it if this thing was fixed.

EDIT: Can a mod shorten the title so that it doesn't overflow?
Title: Req—Make $swapprefix+$stripprefix work on multi-value fields
Post by: mjm716 on 2012-11-19 04:25:02
I can confirm that this is also a problem in Facets.

multiple fields are not correctly handled with swap OR strip prefix.
Title: Req—Make $swapprefix+$stripprefix work on multi-value fields
Post by: Dario on 2013-04-20 18:53:54
I wonder if Peter has noticed this thread. It'd be really awesome if this was fixed.
Title: Req—Make $swapprefix+$stripprefix work on multi-value fields
Post by: db1989 on 2013-04-20 19:04:32
EDIT: Can a mod shorten the title so that it doesn't overflow?
I started doing this but then decided to go with a more general title as the lack of functionality is not specific to the Album List; it affects multi-value fields in general.

I can understand the absent functionality from the point of view of a title-formatting engine that is currently configured to process single values. Adding this ability would require parsing for dividing symbols and splitting the input field into chunks to be processed individually. This would be a good feature to add. However, whether it is as easy as it sounds in terms of the current code, and/or likely to be added, is something about which I can’t speculate.
Title: Req—Make $swapprefix+$stripprefix work on multi-value fields
Post by: foosion on 2013-04-20 23:32:33
Interesting idea, but how do you handle cases like "$left(%<artist>%,1)|%<artist>%"? Even if the $left() function can process and return a list of values, the whole script would return all combinations of artists and their first letters instead of pairing each artist with its first letter.

Fortunately there is another approach which makes it possible to use any function on a multi-value field like %<artist>%. It comes with other drawbacks of course. I have recently dusted of a prototype of this approach and uploaded a tech demo to the just now. It is available from the official component repository (http://www.foobar2000.org/components/view/foo_multiformat). Note that the component does not affect the way other components like Album List or Facets work at all!

After you install the component there is a new command in the context menu called "Multi-formatting Tech Demo". If you select this command the following window will open:
[attachment=7505:foo_mult...20130421.png]
On the top you can enter some title formatting code. The component supports the same extensions as the Album List (http://wiki.hydrogenaudio.org/index.php?title=Foobar2000:Titleformat_Album_List), i.e. %<artist>%, $meta_branch_remap(artist) and $meta_branch(artist). You have to explicitly click the Format button to update the results in the lower part of the window (no auto-update for now). The list box in the lower left part contains all results and the text box in the lower right part contains the full text of the selected result.

I plan to provide more details and the source soon. Happy experimenting!
Title: Req—Make $swapprefix+$stripprefix work on multi-value fields
Post by: db1989 on 2013-04-21 12:47:40
Really interesting; thanks! I look forward to seeing whether it creeps into other parts of foobar2000.
Title: Req—Make $swapprefix+$stripprefix work on multi-value fields
Post by: q-stankovic on 2013-04-21 20:03:44
It would be amazing to see that not only into other parts of foobar2000 but of foobar2000 itself, means: imdependent of any component and everywhere you place tf expressions. If the techdemo prooves that it is realible how probable it would be that Peter implements it?
Title: Req—Make $swapprefix+$stripprefix work on multi-value fields
Post by: foosion on 2013-04-22 10:02:09
My new technique does have its pitfalls, mainly because it expects custom title formatting functions (i.e. ones provided by third-party components instead of the core) to adhere to certain rules which are stricter than the rules imposed by the SDK. I'll create a second tech demo with some functions that demonstrate this.

I expect that this technique will be adopted by developers on a case-by-case basis. If its capabilities and limitations fit the use case of a particular component, it might be integrated otherwise not. As far as integration into the core is concerned I have no idea how likely that is. In particular there are situations when only a single result from a title formatting script is desired.

See the foo_multiformat (http://www.hydrogenaudio.org/forums/index.php?showtopic=100540) topic for further discussion about my technique.