diff --git a/ajax/ajax.php b/ajax/ajax.php index 2bae64b..66d127e 100644 --- a/ajax/ajax.php +++ b/ajax/ajax.php @@ -163,7 +163,7 @@ '; @@ -349,4 +349,4 @@ break; } -?> \ No newline at end of file +?> diff --git a/lib.php b/lib.php index 009440b..b2210ae 100644 --- a/lib.php +++ b/lib.php @@ -60,8 +60,22 @@ function get_channel_video($cid,$pageToken='',$apikey,$regionCode='VN'){ //获取视频类别内容 function videoCategories($apikey,$regionCode='HK'){ - $apilink='https://www.googleapis.com/youtube/v3/videoCategories?part=snippet®ionCode='.$regionCode.'&hl=zh-CN&key='.$apikey; - return json_decode(get_data($apilink),true); + $apicache = '/tmp/ytb_videoCategories_'.$regionCode; + $json = file_get_contents($apicache); + if (empty($json)) { + $apilink='https://www.googleapis.com/youtube/v3/videoCategories?part=snippet®ionCode='.$regionCode.'&hl=zh-CN&key='.$apikey; + $json = get_data($apilink); + file_put_contents($apicache,$json); + file_put_contents($apicache.".ts","REQUEST_TIME: " . $_SERVER['REQUEST_TIME']); + } + $ret = json_decode($json,true); + $items = $ret['items']; + if (strtolower($regionCode) == 'tw') { + return array_filter($items, function($v){ + return array_search($v['id'], ['18','33','41','42']) === FALSE; + }); + } + return $items; } @@ -506,4 +520,4 @@ function Root_part(){ $domain=$_SERVER['SERVER_NAME']; return "$http"."$domain"."$part"; } -?> \ No newline at end of file +?>