0% found this document useful (0 votes)
100 views4 pages

PHP Grabber

This PHP script retrieves information about a YouTube channel from the YouTube API based on the channel ID provided in the URL. It gets the channel title, description, and number of videos. It then makes additional API calls to get details on the most recent 10 videos for that channel, including the video ID, title, thumbnail, and publishing channel. It displays the channel header and lists the videos. It also includes pagination links to retrieve older or newer videos.

Uploaded by

ianiroy13
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views4 pages

PHP Grabber

This PHP script retrieves information about a YouTube channel from the YouTube API based on the channel ID provided in the URL. It gets the channel title, description, and number of videos. It then makes additional API calls to get details on the most recent 10 videos for that channel, including the video ID, title, thumbnail, and publishing channel. It displays the channel header and lists the videos. It also includes pagination links to retrieve older or newer videos.

Uploaded by

ianiroy13
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

<?

php

include 'includes/info.php';

include 'functions/youtube-func.php';

$channelId = $_GET['id']; //Channel Id(Don't Remove This)

$url =
ngegrab('https://www.googleapis.com/youtube/v3/channels?part=snippet,statistics,branding
Settings&id='.$channelId.'&key='.$apikey.'');

$json = json_decode($url);

if($json)

foreach ($json->items as $data)

$channelTitle = $data->snippet->title;

$description = $data->snippet->description;

$total = $data->statistics->videoCount;

$title = ''.$channelTitle.'';

$ogtitle = ''.$channelTitle.' Channel';

$ogdescription = ''.$description.'';

include 'includes/head.php';

echo '<div class="header"><i class="fa fa-television"></i> '.$channelTitle.' ('.$total.')</div>';

if(strlen($_GET['page']) >1)

$yesPage=$_GET['page'];

else

$yesPage='';

}
$grab =
ngegrab('https://www.googleapis.com/youtube/v3/search?part=snippet&channelId='.$chann
elId.'&key='.$apikey.'&maxResults=10&type=video&pageToken='.$yesPage.'');

$json = json_decode($grab);

$nextpage=$json->nextPageToken;

$prevpage=$json->prevPageToken;

if($json)

foreach ($json->items as $hasil)

$id = $hasil->id->videoId;

$title = $hasil->snippet->title;

$thumbnail = $hasil->snippet->thumbnails->medium->url;

$hasil =
ngegrab('https://www.googleapis.com/youtube/v3/videos?key='.$apikey.'&part=snippet,cont
entDetails,statistics,topicDetails&id='.$id.'');

$ks = json_decode($hasil);

foreach ($ks->items as $data)

$channelTitle = $data->snippet->channelTitle;

$channelId = $data->snippet->channelId;

echo '<div class="videos_list">';

echo '<a href="/dl/'.$id.'/'.cleaned($title).'.html" rel="dofollow" title="'.$title.'">';

echo '<table>';

echo '<tbody>';

echo '<tr valign="middle">';

echo '<td>';

echo '<img src="'.$thumbnail.'" class="img" alt="'.$title.'" title="'.$title.'>';

echo '</td>';

echo '<td style="padding-left:2px;">';


echo '<div style="padding-bottom:1px;">';

echo $title;

echo '</div>';

echo '<span style="color:blue">by</span> <span


style="color:green">'.$channelTitle.'</span>';

echo '</td>';

echo '</tr>';

echo '</tbody>';

echo '</table>';

echo '</a>';

echo '</div>';

echo '<div class="pagenavi" style="text-align:center">';

if($_GET['id'])

if (strlen($prevpage)>1)

echo '<a href="/channel/'.$channelId.'/page/'.$prevpage.'" class="page_item" rel="dofollow"


title="Prev">Prev</a>';

if (strlen($nextpage)>1)

echo '<a href="/channel/'.$channelId.'/page/'.$nextpage.'" class="page_item" rel="dofollow"


title="Next">Next</a>';

echo '</div>';

include 'includes/foot.php';
?>

You might also like