2 #include "cachedhttp.h"
5 #include "localcache.h"
7 Http &HttpUtils::notCached() {
10 http->addRequestHeader("User-Agent", userAgent());
17 Http &HttpUtils::cached() {
19 Http *http = new Http;
20 http->addRequestHeader("User-Agent", userAgent());
22 CachedHttp *cachedHttp = new CachedHttp(*http, "http");
29 Http &HttpUtils::yt() {
31 Http *http = new Http;
32 http->addRequestHeader("User-Agent", stealthUserAgent());
34 CachedHttp *cachedHttp = new CachedHttp(*http, "yt");
35 cachedHttp->setMaxSeconds(86400);
42 Http &HttpUtils::stealthAndNotCached() {
44 Http *http = new Http;
45 http->addRequestHeader("User-Agent", stealthUserAgent());
52 void HttpUtils::clearCaches() {
53 LocalCache::instance("yt")->clear();
54 LocalCache::instance("http")->clear();
57 const QByteArray &HttpUtils::userAgent() {
58 static const QByteArray ua = [] {
59 return QString(QLatin1String(Constants::NAME) + QLatin1Char('/') +
60 QLatin1String(Constants::VERSION) + QLatin1String(" ( ") +
61 Constants::WEBSITE + QLatin1String(" )"))
67 const QByteArray &HttpUtils::stealthUserAgent() {
68 static const QByteArray ua =
69 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like "
70 "Gecko) Chrome/84.0.4147.105 Safari/537.36";