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());
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;
return hasMore;
}
-const QStringList & AggregateVideoSource::getSuggestions() {
- QStringList *l = new QStringList();
- return *l;
-}
-
void AggregateVideoSource::abort() { }