示例#1
0
           
               <form action="/index.php" method=get"><input class="form-control" type="text" name="q" value="<?php 
echo $q;
?>
" width="80%"> <input type="submit" value="Search"> <br />
</div>
<hr>
           <div class="row">   
<?php 
$id = $_GET['v'];
include 'vfunc.php';
$yf = json_decode(ngegrab('https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,statistics&id=' . $id . '&maxResults=1&key=' . $key . ''), true);
$name = $yf[items][0][snippet][title];
$tgl = $yf[items][0][snippet][publishedAt];
$date = dateyt($tgl);
$des = $yf[items][0][snippet][description];
$channel = $yf[items][0][snippet][channelTitle];
$viewCount = $yf[items][0][statistics][viewCount];
$likeCount = $yf[items][0][statistics][likeCount];
$durasi = $yf[items][0][contentDetails][duration];
$duration = $durasi;
$duration = str_replace('PT', '', $duration);
$duration = str_replace('H', ' hour ', $duration);
$duration = str_replace('M', ' min ', $duration);
$duration = str_replace('S', ' sec ', $duration);
$kata = '' . $name . '';
$kate = preg_replace('/[^a-z0-9_\\-\\.]/i', '-', $name);
$kate = str_replace('.', '-', $kate);
$kate = str_replace('---', '-', $kate);
$kate = str_replace('--', '-', $kate);
示例#2
0
$prevpage = $json->prevPageToken;
foreach ($json->items as $sam) {
    $link = $sam->id->videoId;
    $yf = json_decode(ngegrab('https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,statistics&id=' . $link . '&maxResults=1&key=' . $key . ''), true);
    $viewCount = $yf[items][0][statistics][viewCount];
    $durasi = $yf[items][0][contentDetails][duration];
    $duration = $durasi;
    $duration = str_replace('PT', '', $duration);
    $duration = str_replace('H', ' hour ', $duration);
    $duration = str_replace('M', ' min ', $duration);
    $duration = str_replace('S', ' sec ', $duration);
    $name = $sam->snippet->title;
    $desc = $sam->snippet->description;
    $chtitle = $sam->snippet->channelTitle;
    $chid = $sam->snippet->channelId;
    $date = dateyt($sam->snippet->publishedAt);
    echo '<div class="col-md-12"><td><img src="https://ytimg.googleusercontent.com/vi/' . $link . '/default.jpg" alt="Thumbnail" class="list-group-item list-group-item-danger" title="' . $name . '" width="198px" height="178px"></td><span class="list-group-item list-group-item-success"><a href="/watch?v=' . $link . '">' . $name . '</a></span><span class="list-group-item list-group-item-info">' . $duration . '</span><span class="list-group-item list-group-item-info">' . $date . '</span><span class="btn btn-info">' . $viewCount . ' Views</span></td></tr></table></div><hr>';
}
echo '</tbody></table>
</div>
<div class="vagination" align="center">';
if (strlen($prevpage) > 1) {
    if (strlen($_GET['q']) > 1) {
        echo '<a href="/index.php?q=' . $q . '&page=' . $prevpage . '" class="btn btn-success">&laquo; Siguiente</a> ';
    } else {
        echo '<a href="/index.php?q=' . $q . '&page=' . $prevpage . '" class="btn btn-success">&laquo; Anterior</a> ';
    }
}
if (strlen($nextpage) > 1) {
    if (strlen($_GET['q']) > 1) {
        echo '<a href="/index.php?q=' . $q . '&page=' . $nextpage . '" class="btn btn-success">Siguiente &raquo;</a> ';