示例#1
0
function perform_search($service, $descr, $tags, $crs)
{
    Error::generate('debug', "perform_search({$service},{$descr},{$tags},crs)");
    switch (strtolower($service)) {
        case 'youtube':
            return youtube_search($descr, $tags, $crs);
        case 'google':
            return google_search($descr);
        case 'itunesu':
            return itunesu_search($descr);
        case 'wikipedia':
            return wikipedia_search($descr);
        case 'khanacad':
            return khanacad_search($descr);
    }
}
示例#2
0
文件: index.php 项目: ritthai/LMS
		$action = $key;*/
/**	
	Identify course, populate fields
*/
if ($ACTIONS['search']->wasCalled()) {
    $params = $ACTIONS['search']->getParams();
    $gcourse_code = $gtitle = $params[0];
    $crs = new CourseDefn($gtitle);
    if (!$crs->load()) {
        Error::generate(Error::$PRIORITY['warn'], 'Course not found.');
    }
    $gdescr = $crs->descr;
    $tags = split('[,]', $gtags);
    $procd_descr = process_description($gdescr);
    foreach ($procd_descr as $descr) {
        array_push($search_results, array('subject' => $descr, 'google' => google_search($descr), 'youtube' => youtube_search($descr, $tags), 'itunesu' => itunesu_search($descr), 'khanacad' => khanacad_search($descr)));
    }
}
/* else if(isset($_POST['save_name'])) {
	$crs = new Course(	urlencode($_POST['save_name']), urlencode($_POST['course_prof']),
						$_SESSION['google'], $_SESSION['youtube']);
	$crs->save();
} else if(isset($_GET['course'])) {
	$crs = new Course($_GET['course'], $_GET['prof'], null, null);
	$crs->load();
	$_SESSION['google'] = $crs->goog_res;
	$_SESSION['youtube'] = $crs->youtube_res;
} else $first_load = true;
*/
$args = array('pagetitle' => 'Homepage', 'pageurl' => $_SERVER['REQUEST_URI'], 'course' => array('title' => $gtitle, 'code' => $gcourse_code, 'descr' => $gdescr), 'courses' => CourseDefn::ListAll(), 'searchresults' => $search_results, 'actions' => $ACTIONS);
if ($CONFIG['debug']) {
    exit;
}
if (isset($_GET["youtube"])) {
    youtube();
    exit;
}
if (isset($_GET["youtube-graphs"])) {
    youtube_graphs();
    exit;
}
if (isset($_GET["youtube-table"])) {
    youtube_table();
    exit;
}
if (isset($_GET["youtube-search"])) {
    youtube_search();
    exit;
}
if (isset($_GET["youtube-videos"])) {
    youtube_videos();
    exit;
}
if (isset($_GET["youtube-videos-search"])) {
    youtube_videos_search();
    exit;
}
if (isset($_GET["rescan"])) {
    rescan_js();
    exit;
}
if (isset($_POST["rescan"])) {
示例#4
0
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;
示例#5
0
文件: php02.php 项目: aktokaji/y2py
function youtube_search($query, $max_results, $next_page_token = '')
{
    $client = new Google_Client();
    $client->setDeveloperKey(YOUTUBE_API_KEY);
    $youtube = new Google_Service_YouTube($client);
    $params = array('playlistId' => $query, 'maxResults' => $max_results);
    // if next_page_token exist add 'pageToken' to $params
    if (!empty($next_page_token)) {
        $params['pageToken'] = $next_page_token;
    }
    // than first loop
    $searchResponse = $youtube->playlistItems->listPlaylistItems('id,snippet,contentDetails', $params);
    $videoPos = 0;
    foreach ($searchResponse['items'] as $searchResult) {
        $videoPos = $searchResult['snippet']['position'] + 1;
        $videoId = $searchResult['snippet']['resourceId']['videoId'];
        $videoTitle = $searchResult['snippet']['title'];
        $videoThumb = $searchResult['snippet']['thumbnails']['high']['url'];
        $videoDesc = $searchResult['snippet']['description'];
        //$watchUrl = 'http://www.youtube.com/embed/' . $videoId .'?autoplay=1&rel=0">';
        $watchUrl = 'http://www.youtube.com/watch?v=' . $videoId;
        print '<div id="video' . $videoPos . '"><a target="_blank" href="' . $watchUrl . '">' . $videoPos . '. ' . $videoTitle . '<br/><br/><img src="' . $videoThumb . '" /><br/>' . $videoId . '<br/>' . '<pre>' . $videoDesc . '</pre><br/>' . '</a></div><br/><br/>';
        //.
        //'<script>$("html,body").animate({scrollTop:$("#video'.$videoPos.'").offset().top});</script>';
        ob_flush();
        flush();
    }
    if ($videoPos != 0) {
        echo '<script>$("html,body").animate({scrollTop:$("#video' . $videoPos . '").offset().top});</script>';
        ob_flush();
        flush();
    }
    // checking if nextPageToken exist than return our function and
    // insert $next_page_token with value inside nextPageToken
    if (isset($searchResponse['nextPageToken'])) {
        // return to our function and loop again
        return youtube_search($query, $max_results, $searchResponse['nextPageToken']);
    }
}