Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 10 of 10
  1. #1
    Senior Member
    Join Date
    Mar 2017
    Posts
    3,066

    Plugin URL prefix mapping?

    For Material 2.4.2 I'm using a track's URL to map to its source. e.g. URL starting with "youtube:" maps to "YouTube". Currently I have a JSON file that maps these prefixes (URL schemes) to a displayable name. Is there a way for material to determine the URL prefixes used for all installed plugins? This way I can remove the JSON file and provide this mapping for a JSONRPC call - and when new plugins are created I don't have to manually update this mapping.

    e.g. I'd like Material's Perl plugin code to be able to query for all active prefixes/schemes and create a mapping from these to the plugin name.
    Material debug: 1. Launch via http: //SERVER:9000/material/?debug=json (Use http: //SERVER:9000/material/?debug=json,cometd to also see update messages, e.g. play queue) 2. Open browser's developer tools 3. Open console tab in developer tools 4. REQ/RESP messages sent to/from LMS will be logged here.

  2. #2
    Senior Member
    Join Date
    Aug 2014
    Location
    UK
    Posts
    539
    Quote Originally Posted by cpd73 View Post
    For Material 2.4.2 I'm using a track's URL to map to its source. e.g. URL starting with "youtube:" maps to "YouTube". Currently I have a JSON file that maps these prefixes (URL schemes) to a displayable name. Is there a way for material to determine the URL prefixes used for all installed plugins? This way I can remove the JSON file and provide this mapping for a JSONRPC call - and when new plugins are created I don't have to manually update this mapping.

    e.g. I'd like Material's Perl plugin code to be able to query for all active prefixes/schemes and create a mapping from these to the plugin name.

    From a plugin I believe, you would be able to get the list of registered handlers from Slim::Player::ProtocolHandlers->registeredHandlers : https://github.com/Logitech/slimserv...andlers.pm#L68

    But that might not give you want you want as the the key, I think, will be a regex, not necessarily a prefix.
    [EDIT : Actually, having looked again, that looks fine, as the url handlers are different]
    Last edited by expectingtofly; 2021-05-09 at 02:19.

  3. #3
    Senior Member
    Join Date
    Mar 2017
    Posts
    3,066
    Quote Originally Posted by expectingtofly View Post
    From a plugin I believe, you would be able to get the list of registered handlers from Slim::Player::ProtocolHandlers->registeredHandlers : https://github.com/Logitech/slimserv...andlers.pm#L68
    Thanks. That gives me half - the prefixes - but not which plugin is for which prefix.

    [Edit] e.g. I want to know that "sounds:" maps to "BBC Sounds"
    Last edited by cpd73; 2021-05-09 at 02:59.
    Material debug: 1. Launch via http: //SERVER:9000/material/?debug=json (Use http: //SERVER:9000/material/?debug=json,cometd to also see update messages, e.g. play queue) 2. Open browser's developer tools 3. Open console tab in developer tools 4. REQ/RESP messages sent to/from LMS will be logged here.

  4. #4
    Senior Member
    Join Date
    Aug 2014
    Location
    UK
    Posts
    539
    Quote Originally Posted by cpd73 View Post
    Thanks. That gives me half - the prefixes - but not which plugin is for which prefix.

    [Edit] e.g. I want to know that "sounds:" maps to "BBC Sounds"
    Ah, yes, I see what you mean. That's going to be tricky. You will probably be able to extract the package name of the protocol handler from the %protocolHandlers hash (e.g. Plugins::BBCSounds::ProtocolHandler ) and try and make something meaningful from that. But that looks a bit problematic.

  5. #5
    Senior Member
    Join Date
    Mar 2017
    Posts
    3,066
    Quote Originally Posted by expectingtofly View Post
    Ah, yes, I see what you mean. That's going to be tricky. You will probably be able to extract the package name of the protocol handler from the %protocolHandlers hash (e.g. Plugins::BBCSounds::ProtocolHandler ) and try and make something meaningful from that. But that looks a bit problematic.
    Yeah, I've just seen that. It might be better than nothing - after all this is only to be shown in the MAI track info section.
    Material debug: 1. Launch via http: //SERVER:9000/material/?debug=json (Use http: //SERVER:9000/material/?debug=json,cometd to also see update messages, e.g. play queue) 2. Open browser's developer tools 3. Open console tab in developer tools 4. REQ/RESP messages sent to/from LMS will be logged here.

  6. #6
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    20,799
    How about
    Code:
    my $urlhandler = Slim::Player::ProtocolHandlers->handlerForURL('sounds://');
    It'll return Plugins::BBCSounds::ProtocolHandler

    You then use use the Protocol Handler to return plugin data on full name.

    edit:

    I think routine _pluginDataFor provides access into install.xml

  7. #7
    Senior Member
    Join Date
    Mar 2017
    Posts
    3,066
    Quote Originally Posted by bpa View Post
    I think routine _pluginDataFor provides access into install.xml
    Yup, but that is from a Plugin not ProtocolHandler. Not sure how I get from a ProtocolHandler to its Plugin?
    Material debug: 1. Launch via http: //SERVER:9000/material/?debug=json (Use http: //SERVER:9000/material/?debug=json,cometd to also see update messages, e.g. play queue) 2. Open browser's developer tools 3. Open console tab in developer tools 4. REQ/RESP messages sent to/from LMS will be logged here.

  8. #8
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    20,799
    Quote Originally Posted by cpd73 View Post
    Yup, but that is from a Plugin not ProtocolHandler. Not sure how I get from a ProtocolHandler to its Plugin?
    Within LMS all plugin are in "Plugin" folders so their names are of the form Plugin::<pluginname>

    The protocol handlers that do not begin with "Plugin" are LMS.

    Full list of plugin data can be got from Slim::Utils::PluginManager->allPlugins (Sounds entry shown)
    The "'module" entry (or basedir) to match with plugin name derived from answer from handlerfromURL - messy but doable.

    Code:
       'BBCSounds' => {
                                 'basedir' => '/mnt/hddrive/home/ubuntu/repos/Cache/InstalledPlugins/Plugins/BBCSounds',
                                 'creator' => 'ExpectingToFly',
                                 'description' => 'PLUGIN_BBCSOUNDS_DESC',
                                 'error' => 'INSTALLERROR_SUCCESS',
                                 'homepageURL' => 'https://github.com/expectingtofly/LMS_BBC_Sounds_Plugin',
                                 'icon' => 'plugins/BBCSounds/html/images/BBCSounds_svg.png',
                                 'module' => 'Plugins::BBCSounds::Plugin',
                                 'name' => 'PLUGIN_BBCSOUNDS',
                                 'optionsURL' => 'plugins/BBCSounds/settings/basic.html',
                                 'targetApplication' => {
                                                          'id' => 'SlimServer',
                                                          'maxVersion' => '*',
                                                          'minVersion' => '7.9'
                                                        },
                                 'version' => '2.17.1'
                               },
    
    .
    .
    .
    
             'Sounds' => {
                              'basedir' => '/mnt/hddrive/home/ubuntu/repos/logitechmediaserver/Slim/Plugin/Sounds',
                              'creator' => 'Logitech',
                              'defaultState' => 'enabled',
                              'description' => 'PLUGIN_SOUNDS_MODULE_NAME',
                              'enforce' => '1',
                              'error' => 'INSTALLERROR_SUCCESS',
                              'homepageURL' => 'http://www.mysqueezebox.com/appgallery/Sounds',
                              'icon' => 'plugins/Sounds/html/images/icon.png',
                              'id' => '0381A1D8-7CDF-4236-BA8B-E92553162EDE',
                              'module' => 'Slim::Plugin::Sounds::Plugin',
                              'name' => 'PLUGIN_SOUNDS_MODULE_NAME',
                              'needsMySB' => 'true',
                              'targetApplication' => {
                                                       'id' => 'Logitech Media Server',
                                                       'maxVersion' => '*',
                                                       'minVersion' => '7.0'
                                                     },
                              'type' => '2',
                              'version' => '1.0'
                            },
    edit:

    Module name can begin with Plugin or Plugins
    Last edited by bpa; 2021-05-09 at 04:55.

  9. #9
    Senior Member
    Join Date
    Mar 2017
    Posts
    3,066
    Quote Originally Posted by bpa View Post
    Within LMS all plugin are in "Plugin" folders so their names are of the form Plugin::<pluginname>

    The protocol handlers that do not begin with "Plugin" are LMS.

    Full list of plugin data can be got from Slim::Utils::PluginManager->allPlugins
    Perfect! Thanks!
    Material debug: 1. Launch via http: //SERVER:9000/material/?debug=json (Use http: //SERVER:9000/material/?debug=json,cometd to also see update messages, e.g. play queue) 2. Open browser's developer tools 3. Open console tab in developer tools 4. REQ/RESP messages sent to/from LMS will be logged here.

  10. #10
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    20,799
    Quote Originally Posted by cpd73 View Post
    Perfect! Thanks!
    Hope you saw the clarifying edit - plugin modules can begin with "Plugin::" or "Plugins::"

Posting Permissions

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