]> git.sur5r.net Git - minitube/commitdiff
video sources now emit Videos in batches instead of one by one
authorFlavio <flavio@odisseo.local>
Mon, 28 Jan 2013 09:25:06 +0000 (10:25 +0100)
committerFlavio <flavio@odisseo.local>
Mon, 28 Jan 2013 09:25:06 +0000 (10:25 +0100)
src/videosource.h
src/videosourcewidget.cpp
src/videosourcewidget.h
src/ytsearch.cpp
src/ytsinglevideosource.cpp
src/ytstandardfeed.cpp

index 25fcfbf0bfa26f89e1079a26845d35b2f458b964..767697edf9e769001c964c6ed1f39d150a5de1a3 100644 (file)
@@ -20,7 +20,7 @@ public slots:
     void setParam(QString name, QVariant value);
 
 signals:
-    void gotVideo(Video *video);
+    void gotVideos(QList<Video*> videos);
     void finished(int total);
     void error(QString message);
     void nameChanged(QString name);
index d789a01f0cb29864fccae215bcd23801080489e5..90b893b0f6145632462f1a16b5af99a7280fb522 100644 (file)
@@ -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<Video*>)),
+            SLOT(previewVideo(QList<Video*>)), 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<Video*> 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();
index 2316fccb6d5176567c5cb931edefc4dfb99d21b7..b2d923631ec116a3f171a4ad0ef11d7b9a591246 100644 (file)
@@ -27,7 +27,7 @@ protected:
 
 private slots:
     void activate();
-    void previewVideo(Video*);
+    void previewVideo(QList<Video*> videos);
     void setPixmapData(QByteArray bytes);
 
 private:
index c9e3c4075fd13780a561511e603721a3f1a82788..9f3fd34f9cb47e111405ff81f8b01c8a98f62c32 100644 (file)
@@ -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());
 }
 
index bf40ff9d8059bddb91bff1890ba11e4d9fa7f5fd..6a22de58b22a55ebe9256871124c365d56991395 100644 (file)
@@ -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);
index 8eb35a321c10c4cbbe45a8fd7ad620e42e47edbc..111ec291a5600cb50236585b76b00480f583aa59 100644 (file)
@@ -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<Video*> videos = reader.getVideos();
 
-    foreach (Video *video, videos)
-        emit gotVideo(video);
-
+    emit gotVideos(videos);
     emit finished(videos.size());
 }