public function __construct(array $nested_params, array $external_params) { parent::__construct($nested_params, $external_params); $this->document = new RESTApiVideoFavoriteDocument($this, $this->external_params); if (empty($this->nested_params['users.id'])) { throw new RESTBadRequest("User must be specified"); } $user_id = $this->nested_params['users.id']; $user = \Stb::getById($user_id); if (empty($user)) { throw new RESTNotFound("User not found"); } $this->user_id = $user['id']; $this->manager = \Vod::getInstance(); }
public function get(RESTApiRequest $request, $params) { /*var_dump($params);*/ if (is_array($params) && (count($params) != 4 || $params[1] != 'episodes')) { throw new RESTBadRequest("Bad params"); } $episode = 0; if (is_array($params)) { $video_id = (int) $params[0]; $episode = (int) $params[2]; } else { $video_id = (int) $params; } $video = \Vod::getInstance(); try { $url = $video->getUrlByVideoId($video_id, $episode); } catch (\Exception $e) { throw new RESTServerError("Failed to obtain url"); } if (preg_match("/(\\S+:\\/\\/\\S+)/", $url, $match)) { $url = $match[1]; } return $url; }
ob_start(); if ($link['type'] == 'tv_archive') { $tv_archive = new TvArchive(); try { $url = $tv_archive->getUrlByProgramId($link['media_id']); } catch (\Exception $e) { header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found"); exit; } if ($url) { header("Location: " . $url); ob_end_clean(); exit; } } elseif ($link['type'] == 'vclub') { $video = Vod::getInstance(); try { $url = $video->getUrlByVideoId($link['media_id'], (int) $link['param1']); } catch (\Exception $e) { header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found"); exit; } if (preg_match('/(\\S+:\\/\\/\\S+)/', $url, $match)) { $url = $match[1]; } if ($url) { header("Location: " . $url); ob_end_clean(); exit; } } elseif ($link['type'] == 'pvr') {