示例#1
0
<?php

require_once '../autoload.php';
$video = YoutubeSongInfo::withId($_GET['id']);
$details = $video->details();
function checkBlacklist($details)
{
    if ($_GET['scope']) {
        $dbManager = new DatabaseManager();
        $room = $dbManager->getRoom($_GET['scope']);
        $whitelist = explode("\n", $room->whitelist);
        $blacklist = explode("\n", $room->blacklist);
        $artist = strtolower($details["artist"]);
        $name = strtolower($details["name"]);
        if (count($details)) {
            foreach ($whitelist as $term) {
                if (strlen($term) > 3 && trim($term)) {
                    if (stristr($name, $term) or stristr($artist, $term)) {
                        return true;
                    }
                }
            }
            foreach ($blacklist as $term) {
                if (strlen($term) > 3 && trim($term)) {
                    if (stristr($name, $term) or stristr($artist, $term)) {
                        return false;
                    }
                }
            }
        }
    }
                    if (stristr($name, $term) or stristr($artist, $term)) {
                        return true;
                    }
                }
            }
            foreach ($blacklist as $term) {
                if (strlen($term) > 3 && trim($term)) {
                    if (stristr($name, $term) or stristr($artist, $term)) {
                        return false;
                    }
                }
            }
        }
    }
    return true;
}
$failed = 0;
$info = [];
foreach (explode(",", $_GET['data']) as $data) {
    $video = YoutubeSongInfo::withId($data);
    $details = $video->details();
    if (!checkBlacklist($data)) {
        $failed++;
        continue;
    }
    if (count($details)) {
        $details['success'] = true;
        $info[] = $details;
    }
}
json_response(["info" => $info, "failed" => $failed]);
示例#3
0
 /**
  * @param $key
  */
 private static function setYoutubeApiKey($key)
 {
     self::$youtube_api_key = $key;
 }
示例#4
0
<?php

session_start();
require_once 'vendor/autoload.php';
$config = (include 'config.live.php');
if (file_exists('../config.dev.php')) {
    $config = (include 'config.dev.php');
}
DatabaseManager::setCredentials($config['database']);
Client::setCredentials($config['google']);
YoutubeSongInfo::setConfig($config['youtube']);