smmd rework part 1

due to changes on the smmdb api i have to rework the smmdb integration
This commit is contained in:
Jannik 2017-08-25 14:57:15 +02:00
parent 9930a4cb15
commit 7a2112a759
13 changed files with 68 additions and 41 deletions

1
bin/.gitignore vendored
View File

@ -1 +1,2 @@
/application/ /application/
/datatypes/

Binary file not shown.

Binary file not shown.

View File

@ -534,11 +534,13 @@ public class MainWindowController {
id = idColumn.getCellData(selected); //get name of selected item id = idColumn.getCellData(selected); //get name of selected item
for (int i = 0; i < courses.size(); i++) { for (int i = 0; i < courses.size(); i++) {
if (courses.get(i).getId() == id) { if (courses.get(i).getId() == id) {
if (courses.get(i).getHasimage() == 1) { if (courses.get(i).getHasimage() == 1) {
try { try {
URL url = new URL("http://smmdb.ddns.net/img/courses/thumbnails/" + id + ".pic"); // URL url = new URL("http://smmdb.ddns.net/img/courses/thumbnails/" + id + ".pic"); //alt
System.out.println("http://smmdb.ddns.net/courseimg/" + id + "_full.jpg?v=3");
URL url = new URL("http://smmdb.ddns.net/courseimg/" + id + "_full.jpg?v=3");
Image image = new Image(url.toURI().toString()); Image image = new Image(url.toURI().toString());
smmdbImageView.setImage(image); smmdbImageView.setImage(image);
} catch (MalformedURLException | URISyntaxException e) { } catch (MalformedURLException | URISyntaxException e) {
@ -709,7 +711,7 @@ public class MainWindowController {
@FXML @FXML
void smmdbDownloadBtnAction(ActionEvent event){ void smmdbDownloadBtnAction(ActionEvent event){
String downloadUrl = "http://smmdb.ddns.net/courses/" + id; String downloadUrl = "http://smmdb.ddns.net/api/downloadcourse?id=" + id + "&type=zip";
String downloadFileURL = getCemuPath() + "/" + id + ".rar"; //getCemuPath() + "/" + smmID + "/" + id + ".rar" String downloadFileURL = getCemuPath() + "/" + id + ".rar"; //getCemuPath() + "/" + smmID + "/" + id + ".rar"
String outputFile = getCemuPath() + "/"; String outputFile = getCemuPath() + "/";
@ -1076,7 +1078,7 @@ public class MainWindowController {
break; break;
} }
switch (course.getLeveltype()) { switch (course.getGamestyle()) {
case 0: case 0:
leveltype = "NSMBU"; leveltype = "NSMBU";
break; break;

View File

@ -41,93 +41,117 @@ public class SmmdbApiQuery {
e.printStackTrace(); e.printStackTrace();
} }
JsonObject mainObject = Json.parse(output).asObject().get("courses").asObject(); System.out.println(URL);
JsonArray objectAssets = Json.parse(output).asObject().get("order").asArray(); System.out.println("{ \"courses\": " + output + "}");
for (JsonValue asset : objectAssets) { String apiOutput = "{ \"courses\": " + output + "}";
courseIDs.add(asset.asInt());
}
//if value is 9 or "notset" the api returned NULL as value JsonArray items = Json.parse(apiOutput).asObject().get("courses").asArray();
for (int i = 0; i < courseIDs.size(); i++) { for (JsonValue item : items) {
int id, owner, coursetype, leveltype, difficulty, lastmodified, uploaded, downloads, stars, hasimage, ispackage, updatereq; int id, owner, coursetype, gamestyle, difficulty, lastmodified, uploaded, downloads, stars, hasimage, ispackage, updatereq;
String nintendoid, title; String nintendoid, title;
JsonObject singleObject = mainObject.get(courseIDs.get(i).toString()).asObject();
//TODO add "courseTheme", "time", "autoScroll"
//geht
try { try {
id = singleObject.getInt("id", 0); id = item.asObject().getInt("id", 0);
} catch (Exception e) { } catch (Exception e) {
id = 9; id = 9;
} }
//geht
try { try {
owner = singleObject.getInt("owner", 0); owner = item.asObject().getInt("owner", 0);
} catch (Exception e) { } catch (Exception e) {
owner = 9; owner = 9;
} }
//test
try { try {
coursetype = singleObject.getInt("coursetype", 0); coursetype = item.asObject().getInt("coursetype", 0);
} catch (Exception e) { } catch (Exception e) {
coursetype = 9; coursetype = 9;
} }
//geht
try { try {
leveltype = singleObject.getInt("leveltype", 0); gamestyle = item.asObject().getInt("gamestyle", 0);
} catch (Exception e) { } catch (Exception e) {
leveltype = 9; gamestyle = 9;
} }
//geht
try { try {
difficulty = singleObject.getInt("difficulty", 0); difficulty = item.asObject().getInt("difficulty", 0);
} catch (Exception e) { } catch (Exception e) {
difficulty = 9; difficulty = 9;
} }
//geht
try { try {
lastmodified = singleObject.getInt("lastmodified", 0); lastmodified = item.asObject().getInt("lastmodified", 0);
} catch (Exception e) { } catch (Exception e) {
lastmodified = 9; lastmodified = 9;
} }
//geht
try { try {
uploaded = singleObject.getInt("uploaded", 0); uploaded = item.asObject().getInt("uploaded", 0);
} catch (Exception e) { } catch (Exception e) {
uploaded = 9; uploaded = 9;
} }
//gestrichen
try { try {
downloads = singleObject.getInt("downloads", 0); downloads = item.asObject().getInt("downloads", 0);
} catch (Exception e) { } catch (Exception e) {
downloads = 9; downloads = 9;
} }
//geht
try { try {
stars = singleObject.getInt("stars", 0); stars = item.asObject().getInt("stars", 0);
} catch (Exception e) { } catch (Exception e) {
stars = 9; stars = 9;
} }
//gestrichen
try { try {
hasimage = singleObject.getInt("hasimage", 0); hasimage = item.asObject().getInt("hasimage", 0);
} catch (Exception e) { } catch (Exception e) {
hasimage = 9; hasimage = 9;
} }
//gestrichen
try { try {
ispackage = singleObject.getInt("ispackage", 0); ispackage = item.asObject().getInt("ispackage", 0);
} catch (Exception e) { } catch (Exception e) {
ispackage = 9; ispackage = 9;
} }
//gestrichen
try { try {
updatereq = singleObject.getInt("updatereq", 0); updatereq = item.asObject().getInt("updatereq", 0);
} catch (Exception e) { } catch (Exception e) {
updatereq = 9; updatereq = 9;
} }
//geht
try { try {
nintendoid = singleObject.getString("nintendoid", ""); nintendoid = item.asObject().getString("nintendoid", "");
} catch (Exception e) { } catch (Exception e) {
nintendoid = "notset"; nintendoid = "notset";
} }
try { try {
title = singleObject.getString("title", "");; title = item.asObject().getString("title", "");;
} catch (Exception e) { } catch (Exception e) {
title = "notset"; title = "notset";
} }
course.add(new SmmdbApiDataType(id, owner, coursetype, leveltype, difficulty, lastmodified, uploaded, downloads, course.add(new SmmdbApiDataType(id, owner, coursetype, gamestyle, difficulty, lastmodified, uploaded, downloads,
stars, hasimage, ispackage, updatereq, nintendoid, title)); stars, hasimage, ispackage, updatereq, nintendoid, title));
} }
return course; return course;
} }

View File

@ -13,7 +13,7 @@ public class SmmdbApiDataType {
private final IntegerProperty id = new SimpleIntegerProperty(); private final IntegerProperty id = new SimpleIntegerProperty();
private final IntegerProperty owner = new SimpleIntegerProperty(); private final IntegerProperty owner = new SimpleIntegerProperty();
private final IntegerProperty coursetype = new SimpleIntegerProperty(); private final IntegerProperty coursetype = new SimpleIntegerProperty();
private final IntegerProperty leveltype = new SimpleIntegerProperty(); private final IntegerProperty gamestyle = new SimpleIntegerProperty();
private final IntegerProperty difficulty = new SimpleIntegerProperty(); private final IntegerProperty difficulty = new SimpleIntegerProperty();
private final IntegerProperty lastmodified = new SimpleIntegerProperty(); private final IntegerProperty lastmodified = new SimpleIntegerProperty();
private final IntegerProperty uploaded = new SimpleIntegerProperty(); private final IntegerProperty uploaded = new SimpleIntegerProperty();
@ -25,13 +25,13 @@ public class SmmdbApiDataType {
private final StringProperty nintendoid = new SimpleStringProperty(); private final StringProperty nintendoid = new SimpleStringProperty();
private final StringProperty title = new SimpleStringProperty(); private final StringProperty title = new SimpleStringProperty();
public SmmdbApiDataType(final int id, final int owner, final int coursetype, final int leveltype, final int difficulty, public SmmdbApiDataType(final int id, final int owner, final int coursetype, final int gamestyle, final int difficulty,
final int lastmodified, final int uploaded, final int downloads, final int stars, final int hasimage, final int lastmodified, final int uploaded, final int downloads, final int stars, final int hasimage,
final int ispackage, final int updatereq, final String nintendoid, final String title) { final int ispackage, final int updatereq, final String nintendoid, final String title) {
this.id.set(id); this.id.set(id);
this.owner.set(owner); this.owner.set(owner);
this.coursetype.set(coursetype); this.coursetype.set(coursetype);
this.leveltype.set(leveltype); this.gamestyle.set(gamestyle);
this.difficulty.set(difficulty); this.difficulty.set(difficulty);
this.lastmodified.set(lastmodified); this.lastmodified.set(lastmodified);
this.uploaded.set(uploaded); this.uploaded.set(uploaded);
@ -60,8 +60,8 @@ public class SmmdbApiDataType {
return nintendoid; return nintendoid;
} }
public IntegerProperty leveltypeProperty(){ public IntegerProperty gamestyleProperty(){
return leveltype; return gamestyle;
} }
public IntegerProperty difficultyProperty(){ public IntegerProperty difficultyProperty(){
@ -112,8 +112,8 @@ public class SmmdbApiDataType {
return coursetypeProperty().get(); return coursetypeProperty().get();
} }
public int getLeveltype() { public int getGamestyle() {
return leveltypeProperty().get(); return gamestyleProperty().get();
} }
public int getDifficulty() { public int getDifficulty() {
@ -168,8 +168,8 @@ public class SmmdbApiDataType {
coursetypeProperty().set(coursetype); coursetypeProperty().set(coursetype);
} }
public final void setLeveltype(int leveltype) { public final void setGamestyle(int leveltype) {
leveltypeProperty().set(leveltype); gamestyleProperty().set(leveltype);
} }
public final void setDifficulty(int difficulty) { public final void setDifficulty(int difficulty) {