diff --git a/debian/changelog b/debian/changelog index db0c345..19b8ca5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +qyoutube (0.1.9-1) unstable; urgency=low + + * Fix for the latest base.js changes + + -- Ivaylo Dimitrov Fri, 30 Aug 2019 20:40:11 +0300 + qyoutube (0.1.9) unstable; urgency=low * Refresh access token during revoke operation, if required. diff --git a/src/streamsrequest.cpp b/src/streamsrequest.cpp index 04c2d9f..c654b8e 100644 --- a/src/streamsrequest.cpp +++ b/src/streamsrequest.cpp @@ -296,17 +296,36 @@ static QString unescape(const QString &s) { void extractVideoStreams(QScriptValue decryptionFunction) { #ifdef QYOUTUBE_DEBUG qDebug() << "QYouTube::StreamsRequestPrivate::extractVideoStreams: Extracting video streams."; + qDebug() << "QYouTube::StreamsRequestPrivate::extractVideoStreams: decryptFunction" << decryptionFunction.toString(); #endif Q_Q(StreamsRequest); - + QVariantList formats; + QStringList parts = response.split(',', QString::SkipEmptyParts); - + foreach (QString part, parts) { part = unescape(part); - part.replace(QRegExp("(^|&)s="), "&signature="); - QString oldSig = part.section("signature=", 1, 1).section('&', 0, 0); + QRegExp r("sp=(.*)&|sp=(.*)$"); + QString sp; + + r.setMinimal(true); + + if (r.indexIn(part) != -1) + { + if (!r.cap(1).isEmpty()) + sp = r.cap(1); + else + sp = r.cap(2); + } + else + sp = "signature"; + + part.replace(QRegExp("(^|&)s="), "&" + sp + "="); + QString oldSig = part.section(sp + "=", 1, 1).section('&', 0, 0); + part.replace(oldSig, decryptionFunction.call(QScriptValue(), QScriptValueList() << oldSig).toString()); + QStringList splitPart = part.split("url="); if (!splitPart.isEmpty()) { @@ -322,8 +341,8 @@ static QString unescape(const QString &s) { query.addQueryItem(param.section('=', 0, 0), param.section('=', -1)); } - if (!query.hasQueryItem("signature")) { - query.addQueryItem("signature", splitPart.first().section("signature=", 1, 1).section('&', 0, 0)); + if (!query.hasQueryItem(sp)) { + query.addQueryItem(sp, splitPart.first().section(sp + "=", 1, 1).section('&', 0, 0)); } url.setQuery(query); @@ -332,16 +351,17 @@ static QString unescape(const QString &s) { format["url"] = url; #else foreach (const QString ¶m, params) { - url.addQueryItem(param.section('=', 0, 0), param.section('=', -1)); + url.addQueryItem(param.section('=', 0, 0), param.section('=', 1)); } - if (!url.hasQueryItem("signature")) { - url.addQueryItem("signature", splitPart.first().section("signature=", 1, 1).section('&', 0, 0)); + if (!url.hasQueryItem(sp)) { + url.addQueryItem(sp, splitPart.first().section(sp + "=", 1, 1).section('&', 0, 0)); } Format format = formatHash.value(url.queryItemValue("itag")); format["url"] = url; #endif + formats << format; } } @@ -443,7 +463,7 @@ static QString unescape(const QString &s) { if (response.contains("url_encoded_fmt_stream_map\":")) { QString js = response.section("\"assets\":", 1, 1).section('}', 0, 0) + "}"; - response = response.section("url_encoded_fmt_stream_map\":\"", 1, 1).section(",\"", 0, 0) + response = response.section("url_encoded_fmt_stream_map\":\"", 1, 1).section("\",\"", 0, 0) .trimmed().replace("\\u0026", "&") .remove(QRegExp("itag=\\d+")); @@ -543,8 +563,8 @@ static QString unescape(const QString &s) { emit q->finished(); return; } - - QRegExp re("[\"']signature[\"'],(\\$[^\\(]+)"); + + QRegExp re("\\b[cs]\\s*&&\\s*[adf]\\.set\\([^,]+\\s*,\\s*encodeURIComponent\\s*\\(\\s*([a-zA-Z0-9$]+)\\("); if (re.indexIn(jsresponse) != -1) { QString funcName = re.cap(1);