Here's an update to Minitube 2.4

Follow the README on how to get an API key.

Comments? OKs?

Index: Makefile
===================================================================
RCS file: /cvs/ports/www/minitube/Makefile,v
retrieving revision 1.38
diff -u -p -u -p -r1.38 Makefile
--- Makefile    27 Mar 2015 08:15:03 -0000      1.38
+++ Makefile    12 May 2015 11:15:34 -0000
@@ -2,9 +2,10 @@
 
 COMMENT =      standalone YouTube.com video browser/player
 
-DISTNAME =     minitube-2.3
-
-REVISION =     1
+GH_ACCOUNT =   flaviotordini
+GH_PROJECT =   minitube
+GH_TAGNAME =   2.4
+DISTNAME =     ${GH_PROJECT}-${GH_TAGNAME}
 
 CATEGORIES =   www multimedia
 
@@ -15,8 +16,6 @@ MAINTAINER =  Paul Irofti <pirofti@openbs
 # GPL v3
 PERMIT_PACKAGE_CDROM =         Yes
 
-MASTER_SITES = http://flavio.tordini.org/files/minitube/
-
 MODULES =      x11/qt4
 
 WANTLIB +=     ICE SM X11 Xext Xi Xinerama Xrender c fontconfig
@@ -28,8 +27,6 @@ RUN_DEPENDS = multimedia/gstreamer-0.10/
                multimedia/gstreamer-0.10/plugins-ffmpeg \
                devel/desktop-file-utils \
                x11/gtk+3,-guic
-
-WRKDIST =      ${WRKDIR}/minitube
 
 MAKE_FLAGS =   CXX=${CXX} \
                LINK=${CXX}
Index: distinfo
===================================================================
RCS file: /cvs/ports/www/minitube/distinfo,v
retrieving revision 1.20
diff -u -p -u -p -r1.20 distinfo
--- distinfo    29 Oct 2014 08:18:23 -0000      1.20
+++ distinfo    12 May 2015 11:15:34 -0000
@@ -1,2 +1,2 @@
-SHA256 (minitube-2.3.tar.gz) = f7JOKV3D4vTOQa3R73HHsf71c4NXj0avjicXEMhsIkc=
-SIZE (minitube-2.3.tar.gz) = 955192
+SHA256 (minitube-2.4.tar.gz) = HYpCekEg1iPGiZadkpBL9mv30+2vyw9vnrfyTW2znHs=
+SIZE (minitube-2.4.tar.gz) = 984265
Index: patches/patch-src_datautils_cpp
===================================================================
RCS file: patches/patch-src_datautils_cpp
diff -N patches/patch-src_datautils_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_datautils_cpp     12 May 2015 11:15:34 -0000
@@ -0,0 +1,21 @@
+$OpenBSD$
+
+Be careful about the lifetime of stack variables!
+
+http://blog.aaronballman.com/2011/07/returning-stack-based-values/
+
+https://wiki.qt.io/Qt_project_org_faq#How_can_I_convert_a_QString_to_char.2A_and_vice_versa.3F
+
+--- src/datautils.cpp.orig     Tue May 12 11:27:07 2015
++++ src/datautils.cpp  Tue May 12 11:29:04 2015
+@@ -50,7 +50,9 @@ uint DataUtils::parseIsoPeriod(const QString &isoPerio
+ 
+     uint days = 0, hours = 0, minutes = 0, seconds = 0;
+ 
+-    const char *ptr = isoPeriod.toStdString().c_str();
++    QByteArray ba = isoPeriod.toLocal8Bit();
++    const char *ptr = ba.data();
++
+     while (*ptr) {
+         if(*ptr == 'P' || *ptr == 'T') {
+             ptr++;
Index: patches/patch-src_jsfunctions_cpp
===================================================================
RCS file: patches/patch-src_jsfunctions_cpp
diff -N patches/patch-src_jsfunctions_cpp
--- patches/patch-src_jsfunctions_cpp   17 Dec 2014 10:02:08 -0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,55 +0,0 @@
-$OpenBSD: patch-src_jsfunctions_cpp,v 1.1 2014/12/17 10:02:08 dcoppa Exp $
-
-commit 6ef6d1752c7fac4f1db7ddc283e934acc8a4556b
-Author: Flavio <[email protected]>
-Date:   Thu Nov 13 13:22:36 2014 +0100
-
-Fix VEVO videos
-
---- src/jsfunctions.cpp.orig   Thu Oct 23 05:47:15 2014
-+++ src/jsfunctions.cpp        Wed Dec 17 03:42:47 2014
-@@ -94,7 +94,7 @@ void JsFunctions::errorJs(QNetworkReply *reply) {
-                   << reply->url().toString() << reply->errorString();
- }
- 
--QString JsFunctions::evaluateFunction(const QString &function) {
-+QString JsFunctions::evaluate(const QString &function) {
-     if (!engine) return QString();
-     QScriptValue value = engine->evaluate(function);
-     if (value.isUndefined())
-@@ -106,9 +106,33 @@ QString JsFunctions::evaluateFunction(const QString &f
- }
- 
- QString JsFunctions::decryptSignature(const QString &s) {
--    return evaluateFunction("decryptSignature('" + s + "')");
-+    return evaluate("decryptSignature('" + s + "')");
- }
- 
- QString JsFunctions::decryptAgeSignature(const QString &s) {
--    return evaluateFunction("decryptAgeSignature('" + s + "')");
-+    return evaluate("decryptAgeSignature('" + s + "')");
-+}
-+
-+QString JsFunctions::videoIdRE() {
-+    return evaluate("videoIdRE()");
-+}
-+
-+QString JsFunctions::videoTokenRE() {
-+    return evaluate("videoTokenRE()");
-+}
-+
-+QString JsFunctions::videoInfoFmtMapRE() {
-+    return evaluate("videoInfoFmtMapRE()");
-+}
-+
-+QString JsFunctions::webPageFmtMapRE() {
-+    return evaluate("webPageFmtMapRE()");
-+}
-+
-+QString JsFunctions::jsPlayerRE() {
-+    return evaluate("jsPlayerRE()");
-+}
-+
-+QString JsFunctions::signatureFunctionNameRE() {
-+    return evaluate("signatureFunctionNameRE()");
- }
Index: patches/patch-src_jsfunctions_h
===================================================================
RCS file: patches/patch-src_jsfunctions_h
diff -N patches/patch-src_jsfunctions_h
--- patches/patch-src_jsfunctions_h     17 Dec 2014 10:02:08 -0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,35 +0,0 @@
-$OpenBSD: patch-src_jsfunctions_h,v 1.1 2014/12/17 10:02:08 dcoppa Exp $
-
-commit 6ef6d1752c7fac4f1db7ddc283e934acc8a4556b
-Author: Flavio <[email protected]>
-Date:   Thu Nov 13 13:22:36 2014 +0100
-
-Fix VEVO videos
-
---- src/jsfunctions.h.orig     Thu Oct 23 05:47:15 2014
-+++ src/jsfunctions.h  Wed Dec 17 03:44:28 2014
-@@ -33,7 +33,16 @@ class JsFunctions : public QObject { (public)
-     static JsFunctions* instance();
-     QString decryptSignature(const QString &s);
-     QString decryptAgeSignature(const QString &s);
-+    QString videoIdRE();
-+    QString videoTokenRE();
-+    QString videoInfoFmtMapRE();
-+    QString webPageFmtMapRE();
-+    QString jsPlayerRE();
-+    QString signatureFunctionNameRE();
- 
-+protected:
-+    QString evaluate(const QString &function);
-+
- private slots:
-     void gotJs(QByteArray bytes);
-     void errorJs(QNetworkReply *reply);
-@@ -44,7 +53,6 @@ private slots: (private)
-     static const QString &jsPath();
-     void loadJs();
-     void parseJs(const QString &js);
--    QString evaluateFunction(const QString &function);
- 
-     QScriptEngine *engine;
- };
Index: patches/patch-src_main_cpp
===================================================================
RCS file: patches/patch-src_main_cpp
diff -N patches/patch-src_main_cpp
--- patches/patch-src_main_cpp  17 Dec 2014 10:02:08 -0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,20 +0,0 @@
-$OpenBSD: patch-src_main_cpp,v 1.1 2014/12/17 10:02:08 dcoppa Exp $
-
-commit 96ad9483a14d0b2252fb9eac976d8ed563bb4aca
-Author: Flavio <[email protected]>
-Date:   Thu Nov 13 13:21:53 2014 +0100
-
-Restore wheel scroll setting
-
---- src/main.cpp.orig  Wed Dec 17 03:37:01 2014
-+++ src/main.cpp       Wed Dec 17 03:38:25 2014
-@@ -54,6 +54,9 @@ int main(int argc, char **argv) {
-     app.setOrganizationName(QLatin1String(Constants::ORG_NAME));
-     app.setOrganizationDomain(QLatin1String(Constants::ORG_DOMAIN));
-     app.setAttribute(Qt::AA_DontShowIconsInMenus);
-+#ifndef APP_WIN
-+    app.setWheelScrollLines(1);
-+#endif
- 
- #ifdef APP_EXTRA
-     Extra::appSetup(&app);
Index: patches/patch-src_mainwindow_cpp
===================================================================
RCS file: /cvs/ports/www/minitube/patches/patch-src_mainwindow_cpp,v
retrieving revision 1.3
diff -u -p -u -p -r1.3 patch-src_mainwindow_cpp
--- patches/patch-src_mainwindow_cpp    30 Oct 2014 13:59:44 -0000      1.3
+++ patches/patch-src_mainwindow_cpp    12 May 2015 11:15:34 -0000
@@ -2,9 +2,9 @@ $OpenBSD: patch-src_mainwindow_cpp,v 1.3
 
 Do not use symbolic icons
 
---- src/mainwindow.cpp.orig    Thu Dec 19 00:37:27 2013
-+++ src/mainwindow.cpp Fri Feb  7 16:50:08 2014
-@@ -565,7 +565,7 @@ void MainWindow::createActions() {
+--- src/mainwindow.cpp.orig    Wed Apr  8 11:38:01 2015
++++ src/mainwindow.cpp Mon May 11 20:49:56 2015
+@@ -567,7 +567,7 @@ void MainWindow::createActions() {
      action = new QAction(tr("More..."), this);
      actions->insert("more-region", action);
  
Index: patches/patch-src_video_cpp
===================================================================
RCS file: patches/patch-src_video_cpp
diff -N patches/patch-src_video_cpp
--- patches/patch-src_video_cpp 17 Dec 2014 10:02:08 -0000      1.3
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,198 +0,0 @@
-$OpenBSD: patch-src_video_cpp,v 1.3 2014/12/17 10:02:08 dcoppa Exp $
-
-commit 6ef6d1752c7fac4f1db7ddc283e934acc8a4556b
-Author: Flavio <[email protected]>
-Date:   Thu Nov 13 13:22:36 2014 +0100
-
-Fix VEVO videos
-
---- src/video.cpp.orig Thu Oct 23 05:47:15 2014
-+++ src/video.cpp      Wed Dec 17 03:42:47 2014
-@@ -35,10 +35,10 @@ static const QString jsNameChars = "a-zA-Z0-9\\$_";
- 
- Video::Video() : m_duration(0),
-     m_viewCount(-1),
-+    m_license(LicenseYouTube),
-     definitionCode(0),
-     elIndex(0),
-     ageGate(false),
--    m_license(LicenseYouTube),
-     loadingStreamUrl(false),
-     loadingThumbnail(false)
- { }
-@@ -67,11 +67,8 @@ void Video::setWebpage(QUrl webpage) {
-     m_webpage = webpage;
- 
-     // Get Video ID
--    // youtube-dl line 428
--    // QRegExp 
re("^((?:http://)?(?:\\w+\\.)?youtube\\.com/(?:(?:v/)|(?:(?:watch(?:\\.php)?)?\\?(?:.+&)?v=)))?([0-9A-Za-z_-]+)(?(1).+)?$");
--    QRegExp re("^https?://www\\.youtube\\.com/watch\\?v=([0-9A-Za-z_-]+).*");
--    bool match = re.exactMatch(m_webpage.toString());
--    if (!match) {
-+    QRegExp re(JsFunctions::instance()->videoIdRE());
-+    if (re.indexIn(m_webpage.toString()) == -1) {
-         qWarning() << QString("Cannot get video id for 
%1").arg(m_webpage.toString());
-         // emit errorStreamUrl(QString("Cannot get video id for 
%1").arg(m_webpage.toString()));
-         // loadingStreamUrl = false;
-@@ -163,29 +160,26 @@ void  Video::gotVideoInfo(QByteArray data) {
-     // qDebug() << "videoInfo" << videoInfo;
- 
-     // get video token
--    QRegExp re = QRegExp("^.*&token=([^&]+).*$");
--    bool match = re.exactMatch(videoInfo);
--    // handle regexp failure
--    if (!match) {
--        // qDebug() << "Cannot get token. Trying next el param";
-+    QRegExp videoTokeRE(JsFunctions::instance()->videoTokenRE());
-+    if (videoTokeRE.indexIn(videoInfo) == -1) {
-+        qWarning() << "Cannot get token. Trying next el param" << videoInfo 
<< videoTokeRE.pattern();
-         // Don't panic! We're gonna try another magic "el" param
-         elIndex++;
-         getVideoInfo();
-         return;
-     }
- 
--    QString videoToken = re.cap(1);
-+    QString videoToken = videoTokeRE.cap(1);
-+    // qWarning() << "got token" << videoToken;
-     while (videoToken.contains('%'))
-         videoToken = QByteArray::fromPercentEncoding(videoToken.toLatin1());
-     // qDebug() << "videoToken" << videoToken;
-     this->videoToken = videoToken;
- 
-     // get fmt_url_map
--    re = QRegExp("^.*&url_encoded_fmt_stream_map=([^&]+).*$");
--    match = re.exactMatch(videoInfo);
--    // handle regexp failure
--    if (!match) {
--        // qDebug() << "Cannot get urlMap. Trying next el param";
-+    QRegExp fmtMapRE(JsFunctions::instance()->videoInfoFmtMapRE());
-+    if (fmtMapRE.indexIn(videoInfo) == -1) {
-+        qWarning() << "Cannot get urlMap. Trying next el param";
-         // Don't panic! We're gonna try another magic "el" param
-         elIndex++;
-         getVideoInfo();
-@@ -194,7 +188,8 @@ void  Video::gotVideoInfo(QByteArray data) {
- 
-     // qDebug() << "Got token and urlMap" << elIndex;
- 
--    QString fmtUrlMap = re.cap(1);
-+    QString fmtUrlMap = fmtMapRE.cap(1);
-+    // qWarning() << "got fmtUrlMap" << fmtUrlMap;
-     fmtUrlMap = QByteArray::fromPercentEncoding(fmtUrlMap.toUtf8());
-     parseFmtUrlMap(fmtUrlMap);
- }
-@@ -339,18 +334,16 @@ void Video::scrapeWebPage(QByteArray data) {
-         return;
-     }
- 
--    QRegExp re(".*\"url_encoded_fmt_stream_map\":\\s+\"([^\"]+)\".*");
--    bool match = re.exactMatch(html);
--    // on regexp failure, stop and report error
--    if (!match) {
--        qWarning() << "Error parsing video page";
-+    QRegExp fmtMapRE(JsFunctions::instance()->webPageFmtMapRE());
-+    if (fmtMapRE.indexIn(html) == -1) {
-+        // qWarning() << "Error parsing video page";
-         // emit errorStreamUrl("Error parsing video page");
-         // loadingStreamUrl = false;
-         elIndex++;
-         getVideoInfo();
-         return;
-     }
--    fmtUrlMap = re.cap(1);
-+    fmtUrlMap = fmtMapRE.cap(1);
-     fmtUrlMap.replace("\\u0026", "&");
-     // parseFmtUrlMap(fmtUrlMap, true);
- 
-@@ -367,7 +360,7 @@ void Video::scrapeWebPage(QByteArray data) {
-     }
- #endif
- 
--    QRegExp jsPlayerRe("\"assets\":.+\"js\":\\s*\"([^\"]+)\"");
-+    QRegExp jsPlayerRe(JsFunctions::instance()->jsPlayerRE());
-     if (jsPlayerRe.indexIn(html) != -1) {
-         QString jsPlayerUrl = jsPlayerRe.cap(1);
-         jsPlayerUrl.remove('\\');
-@@ -384,55 +377,15 @@ void Video::scrapeWebPage(QByteArray data) {
-     }
- }
- 
--void Video::gotHeadHeaders(QNetworkReply* reply) {
--    int statusCode = 
reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
--    // qDebug() << "gotHeaders" << statusCode;
--    if (statusCode == 200) {
--        foundVideoUrl(videoToken, definitionCode);
--    } else {
--
--        // try next (lower quality) definition
--        /*
--        QStringList definitionNames = VideoDefinition::getDefinitionNames();
--        int currentIndex = definitionNames.indexOf(currentDefinition);
--        int previousIndex = 0;
--        if (currentIndex > 0) {
--            previousIndex = currentIndex - 1;
--        }
--        if (previousIndex > 0) {
--            QString nextDefinitionName = definitionNames.at(previousIndex);
--            findVideoUrl(nextDefinitionName);
--        } else {
--            foundVideoUrl(videoToken, 18);
--        }*/
--
--
--        QList<int> definitionCodes = VideoDefinition::getDefinitionCodes();
--        int currentIndex = definitionCodes.indexOf(definitionCode);
--        int previousIndex = 0;
--        if (currentIndex > 0) {
--            previousIndex = currentIndex - 1;
--            int definitionCode = definitionCodes.at(previousIndex);
--            if (definitionCode == 18) {
--                // This is assumed always available
--                foundVideoUrl(videoToken, 18);
--            } else {
--                findVideoUrl(definitionCode);
--            }
--
--        } else {
--            foundVideoUrl(videoToken, 18);
--        }
--
--    }
--}
--
- void Video::parseJsPlayer(QByteArray bytes) {
-     QString js = QString::fromUtf8(bytes);
-     // qWarning() << "jsPlayer" << js;
--    QRegExp funcNameRe("signature=([" + jsNameChars + "]+)");
-+
-+    // QRegExp funcNameRe("\"signature\"\\w*,\\w*([" + jsNameChars + "]+)");
-+    QRegExp 
funcNameRe(JsFunctions::instance()->signatureFunctionNameRE().arg(jsNameChars));
-+
-     if (funcNameRe.indexIn(js) == -1) {
--        qWarning() << "Cannot capture signature function name";
-+        qWarning() << "Cannot capture signature function name" << js;
-     } else {
-         sigFuncName = funcNameRe.cap(1);
-         captureFunction(sigFuncName, js);
-@@ -546,20 +499,6 @@ QString Video::decryptSignature(const QString &s) {
-         return QString();
-     }
-     return value.toString();
--}
--
--void Video::findVideoUrl(int definitionCode) {
--    this->definitionCode = definitionCode;
--
--    QUrl videoUrl = QUrl(QString(
--                             
"http://www.youtube.com/get_video?video_id=%1&t=%2&eurl=&el=&ps=&asv=&fmt=%3";
--                             ).arg(videoId, videoToken, 
QString::number(definitionCode)));
--
--    QObject *reply = The::http()->head(videoUrl);
--    connect(reply, SIGNAL(finished(QNetworkReply*)), 
SLOT(gotHeadHeaders(QNetworkReply*)));
--    // connect(reply, SIGNAL(error(QNetworkReply*)), 
SLOT(errorVideoInfo(QNetworkReply*)));
--
--    // see you in gotHeadHeaders()
- }
- 
- QString Video::formattedDuration() const {
Index: patches/patch-src_video_h
===================================================================
RCS file: patches/patch-src_video_h
diff -N patches/patch-src_video_h
--- patches/patch-src_video_h   17 Dec 2014 10:02:08 -0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,24 +0,0 @@
-$OpenBSD: patch-src_video_h,v 1.1 2014/12/17 10:02:08 dcoppa Exp $
-
-commit 6ef6d1752c7fac4f1db7ddc283e934acc8a4556b
-Author: Flavio <[email protected]>
-Date:   Thu Nov 13 13:22:36 2014 +0100
-
-Fix VEVO videos
-
---- src/video.h.orig   Thu Oct 23 05:47:15 2014
-+++ src/video.h        Wed Dec 17 03:42:47 2014
-@@ -97,13 +97,11 @@ private slots:
-     void gotVideoInfo(QByteArray);
-     void errorVideoInfo(QNetworkReply*);
-     void scrapeWebPage(QByteArray);
--    void gotHeadHeaders(QNetworkReply*);
-     void parseJsPlayer(QByteArray bytes);
-     void parseDashManifest(QByteArray bytes);
- 
- private:
-     void getVideoInfo();
--    void findVideoUrl(int definitionCode);
-     void foundVideoUrl(QString videoToken, int definitionCode);
-     void parseFmtUrlMap(const QString &fmtUrlMap, bool fromWebPage = false);
-     void captureFunction(const QString &name, const QString &js);
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/www/minitube/pkg/PLIST,v
retrieving revision 1.20
diff -u -p -u -p -r1.20 PLIST
--- pkg/PLIST   29 Oct 2014 08:18:23 -0000      1.20
+++ pkg/PLIST   12 May 2015 11:15:34 -0000
@@ -1,14 +1,13 @@
 @comment $OpenBSD: PLIST,v 1.20 2014/10/29 08:18:23 dcoppa Exp $
 @bin bin/minitube
 share/applications/minitube.desktop
+share/doc/pkg-readmes/${FULLPKGNAME}
 share/icons/hicolor/128x128/apps/minitube.png
 share/icons/hicolor/16x16/apps/minitube.png
 share/icons/hicolor/22x22/apps/minitube.png
 share/icons/hicolor/256x256/apps/minitube.png
 share/icons/hicolor/32x32/apps/minitube.png
 share/icons/hicolor/48x48/apps/minitube.png
-share/icons/hicolor/512x512/
-share/icons/hicolor/512x512/apps/
 share/icons/hicolor/512x512/apps/minitube.png
 share/icons/hicolor/64x64/apps/minitube.png
 share/icons/hicolor/scalable/apps/minitube.svg
Index: pkg/README
===================================================================
RCS file: pkg/README
diff -N pkg/README
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ pkg/README  12 May 2015 11:15:34 -0000
@@ -0,0 +1,41 @@
+$OpenBSD$
+
++-----------------------------------------------------------------------
+| Running ${FULLPKGNAME} on OpenBSD
++-----------------------------------------------------------------------
+
+Minitube 2.4 has been ported to the new YouTube API version 3, hence an
+API key is now required in order to access the YouTube Data web services.
+
+Go to https://console.developers.google.com/
+
+Log in using your Google account
+
+Click on "Create Project"
+
+Enter a Project name (e.g.: "Minitube")
+
+On the left side bar, expand the "APIs & auth" drop-down menu and
+click on "Credentials"
+
+Click on "Create new Key" and then on "Browser key"
+
+Click on "Create"
+
+You should get an output like the one below:
+
+Key for browser applications
+  API key                      AIzaSyD7zlL9sAC6-IcwU7Bpds8lZNzmqQTmALQ
+  Referers                     Any referer allowed
+  Activation date              Apr 28, 2015, 2:02:00 AM
+  Activated by                 [email protected] (you)
+
+Be sure that "YouTube Data API v3" is enabled under "APIs & auth" ->
+"APIs" -> "Enabled APIs"
+
+Add the environment variable containing your newly generated key
+to your ~/.profile or ~/.xinitrc:
+
+GOOGLE_API_KEY="AIzaSyD7zlL9sAC6-IcwU7Bpds8lZNzmqQTmALQ"
+export GOOGLE_API_KEY
+

Reply via email to