public function getLatest() { $feed = Feed::make(); // cache response for a minute $feed->setCache(Config::get("custom.feeds_cache_time", 'feeds-latest')); if (!$feed->isCached()) { $items = MediaItem::getCachedRecentItems(); $feed->title = "LA1:TV's Latest Content"; $feed->description = 'This feed contains the latest content that is published to our website.'; $feed->logo = asset("/assets/img/logo.png"); $feed->link = URL::route('home'); $feed->setDateFormat('datetime'); $feed->pubdate = Carbon::now(); $feed->lang = 'en'; $feed->setShortening(false); foreach ($items as $item) { $mediaItem = $item['mediaItem']; $scheduledPublishTime = new Carbon($mediaItem->scheduled_publish_time); // title, author, url, pubdate, description $feed->add($item['generatedName'] . " [" . $item['playlistName'] . "]", "LA1:TV", $item['uri'], $scheduledPublishTime, $mediaItem->description); } } return $feed->render('rss'); }
public function getIndex() { if (Config::get("degradedService.enabled")) { $view = View::make("home.degradedIndex"); $view->contactEmail = Config::get("contactEmails.development"); $this->setContent($view, "home", "home-degraded", array(), null, 200, array()); return; } $promoMediaItem = MediaItem::with("liveStreamItem", "liveStreamItem.liveStream", "videoItem")->accessible()->whereNotNull("time_promoted")->orderBy("time_promoted", "desc")->first(); if (!is_null($promoMediaItem)) { $liveStreamItem = $promoMediaItem->liveStreamItem; if (!is_null($liveStreamItem) && !$liveStreamItem->getIsAccessible()) { $liveStreamItem = null; } $videoItem = $promoMediaItem->videoItem; if (!is_null($videoItem) && !$videoItem->getIsAccessible()) { $videoItem = null; } $shouldShowItem = false; // if there is a live stream which is in the "not live" state the player won't display the vod // even if there is one. It will show the countdown to the start of the live stream. if (is_null($liveStreamItem) || !$liveStreamItem->isNotLive()) { if (!is_null($videoItem) && $videoItem->getIsLive()) { $shouldShowItem = true; } else { if (!is_null($liveStreamItem) && $liveStreamItem->hasWatchableContent()) { $shouldShowItem = true; } } } if (!$shouldShowItem) { $promoMediaItem = null; } } $promoPlaylist = null; if (!is_null($promoMediaItem)) { $promoPlaylist = $promoMediaItem->getDefaultPlaylist(); } $promotedItems = MediaItem::getCachedPromotedItems(); $promotedItemsData = array(); // if there is an item to promote insert it at the start of the carousel if (!is_null($promoMediaItem)) { $coverArtResolutions = Config::get("imageResolutions.coverArt"); $isLiveShow = !is_null($promoMediaItem->liveStreamItem) && !$promoMediaItem->liveStreamItem->isOver(); $liveNow = $isLiveShow && $promoMediaItem->liveStreamItem->isLive(); $promotedItemsData[] = array("coverArtUri" => $promoPlaylist->getMediaItemCoverArtUri($promoMediaItem, $coverArtResolutions['full']['w'], $coverArtResolutions['full']['h']), "name" => $promoMediaItem->name, "seriesName" => !is_null($promoPlaylist->show) ? $promoPlaylist->generateName() : null, "availableMsg" => $liveNow ? "Live Now!" : $this->buildTimeStr($isLiveShow, $promoMediaItem->scheduled_publish_time), "uri" => $promoPlaylist->getMediaItemUri($promoMediaItem)); } foreach ($promotedItems as $a) { $mediaItem = $a['mediaItem']; if (!is_null($promoMediaItem) && intval($mediaItem->id) === intval($promoMediaItem->id)) { // prevent duplicate continue; } $isLiveShow = !is_null($mediaItem->liveStreamItem) && !$mediaItem->liveStreamItem->isOver(); $liveNow = $isLiveShow && $mediaItem->liveStreamItem->isLive(); $promotedItemsData[] = array("coverArtUri" => $a['coverArtUri'], "name" => $mediaItem->name, "seriesName" => $a['seriesName'], "availableMsg" => $liveNow ? "Live Now!" : $this->buildTimeStr($isLiveShow, $mediaItem->scheduled_publish_time), "uri" => $a['uri']); } $coverArtResolutions = Config::get("imageResolutions.coverArt"); $recentlyAddedItems = MediaItem::getCachedRecentItems(); $recentlyAddedTableData = array(); foreach ($recentlyAddedItems as $i => $a) { $mediaItem = $a['mediaItem']; $recentlyAddedTableData[] = array("uri" => $a['uri'], "active" => false, "title" => $mediaItem->name, "escapedDescription" => null, "playlistName" => $a['playlistName'], "episodeNo" => $i + 1, "thumbnailUri" => $a['coverArtUri'], "thumbnailFooter" => null, "duration" => $a['duration']); } $mostPopularItems = MediaItem::getCachedMostPopularItems(); $mostPopularTableData = array(); foreach ($mostPopularItems as $i => $a) { $mediaItem = $a['mediaItem']; $mostPopularTableData[] = array("uri" => $a['uri'], "active" => false, "title" => $mediaItem->name, "escapedDescription" => null, "playlistName" => $a['playlistName'], "episodeNo" => $i + 1, "thumbnailUri" => $a['coverArtUri'], "thumbnailFooter" => null, "duration" => $a['duration']); } $view = View::make("home.index"); $view->promotedItemsData = $promotedItemsData; $view->recentlyAddedPlaylistFragment = count($recentlyAddedTableData) > 0 ? View::make("fragments.home.playlist", array("stripedTable" => true, "headerRowData" => null, "tableData" => $recentlyAddedTableData)) : null; $view->mostPopularPlaylistFragment = count($mostPopularTableData) > 0 ? View::make("fragments.home.playlist", array("stripedTable" => true, "headerRowData" => null, "tableData" => $mostPopularTableData)) : null; $view->twitterWidgetId = Config::get("twitter.timeline_widget_id"); $hasPromoItem = !is_null($promoMediaItem); $showPromoItem = $hasPromoItem; if ($hasPromoItem) { // determine if the user has already seen the promo $cookieVal = Cookie::get('seenPromo-' . $promoMediaItem->id); if (!is_null($cookieVal) && $cookieVal === $promoMediaItem->time_promoted->timestamp) { // user already seen promo $showPromoItem = false; } // put a cookie in the users browser to inform us in the future that the user has seen this promo video // store the time so that if the item is repromoted in the future, it will be shown again. Cookie::queue('seenPromo-' . $promoMediaItem->id, $promoMediaItem->time_promoted->timestamp, 40320); // store for 4 weeks } $view->showPromoItem = $showPromoItem; if ($showPromoItem) { $userHasMediaItemsPermission = false; if (Auth::isLoggedIn()) { $userHasMediaItemsPermission = Auth::getUser()->hasPermission(Config::get("permissions.mediaItems"), 0); } $view->promoPlayerInfoUri = PlayerHelpers::getInfoUri($promoPlaylist->id, $promoMediaItem->id); $view->promoRegisterWatchingUri = PlayerHelpers::getRegisterWatchingUri($promoPlaylist->id, $promoMediaItem->id); $view->promoRegisterLikeUri = PlayerHelpers::getRegisterLikeUri($promoPlaylist->id, $promoMediaItem->id); $view->promoAdminOverrideEnabled = $userHasMediaItemsPermission; $view->promoLoginRequiredMsg = "Please log in to use this feature."; } $this->setContent($view, "home", "home", array(), null, 200, array()); }