Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    27

    How to read the whole list of favorites?

    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?

  2. #2
    Senior Member
    Join Date
    Aug 2012
    Location
    Austria
    Posts
    1,229
    Quote Originally Posted by GoldenEye View Post
    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: Web Interface | TUI | Playlist Editor / Generator | Music Classification | Similar Music | Announce | EventTrigger | DB Optimizer | Image Enhancer | Chiptunes | LMSlib2go | ...
    Various HowTos: build a self-contained LMS | Bluetooth/ALSA | Control LMS with any device | ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •