]> git.sur5r.net Git - minitube/blobdiff - src/aggregatevideosource.cpp
Upload 3.9.3-2 to unstable
[minitube] / src / aggregatevideosource.cpp
index dfffebfc33831424d4331c505e2a420190dd3a74..cf9b6a89801c313592314c23c7597aa54d398611 100644 (file)
@@ -52,7 +52,8 @@ void AggregateVideoSource::loadVideos(int max, int startIndex) {
     query.bindValue(1, max);
     bool success = query.exec();
     if (!success) qWarning() << query.lastQuery() << query.lastError().text();
-    QList<Video*> videos;
+    QVector<Video*> videos;
+    videos.reserve(query.size());
     while (query.next()) {
         Video *video = new Video();
         video->setId(query.value(0).toString());
@@ -62,7 +63,18 @@ void AggregateVideoSource::loadVideos(int max, int startIndex) {
         video->setChannelId(query.value(4).toString());
         video->setDescription(query.value(5).toString());
         video->setWebpage(query.value(6).toString());
-        video->setThumbnailUrl(query.value(7).toString());
+
+        QString thumbString = query.value(7).toString();
+        if (thumbString.startsWith('[')) {
+            const auto thumbs = QJsonDocument::fromJson(thumbString.toUtf8()).array();
+            for (const auto &t : thumbs) {
+                video->addThumb(t["width"].toInt(), t["height"].toInt(), t["url"].toString());
+            }
+        } else {
+            // assume it's a URL
+            video->addThumb(0, 0, thumbString);
+        }
+
         video->setViewCount(query.value(8).toInt());
         video->setDuration(query.value(9).toInt());
         videos << video;
@@ -78,9 +90,4 @@ bool AggregateVideoSource::hasMoreVideos() {
     return hasMore;
 }
 
-const QStringList & AggregateVideoSource::getSuggestions() {
-    static const QStringList l;
-    return l;
-}
-
 void AggregateVideoSource::abort() { }