/** Set the online message. */ $online_message = isset($_GET['online']) && !empty($_GET['online']) ? $_GET['online'] : 'online'; /** Set the offline message. */ $offline_message = isset($_GET['offline']) && !empty($_GET['offline']) ? $_GET['offline'] : 'offline'; /** Initialize. */ require_once 'lctv_badges_init.php'; /** Load the API. */ $lctv_api = new LCTVAPI(array('data_store' => LCTVAPI_DATA_STORE_CLASS, 'client_id' => LCTV_CLIENT_ID, 'client_secret' => LCTV_CLIENT_SECRET, 'user' => LCTV_MASTER_USER)); /** Bail if API isn't authorized. */ if (!$lctv_api->is_authorized()) { header("Content-type:image/svg+xml"); echo get_badge_svg('livecoding.tv', 'error', '#e05d44'); exit; } /** Get live streaming info for a channel. */ $api_request = $lctv_api->api_request('v1/livestreams/' . urlencode($channel) . '/'); /** Bail on error. */ if ($api_request === false) { header("Content-type:image/svg+xml"); echo get_badge_svg('livecoding.tv', 'error', '#e05d44'); exit; } /** API returned an error. This happens if user is not streaming. */ if (isset($api_request->result->detail)) { $api_request->result->is_live = false; } /** Display live stream title instead of 'online'. */ if (isset($_GET['title']) && strtolower($_GET['title']) === 'true') { if (!empty($api_request->result->title)) { $online_message = $api_request->result->title; }
exit; } /** Set the channel name. */ $channel = strtolower($_GET['channel']); /** Initialize. */ require_once 'lctv_badges_init.php'; /** Load the API. */ $lctv_api = new LCTVAPI(array('data_store' => LCTVAPI_DATA_STORE_CLASS, 'client_id' => LCTV_CLIENT_ID, 'client_secret' => LCTV_CLIENT_SECRET, 'user' => LCTV_MASTER_USER)); /** Bail if API isn't authorized. */ if (!$lctv_api->is_authorized()) { header("Content-type:image/svg+xml"); echo get_badge_svg('livecoding.tv', 'error', '#e05d44'); exit; } /** Get live streaming info for a channel. */ $api_request = $lctv_api->api_request('v1/scheduledbroadcast/?limit=500'); /** Bail on error. */ if ($api_request === false || isset($api_request->result->detail)) { header("Content-type:image/svg+xml"); echo get_badge_svg('livecoding.tv', 'error', '#e05d44'); exit; } /** Get scheduled streams and search for channel name. */ $next_stream = ''; $api_request->result->results = array_reverse($api_request->result->results); foreach ($api_request->result->results as $scheduled) { if (strpos($scheduled->livestream, $channel) !== false) { $next_stream = strtotime($scheduled->start_time_original_timezone); break; } }
exit; } /** Set the channel name. */ $channel = strtolower($_GET['channel']); /** Initialize. */ require_once 'lctv_badges_init.php'; /** Load the API. */ $lctv_api = new LCTVAPI(array('data_store' => LCTVAPI_DATA_STORE_CLASS, 'client_id' => LCTV_CLIENT_ID, 'client_secret' => LCTV_CLIENT_SECRET, 'user' => $channel)); /** Bail if API isn't authorized. */ if (!$lctv_api->is_authorized()) { header("Content-type:image/svg+xml"); echo get_badge_svg('lctv last streamed', 'error', '#e05d44'); exit; } /** Get users latest videos. */ $api_request = $lctv_api->api_request('v1/user/videos/latest/'); /** Bail on error. */ if ($api_request === false || isset($api->request->detail)) { header("Content-type:image/svg+xml"); echo get_badge_svg('lctv last streamed', 'error', '#e05d44'); exit; } /** Check to auto link. */ if (isset($_GET['link']) && strtolower($_GET['link']) === 'true') { $link = 'https://www.livecoding.tv/' . urlencode($channel) . '/'; } else { $link = ''; } /** Output svg image. */ header("Content-type:image/svg+xml"); if (is_array($api_request->result) && !empty($api_request->result[0]->creation_time)) {
exit; } /** Set the channel name. */ $channel = strtolower($_GET['channel']); /** Initialize. */ require_once 'lctv_badges_init.php'; /** Load the API. */ $lctv_api = new LCTVAPI(array('data_store' => LCTVAPI_DATA_STORE_CLASS, 'client_id' => LCTV_CLIENT_ID, 'client_secret' => LCTV_CLIENT_SECRET, 'user' => $channel)); /** Bail if API isn't authorized. */ if (!$lctv_api->is_authorized()) { header("Content-type:image/svg+xml"); echo get_badge_svg('lctv followers', 'error', '#e05d44'); exit; } /** Get user followers. */ $api_request = $lctv_api->api_request('v1/user/followers/'); /** Bail on error. */ if ($api_request === false || isset($api_request->result->detail)) { header("Content-type:image/svg+xml"); echo get_badge_svg('lctv followers', 'error', '#e05d44'); exit; } /** Count number of followers. */ $follower_count = count($api_request->result); /** Check to auto link. */ if (isset($_GET['link']) && strtolower($_GET['link']) === 'true') { $link = 'https://www.livecoding.tv/' . urlencode($channel) . '/'; } else { $link = ''; } /** Output svg image. */