* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License v2 * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ if (!isset($video_type)) { $libitem = Video::create_from_id($libitem->id); $libitem->format(); $video_type = strtolower(get_class($libitem)); } ?> <td class="cel_play"> <span class="cel_play_content"> </span> <div class="cel_play_hover"> <?php if (AmpConfig::get('directplay')) { ?> <?php echo Ajax::button('?page=stream&action=directplay&object_type=video&object_id=' . $libitem->id, 'play', T_('Play'), 'play_video_' . $libitem->id); ?> <?php if (Stream_Playlist::check_autoplay_append()) {
/** * * @param string $type * @param int $id */ public function gather_art_item($type, $id) { debug_event('gather_art', 'Gathering art for ' . $type . '/' . $id . '...', 5); // Should be more generic ! if ($type == 'video') { $libitem = Video::create_from_id($id); } else { $libitem = new $type($id); } $options = array(); $libitem->format(); if ($libitem->id) { if (count($options) == 0) { // Only search on items with default art kind as `default`. if ($libitem->get_default_art_kind() == 'default') { $keywords = $libitem->get_keywords(); $keyword = ''; foreach ($keywords as $key => $word) { $options[$key] = $word['value']; if ($word['important']) { if (!empty($word['value'])) { $keyword .= ' ' . $word['value']; } } } $options['keyword'] = $keyword; } $parent = $libitem->get_parent(); if ($parent != null) { if (!Art::has_db($parent['object_id'], $parent['object_type'])) { $this->gather_art_item($parent['object_type'], $parent['object_id']); } } } } $art = new Art($id, $type); $results = $art->gather($options, 1); if (count($results)) { // Pull the string representation from the source $image = Art::get_from_source($results[0], $type); 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')) { $size = array('width' => 275, 'height' => 275); $thumb = $art->generate_thumb($image, $size, $results[0]['mime']); if (is_array($thumb)) { $art->save_thumb($thumb['thumb'], $thumb['thumb_mime'], $size); } } } else { debug_event('gather_art', 'Image less than 5 chars, not inserting', 3); } } if ($type == 'video' && AmpConfig::get('generate_video_preview')) { Video::generate_preview($id); } if (UI::check_ticker()) { UI::update_text('read_art_' . $this->id, $libitem->get_fullname()); } }
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()); }
public function remove_from_disk() { $deleted = true; $video_ids = $this->get_episodes(); foreach ($video_ids as $id) { $video = Video::create_from_id($id); $deleted = $video->remove_from_disk(); if (!$deleted) { debug_event('tvshow_season', 'Error when deleting the video `' . $id . '`.', 1); break; } } if ($deleted) { $sql = "DELETE FROM `tvshow_season` WHERE `id` = ?"; $deleted = Dba::write($sql, array($this->id)); if ($deleted) { Art::gc('tvshow_season', $this->id); Userflag::gc('tvshow_season', $this->id); Rating::gc('tvshow_season', $this->id); Shoutbox::gc('tvshow_season', $this->id); } } return $deleted; }
* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License v2 * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ $media = Video::create_from_id($media->id); $media->format(); ?> <div class="np_group" id="np_group_1"> <div class="np_cell cel_username"> <label><?php echo T_('Username'); ?> </label> <a title="<?php echo scrub_out($agent); ?> " href="<?php echo $web_path; ?> /stats.php?action=show_user&user_id=<?php
public static function createLibraryItem($id) { $item = null; $oid = self::getAmpacheId($id); $type = self::getLibraryItemType($id); if ($type) { if ($type == 'video') { $item = Video::create_from_id($oid); } else { $item = new $type($oid); } } if ($item != null) { if ($item->id) { $item->format(); } else { $item = null; } } return $item; }
* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ $web_path = AmpConfig::get('web_path'); $button = Ajax::button('?page=index&action=random_videos', 'random', T_('Refresh'), 'random_video_refresh'); UI::show_box_top(T_('Videos of the Moment') . ' ' . $button, 'box box_random_videos'); if ($videos) { foreach ($videos as $video_id) { $video = Video::create_from_id($video_id); $video->format(); ?> <div class="random_video"> <div class="art_album"> <?php if (Art::is_enabled()) { $release_art = $video->get_release_item_art(); Art::display($release_art['object_type'], $release_art['object_id'], $video->get_fullname(), 6, $video->link); } else { ?> <?php echo $video->get_fullname(); ?> <?php }
case 'delete': if (AmpConfig::get('demo_mode')) { break; } $video_id = scrub_in($_REQUEST['video_id']); show_confirmation(T_('Video Deletion'), T_('Are you sure you want to permanently delete this video?'), AmpConfig::get('web_path') . "/video.php?action=confirm_delete&video_id=" . $video_id, 1, 'delete_video'); break; case 'confirm_delete': if (AmpConfig::get('demo_mode')) { break; } $video = Video::create_from_id($_REQUEST['video_id']); if (!Catalog::can_remove($video)) { debug_event('video', 'Unauthorized to remove the video `.' . $video->id . '`.', 1); UI::access_denied(); exit; } if ($video->remove_from_disk()) { show_confirmation(T_('Video Deletion'), T_('Video has been deleted.'), AmpConfig::get('web_path')); } else { show_confirmation(T_('Video Deletion'), T_('Cannot delete this video.'), AmpConfig::get('web_path')); } break; case 'show_video': default: $video = Video::create_from_id($_REQUEST['video_id']); $video->format(); require_once AmpConfig::get('prefix') . '/templates/show_video.inc.php'; break; } UI::show_footer();