Skip to content

Commit

Permalink
whatever i changed
Browse files Browse the repository at this point in the history
  • Loading branch information
crutchy committed Nov 2, 2015
1 parent b2b7c67 commit f58f906
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 2 deletions.
2 changes: 1 addition & 1 deletion interface/reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
$cmd=$argv[5];*/

#define("LISTEN_ADDRESS","192.168.1.25");
define("LISTEN_ADDRESS","192.168.1.22");
define("LISTEN_ADDRESS","10.0.2.15");
define("BUFFER_FILE",__DIR__."/../../data/exec_iface");
define("LISTEN_PORT",50000);
define("CLIENT_TIMEOUT",60); # seconds
Expand Down
2 changes: 1 addition & 1 deletion scripts/wiki_lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ function wiki_delspamuser($nick,$trailing)
function wiki_testrule($nick,$trailing)
{
$test=trim(substr($trailing,strlen(".testrule")));
if (preg_match("/^[A-Z]{1}[a-z]+[A-Z]{1}[a-z]+[0-9]+/",$test)==1)
if (preg_match("/^[[:upper:]]{1}[[:lower:]]+[[:upper:]]{1}[[:lower:]]*[[:digit:]]+/",$test)==1)
{
privmsg("match");
}
Expand Down
91 changes: 91 additions & 0 deletions scripts/youtube.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php

#####################################################################################################

/*
exec:~youtube|20|0|0|1|||||php scripts/youtube.php %%trailing%%
exec:~yt|20|0|0|1|||||php scripts/youtube.php %%trailing%%
help: ~youtube | syntax: ~youtube <query>
help: ~youtube | returns first result URL for a youtube search
help: ~yt | syntax: ~youtube <query>
help: ~yt | returns first result URL for a youtube search
*/

#####################################################################################################

require_once("lib.php");

$trailing=trim($argv[1]);

if ($trailing=="")
{
privmsg("syntax: ~youtube <query>");
privmsg("returns first result URL for a youtube search");
return;
}

$results=youtube_search($trailing);

if ($results!==False)
{
if (count($results)>0)
{
if (strlen($results[0])>300)
{
return;
}
privmsg($results[0]);
}
}

#####################################################################################################

function youtube_search($query)
{
$agent=ICEWEASEL_UA;
$host="www.youtube.com";
$uri="/results";
$port=443;
$params=array();
$params["search_query"]=$query;
$response=wpost($host,$uri,$port,$agent,$params);
$html=strip_headers($response);
strip_all_tag($html,"head");
strip_all_tag($html,"script");
strip_all_tag($html,"style");
$delim1="class=\"item-section\">";
$delim2="</ol>";
$html=extract_text_nofalse($html,$delim1,$delim2);
$results=explode("<li><div class=\"yt-lockup yt-lockup-tile yt-lockup-video vve-check clearfix yt-uix-tile\"",$html);
array_shift($results);
if (count($results)==0)
{
return False;
}
for ($i=0;$i<count($results);$i++)
{
$parts=explode(">",$results[$i]);
array_shift($parts);
$results[$i]=implode(">",$parts);
$delim1="<h3 class=\"yt-lockup-title \">";
$delim2="</h3>";
$results[$i]=extract_text_nofalse($results[$i],$delim1,$delim2);
$delim1="<a href=\"";
$delim2="\" ";
$url="https://www.youtube.com".extract_text_nofalse($results[$i],$delim1,$delim2);
$delim1="dir=\"ltr\">";
$delim2="</a>";
$title=extract_text_nofalse($results[$i],$delim1,$delim2);
$title=html_decode($title);
$title=html_decode($title);
$delim1="> - Duration: ";
$delim2=".</span>";
$time=extract_text_nofalse($results[$i],$delim1,$delim2);
$results[$i]=$url." - ".$title." - ".$time;
}
return $results;
}

#####################################################################################################

?>

0 comments on commit f58f906

Please sign in to comment.