Skip to content

Commit

Permalink
V0.10
Browse files Browse the repository at this point in the history
 - Mise en place des listes de recherche pour les entrées : `serveur` + `net_radio` + `usb` + `qobuz` + `deezer` + `tidal` + `napster`.
 - Refonte des écrans `HTML` + `CSS` pour plus de lisibilité.
 - Ajout d’un écran pour le tuner + ajout de commande dédiées tuner.
 - Meilleur gestion des commandes d’infos concernant la piste.
 - Gestion des `scenes`.
  • Loading branch information
lucguinchard committed Mar 29, 2022
1 parent be1ce90 commit befae90
Show file tree
Hide file tree
Showing 6 changed files with 555 additions and 155 deletions.
65 changes: 64 additions & 1 deletion core/ajax/YamahaMusiccast.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
$return = YamahaMusiccast::searchAndSaveDeviceList();
$nb = count($return);
if($nb === 0) {
ajax::error(__('La recherche automatique n’a pas trouvé d’appareil compatible.', __FILE__). ' ' . __('Pour plus d’information consulter la ', __FILE__) . ' <a href="https://lucguinchard.github.io/plugin-Yamaha-musiccast/fr_FR/#tocAnchor-1-5">' . __('FAQ', __FILE__) . '</a>');
ajax::error(__('La recherche automatique n’a pas trouvé d’appareil compatible.', __FILE__). ' ' . __('Pour plus d’information consulter la ', __FILE__) . ' <a href="https://lucguinchard.github.io/plugin-Yamaha-musiccast/#faq">' . __('FAQ', __FILE__) . '</a>');
} else {
$deviceList = "";
foreach ($return as $device){
Expand All @@ -146,6 +146,69 @@
ajax::success('La recherche a trouvé ' . $nb . ' zone(s) compatible(s) : ' . substr($deviceList, 0, -2) . '.', __FILE__);
}
break;
case 'searchDirlist':
$id = init('id');
$yamahaMusiccast = YamahaMusiccast::byId($id);
$device[YamahaMusiccast::main] = $yamahaMusiccast;
$type = init('type');
$index = init('index');
$input = init('input');
$zone = $yamahaMusiccast->getConfiguration('zone');
$power_state_cmd = $yamahaMusiccast->getCmd(null, 'power_state');
if($power_state_cmd->execCmd() !== 'on') {
$yamahaMusiccast->callAPIGET(YamahaMusiccast::url_v1 . "$zone/setPower?power=on");
log::add("YamahaMusiccast", 'info', 'Allumer l’appareil');
sleep(1);
}
$inputCmd = $yamahaMusiccast->getCmd('info', 'input');
if($inputCmd->execCmd() !== $input) {
$yamahaMusiccast->callAPIGET(YamahaMusiccast::url_v1 . "$zone/setInput?input=$input");
log::add("YamahaMusiccast", 'info', 'Change Input');
}
if($type != null) {
switch($type) {
case 'select':
YamahaMusiccast::callListControlSelect($device, $index);
break;
case 'return':
YamahaMusiccast::callListControlReturn($device);
break;
// ALL
case 'main':
// Pandora
case 'auto_complete':
case 'search_artist':
case 'search_track':
$text = init('text');
YamahaMusiccast::callSearchString($device, $type, $text, $index);
break;
}
}
$netusbListInfo = YamahaMusiccast::callGetNetusbListInfo($device, $input);
ajax::success($netusbListInfo);
break;
case 'playDirlist':
$id = init('id');
$yamahaMusiccast = YamahaMusiccast::byId($id);
$device[YamahaMusiccast::main] = $yamahaMusiccast;
$input = init('input');
$index = init('index');
if($index != null) {
YamahaMusiccast::callListControlPlay($device, $index);
}
ajax::success("OK");
break;
case 'searchPlaylist':
$id = init('id');
$yamahaMusiccast = YamahaMusiccast::byId($id);
$device[YamahaMusiccast::main] = $yamahaMusiccast;
$input = init('input');
if(empty($input)) {
$input = "server";
}
$index = init('index');
ajax::success("Cette partie affichera les playlists enregistrées.");
break;
}

// Lève une exception si la requête n'a pas été traitée avec succès (Appel de la fonction ajax::success());
Expand Down
55 changes: 43 additions & 12 deletions core/class/YamahaMusiccast.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,6 @@ public static function traitement_message($host, $port, $json) {
log::add(__CLASS__, 'info', 'TODO: $tag_updated - Reserved ' . print_r($tag_updated = $system->tag_updated, true));
}
}

foreach ($device as $eqLogic) {
$zone = $eqLogic->getConfiguration('zone');
if (!empty($result->$zone)) {
Expand Down Expand Up @@ -1527,17 +1526,14 @@ public static function callNetusbGetPlayInfo($device) {
if (!empty($result->total_time)) {
YamahaMusiccast::checkAndUpdateDeviceCmd($device, 'netusb_total_time', $result->total_time);
}
if (!empty($result->artist)) {
YamahaMusiccast::checkAndUpdateDeviceCmd($device, 'netusb_artist', $result->artist);
if (!empty($result->artist) || !empty($result->artist) || !empty($result->track)) {
YamahaMusiccast::checkAndUpdateDeviceCmd($device, 'netusb_artist', "");
YamahaMusiccast::checkAndUpdateDeviceCmd($device, 'netusb_album', "");
YamahaMusiccast::checkAndUpdateDeviceCmd($device, 'netusb_track', "");
YamahaMusiccast::checkAndUpdateDeviceCmd($device, 'netusb_albumart_url', '/plugins/' . __CLASS__ . '/plugin_info/' . __CLASS__ . '_icon.png');
}
if (!empty($result->artist)) {
// Lorsque la radio Web est allumé, seul `artist` est renseigné.
foreach ($device as $eqLogic) {
$eqLogic->checkAndUpdateCmd('netusb_album', "");
$eqLogic->checkAndUpdateCmd('netusb_track', "");
}
//YamahaMusiccast::checkAndUpdateDeviceCmd($device, 'netusb_album', "");
//YamahaMusiccast::checkAndUpdateDeviceCmd($device, 'netusb_track', "");
YamahaMusiccast::checkAndUpdateDeviceCmd($device, 'netusb_artist', $result->artist);
}
if (!empty($result->album)) {
YamahaMusiccast::checkAndUpdateDeviceCmd($device, 'netusb_album', $result->album);
Expand Down Expand Up @@ -1676,8 +1672,8 @@ public static function callGetLocationInfo($device) {
}
}

public static function callGetNetusbListInfo($device) {
$result = $device[YamahaMusiccast::main]->callAPIGET(YamahaMusiccast::url_v1_netusb . "getListInfo?list_id=main&input=net_radio&index=0&size=8");
public static function callGetNetusbListInfo($device, $input = "net_radio") {
$result = $device[YamahaMusiccast::main]->callAPIGET(YamahaMusiccast::url_v1_netusb . "getListInfo?list_id=main&input=" . $input . "&index=0&size=8");
if (!empty($result->service_list)) {
log::add(__CLASS__, 'info', 'TODO: Gestion de la méthode netusb getListInfo - Warning:net_radio');
foreach ($result->service_list as $service) {
Expand All @@ -1689,6 +1685,41 @@ public static function callGetNetusbListInfo($device) {
$trial_time_left = $service->trial_time_left;
}
}
return $result;
}

public static function callListControlReturn($device) {
$result = $device[YamahaMusiccast::main]->callAPIGET(YamahaMusiccast::url_v1_netusb . "setListControl?list_id=&type=return");
if (!empty($result->service_list)) {

}
return $result;
}

public static function callSearchString($device, $list_id, $string, $index) {
$data = '{
"list_id": "'.$list_id.'",
"string":"'.$string.'",
"index":"'.$index.'"
}';
$result = $device[YamahaMusiccast::main]->callAPIPOST(YamahaMusiccast::url_v1_netusb . "setSearchString", $data);
return $result;
}

public static function callListControlSelect($device, $index = 0) {
$result = $device[YamahaMusiccast::main]->callAPIGET(YamahaMusiccast::url_v1_netusb . "setListControl?list_id=&type=select&index=" . $index);
if (!empty($result->service_list)) {

}
return $result;
}

public static function callListControlPlay($device, $index = 0) {
$result = $device[YamahaMusiccast::main]->callAPIGET(YamahaMusiccast::url_v1_netusb . "setListControl?list_id=&type=play&index=" . $index);
if (!empty($result->service_list)) {

}
return $result;
}

public static function callDistributionGetInfo($device) {
Expand Down
Loading

0 comments on commit befae90

Please sign in to comment.