Add settings. Add searching by movie title on TheMovieDB.
This commit is contained in:
parent
dc43da0e0e
commit
d364cfd0b7
@ -4,7 +4,7 @@ project(DoViGUI VERSION 0.1 LANGUAGES CXX)
|
|||||||
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
find_package(Qt6 6.4 REQUIRED COMPONENTS Quick Core)
|
find_package(Qt6 6.4 REQUIRED COMPONENTS Quick Core Network)
|
||||||
|
|
||||||
qt_standard_project_setup()
|
qt_standard_project_setup()
|
||||||
|
|
||||||
@ -20,6 +20,10 @@ qt_add_qml_module(appDoViGUI
|
|||||||
SOURCES QMediaInfo.h QMediaInfo.cpp
|
SOURCES QMediaInfo.h QMediaInfo.cpp
|
||||||
RESOURCES MediaInfo.dll
|
RESOURCES MediaInfo.dll
|
||||||
SOURCES QHandbrake.h QHandbrake.cpp
|
SOURCES QHandbrake.h QHandbrake.cpp
|
||||||
|
SOURCES
|
||||||
|
SOURCES
|
||||||
|
SOURCES
|
||||||
|
SOURCES qmoviedb.h qmoviedb.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
|
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
|
||||||
@ -34,7 +38,7 @@ set_target_properties(appDoViGUI PROPERTIES
|
|||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(appDoViGUI
|
target_link_libraries(appDoViGUI
|
||||||
PRIVATE Qt6::Quick Qt6::Core
|
PRIVATE Qt6::Quick Qt6::Core Qt6::Network
|
||||||
)
|
)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
@ -2,17 +2,31 @@
|
|||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
#include <QMediaInfo.h>
|
#include <QMediaInfo.h>
|
||||||
#include <QHandbrake.h>
|
#include <QHandbrake.h>
|
||||||
|
#include "qmoviedb.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QGuiApplication app(argc, argv);
|
QGuiApplication app(argc, argv);
|
||||||
|
QCoreApplication::setOrganizationName("abissen");
|
||||||
|
QCoreApplication::setApplicationName("DoViGUI");
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
|
||||||
QMediaInfo mInfo(&app);
|
QMediaInfo mInfo(&app);
|
||||||
|
|
||||||
|
if (QString::compare(settings.value("MovieDB API Key").toString(), "", Qt::CaseInsensitive) == 0) {
|
||||||
|
qWarning() << "Set MovieDB API key in settings file.";
|
||||||
|
settings.setValue("MovieDB API Key", "");
|
||||||
|
}
|
||||||
|
QMovieDB movieDB(settings.value("MovieDB API Key").toString());
|
||||||
|
|
||||||
|
movieDB.searchMovieTitle("The Shawshank Redemption");
|
||||||
|
|
||||||
// //Check if HDR/DolbyVision
|
// //Check if HDR/DolbyVision
|
||||||
// enum QMediaInfo::HDR_Type hdrType = mInfo.getHDRType(__T("Cosmos.mkv"));
|
// enum QMediaInfo::HDR_Type hdrType = mInfo.getHDRType(__T("Cosmos.mkv"));
|
||||||
// if (hdrType >= 0) {
|
// if (hdrType >= 0) {
|
||||||
|
29
DoViGUI/qmoviedb.cpp
Normal file
29
DoViGUI/qmoviedb.cpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#include "qmoviedb.h"
|
||||||
|
#include "QNetworkReply"
|
||||||
|
#include "QDebug"
|
||||||
|
|
||||||
|
QMovieDB::QMovieDB(QString apiKey, QObject *parent)
|
||||||
|
: QObject{parent}, netMan(new QNetworkAccessManager(this)) {
|
||||||
|
movieDbApiKey = apiKey;
|
||||||
|
QObject::connect(netMan, &QNetworkAccessManager::finished, this, &QMovieDB::receiveReply);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QMovieDB::searchMovieTitle(const QString title)
|
||||||
|
{
|
||||||
|
QNetworkRequest req;
|
||||||
|
req.setRawHeader("Accept", "application/json");
|
||||||
|
|
||||||
|
QString bearer = "Bearer " + movieDbApiKey;
|
||||||
|
req.setRawHeader("Authorization", bearer.toUtf8());
|
||||||
|
|
||||||
|
QByteArray URL = QUrl::toPercentEncoding(title);
|
||||||
|
URL = "https://api.themoviedb.org/3/search/movie?query=" + URL + "&include_adult=false&language=en-US&page=1";
|
||||||
|
|
||||||
|
req.setUrl(QUrl(URL));
|
||||||
|
netMan->get(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QMovieDB::receiveReply(QNetworkReply *reply)
|
||||||
|
{
|
||||||
|
qInfo() << reply->readAll();
|
||||||
|
}
|
25
DoViGUI/qmoviedb.h
Normal file
25
DoViGUI/qmoviedb.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef QMOVIEDB_H
|
||||||
|
#define QMOVIEDB_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
|
||||||
|
class QMovieDB : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit QMovieDB(QString apiKey, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
QNetworkAccessManager *netMan;
|
||||||
|
|
||||||
|
void searchMovieTitle(const QString title);
|
||||||
|
private:
|
||||||
|
QString movieDbApiKey;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void receiveReply(QNetworkReply *reply);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QMOVIEDB_H
|
Loading…
Reference in New Issue
Block a user