]> git.sur5r.net Git - minitube/commitdiff
New upstream version 3.3 upstream/3.3
authorJakob Haufe <sur5r@debian.org>
Wed, 4 Mar 2020 19:52:19 +0000 (19:52 +0000)
committerJakob Haufe <sur5r@debian.org>
Wed, 4 Mar 2020 19:52:19 +0000 (19:52 +0000)
README.md
locale/ca.ts
locale/fr.ts
locale/hu.ts
locale/ko_KR.ts
locale/pt_PT.ts
locale/ru.ts
minitube.pro
src/httputils.cpp
src/ytvideo.cpp
src/ytvideo.h

index 1580dc61ffa10bed96c2d14856f8c7ff62599e60..4106a0e1c098e13f9589e8f114c5c30c63ac3e00 100644 (file)
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ Clone from Github:
 
     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:
 
index f3d56f3e38672cfa85f0010e41b65263d6c185f6..64c3ecfe8f940521ad7cbacde85c655a75ec1a2e 100644 (file)
     <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>
index 978bb23ba839dc283a2ef2055841b9a665cee240..46ff0f36f9ed138af6cfde22936bf3b8d3810819 100644 (file)
@@ -27,7 +27,7 @@
     </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>&amp;Forward</source>
-        <translation type="unfinished"/>
+        <translation>&amp;Continuer</translation>
     </message>
     <message>
         <source>Forward to %1</source>
index 9d60117634c312f5ecab7e53e263abfac57c9693..fa4c83f7228a024db05209d3d6b8f42fe1b14734 100644 (file)
     </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 &amp;Menu Bar</source>
-        <translation type="unfinished"/>
+        <translation>Toggle &amp;Menu Bar</translation>
     </message>
     <message>
         <source>Menu</source>
-        <translation type="unfinished"/>
+        <translation>Menü</translation>
     </message>
     <message>
         <source>&amp;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>&amp;Forward</source>
-        <translation type="unfinished"/>
+        <translation>&amp;Előre</translation>
     </message>
     <message>
         <source>Forward to %1</source>
index 1240d49a73cd7277533e6e3acc611efe67f1b666..503df0efffa4a87c93ee1a748639ef1ffb3d4b73 100644 (file)
@@ -69,7 +69,7 @@
     <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>
index 6caf9969ed0693ff301a44a458ed9135562708a2..30161aea32d89c4ce84fd0a9afbb0181c908c84f 100644 (file)
     </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>
index 179bbb5811820e5ac9956afbe766742f8c8a1b90..1de2897b484c1e256206cefc8310e9c38c2e0807 100644 (file)
     </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 &amp;Menu Bar</source>
-        <translation type="unfinished"/>
+        <translation>Скрыть &amp;Меню</translation>
     </message>
     <message>
         <source>Menu</source>
-        <translation type="unfinished"/>
+        <translation>Меню</translation>
     </message>
     <message>
         <source>&amp;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>&amp;Forward</source>
-        <translation type="unfinished"/>
+        <translation>&amp;Вверх</translation>
     </message>
     <message>
         <source>Forward to %1</source>
index 27c5a01681bb096f021d2315314cd4e0e9552f42..778eb3e0f45b8199fc9beea43061de3b44a4bcb7 100644 (file)
@@ -1,7 +1,7 @@
 CONFIG += c++14 exceptions_off rtti_off optimize_full
 
 TEMPLATE = app
-VERSION = 3.1
+VERSION = 3.3
 DEFINES += APP_VERSION="$$VERSION"
 
 APP_NAME = Minitube
index d522f6e3423e9c2fad7e3fcbad6571ea88ac1a94..6865499824d890d7068be34e86bf08b76d92cd6a 100644 (file)
@@ -56,6 +56,8 @@ const QByteArray &HttpUtils::userAgent() {
 }
 
 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;
 }
index f311011ef86f2d37794588b03e86dbdb734e8ebe..157eeb9e76a3f83d2804d127c4ac8fc9facd6028 100644 (file)
@@ -28,8 +28,10 @@ void YTVideo::loadStreamUrl() {
     loadingStreamUrl = true;
     elIndex = 0;
     ageGate = false;
+    webPageLoaded = false;
 
-    getVideoInfo();
+    // getVideoInfo();
+    loadWebPage();
 }
 
 void YTVideo::getVideoInfo() {
@@ -49,9 +51,13 @@ 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;
@@ -62,7 +68,7 @@ void YTVideo::getVideoInfo() {
 
     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...
 }
@@ -71,10 +77,54 @@ void YTVideo::gotVideoInfo(const QByteArray &bytes) {
     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();
@@ -96,16 +146,22 @@ void YTVideo::gotVideoInfo(const QByteArray &bytes) {
         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();
 
@@ -137,7 +193,7 @@ void YTVideo::parseFmtUrlMap(const QString &fmtUrlMap, bool fromWebPage) {
                 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);
@@ -173,7 +229,7 @@ void YTVideo::parseFmtUrlMap(const QString &fmtUrlMap, bool fromWebPage) {
         urlMap.insert(format, url);
     }
 
-    if (!fromWebPage && !ageGate) {
+    if (!webPageLoaded && !ageGate) {
         loadWebPage();
         return;
     }
@@ -185,6 +241,7 @@ void YTVideo::parseFmtUrlMap(const QString &fmtUrlMap, bool fromWebPage) {
         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--) {
@@ -209,22 +266,26 @@ void YTVideo::loadWebPage() {
     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) {
@@ -249,11 +310,11 @@ void YTVideo::scrapeWebPage(const QByteArray &bytes) {
         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());
@@ -273,7 +334,7 @@ void YTVideo::scrapeWebPage(const QByteArray &bytes) {
                     */
         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)));
     }
 }
 
@@ -291,7 +352,7 @@ void YTVideo::parseJsPlayer(const QByteArray &bytes) {
     }();
     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);
@@ -307,7 +368,8 @@ void YTVideo::parseJsPlayer(const QByteArray &bytes) {
     }
     if (sigFuncName.isEmpty()) qDebug() << "Empty signature function name";
 
-    parseFmtUrlMap(fmtUrlMap, true);
+    // parseFmtUrlMap(fmtUrlMap, true);
+    getVideoInfo();
 }
 
 void YTVideo::captureFunction(const QString &name, const QString &js) {
index 772df5f90a6c1eb60b791e50ffa3dbfd9c29e1df..d50fa595ab1521a5c90a755dc04b392b58bc9959 100644 (file)
@@ -19,13 +19,13 @@ signals:
 
 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);
@@ -46,6 +46,7 @@ private:
     QString dashManifestUrl;
     QString jsPlayer;
     QMap<int, QString> urlMap;
+    bool webPageLoaded = false;
 };
 
 #endif // YTVIDEO_H