<?sphp $this->text('pagetitle') ?>
 
Home of the Squeezebox™ & Transporter® network music players.

Song Info plugin

From SqueezeboxWiki

Jump to: navigation, search

This plugin for SqueezeCenter which enhances the with some new CLI/JSON commands to get extra information about a specific artist, album or track.

Please note that even though the plugin can be used by itself, it's often used to enhance other plugins, applets or applications. For example the Album Flow applet uses the extra JSON commands to get images from LastFM.

Besides the CLI/JSON commands the Song Info plugin also displays the information provided in the context/details menus of artists, albums and songs.

Contents

Installation

  1. Remove any previous version of Song Info plugin from the SqueezeCenter Plugins directory if you have manually installed it earlier (this is not needed if you have installed it through Plugins tab)
  2. Goto SqueezeCenter Settings/Plugins and select to install Song Info. You might need to add Erland's repository to see it, see here for more information regarding this: SqueezeCenter_Repositories. If you don't want to install it through Extension Downloader, you can also download it from the download page and manually unzip the new version in the SqueezeCenter Plugins directory

Bugs and new features

The current list of known bugs and wishes for new features can be found here:

If you want to encourage future development of this plugin you should also consider making a donation

http://erland.isaksson.info/donate

Available information modules

  • lastfmtracktags: LastFM tags for current song
  • lastfmsimilarartists: Artists similar to the specified artist based on LastFM
  • lastfmartistimages: Images of the specified artist from LastFM
  • lastfmartistbio: Biography text for the specified artist from LastFM
  • lastfmtrackimage: Image for the specified track from LastFM
  • lastfmsimilarartistsimages: Images of artists similar to the specified artist from LastFM
  • lastfmtrackdesc: Description text of the specified track from LastFM
  • lastfmalbumimage: Image for the specified album from LastFM
  • lastfmartisttags: Tags for the specified artist
  • lastfmalbumdesc: Album description from LastFM for the specified album

CLI/JSON commands

  • Get all available information modules:
songinfomodules
  • Get all available information modules that provides text items:
songinfomodules type:text
  • Get all available information modules that provides images:
songinfomodules type:image
  • Get all available information modules that provides images based on an artist:
songinfomodules type:image context:artist


  • Get information from lastfmartistimages module about current song:
00:01:02:03:04:05 songinfoitems lastfmartistimages
  • Get information from lastfmartistimages module about a specific artist:
00:01:02:03:04:05 songinfoitems lastfmartistimages artist:42
  • Get information from lastfmalbumimage module for a specific album:
00:01:02:03:04:05 songinfoitems lastfmalbumimage album:142
  • Get information from lastfmtrackimage module for a specific track:
00:01:02:03:04:05 songinfoitems lastfmtrackimage track:2001

CLI/JSON responses

The response for a image module looks like this:

count => 2,          
item_loop => [                
     {                  
         text => "Melissa Horn",                  
         type => "image",                  
         url  => "http://userserve-ak.last.fm/serve/_/5707275/Melissa+Horn.jpg",                
     },
     {
         text => "Melissa Horn",
         type => "image",
         url  => "http://userserve-ak.last.fm/serve/_/19061825/Melissa+Horn.jpg",
     },
]

The response fro a text module looks like this:

count => 1,          
item_loop => [                
     {                  
         text => "Some text that contains the biography of the specified artist",                  
         type => "text",                  
     },
]

Plugin API

Information modules can be provided as separate plugins, to do this you will need to do something like this in the "initPlugin" function in your plugin.

if(UNIVERSAL::can("Plugins::SongInfo::Plugin","registerInformationModule")) {
    Plugins::SongInfo::Plugin::registerInformationModule('mypluginitem',{
        'name' => 'My Plugin Info',
        'description' => "This module gets information from ...",
        'developedBy' => 'John Doe', #optional, name of developer
        'developedByLink' => 'http://somesite', #optional, link to developers site
        'dataproviderlink' => 'http://somesite', # optional, link to information provider
        'dataprovidername' => 'Some Site', # optional, name of information provider
        'function' => \&getInformation,
        'type' => 'text',
        'context' => 'track',
        'jivemenu' => 1, # Should be shown in Touch/Radio/Duet context menus
        'playermenu' => 1, # Should be shown in Classic/Boom/Transporter context menus
        'webmenu' => 1, # Should be shown in web interface
        'properties' => [
            {
                'id' => 'mypluginattribute1',
                'name' => 'Attribute1',
                'description' => 'Some description of configuration parameter Attribute1',
                'type' => 'text',
                'value' => 80, # Default value
           },
        ]
    });
}

The "context" attribute can be "track", "album" or "artist". The "type" attribute can be "text" or "image"

You will also need to implement the "getInformation" function referred to by the above registration call.

sub getSongInfoFiles {
       my $client = shift;
       my $callback = shift;
       my $errorCallback = shift;
       my $callbackParams = shift;
       my $track = shift;
       my $params = shift;

       my @result = ();

       # TODO: Implement your logic to get information related to the specified track
       my $entry = {
               'type' => 'text',
               'name' => 'item1', 
               'text' => 'More textual information about item1....',
       };
       push @result,$entry;
       $entry = {
               'type' => 'text',
               'name' => 'item2',
               'text' => 'More textual information about item2....',
       };
       push @result,$entry;

       eval {
               &{$callback}($client,$callbackParams,\@result);
       };
       if( $@ ) {
               $log->error("Error calling callback: $@");
       }
}

For text items the "name" attribute in the result entries are optional, it will be used to display an intermediate menu if provided and more than one item is returned.

If you implement a "image" provider you would instead have entries like:

my $entry = {
    'type' => 'image',
    'name' => 'Image1',
    'url' => 'http://somehost/somepath/image.jpg',
};