]> git.sur5r.net Git - minitube/blobdiff - src/yt/ytjs/ytjschannelsource.cpp
New upstream version 3.9.1
[minitube] / src / yt / ytjs / ytjschannelsource.cpp
index a38264006fb84e26633a76cf9b8b3fe5de056c49..d40e81fe39fad89c1f8452ed50ad970d36f1b1cf 100644 (file)
@@ -99,15 +99,9 @@ void YTJSChannelSource::loadVideos(int max, int startIndex) {
                     video->setDescription(desc);
 
                     const auto thumbs = i["videoThumbnails"].toArray();
-                    for (const auto &thumbObj : thumbs) {
-                        QString url = thumbObj["url"].toString();
-                        int width = thumbObj["width"].toInt();
-                        if (width >= 336)
-                            video->setLargeThumbnailUrl(url);
-                        else if (width >= 246)
-                            video->setMediumThumbnailUrl(url);
-                        else if (width >= 168)
-                            video->setThumbnailUrl(url);
+                    for (const auto &t : thumbs) {
+                        video->addThumb(t["width"].toInt(), t["height"].toInt(),
+                                        t["url"].toString());
                     }
 
                     int views = i["viewCount"].toInt();
@@ -134,13 +128,10 @@ void YTJSChannelSource::loadVideos(int max, int startIndex) {
                 emit gotVideos(videos);
                 emit finished(videos.size());
             })
-            .onError([this, &js, max, startIndex](auto &msg) {
+            .onError([this, max, startIndex](auto &msg) {
                 static int retries = 0;
                 if (retries < 3) {
                     qDebug() << "Retrying...";
-                    auto nam = js.getEngine().networkAccessManager();
-                    nam->clearAccessCache();
-                    nam->setCookieJar(new QNetworkCookieJar());
                     QTimer::singleShot(0, this,
                                        [this, max, startIndex] { loadVideos(max, startIndex); });
                     retries++;