Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Senior Member philchillbill's Avatar
    Join Date
    Jan 2019
    Location
    The Netherlands
    Posts
    816

    Retrieve entire favorites hierarchy without recursion

    I've been looking in the source of Slim::Control::XMLBrowser.pm to see if I could figure out how to retrieve the entire favorites hierarchy with a single jsonrpc.js call. I gave up because there's too much goinf on for somebody new to looking at the code.

    ["favorites", "items", 0, 300, "want_url: 1"] will only return the top level favorites and I need to figure out the IDs of the embedded folders and then repeatedly call ["favorites", "items", 0, 300, "item_id:x.y.z", "want_url: 1"] with the folder item_id's to pick up underlying levels.

    The thing is, the search variant ["favorites", "items", 0, 300, "search:radio", "want_url: 1"] returns all matches regardless of level but it won't take a wildcard for the search, nor will it take a regexp.

    Any pointers as to where the code could be tweaked to get back all the items with a single call? Or is there a parameter I'm not seeing?

    The MediaServer skill has to call jsonrpc.js from the cloud and recursion is 'expensive'.

  2. #2
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,597

    Retrieve entire favorites hierarchy withoutrecursion

    > The thing is, the search variant ["favorites", "items", 0, 300,
    > "search:radio", "want_url: 1"] returns all matches regardless of level
    > but it won't take a wildcard for the search, nor will it take a regexp.


    Checkout
    https://github.com/Logitech/slimserv...Plugin.pm#L763
    - it's where the recursive search is implemented.

    As you'll see it's using the \Q...\E delimiters in the search expression
    to explicitly disable use of user provided regexes. The problem is that
    not doing so might accidentally break the search if somebody
    accidentally used a character which might be interpreted as a regex.

  3. #3
    Senior Member philchillbill's Avatar
    Join Date
    Jan 2019
    Location
    The Netherlands
    Posts
    816
    Quote Originally Posted by mherger View Post
    > The thing is, the search variant ["favorites", "items", 0, 300,
    > "search:radio", "want_url: 1"] returns all matches regardless of level
    > but it won't take a wildcard for the search, nor will it take a regexp.


    Checkout
    https://github.com/Logitech/slimserv...Plugin.pm#L763
    - it's where the recursive search is implemented.

    As you'll see it's using the \Q...\E delimiters in the search expression
    to explicitly disable use of user provided regexes. The problem is that
    not doing so might accidentally break the search if somebody
    accidentally used a character which might be interpreted as a regex.
    So I was looking in the wrong file entirely

    Of course a /Q /E will destroy a regex. I stripped them from the perl for an experiment and indeed a regex-search then works. One thing I noticed is that using 'search' (either with or without the QuoteMeta) will not return any of the items in On mysqueezebox.com whereas they do show up if their item_id is specified. Is that expected behaviour?

  4. #4
    Senior Member philchillbill's Avatar
    Join Date
    Jan 2019
    Location
    The Netherlands
    Posts
    816
    @mherger, I just discovered that if I include the parameter 'feedMode:1' in my query, the whole favorites tree is returned as a nested structure

    What is the actual intention of feedMode? Can I safely assume it will always return all the favorites?

  5. #5
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,597

    Retrieve entire favorites hierarchy withoutrecursion

    > What is the actual intention of feedMode? Can I safely assume it will
    > always return all the favorites?


    I have no clue... all code changes touching this flag seem to go back
    10-11 years and don't mention it...

  6. #6
    Senior Member philchillbill's Avatar
    Join Date
    Jan 2019
    Location
    The Netherlands
    Posts
    816
    Quote Originally Posted by mherger View Post
    > What is the actual intention of feedMode? Can I safely assume it will
    > always return all the favorites?


    I have no clue... all code changes touching this flag seem to go back
    10-11 years and don't mention it...
    Ok, well I'm going to (gladly) start using it so it might be an idea to mention it in the Help file for the CLI. If people don't know about its existence the it will likely never be used and it is a very useful option !

  7. #7
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,597

    Retrieve entire favorites hierarchy withoutrecursion

    > Ok, well I'm going to (gladly) start using it so it might be an idea to
    > mention it in the Help file for the CLI. If people don't know about its
    > existence the it will likely never be used and it is a very useful
    > option !


    As I don't really understand what the flag is supposed to really do, I
    don't know how to reasonably document it...

  8. #8
    Senior Member philchillbill's Avatar
    Join Date
    Jan 2019
    Location
    The Netherlands
    Posts
    816
    Quote Originally Posted by mherger
    >
    As I don't really understand what the flag is supposed to really do, I
    don't know how to reasonably document it...
    I'd humbly suggest something like this:

    Code:
    	<tr>
    		<td>
    			feedMode
    		</td>
    		<td>
    			If set to 1, the entire nested hierarchy of favorites is returned. In this case, the
    			type will be opml and the nested sub-items will be in each level's items array.
    		</td>
    	</tr>

  9. #9
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    4,749
    Does that parameter (feedMode) apply to things other than favourites?
    I see from the code a reference to returning the raw data rather than going deeper into a set looking for audio - and also maybe a paging mechanism.
    Perhaps it means that it is like using a real RSS feed (outside of LMS) - and the info is passed through without much, if any, parsing.
    Paul Webster
    http://dabdig.blogspot.com
    Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, Supla Finland, ABC Australia, CBC/Radio-Canada and RTE Ireland
    and, via the extra "Radio Now Playing" plugin, AllZIC Radio, Caroline Flashback, Cesky rozhlas, Frequence3, JukeRadio, KlassikRadio.de, Linn Radio, Mother Earth, Naim Radio, Nova.fr, RadioBlues Flac, Radio Espace, Somehow Jazz

  10. #10
    Senior Member philchillbill's Avatar
    Join Date
    Jan 2019
    Location
    The Netherlands
    Posts
    816
    Quote Originally Posted by Paul Webster;
    Does that parameter (feedMode) apply to things other than favourites?
    I see from the code a reference to returning the raw data rather than going deeper into a set looking for audio - and also maybe a paging mechanism.
    Perhaps it means that it is like using a real RSS feed (outside of LMS) - and the info is passed through without much, if any, parsing.
    The docs have:
    Code:
     <playerid> <lma|mp3tunes|pandora|podcast|radiotime|rhapsodydirect|shoutcast|picks|rss> items <start> <itemsPerResponse> <taggedParameters>
    
    These instructions are valid for all XMLBrowser based plugins.
    so I would think that feedMode will also act as passthrough for any data structures these queries can generate.

Posting Permissions

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