{ $lYTID = Youtube::extractYTID($lElement->href); $lYTTitle = preg_replace('/[\'\"\`\=\&\%\'\+]+/', ' ', $lElement->title); $lYTTitle = preg_replace('/\s{2,}/', ' ', $lYTTitle); if (Youtube::validYoutubeID($lYTID)) { $lRec = " {\n"; $lRec .= " \"ytid\": \"$lYTID\",\n"; $lRec .= " \"href\": \"$lElement->href\",\n"; $lRec .= " \"title\": \"$lElement->title\"\n"; $lRec .= " }"; array_push($gOutRecords, $lRec); $lVideo->addVideo($lYTID, $lYTTitle); } else { Log::writeLog(1, $_SERVER["SCRIPT_NAME"], "Invalid Youtube ID \"$lYTID\""); } } else { Log::writeLog(1, $_SERVER["SCRIPT_NAME"], "Ignoring title \"$lElement->title\""); } } else { Log::writeLog(1, $_SERVER["SCRIPT_NAME"], "Something is wrong with the title or href"); }