add criteras to a musicselection through script?

The forum for designers and developers.
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
spexer
Posts: 51
Joined: 12. Jul 07, 15:36
Location: Sweden
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

add criteras to a musicselection through script?

Postby spexer » 26. May 09, 19:34


Guest
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: add criteras to a musicselection through script?

Postby Guest » 26. May 09, 20:09


spexer
Posts: 51
Joined: 12. Jul 07, 15:36
Location: Sweden
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: add criteras to a musicselection through script?

Postby spexer » 26. May 09, 20:31


SilverEagle
Posts: 713
Joined: 30. Sep 08, 14:00
Location: Netherlands
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: add criteras to a musicselection through script?

Postby SilverEagle » 26. May 09, 22:38

Hi spexer,

spexer wrote:
> is there a way to add criteras to a
> musicselection through script?

Yes there is. But you'd better not be afraid of some programming...

Look for sample code in my Touch Blue skin, the module
musicsearch.sj. It can construct the SQL from a musicsearch, after which you can add SQL clauses to it and set it up as a new SQL based musicsearch. The good news for this is you can use my module 99% out of the box for this purpose.

Alternatively you can use script to modify the musicsearch in such a way that is still compatible with the musicsearch GUI setup (and not just SQL based like above).

However from a programming viewpoint this might be more complicated, it depends on your exact requirements. For instance just creating a year-based search where you can only add extra years in script is less hard than writing something which could add anything the GUI could.

Have a look at the MusicSearchSet() function in the module to see the sort of construct you have to build to create a valid musicsearch entry.

SilverEagle

spexer
Posts: 51
Joined: 12. Jul 07, 15:36
Location: Sweden
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: add criteras to a musicselection through script?

Postby spexer » 27. May 09, 06:36

Thanks for the answer SilverE. I doubt I will have the skillset requiered but I'll have a look and try to make something out of it!

spexer
Posts: 51
Joined: 12. Jul 07, 15:36
Location: Sweden
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: add criteras to a musicselection through script?

Postby spexer » 27. May 09, 09:18

Oki, as I though I will have a hard time doing anything with this although I will try... my I ask you,if it would be possible to use preset musicselections as criteras aswell? If I load one, genre=pop (then the script saves this info to another selection)after that I load another one, year=1960-1969, and it saves that info to the same selection. I guess it should work, huh?

Me I will have to try learn the basics of programmning... ;-)

SilverEagle
Posts: 713
Joined: 30. Sep 08, 14:00
Location: Netherlands
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: add criteras to a musicselection through script?

Postby SilverEagle » 27. May 09, 10:05

spexer wrote:
> it would be possible to use preset
> musicselections as criteras aswell?

> If I load
> one, genre=pop (then the script saves this info
> to another selection)after that I load another
> one, year=1960-1969, and it saves that info to
> the same selection. I guess it should work, huh?

Well, first we have doublecheck our terminology:
A musicselection is a single entry in the list you get when you press ctrl-F. A default for instance is 70's music.

Each musicselection consists of one or more criteria. The default musicselection "Top 20" for instance consists of two criteria: "play count > 1" and "limit result to 20 tracks most often played".

The first field in each criteria line is a drop down list with all possible criteriatypes (from 'title/artist/album' to 'limit result to').

As you can see there is no criteriatype 'music selection', meaning you can not build nested musicselections where a criteria is specified as another music selection. This does not change using scripting.

What you CAN do is copy the criteria of music selections to other msuic selections. Without SQL this is limited, as AND/OR cannot be nested. This is no problem for your very basic example (precisely one criteria for each selection) but it get impossible fast. Take for instance these music selections:
A) match all criteria: year=1970 and genre=bluegrass
B) match all criteria: year=1980 and genre=country

Now when you want to combine them you definitely want to OR them, AND-ing makes no sense as the intersection would by definition be empty. But Silverjuke does not make this possible: you can only 'match all criteria' (=AND) or 'match any criteria' (=OR).

So you are quite limited in your options and cannot create a satisfactory combinational selection using the GUI (or scripting).

The alternative is using SQL. Change both music selections to SQL and they read:
A) (year=1971 and genrename='bluegrass')
B) (year=1980 and genrename='country')

Combining is as simple as creating a single SQL selection with
((year=1971 and genrename='bluegrass') or (year=1980 and genrename='country'))

> Me I will have to try learn the basics of
> programmning... ;-)
I'm afraid it needs a bit more than basics. If you are really new to programming (and not just Silverjuke scripting) I think you might consider starting with a few challenges a bit smaller in scope to get a feel for it all.

SilverEagle

spexer
Posts: 51
Joined: 12. Jul 07, 15:36
Location: Sweden
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: add criteras to a musicselection through script?

Postby spexer » 27. May 09, 11:38


SilverEagle
Posts: 713
Joined: 30. Sep 08, 14:00
Location: Netherlands
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: add criteras to a musicselection through script?

Postby SilverEagle » 27. May 09, 11:58


spexer
Posts: 51
Joined: 12. Jul 07, 15:36
Location: Sweden
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: add criteras to a musicselection through script?

Postby spexer » 15. Jul 09, 07:33

Sorry, for not responding, however I been busy making it work the way I wanted it ;-)
Have a look at it if you like, I did some minor changes to your script and now it works the way I wanted it (but wasnt really able to explain to you I think).
Thanks for your help anyway!

viewtopic.php?t=3340

/spexer


[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Return to “Developer Network”