]> git.sur5r.net Git - minitube/blobdiff - src/ytjs/ytjschannel.cpp
Update upstream source from tag 'upstream/3.8'
[minitube] / src / ytjs / ytjschannel.cpp
diff --git a/src/ytjs/ytjschannel.cpp b/src/ytjs/ytjschannel.cpp
deleted file mode 100644 (file)
index da8fc80..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#include "ytjschannel.h"
-
-#include "http.h"
-#include "httputils.h"
-#include "ytjs.h"
-
-YTJSChannel::YTJSChannel(const QString &id, QObject *parent) : QObject(parent) {
-    load(id);
-}
-
-void YTJSChannel::load(const QString &channelId) {
-    auto &ytjs = YTJS::instance();
-    if (!ytjs.isInitialized()) {
-        QTimer::singleShot(500, this, [this, channelId] { load(channelId); });
-        return;
-    }
-    auto &engine = ytjs.getEngine();
-
-    auto function = engine.evaluate("channelInfo");
-    if (!function.isCallable()) {
-        qWarning() << function.toString() << " is not callable";
-        emit error(function.toString());
-        return;
-    }
-
-    auto handler = new ResultHandler;
-    connect(handler, &ResultHandler::error, this, &YTJSChannel::error);
-    connect(handler, &ResultHandler::data, this, [this](const QJsonDocument &doc) {
-        auto obj = doc.object();
-
-        displayName = obj["author"].toString();
-        description = obj["description"].toString();
-
-        const auto thumbs = obj["authorThumbnails"].toArray();
-        int maxFoundWidth = 0;
-        for (const auto &thumbObj : thumbs) {
-            QString url = thumbObj["url"].toString();
-            int width = thumbObj["width"].toInt();
-            if (width > maxFoundWidth) {
-                maxFoundWidth = width;
-                thumbnailUrl = url;
-            }
-        }
-
-        emit loaded();
-    });
-    QJSValue h = engine.newQObject(handler);
-    auto value = function.call({h, channelId});
-    ytjs.checkError(value);
-}