diff --git a/feed/index.php b/feed/index.php index 81f19d851..c9d13e27d 100644 --- a/feed/index.php +++ b/feed/index.php @@ -1,56 +1,57 @@ getWebSiteTitle(); $link = $global['webSiteRootURL']; $logo = "{$global['webSiteRootURL']}videos/userPhoto/logo.png"; $description = ""; $extraPluginFile = $global['systemRootPath'] . 'plugin/Customize/Objects/ExtraConfig.php'; if (file_exists($extraPluginFile) && AVideoPlugin::isEnabledByName("Customize")) { require_once $extraPluginFile; $ec = new ExtraConfig(); $description = $ec->getDescription(); } if(!empty($_GET['channelName'])){ $user = User::getChannelOwner($_GET['channelName']); $showOnlyLoggedUserVideos = $user['id']; $title = User::getNameIdentificationById($user['id']); $link = User::getChannelLink($user['id']); $logo = User::getPhoto($user['id']); } $cacheName = "feedCache".json_encode($_GET); $rows = ObjectYPT::getCache($cacheName, 0); if(empty($rows)){ // send $_GET['catName'] to be able to filter by category $rows = Video::getAllVideos("viewable", $showOnlyLoggedUserVideos); + ObjectYPT::setCache($cacheName, $rows); }else{ $rows = object_to_array($rows); } if(!empty($_REQUEST['roku'])){ header('Content-Type: application/json'); include $global['systemRootPath'] . 'feed/roku.json.php'; }else if(empty($_REQUEST['mrss'])){ header('Content-Type: text/xml; charset=UTF8'); include $global['systemRootPath'] . 'feed/rss.php'; }else{ header('Content-Type: text/xml; charset=UTF8'); include $global['systemRootPath'] . 'feed/mrss.php'; } function feedText($text){ return str_replace(array('&&'), array('&'), str_replace(array('&','<','>'), array('&','<','>'), (strip_tags(br2nl($text))))); } ?> \ No newline at end of file diff --git a/feed/roku.json.php b/feed/roku.json.php index a463bdfd1..29806d52a 100644 --- a/feed/roku.json.php +++ b/feed/roku.json.php @@ -1,61 +1,78 @@ providerName = $title; $obj->language = "en"; $obj->lastUpdated = date('c'); $obj->movies = array(); + +$cacheName = "roju.json.movies"; + +$movies = ObjectYPT::getCache($cacheName, 0); + $categories = array(); -foreach ($rows as $row) { - $videoSource = Video::getHigestResolution($row['filename']); - if(empty($videoSource)){ - continue; +if (empty($movies)) { + foreach ($rows as $row) { + $videoSource = Video::getHigestResolution($row['filename']); + if (empty($videoSource)) { + continue; + } + $movie = new stdClass(); + $movie->id = Video::getLinkToVideo($row['id'], $row['clean_title'], false, "permalink"); + $movie->title = UTF8encode($row['title']); + $movie->longDescription = "=> " . _substr(strip_tags(br2nl(UTF8encode($row['description']))), 0, 490); + $movie->shortDescription = _substr($movie->longDescription, 0, 200); + $movie->thumbnail = Video::getRokuImage($row['id']); + $movie->tags = _substr(UTF8encode($row['category']), 0, 20); + $movie->genres = array("special"); + $movie->releaseDate = date('c', strtotime($row['created'])); + + $content = new stdClass(); + $content->dateAdded = date('c', strtotime($row['created'])); + $content->captions = array(); + $content->duration = durationToSeconds($row['duration']); + $content->language = "en"; + $content->adBreaks = array("00:00:00"); + + $video = new stdClass(); + $video->url = $videoSource["url"]; + $video->quality = "HD"; + $video->videoType = Video::getVideoTypeText($row['filename']); + $content->videos = array($video); + + $movie->content = $content; + + $obj->movies[] = $movie; + + if (empty($categories[$row['categories_id']])) { + $categories[$row['categories_id']] = new stdClass(); + $categories[$row['categories_id']]->name = $movie->tags; + $categories[$row['categories_id']]->query = $movie->tags; + $categories[$row['categories_id']]->order = 'most_recent'; + } } - $movie = new stdClass(); - $movie->id = Video::getLinkToVideo($row['id'], $row['clean_title'], false, "permalink"); - $movie->title = UTF8encode($row['title']); - $movie->longDescription = "=> " . _substr(strip_tags(br2nl(UTF8encode($row['description']))), 0, 490); - $movie->shortDescription = _substr($movie->longDescription, 0, 200); - $movie->thumbnail = Video::getRokuImage($row['id']); - $movie->tags = _substr(UTF8encode($row['category']), 0, 20); - $movie->genres = array("special"); - $movie->releaseDate = date('c', strtotime($row['created'])); - - $content = new stdClass(); - $content->dateAdded = date('c', strtotime($row['created'])); - $content->captions = array(); - $content->duration = durationToSeconds($row['duration']); - $content->language = "en"; - $content->adBreaks = array("00:00:00"); - - $video = new stdClass(); - $video->url = $videoSource["url"]; - $video->quality = "HD"; - $video->videoType = Video::getVideoTypeText($row['filename']); - $content->videos = array($video); - - $movie->content = $content; - - $obj->movies[] = $movie; - - if(empty($categories[$row['categories_id']])){ - $categories[$row['categories_id']] = new stdClass(); - $categories[$row['categories_id']]->name = $movie->tags; - $categories[$row['categories_id']]->query = $movie->tags; - $categories[$row['categories_id']]->order = 'most_recent'; + ObjectYPT::setCache($cacheName, $obj->movies); +} else { + $obj->movies = $movies; + foreach ($obj->movies as $movie) { + if (empty($categories[$row['categories_id']])) { + $categories[$row['categories_id']] = new stdClass(); + $categories[$row['categories_id']]->name = $movie->tags; + $categories[$row['categories_id']]->query = $movie->tags; + $categories[$row['categories_id']]->order = 'most_recent'; + } } - } $obj->categories = array(); foreach ($categories as $value) { $obj->categories[] = $value; } -$output = json_encode($obj, JSON_UNESCAPED_UNICODE ); -if(json_last_error()){ +$output = json_encode($obj, JSON_UNESCAPED_UNICODE); +if (json_last_error()) { $output = json_encode(json_last_error_msg()); } die($output); ?> \ No newline at end of file