From 09bb449c94be5f6f2dd021d83a9efe3f0c0befee Mon Sep 17 00:00:00 2001 From: Flavio Date: Mon, 28 Jan 2013 10:25:06 +0100 Subject: [PATCH] video sources now emit Videos in batches instead of one by one --- src/videosource.h | 2 +- src/videosourcewidget.cpp | 9 +++++---- src/videosourcewidget.h | 2 +- src/ytsearch.cpp | 6 ++---- src/ytsinglevideosource.cpp | 7 +++---- src/ytstandardfeed.cpp | 6 ++---- 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/videosource.h b/src/videosource.h index 25fcfbf..767697e 100644 --- a/src/videosource.h +++ b/src/videosource.h @@ -20,7 +20,7 @@ public slots: void setParam(QString name, QVariant value); signals: - void gotVideo(Video *video); + void gotVideos(QList videos); void finished(int total); void error(QString message); void nameChanged(QString name); diff --git a/src/videosourcewidget.cpp b/src/videosourcewidget.cpp index d789a01..90b893b 100644 --- a/src/videosourcewidget.cpp +++ b/src/videosourcewidget.cpp @@ -13,8 +13,8 @@ VideoSourceWidget::VideoSourceWidget(VideoSource *videoSource, QWidget *parent) setCursor(Qt::PointingHandCursor); setFocusPolicy(Qt::StrongFocus); - connect(videoSource, SIGNAL(gotVideo(Video*)), - SLOT(previewVideo(Video*)), Qt::UniqueConnection); + connect(videoSource, SIGNAL(gotVideos(QList)), + SLOT(previewVideo(QList)), Qt::UniqueConnection); videoSource->loadVideos(1, 1); } @@ -22,9 +22,10 @@ void VideoSourceWidget::activate() { emit activated(videoSource); } -void VideoSourceWidget::previewVideo(Video *video) { +void VideoSourceWidget::previewVideo(QList videos) { videoSource->disconnect(); - this->video = video; + if (videos.isEmpty()) return; + video = videos.first(); connect(video, SIGNAL(gotMediumThumbnail(QByteArray)), SLOT(setPixmapData(QByteArray)), Qt::UniqueConnection); video->loadMediumThumbnail(); diff --git a/src/videosourcewidget.h b/src/videosourcewidget.h index 2316fcc..b2d9236 100644 --- a/src/videosourcewidget.h +++ b/src/videosourcewidget.h @@ -27,7 +27,7 @@ protected: private slots: void activate(); - void previewVideo(Video*); + void previewVideo(QList videos); void setPixmapData(QByteArray bytes); private: diff --git a/src/ytsearch.cpp b/src/ytsearch.cpp index c9e3c40..9f3fd34 100644 --- a/src/ytsearch.cpp +++ b/src/ytsearch.cpp @@ -18,7 +18,7 @@ YTSearch::YTSearch(SearchParams *searchParams, QObject *parent) : void YTSearch::loadVideos(int max, int skip) { aborted = false; - QUrl url("https://gdata.youtube.com/feeds/api/videos/"); + QUrl url("http://gdata.youtube.com/feeds/api/videos/"); url.addQueryItem("v", "2"); url.addQueryItem("max-results", QString::number(max)); @@ -108,9 +108,7 @@ void YTSearch::parseResults(QByteArray data) { emit nameChanged(name); } - foreach (Video *video, videos) - emit gotVideo(video); - + emit gotVideos(videos); emit finished(videos.size()); } diff --git a/src/ytsinglevideosource.cpp b/src/ytsinglevideosource.cpp index bf40ff9..6a22de5 100644 --- a/src/ytsinglevideosource.cpp +++ b/src/ytsinglevideosource.cpp @@ -19,8 +19,8 @@ void YTSingleVideoSource::loadVideos(int max, int skip) { this->max = max; QString s; - if (skip == 1) s = "https://gdata.youtube.com/feeds/api/videos/" + videoId; - else s = QString("https://gdata.youtube.com/feeds/api/videos/%1/related").arg(videoId); + if (skip == 1) s = "http://gdata.youtube.com/feeds/api/videos/" + videoId; + else s = QString("http://gdata.youtube.com/feeds/api/videos/%1/related").arg(videoId); QUrl url(s); url.addQueryItem("v", "2"); @@ -58,8 +58,7 @@ void YTSingleVideoSource::parse(QByteArray data) { emit nameChanged(name); } - foreach (Video *video, videos) - emit gotVideo(video); + emit gotVideos(videos); if (skip == 1) loadVideos(max - 1, 2); else if (skip == 2) emit finished(videos.size() + 1); diff --git a/src/ytstandardfeed.cpp b/src/ytstandardfeed.cpp index 8eb35a3..111ec29 100644 --- a/src/ytstandardfeed.cpp +++ b/src/ytstandardfeed.cpp @@ -15,7 +15,7 @@ YTStandardFeed::YTStandardFeed(QObject *parent) void YTStandardFeed::loadVideos(int max, int skip) { aborted = false; - QString s = "https://gdata.youtube.com/feeds/api/standardfeeds/"; + QString s = "http://gdata.youtube.com/feeds/api/standardfeeds/"; if (!regionId.isEmpty()) s += regionId + "/"; s += feedId; if (!category.isEmpty()) s += "_" + category; @@ -49,9 +49,7 @@ void YTStandardFeed::parse(QByteArray data) { YTFeedReader reader(data); QList videos = reader.getVideos(); - foreach (Video *video, videos) - emit gotVideo(video); - + emit gotVideos(videos); emit finished(videos.size()); } -- 2.39.5