Remove “Upload to YouTube” functionality which has been broken for years
authorWuzzy <Wuzzy2@mail.ru>
Sat, 17 Mar 2018 02:16:16 +0100
changeset 13237 2a3c52c49e8e
parent 13236 6193503c4727
child 13238 bb73d6d3348a
Remove “Upload to YouTube” functionality which has been broken for years
ChangeLog.txt
QTfrontend/ui/dialog/upload_video.cpp
QTfrontend/ui/dialog/upload_video.h
QTfrontend/ui/page/pagevideos.cpp
QTfrontend/ui/page/pagevideos.h
--- a/ChangeLog.txt	Sat Mar 17 00:13:49 2018 +0100
+++ b/ChangeLog.txt	Sat Mar 17 02:16:16 2018 +0100
@@ -23,6 +23,7 @@
  + Schemes are now stored in separate files under Schemes
  + Add default directory DrawnMaps for hand-drawn maps
  + Lead player to training missions when starting Hedgewars the first time
+ * Remove “Upload to YouTube” functionality (it was broken for years)
  * Fix broken preview of team hats (e.g. cap_team)
  * Fix chart in stats screen not supporting negative numbers
 
--- a/QTfrontend/ui/dialog/upload_video.cpp	Sat Mar 17 00:13:49 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,312 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <QLineEdit>
-#include <QDialogButtonBox>
-#include <QPushButton>
-#include <QGridLayout>
-#include <QCheckBox>
-#include <QLabel>
-#include <QFrame>
-#include <QPlainTextEdit>
-#include <QSslError>
-#include <QUrl>
-#include <QNetworkAccessManager>
-#include <QNetworkRequest>
-#include <QNetworkReply>
-#include <QMessageBox>
-#include <QRegExp>
-#include <QRegExpValidator>
-
-#include "upload_video.h"
-#include "hwconsts.h"
-
-// User-agent string used in http requests.
-// Don't make it a global varibale - crash on linux because of cVersionString
-#define USER_AGENT ("Hedgewars-QtFrontend/" + *cVersionString).toLatin1()
-
-// This is developer key obtained from http://code.google.com/apis/youtube/dashboard/
-// If you are reusing this code outside Hedgewars, don't use this developer key,
-// obtain you own at http://code.google.com/apis/youtube/dashboard/
-static const QByteArray devKey = "AI39si5pKjxR0XgNIlmrEFF-LyYD31rps4g2O5dZTxLgD0fvJ2rHxrMrNFY8FYTZrzeI3VlaFVQLKfFnSBugvdZmy8vFzRDefQ";
-
-HWUploadVideoDialog::HWUploadVideoDialog(QWidget* parent, const QString &filename, QNetworkAccessManager* netManager) : QDialog(parent)
-{
-    this->filename = filename;
-    this->netManager = netManager;
-
-    setWindowTitle(tr("Upload video"));
-
-    // Google requires us to display this, see https://developers.google.com/youtube/terms
-    QString GoogleNotice =
-        "<p>By clicking 'upload,' you certify that you own all rights to the content or that "
-        "you are authorized by the owner to make the content publicly available on YouTube, "
-        "and that it otherwise complies with the YouTube Terms of Service located at "
-        "<a href=\"https://www.youtube.com/t/terms\" style=\"color: white;\">https://www.youtube.com/t/terms</a>.</p>";
-
-    // youtube doesn't understand this characters, even when they are properly escaped
-    // (either with CDATA or with &lt or &gt)
-    QRegExp rx("[^<>]*");
-
-    int row = 0;
-
-    QGridLayout * layout = new QGridLayout(this);
-    layout->setColumnStretch(0, 1);
-    layout->setColumnStretch(1, 2);
-
-    QLabel * lbLabel = new QLabel(this);
-    lbLabel->setWordWrap(true);
-    lbLabel->setText(QLabel::tr(
-                         "Please provide either the YouTube account name "
-                         "or the email address associated with the Google Account."));
-    layout->addWidget(lbLabel, row++, 0, 1, 2);
-
-    lbLabel = new QLabel(this);
-    lbLabel->setText(QLabel::tr("Account name (or email): "));
-    layout->addWidget(lbLabel, row, 0);
-
-    leAccount = new QLineEdit(this);
-    layout->addWidget(leAccount, row++, 1);
-
-    lbLabel = new QLabel(this);
-    lbLabel->setText(QLabel::tr("Password: "));
-    layout->addWidget(lbLabel, row, 0);
-
-    lePassword = new QLineEdit(this);
-    lePassword->setEchoMode(QLineEdit::Password);
-    layout->addWidget(lePassword, row++, 1);
-
-    cbSave = new QCheckBox(this);
-    cbSave->setText(QCheckBox::tr("Save account name and password"));
-    layout->addWidget(cbSave, row++, 0, 1, 2);
-
-    QFrame * hr = new QFrame(this);
-    hr->setFrameStyle(QFrame::HLine);
-    hr->setLineWidth(3);
-    hr->setFixedHeight(10);
-    layout->addWidget(hr, row++, 0, 1, 2);
-
-    lbLabel = new QLabel(this);
-    lbLabel->setText(QLabel::tr("Video title: "));
-    layout->addWidget(lbLabel, row, 0);
-
-    leTitle = new QLineEdit(this);
-    leTitle->setText(filename);
-    leTitle->setValidator(new QRegExpValidator(rx, leTitle));
-    layout->addWidget(leTitle, row++, 1);
-
-    lbLabel = new QLabel(this);
-    lbLabel->setText(QLabel::tr("Video description: "));
-    layout->addWidget(lbLabel, row++, 0, 1, 2);
-
-    teDescription = new QPlainTextEdit(this);
-    layout->addWidget(teDescription, row++, 0, 1, 2);
-
-    lbLabel = new QLabel(this);
-    lbLabel->setText(QLabel::tr("Tags (comma separated): "));
-    layout->addWidget(lbLabel, row, 0);
-
-    leTags = new QLineEdit(this);
-    leTags->setText("hedgewars");
-    leTags->setMaxLength(500);
-    leTags->setValidator(new QRegExpValidator(rx, leTags));
-    layout->addWidget(leTags, row++, 1);
-
-    cbPrivate = new QCheckBox(this);
-    cbPrivate->setText(QCheckBox::tr("Video is private"));
-    layout->addWidget(cbPrivate, row++, 0, 1, 2);
-
-    hr = new QFrame(this);
-        hr->setFrameStyle(QFrame::HLine);
-        hr->setLineWidth(3);
-        hr->setFixedHeight(10);
-        layout->addWidget(hr, row++, 0, 1, 2);
-
-    lbLabel = new QLabel(this);
-    lbLabel->setWordWrap(true);
-    lbLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
-    lbLabel->setTextFormat(Qt::RichText);
-    lbLabel->setOpenExternalLinks(true);
-    lbLabel->setText(GoogleNotice);
-    layout->addWidget(lbLabel, row++, 0, 1, 2);
-
-    QDialogButtonBox* dbbButtons = new QDialogButtonBox(this);
-    btnUpload = dbbButtons->addButton(tr("Upload"), QDialogButtonBox::ActionRole);
-    QPushButton * pbCancel = dbbButtons->addButton(QDialogButtonBox::Cancel);
-    layout->addWidget(dbbButtons, row++, 0, 1, 2);
-
-   /* hr = new QFrame(this);
-        hr->setFrameStyle(QFrame::HLine);
-        hr->setLineWidth(3);
-        hr->setFixedHeight(10);
-        layout->addWidget(hr, row++, 0, 1, 2);*/
-
-    connect(btnUpload, SIGNAL(clicked()), this, SLOT(upload()));
-    connect(pbCancel, SIGNAL(clicked()), this, SLOT(reject()));
-
-    this->setWindowModality(Qt::WindowModal);
-}
-
-void HWUploadVideoDialog::showEvent(QShowEvent * event)
-{
-    QDialog::showEvent(event);
-
-    // set width to the same value as height (otherwise dialog has too small width)
-    QSize s = size();
-    QPoint p = pos();
-    resize(s.height(), s.height());
-    move(p.x() - (s.height() - s.width())/2, p.y());
-}
-
-void HWUploadVideoDialog::setEditable(bool editable)
-{
-    leTitle->setEnabled(editable);
-    leAccount->setEnabled(editable);
-    lePassword->setEnabled(editable);
-    btnUpload->setEnabled(editable);
-}
-
-void HWUploadVideoDialog::upload()
-{
-    setEditable(false);
-
-    // Documentation is at https://developers.google.com/youtube/2.0/developers_guide_protocol_clientlogin#ClientLogin_Authentication
-    QNetworkRequest request;
-    request.setUrl(QUrl("https://www.google.com/accounts/ClientLogin"));
-    request.setRawHeader("User-Agent", USER_AGENT);
-    request.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
-
-    QString account(QUrl::toPercentEncoding(leAccount->text()));
-    QString pass(QUrl::toPercentEncoding(lePassword->text()));
-    QByteArray data = QString("Email=%1&Passwd=%2&service=youtube&source=Hedgewars").arg(account).arg(pass).toUtf8();
-
-    QNetworkReply *reply = netManager->post(request, data);
-    connect(reply, SIGNAL(finished()), this, SLOT(authFinished()));
-}
-
-static QString XmlEscape(const QString& str)
-{
-    QString str2 = str;
-    // youtube doesn't understand this characters, even when they are properly escaped
-    // (either with CDATA or with &lt; &gt;)
-    str2.replace('<', ' ').replace('>', ' ');
-    return "<![CDATA[" + str2.replace("]]>", "]]]]><![CDATA[>") + "]]>";
-}
-
-void HWUploadVideoDialog::authFinished()
-{
-    QNetworkReply *reply = (QNetworkReply*)sender();
-    reply->deleteLater();
-
-    int HttpCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
-
-    QByteArray answer = reply->readAll();
-    QString authToken = "";
-    QList<QByteArray> lines = answer.split('\n');
-    foreach (const QByteArray& line, lines)
-    {
-        QString str(line);
-        if (!str.startsWith("Auth=", Qt::CaseInsensitive))
-            continue;
-        str.remove(0, 5);
-        authToken = str;
-        break;
-    }
-    if (authToken.isEmpty())
-    {
-        QString errorStr = QMessageBox::tr("Error while authenticating at google.com:\n");
-        if (HttpCode == 403)
-            errorStr += QMessageBox::tr("Login or password is incorrect");
-        else
-            errorStr += reply->errorString();
-
-        QMessageBox deniedMsg(this);
-        deniedMsg.setIcon(QMessageBox::Warning);
-        deniedMsg.setWindowTitle(QMessageBox::tr("Video upload - Error"));
-        deniedMsg.setText(errorStr);
-        deniedMsg.setWindowModality(Qt::WindowModal);
-        deniedMsg.exec();
-
-        setEditable(true);
-        return;
-    }
-
-    QByteArray auth = ("GoogleLogin auth=" + authToken).toLatin1();
-
-    // We have authenticated, now we can send metadata and start upload
-    // Documentation is here: https://developers.google.com/youtube/2.0/developers_guide_protocol_resumable_uploads#Resumable_uploads
-    QByteArray body =
-            "<?xml version=\"1.0\"?>"
-            "<entry xmlns=\"http://www.w3.org/2005/Atom\" "
-                "xmlns:media=\"http://search.yahoo.com/mrss/\" "
-                "xmlns:yt=\"http://gdata.youtube.com/schemas/2007\">"
-                "<media:group>"
-                  //  "<yt:incomplete/>"
-                    "<media:category "
-                        "scheme=\"http://gdata.youtube.com/schemas/2007/categories.cat\">Games"
-                    "</media:category>"
-                    "<media:title type=\"plain\">"
-                        + XmlEscape(leTitle->text()).toUtf8() +
-                    "</media:title>"
-                    "<media:description type=\"plain\">"
-                        + XmlEscape(teDescription->toPlainText()).toUtf8() +
-                    "</media:description>"
-                    "<media:keywords type=\"plain\">"
-                        + XmlEscape(leTags->text()).toUtf8() +
-                    "</media:keywords>"
-                    + (cbPrivate->isChecked()? "<yt:private/>" : "") +
-                "</media:group>"
-            "</entry>";
-
-    QNetworkRequest request;
-    request.setUrl(QUrl("http://uploads.gdata.youtube.com/resumable/feeds/api/users/default/uploads"));
-    request.setRawHeader("User-Agent", USER_AGENT);
-    request.setRawHeader("Authorization", auth);
-    request.setRawHeader("GData-Version", "2");
-    request.setRawHeader("X-GData-Key", "key=" + devKey);
-    request.setRawHeader("Slug", filename.toUtf8());
-    request.setRawHeader("Content-Type", "application/atom+xml; charset=UTF-8");
-
-    reply = netManager->post(request, body);
-    connect(reply, SIGNAL(finished()), this, SLOT(startUpload()));
-}
-
-void HWUploadVideoDialog::startUpload()
-{
-    QNetworkReply *reply = (QNetworkReply*)sender();
-    reply->deleteLater();
-
-    location = QString::fromLatin1(reply->rawHeader("Location"));
-    if (location.isEmpty())
-    {
-        QString errorStr = QMessageBox::tr("Error while sending metadata to youtube.com:\n");
-        errorStr += reply->errorString();
-
-        QMessageBox deniedMsg(this);
-        deniedMsg.setIcon(QMessageBox::Warning);
-        deniedMsg.setWindowTitle(QMessageBox::tr("Video upload - Error"));
-        deniedMsg.setText(errorStr);
-        deniedMsg.setWindowModality(Qt::WindowModal);
-        deniedMsg.exec();
-
-        setEditable(true);
-        return;
-    }
-
-    accept();
-}
--- a/QTfrontend/ui/dialog/upload_video.h	Sat Mar 17 00:13:49 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef UPLOAD_VIDEO_H
-#define UPLOAD_VIDEO_H
-
-#include <QDialog>
-
-class QLineEdit;
-class QCheckBox;
-class QPlainTextEdit;
-class QLabel;
-class QNetworkAccessManager;
-
-class HWUploadVideoDialog : public QDialog
-{
-        Q_OBJECT
-    public:
-    HWUploadVideoDialog(QWidget* parent, const QString& filename, QNetworkAccessManager* netManager);
-
-        QLineEdit* leAccount;
-        QLineEdit* lePassword;
-        QCheckBox* cbSave;
-
-        QLineEdit* leTitle;
-        QPlainTextEdit* teDescription;
-        QLineEdit* leTags;
-        QCheckBox* cbPrivate;
-
-        QPushButton* btnUpload;
-
-        QString location;
-
-    private:
-        QNetworkAccessManager* netManager;
-        QString filename;
-
-        void setEditable(bool editable);
-
-    protected:
-        // virtual from QWidget
-        void showEvent(QShowEvent * event);
-
-    private slots:
-        void upload();
-        void authFinished();
-        void startUpload();
-};
-
-#endif // UPLOAD_VIDEO_H
--- a/QTfrontend/ui/page/pagevideos.cpp	Sat Mar 17 00:13:49 2018 +0100
+++ b/QTfrontend/ui/page/pagevideos.cpp	Sat Mar 17 02:16:16 2018 +0100
@@ -39,9 +39,6 @@
 #include <QFileSystemWatcher>
 #include <QDateTime>
 #include <QRegExp>
-#include <QNetworkAccessManager>
-#include <QNetworkRequest>
-#include <QNetworkReply>
 #include <QXmlStreamReader>
 
 #include "hwconsts.h"
@@ -51,7 +48,6 @@
 #include "gameuiconfig.h"
 #include "recorder.h"
 #include "ask_quit.h"
-#include "upload_video.h"
 
 static const QSize ThumbnailSize(350, 350*3/5);
 
@@ -60,7 +56,7 @@
 {
     vcName,
     vcSize,
-    vcProgress, // either encoding or uploading
+    vcProgress, // for encoding
 
     vcNumColumns,
 };
@@ -77,9 +73,7 @@
         QString name;
         QString prefix; // original filename without extension
         QString desc;   // description (duration, resolution, etc...)
-        QString uploadUrl; // https://youtu.be/???????
         HWRecorder    * pRecorder; // non NULL if file is being encoded
-        QNetworkReply * pUploading; // non NULL if file is being uploaded
         bool seen; // used when updating directory
         float lastSizeUpdate;
         float progress;
@@ -96,7 +90,6 @@
 {
     this->name = name;
     pRecorder = NULL;
-    pUploading = NULL;
     lastSizeUpdate = 0;
     progress = 0;
     seen = false;
@@ -180,8 +173,6 @@
         labelDesc->setTextFormat(Qt::RichText);
         labelDesc->setWordWrap(true);
         labelDesc->setOpenExternalLinks(true);
-        //labelDesc->setMinimumSize(ThumbnailSize);
-        //pTopDescLayout->addWidget(labelDesc, 1);
 
         // buttons: play and delete
         btnPlay = new QPushButton(QPushButton::tr("Play"), pDescGroup);
@@ -192,10 +183,6 @@
         btnDelete->setEnabled(false);
         btnDelete->setWhatsThis(QPushButton::tr("Delete this video"));
         pBottomDescLayout->addWidget(btnDelete);
-        btnToYouTube = new QPushButton(QPushButton::tr("Upload to YouTube"), pDescGroup);
-        btnToYouTube->setEnabled(false);
-        btnToYouTube->setWhatsThis(QPushButton::tr("Upload this video to your YouTube account"));
-        pBottomDescLayout->addWidget(btnToYouTube);
 
         pDescLayout->addWidget(labelThumbnail, 0);
         pDescLayout->addWidget(labelDesc, 0);
@@ -220,16 +207,14 @@
     connect(filesTable, SIGNAL(currentCellChanged(int,int,int,int)), this, SLOT(currentCellChanged()));
     connect(btnPlay,   SIGNAL(clicked()), this, SLOT(playSelectedFile()));
     connect(btnDelete, SIGNAL(clicked()), this, SLOT(deleteSelectedFiles()));
-    connect(btnToYouTube, SIGNAL(clicked()), this, SLOT(uploadToYouTube()));
     connect(btnOpenDir, SIGNAL(clicked()), this, SLOT(openVideosDirectory()));
 }
 
 PageVideos::PageVideos(QWidget* parent) : AbstractPage(parent),
-    config(0), netManager(0)
+    config(0)
 {
     nameChangedFromCode = false;
     numRecorders = 0;
-    numUploads = 0;
     initPage();
 }
 
@@ -491,15 +476,12 @@
         clearThumbnail();
         btnPlay->setEnabled(false);
         btnDelete->setEnabled(false);
-        btnToYouTube->setEnabled(false);
         return;
     }
 
     btnPlay->setEnabled(item->ready());
-    btnToYouTube->setEnabled(item->ready());
     btnDelete->setEnabled(true);
     btnDelete->setText(item->ready()? QPushButton::tr("Delete") :  QPushButton::tr("Cancel"));
-    btnToYouTube->setText(item->pUploading? QPushButton::tr("Cancel uploading") :  QPushButton::tr("Upload to YouTube"));
 
     // construct string with desctiption of this file to display it
     QString desc = item->name + "\n\n";
@@ -543,21 +525,6 @@
             item->prefix.truncate(pt);
     }
 
-    if (item->ready() && item->uploadUrl.isEmpty())
-    {
-        // try to load url from file
-        QFile * file = new QFile(cfgdir->absoluteFilePath("VideoTemp/" + item->prefix + "-url.txt"), this);
-        if (!file->open(QIODevice::ReadOnly))
-            item->uploadUrl = "no";
-        else
-        {
-            QByteArray data = file->readAll();
-            file->close();
-            item->uploadUrl = QString::fromUtf8(data.data());
-        }
-    }
-    if (item->uploadUrl != "no")
-        desc += QString("<a href=\"%1\" style=\"color: white;\">%1</a>").arg(item->uploadUrl);
     desc.replace("\n", "<br/>");
 
     labelDesc->setText(desc);
@@ -688,14 +655,14 @@
     QDesktopServices::openUrl(QUrl("file:///" + path));
 }
 
-// clear VideoTemp directory (except for thumbnails and upload links)
+// clear VideoTemp directory (except for thumbnails)
 void PageVideos::clearTemp()
 {
     QDir temp(cfgdir->absolutePath() + "/VideoTemp");
     QStringList files = temp.entryList(QDir::Files);
     foreach (const QString& file, files)
     {
-        if (!file.endsWith(".bmp") && !file.endsWith(".png") && !file.endsWith("-url.txt"))
+        if (!file.endsWith(".bmp") && !file.endsWith(".png"))
             temp.remove(file);
     }
 }
@@ -703,7 +670,7 @@
 bool PageVideos::tryQuit(HWForm * form)
 {
     bool quit = true;
-    if (numRecorders != 0 || numUploads != 0)
+    if (numRecorders != 0)
     {
         // ask user what to do - abort or wait
         HWAskQuitDialog * askd = new HWAskQuitDialog(this, form);
@@ -718,7 +685,6 @@
 // returns multi-line string with list of videos in progress
 /* it will look like this:
 foo.avi (15.21% - encoding)
-bar.avi (18.21% - uploading)
 */
 QString PageVideos::getVideosInProgress()
 {
@@ -730,8 +696,6 @@
         QString process;
         if (!item->ready())
             process = tr("encoding");
-        else if (item->pUploading)
-            process = tr("uploading");
         else
             continue;
         float progress = 100*item->progress;
@@ -771,168 +735,3 @@
     }
 }
 
-VideoItem * PageVideos::itemFromReply(QNetworkReply* reply, int & row)
-{
-    VideoItem * item = NULL;
-    int count = filesTable->rowCount();
-    // find corresponding item (maybe there is a better way to implement this?)
-    for (int i = 0; i < count; i++)
-    {
-        item = nameItem(i);
-        if (item->pUploading == reply)
-        {
-            row = i;
-            break;
-        }
-    }
-    return item;
-}
-
-void PageVideos::uploadProgress(qint64 bytesSent, qint64 bytesTotal)
-{
-    QNetworkReply* reply = (QNetworkReply*)sender();
-    int row;
-    VideoItem * item = itemFromReply(reply, row);
-    setProgress(row, item, bytesSent*1.0/bytesTotal);
-}
-
-void PageVideos::uploadFinished()
-{
-    QNetworkReply* reply = (QNetworkReply*)sender();
-    reply->deleteLater();
-
-    int row;
-    VideoItem * item = itemFromReply(reply, row);
-    if (!item)
-        return;
-
-    item->pUploading = NULL;
-
-    // extract video id from reply
-    QString videoid;
-    QXmlStreamReader xml(reply);
-    while (!xml.atEnd())
-    {
-        xml.readNext();
-        if (xml.qualifiedName() == "yt:videoid")
-        {
-            videoid = xml.readElementText();
-            break;
-        }
-    }
-
-    if (!videoid.isEmpty())
-    {
-        item->uploadUrl = "https://youtu.be/" + videoid;
-        updateDescription();
-
-        // save url in file
-        QFile * file = new QFile(cfgdir->absoluteFilePath("VideoTemp/" + item->prefix + "-url.txt"), this);
-        if (file->open(QIODevice::WriteOnly))
-        {
-            file->write(item->uploadUrl.toUtf8());
-            file->close();
-        }
-    }
-
-    filesTable->setCellWidget(row, vcProgress, NULL); // remove progress bar
-    numUploads--;
-}
-
-// this will protect saved youtube password from those who cannot read source code
-static QString protectPass(QString str)
-{
-    QByteArray array = str.toUtf8();
-    for (int i = 0; i < array.size(); i++)
-        array[i] = array[i] ^ 0xC4 ^ i;
-    array = array.toBase64();
-    return QString::fromLatin1(array.data());
-}
-
-static QString unprotectPass(QString str)
-{
-    QByteArray array = QByteArray::fromBase64(str.toLatin1());
-    for (int i = 0; i < array.size(); i++)
-        array[i] = array[i] ^ 0xC4 ^ i;
-    return QString::fromUtf8(array);
-}
-
-void PageVideos::uploadToYouTube()
-{
-    int row = filesTable->currentRow();
-    VideoItem * item = nameItem(row);
-
-    if (item->pUploading) //Act as 'cancel uploading' button
-    {
-        // ask user if (s)he is serious
-        QMessageBox reallyStopMsg(this);
-        reallyStopMsg.setIcon(QMessageBox::Question);
-        reallyStopMsg.setWindowTitle(QMessageBox::tr("Videos - Are you sure?"));
-        reallyStopMsg.setText(QMessageBox::tr("Do you really want to cancel uploading %1?").arg(item->name));
-        reallyStopMsg.setWindowModality(Qt::WindowModal);
-        reallyStopMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
-
-        if (reallyStopMsg.exec() != QMessageBox::Ok)
-            return;
-        item->pUploading->abort();
-        btnToYouTube->setText(QPushButton::tr("Upload to YouTube"));
-        filesTable->setCellWidget(row, vcProgress, NULL); // remove progress bar
-        //numUploads--;
-        return;
-    }
-
-    if (!netManager)
-        netManager = new QNetworkAccessManager(this);
-
-    HWUploadVideoDialog* dlg = new HWUploadVideoDialog(this, item->name, netManager);
-    dlg->deleteLater();
-    if (config->value("youtube/save").toBool())
-    {
-        dlg->cbSave->setChecked(true);
-        dlg->leAccount->setText(config->value("youtube/name").toString());
-        dlg->lePassword->setText(unprotectPass(config->value("youtube/pswd").toString()));
-    }
-
-    bool result = dlg->exec();
-
-    if (dlg->cbSave->isChecked())
-    {
-        config->setValue("youtube/save", true);
-        config->setValue("youtube/name", dlg->leAccount->text());
-        config->setValue("youtube/pswd", protectPass(dlg->lePassword->text()));
-    }
-    else
-    {
-        config->setValue("youtube/save", false);
-        config->setValue("youtube/name", "");
-        config->setValue("youtube/pswd", "");
-    }
-
-    if (!result)
-        return;
-
-    QNetworkRequest request(QUrl(dlg->location));
-    request.setRawHeader("Content-Type", "application/octet-stream");
-
-    QFile * file = new QFile(item->path(), this);
-    if (!file->open(QIODevice::ReadOnly))
-        return;
-
-    // add progress bar
-    QProgressBar * progressBar = new QProgressBar(filesTable);
-    progressBar->setMinimum(0);
-    progressBar->setMaximum(10000);
-    progressBar->setValue(0);
-    // make it different from progress-bar used during encoding (use blue color)
-    progressBar->setStyleSheet("* {color: #00ccff; selection-background-color: #00ccff;}" );
-    filesTable->setCellWidget(row, vcProgress, progressBar);
-
-    QNetworkReply* reply = netManager->put(request, file);
-    file->setParent(reply); // automatically close file when needed
-    item->pUploading = reply;
-    connect(reply, SIGNAL(uploadProgress(qint64, qint64)), this, SLOT(uploadProgress(qint64, qint64)));
-    connect(reply, SIGNAL(finished()), this, SLOT(uploadFinished()));
-    numUploads++;
-
-    updateDescription();
-}
--- a/QTfrontend/ui/page/pagevideos.h	Sat Mar 17 00:13:49 2018 +0100
+++ b/QTfrontend/ui/page/pagevideos.h	Sat Mar 17 02:16:16 2018 +0100
@@ -22,8 +22,6 @@
 
 #include "AbstractPage.h"
 
-class QNetworkAccessManager;
-class QNetworkReply;
 class GameUIConfig;
 class HWRecorder;
 class VideoItem;
@@ -60,17 +58,15 @@
         void clearTemp();
         void clearThumbnail();
         void setProgress(int row, VideoItem* item, float value);
-        VideoItem * itemFromReply(QNetworkReply* reply, int & row);
 
         GameUIConfig * config;
-        QNetworkAccessManager* netManager;
 
         // file list group
         QTableWidget *filesTable;
         QPushButton *btnOpenDir;
 
         // description group
-        QPushButton *btnPlay, *btnDelete, *btnToYouTube;
+        QPushButton *btnPlay, *btnDelete;
         QLabel *labelDesc;
         QLabel *labelThumbnail;
 
@@ -78,7 +74,7 @@
         // (in signal cellChanged)
         bool nameChangedFromCode;
 
-        int numRecorders, numUploads;
+        int numRecorders;
 
     private slots:
         void encodingFinished(bool success);
@@ -90,9 +86,6 @@
         void deleteSelectedFiles();
         void openVideosDirectory();
         void updateFileList(const QString & path);
-        void uploadToYouTube();
-        void uploadProgress(qint64 bytesSent, qint64 bytesTotal);
-        void uploadFinished();
 };
 
 #endif // PAGE_VIDEOS_H