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

"; self::apiOutput($html); exit(); } public static function root() { $r = Plex_XML_Data::createContainer(); Plex_XML_Data::setRootContent($r, Catalog::get_catalogs()); Plex_XML_Data::setContainerSize($r); self::apiOutput($r->asXML()); } public static function library($params) { $r = Plex_XML_Data::createLibContainer(); Plex_XML_Data::setLibraryContent($r); Plex_XML_Data::setContainerSize($r); self::apiOutput($r->asXML()); } public static function system($params) { $r = Plex_XML_Data::createSysContainer(); Plex_XML_Data::setSystemContent($r); 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) { $mime = $response['headers']['Content-Type']; self::setHeader($mime); $art = new Art(0); $art->raw = $response['body']; $thumb = $art->generate_thumb($art->raw, array('width' => $width, 'height' => $height), $mime); echo $thumb['thumb']; exit(); } } } } } 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(); $n = count($params); if ($n == 0) { Plex_XML_Data::setSections($r, Catalog::get_catalogs()); } else { $key = $params[0]; $catalog = Catalog::create_from_id($key); if (!$catalog) { self::createError(404); } if ($n == 1) { Plex_XML_Data::setSectionContent($r, $catalog); } elseif ($n == 2) { $view = $params[1]; if ($view == "all") { Plex_XML_Data::setSectionAll($r, $catalog); } elseif ($view == "albums") { Plex_XML_Data::setSectionAlbums($r, $catalog); } } } 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); $artist->format(); Plex_XML_Data::addArtist($r, $artist); } elseif (Plex_XML_Data::isAlbum($key)) { $album = new Album($id); $album->format(); Plex_XML_Data::addAlbum($r, $album); } } else { $subact = $params[1]; if ($subact == "children") { if (Plex_XML_Data::isArtist($key)) { $artist = new Artist($id); $artist->format(); Plex_XML_Data::setArtistRoot($r, $artist); } else if (Plex_XML_Data::isAlbum($key)) { $album = new Album($id); $album->format(); Plex_XML_Data::setAlbumRoot($r, $album); } else if (Plex_XML_Data::isTrack($key)) { /*$song = new Song($id); $song->format(); Plex_XML_Data::setSongRoot($r, $song);*/ } } elseif ($subact == "thumb") { if ($n == 3) { // Ignore thumb id as we can only have 1 thumb $art = null; if (Plex_XML_Data::isArtist($key)) { $art = new Art($id, "artist"); } else if (Plex_XML_Data::isAlbum($key)) { $art = new Art($id, "album"); } else if (Plex_XML_Data::isSong($key)) { $art = new Art($id, "song"); } if ($art != null) { $art->get_db(); if (!$size) { self::setHeader($art->raw_mime); echo $art->raw; } else { $dim = array(); $dim['width'] = $size; $dim['height'] = $size; $thumb = $art->get_thumb($dim); self::setHeader($art->thumb_mime); echo $thumb['thumb']; } exit(); } } } } } 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) { $url = Song::play_url($id); header("Location: " . $url); } else { self::createError(404); } } } }