<< reply->url().toString() << reply->errorString();
}
-QString JsFunctions::evaluate(const QString &function) {
+QString JsFunctions::evaluate(const QString &js) {
if (!engine) return QString();
- QScriptValue value = engine->evaluate(function);
+ QScriptValue value = engine->evaluate(js);
if (value.isUndefined())
- qWarning() << "Undefined result for" << function;
+ qWarning() << "Undefined result for" << js;
if (value.isError())
- qWarning() << "Error in" << function << value.toString();
+ qWarning() << "Error in" << js << value.toString();
return value.toString();
}
return evaluate("webPageFmtMapRE()");
}
+QString JsFunctions::ageGateRE() {
+ return evaluate("ageGateRE()");
+}
+
QString JsFunctions::jsPlayerRE() {
return evaluate("jsPlayerRE()");
}
QString videoTokenRE();
QString videoInfoFmtMapRE();
QString webPageFmtMapRE();
+ QString ageGateRE();
QString jsPlayerRE();
QString signatureFunctionNameRE();
protected:
- QString evaluate(const QString &function);
+ QString evaluate(const QString &js);
private slots:
void gotJs(QByteArray bytes);
// get video token
QRegExp videoTokeRE(JsFunctions::instance()->videoTokenRE());
if (videoTokeRE.indexIn(videoInfo) == -1) {
- qWarning() << "Cannot get token. Trying next el param" << videoInfo << videoTokeRE.pattern();
+ // qWarning() << "Cannot get token. Trying next el param" << videoInfo << videoTokeRE.pattern();
// Don't panic! We're gonna try another magic "el" param
elIndex++;
getVideoInfo();
// get fmt_url_map
QRegExp fmtMapRE(JsFunctions::instance()->videoInfoFmtMapRE());
if (fmtMapRE.indexIn(videoInfo) == -1) {
- qWarning() << "Cannot get urlMap. Trying next el param";
+ // qWarning() << "Cannot get urlMap. Trying next el param";
// Don't panic! We're gonna try another magic "el" param
elIndex++;
getVideoInfo();
emit errorStreamUrl(tr("Cannot get video stream for %1").arg(m_webpage.toString()));
}
-void Video::foundVideoUrl(QString videoToken, int definitionCode) {
- // qDebug() << "foundVideoUrl" << videoToken << definitionCode;
-
- QUrl videoUrl = QUrl(QString(
- "http://www.youtube.com/get_video?video_id=%1&t=%2&eurl=&el=&ps=&asv=&fmt=%3"
- ).arg(videoId, videoToken, QString::number(definitionCode)));
-
- m_streamUrl = videoUrl;
- loadingStreamUrl = false;
- emit gotStreamUrl(videoUrl);
-}
-
void Video::errorVideoInfo(QNetworkReply *reply) {
loadingStreamUrl = false;
emit errorStreamUrl(tr("Network error: %1 for %2").arg(reply->errorString(), reply->url().toString()));
QString html = QString::fromUtf8(data);
// qWarning() << html;
- if (html.contains("player-age-gate-content\"")) {
+ QRegExp ageGateRE(JsFunctions::instance()->ageGateRE());
+ if (ageGateRE.indexIn(html) != -1) {
// qDebug() << "Found ageGate";
ageGate = true;
elIndex = 4;
private:
void getVideoInfo();
- void foundVideoUrl(QString videoToken, int definitionCode);
void parseFmtUrlMap(const QString &fmtUrlMap, bool fromWebPage = false);
void captureFunction(const QString &name, const QString &js);
void captureObject(const QString &name, const QString &js);