#include "searchparams.h"
#include "ytsinglevideosource.h"
#include "channelaggregator.h"
-#include "utils.h"
-#include "ytuser.h"
+#include "iconutils.h"
+#include "ytchannel.h"
#ifdef APP_SNAPSHOT
#include "snapshotsettings.h"
#endif
#include "datautils.h"
+#include "compatibility/qurlqueryhelper.h"
namespace The {
NetworkAccess* http();
}
}
}
- setVideoSource(new YTSearch(searchParams, this));
+ YTSearch *ytSearch = new YTSearch(searchParams, this);
+ ytSearch->setAsyncDetails(true);
+ connect(ytSearch, SIGNAL(gotDetails()), playlistModel, SLOT(emitDataChanged()));
+ setVideoSource(ytSearch);
}
void MediaView::setVideoSource(VideoSource *videoSource, bool addToHistory, bool back) {
sidebar->getHeader()->updateInfo();
SearchParams *searchParams = getSearchParams();
- bool isChannel = searchParams && !searchParams->author().isEmpty();
+ bool isChannel = searchParams && !searchParams->channelId().isEmpty();
playlistView->setClickableAuthors(!isChannel);
if (newState == Phonon::PlayingState)
videoAreaWidget->showVideo();
else if (newState == Phonon::ErrorState) {
- qDebug() << "Phonon error:" << mediaObject->errorString() << mediaObject->errorType();
+ qWarning() << "Phonon error:" << mediaObject->errorString() << mediaObject->errorType();
if (mediaObject->errorType() == Phonon::FatalError)
handleError(mediaObject->errorString());
}
a->setEnabled(enableDownload);
a->setVisible(enableDownload);
- updateSubscriptionAction(video, YTUser::isSubscribed(video->userId()));
+ updateSubscriptionAction(video, YTChannel::isSubscribed(video->channelId()));
foreach (QAction *action, currentVideoActions)
action->setEnabled(true);
startDownloading();
#endif
- // ensure we always have 10 videos ahead
+ // ensure we always have videos ahead
playlistModel->searchNeeded();
// ensure active item is visible
#endif
#ifdef APP_EXTRA
- Extra::notify(video->title(), video->author(), video->formattedDuration());
+ Extra::notify(video->title(), video->channelTitle(), video->formattedDuration());
#endif
ChannelAggregator::instance()->videoWatched(video);
void MediaView::copyWebPage() {
Video* video = playlistModel->activeVideo();
if (!video) return;
- QString address = video->webpage().toString();
+ QString address = video->webpage();
QApplication::clipboard()->setText(address);
QString message = tr("You can now paste the YouTube link into another application");
MainWindow::instance()->showMessage(message);
if (!video) return;
QString location = SnapshotSettings::getCurrentLocation();
+ QDir dir(location);
+ if (!dir.exists()) dir.mkpath(location);
QString basename = video->title();
QString format = video->duration() > 3600 ? "h_mm_ss" : "m_ss";
basename += " (" + QTime().addSecs(currentTime).toString(format) + ")";
SearchParams *searchParams = new SearchParams();
searchParams->setTransient(true);
searchParams->setKeywords(query);
- searchParams->setAuthor(video->author());
+ searchParams->setChannelId(video->channelId());
/*
if (!numberAsWords) {
Video* video = playlistModel->activeVideo();
if (!video) return;
YTSingleVideoSource *singleVideoSource = new YTSingleVideoSource();
- singleVideoSource->setVideoId(video->id());
+ singleVideoSource->setVideo(video->clone());
+ singleVideoSource->setAsyncDetails(true);
setVideoSource(singleVideoSource);
The::globalActions()->value("related-videos")->setEnabled(false);
}
Video* video = playlistModel->activeVideo();
if (!video) return;
QUrl url("https://twitter.com/intent/tweet");
-#if QT_VERSION >= 0x050000
{
- QUrl &u = url;
- QUrlQuery url;
-#endif
- url.addQueryItem("via", "minitubeapp");
- url.addQueryItem("text", video->title());
- url.addQueryItem("url", video->webpage().toString());
-#if QT_VERSION >= 0x050000
- u.setQuery(url);
+ QUrlQueryHelper urlHelper(url);
+ urlHelper.addQueryItem("via", "minitubeapp");
+ urlHelper.addQueryItem("text", video->title());
+ urlHelper.addQueryItem("url", video->webpage());
}
-#endif
QDesktopServices::openUrl(url);
}
Video* video = playlistModel->activeVideo();
if (!video) return;
QUrl url("https://www.facebook.com/sharer.php");
-#if QT_VERSION >= 0x050000
{
- QUrl &u = url;
- QUrlQuery url;
-#endif
- url.addQueryItem("t", video->title());
- url.addQueryItem("u", video->webpage().toString());
-#if QT_VERSION >= 0x050000
- u.setQuery(url);
+ QUrlQueryHelper urlHelper(url);
+ urlHelper.addQueryItem("t", video->title());
+ urlHelper.addQueryItem("u", video->webpage());
}
-#endif
QDesktopServices::openUrl(url);
}
Video* video = playlistModel->activeVideo();
if (!video) return;
QUrl url("http://bufferapp.com/add");
-#if QT_VERSION >= 0x050000
{
- QUrl &u = url;
- QUrlQuery url;
-#endif
- url.addQueryItem("via", "minitubeapp");
- url.addQueryItem("text", video->title());
- url.addQueryItem("url", video->webpage().toString());
- url.addQueryItem("picture", video->thumbnailUrl());
-#if QT_VERSION >= 0x050000
- u.setQuery(url);
+ QUrlQueryHelper urlHelper(url);
+ urlHelper.addQueryItem("via", "minitubeapp");
+ urlHelper.addQueryItem("text", video->title());
+ urlHelper.addQueryItem("url", video->webpage());
+ urlHelper.addQueryItem("picture", video->thumbnailUrl());
}
-#endif
QDesktopServices::openUrl(url);
}
Video* video = playlistModel->activeVideo();
if (!video) return;
QUrl url("mailto:");
-#if QT_VERSION >= 0x050000
{
- QUrl &u = url;
- QUrlQuery url;
-#endif
- url.addQueryItem("subject", video->title());
- QString body = video->title() + "\n" +
- video->webpage().toString() + "\n\n" +
+ QUrlQueryHelper urlHelper(url);
+ urlHelper.addQueryItem("subject", video->title());
+ const QString body = video->title() + "\n" +
+ video->webpage() + "\n\n" +
tr("Sent from %1").arg(Constants::NAME) + "\n" +
Constants::WEBSITE;
- url.addQueryItem("body", body);
-#if QT_VERSION >= 0x050000
- u.setQuery(url);
+ urlHelper.addQueryItem("body", body);
}
-#endif
QDesktopServices::openUrl(url);
}
Video* video = playlistModel->videoAt(index.row());
if (!video) return;
- QString channel = video->userId();
- if (channel.isEmpty()) channel = video->author();
- if (channel.isEmpty()) return;
+ QString channelId = video->channelId();
+ // if (channelId.isEmpty()) channelId = video->channelTitle();
+ if (channelId.isEmpty()) return;
SearchParams *searchParams = new SearchParams();
- searchParams->setAuthor(channel);
+ searchParams->setChannelId(channelId);
searchParams->setSortBy(SearchParams::SortByNewest);
// go!
subscribeText = subscribeAction->property("originalText").toString();
subscribeAction->setEnabled(false);
} else if (subscribed) {
- subscribeText = tr("Unsubscribe from %1").arg(video->author());
+ subscribeText = tr("Unsubscribe from %1").arg(video->channelTitle());
subscribeTip = subscribeText;
subscribeAction->setEnabled(true);
} else {
- subscribeText = tr("Subscribe to %1").arg(video->author());
+ subscribeText = tr("Subscribe to %1").arg(video->channelTitle());
subscribeTip = subscribeText;
subscribeAction->setEnabled(true);
}
if (tintedIcon.isNull()) {
QList<QSize> sizes;
sizes << QSize(16, 16);
- tintedIcon = Utils::tintedIcon("bookmark-new", QColor(254, 240, 0), sizes);
+ tintedIcon = IconUtils::tintedIcon("bookmark-new", QColor(254, 240, 0), sizes);
}
subscribeAction->setIcon(tintedIcon);
#else
- subscribeAction->setIcon(Utils::icon("bookmark-remove"));
+ subscribeAction->setIcon(IconUtils::icon("bookmark-remove"));
#endif
} else {
- subscribeAction->setIcon(Utils::icon("bookmark-new"));
+ subscribeAction->setIcon(IconUtils::icon("bookmark-new"));
}
- Utils::setupAction(subscribeAction);
+ IconUtils::setupAction(subscribeAction);
}
void MediaView::toggleSubscription() {
Video *video = playlistModel->activeVideo();
if (!video) return;
- QString userId = video->userId();
+ QString userId = video->channelId();
if (userId.isEmpty()) return;
- bool subscribed = YTUser::isSubscribed(userId);
- if (subscribed) YTUser::unsubscribe(userId);
- else YTUser::subscribe(userId);
+ bool subscribed = YTChannel::isSubscribed(userId);
+ if (subscribed) YTChannel::unsubscribe(userId);
+ else YTChannel::subscribe(userId);
updateSubscriptionAction(video, !subscribed);
}