fixed crew fetcher, bump version to 1.3.5

This commit is contained in:
Syping 2017-08-26 10:04:59 +02:00
parent 2bbeb98005
commit ccfb4c7ccb
4 changed files with 98 additions and 37 deletions

View file

@ -121,9 +121,14 @@ QByteArray AppEnv::getUserAgent()
return QString("Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0 %1/%2").arg(GTA5SYNC_APPSTR, GTA5SYNC_APPVER).toUtf8();
}
// QUrl AppEnv::getCrewFetchingUrl(QString crewID)
// {
// return QUrl(QString("https://socialclub.rockstargames.com/reference/crewfeed/%1").arg(crewID));
// }
QUrl AppEnv::getCrewFetchingUrl(QString crewID)
{
return QUrl(QString("https://socialclub.rockstargames.com/reference/crewfeed/%1").arg(crewID));
return QUrl(QString("https://socialclub.rockstargames.com/crew/%1/%1").arg(crewID));
}
QUrl AppEnv::getPlayerFetchingUrl(QString crewID, QString pageNumber)

View file

@ -82,6 +82,80 @@ void DatabaseThread::run()
}
}
// void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay)
// {
// foreach (const QString &crewID, crewList)
// {
// if (threadRunning && crewID != "0")
// {
// QNetworkAccessManager *netManager = new QNetworkAccessManager();
// QNetworkRequest netRequest(AppEnv::getCrewFetchingUrl(crewID));
// netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent());
// netRequest.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
// netRequest.setRawHeader("Accept-Language", "en-US;q=0.5,en;q=0.3");
// netRequest.setRawHeader("Connection", "keep-alive");
// QNetworkReply *netReply = netManager->get(netRequest);
// QEventLoop *downloadLoop = new QEventLoop();
// QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit()));
// QObject::connect(this, SIGNAL(threadEndCommited()), downloadLoop, SLOT(quit()));
// QTimer::singleShot(30000, downloadLoop, SLOT(quit()));
// downloadLoop->exec();
// delete downloadLoop;
// if (netReply->isFinished())
// {
// QByteArray crewJson = netReply->readAll();
// QJsonDocument crewDocument = QJsonDocument::fromJson(crewJson);
// QJsonObject crewObject = crewDocument.object();
// QVariantMap crewMap = crewObject.toVariantMap();
// QString crewName;
// bool isFound = false;
// if (crewMap.contains("activities"))
// {
// QList<QVariant> activitiesList = crewMap["activities"].toList();
// foreach (const QVariant &activitiesVariant, activitiesList)
// {
// QMap<QString, QVariant> activityRootMap = activitiesVariant.toMap();
// foreach(const QVariant &activityRootVariant, activityRootMap)
// {
// QMap<QString, QVariant> activityMap = activityRootVariant.toMap();
// foreach(const QVariant &activityVariant, activityMap)
// {
// QMap<QString, QVariant> activityFinalMap = activityVariant.toMap();
// if (activityFinalMap.contains("id") && activityFinalMap["id"] == crewID)
// {
// if (activityFinalMap.contains("name") && isFound == false)
// {
// isFound = true;
// crewName = activityFinalMap["name"].toString();
// }
// }
// }
// }
// }
// }
// if (!crewName.isNull())
// {
// crewDB->setCrewName(crewID.toInt(), crewName);
// }
// }
// QEventLoop *waitingLoop = new QEventLoop();
// QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit()));
// QObject::connect(this, SIGNAL(threadEndCommited()), waitingLoop, SLOT(quit()));
// waitingLoop->exec();
// delete waitingLoop;
// delete netReply;
// delete netManager;
// }
// }
// }
void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay)
{
foreach (const QString &crewID, crewList)
@ -91,6 +165,9 @@ void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay)
QNetworkAccessManager *netManager = new QNetworkAccessManager();
QNetworkRequest netRequest(AppEnv::getCrewFetchingUrl(crewID));
#if QT_VERSION >= 0x050600
netRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
#endif
netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent());
netRequest.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
netRequest.setRawHeader("Accept-Language", "en-US;q=0.5,en;q=0.3");
@ -107,38 +184,18 @@ void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay)
if (netReply->isFinished())
{
QByteArray crewJson = netReply->readAll();
QJsonDocument crewDocument = QJsonDocument::fromJson(crewJson);
QJsonObject crewObject = crewDocument.object();
QVariantMap crewMap = crewObject.toVariantMap();
QString crewName;
bool isFound = false;
if (crewMap.contains("activities"))
QByteArray crewHtml = netReply->readAll();
QStringList crewHtmlSplit1 = QString::fromUtf8(crewHtml).split("<title>Rockstar Games Social Club - Crew : ");
if (crewHtmlSplit1.length() >= 2)
{
QList<QVariant> activitiesList = crewMap["activities"].toList();
foreach (const QVariant &activitiesVariant, activitiesList)
QStringList crewHtmlSplit2 = QString(crewHtmlSplit1.at(1)).split("</title>");
if (crewHtmlSplit2.length() >= 1)
{
QMap<QString, QVariant> activityRootMap = activitiesVariant.toMap();
foreach(const QVariant &activityRootVariant, activityRootMap)
{
QMap<QString, QVariant> activityMap = activityRootVariant.toMap();
foreach(const QVariant &activityVariant, activityMap)
{
QMap<QString, QVariant> activityFinalMap = activityVariant.toMap();
if (activityFinalMap.contains("id") && activityFinalMap["id"] == crewID)
{
if (activityFinalMap.contains("name") && isFound == false)
{
isFound = true;
crewName = activityFinalMap["name"].toString();
}
}
}
}
crewName = crewHtmlSplit2.at(0);
}
}
if (!crewName.isNull())
if (!crewName.isEmpty())
{
crewDB->setCrewName(crewID.toInt(), crewName);
}
@ -150,9 +207,7 @@ void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay)
waitingLoop->exec();
delete waitingLoop;
netReply->deleteLater();
delete netReply;
netManager->deleteLater();
delete netManager;
}
}
@ -173,6 +228,9 @@ void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int
QNetworkAccessManager *netManager = new QNetworkAccessManager();
QNetworkRequest netRequest(AppEnv::getPlayerFetchingUrl(crewID, QString::number(currentPage)));
#if QT_VERSION >= 0x050600
netRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
#endif
netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent());
netRequest.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
netRequest.setRawHeader("Accept-Language", "en-US;q=0.5,en;q=0.3");
@ -224,9 +282,7 @@ void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int
currentPage++;
}
netReply->deleteLater();
delete netReply;
netManager->deleteLater();
delete netManager;
}
}

View file

@ -50,7 +50,7 @@
#ifndef GTA5SYNC_APPVER
#ifndef GTA5SYNC_DAILYB
#define GTA5SYNC_APPVER "1.3.4"
#define GTA5SYNC_APPVER "1.3.5"
#else
#define GTA5SYNC_APPVER QString("%1").arg(GTA5SYNC_DAILYB)
#endif

View file

@ -7,8 +7,8 @@ CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "gta5view.exe.manifest"
#include <windows.h>
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1, 3, 4, 0
PRODUCTVERSION 1, 3, 4, 0
FILEVERSION 1, 3, 5, 0
PRODUCTVERSION 1, 3, 5, 0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0
FILEOS VOS_NT_WINDOWS32
@ -25,12 +25,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Syping"
VALUE "FileDescription", "gta5view\0"
VALUE "FileVersion", "1.3.4\0"
VALUE "FileVersion", "1.3.5\0"
VALUE "InternalName", "gta5view\0"
VALUE "LegalCopyright", "Copyright © 2016-2017 Syping\0"
VALUE "OriginalFilename", "gta5view.exe\0"
VALUE "ProductName", "gta5view\0"
VALUE "ProductVersion", "1.3.4\0"
VALUE "ProductVersion", "1.3.5\0"
END
END
END