Merge pull request #608 from timoreo22/feature/curseforge-fix
Very Temporary Fix for curseforge
This commit is contained in:
commit
92e8aaf36f
@ -31,7 +31,21 @@ void Flame::FileResolvingTask::netJobFinished()
|
|||||||
for (auto& bytes : results) {
|
for (auto& bytes : results) {
|
||||||
auto& out = m_toProcess.files[index];
|
auto& out = m_toProcess.files[index];
|
||||||
try {
|
try {
|
||||||
failed &= (!out.parseFromBytes(bytes));
|
bool fail = (!out.parseFromBytes(bytes));
|
||||||
|
if(fail){
|
||||||
|
//failed :( probably disabled mod, try to add to the list
|
||||||
|
auto doc = Json::requireDocument(bytes);
|
||||||
|
if (!doc.isObject()) {
|
||||||
|
throw JSONValidationError(QString("data is not an object? that's not supposed to happen"));
|
||||||
|
}
|
||||||
|
auto obj = Json::ensureObject(doc.object(), "data");
|
||||||
|
//FIXME : HACK, MAY NOT WORK FOR LONG
|
||||||
|
out.url = QUrl(QString("https://media.forgecdn.net/files/%1/%2/%3")
|
||||||
|
.arg(QString::number(QString::number(out.fileId).leftRef(4).toInt())
|
||||||
|
,QString::number(QString::number(out.fileId).rightRef(3).toInt())
|
||||||
|
,QUrl::toPercentEncoding(out.fileName)), QUrl::TolerantMode);
|
||||||
|
}
|
||||||
|
failed &= fail;
|
||||||
} catch (const JSONValidationError& e) {
|
} catch (const JSONValidationError& e) {
|
||||||
qCritical() << "Resolving of" << out.projectId << out.fileId << "failed because of a parsing error:";
|
qCritical() << "Resolving of" << out.projectId << out.fileId << "failed because of a parsing error:";
|
||||||
qCritical() << e.cause();
|
qCritical() << e.cause();
|
||||||
|
@ -56,8 +56,15 @@ void FlameMod::loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
|
|||||||
file.fileId = Json::requireInteger(obj, "id");
|
file.fileId = Json::requireInteger(obj, "id");
|
||||||
file.date = Json::requireString(obj, "fileDate");
|
file.date = Json::requireString(obj, "fileDate");
|
||||||
file.version = Json::requireString(obj, "displayName");
|
file.version = Json::requireString(obj, "displayName");
|
||||||
file.downloadUrl = Json::requireString(obj, "downloadUrl");
|
|
||||||
file.fileName = Json::requireString(obj, "fileName");
|
file.fileName = Json::requireString(obj, "fileName");
|
||||||
|
file.downloadUrl = Json::ensureString(obj, "downloadUrl", "");
|
||||||
|
if(file.downloadUrl.isEmpty()){
|
||||||
|
//FIXME : HACK, MAY NOT WORK FOR LONG
|
||||||
|
file.downloadUrl = QString("https://media.forgecdn.net/files/%1/%2/%3")
|
||||||
|
.arg(QString::number(QString::number(file.fileId.toInt()).leftRef(4).toInt())
|
||||||
|
,QString::number(QString::number(file.fileId.toInt()).rightRef(3).toInt())
|
||||||
|
,QUrl::toPercentEncoding(file.fileName));
|
||||||
|
}
|
||||||
|
|
||||||
unsortedVersions.append(file);
|
unsortedVersions.append(file);
|
||||||
}
|
}
|
||||||
|
@ -71,11 +71,6 @@ bool Flame::File::parseFromBytes(const QByteArray& bytes)
|
|||||||
|
|
||||||
fileName = Json::requireString(obj, "fileName");
|
fileName = Json::requireString(obj, "fileName");
|
||||||
|
|
||||||
QString rawUrl = Json::requireString(obj, "downloadUrl");
|
|
||||||
url = QUrl(rawUrl, QUrl::TolerantMode);
|
|
||||||
if (!url.isValid()) {
|
|
||||||
throw JSONValidationError(QString("Invalid URL: %1").arg(rawUrl));
|
|
||||||
}
|
|
||||||
// This is a piece of a Flame project JSON pulled out into the file metadata (here) for convenience
|
// This is a piece of a Flame project JSON pulled out into the file metadata (here) for convenience
|
||||||
// It is also optional
|
// It is also optional
|
||||||
type = File::Type::SingleFile;
|
type = File::Type::SingleFile;
|
||||||
@ -87,7 +82,17 @@ bool Flame::File::parseFromBytes(const QByteArray& bytes)
|
|||||||
// this is probably a mod, dunno what else could modpacks download
|
// this is probably a mod, dunno what else could modpacks download
|
||||||
targetFolder = "mods";
|
targetFolder = "mods";
|
||||||
}
|
}
|
||||||
|
QString rawUrl = Json::ensureString(obj, "downloadUrl");
|
||||||
|
|
||||||
|
if(rawUrl.isEmpty()){
|
||||||
|
//either there somehow is an emtpy string as a link, or it's null either way it's invalid
|
||||||
|
//soft failing
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
url = QUrl(rawUrl, QUrl::TolerantMode);
|
||||||
|
if (!url.isValid()) {
|
||||||
|
throw JSONValidationError(QString("Invalid URL: %1").arg(rawUrl));
|
||||||
|
}
|
||||||
resolved = true;
|
resolved = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -6,30 +6,66 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>837</width>
|
<width>800</width>
|
||||||
<height>685</height>
|
<height>600</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="1" column="0" colspan="2">
|
<item row="0" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<widget class="QLabel" name="label_2">
|
||||||
<item row="1" column="0">
|
<property name="font">
|
||||||
<widget class="QListView" name="packView">
|
<font>
|
||||||
<property name="iconSize">
|
<italic>true</italic>
|
||||||
<size>
|
</font>
|
||||||
<width>48</width>
|
|
||||||
<height>48</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Note: CurseForge's API is very unreliable. CurseForge and some mod authors have disallowed downloading mods in third-party applications like PolyMC. As such, you may need to manually download some mods to be able to install a modpack.</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<layout class="QHBoxLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="searchEdit">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Search and filter...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="searchButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Search</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<layout class="QHBoxLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QListView" name="packView">
|
||||||
<property name="horizontalScrollBarPolicy">
|
<property name="horizontalScrollBarPolicy">
|
||||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="alternatingRowColors">
|
<property name="alternatingRowColors">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>48</width>
|
||||||
|
<height>48</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item>
|
||||||
<widget class="QTextBrowser" name="packDescription">
|
<widget class="QTextBrowser" name="packDescription">
|
||||||
<property name="openExternalLinks">
|
<property name="openExternalLinks">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -41,12 +77,12 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="2">
|
<item row="3" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_4" columnstretch="0,0,0" rowminimumheight="0" columnminimumwidth="0,0,0">
|
<layout class="QHBoxLayout">
|
||||||
<item row="0" column="2">
|
<item>
|
||||||
<widget class="QComboBox" name="versionSelectionBox"/>
|
<widget class="QComboBox" name="sortByBox"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Version selected:</string>
|
<string>Version selected:</string>
|
||||||
@ -56,30 +92,14 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item>
|
||||||
<widget class="QComboBox" name="sortByBox"/>
|
<widget class="QComboBox" name="versionSelectionBox"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QPushButton" name="searchButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Search</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLineEdit" name="searchEdit">
|
|
||||||
<property name="placeholderText">
|
|
||||||
<string>Search and filter...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>searchEdit</tabstop>
|
|
||||||
<tabstop>searchButton</tabstop>
|
|
||||||
<tabstop>packView</tabstop>
|
<tabstop>packView</tabstop>
|
||||||
<tabstop>packDescription</tabstop>
|
<tabstop>packDescription</tabstop>
|
||||||
<tabstop>sortByBox</tabstop>
|
<tabstop>sortByBox</tabstop>
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>837</width>
|
<width>800</width>
|
||||||
<height>685</height>
|
<height>600</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout">
|
<layout class="QVBoxLayout">
|
||||||
@ -24,6 +24,9 @@
|
|||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignCenter</set>
|
<set>Qt::AlignCenter</set>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
Loading…
Reference in New Issue
Block a user