<?php ob_start(ob_gzhandler); header('Access-Control-Allow-Origin: *'); header("Content-Type: application/json");
require_once("cdn.father.php");
define("baseurl", $_POST['client']);
define("apikey", "AIzaSyB72cwViYmYWv_XOueyqYwg5i2lXGORBhA");

switch($_GET['action']):
	case "getytlist":
		$pid = $_GET['id'];
		$next = isset($_GET['next']) ? '&pageToken='.$_GET['next'] : '';		
		$data = @json_decode($z->_CURL('https://www.googleapis.com/youtube/v3/playlistItems?key='.apikey.'&part=snippet,contentDetails&maxResults=50&playlistId='.$pid.$next, false));		
		if(isset($data->error)){
        	echo @json_encode(array('result' => 'failed', 'message' => 'Invalid Playlist ID')); exit;
        }		
		$total = $data->pageInfo->totalResults;	
		$ids = array(); $nxt = '';
		$nxt = isset($data->nextPageToken) ? $data->nextPageToken : 'none';
		for($n = 0; $n < count($data->items); $n++):
			$id = $data->items[$n]->snippet->resourceId->videoId;
			if(!in_array($id, $ids)) array_push($ids, $id);
		endfor;
		echo @json_encode(array('result' => 'ok', 'total' => $total, 'nxt' => $nxt, 'ids' => $ids)); exit;		
	break;
endswitch;

ob_flush(); ?>