Commit 795e31de authored by Camilo Higuita's avatar Camilo Higuita

allowa custom youtube api key to avoid quota limits

parent 5b0c5fa2
......@@ -764,12 +764,9 @@ Kirigami.ApplicationWindow
}
}
Loader
YouTube
{
id: youtubeView
source: isMobile ? "qrc:/services/web/YouTube-A.qml" : "qrc:/services/web/YouTube.qml"
}
......@@ -834,7 +831,7 @@ Kirigami.ApplicationWindow
{
// if(isMobile) settingsDrawer.switchColorScheme(bae.loadSetting("THEME", "BABE", "Dark"))
// console.log(Imagine.url, Imagine.path)
bae.androidStatusBarColor(backgroundColor)
bae.androidStatusBarColor(viewBackgroundColor)
}
/*CONNECTIONS*/
......
......@@ -74,5 +74,7 @@
<file>widgets/SearchView/SearchSuggestions.qml</file>
<file>services/web/YouTube.qml</file>
<file>services/web/YouTube-A.qml</file>
<file>services/web/YoutubeViewer.qml</file>
<file>services/web/YoutubeViewer_A.qml</file>
</qresource>
</RCC>
import QtQuick 2.9
import QtWebKit 3.0
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import "../../view_models"
......@@ -10,7 +9,6 @@ import org.kde.kirigami 2.2 as Kirigami
Page
{
id: youtubeViewRoot
property alias web : webView
property var searchRes : []
clip: true
Connections
......@@ -24,18 +22,12 @@ Page
}
}
BabePopup
Loader
{
id: videoPlayback
WebView
{
id: webView
anchors.fill: parent
onLoadingChanged: {
if (loadRequest.errorString)
console.error(loadRequest.errorString);
}
}
id: youtubeViewer
source: isMobile ? "qrc:/services/web/YoutubeViewer_A.qml" : "qrc:/services/web/YoutubeViewer.qml"
}
......@@ -70,6 +62,7 @@ Page
Layout.column: 1
Layout.row: 2
Layout.fillWidth: true
}
TextField
......@@ -77,6 +70,7 @@ Page
Layout.column: 1
Layout.row: 3
Layout.fillWidth: true
text: bae.loadSetting("YOUTUBEKEY", "BABE", youtube.getKey())
}
Label
......@@ -98,6 +92,12 @@ Page
Layout.fillWidth: true
from: 1
to: 50
value: bae.loadSetting("YOUTUBELIMIT", "BABE", 25)
editable: true
onValueChanged:
{
bae.saveSetting("YOUTUBELIMIT", value, "BABE")
}
}
Item
......@@ -117,7 +117,7 @@ Page
if(searchTxt !== youtubeTable.headerBarTitle)
{
youtubeTable.headerBarTitle = searchTxt
youtube.getQuery(searchTxt)
youtube.getQuery(searchTxt, bae.loadSetting("YOUTUBELIMIT", "BABE", 25))
}
}
......@@ -176,8 +176,8 @@ Page
onRowClicked:
{
videoPlayback.open()
webView.url= youtubeTable.model.get(index).url
youtubeViewer.item.open()
youtubeViewer.item.webView.url= youtubeTable.model.get(index).url
}
onQuickPlayTrack:
......
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import "../../view_models"
import QtWebKit 3.0
BabePopup
{
id: videoPlayback
property alias webView: webView
WebView
{
id: webView
anchors.fill: parent
onLoadingChanged: {
if (loadRequest.errorString)
console.error(loadRequest.errorString);
}
}
}
import QtQuick 2.9
import QtWebView 1.1
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import "../../view_models"
BabePopup
{
id: videoPlayback
property alias webView: webView
WebView
{
id: webView
anchors.fill: parent
onLoadingChanged: {
if (loadRequest.errorString)
console.error(loadRequest.errorString);
}
}
}
......@@ -37,7 +37,7 @@ YouTube::YouTube(QObject *parent) : QObject(parent)
YouTube::~YouTube(){}
bool YouTube::getQuery(const QString &query)
bool YouTube::getQuery(const QString &query, const int &limit)
{
QUrl encodedQuery(query);
encodedQuery.toEncoded(QUrl::FullyEncoded);
......@@ -45,8 +45,8 @@ bool YouTube::getQuery(const QString &query)
auto url = this->API[METHOD::SEARCH];
url.append("q="+encodedQuery.toString());
url.append("&maxResults=25&part=snippet");
url.append("&key="+this->KEY);
url.append(QString("&maxResults=%1&part=snippet").arg(QString::number(limit)));
url.append("&key="+ BAE::loadSettings("YOUTUBEKEY", "BABE", this->KEY).toString());
qDebug()<< url;
auto array = this->startConnection(url);
......@@ -136,6 +136,12 @@ void YouTube::getUrl(const QString &id)
}
QString YouTube::getKey() const
{
return this->KEY;
}
QByteArray YouTube::startConnection(const QString &url, const QMap<QString, QString> &headers)
{
if(!url.isEmpty())
......
......@@ -21,10 +21,12 @@ class YouTube : public QObject
public:
explicit YouTube(QObject *parent = nullptr);
~YouTube();
Q_INVOKABLE bool getQuery(const QString &query);
Q_INVOKABLE bool getQuery(const QString &query, const int &limit = 5);
bool packQueryResults(const QByteArray &array);
void getId(const QString &results);
void getUrl(const QString &id);
Q_INVOKABLE QString getKey() const;
QByteArray startConnection(const QString &url, const QMap<QString, QString> &headers = {});
Q_INVOKABLE static QUrl fromUserInput(const QString &userInput);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment