From: Flavio Date: Fri, 18 Jul 2014 21:08:12 +0000 (+0200) Subject: July is the official cat'n'mouse game month X-Git-Tag: 2.2~9 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d70e4b2cc25c8528d876a163e9dc52cd8b144159;p=minitube July is the official cat'n'mouse game month --- diff --git a/src/video.cpp b/src/video.cpp index 7a37c08..ce35110 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -424,11 +424,37 @@ void Video::captureFunction(const QString &name, const QString &js) { captureFunction(funcName, js); pos += invokedFuncRe.matchedLength(); } + + // capture referenced objects + QRegExp objRe("[\\s=;\\(]([" + jsNameChars + "]+)\\.[" + jsNameChars + "]+"); + pos = name.length() + 9; + while ((pos = objRe.indexIn(func, pos)) != -1) { + QString objName = objRe.cap(1); + if (!sigObjects.contains(objName)) + captureObject(objName, js); + pos += objRe.matchedLength(); + } +} + +void Video::captureObject(const QString &name, const QString &js) { + QRegExp re("var\\s+" + QRegExp::escape(name) + "\\s*=\\s*\\{.+\\}\\s*;"); + re.setMinimal(true); + if (re.indexIn(js) == -1) { + qWarning() << "Cannot capture object" << name; + return; + } + QString obj = re.cap(0); + sigObjects.insert(name, obj); } QString Video::decryptSignature(const QString &s) { if (sigFuncName.isEmpty()) return QString(); QScriptEngine engine; + foreach (QString f, sigObjects.values()) { + QScriptValue value = engine.evaluate(f); + if (value.isError()) + qWarning() << "Error in" << f << value.toString(); + } foreach (QString f, sigFunctions.values()) { QScriptValue value = engine.evaluate(f); if (value.isError()) diff --git a/src/video.h b/src/video.h index 7220a4d..dc7dd60 100644 --- a/src/video.h +++ b/src/video.h @@ -103,6 +103,7 @@ private: 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); QString decryptSignature(const QString &s); QString m_title; @@ -130,9 +131,10 @@ private: bool loadingStreamUrl; bool loadingThumbnail; - QHash sigFunctions; - QString sigFuncName; QString fmtUrlMap; + QString sigFuncName; + QHash sigFunctions; + QHash sigObjects; }; // This is required in order to use QPointer