From 0d243595f7728017ae0f205f8f947ea5c9a3c771 Mon Sep 17 00:00:00 2001 From: Flavio Date: Fri, 23 Aug 2013 17:02:12 +0200 Subject: [PATCH] 2.1.2 stuff --- CHANGES | 4 +++ minitube.pro | 2 +- src/jsfunctions.cpp | 9 ++++++- src/jsfunctions.h | 1 + src/mainwindow.cpp | 9 ++----- src/mediaview.cpp | 24 +++++++++++++++++- src/networkaccess.cpp | 2 +- src/video.cpp | 58 ++++++++++++++++++++++++++++++------------- src/video.h | 12 ++++++++- src/ytfeedreader.cpp | 6 +++++ 10 files changed, 98 insertions(+), 29 deletions(-) diff --git a/CHANGES b/CHANGES index f0f8580..8d9e128 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +2.1.2 +- Downloads only enabled on Creative Commons licensed videos +- Fixed playback of some videos + 2.1.1 - Fixed VEVO videos playback - Fixed Ubuntu skin not being used diff --git a/minitube.pro b/minitube.pro index d0be3cc..532c28a 100644 --- a/minitube.pro +++ b/minitube.pro @@ -1,6 +1,6 @@ CONFIG += release TEMPLATE = app -VERSION = 2.1.1 +VERSION = 2.1.2 DEFINES += APP_VERSION="$$VERSION" APP_NAME = Minitube diff --git a/src/jsfunctions.cpp b/src/jsfunctions.cpp index 5374224..45070f1 100644 --- a/src/jsfunctions.cpp +++ b/src/jsfunctions.cpp @@ -40,7 +40,7 @@ JsFunctions::JsFunctions(QObject *parent) : QObject(parent), engine(0) { else qWarning() << file.errorString() << file.fileName(); QFileInfo info(file); - if (info.lastModified().toTime_t() < QDateTime::currentDateTime().toTime_t() - 86400) + if (info.lastModified().toTime_t() < QDateTime::currentDateTime().toTime_t() - 3600) loadJs(); } else { QFile resFile(QLatin1String(":/") + jsFilename()); @@ -95,9 +95,16 @@ QString JsFunctions::evaluateFunction(const QString &function) { QScriptValue value = engine->evaluate(function); if (value.isUndefined()) qWarning() << "Undefined result for" << function; + if (value.isError()) + qWarning() << "Error in" << function << value.toString(); + return value.toString(); } QString JsFunctions::decryptSignature(const QString &s) { return evaluateFunction("decryptSignature('" + s + "')"); } + +QString JsFunctions::decryptAgeSignature(const QString &s) { + return evaluateFunction("decryptAgeSignature('" + s + "')"); +} diff --git a/src/jsfunctions.h b/src/jsfunctions.h index 0f8ff21..31d7aac 100644 --- a/src/jsfunctions.h +++ b/src/jsfunctions.h @@ -32,6 +32,7 @@ class JsFunctions : public QObject { public: static JsFunctions* instance(); QString decryptSignature(const QString &s); + QString decryptAgeSignature(const QString &s); private slots: void gotJs(QByteArray bytes); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 913da2f..3ae36bd 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -467,11 +467,10 @@ void MainWindow::createActions() { action = new QAction(tr("&Download"), this); action->setStatusTip(tr("Download the current video")); -#ifndef APP_NO_DOWNLOADS action->setShortcut(QKeySequence::Save); -#endif action->setIcon(Utils::icon("document-save")); action->setEnabled(false); + action->setVisible(false); action->setPriority(QAction::LowPriority); connect(action, SIGNAL(triggered()), mediaView, SLOT(downloadVideo())); actions->insert("download", action); @@ -628,11 +627,9 @@ void MainWindow::createMenus() { videoMenu->addAction(webPageAct); videoMenu->addSeparator(); videoMenu->addAction(The::globalActions()->value("subscribe-channel")); -#ifndef APP_NO_DOWNLOADS videoMenu->addSeparator(); videoMenu->addAction(The::globalActions()->value("download")); - // videoMenu->addAction(copyLinkAct); -#endif + videoMenu->addAction(copyLinkAct); // videoMenu->addAction(The::globalActions()->value("snapshot")); QMenu* viewMenu = menuBar()->addMenu(tr("&View")); @@ -683,9 +680,7 @@ void MainWindow::createToolBars() { mainToolBar->addAction(skipAct); mainToolBar->addAction(The::globalActions()->value("related-videos")); -#ifndef APP_NO_DOWNLOADS mainToolBar->addAction(The::globalActions()->value("download")); -#endif bool addFullScreenAct = true; #ifdef Q_WS_MAC diff --git a/src/mediaview.cpp b/src/mediaview.cpp index 1217e30..9f5aafa 100644 --- a/src/mediaview.cpp +++ b/src/mediaview.cpp @@ -145,7 +145,7 @@ void MediaView::initialize() { << The::globalActions()->value("findVideoParts") << The::globalActions()->value("skip") << The::globalActions()->value("previous") - << The::globalActions()->value("download") + // << The::globalActions()->value("download") << The::globalActions()->value("stopafterthis") << The::globalActions()->value("related-videos") << The::globalActions()->value("refine-search") @@ -342,6 +342,10 @@ void MediaView::stop() { foreach (QAction *action, currentVideoActions) action->setEnabled(false); + QAction *a = The::globalActions()->value("download"); + a->setEnabled(false); + a->setVisible(false); + mediaObject->stop(); currentVideoId.clear(); } @@ -390,6 +394,20 @@ void MediaView::activeRowChanged(int row) { The::globalActions()->value("previous")->setEnabled(row > 0); The::globalActions()->value("stopafterthis")->setEnabled(true); The::globalActions()->value("related-videos")->setEnabled(true); + +#ifndef APP_NO_DOWNLOADS + bool enableDownload = video->license() == Video::LicenseCC; +#ifdef APP_ACTIVATION + enableDownload = enableDownload || Activation::instance().isLegacy(); +#endif +#ifdef APP_DOWNLOADS + enableDownload = true; +#endif + QAction *a = The::globalActions()->value("download"); + a->setEnabled(enableDownload); + a->setVisible(enableDownload); +#endif + updateSubscriptionAction(video, YTUser::isSubscribed(video->userId())); foreach (QAction *action, currentVideoActions) @@ -400,6 +418,10 @@ void MediaView::activeRowChanged(int row) { void MediaView::gotStreamUrl(QUrl streamUrl) { if (stopped) return; + if (!streamUrl.isValid()) { + skip(); + return; + } Video *video = static_cast