Re: How to read the whole list of favorites?
Roland0 <Roland0.a5awqn-NUepA2SMhDQqspMVqqL2D+4xXEVPTSb/[email protected]>
| Newsgroups | gmane.music.equipment.slimdevices.devel |
|---|---|
| Organization | Logitech Squeezebox Forums |
| Message-ID | <[email protected]> |
GoldenEye wrote:
> I'd like to store the titles and URLs of all my favorites including the
> favorite hierarchy in an array variable.
>
> What would be the most efficient method to get this done?
recursively calling 'favorites items'
eg.
Code:
--------------------
[...]
sub getFavorites {
my ($client, $item, $result) = @_;
[...]
if ($item->{'hasitems'}) {
my $ssr = $client->execute(['favorites', 'items', 0, 999,"item_id:" . $item->{'id'}]);
my @schildren = ();
foreach my $sitem (@{$ssr->getResults()->{loop_loop}}) {
getFavorites($client, $sitem, \@schildren);
}
[...]
--------------------
preserving the hierarchy in a flat array won't work, you'll need e.g. an
array of hashrefs referencing an array or similar
e.g.
Code:
--------------------
$child->{'children'} = \@schildren
push @$result, $child;
--------------------
'Various SW' (https://www.nexus0.net/pub/sw/): Web Interface | TUI |
Playlist Editor / Generator | Music Classification | Similar Music |
Announce | EventTrigger | DB Optimizer | Image Enhancer | Chiptunes |
LMSlib2go | ...
'Various HowTos' (https://www.nexus0.net/pub/documents/LMS/): build a
self-contained LMS | Bluetooth/ALSA | Control LMS with any device | ...
------------------------------------------------------------------------
Roland0's Profile: http://forums.slimdevices.com/member.php?userid=56808
View this thread: http://forums.slimdevices.com/showthread.php?t=114885