]> git.sur5r.net Git - minitube/blobdiff - src/channelaggregator.cpp
New upstream version 3.6
[minitube] / src / channelaggregator.cpp
index 5848fa9e935d47bf908db7e039871fa7c1d452fc..2fcf42b5d0f8fdca1430e819e78535159477fc3a 100644 (file)
@@ -30,8 +30,9 @@ $END_LICENSE */
 #include "http.h"
 #include "httputils.h"
 
-#include "videoapi.h"
 #include "ivchannelsource.h"
+#include "videoapi.h"
+#include "ytjschannelsource.h"
 
 ChannelAggregator::ChannelAggregator(QObject *parent)
     : QObject(parent), unwatchedCount(-1), running(false), stopped(false), currentChannel(0) {
@@ -100,7 +101,15 @@ void ChannelAggregator::processNextChannel() {
 
 void ChannelAggregator::checkWebPage(YTChannel *channel) {
     currentChannel = channel;
-    QString url = "https://www.youtube.com/channel/" + channel->getChannelId() + "/videos";
+
+    QString channelId = channel->getChannelId();
+    QString url;
+    if (channelId.startsWith("UC") && !channelId.contains(' ')) {
+        url = "https://www.youtube.com/channel/" + channelId + "/videos";
+    } else {
+        url = "https://www.youtube.com/user/" + channelId + "/videos";
+    }
+
     QObject *reply = HttpUtils::yt().get(url);
 
     connect(reply, SIGNAL(data(QByteArray)), SLOT(parseWebPage(QByteArray)));
@@ -153,6 +162,11 @@ void ChannelAggregator::reallyProcessChannel(YTChannel *channel) {
         connect(videoSource, SIGNAL(gotVideos(QVector<Video *>)),
                 SLOT(videosLoaded(QVector<Video *>)));
         videoSource->loadVideos(50, 1);
+    } else if (VideoAPI::impl() == VideoAPI::JS) {
+        auto *videoSource = new YTJSChannelSource(params);
+        connect(videoSource, SIGNAL(gotVideos(QVector<Video *>)),
+                SLOT(videosLoaded(QVector<Video *>)));
+        videoSource->loadVideos(50, 1);
     }
 
     channel->updateChecked();