Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public record OSCMeta(String name, String author, String[] authors, String categ
List<String> peripherals, String version, EnumSet<Flag> flags,
Source source, List<Treatment> treatments)
{
public record Source(String type, Format format, String url, String file,
public record Source(String type, String host, Format format, String url, String file,
String userAgent, Set<String> additionalFiles)
{
public enum Format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,20 @@ protected Request fetchFileInformation(InstalledApp app, Path archivePath, Path
OSCMeta.Source source = app.getMeta().source();
Request.Builder request = new Request.Builder();

if(!config.getGithubToken().isEmpty())
{
logger.info(" - Authenticating with GitHub");
request.addHeader("Authorization", "token " + config.getGithubToken());
String apiHost = source.host() + "/api/v1";
if (source.host() == null) {
apiHost = "https://api.github.com";

if(!config.getGithubToken().isEmpty())
{
logger.info(" - Authenticating with GitHub");
request.addHeader("Authorization", "token " + config.getGithubToken());
}
else
logger.info(" - No valid GitHub token found, using unauthenticated requests.");
}
else
logger.info(" - No valid GitHub token found, using unauthenticated requests.");

return request.url(LATEST_RELEASE.formatted(source.url()))
return request.url(LATEST_RELEASE.formatted(apiHost, source.url()))
.addHeader("User-Agent", config.getUserAgent())
.build();
}
Expand Down Expand Up @@ -106,5 +111,5 @@ protected void processFiles(InstalledApp app, Path archivePath, Path tmpDir, Req
}
}

private static final String LATEST_RELEASE = "https://api.github.com/repos/%s/releases/latest";
private static final String LATEST_RELEASE = "%s/repos/%s/releases/latest";
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ else if(type.equalsIgnoreCase("itchio"))
context.deserialize(additionalFilesArr, new TypeToken<>(){}.getType());

return new OSCMeta.Source(type,
obj.has("host") ? obj.get("host").getAsString() : null,
context.deserialize(obj.get("format"), OSCMeta.Source.Format.class),
url,
file,
Expand Down