mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-05 19:41:55 +02:00
api fixes, added librefm scrobbler (untested) and fixed minor error in header file with rtl vs ltr languages also removed dead RioPlayer plugin
This commit is contained in:
parent
5bd82180f5
commit
d84e62dba7
10 changed files with 286 additions and 106 deletions
|
@ -30,12 +30,13 @@ class scrobbler {
|
|||
public $submit_url;
|
||||
public $queued_tracks;
|
||||
public $reset_handshake = false;
|
||||
public $scrobble_host = 'post.audioscrobbler.com';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* This is the constructer it takes a username and password
|
||||
*/
|
||||
public function __construct($username, $password,$host='',$port='',$url='',$challenge='') {
|
||||
public function __construct($username, $password,$host='',$port='',$url='',$challenge='',$scrobble_host='') {
|
||||
|
||||
$this->error_msg = '';
|
||||
$this->username = trim($username);
|
||||
|
@ -45,6 +46,7 @@ class scrobbler {
|
|||
$this->submit_port = $port;
|
||||
$this->submit_url = $url;
|
||||
$this->queued_tracks = array();
|
||||
if ($scrobble_host) { $this->scrobble_host = $scrobble_host; }
|
||||
|
||||
} // scrobbler
|
||||
|
||||
|
@ -73,7 +75,7 @@ class scrobbler {
|
|||
*/
|
||||
public function handshake() {
|
||||
|
||||
$as_socket = fsockopen('post.audioscrobbler.com', 80, $errno, $errstr, 2);
|
||||
$as_socket = fsockopen($this->scrobble_host, 80, $errno, $errstr, 2);
|
||||
if(!$as_socket) {
|
||||
$this->error_msg = $errstr;
|
||||
return false;
|
||||
|
@ -86,7 +88,7 @@ class scrobbler {
|
|||
$get_string = "GET /?hs=true&p=1.2&c=apa&v=0.1&u=$username&t=$timestamp&a=$auth_token HTTP/1.1\r\n";
|
||||
|
||||
fwrite($as_socket, $get_string);
|
||||
fwrite($as_socket, "Host: post.audioscrobbler.com\r\n");
|
||||
fwrite($as_socket, "Host: $this->scrobble_host\r\n");
|
||||
fwrite($as_socket, "Accept: */*\r\n\r\n");
|
||||
|
||||
$buffer = '';
|
||||
|
@ -202,7 +204,7 @@ class scrobbler {
|
|||
fwrite($as_socket, $action);
|
||||
fwrite($as_socket, "Host: ".$this->submit_host."\r\n");
|
||||
fwrite($as_socket, "Accept: */*\r\n");
|
||||
fwrite($as_socket, "User-Agent: Ampache/3.4\r\n");
|
||||
fwrite($as_socket, "User-Agent: Ampache/3.6\r\n");
|
||||
fwrite($as_socket, "Content-type: application/x-www-form-urlencoded\r\n");
|
||||
fwrite($as_socket, "Content-length: ".strlen($query_str)."\r\n\r\n");
|
||||
|
||||
|
|
|
@ -349,18 +349,20 @@ class Tag extends database_object {
|
|||
/**
|
||||
* get_object_tags
|
||||
* Display all tags that apply to maching target type of the specified id
|
||||
* UNUSED
|
||||
*/
|
||||
public static function get_object_tags($type, $id) {
|
||||
|
||||
if (!self::validate_type($type)) { return array(); }
|
||||
|
||||
$id = Dba::escape($id);
|
||||
|
||||
$sql = "SELECT DISTINCT `tag_map`.`id`, `tag`.`name`, `tag_map`.`user` FROM `tag` " .
|
||||
"LEFT JOIN `tag_map` ON `tag_map`.`id`=`tag`.`map_id` " .
|
||||
"LEFT JOIN `$type` ON `$type`.`id`=`tag_map`.`object_id` " .
|
||||
"WHERE `tag_map`.`object_type`='$type'";
|
||||
$sql = "SELECT `tag_map`.`id`, `tag`.`name`, `tag_map`.`user` FROM `tag` " .
|
||||
"LEFT JOIN `tag_map` ON `tag_map`.`tag_id`=`tag`.`id` " .
|
||||
"WHERE `tag_map`.`object_type`='$type' AND `tag_map`.`object_id`='$id'";
|
||||
|
||||
$results = array();
|
||||
$db_results = Dba::query($sql);
|
||||
$db_results = Dba::read($sql);
|
||||
|
||||
while ($row = Dba::fetch_assoc($db_results)) {
|
||||
$results[] = $row;
|
||||
|
@ -370,6 +372,31 @@ class Tag extends database_object {
|
|||
|
||||
} // get_object_tags
|
||||
|
||||
/**
|
||||
* get_tag_objects
|
||||
* This gets the objects from a specified tag and returns an array of object ids, nothing more
|
||||
*/
|
||||
public static function get_tag_objects($type,$tag_id) {
|
||||
|
||||
if (!self::validate_type($type)) { return array(); }
|
||||
|
||||
$tag_id = Dba::escape($id);
|
||||
|
||||
$sql = "SELECT DISTINCT `tag_map`.`object_id` FROM `tag_map` " .
|
||||
"WHERE `tag_map`.`tag_id`='$tag_id' AND `tag_map`.`object_type`='$type'";
|
||||
$db_results = Dba::read($sql);
|
||||
|
||||
$results = array();
|
||||
|
||||
while ($row = Dba::fetch_assoc($db_results)) {
|
||||
$results[] = $row['object_id'];
|
||||
}
|
||||
|
||||
return $results;
|
||||
|
||||
|
||||
} // get_tag_objects
|
||||
|
||||
/**
|
||||
* get_tags
|
||||
* This is a non-object non type depedent function that just returns tags
|
||||
|
|
|
@ -1762,7 +1762,23 @@ class Update {
|
|||
*/
|
||||
public static function update_360001() {
|
||||
|
||||
// Remove any RIO related information from the database as the plugin has been removed
|
||||
$sql = "DELETE FROM `update_info` WHERE `key` LIKE 'Plugin_Ri%'";
|
||||
$db_results = Dba::write($sql);
|
||||
|
||||
$sql = "DELETE FROM `preference` WHERE `name` LIKE 'rio_%'";
|
||||
$db_results = Dba::write($sql);
|
||||
|
||||
$sql = "SELECT `id` FROM `user`";
|
||||
$db_results = Dba::query($sql);
|
||||
|
||||
User::fix_preferences('-1');
|
||||
|
||||
while ($r = Dba::fetch_assoc($db_results)) {
|
||||
User::fix_preferences($r['id']);
|
||||
} // while we're fixing the useres stuff
|
||||
|
||||
// self::set_version('db_version','360001');
|
||||
|
||||
|
||||
} // update_360001
|
||||
|
|
|
@ -561,6 +561,14 @@ class User extends database_object {
|
|||
}
|
||||
} // end if is_installed
|
||||
|
||||
// Check and see if librefm is loaded and run scrobblizing
|
||||
if (Plugin::is_installed('Libre.FM')) {
|
||||
$librefm = new Plugin('Librefm');
|
||||
if ($lastfm->_plugin->load($this->prefs,$this->id)) {
|
||||
$lastfm->_plugin->submit($song_info,$this->id);
|
||||
}
|
||||
} // end if is_installed
|
||||
|
||||
// Do this last so the 'last played checks are correct'
|
||||
Stats::insert('song',$song_id,$user);
|
||||
Stats::insert('album',$song_info->album,$user);
|
||||
|
|
|
@ -179,7 +179,6 @@ class xmlData {
|
|||
$tags = array_splice($tags,self::$offset,self::$limit);
|
||||
}
|
||||
|
||||
|
||||
$string = '';
|
||||
|
||||
foreach ($tags as $tag_id) {
|
||||
|
@ -190,12 +189,11 @@ class xmlData {
|
|||
"\t<albums>" . intval($counts['album']) . "</albums>\n" .
|
||||
"\t<artists>" . intval($counts['artist']) . "</artists>\n" .
|
||||
"\t<songs>" . intval($counts['songs']) . "</songs>\n" .
|
||||
"\t<videos>" . intval($counts['video']) . "</video>\n" .
|
||||
"\t<videos>" . intval($counts['video']) . "</videos>\n" .
|
||||
"\t<playlists>" . intval($count['playlist']) . "</playlists>\n" .
|
||||
"\t<stream>" . intval($count['live_stream']) . "</stream>\n" .
|
||||
"</tag>\n";
|
||||
} // end foreach
|
||||
|
||||
|
||||
$final = self::_header() . $string . self::_footer();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue