]> git.sur5r.net Git - minitube/blobdiff - src/ytchannel.cpp
Update upstream source from tag 'upstream/3.6'
[minitube] / src / ytchannel.cpp
index bfc2d42e101105b311b7cff6f09722b727bf527e..1d83b2a7c11aa8dff802f025b3d08ee86c63d7cf 100644 (file)
@@ -28,6 +28,10 @@ $END_LICENSE */
 
 #include "iconutils.h"
 
+#include "ivchannel.h"
+#include "videoapi.h"
+#include "ytjschannel.h"
+
 YTChannel::YTChannel(const QString &channelId, QObject *parent)
     : QObject(parent), id(0), channelId(channelId), loadingThumbnail(false), notifyCount(0),
       checked(0), watched(0), loaded(0), loading(false) {}
@@ -80,15 +84,41 @@ void YTChannel::maybeLoadfromAPI() {
 
     loading = true;
 
-    QUrl url = YT3::instance().method("channels");
-    QUrlQuery q(url);
-    q.addQueryItem("id", channelId);
-    q.addQueryItem("part", "snippet");
-    url.setQuery(q);
-
-    QObject *reply = HttpUtils::yt().get(url);
-    connect(reply, SIGNAL(data(QByteArray)), SLOT(parseResponse(QByteArray)));
-    connect(reply, SIGNAL(error(QString)), SLOT(requestError(QString)));
+    if (VideoAPI::impl() == VideoAPI::YT3) {
+        QUrl url = YT3::instance().method("channels");
+        QUrlQuery q(url);
+        q.addQueryItem("id", channelId);
+        q.addQueryItem("part", "snippet");
+        url.setQuery(q);
+
+        QObject *reply = HttpUtils::yt().get(url);
+        connect(reply, SIGNAL(data(QByteArray)), SLOT(parseResponse(QByteArray)));
+        connect(reply, SIGNAL(error(QString)), SLOT(requestError(QString)));
+    } else if (VideoAPI::impl() == VideoAPI::IV) {
+        auto ivChannel = new IVChannel(channelId);
+        connect(ivChannel, &IVChannel::error, this, &YTChannel::requestError);
+        connect(ivChannel, &IVChannel::loaded, this, [this, ivChannel] {
+            displayName = ivChannel->getDisplayName();
+            description = ivChannel->getDescription();
+            thumbnailUrl = ivChannel->getThumbnailUrl();
+            ivChannel->deleteLater();
+            emit infoLoaded();
+            storeInfo();
+            loading = false;
+        });
+    } else if (VideoAPI::impl() == VideoAPI::JS) {
+        auto ivChannel = new YTJSChannel(channelId);
+        connect(ivChannel, &YTJSChannel::error, this, &YTChannel::requestError);
+        connect(ivChannel, &YTJSChannel::loaded, this, [this, ivChannel] {
+            displayName = ivChannel->getDisplayName();
+            description = ivChannel->getDescription();
+            thumbnailUrl = ivChannel->getThumbnailUrl();
+            ivChannel->deleteLater();
+            emit infoLoaded();
+            storeInfo();
+            loading = false;
+        });
+    }
 }
 
 void YTChannel::parseResponse(const QByteArray &bytes) {