Skip to content
Merged
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
9 changes: 8 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ file("src/main/resources/version.properties").takeIf { it.exists() }?.let {
plugins {
id("java")
id("application")
application
id("com.github.johnrengelman.shadow") version "8.1.1"
}

group = "org.example"
Expand Down Expand Up @@ -56,4 +58,9 @@ tasks.named<Jar>("jar") {
"Main-Class" to "com.CDPrintable.Main"
)
}
}
}

tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
archiveClassifier.set("all")
mergeServiceFiles()
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

package com.CDPrintable.MusicBrainzResources;

import java.util.Locale;

public class MusicBrainzArtist {
private String name;
private String dateOrganized; // May only be present for groups
Expand Down Expand Up @@ -121,7 +123,9 @@ public void setBirthDate(String birthDate) {
}

public String getCountry() {
return country;
if (country == null || country.equals("xw")) {return null;}
Locale locale = new Locale.Builder().setRegion(country).build();
return locale.getDisplayName();
}

public void setCountry(String country) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,6 @@ public MusicBrainzArtist[] getArtists() {
}

String country = jsonHasAndIsNotNull(jsonObject, "country") ? jsonObject.get("country").getAsString() : null;
if (country != null) {
Locale locale = new Locale.Builder().setRegion(country).build();
country = locale.getDisplayCountry();
}

return new MusicBrainzArtist(name, organizedDate, birthDate, id, sortName, gender, type, disambiguation, lifeSpan, country);
}, new MusicBrainzArtist[0]);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/CDPrintable/WebRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ public WebRequest(String url, String userAgent) {
*/
public String sendRequest() throws IOException, URISyntaxException {
HttpURLConnection connection = (HttpURLConnection) new URI(url).toURL().openConnection();

connection.setRequestMethod("GET");
connection.setRequestProperty("User-Agent", userAgent);
connection.setRequestProperty("Accept", "application/json");

connection.setConnectTimeout(6000);
connection.setReadTimeout(5000);

int responseCode = connection.getResponseCode();
if (responseCode != HttpURLConnection.HTTP_OK) {
throw new IOException("HTTP error code: " + responseCode);
Expand Down