X-Git-Url: https://git.sur5r.net/?p=minitube;a=blobdiff_plain;f=src%2Fyt%2Fytjs%2Fytjssearch.cpp;fp=src%2Fyt%2Fytjs%2Fytjssearch.cpp;h=65bd85dd00a0380ad41338f0632818dbbe8d2b62;hp=efdd0a0f51911b56b5633491dd50974376534dfb;hb=9ff1806f2db97d617aa96185b7bf17f77bbacbcb;hpb=707b121e136bbb650f012ad9a55010acf6dea6fd diff --git a/src/yt/ytjs/ytjssearch.cpp b/src/yt/ytjs/ytjssearch.cpp index efdd0a0..65bd85d 100644 --- a/src/yt/ytjs/ytjssearch.cpp +++ b/src/yt/ytjs/ytjssearch.cpp @@ -108,7 +108,7 @@ void YTJSSearch::loadVideos(int max, int startIndex) { jsMapSet.callWithInstance(filterMap, {name, value}); }; - addFilter("Type", "Video"); + // addFilter("Type", "Video"); switch (searchParams->sortBy()) { case SearchParams::SortByNewest: @@ -127,6 +127,8 @@ void YTJSSearch::loadVideos(int max, int startIndex) { addFilter("Duration", "Short"); break; case SearchParams::DurationMedium: + addFilter("Duration", "Medium"); + break; case SearchParams::DurationLong: addFilter("Duration", "Long"); break; @@ -142,6 +144,9 @@ void YTJSSearch::loadVideos(int max, int startIndex) { case SearchParams::TimeMonth: addFilter("Upload date", "This month"); break; + case SearchParams::TimeYear: + addFilter("Upload date", "This year"); + break; } switch (searchParams->quality()) { @@ -183,8 +188,11 @@ void YTJSSearch::loadVideos(int max, int startIndex) { QString desc = i["description"].toString(); video->setDescription(desc); - QString thumb = i["thumbnail"].toString(); - video->setThumbnailUrl(thumb); + const auto thumbs = i["thumbnails"].toArray(); + for (const auto &t : thumbs) { + video->addThumb(t["width"].toInt(), t["height"].toInt(), + t["url"].toString()); + } int views = i["views"].toInt(); video->setViewCount(views); @@ -211,13 +219,10 @@ void YTJSSearch::loadVideos(int max, int startIndex) { 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++;