#include <QtNetwork>
#include "videodefinition.h"
#include "jsfunctions.h"
+#include "temporary.h"
namespace The {
NetworkAccess* http();
fmtUrlMap.replace("\\u0026", "&");
// parseFmtUrlMap(fmtUrlMap, true);
+#ifdef APP_DASH
+ QSettings settings;
+ QString definitionName = settings.value("definition", "360p").toString();
+ if (definitionName == "1080p") {
+ QRegExp dashManifestRe("\"dashmpd\":\\s*\"([^\"]+)\"");
+ if (dashManifestRe.indexIn(html) != -1) {
+ dashManifestUrl = dashManifestRe.cap(1);
+ dashManifestUrl.remove('\\');
+ qDebug() << "dashManifestUrl" << dashManifestUrl;
+ }
+ }
+#endif
+
QRegExp jsPlayerRe("\"assets\":.+\"js\":\\s*\"([^\"]+)\"");
if (jsPlayerRe.indexIn(html) != -1) {
QString jsPlayerUrl = jsPlayerRe.cap(1);
captureFunction(sigFuncName, js);
// qWarning() << sigFunctions;
}
+
+#ifdef APP_DASH
+ if (!dashManifestUrl.isEmpty()) {
+ QRegExp sigRe("/s/([\\w\\.]+)");
+ if (sigRe.indexIn(dashManifestUrl) != -1) {
+ qDebug() << "Decrypting signature for dash manifest";
+ QString sig = sigRe.cap(1);
+ sig = decryptSignature(sig);
+ dashManifestUrl.replace(sigRe, "/signature/" + sig);
+ qDebug() << dashManifestUrl;
+
+ m_streamUrl = dashManifestUrl;
+ this->definitionCode = 37;
+ emit gotStreamUrl(m_streamUrl);
+ loadingStreamUrl = false;
+
+ /*
+ QObject *reply = The::http()->get(QUrl::fromEncoded(dashManifestUrl.toUtf8()));
+ connect(reply, SIGNAL(data(QByteArray)), SLOT(parseDashManifest(QByteArray)));
+ connect(reply, SIGNAL(error(QNetworkReply*)), SLOT(errorVideoInfo(QNetworkReply*)));
+ */
+
+ return;
+ }
+ }
+#endif
+
parseFmtUrlMap(fmtUrlMap, true);
}
+void Video::parseDashManifest(QByteArray bytes) {
+ QFile file(Temporary::filename());
+ if (!file.open(QIODevice::WriteOnly))
+ qWarning() << file.errorString() << file.fileName();
+ QDataStream stream(&file);
+ stream.writeRawData(bytes.constData(), bytes.size());
+
+ m_streamUrl = "file://" + file.fileName();
+ this->definitionCode = 37;
+ emit gotStreamUrl(m_streamUrl);
+ loadingStreamUrl = false;
+}
+
void Video::captureFunction(const QString &name, const QString &js) {
QRegExp funcRe("function\\s+" + QRegExp::escape(name) + "\\s*\\([" + jsNameChars + ",\\s]*\\)\\s*\\{[^\\}]+\\}");
if (funcRe.indexIn(js) == -1) {
void errorVideoInfo(QNetworkReply*);
void scrapeWebPage(QByteArray);
void gotHeadHeaders(QNetworkReply*);
- void parseJsPlayer(QByteArray);
+ void parseJsPlayer(QByteArray bytes);
+ void parseDashManifest(QByteArray bytes);
private:
void getVideoInfo();
QString sigFuncName;
QHash<QString, QString> sigFunctions;
QHash<QString, QString> sigObjects;
+
+ QString dashManifestUrl;
};
// This is required in order to use QPointer<Video> as a QVariant