X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fchannelaggregator.cpp;h=8097af180e51fe03d44ed32383b50b61cc8e42f9;hb=HEAD;hp=5848fa9e935d47bf908db7e039871fa7c1d452fc;hpb=de286bbf3fb8456ced35bf99730b98c59050f7c4;p=minitube diff --git a/src/channelaggregator.cpp b/src/channelaggregator.cpp index 5848fa9..8097af1 100644 --- a/src/channelaggregator.cpp +++ b/src/channelaggregator.cpp @@ -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) { @@ -80,9 +81,6 @@ void ChannelAggregator::run() { updatedChannels.clear(); updatedChannels.squeeze(); - if (!Database::instance().getConnection().transaction()) - qWarning() << "Transaction failed" << __PRETTY_FUNCTION__; - processNextChannel(); } @@ -100,7 +98,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))); @@ -126,7 +132,7 @@ void ChannelAggregator::parseWebPage(const QByteArray &bytes) { } else { currentChannel->updateChecked(); currentChannel = 0; - processNextChannel(); + QTimer::singleShot(5000, this, &ChannelAggregator::processNextChannel); } } @@ -153,6 +159,11 @@ void ChannelAggregator::reallyProcessChannel(YTChannel *channel) { connect(videoSource, SIGNAL(gotVideos(QVector