IPB

Welcome Guest ( Log In | Register )

> foobar2000 General Forum Rules

This is NOT a tech support forum.
Tech support questions go to foobar2000 Tech Support forum instead.

See also: Hydrogenaudio Terms of Service.

 
Reply to this topicStart new topic
script help needed
dolgorazzo
post Feb 12 2013, 15:44
Post #1





Group: Members
Posts: 14
Joined: 10-September 11
Member No.: 93624



Hi everybody,
I need to get the album tag with everything that is in front of three characters (or more): (, [, {. I managed to do so with only one of the three, how can I do this for three of them at once? And also, if the %album% doesn't contain any of them, how can I make it so that it appears as it is? Like "if %album% contains ( or [ or { than return everything that stands before ( or [ or {, otherwise return %album% as it is".
Thanks in advance!
Go to the top of the page
+Quote Post
dolgorazzo
post Feb 12 2013, 18:07
Post #2





Group: Members
Posts: 14
Joined: 10-September 11
Member No.: 93624



I'll make some examples so that it is clearer:

If %album% is "Title (EP)" or "Title [EP]" or "Title {EP}" I want that the script returns "Title"
If %album% is "Title" I want that the script returns "Title".

I tried to use this: http://wiki.hydrogenaudio.org/index.php?ti...g_in_front_of_X
but can't get to adapt it to multiple values (X), i. e. (, [ and {.

Thanks in advance!
Go to the top of the page
+Quote Post
lvqcl
post Feb 12 2013, 18:26
Post #3





Group: Developer
Posts: 3436
Joined: 2-December 07
Member No.: 49183



Slightly modified example:

CODE
$puts(tag,%tag%)
$puts(spacer1,$strchr($get(tag),'{'))
$puts(spacer2,$strchr($get(tag),'['))
$puts(spacer3,$strchr($get(tag),'('))
$puts(spacer,$min($min(spacer1,spacer2),spacer3))
$trim($left($get(tag),$sub($get(spacer),1)))
Go to the top of the page
+Quote Post
dolgorazzo
post Feb 12 2013, 18:35
Post #4





Group: Members
Posts: 14
Joined: 10-September 11
Member No.: 93624



QUOTE (lvqcl @ Feb 12 2013, 19:26) *
Slightly modified example:

CODE
$puts(tag,%tag%)
$puts(spacer1,$strchr($get(tag),'{'))
$puts(spacer2,$strchr($get(tag),'['))
$puts(spacer3,$strchr($get(tag),'('))
$puts(spacer,$min($min(spacer1,spacer2),spacer3))
$trim($left($get(tag),$sub($get(spacer),1)))



Thanks a lot but I can't get it to work. I'm using this to launch album art downloader with the run service component...
Go to the top of the page
+Quote Post
dolgorazzo
post Feb 12 2013, 22:02
Post #5





Group: Members
Posts: 14
Joined: 10-September 11
Member No.: 93624



It works only with one. Why???

This works:

$puts(spacer1,$strchr(%album%,'{'))$trim($left(%album%,$sub($get(spacer1),1)))

But not if I make a script with more than one spacer, like the one you suggested.
Go to the top of the page
+Quote Post
lvqcl
post Feb 12 2013, 22:16
Post #6





Group: Developer
Posts: 3436
Joined: 2-December 07
Member No.: 49183



in my code, the 5th line should be:
CODE
$puts(spacer,$max($max($get(spacer1),$get(spacer2)),$get(spacer3)))


but it also works incorrectly if there are several characters: for "Title (EP) [2012]" the script returns "Title (EP)"...
Go to the top of the page
+Quote Post
dolgorazzo
post Feb 12 2013, 22:32
Post #7





Group: Members
Posts: 14
Joined: 10-September 11
Member No.: 93624



QUOTE (lvqcl @ Feb 12 2013, 23:16) *
in my code, the 5th line should be:
CODE
$puts(spacer,$max($max($get(spacer1),$get(spacer2)),$get(spacer3)))


but it also works incorrectly if there are several characters: for "Title (EP) [2012]" the script returns "Title (EP)"...


Thanks a lot, you've been very helpful! I don't think I have albums tagged that way, your code works fine for me! I'm now curious to see if there's a way to do it the way I meant tough.
Thanks again!
Go to the top of the page
+Quote Post
fbuser
post Feb 12 2013, 22:39
Post #8





Group: Developer
Posts: 684
Joined: 26-September 07
Member No.: 47369



Although not tested, this should also cover the not working part lvqcl mentioned (and it's shorter smile.gif) :
CODE
$trim($left(%album%,$sub($strchr($replace(%album%,'{','(','[','('),'('),1)))


This post has been edited by fbuser: Feb 12 2013, 22:41
Go to the top of the page
+Quote Post
dolgorazzo
post Feb 13 2013, 17:57
Post #9





Group: Members
Posts: 14
Joined: 10-September 11
Member No.: 93624



QUOTE (fbuser @ Feb 12 2013, 23:39) *
Although not tested, this should also cover the not working part lvqcl mentioned (and it's shorter smile.gif)[/code]


Thanks a lot, it works!
Go to the top of the page
+Quote Post
mobyduck
post Feb 14 2013, 13:09
Post #10





Group: Members
Posts: 576
Joined: 24-April 03
From: Italy
Member No.: 6159



I'm unable to test it right now, but wouldn't this be enough?
QUOTE
$replace(%album%, '(EP)', '', '[EP]', '', '{EP}', '')
Alessandro

PS: never mind, scratch that. Didn't realize EP was a mere example.

This post has been edited by mobyduck: Feb 14 2013, 13:12
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 26th November 2014 - 06:37