diff --git a/lib/class/album.class.php b/lib/class/album.class.php index 8cf47e27..321aa181 100644 --- a/lib/class/album.class.php +++ b/lib/class/album.class.php @@ -396,7 +396,7 @@ class Album extends database_object $mbid = $data['mbid']; $current_id = $this->id; - + if ($artist != $this->artist_id AND $artist) { // Update every song $songs = $this->get_songs(); diff --git a/lib/class/plex_api.class.php b/lib/class/plex_api.class.php index 28fb75ee..e2383456 100644 --- a/lib/class/plex_api.class.php +++ b/lib/class/plex_api.class.php @@ -20,7 +20,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ - + require_once Config::get('prefix') . '/modules/plugins/helper.php'; /** @@ -45,9 +45,9 @@ class Plex_Api header("HTTP/1.0 200 OK", true, 200); header("Connection: close", true); header("X-Plex-Protocol: 1.0"); - + header_remove("x-powered-by"); - + if (strtolower($f) == "xml") { header("Cache-Control: no-cache", true); header("Content-type: text/xml; charset=" . Config::get('site_charset'), true); @@ -58,33 +58,32 @@ class Plex_Api header("Content-type: " . $f, true); } } - + public static function apiOutput($string) { - ob_start('ob_gzhandler'); - echo $string; + ob_start('ob_gzhandler'); + echo $string; ob_end_flush(); header("X-Plex-Compressed-Content-Length: " . ob_get_length()); header("X-Plex-Original-Content-Length: " . strlen($string)); } - + public static function createError($code) { $error = ""; - switch ($code) - { + switch ($code) { case 404: $error = "Not Found"; break; } header("Content-type: text/html", true); header("HTTP/1.0 ". $code . " " . $error, true, $code); - + $html = "" . $error . "

" . $code . " " . $error . "

"; self::apiOutput($html); exit(); } - + public static function root() { $r = Plex_XML_Data::createContainer(); @@ -92,7 +91,7 @@ class Plex_Api Plex_XML_Data::setContainerSize($r); self::apiOutput($r->asXML()); } - + public static function library($params) { $r = Plex_XML_Data::createLibContainer(); @@ -100,7 +99,7 @@ class Plex_Api Plex_XML_Data::setContainerSize($r); self::apiOutput($r->asXML()); } - + public static function system($params) { $r = Plex_XML_Data::createSysContainer(); @@ -108,37 +107,37 @@ class Plex_Api Plex_XML_Data::setContainerSize($r); self::apiOutput($r->asXML()); } - + public static function clients($params) { $r = Plex_XML_Data::createContainer(); Plex_XML_Data::setContainerSize($r); self::apiOutput($r->asXML()); } - + public static function channels($params) { $r = Plex_XML_Data::createContainer(); Plex_XML_Data::setContainerSize($r); self::apiOutput($r->asXML()); } - + public static function photos($params) { $r = Plex_XML_Data::createPluginContainer(); Plex_XML_Data::setContainerSize($r); self::apiOutput($r->asXML()); } - + public static function photo($params) { if (count($params) == 2) { if ($params[0] == ':' && $params[1] == 'transcode') { - + $width = $_REQUEST['width']; $height = $_REQUEST['height']; $url = $_REQUEST['url']; - + if ($width && $height && $url) { $response = PluginHelper::wsGet($url); if ($response['status'] == 200) { @@ -154,28 +153,28 @@ class Plex_Api } } } - + public static function music($params) { $r = Plex_XML_Data::createPluginContainer(); Plex_XML_Data::setContainerSize($r); self::apiOutput($r->asXML()); } - + public static function video($params) { $r = Plex_XML_Data::createPluginContainer(); Plex_XML_Data::setContainerSize($r); self::apiOutput($r->asXML()); } - + public static function applications($params) { $r = Plex_XML_Data::createPluginContainer(); Plex_XML_Data::setContainerSize($r); self::apiOutput($r->asXML()); } - + public static function library_sections($params) { $r = Plex_XML_Data::createLibContainer(); @@ -199,20 +198,20 @@ class Plex_Api } } } - + Plex_XML_Data::setContainerSize($r); self::apiOutput($r->asXML()); } - + public static function library_metadata($params) { $r = Plex_XML_Data::createLibContainer(); $n = count($params); if ($n > 0) { $key = $params[0]; - + $id = Plex_XML_Data::getAmpacheId($key); - + if ($n == 1) { if (Plex_XML_Data::isArtist($key)) { $artist = new Artist($id); @@ -225,7 +224,7 @@ class Plex_Api } } else { $subact = $params[1]; - if($subact == "children") { + if ($subact == "children") { if (Plex_XML_Data::isArtist($key)) { $artist = new Artist($id); $artist->format(); @@ -253,7 +252,7 @@ class Plex_Api if ($art != null) { $art->get_db(); - + if (!$size) { self::setHeader($art->raw_mime); echo $art->raw; @@ -274,15 +273,15 @@ class Plex_Api Plex_XML_Data::setContainerSize($r); self::apiOutput($r->asXML()); } - + public static function library_parts($params) { $n = count($params); - + if ($n == 2) { $key = $params[0]; $file = $params[1]; - + $id = Plex_XML_Data::getAmpacheId($key); $song = new Song($id); if ($song->id) { diff --git a/lib/class/plex_xml_data.class.php b/lib/class/plex_xml_data.class.php index cc1676a3..d4455f59 100644 --- a/lib/class/plex_xml_data.class.php +++ b/lib/class/plex_xml_data.class.php @@ -60,12 +60,12 @@ class Plex_XML_Data { return $id + Plex_XML_Data::AMPACHEID_TRACK; } - + public static function getMediaId($id) { return $id + Plex_XML_Data::AMPACHEID_MEDIA; } - + public static function getPartId($id) { return $id + Plex_XML_Data::AMPACHEID_PART; @@ -99,12 +99,12 @@ class Plex_XML_Data { return ($id >= Plex_XML_Data::AMPACHEID_TRACK && $id < Plex_XML_Data::AMPACHEID_MEDIA); } - + public static function isMedia($id) { return ($id >= Plex_XML_Data::AMPACHEID_MEDIA && $id < Plex_XML_Data::AMPACHEID_PART); } - + public static function isPart($id) { return ($id >= Plex_XML_Data::AMPACHEID_PART); @@ -123,7 +123,7 @@ class Plex_XML_Data $response->addAttribute('status', 'ok'); return $response; } - + public static function createContainer() { $response = new SimpleXMLElement(''); @@ -138,14 +138,14 @@ class Plex_XML_Data $response->addAttribute('mediaTagVersion', '1365384731'); return $response; } - + public static function createPluginContainer() { $response = self::createContainer(); $response->addAttribute('content', 'plugins'); return $response; } - + public static function createSysContainer() { $response = self::createContainer(); @@ -159,32 +159,32 @@ class Plex_XML_Data { $container->addAttribute('size', $container->count()); } - + public static function setContainerTitle($container, $title) { $container->addAttribute('title1', $title); } - + public static function getResourceUri($resource) { return '/resources/' . $resource; } - + public static function getMetadataUri($key) { return '/library/metadata/' . $key; } - + public static function getPartUri($key, $type) { return '/library/parts/' . $key . '/file.' . $type; } - + public static function uuidFromKey($key) { return hash('sha1', $key); } - + public static function setRootContent($xml, $catalogs) { $xml->addAttribute('friendlyName', 'Ampache'); @@ -199,7 +199,7 @@ class Plex_XML_Data $xml->addAttribute('transcoderVideo', '0'); $xml->addAttribute('updatedAt', self::getLastUpdate($catalogs)); $xml->addAttribute('version', '0.9.8.10.215-020456b'); - + $dir = $xml->addChild('Directory'); $dir->addAttribute('count', '1'); $dir->addAttribute('key', 'channels'); @@ -237,7 +237,7 @@ class Plex_XML_Data $dir->addAttribute('key', 'transcode'); $dir->addAttribute('title', 'transcode'); } - + public static function getLastUpdate($catalogs) { $last_update = 0; @@ -253,12 +253,12 @@ class Plex_XML_Data $last_update = $catalog->last_clean; } } - + return $last_update; } public static function setSections($xml, $catalogs) - { + { foreach ($catalogs as $id) { $catalog = Catalog::create_from_id($id); $catalog->format(); @@ -274,16 +274,16 @@ class Plex_XML_Data self::setSectionXContent($dir, $catalog, 'title'); //$date = new DateTime("2013-01-01"); //$dir->addAttribute('createdAt', $date->getTimestamp()); - + $location = $dir->addChild('Location'); $location->addAttribute('id', $id); $location->addAttribute('path', $catalog->f_full_info); } - + $xml->addAttribute('allowSync', '0'); self::setContainerTitle($xml, 'Plex Library'); } - + public static function setLibraryContent($xml) { $dir = $xml->addChild('Directory'); @@ -295,11 +295,11 @@ class Plex_XML_Data $dir = $xml->addChild('Directory'); $dir->addAttribute('key', 'onDeck'); $dir->addAttribute('title', 'On Deck Content'); - + $xml->addAttribute('allowSync', '0'); self::setContainerTitle($xml, 'Plex Library'); } - + public static function setSectionContent($xml, $catalog) { $dir = $xml->addChild('Directory'); @@ -315,7 +315,7 @@ class Plex_XML_Data $dir = $xml->addChild('Directory'); $dir->addAttribute('key', 'recentlyAdded'); $dir->addAttribute('title', 'Recently Added'); - + $dir = $xml->addChild('Directory'); $dir->addAttribute('key', 'search?type=8'); $dir->addAttribute('prompt', 'Search for Artists'); @@ -331,7 +331,7 @@ class Plex_XML_Data $dir->addAttribute('prompt', 'Search for Tracks'); $dir->addAttribute('search', '1'); $dir->addAttribute('title', 'Search Tracks...'); - + $xml->addAttribute('allowSync', '0'); $xml->addAttribute('content', 'secondary'); $xml->addAttribute('nocache', '1'); @@ -339,14 +339,14 @@ class Plex_XML_Data $xml->addAttribute('viewMode', '65592'); self::setSectionXContent($xml, $catalog); } - + public static function setSectionXContent($xml, $catalog, $title = 'title1') { $xml->addAttribute('art', self::getResourceUri('artist-fanart.jpg')); $xml->addAttribute('thumb', self::getResourceUri('artist.png')); $xml->addAttribute($title, $catalog->name); } - + public static function setSystemContent($xml) { $dir = $xml->addChild('Directory'); @@ -366,11 +366,11 @@ class Plex_XML_Data $dir->addAttribute('title', 'Plug-ins'); $dir->addAttribute('name', 'Plug-ins'); } - + public static function setSectionAll($xml, $catalog) { $artists = Catalog::get_artists(array($catalog->id)); - + $xml->addAttribute('allowSync', '1'); self::setSectionXContent($xml, $catalog); $xml->addAttribute('title2', 'All Artists'); @@ -379,16 +379,16 @@ class Plex_XML_Data $xml->addAttribute('viewMode', '65592'); $xml->addAttribute('librarySectionID', $catalog->id); $xml->addAttribute('librarySectionUUID', self::uuidFromKey($catalog->id)); - - foreach($artists as $artist) { + + foreach ($artists as $artist) { self::addArtist($xml, $artist); } } - + public static function setSectionAlbums($xml, $catalog) { $albums = $catalog->get_album_ids(); - + $xml->addAttribute('allowSync', '0'); self::setSectionXContent($xml, $catalog); $xml->addAttribute('title2', 'By Album'); @@ -396,8 +396,8 @@ class Plex_XML_Data $xml->addAttribute('nocache', '1'); $xml->addAttribute('viewGroup', 'album'); $xml->addAttribute('viewMode', '65592'); - - foreach($albums as $id) { + + foreach ($albums as $id) { $album = new Album($id); $album->format(); self::addAlbum($xml, $album); @@ -413,7 +413,7 @@ class Plex_XML_Data $xdir->addAttribute('addedAt', ''); $xdir->addAttribute('updatedAt', ''); self::addArtistMeta($xdir, $artist); - + $tags = Tag::get_top_tags('artist', $artist->id); foreach ($tags as $tag_id=>$value) { $tag = new Tag($tag_id); @@ -421,7 +421,7 @@ class Plex_XML_Data $xgenre->addAttribute('tag', $tag->name); } } - + public static function addArtistMeta($xml, $artist) { $id = self::getArtistId($artist->id); @@ -430,7 +430,7 @@ class Plex_XML_Data $xml->addAttribute('summary', ''); $xml->addAttribute('thumb', ''); } - + public static function addAlbum($xml, $album) { $xdir = $xml->addChild('Directory'); @@ -444,7 +444,7 @@ class Plex_XML_Data if ($album->year != 0 && $album->year != 'N/A') { $xdir->addAttribute('year', $album->year); } - + $tags = Tag::get_top_tags('album', $album->id); foreach ($tags as $tag_id=>$value) { $tag = new Tag($tag_id); @@ -452,7 +452,7 @@ class Plex_XML_Data $xgenre->addAttribute('tag', $tag->name); } } - + public static function addAlbumMeta($xml, $album) { $id = self::getAlbumId($album->id); @@ -475,7 +475,7 @@ class Plex_XML_Data $xml->addAttribute('addedAt', ''); $xml->addAttribute('updatedAt', ''); } - + public static function setArtistRoot($xml, $artist) { self::addArtistMeta($xml, $artist); @@ -487,7 +487,7 @@ class Plex_XML_Data $xml->addAttribute('title2', $artist->name); $xml->addAttribute('viewGroup', 'album'); $xml->addAttribute('viewMode', '65592'); - + $allalbums = $artist->get_albums(); foreach ($allalbums as $id) { $album = new Album($id); @@ -511,7 +511,7 @@ class Plex_XML_Data } $xml->addAttribute('viewGroup', 'track'); $xml->addAttribute('viewMode', '65593'); - + $allsongs = $album->get_songs(); foreach ($allsongs as $id) { $song = new Song($id); @@ -534,7 +534,7 @@ class Plex_XML_Data $xdir->addAttribute('type', 'track'); $xdir->addAttribute('addedAt', ''); $xdir->addAttribute('updatedAt', ''); - + $xmedia = $xdir->addChild('Media'); $mediaid = self::getMediaId($song->id); $xmedia->addAttribute('id', $mediaid); @@ -544,7 +544,7 @@ class Plex_XML_Data // Type != Codec != Container, but that's how Ampache works today... $xmedia->addAttribute('audioCodec', $song->type); $xmedia->addAttribute('container', $song->type); - + $xpart = $xmedia->addChild('Part'); $partid = self::getPartId($song->id); $xpart->addAttribute('id', $partid); diff --git a/lib/class/radio.class.php b/lib/class/radio.class.php index fa5d2b18..9565d48d 100644 --- a/lib/class/radio.class.php +++ b/lib/class/radio.class.php @@ -46,7 +46,7 @@ class Radio extends database_object implements media public function __construct($id = null) { if (!$id) { return false; } - + $info = $this->get_info($id, 'live_stream'); // Set the vars diff --git a/lib/class/song.class.php b/lib/class/song.class.php index d0bc7932..37851134 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -555,7 +555,7 @@ class Song extends database_object implements media { foreach ($data as $key=>$value) { debug_event('song.class.php', $key.'='.$value, '5'); - + switch ($key) { case 'artist_name': // Need to create new artist according the name @@ -895,7 +895,7 @@ class Song extends database_object implements media // Format the size $this->f_size = UI::format_bytes($this->size); - + $this->f_lyrics = "title) . "\" href=\"" . Config::get('web_path') . "/song.php?action=show_lyrics&song_id=" . $this->id . "\">" . T_('Show Lyrics') . ""; return true; @@ -1106,12 +1106,13 @@ class Song extends database_object implements media return array('format' => $target, 'command' => $cmd . ' ' . $args); } - - public function get_lyrics() { + + public function get_lyrics() + { if ($this->lyrics) { return array('text' => $this->lyrics); } - + foreach (Plugin::get_plugins('get_lyrics') as $plugin_name) { $plugin = new Plugin($plugin_name); if ($plugin->load()) { diff --git a/lib/class/update.class.php b/lib/class/update.class.php index 3a4d356f..02efa0de 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -313,7 +313,7 @@ class Update $update_string = '- Remove unused live_stream fields and add codec field.
'; $version[] = array('version' => '360022', 'description' => $update_string); - + $update_string = '- Enable/Disable SubSonic and Plex backend.
'; $version[] = array('version' => '360023', 'description' => $update_string); @@ -1717,7 +1717,7 @@ class Update return true; } - + /** * update_360023 * @@ -1733,7 +1733,7 @@ class Update $sql = "INSERT INTO `user_preference` VALUES (-1,?,'0')"; Dba::write($sql, array($id)); - + $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . "VALUES ('plex_backend','0','Use Plex backend',25,'boolean','system')"; Dba::write($sql); diff --git a/server/playlist.ajax.php b/server/playlist.ajax.php index 3152ef68..be5a18fd 100644 --- a/server/playlist.ajax.php +++ b/server/playlist.ajax.php @@ -42,7 +42,7 @@ switch ($_REQUEST['action']) { $browse->save_objects($object_ids); $browse->show_objects($object_ids); $browse->store(); - + $results['browse_content'] = ob_get_clean(); break; case 'create': diff --git a/templates/header.inc.php b/templates/header.inc.php index 0c74442c..a227f4a7 100644 --- a/templates/header.inc.php +++ b/templates/header.inc.php @@ -74,7 +74,7 @@ function forceIframe() var jsAjaxShowEditUrl = ""; var jsSaveTitle = ""; var jsCancelTitle = ""; - + > diff --git a/templates/show_song.inc.php b/templates/show_song.inc.php index 39a6261c..0356285e 100644 --- a/templates/show_song.inc.php +++ b/templates/show_song.inc.php @@ -81,7 +81,7 @@ $button_flip_state_id = 'button_flip_state_' . $song->id; if (Config::get('show_played_times')) { $songprops[gettext_noop('# Played')] = scrub_out($song->object_cnt); } - + if (Config::get('show_lyrics')) { $songprops[gettext_noop('Lyrics')] = $song->f_lyrics; }