update stream count by 1 seem impossible
Jamroom Developers
The URL that should be being used in the /update currently is:
but that should be
--edit--
Alternatively if you don't know what is causing that url to be like that then changing the _update() function to allow ?audio_title works too, use this function:
PREVIOUSLY
function view_jrShoutcastPlayer_update($_post, $_user, $_conf) {
jrCore_validate_location_url();
if (!isset($_post['song']) || strlen($_post['song']) == 0) {
return jrCore_json_response(array('error' => 'invalid song title'));
}
if (!isset($_post['profile_name']) || strlen($_post['song']) == 0) {
return jrCore_json_response(array('error' => 'invalid profile name'));
}
$_sp = array(
'search' => array(
"audio_title = {$_post['song']}",
"profile_name = {$_post['profile_name']}",
"audio_artist = {$_post['profile_name']}",
),
'return_keys' => array('_item_id'),
'exclude_jrUser_keys' => true,
'exclude_jrProfile_quota_keys' => true,
'order_by' => array('_created' => 'numerical_asc'),
'limit' => 1
);
$_rt = jrCore_db_search_items('jrAudio', $_sp);
if (isset($_rt) && is_array($_rt)) {
jrCore_db_increment_key('jrAudio',$_rt['_items'][0]['_item_id'],'audio_file_stream_count',1,true);
return jrCore_json_response(array('success' => 1));
}
return jrCore_json_response(array('error' => 'update failed'));
}
CHANGE IT TO:
function view_jrShoutcastPlayer_update($_post, $_user, $_conf)
{
jrCore_validate_location_url();
$title = '';
if (!empty($_post['song'])) {
$title = $_post['song'];
}
elseif (!empty($_post['audio_title'])) {
$title = $_post['audio_title'];
}
if (!empty($title)) {
return jrCore_json_response(array('error' => 'invalid song title'));
}
if (!isset($_post['profile_name'])) {
return jrCore_json_response(array('error' => 'invalid profile name'));
}
$_sp = array(
'search' => array(
"audio_title = {$title}",
"profile_name = {$_post['profile_name']}",
"audio_artist = {$_post['profile_name']}",
),
'return_keys' => array('_item_id'),
'exclude_jrUser_keys' => true,
'exclude_jrProfile_quota_keys' => true,
'order_by' => array('_created' => 'numerical_asc'),
'limit' => 1
);
$_rt = jrCore_db_search_items('jrAudio', $_sp);
if (isset($_rt) && is_array($_rt)) {
jrCore_db_increment_key('jrAudio', $_rt['_items'][0]['_item_id'], 'audio_file_stream_count', 1, true);
return jrCore_json_response(array('success' => 1));
}
return jrCore_json_response(array('error' => 'update failed'));
}
updated by @michael: 06/27/23 05:42:06PM