} ?> </ul> </div> <?php UI::show_box_bottom(); ?> <div id="additional_information"> </div> <?php define('TABLE_RENDERED', 1); $album_suite = $album->get_group_disks_ids(); foreach ($album_suite as $album_id) { $c_album = new Album($album_id); $c_album->format(); $c_title = scrub_out($c_album->name) . " <span class=\"discnb disc" . $c_album->disk . "\">, " . T_('Disk') . " " . $c_album->disk . "</span>"; $show_direct_play = $show_direct_play_cfg; $show_playlist_add = Access::check('interface', '25'); if ($directplay_limit > 0) { $show_playlist_add = $c_album->song_count <= $directplay_limit; if ($show_direct_play) { $show_direct_play = $show_playlist_add; } } ?> <div class="album_group_disks_title"><span> <?php echo $c_title; ?> </span></div> <div class="album_group_disks_actions">
public static function library_metadata($params) { $r = Plex_XML_Data::createLibContainer(); $n = count($params); $litem = null; $createMode = $_SERVER['REQUEST_METHOD'] == 'POST'; $editMode = $_SERVER['REQUEST_METHOD'] == 'PUT'; if ($n > 0) { $key = $params[0]; $id = Plex_XML_Data::getAmpacheId($key); if ($editMode) { self::check_access(50); } if ($n == 1) { // Should we check that files still exists here? $checkFiles = $_REQUEST['checkFiles']; $extra = $_REQUEST['includeExtra']; if (Plex_XML_Data::isArtist($key)) { $litem = new Artist($id); $litem->format(); if ($editMode) { $dmap = array('title' => 'name', 'summary' => null); $litem->update(self::get_data_from_map($dmap)); } Plex_XML_Data::addArtist($r, $litem); } elseif (Plex_XML_Data::isAlbum($key)) { $litem = new Album($id); $litem->format(); if ($editMode) { $dmap = array('title' => 'name', 'year' => null); $litem->update(self::get_data_from_map($dmap)); } Plex_XML_Data::addAlbum($r, $litem); } elseif (Plex_XML_Data::isTrack($key)) { $litem = new Song($id); $litem->format(); if ($editMode) { $dmap = array('title' => null); $litem->update(self::get_data_from_map($dmap)); } Plex_XML_Data::addSong($r, $litem); } elseif (Plex_XML_Data::isTVShow($key)) { $litem = new TVShow($id); $litem->format(); if ($editMode) { $dmap = array('title' => 'name', 'year' => null, 'summary' => null); $litem->update(self::get_data_from_map($dmap)); } Plex_XML_Data::addTVShow($r, $litem); } elseif (Plex_XML_Data::isTVShowSeason($key)) { $litem = new TVShow_Season($id); $litem->format(); Plex_XML_Data::addTVShowSeason($r, $litem); } elseif (Plex_XML_Data::isVideo($key)) { $litem = Video::create_from_id($id); if ($editMode) { $dmap = array('title' => null, 'year' => null, 'originallyAvailableAt' => 'release_date', 'originalTitle' => 'original_name', 'summary' => null); $litem->update(self::get_data_from_map($dmap)); } $litem->format(); $subtype = strtolower(get_class($litem)); if ($subtype == 'tvshow_episode') { Plex_XML_Data::addEpisode($r, $litem, true); } elseif ($subtype == 'movie') { Plex_XML_Data::addMovie($r, $litem, true); } } elseif (Plex_XML_Data::isPlaylist($key)) { $litem = new Playlist($id); $litem->format(); if ($editMode) { $dmap = array('title' => 'name'); $litem->update(self::get_data_from_map($dmap)); } Plex_XML_Data::addPlaylist($r, $litem); } } else { $subact = $params[1]; if ($subact == "children") { if (Plex_XML_Data::isArtist($key)) { $litem = new Artist($id); $litem->format(); Plex_XML_Data::setArtistRoot($r, $litem); } else { if (Plex_XML_Data::isAlbum($key)) { $litem = new Album($id); $litem->format(); Plex_XML_Data::setAlbumRoot($r, $litem); } else { if (Plex_XML_Data::isTVShow($key)) { $litem = new TVShow($id); $litem->format(); Plex_XML_Data::setTVShowRoot($r, $litem); } else { if (Plex_XML_Data::isTVShowSeason($key)) { $litem = new TVShow_Season($id); $litem->format(); Plex_XML_Data::setTVShowSeasonRoot($r, $litem); } } } } } elseif ($subact == "thumbs" || $subact == "posters" || $subact == "arts" || $subact == 'backgrounds') { $kind = Plex_XML_Data::getPhotoKind($subact); if ($createMode) { // Upload art $litem = Plex_XML_Data::createLibraryItem($key); if ($litem != null) { $uri = Plex_XML_Data::getMetadataUri($key) . '/' . Plex_XML_Data::getPhotoPlexKind($kind) . '/' . $key; if (is_a($litem, 'video')) { $type = 'video'; } else { $type = get_class($litem); } $art = new Art($litem->id, $type, $kind); $raw = file_get_contents("php://input"); $art->insert($raw); header('Content-Type: text/html'); echo $uri; exit; } } Plex_XML_Data::addPhotos($r, $key, $kind); } elseif ($subact == "thumb" || $subact == "poster" || $subact == "art" || $subact == "background") { if ($n == 3) { $kind = Plex_XML_Data::getPhotoKind($subact); // Ignore art id as we can only have 1 thumb $art = null; if (Plex_XML_Data::isArtist($key)) { $art = new Art($id, "artist", $kind); } else { if (Plex_XML_Data::isAlbum($key)) { $art = new Art($id, "album", $kind); } else { if (Plex_XML_Data::isTrack($key)) { $art = new Art($id, "song", $kind); } else { if (Plex_XML_Data::isTVShow($key)) { $art = new Art($id, "tvshow", $kind); } else { if (Plex_XML_Data::isTVShowSeason($key)) { $art = new Art($id, "tvshow_season", $kind); } else { if (Plex_XML_Data::isVideo($key)) { $art = new Art($id, "video", $kind); } } } } } } if ($art != null) { $art->get_db(); ob_clean(); if (!isset($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; } } } } } if ($litem != null) { $catalog_ids = $litem->get_catalogs(); if (count($catalog_ids) > 0) { $catalog = Catalog::create_from_id($catalog_ids[0]); Plex_XML_Data::addCatalogIdentity($r, $catalog); } } Plex_XML_Data::setContainerSize($r); self::apiOutputXml($r->asXML()); }
/** * get_favorites * returns an array of your $type favorites */ public function get_favorites($type) { $results = Stats::get_user(AmpConfig::get('popular_threshold'), $type, $this->id, 1); $items = array(); foreach ($results as $r) { /* If its a song */ if ($type == 'song') { $data = new Song($r['object_id']); $data->count = $r['count']; $data->format(); $data->f_link; $items[] = $data; } elseif ($type == 'album') { $data = new Album($r['object_id']); //$data->count = $r['count']; $data->format(); $items[] = $data; } elseif ($type == 'artist') { $data = new Artist($r['object_id']); //$data->count = $r['count']; $data->format(); $data->f_name = $data->f_link; $items[] = $data; } elseif ($type == 'genre') { $data = new Genre($r['object_id']); //$data->count = $r['count']; $data->format(); $data->f_name = $data->f_link; $items[] = $data; } } // end foreach return $items; }
$artist->format(false); $results[] = array('type' => T_('Artists'), 'link' => $artist->link, 'label' => $artist->name, 'value' => $artist->name, 'rels' => '', 'image' => Art::url($artist->id, 'artist', null, 10)); } } if ($target == 'anywhere' || $target == 'album') { $searchreq = array('limit' => $limit, 'type' => 'album', 'rule_1_input' => $search, 'rule_1_operator' => '2', 'rule_1' => 'title'); $sres = Search::run($searchreq); // Litmit not reach, new search with another operator if (count($sres) < $limit) { $searchreq['limit'] = $limit - count($sres); $searchreq['rule_1_operator'] = '0'; $sres = array_unique(array_merge($sres, Search::run($searchreq))); } foreach ($sres as $id) { $album = new Album($id); $album->format(true); $a_title = $album->f_title; if ($album->disk) { $a_title .= " [" . T_('Disk') . " " . $album->disk . "]"; } $results[] = array('type' => T_('Albums'), 'link' => $album->link, 'label' => $a_title, 'value' => $album->f_title, 'rels' => $album->f_artist, 'image' => Art::url($album->id, 'album', null, 10)); } } if ($target == 'anywhere' || $target == 'title') { $searchreq = array('limit' => $limit, 'type' => 'song', 'rule_1_input' => $search, 'rule_1_operator' => '2', 'rule_1' => 'title'); $sres = Search::run($searchreq); // Litmit not reach, new search with another operator if (count($sres) < $limit) { $searchreq['limit'] = $limit - count($sres); $searchreq['rule_1_operator'] = '0'; $sres = array_unique(array_merge($sres, Search::run($searchreq)));
/** * load_latest_album * This loads in the latest added albums * @return array */ public static function load_latest_album() { $ids = Stats::get_newest('album', 10); $results = array(); foreach ($ids as $id) { $album = new Album($id); $album->format(); $xml_array = array('title' => $album->f_name, 'link' => $album->link, 'description' => $album->f_artist_name . ' - ' . $album->f_name, 'image' => Art::url($album->id, 'album', null, 2), 'comments' => '', 'pubDate' => date("c", $album->get_addtime_first_song())); $results[] = $xml_array; } // end foreach return $results; }
/** * gather_lastfm * This returns the art from lastfm. It doesn't currently require an * account but may in the future. */ public function gather_lastfm($limit, $options = false) { $data = array(); // Create the parser object $lastfm = new LastFMSearch(); switch ($this->type) { case 'album': if (is_array($options)) { $artist = $options['artist']; $album = $options['album_name']; } else { $media = new Album($this->uid); $media->format(); $artist = $media->artist_name; $album = $media->full_name; } break; default: return $data; } if (AmpConfig::get('proxy_host') and AmpConfig::get('proxy_port')) { $proxyhost = AmpConfig::get('proxy_host'); $proxyport = AmpConfig::get('proxy_port'); $proxyuser = AmpConfig::get('proxy_user'); $proxypass = AmpConfig::get('proxy_pass'); debug_event('LastFM', 'proxy set', 5); $lastfm->setProxy($proxyhost, $proxyport, $proxyuser, $proxypass); } $raw_data = $lastfm->album_search($artist, $album); if (!count($raw_data)) { return array(); } $coverart = $raw_data['coverart']; if (!is_array($coverart)) { return array(); } ksort($coverart); foreach ($coverart as $url) { // We need to check the URL for the /noimage/ stuff if (strpos($url, '/noimage/') !== false) { debug_event('LastFM', 'Detected as noimage, skipped ' . $url, 3); continue; } // HACK: we shouldn't rely on the extension to determine file type $results = pathinfo($url); $mime = 'image/' . $results['extension']; $data[] = array('url' => $url, 'mime' => $mime); if ($limit && count($data) >= $limit) { return $data; } } // end foreach return $data; }
/** * gather_art * * This runs through all of the albums and finds art for them * This runs through all of the needs art albums and trys * to find the art for them from the mp3s */ public function gather_art() { // Make sure they've actually got methods $art_order = AmpConfig::get('art_order'); if (!count($art_order)) { debug_event('gather_art', 'art_order not set, Catalog::gather_art aborting', 3); return true; } // Prevent the script from timing out set_time_limit(0); $search_count = 0; $albums = $this->get_album_ids(); // Run through them and get the art! foreach ($albums as $album_id) { $art = new Art($album_id, 'album'); $album = new Album($album_id); // We're going to need the name here $album->format(); debug_event('gather_art', 'Gathering art for ' . $album->name, 5); $options = array('album_name' => $album->full_name, 'artist' => $album->artist_name, 'keyword' => $album->artist_name . ' ' . $album->full_name); $results = $art->gather($options, 1); if (count($results)) { // Pull the string representation from the source $image = Art::get_from_source($results[0], 'album'); if (strlen($image) > '5') { $art->insert($image, $results[0]['mime']); // If they've enabled resizing of images generate a thumbnail if (AmpConfig::get('resize_images')) { $thumb = $art->generate_thumb($image, array('width' => 275, 'height' => 275), $results[0]['mime']); if (is_array($thumb)) { $art->save_thumb($thumb['thumb'], $thumb['thumb_mime'], '275x275'); } } } else { debug_event('gather_art', 'Image less than 5 chars, not inserting', 3); } } // Stupid little cutesie thing $search_count++; if (UI::check_ticker()) { UI::update_text('count_art_' . $this->id, $search_count); UI::update_text('read_art_' . $this->id, scrub_out($album->name)); } unset($found); } // foreach albums // One last time for good measure UI::update_text('count_art_' . $this->id, $search_count); }
public static function setArtistRoot(SimpleXMLElement $xml, Artist $artist) { $id = self::getAlbumId($artist->id); $xml->addAttribute('key', $id); self::addArtistMeta($xml, $artist); $xml->addAttribute('allowSync', '1'); $xml->addAttribute('nocache', '1'); $xml->addAttribute('parentIndex', '1'); // ?? $xml->addAttribute('parentTitle', $artist->name); $xml->addAttribute('title1', ''); // TODO: Should be catalog name $xml->addAttribute('title2', $artist->name); $xml->addAttribute('viewGroup', 'album'); $xml->addAttribute('viewMode', '65592'); $allalbums = $artist->get_albums(null, true); foreach ($allalbums as $id) { $album = new Album($id); $album->format(); self::addAlbum($xml, $album); } }
</th> </tr> </thead> <tbody> <?php if (AmpConfig::get('ratings')) { Rating::build_cache('album', $object_ids); } if (AmpConfig::get('userflags')) { Userflag::build_cache('album', $object_ids); } /* Foreach through the albums */ foreach ($object_ids as $album_id) { $album = new Album($album_id); $album->allow_group_disks = $allow_group_disks; $album->format(); ?> <tr id="album_<?php echo $album->id; ?> " class="<?php echo UI::flip_class(); ?> "> <?php require AmpConfig::get('prefix') . '/templates/show_album_row.inc.php'; ?> </tr> <?php } //end foreach ($albums as $album)
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) { // Should we check that files still exists here? $checkFiles = $_REQUEST['checkFiles']; 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); } elseif (Plex_XML_Data::isTrack($key)) { $song = new Song($id); $song->format(); Plex_XML_Data::addSong($r, $song); } } 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); } } } 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::isTrack($key)) { $art = new Art($id, "song"); } } } if ($art != null) { $art->get_db(); if (!isset($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()); }
</thead> <tbody> <?php if (AmpConfig::get('ratings')) { Rating::build_cache('album', $object_ids); } if (AmpConfig::get('userflags')) { Userflag::build_cache('album', $object_ids); } $show_direct_play_cfg = AmpConfig::get('directplay'); $directplay_limit = AmpConfig::get('direct_play_limit'); /* Foreach through the albums */ foreach ($object_ids as $album_id) { $libitem = new Album($album_id); $libitem->allow_group_disks = $allow_group_disks; $libitem->format(true, $limit_threshold); $show_direct_play = $show_direct_play_cfg; $show_playlist_add = Access::check('interface', '25'); if ($directplay_limit > 0) { $show_playlist_add = $libitem->song_count <= $directplay_limit; if ($show_direct_play) { $show_direct_play = $show_playlist_add; } } ?> <tr id="album_<?php echo $libitem->id; ?> " class="<?php echo UI::flip_class(); ?>
public static function _musicChilds($prmPath, $prmQuery, $start, $count) { $mediaItems = array(); $maxCount = 0; $queryData = array(); parse_str($prmQuery, $queryData); $parent = 'amp://music' . $prmPath; $pathreq = explode('/', $prmPath); if ($pathreq[0] == '' && count($pathreq) > 0) { array_shift($pathreq); } switch ($pathreq[0]) { case 'artists': switch (count($pathreq)) { case 1: // Get artists list //$artists = Catalog::get_artists(); //list($maxCount, $artists) = self::_slice($artists, $start, $count); $artists = Catalog::get_artists(null, $count, $start); list($maxCount, $artists) = array(999999, $artists); foreach ($artists as $artist) { $artist->format(); $mediaItems[] = self::_itemArtist($artist, $parent); } break; case 2: // Get artist's albums list $artist = new Artist($pathreq[1]); if ($artist->id) { $album_ids = $artist->get_albums(); list($maxCount, $album_ids) = self::_slice($album_ids, $start, $count); foreach ($album_ids as $album_id) { $album = new Album($album_id); $album->format(); $mediaItems[] = self::_itemAlbum($album, $parent); } } break; } break; case 'albums': switch (count($pathreq)) { case 1: // Get albums list //!!$album_ids = Catalog::get_albums(); //!!list($maxCount, $album_ids) = self::_slice($album_ids, $start, $count); $album_ids = Catalog::get_albums($count, $start); list($maxCount, $album_ids) = array(999999, $album_ids); foreach ($album_ids as $album_id) { $album = new Album($album_id); $album->format(); $mediaItems[] = self::_itemAlbum($album, $parent); } break; case 2: // Get album's songs list $album = new Album($pathreq[1]); if ($album->id) { $song_ids = $album->get_songs(); list($maxCount, $song_ids) = self::_slice($song_ids, $start, $count); foreach ($song_ids as $song_id) { $song = new Song($song_id); $song->format(); $mediaItems[] = self::_itemSong($song, $parent); } } break; } break; case 'songs': switch (count($pathreq)) { case 1: // Get songs list $catalogs = Catalog::get_catalogs(); foreach ($catalogs as $catalog_id) { $catalog = Catalog::create_from_id($catalog_id); $songs = $catalog->get_songs(); list($maxCount, $songs) = self::_slice($songs, $start, $count); foreach ($songs as $song) { $song->format(); $mediaItems[] = self::_itemSong($song, $parent); } } break; } break; case 'playlists': switch (count($pathreq)) { case 1: // Get playlists list $pl_ids = Playlist::get_playlists(); list($maxCount, $pl_ids) = self::_slice($pl_ids, $start, $count); foreach ($pl_ids as $pl_id) { $playlist = new Playlist($pl_id); $playlist->format(); $mediaItems[] = self::_itemPlaylist($playlist, $parent); } break; case 2: // Get playlist's songs list $playlist = new Playlist($pathreq[1]); if ($playlist->id) { $items = $playlist->get_items(); list($maxCount, $items) = self::_slice($items, $start, $count); foreach ($items as $item) { if ($item['object_type'] == 'song') { $song = new Song($item['object_id']); $song->format(); $mediaItems[] = self::_itemSong($song, $parent); } } } break; } break; case 'smartplaylists': switch (count($pathreq)) { case 1: // Get playlists list $pl_ids = Search::get_searches(); list($maxCount, $pl_ids) = self::_slice($pl_ids, $start, $count); foreach ($pl_ids as $pl_id) { $playlist = new Search($pl_id, 'song'); $playlist->format(); $mediaItems[] = self::_itemPlaylist($playlist, $parent); } break; case 2: // Get playlist's songs list $playlist = new Search($pathreq[1], 'song'); if ($playlist->id) { $items = $playlist->get_items(); list($maxCount, $items) = self::_slice($items, $start, $count); foreach ($items as $item) { if ($item['object_type'] == 'song') { $song = new Song($item['object_id']); $song->format(); $mediaItems[] = self::_itemSong($song, $parent); } } } break; } break; default: $mediaItems[] = self::_musicMetadata('artists'); $mediaItems[] = self::_musicMetadata('albums'); $mediaItems[] = self::_musicMetadata('songs'); $mediaItems[] = self::_musicMetadata('playlists'); $mediaItems[] = self::_musicMetadata('smartplaylists'); break; } if ($maxCount == 0) { $maxCount = count($mediaItems); } return array($maxCount, $mediaItems); }
/** * albums * * This echos out a standard albums XML document, it pays attention to the limit * * @param array $albums (description here...) * @return string return xml */ public static function albums($albums) { if (count($albums) > self::$limit or self::$offset > 0) { $albums = array_splice($albums, self::$offset, self::$limit); } Rating::build_cache('album', $albums); $string = ""; foreach ($albums as $album_id) { $album = new Album($album_id); $album->format(); $rating = new Rating($album_id, 'album'); // Build the Art URL, include session $art_url = AmpConfig::get('web_path') . '/image.php?object_id=' . $album->id . '&object_type=album&auth=' . scrub_out($_REQUEST['auth']); $string .= "<album id=\"" . $album->id . "\">\n" . "\t<name><![CDATA[" . $album->name . "]]></name>\n"; // Do a little check for artist stuff if ($album->artist_count != 1) { $string .= "\t<artist id=\"0\"><![CDATA[Various]]></artist>\n"; } else { $string .= "\t<artist id=\"{$album->artist_id}\"><![CDATA[{$album->artist_name}]]></artist>\n"; } $string .= "\t<year>" . $album->year . "</year>\n" . "\t<tracks>" . $album->song_count . "</tracks>\n" . "\t<disk>" . $album->disk . "</disk>\n" . self::tags_string($album->tags) . "\t<art><![CDATA[{$art_url}]]></art>\n" . "\t<preciserating>" . $rating->get_user_rating() . "</preciserating>\n" . "\t<rating>" . $rating->get_user_rating() . "</rating>\n" . "\t<averagerating>" . $rating->get_average_rating() . "</averagerating>\n" . "\t<mbid>" . $album->mbid . "</mbid>\n" . "</album>\n"; } // end foreach $final = self::_header() . $string . self::_footer(); return $final; }
public function get_description() { if (!empty($this->comment)) { return $this->comment; } $album = new Album($this->album); $album->format(); return $album->get_description(); }