forked from anmolduainter/Youtube-Telegram-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
151 changed files
with
31,873 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
require('simple_html_dom.php'); | ||
|
||
$loading=TRUE; | ||
$i=0; | ||
$webToken="302517024:AAGgrgOiESarNaMM8LoS6Ct-goVmJ3ircmc"; | ||
$url="https://api.telegram.org/bot".$webToken; | ||
// while(true){ | ||
|
||
|
||
$update=file_get_contents($url."/getupdates"); | ||
$updateArray=json_decode($update,TRUE); | ||
$chat_id=$updateArray["result"][0]["message"]["chat"]["id"]; | ||
$num=(sizeof($updateArray["result"]))-1; | ||
$chat_text=$updateArray["result"][$num]["message"]["text"]; | ||
|
||
|
||
$html = file_get_html('https://www.youtube.com/results?search_query='.str_replace(' ','+',$chat_text)); | ||
|
||
// creating an array of elements | ||
$videos = []; | ||
|
||
// Find top ten videos | ||
$i = 1; | ||
$ol=$html->find('ol.item-section',0); | ||
foreach ($ol->find('li') as $video) { | ||
if ($i > 2) { | ||
break; | ||
} | ||
|
||
// Find item link element | ||
$videoDetails = $video->find('a.yt-uix-tile-link', 0); | ||
|
||
// get title attribute | ||
// $videoTitle = $videoDetails->title; | ||
|
||
// get href attribute | ||
$videoUrl = 'https://youtube.com' . $videoDetails->href; | ||
|
||
// push to a list of videos | ||
$videos[] = [ | ||
// 'title' => $videoTitle, | ||
'url' => $videoUrl | ||
]; | ||
|
||
$i++; | ||
} | ||
|
||
file_get_contents($url."/sendmessage?chat_id=".$chat_id."&text=".implode("",$videos[0])); | ||
|
||
file_get_contents($url."/sendmessage?chat_id=".$chat_id."&text=".implode("",$videos[1])); | ||
|
||
|
||
|
||
// print_r($chat_text); | ||
// print_r(sizeof($updateArray["result"])); | ||
// print_r($updateArray); | ||
var_dump($videos); | ||
// } | ||
|
||
?> |
Oops, something went wrong.