/** * insert * Insert a new tv show episode and related entities. */ public static function insert(array $data, $gtypes = array(), $options = array()) { if (empty($data['tvshow'])) { $data['tvshow'] = T_('Unknown'); } $tags = $data['genre']; $tvshow = TVShow::check($data['tvshow'], $data['year']); if ($options['gather_art'] && $tvshow && $data['tvshow_art'] && !Art::has_db($tvshow, 'tvshow')) { $art = new Art($tvshow, 'tvshow'); $art->insert_url($data['tvshow_art']); } $tvshow_season = TVShow_Season::check($tvshow, $data['tvshow_season']); if ($options['gather_art'] && $tvshow_season && $data['tvshow_season_art'] && !Art::has_db($tvshow_season, 'tvshow_season')) { $art = new Art($tvshow_season, 'tvshow_season'); $art->insert_url($data['tvshow_season_art']); } if (is_array($tags)) { foreach ($tags as $tag) { $tag = trim($tag); if (!empty($tag)) { Tag::add('tvshow_season', $tvshow_season, $tag, false); Tag::add('tvshow', $tvshow, $tag, false); } } } $sdata = $data; // Replace relation name with db ids $sdata['tvshow'] = $tvshow; $sdata['tvshow_season'] = $tvshow_season; return self::create($sdata); }
?> </th> </tr> </thead> <tbody> <?php // Cache the ratings we are going to use if (AmpConfig::get('ratings')) { Rating::build_cache('tvshow', $object_ids); } if (AmpConfig::get('userflags')) { Userflag::build_cache('tvshow', $object_ids); } /* Foreach through every tv show that has been passed to us */ foreach ($object_ids as $tvshow_id) { $libitem = new TVShow($tvshow_id); $libitem->format(); ?> <tr id="tvshow_<?php echo $libitem->id; ?> " class="<?php echo UI::flip_class(); ?> "> <?php require AmpConfig::get('prefix') . UI::find_template('show_tvshow_row.inc.php'); ?> </tr> <?php }
public function get_description() { // No season description for now, always return tvshow description $tvshow = new TVShow($this->tvshow); return $tvshow->get_description(); }
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 static function _videoChilds($prmPath, $prmQuery, $start, $count) { $mediaItems = array(); $maxCount = 0; $queryData = array(); parse_str($prmQuery, $queryData); $parent = 'amp://video' . $prmPath; $pathreq = explode('/', $prmPath); if ($pathreq[0] == '' && count($pathreq) > 0) { array_shift($pathreq); } switch ($pathreq[0]) { case 'tvshows': switch (count($pathreq)) { case 1: // Get tvshow list $tvshows = Catalog::get_tvshows(); list($maxCount, $tvshows) = self::_slice($tvshows, $start, $count); foreach ($tvshows as $tvshow) { $tvshow->format(); $mediaItems[] = self::_itemTVShow($tvshow, $parent); } break; case 2: // Get season list $tvshow = new TVShow($pathreq[1]); if ($tvshow->id) { $season_ids = $tvshow->get_seasons(); list($maxCount, $season_ids) = self::_slice($season_ids, $start, $count); foreach ($season_ids as $season_id) { $season = new TVShow_Season($season_id); $season->format(); $mediaItems[] = self::_itemTVShowSeason($season, $parent); } } break; case 3: // Get episode list $season = new TVShow_Season($pathreq[2]); if ($season->id) { $episode_ids = $season->get_episodes(); list($maxCount, $episode_ids) = self::_slice($episode_ids, $start, $count); foreach ($episode_ids as $episode_id) { $video = new Video($episode_id); $video->format(); $mediaItems[] = self::_itemVideo($video, $parent); } } break; } break; case 'clips': switch (count($pathreq)) { case 1: // Get clips list $videos = Catalog::get_videos(null, 'clip'); list($maxCount, $videos) = self::_slice($videos, $start, $count); foreach ($videos as $video) { $video->format(); $mediaItems[] = self::_itemVideo($video, $parent); } break; } break; case 'movies': switch (count($pathreq)) { case 1: // Get clips list $videos = Catalog::get_videos(null, 'movie'); list($maxCount, $videos) = self::_slice($videos, $start, $count); foreach ($videos as $video) { $video->format(); $mediaItems[] = self::_itemVideo($video, $parent); } break; } break; case 'personal_videos': switch (count($pathreq)) { case 1: // Get clips list $videos = Catalog::get_videos(null, 'personal_video'); list($maxCount, $videos) = self::_slice($videos, $start, $count); foreach ($videos as $video) { $video->format(); $mediaItems[] = self::_itemVideo($video, $parent); } break; } break; default: $mediaItems[] = self::_videoMetadata('clips'); $mediaItems[] = self::_videoMetadata('tvshows'); $mediaItems[] = self::_videoMetadata('movies'); $mediaItems[] = self::_videoMetadata('personal_videos'); break; } if ($maxCount == 0) { $maxCount = count($mediaItems); } return array($maxCount, $mediaItems); }
public static function setTVShowSeasonRoot(SimpleXMLElement $xml, TVShow_Season $season) { $tvshow = new TVShow($season->tvshow); $tvshow->format(); $id = self::getTVShowSeasonId($season->id); $xml->addAttribute('key', $id); $xml->addAttribute('allowSync', '1'); $xml->addAttribute('nocache', '1'); $xml->addAttribute('parentIndex', '1'); // ?? $xml->addAttribute('parentTitle', ''); $xml->addAttribute('grandparentStudio', ''); $xml->addAttribute('grandparentTitle', $tvshow->f_name); $xml->addAttribute('title1', $tvshow->f_name); $xml->addAttribute('title2', $season->f_name); $xml->addAttribute('viewGroup', 'episode'); $xml->addAttribute('viewMode', '65592'); $xml->addAttribute('thumb', self::getMetadataUri($id) . '/thumb/' . $id); $xml->addAttribute('art', self::getMetadataUri($id) . '/art/' . $id); //$xml->addAttribute('banner', self::getMetadataUri($id) . '/banner/' . $id); $episodes = $season->get_episodes(); foreach ($episodes as $episode_id) { $episode = new TVShow_Episode($episode_id); $episode->format(); self::addEpisode($xml, $episode); } }
break; } $tvshow = new TVShow($_REQUEST['tvshow_id']); if (!Catalog::can_remove($tvshow)) { debug_event('tvshow', 'Unauthorized to remove the tvshow `.' . $tvshow->id . '`.', 1); UI::access_denied(); exit; } if ($tvshow->remove_from_disk()) { show_confirmation(T_('TVShow Deletion'), T_('TVShow has been deleted.'), AmpConfig::get('web_path')); } else { show_confirmation(T_('TVShow Deletion'), T_('Cannot delete this tvshow.'), AmpConfig::get('web_path')); } break; case 'show': $tvshow = new TVShow($_REQUEST['tvshow']); $tvshow->format(); $object_ids = $tvshow->get_seasons(); $object_type = 'tvshow_season'; require_once AmpConfig::get('prefix') . '/templates/show_tvshow.inc.php'; break; case 'match': case 'Match': $match = scrub_in($_REQUEST['match']); if ($match == "Browse") { $chr = ""; } else { $chr = $match; } /* Enclose this in the purty box! */ require AmpConfig::get('prefix') . '/templates/show_box_top.inc.php';
/** * gc * * Cleans up the inherited object tables */ public static function gc() { Movie::gc(); TVShow_Episode::gc(); TVShow_Season::gc(); TVShow::gc(); Personal_Video::gc(); Clip::gc(); }
/** * Deletes seasons and episodes will not be any more in database. * Used in /tvshow/actions/executeRefreshTVShow * * @param TVShow $tvshow * @param Array $current_seasons ex: [2, 5] * @param Array $current_episodes ex: [23, 54] */ public static function deleteSeasonsAndEpisodes($tvshow, $current_seasons, $current_episodes) { foreach ($tvshow['Seasons'] as $season) { if (!in_array($season['id'], $current_seasons)) { $tvshow->unlink('Seasons', $season['id']); $season->delete(); } else { foreach ($season['Episodes'] as $episode) { if (!in_array($episode['id'], $current_episodes)) { $season->unlink('Episodes', $episode['id']); $episode->delete(); } } } } }
public function savehasilterms($termsx = '', $type = 'movie', $page = 1, $self = 0) { //cek exist terms $termsx = $this->clean($termsx); $termsx = $this->filterminchar($termsx); $terms = $termsx['string']; if ($termsx['in'] == '') { $termsx['in'] = '""'; } $existterms = $this->CI->db->query('SELECT COUNT(*) as cnt FROM movie_terms WHERE k_name IN(' . $termsx['in'] . ')')->result_array(); if ($existterms[0]['cnt'] == 0) { //echo 1; // if($page==1){$page=rand(1,30);} $results = $this->searches($terms, $type, $page); if ($self == 0) { $expterms = explode(' ', $terms); if (!empty($expterms)) { foreach ($expterms as $temsnya) { // if(strlen($temsnya)>3){ // $clean = $this->clean($temsnya); $this->savetermsnofile($temsnya, $type); // } } } } // pr($results->results);die; foreach ($results->results as $datasave) { // $imgurl=$datasave->poster_path; if ($this->cinmovie < 10) { //$keywords=''; if ($type == 'movie') { $original = $this->getMovie($datasave->id); //$keywords=$this->getKeywordsmovie($datasave->id).' '.$datasave->original_title.' '.$terms; $keywords = $datasave->original_title . ' ' . $terms; $sqlinsert = "INSERT IGNORE INTO movie_data SET id_tmdb=?, id_genre=?, original=?,date=?, type=?, keywords=?"; $this->CI->db->query($sqlinsert, array($datasave->id, implode(' ', $datasave->genre_ids), json_encode($original->getdata()), date('Y-m-d H:i:s'), $type, $this->clean($keywords))); } elseif ($type == 'tv') { $appendToResponse = 'append_to_response=trailers,images,credits,translations,keywords,external_ids'; $original = new TVShow($this->_call('tv/' . $datasave->id, $appendToResponse)); $originals = (object) $original->getdata(); //pr(json_encode($originals));die; //$keywords=$this->getKeywordsmovie($datasave->id).' '.$datasave->name.' '.$terms; $keywords = $datasave->name . ' ' . $terms; $sqlinsert = "INSERT IGNORE INTO movie_data SET id_tmdb=?, id_genre=?, original=?,date=?, type=?, keywords=?"; $this->CI->db->query($sqlinsert, array($datasave->id, implode(' ', $datasave->genre_ids), json_encode($originals), date('Y-m-d H:i:s'), $type, $this->clean($keywords))); } } $this->cinmovie++; } $this->cinmovie = 0; return $results->total_pages; } }
public function __construct( $name, $parentFolder ) { parent::__construct( $name ); $this->folder = "{$parentFolder}/{$name}"; }