git clone --recursive https://github.com/flaviotordini/minitube.git
-You need Qt >= 5.6 and MPV >= 0.29.0. The following Qt modules are needed: core, gui, widgets, network, sql (using the Sqlite plugin), declarative, dbus, x11extras.
+You need Qt >= 5.10 and MPV >= 0.29.0. The following Qt modules are needed: core, gui, widgets, network, sql (using the Sqlite plugin), declarative, dbus, x11extras.
To be able to build on a Debian (or derivative) system:
<message>
<source>K</source>
<comment>K as in Kilo, i.e. thousands</comment>
- <translation type="unfinished"/>
+ <translation>K</translation>
</message>
<message>
<source>M</source>
<comment>M stands for Millions</comment>
- <translation type="unfinished"/>
+ <translation>M</translation>
</message>
<message>
<source>B</source>
<comment>B stands for Billions</comment>
- <translation type="unfinished"/>
+ <translation>B</translation>
</message>
<message>
<source>%1 views</source>
</message>
<message>
<source>Powered by %1</source>
- <translation type="unfinished"/>
+ <translation>Alimenté par %1</translation>
</message>
<message>
<source>Open-source software</source>
</message>
<message>
<source>Switched to %1</source>
- <translation type="unfinished"/>
+ <translation>Basculé vers %1</translation>
</message>
<message>
<source>Unsubscribed from %1</source>
<name>PickMessage</name>
<message>
<source>Pick a video</source>
- <translation type="unfinished"/>
+ <translation>Choisir une vidéo</translation>
</message>
</context>
<context>
</message>
<message>
<source>&Forward</source>
- <translation type="unfinished"/>
+ <translation>&Continuer</translation>
</message>
<message>
<source>Forward to %1</source>
</message>
<message>
<source>Powered by %1</source>
- <translation type="unfinished"/>
+ <translation>%1 támogatásával</translation>
</message>
<message>
<source>Open-source software</source>
- <translation type="unfinished"/>
+ <translation>Nyílt forráskódú szoftver</translation>
</message>
<message>
<source>Icon designed by %1.</source>
<message>
<source>K</source>
<comment>K as in Kilo, i.e. thousands</comment>
- <translation type="unfinished"/>
+ <translation>K</translation>
</message>
<message>
<source>M</source>
<comment>M stands for Millions</comment>
- <translation type="unfinished"/>
+ <translation>M</translation>
</message>
<message>
<source>B</source>
<comment>B stands for Billions</comment>
- <translation type="unfinished"/>
+ <translation>B</translation>
</message>
<message>
<source>%1 views</source>
</message>
<message>
<source>Toggle &Menu Bar</source>
- <translation type="unfinished"/>
+ <translation>Toggle &Menu Bar</translation>
</message>
<message>
<source>Menu</source>
- <translation type="unfinished"/>
+ <translation>Menü</translation>
</message>
<message>
<source>&Love %1? Rate it!</source>
</message>
<message>
<source>You can still access the menu bar by pressing the ALT key</source>
- <translation type="unfinished"/>
+ <translation>A menüt az ALT gomb lenyomásával továbbra is eléred</translation>
</message>
</context>
<context>
</message>
<message>
<source>Switched to %1</source>
- <translation type="unfinished"/>
+ <translation>Ide váltás: %1</translation>
</message>
<message>
<source>Unsubscribed from %1</source>
<name>PickMessage</name>
<message>
<source>Pick a video</source>
- <translation type="unfinished"/>
+ <translation>Válassz videót</translation>
</message>
</context>
<context>
</message>
<message>
<source>&Forward</source>
- <translation type="unfinished"/>
+ <translation>&Előre</translation>
</message>
<message>
<source>Forward to %1</source>
<name>ActivationView</name>
<message>
<source>Please license %1</source>
- <translation>%1을(를) 구입 하세요</translation>
+ <translation>%1을(를) 구입하세요</translation>
</message>
<message>
<source>This demo has expired.</source>
</message>
<message>
<source>Last Watched</source>
- <translation>마지막 시청</translation>
+ <translation>최근 본 동영상</translation>
</message>
<message>
<source>Most Watched</source>
- <translation>가장 많이 시청</translation>
+ <translation>가장 많이 본 동영상</translation>
</message>
<message>
<source>Sort by</source>
</message>
<message>
<source>Show Updated</source>
- <translation>업데이트 표시</translation>
+ <translation>업데이트</translation>
</message>
<message>
<source>You have no subscriptions. Use the star symbol to subscribe to channels.</source>
- <translation>구독 항목이 없습니다. 채널을 구독 하려면 별 아이콘을 사용 하세요.</translation>
+ <translation>구독 항목이 없습니다. 채널을 구독하려면 별 아이콘을 사용하세요.</translation>
</message>
<message>
<source>All Videos</source>
</message>
<message>
<source>There are no updated subscriptions at this time.</source>
- <translation>현재 업데이트된 구독이 없습니다.</translation>
+ <translation>구독 목록이 최신입니다.</translation>
</message>
</context>
<context>
<name>DataUtils</name>
<message>
<source>Just now</source>
- <translation>지금</translation>
+ <translation>방금 전</translation>
</message>
<message numerus="yes">
<source>%n hour(s) ago</source>
- <translation type="unfinished"><numerusform></numerusform></translation>
+ <translation><numerusform>%n시간 전</numerusform></translation>
</message>
<message numerus="yes">
<source>%n day(s) ago</source>
- <translation type="unfinished"><numerusform></numerusform></translation>
+ <translation><numerusform>%s일 전</numerusform></translation>
</message>
<message numerus="yes">
<source>%n month(s) ago</source>
- <translation type="unfinished"><numerusform></numerusform></translation>
+ <translation><numerusform>%n달 전</numerusform></translation>
</message>
<message>
<source>K</source>
</message>
<message>
<source>%1 views</source>
- <translation>%1 조회수</translation>
+ <translation>조회수 %1</translation>
</message>
<message numerus="yes">
<source>%n week(s) ago</source>
<name>DownloadManager</name>
<message>
<source>%1 downloaded in %2</source>
- <translation>%1 downloaded in %2</translation>
+ <translation>%2 중 %1 다운로드 완료</translation>
</message>
<message>
<source>Download finished</source>
</message>
<message>
<source>Long</source>
- <translation>김</translation>
+ <translation>오래 전</translation>
</message>
<message>
<source>Less than 4 minutes</source>
</message>
<message>
<source>Enter</source>
- <translation>ì\96¸í\84°</translation>
+ <translation>ì\9d´ë\8f\99</translation>
</message>
<message>
<source>Recent keywords</source>
</message>
<message>
<source>Forward to %1</source>
- <translation>%1(으)로 이동</translation>
+ <translation>앞으로 (%1)</translation>
</message>
<message>
<source>Back to %1</source>
- <translation>%1(으)로 이동</translation>
+ <translation>뒤로 (%1)</translation>
</message>
</context>
<context>
</message>
<message>
<source>Did you mean: %1</source>
- <translation>ì\9b\90í\96\88ë\8d\98 ë\8b¨ì\96´: %1</translation>
+ <translation>ì\9d´ê²\83ì\9d\84 ê²\80ì\83\89í\95\98ì\85¨ë\82\98ì\9a\94: %1</translation>
</message>
</context>
<context>
<name>YTRegions</name>
<message>
<source>Algeria</source>
- <translation>알제리아</translation>
+ <translation>알제리</translation>
</message>
<message>
<source>Argentina</source>
</message>
<message>
<source>United Arab Emirates</source>
- <translation>아랍에메레이트</translation>
+ <translation>아랍 에미리트</translation>
</message>
<message>
<source>United Kingdom</source>
</message>
<message>
<source>Powered by %1</source>
- <translation type="unfinished"/>
+ <translation>Animado por %1</translation>
</message>
<message>
<source>Open-source software</source>
- <translation type="unfinished"/>
+ <translation>Programa Livre</translation>
</message>
<message>
<source>Icon designed by %1.</source>
</message>
<message numerus="yes">
<source>You have %n new video(s)</source>
- <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
+ <translation><numerusform>Você tem %n novos vídeos</numerusform><numerusform>Você tem %n novos vídeos</numerusform></translation>
</message>
</context>
<context>
</message>
<message numerus="yes">
<source>%n hour(s) ago</source>
- <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
+ <translation><numerusform>há %n horas</numerusform><numerusform>há %n horas</numerusform></translation>
</message>
<message numerus="yes">
<source>%n day(s) ago</source>
- <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
+ <translation><numerusform>há %n dias</numerusform><numerusform>há %n dias</numerusform></translation>
</message>
<message numerus="yes">
<source>%n month(s) ago</source>
- <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
+ <translation><numerusform>há %n mês</numerusform><numerusform>há %n meses</numerusform></translation>
</message>
<message>
<source>K</source>
<comment>K as in Kilo, i.e. thousands</comment>
- <translation type="unfinished"/>
+ <translation>K</translation>
</message>
<message>
<source>M</source>
<comment>M stands for Millions</comment>
- <translation type="unfinished"/>
+ <translation>M</translation>
</message>
<message>
<source>B</source>
<comment>B stands for Billions</comment>
- <translation type="unfinished"/>
+ <translation>B</translation>
</message>
<message>
<source>%1 views</source>
</message>
<message numerus="yes">
<source>%n week(s) ago</source>
- <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
+ <translation><numerusform>há %n semanas</numerusform><numerusform>há %n semanas</numerusform></translation>
</message>
</context>
<context>
</message>
<message numerus="yes">
<source>%n Download(s)</source>
- <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
+ <translation><numerusform>%n Transferência</numerusform><numerusform>%n Transferências</numerusform></translation>
</message>
</context>
<context>
</message>
<message>
<source>Powered by %1</source>
- <translation type="unfinished"/>
+ <translation>При помощи %1</translation>
</message>
<message>
<source>Open-source software</source>
- <translation type="unfinished"/>
+ <translation>ПО с открытым исходным кодом</translation>
</message>
<message>
<source>Icon designed by %1.</source>
</message>
<message numerus="yes">
<source>You have %n new video(s)</source>
- <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform><numerusform></numerusform><numerusform></numerusform></translation>
+ <translation><numerusform>У вас %n новых видео()</numerusform><numerusform>У вас %n новых видео()</numerusform><numerusform>У вас %n новых видео()</numerusform><numerusform>У вас %n новых видео()</numerusform></translation>
</message>
</context>
<context>
</message>
<message>
<source>Mark as Watched</source>
- <translation>Ð\9eÑ\82меÑ\82иÑ\82Ñ\8c как Ð\9fÑ\80оÑ\81моÑ\82Ñ\80енное.</translation>
+ <translation>Ð\9eÑ\82меÑ\82иÑ\82Ñ\8c как пÑ\80оÑ\81моÑ\82Ñ\80енное</translation>
</message>
<message>
<source>Unsubscribe</source>
</message>
<message numerus="yes">
<source>%n hour(s) ago</source>
- <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform><numerusform></numerusform><numerusform></numerusform></translation>
+ <translation><numerusform>%n час назад ()</numerusform><numerusform>%n часов назад ()</numerusform><numerusform>%n часов назад ()</numerusform><numerusform>%n час(-а, -ов) назад</numerusform></translation>
</message>
<message numerus="yes">
<source>%n day(s) ago</source>
- <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform><numerusform></numerusform><numerusform></numerusform></translation>
+ <translation><numerusform>%n день назад</numerusform><numerusform>%n дней (-ня) назад</numerusform><numerusform>%n дней (-ня) назад</numerusform><numerusform>%n день (суток) назад</numerusform></translation>
</message>
<message numerus="yes">
<source>%n month(s) ago</source>
- <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform><numerusform></numerusform><numerusform></numerusform></translation>
+ <translation><numerusform>%n месяц назад ()</numerusform><numerusform>%n месяца назад ()</numerusform><numerusform>%n месяцев назад ()</numerusform><numerusform>%n месяц(-ев) назад</numerusform></translation>
</message>
<message>
<source>K</source>
<comment>K as in Kilo, i.e. thousands</comment>
- <translation type="unfinished"/>
+ <translation>Тыс</translation>
</message>
<message>
<source>M</source>
<comment>M stands for Millions</comment>
- <translation type="unfinished"/>
+ <translation>Млн</translation>
</message>
<message>
<source>B</source>
<comment>B stands for Billions</comment>
- <translation type="unfinished"/>
+ <translation>Млрд</translation>
</message>
<message>
<source>%1 views</source>
</message>
<message numerus="yes">
<source>%n week(s) ago</source>
- <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform><numerusform></numerusform><numerusform></numerusform></translation>
+ <translation><numerusform>%n неделю назад ()</numerusform><numerusform>%n недель назад ()</numerusform><numerusform>%n недель назад ()</numerusform><numerusform>%n неделя назад ()</numerusform></translation>
</message>
</context>
<context>
</message>
<message>
<source>Toggle &Menu Bar</source>
- <translation type="unfinished"/>
+ <translation>Скрыть &Меню</translation>
</message>
<message>
<source>Menu</source>
- <translation type="unfinished"/>
+ <translation>Меню</translation>
</message>
<message>
<source>&Love %1? Rate it!</source>
</message>
<message>
<source>You can still access the menu bar by pressing the ALT key</source>
- <translation type="unfinished"/>
+ <translation>Открыть меню можно нажатием ALT</translation>
</message>
</context>
<context>
<name>PickMessage</name>
<message>
<source>Pick a video</source>
- <translation type="unfinished"/>
+ <translation>Посмотреть видео</translation>
</message>
</context>
<context>
</message>
<message>
<source>&Forward</source>
- <translation type="unfinished"/>
+ <translation>&Вверх</translation>
</message>
<message>
<source>Forward to %1</source>
CONFIG += c++14 exceptions_off rtti_off optimize_full
TEMPLATE = app
-VERSION = 3.1
+VERSION = 3.3
DEFINES += APP_VERSION="$$VERSION"
APP_NAME = Minitube
}
const QByteArray &HttpUtils::stealthUserAgent() {
- static const QByteArray ua = "curl/7.37.0";
+ static const QByteArray ua =
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like "
+ "Gecko) Chrome/79.0.3945.79 Safari/537.36";
return ua;
}
loadingStreamUrl = true;
elIndex = 0;
ageGate = false;
+ webPageLoaded = false;
- getVideoInfo();
+ // getVideoInfo();
+ loadWebPage();
}
void YTVideo::getVideoInfo() {
q.addQueryItem("sts", "1588");
url.setQuery(q);
} else if (elIndex > elTypes.size() - 1) {
- qWarning() << "Cannot get video info";
- loadingStreamUrl = false;
- emit errorStreamUrl("Cannot get video info");
+ qDebug() << "Cannot get video info";
+ if (!webPageLoaded) {
+ // no video info file, but we can try loading the "urlmap" from the web page
+ loadWebPage();
+ } else {
+ emitError("Cannot get video info");
+ }
return;
} else {
// qDebug() << "Trying el param:" << elTypes.at(elIndex) << elIndex;
QObject *reply = HttpUtils::yt().get(url);
connect(reply, SIGNAL(data(QByteArray)), SLOT(gotVideoInfo(QByteArray)));
- connect(reply, SIGNAL(error(QString)), SLOT(errorVideoInfo(QString)));
+ connect(reply, SIGNAL(error(QString)), SLOT(emitError(QString)));
// see you in gotVideoInfo...
}
QString videoInfo = QString::fromUtf8(bytes);
// qDebug() << "videoInfo" << videoInfo;
+ // get player_response
+ static const QRegExp playerResponseRE("&player_response=([^&]+)");
+ if (playerResponseRE.indexIn(videoInfo) != -1) {
+ QString playerResponse = playerResponseRE.cap(1);
+ QByteArray playerResponseUtf8 = QByteArray::fromPercentEncoding(playerResponse.toUtf8());
+ // qDebug() << "player_response" << playerResponseUtf8;
+ QJsonDocument doc = QJsonDocument::fromJson(playerResponseUtf8);
+ QJsonObject obj = doc.object();
+ if (obj.contains("streamingData")) {
+ auto parseFormats = [this](const QJsonArray &formats) {
+ for (const QJsonValue &format : formats) {
+ QJsonObject formatObj = format.toObject();
+ int itag = formatObj["itag"].toInt();
+ QString url = formatObj["url"].toString();
+ if (url.isEmpty()) {
+ QString cipher = formatObj["cipher"].toString();
+ QUrlQuery q(cipher);
+ qDebug() << "Cipher is " << q.toString();
+ url = q.queryItemValue("url").trimmed();
+ // while (url.contains('%'))
+ url = QByteArray::fromPercentEncoding(url.toUtf8());
+ if (q.hasQueryItem("s")) {
+ QString s = q.queryItemValue("s");
+ qDebug() << "s is" << s;
+ s = decryptSignature(s);
+ if (!s.isEmpty()) {
+ qDebug() << "Added signature" << s;
+ url += "&sig=";
+ url += s;
+ }
+ }
+ }
+ // qDebug() << "player_response format" << itag << url;
+ if (!url.isEmpty()) urlMap.insert(itag, url);
+ }
+ };
+ QJsonObject streamingDataObj = obj["streamingData"].toObject();
+ // qDebug() << "Found streamingData" << streamingDataObj;
+ parseFormats(streamingDataObj["formats"].toArray());
+ parseFormats(streamingDataObj["adaptiveFormats"].toArray());
+ }
+ }
+
+ /*
// get video token
static const QRegExp videoTokeRE(JsFunctions::instance()->videoTokenRE());
if (videoTokeRE.indexIn(videoInfo) == -1) {
- qDebug() << "Cannot get token. Trying next el param" << videoInfo << videoTokeRE.pattern();
+ qDebug() << "Cannot get token. Trying next el param" << videoTokeRE.pattern() << videoInfo;
// Don't panic! We're gonna try another magic "el" param
elIndex++;
getVideoInfo();
getVideoInfo();
return;
}
-
QString fmtUrlMap = fmtMapRE.cap(1);
// qDebug() << "got fmtUrlMap" << fmtUrlMap;
fmtUrlMap = QByteArray::fromPercentEncoding(fmtUrlMap.toUtf8());
+*/
+
+ if (urlMap.isEmpty()) {
+ elIndex++;
+ getVideoInfo();
+ return;
+ }
qDebug() << "Got token and urlMap" << elIndex << videoToken << fmtUrlMap;
parseFmtUrlMap(fmtUrlMap);
}
-void YTVideo::parseFmtUrlMap(const QString &fmtUrlMap, bool fromWebPage) {
+void YTVideo::parseFmtUrlMap(const QString &fmtUrlMap) {
int videoFormat = 0;
const VideoDefinition &definition = YT3::instance().maxVideoDefinition();
int separator = urlParam.indexOf('=');
sig = QByteArray::fromPercentEncoding(urlParam.mid(separator + 1).toUtf8());
} else if (urlParam.startsWith(QLatin1String("s="))) {
- if (fromWebPage || ageGate) {
+ if (webPageLoaded || ageGate) {
int separator = urlParam.indexOf('=');
sig = QByteArray::fromPercentEncoding(urlParam.mid(separator + 1).toUtf8());
sig = decryptSignature(sig);
urlMap.insert(format, url);
}
- if (!fromWebPage && !ageGate) {
+ if (!webPageLoaded && !ageGate) {
loadWebPage();
return;
}
return;
}
+ qDebug() << "available formats" << urlMap.keys();
const QVector<VideoDefinition> &definitions = VideoDefinition::getDefinitions();
int previousIndex = std::max(definitions.indexOf(definition) - 1, 0);
for (; previousIndex >= 0; previousIndex--) {
q.addQueryItem("has_verified", "1");
q.addQueryItem("bpctr", "9999999999");
url.setQuery(q);
+
+ // QUrl url("https://www.youtube.com/embed/" + videoId);
+
qDebug() << "Loading webpage" << url;
QObject *reply = HttpUtils::yt().get(url);
connect(reply, SIGNAL(data(QByteArray)), SLOT(scrapeWebPage(QByteArray)));
- connect(reply, SIGNAL(error(QString)), SLOT(errorVideoInfo(QString)));
+ connect(reply, SIGNAL(error(QString)), SLOT(emitError(QString)));
// see you in scrapWebPage(QByteArray)
}
-void YTVideo::errorVideoInfo(const QString &message) {
- loadingStreamUrl = false;
+void YTVideo::emitError(const QString &message) {
+ qWarning() << message;
emit errorStreamUrl(message);
}
void YTVideo::scrapeWebPage(const QByteArray &bytes) {
- qDebug() << "scrapeWebPage";
+ webPageLoaded = true;
const QString html = QString::fromUtf8(bytes);
+ // qDebug() << "scrapeWebPage" << html;
static const QRegExp ageGateRE(JsFunctions::instance()->ageGateRE());
if (ageGateRE.indexIn(html) != -1) {
fmtUrlMap += adaptiveFormatsRE.cap(1).replace("\\u0026", "&");
}
- if (fmtUrlMap.isEmpty()) {
+ if (fmtUrlMap.isEmpty() && urlMap.isEmpty()) {
qWarning() << "Cannot get fmtUrlMap from video page. Trying next el";
- elIndex++;
- getVideoInfo();
- return;
+ // elIndex++;
+ // getVideoInfo();
+ // return;
}
static const QRegExp jsPlayerRe(JsFunctions::instance()->jsPlayerRE());
*/
QObject *reply = HttpUtils::yt().get(jsPlayerUrl);
connect(reply, SIGNAL(data(QByteArray)), SLOT(parseJsPlayer(QByteArray)));
- connect(reply, SIGNAL(error(QString)), SLOT(errorVideoInfo(QString)));
+ connect(reply, SIGNAL(error(QString)), SLOT(emitError(QString)));
}
}
}();
for (const QRegExp &funcNameRe : funcNameRes) {
if (funcNameRe.indexIn(jsPlayer) == -1) {
- qWarning() << "Cannot capture signature function name" << funcNameRe;
+ qDebug() << "Cannot capture signature function name" << funcNameRe;
continue;
} else {
sigFuncName = funcNameRe.cap(1);
}
if (sigFuncName.isEmpty()) qDebug() << "Empty signature function name";
- parseFmtUrlMap(fmtUrlMap, true);
+ // parseFmtUrlMap(fmtUrlMap, true);
+ getVideoInfo();
}
void YTVideo::captureFunction(const QString &name, const QString &js) {
private slots:
void gotVideoInfo(const QByteArray &bytes);
- void errorVideoInfo(const QString &message);
+ void emitError(const QString &message);
void scrapeWebPage(const QByteArray &bytes);
void parseJsPlayer(const QByteArray &bytes);
private:
void getVideoInfo();
- void parseFmtUrlMap(const QString &fmtUrlMap, bool fromWebPage = false);
+ void parseFmtUrlMap(const QString &fmtUrlMap);
void loadWebPage();
void captureFunction(const QString &name, const QString &js);
void captureObject(const QString &name, const QString &js);
QString dashManifestUrl;
QString jsPlayer;
QMap<int, QString> urlMap;
+ bool webPageLoaded = false;
};
#endif // YTVIDEO_H