2 #include "cachedhttp.h"
5 #include "localcache.h"
6 #include "throttledhttp.h"
8 Http &HttpUtils::notCached() {
10 Http *http = new Http;
11 http->addRequestHeader("User-Agent", userAgent());
18 Http &HttpUtils::cached() {
20 Http *http = new Http;
21 http->addRequestHeader("User-Agent", userAgent());
23 CachedHttp *cachedHttp = new CachedHttp(*http, "http");
30 Http &HttpUtils::yt() {
32 Http *http = new Http;
33 http->addRequestHeader("User-Agent", stealthUserAgent());
35 CachedHttp *cachedHttp = new CachedHttp(*http, "yt");
36 cachedHttp->setMaxSeconds(3600);
43 void HttpUtils::clearCaches() {
44 LocalCache::instance("yt")->clear();
45 LocalCache::instance("http")->clear();
48 const QByteArray &HttpUtils::userAgent() {
49 static const QByteArray ua = [] {
50 return QString(QLatin1String(Constants::NAME) + QLatin1Char('/') +
51 QLatin1String(Constants::VERSION) + QLatin1String(" ( ") +
52 Constants::WEBSITE + QLatin1String(" )"))
58 const QByteArray &HttpUtils::stealthUserAgent() {
59 static const QByteArray ua =
60 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like "
61 "Gecko) Chrome/79.0.3945.79 Safari/537.36";