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);
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);
}
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();
private slots:
void activate();
- void previewVideo(Video*);
+ void previewVideo(QList<Video*> videos);
void setPixmapData(QByteArray bytes);
private:
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));
emit nameChanged(name);
}
- foreach (Video *video, videos)
- emit gotVideo(video);
-
+ emit gotVideos(videos);
emit finished(videos.size());
}
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");
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);
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;
YTFeedReader reader(data);
QList<Video*> videos = reader.getVideos();
- foreach (Video *video, videos)
- emit gotVideo(video);
-
+ emit gotVideos(videos);
emit finished(videos.size());
}