PDA

View Full Version : Multi library and cli



Hydro
2018-01-28, 03:30
Hi

Currently I have two servers with my own plugin to send data to my home automation system.

I'd like to change and use one server with two librairies.

Is it possible, with CLI, to know witch library is currently use ?

Thank

Sent from my ONEPLUS A3003 using Tapatalk

pippin
2018-01-28, 03:35
How do you separate them? Through the MultiLibrary plugin or virtual libraries?

Hydro
2018-01-28, 15:04
I don't do it yet so I don't know what is the best to separate my wife and I libraries and use CLI to play one or other.

Sent from my ONEPLUS A3003 using Tapatalk

mherger
2018-01-28, 22:42
> I don't do it yet so I don't know what is the best to separate my wife
> and I libraries and use CLI to play one or other.

Using the library views built in to LMS you'd get the library_id and
library_name in the status query.

--

Michael

Hydro
2018-01-29, 23:16
With the "simple library view" plugin ?

Sent from my ONEPLUS A3003 using Tapatalk

mherger
2018-01-29, 23:38
> With the "simple library view" plugin ?

Yes. That's just an add-on to create views for the built-in library view
feature.

--

Michael

Hydro
2018-01-30, 00:41
Ok I install the plugin, create the file on a folder to test (not very friendly to have this file on each albums folders) restart scan and...

Sorry I try to find the information but now how I can see the library view ?

Sent from my ONEPLUS A3003 using Tapatalk

mherger
2018-01-30, 04:54
> Sorry I try to find the information but now how I can see the library
> view ?

You should have a new item in the My Music menu.

--

Michael

Hydro
2018-02-01, 02:01
I've got nothing new. Maybe my file isn't working :/

Sent from my ONEPLUS A3003 using Tapatalk

mherger
2018-02-01, 02:22
> I've got nothing new. Maybe my file isn't working :/

Do you have the Additional Browse Modes plugin enabled? Did you enable
the library views menu in the player's settings for above plugin?

--

Michael

Hydro
2018-02-03, 03:48
It work thanks ! I didn't have this plugin.

Let's go testing CLI now :)

Sent from my ONEPLUS A3003 using Tapatalk

Hydro
2018-02-03, 05:02
First question, on a server plugin, how did you get the library ?

I use this code to get informations for a player :


sub handlePlayTrack {

my $client = shift;

my $iSyncedPlayer = $client->isSynced() ;

my $iPower = $client->power();

my $iMaster = Slim::Player::Sync::isMaster($client);

my @iSyncedMaster = $client->master() ;

my $iSyncedGroup = "";

my @SyncedSlaves ;

my $sTitle = $client->playingSong();

my $sName = 'Vide';

my $artist = 'Vide';

my $artist_id = 'null';

my $album = 'Vide';

my $album_id = 'null';

my $id = 'null';

my $cover = 'null';

my $duration = 0;

my $played = 0;

my $iVolume = $client->volume();

my $player_name = $client->name();

$log->debug('handlePlayTrack for '.$player_name);

my $player_model = $client->modelName();

my $player_ip = $client->ip();

my $status = ' ';

my $sync_status = 0;

my $repeat_status = Slim::Player::Playlist::repeat($client);

my $shuffle_status = Slim::Player::Playlist::shuffle($client);

my $mac = ref($client) ? $client->macaddress() : $client;

if(defined($sTitle)) {

eval {$sName = $sTitle->track()->title || ''; }; warn $@ if $@;

eval {$id = $sTitle->track()->id || ''; }; warn $@ if $@;

eval { $artist = $sTitle->track()->artistName || '';}; warn $@ if $@;

eval { $artist_id = $sTitle->track()->artistid || '';}; warn $@ if $@;

eval { $album = $sTitle->track()->album ? $sTitle->track()->album->name : '';}; warn $@ if $@;

eval { $album_id = $sTitle->track()->albumid || '';}; warn $@ if $@;

eval { $duration = $sTitle->track()->secs;}; warn $@ if $@;

$cover = 'music/current/cover.jpg?player='.$mac.'&album_id='.$album_id;

$artist = encode('UTF-8', $artist);

$album = encode('UTF-8', $album);

$sName = encode('UTF-8', $sName);

my $remoteMeta;

my $handler;

$handler = Slim::Player::ProtocolHandlers->handlerForURL($sTitle->track()->url);

if ( $handler && $handler->can('getMetadataFor') ) {

$remoteMeta = $handler->getMetadataFor($client,$sTitle->track()->url );

$cover = 'music/current/cover.jpg?player='.$mac.'&'.rand();

$album = $sName;

if(defined( $remoteMeta->{album})) {

$album = encode('UTF-8', $remoteMeta->{album});

}

$artist = encode('UTF-8', $remoteMeta->{artist});

$sName = encode('UTF-8', $remoteMeta->{title});

$artist_id = "null";

$album_id = "null";

}

$played = Slim::Player::Source::songTime($client);

}

my $remaining = $duration - $played;

my $iPaused = $client->isPaused();

my $iStopped = $client->isStopped();

my $lifetime = 0;

my $type = "PlayerInformations";

if($iPower == 1) {

if($iPaused ne 1) {

if ($iStopped == 1){

$status = "Stop";
$lifetime = 0;

}else{

$status = "Lecture";
$volume = $iVolume;
$lifetime = roundup($remaining);

}

}else{

$status = "Pause";
$lifetime = 0;

}

}else{

$status = "Off";
$lifetime = 0;

}

if ($iSyncedPlayer ==1 ){

$sync_status = 1;

@SyncedSlaves = Slim::Player::Sync::slaves($client);

my $slave_json;

my $macmaster;

my $master_name;

foreach my $slaveclient (@SyncedSlaves) {

my $macslave = ref($slaveclient) ? $slaveclient->macaddress() : $slaveclient;

my $slave_name = $slaveclient->name();

$slave_json .= "{name:\"$slave_name\",mac:\"$macslave\"},";

}

foreach my $masterclient (@iSyncedMaster) {

$macmaster = ref($masterclient) ? $masterclient->macaddress() : $masterclient;

$master_name = $masterclient->name();

my $volume = $masterclient->volume();

my $player_model = $masterclient->modelName();

my $player_ip = $masterclient->ip();

&sendToConstellation ( $master_name, "{name:\"$master_name\",mac:\"$macmaster\",ip:\"$player_ip\",model:\"$player_model\",repeat:$repeat_status,shuffle:$shuffle_status,dat a:{title:\"$sName\",title_id:$id,artist:\"$artist\",artist_id:$artist_id,album:\"$album\",album_id:$album_id,cover:\"$cover\",duration:$duration,remaining:$remaining,statut:\"$status\",volume:$volume,sync:{master:null,slave:[$slave_json]}}}",$lifetime,$type);

}

foreach my $slaveclient (@SyncedSlaves) {

my $macslave = ref($slaveclient) ? $slaveclient->macaddress() : $slaveclient;

my $slave_name = $slaveclient->name();

my $volume = $slaveclient->volume();

my $player_model = $slaveclient->modelName();

my $player_ip = $slaveclient->ip();

&sendToConstellation ( $slave_name, "{name:\"$slave_name\",mac:\"$macslave\",ip:\"$player_ip\",model:\"$player_model\",repeat:$repeat_status,shuffle:$shuffle_status,dat a:{title:\"$sName\",title_id:$id,artist:\"$artist\",artist_id:$artist_id,album:\"$album\",album_id:$album_id,cover:\"$cover\",duration:$duration,remaining:$remaining,statut:\"$status\",volume:$volume,sync:{master:{name:\"$master_name\",mac:\"$macmaster\"},slave:[$slave_json]}}}",$lifetime,$type);

}

}else{

$log->debug('handlePlayTrack2');

&sendToConstellation ( $player_name, "{name:\"$player_name\",mac:\"$mac\",ip:\"$player_ip\",model:\"$player_model\",repeat:$repeat_status,shuffle:$shuffle_status,dat a:{title:\"$sName\",title_id:$id,artist:\"$artist\",artist_id:$artist_id,album:\"$album\",album_id:$album_id,cover:\"$cover\",duration:$duration,remaining:$remaining,statut:\"$status\",volume:$volume,sync:null}}",$lifetime,$type);

}
}

sub commandCallbackPlayers {

my @players = Slim::Player::Client::clients();

my $informations;

my $info;

my $lifetime = 0;

my $type = "PlayersList";

my $player_connect = 0;

foreach my $client (@players) {

my $client_connect = $client->connected();

if($client_connect ==1){

$player_connect++;

my $client_name = $client->name();

$client_name = encode('UTF-8', $client_name);

my $client_mac = ref($client) ? $client->macaddress() : $client;

$informations .= "{name:\"$client_name\",mac:\"$client_mac\"},";

&handlePlayTrack($client);

$data{$client_name} = '';

}
}


$info = "{players_connect:$player_connect,players:[" . $informations . "]}";

if($player_connect == 0) {


$info = "{players_connect:0,players:null}";


&sendToConstellation ( "Players", $info, 0, $type);


}else{

$informations .= ']}';
&sendToConstellation ( "Players", $informations, $lifetime, $type);

}



}

epoch1970
2018-02-03, 05:10
Try this: http://forums.slimdevices.com/showthread.php?107416-Before-I-go-use-the-code-can-someone-tell-me-about-Virtual-Libraries-with-the-CLI&p=884059&viewfull=1#post884059

Hydro
2018-02-03, 05:58
Yes you get the library id with CLI but inside a server plugin ?

Sent from my ONEPLUS A3003 using Tapatalk

mherger
2018-02-03, 12:22
> Yes you get the library id with CLI but inside a server plugin ?

I think I should start to refer to the commands differently than CLI.
It's misleading. Those commands are being used internally, too, of
course. Look into some code doing eg. $client->execute(). That method
would accept all those "CLI" commands. What you're looking for (and
basically re-implemented) is the "status" query.

--

Michael