public static function _videoMetadata($prmPath, $prmQuery = '') { $root = 'amp://video'; $pathreq = explode('/', $prmPath); if ($pathreq[0] == '' && count($pathreq) > 0) { array_shift($pathreq); } $meta = null; switch ($pathreq[0]) { case 'tvshows': switch (count($pathreq)) { case 1: $counts = count(Catalog::get_tvshows()); $meta = array('id' => $root . '/tvshows', 'parentID' => $root, 'restricted' => '1', 'childCount' => $counts, 'dc:title' => T_('TV Shows'), 'upnp:class' => 'object.container'); break; case 2: $tvshow = new TVShow($pathreq[1]); if ($tvshow->id) { $tvshow->format(); $meta = self::_itemTVShow($tvshow, $root . '/tvshows'); } break; case 3: $season = new TVShow_Season($pathreq[2]); if ($season->id) { $season->format(); $meta = self::_itemTVShowSeason($season, $root . '/tvshows/' . $pathreq[1]); } break; case 4: $video = new TVShow_Episode($pathreq[3]); if ($video->id) { $video->format(); $meta = self::_itemVideo($video, $root . '/tvshows/' . $pathreq[1] . '/' . $pathreq[2]); } break; } break; case 'clips': switch (count($pathreq)) { case 1: $counts = Catalog::get_videos_count(null, 'clip'); $meta = array('id' => $root . '/clips', 'parentID' => $root, 'restricted' => '1', 'childCount' => $counts, 'dc:title' => T_('Clips'), 'upnp:class' => 'object.container'); break; case 2: $video = new Clip($pathreq[1]); if ($video->id) { $video->format(); $meta = self::_itemVideo($video, $root . '/clips'); } break; } break; case 'movies': switch (count($pathreq)) { case 1: $counts = Catalog::get_videos_count(null, 'movie'); $meta = array('id' => $root . '/movies', 'parentID' => $root, 'restricted' => '1', 'childCount' => $counts, 'dc:title' => T_('Movies'), 'upnp:class' => 'object.container'); break; case 2: $video = new Movie($pathreq[1]); if ($video->id) { $video->format(); $meta = self::_itemVideo($video, $root . '/movies'); } break; } break; case 'personal_videos': switch (count($pathreq)) { case 1: $counts = Catalog::get_videos_count(null, 'personal_video'); $meta = array('id' => $root . '/personal_videos', 'parentID' => $root, 'restricted' => '1', 'childCount' => $counts, 'dc:title' => T_('Personal Videos'), 'upnp:class' => 'object.container'); break; case 2: $video = new Personal_Video($pathreq[1]); if ($video->id) { $video->format(); $meta = self::_itemVideo($video, $root . '/personal_videos'); } break; } break; default: $meta = array('id' => $root, 'parentID' => '0', 'restricted' => '1', 'childCount' => '4', 'dc:title' => T_('Video'), 'upnp:class' => 'object.container'); break; } return $meta; }
/** * Insert video for derived type. * @param array $data * @param array $gtypes * @param array $options * @return int */ private static function insert_video_type(array $data, $gtypes, $options = array()) { if (count($gtypes) > 0) { $gtype = $gtypes[0]; switch ($gtype) { case 'tvshow': return TVShow_Episode::insert($data, $gtypes, $options); case 'movie': return Movie::insert($data, $gtypes, $options); case 'clip': return Clip::insert($data, $gtypes, $options); case 'personal_video': return Personal_Video::insert($data, $gtypes, $options); default: // Do nothing, video entry already created and no additional data for now break; } } return $data['id']; }