Adjust an edge case
@ -17,6 +17,8 @@ dependencies {
|
||||
testImplementation('org.springframework.boot:spring-boot-starter-test') {
|
||||
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
|
||||
}
|
||||
compile 'org.apache.httpcomponents:httpcore:4.4.1'
|
||||
compile 'org.apache.httpcomponents:httpclient:4.5'
|
||||
}
|
||||
|
||||
test {
|
||||
|
BIN
lib/httpclient-4.5.12.jar
Normal file
BIN
lib/httpcore-4.4.13.jar
Normal file
@ -1,8 +1,17 @@
|
||||
package com.example.demo;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.filter.CharacterEncodingFilter;
|
||||
@ -20,6 +29,7 @@ import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.ConnectException;
|
||||
@ -29,7 +39,11 @@ import java.net.URLDecoder;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
@ -52,10 +66,72 @@ public class Controller {
|
||||
return failPixel.getRed()>=50 && failPixel.getRed()<=150 && failPixel.getGreen()>=50 && failPixel.getGreen()<=150 && failPixel.getBlue()>=50 && failPixel.getBlue()<=150;
|
||||
}
|
||||
|
||||
@PostMapping("/image")
|
||||
public String postImage(@RequestParam Map<String,String> body){
|
||||
HashMap<String,String> data = new HashMap<>();
|
||||
if (body.containsKey("url") && body.containsKey("user") && body.containsKey("auth")) {
|
||||
HashMap<String,String> imageData = GetImageData(body.get("url"));
|
||||
data.putAll(imageData);
|
||||
data.put("user",body.get("user"));
|
||||
data.put("auth",body.get("auth"));
|
||||
//System.out.println("In here.");
|
||||
HttpClient httpclient = HttpClients.createDefault();
|
||||
HttpPost httppost = new HttpPost("http://projectdivar.com/submit");
|
||||
|
||||
// Request parameters and other properties.
|
||||
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
||||
params.add(new BasicNameValuePair("song", data.get("songname")));
|
||||
params.add(new BasicNameValuePair("username", data.get("user")));
|
||||
params.add(new BasicNameValuePair("authentication_token", data.get("auth")));
|
||||
params.add(new BasicNameValuePair("difficulty", data.get("difficulty")));
|
||||
params.add(new BasicNameValuePair("cool", data.get("cool")));
|
||||
params.add(new BasicNameValuePair("fine", data.get("fine")));
|
||||
params.add(new BasicNameValuePair("safe", data.get("safe")));
|
||||
params.add(new BasicNameValuePair("sad", data.get("sad")));
|
||||
params.add(new BasicNameValuePair("worst", data.get("worst")));
|
||||
params.add(new BasicNameValuePair("percent", data.get("percent")));
|
||||
params.add(new BasicNameValuePair("fail", data.get("fail")));
|
||||
params.add(new BasicNameValuePair("combo", data.get("combo")));
|
||||
params.add(new BasicNameValuePair("mod", data.get("mod")));
|
||||
params.add(new BasicNameValuePair("gameScore", data.get("gameScore")));
|
||||
try {
|
||||
httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//Execute and get the response.
|
||||
HttpResponse response = null;
|
||||
try {
|
||||
response = httpclient.execute(httppost);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
HttpEntity entity = response.getEntity();
|
||||
String result = "";
|
||||
if (entity != null) {
|
||||
try (InputStream instream = entity.getContent()) {
|
||||
Scanner s = new Scanner(instream).useDelimiter("\\A");
|
||||
result = s.hasNext() ? s.next() : "";
|
||||
instream.close();
|
||||
} catch (UnsupportedOperationException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return "Invalid parameters!";
|
||||
}
|
||||
|
||||
@GetMapping("/image")
|
||||
public HashMap<String,String> helloWorld(@RequestParam("url") String url){
|
||||
public HashMap<String,String> getImage(@RequestParam("url") String url){
|
||||
return GetImageData(url);
|
||||
}
|
||||
|
||||
private HashMap<String, String> GetImageData(String url) {
|
||||
HashMap<String,String> data = new HashMap<>();
|
||||
//System.out.println(new File(".").getAbsolutePath());
|
||||
//System.out.println(body);
|
||||
try {
|
||||
System.out.println(url);
|
||||
downloadFileFromUrl(url,"temp");
|
||||
|
@ -68,7 +68,7 @@ public class TypeFace {
|
||||
img.setRGB(x, y, Color.WHITE.getRGB());
|
||||
}
|
||||
} else
|
||||
if ((currentCol.getRed()>=0 && currentCol.getRed()<=100
|
||||
if ((currentCol.getRed()>=0 && currentCol.getRed()<=105
|
||||
&& currentCol.getGreen()>=0 && currentCol.getGreen()<=150
|
||||
&& currentCol.getBlue()>=0 && currentCol.getBlue()<=150) ||
|
||||
(this.equals(DemoApplication.typeface2) &&
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
server.port=4503
|
||||
# Charset of HTTP requests and responses. Added to the "Content-Type" header if not set explicitly.
|
||||
spring.http.encoding.charset=UTF-8
|
||||
# Enable http encoding support.
|
||||
|
BIN
temp
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.5 MiB |
@ -1,10 +1,10 @@
|
||||
1:0.71875
|
||||
2:0.9296875
|
||||
1:0.71484375
|
||||
2:0.92578125
|
||||
3:0.017578125
|
||||
4:0.03125
|
||||
5:0.0107421875
|
||||
6:0.07421875
|
||||
6:0.072265625
|
||||
7:0.0078125
|
||||
8:0.048828125
|
||||
9:0.03125
|
||||
0:0.07421875
|
||||
0:0.072265625
|
||||
|
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 145 B |
Before Width: | Height: | Size: 140 B After Width: | Height: | Size: 140 B |
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 142 B |
Before Width: | Height: | Size: 141 B After Width: | Height: | Size: 141 B |
Before Width: | Height: | Size: 144 B After Width: | Height: | Size: 144 B |
Before Width: | Height: | Size: 138 B After Width: | Height: | Size: 138 B |
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 145 B |
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 143 B |
Before Width: | Height: | Size: 141 B After Width: | Height: | Size: 143 B |
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 146 B |
@ -1,10 +1,10 @@
|
||||
1:0.759765625
|
||||
1:0.5
|
||||
2:0.0078125
|
||||
3:0.00390625
|
||||
4:0.04296875
|
||||
5:0.0185546875
|
||||
6:0.9013671875
|
||||
4:0.826171875
|
||||
5:0.2373046875
|
||||
6:0.052734375
|
||||
7:0.00390625
|
||||
8:0.76171875
|
||||
9:0.0390625
|
||||
0:0.400390625
|
||||
8:0.052734375
|
||||
9:0.1171875
|
||||
0:0.0703125
|
||||
|
Before Width: | Height: | Size: 152 B After Width: | Height: | Size: 138 B |
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 136 B |
Before Width: | Height: | Size: 139 B After Width: | Height: | Size: 135 B |
Before Width: | Height: | Size: 147 B After Width: | Height: | Size: 138 B |
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 150 B |
Before Width: | Height: | Size: 139 B After Width: | Height: | Size: 151 B |
Before Width: | Height: | Size: 154 B After Width: | Height: | Size: 139 B |
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 139 B |
Before Width: | Height: | Size: 147 B After Width: | Height: | Size: 139 B |
Before Width: | Height: | Size: 151 B After Width: | Height: | Size: 150 B |
@ -1,10 +1,10 @@
|
||||
1:0.74609375
|
||||
1:0.501953125
|
||||
2:0.005859375
|
||||
3:0.005859375
|
||||
4:0.041015625
|
||||
5:0.0166015625
|
||||
6:0.2802734375
|
||||
7:0.001953125
|
||||
8:0.326171875
|
||||
9:0.041015625
|
||||
0:0.95703125
|
||||
4:0.83984375
|
||||
5:0.2294921875
|
||||
6:0.044921875
|
||||
7:0.041015625
|
||||
8:0.044921875
|
||||
9:0.1171875
|
||||
0:0.0625
|
||||
|
Before Width: | Height: | Size: 138 B After Width: | Height: | Size: 145 B |
Before Width: | Height: | Size: 130 B After Width: | Height: | Size: 138 B |
Before Width: | Height: | Size: 135 B After Width: | Height: | Size: 146 B |
Before Width: | Height: | Size: 136 B After Width: | Height: | Size: 142 B |
Before Width: | Height: | Size: 135 B After Width: | Height: | Size: 152 B |
Before Width: | Height: | Size: 134 B After Width: | Height: | Size: 157 B |
Before Width: | Height: | Size: 134 B After Width: | Height: | Size: 145 B |
Before Width: | Height: | Size: 141 B After Width: | Height: | Size: 146 B |
Before Width: | Height: | Size: 141 B After Width: | Height: | Size: 145 B |
Before Width: | Height: | Size: 133 B After Width: | Height: | Size: 150 B |
Before Width: | Height: | Size: 259 B After Width: | Height: | Size: 283 B |
@ -1,10 +1,10 @@
|
||||
1:0.77734375
|
||||
2:0.9296875
|
||||
3:0.013671875
|
||||
4:0.037109375
|
||||
5:0.0146484375
|
||||
6:0.08984375
|
||||
7:0.0078125
|
||||
8:0.0625
|
||||
9:0.029296875
|
||||
0:0.08984375
|
||||
1:0.53125
|
||||
2:0.0078125
|
||||
3:0.00390625
|
||||
4:0.787109375
|
||||
5:0.2353515625
|
||||
6:0.0546875
|
||||
7:0.00390625
|
||||
8:0.0546875
|
||||
9:0.111328125
|
||||
0:0.07421875
|
||||
|
BIN
tmp/cool/0_0.png
Before Width: | Height: | Size: 138 B After Width: | Height: | Size: 139 B |
BIN
tmp/cool/0_1.png
Before Width: | Height: | Size: 135 B After Width: | Height: | Size: 142 B |
BIN
tmp/cool/0_2.png
Before Width: | Height: | Size: 137 B After Width: | Height: | Size: 139 B |
BIN
tmp/cool/0_3.png
Before Width: | Height: | Size: 137 B After Width: | Height: | Size: 142 B |
BIN
tmp/cool/0_4.png
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 151 B |
BIN
tmp/cool/0_5.png
Before Width: | Height: | Size: 132 B After Width: | Height: | Size: 162 B |
BIN
tmp/cool/0_6.png
Before Width: | Height: | Size: 138 B After Width: | Height: | Size: 139 B |
BIN
tmp/cool/0_7.png
Before Width: | Height: | Size: 135 B After Width: | Height: | Size: 140 B |
BIN
tmp/cool/0_8.png
Before Width: | Height: | Size: 138 B After Width: | Height: | Size: 139 B |
BIN
tmp/cool/0_9.png
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 154 B |
@ -1,10 +1,10 @@
|
||||
1:0.828125
|
||||
1:0.537109375
|
||||
2:0.005859375
|
||||
3:0.005859375
|
||||
4:0.064453125
|
||||
5:0.744140625
|
||||
6:0.05859375
|
||||
4:0.80859375
|
||||
5:0.2314453125
|
||||
6:0.048828125
|
||||
7:0.001953125
|
||||
8:0.05859375
|
||||
9:0.93359375
|
||||
0:0.0859375
|
||||
8:0.048828125
|
||||
9:0.119140625
|
||||
0:0.06640625
|
||||
|
BIN
tmp/cool/1_0.png
Before Width: | Height: | Size: 133 B After Width: | Height: | Size: 141 B |
BIN
tmp/cool/1_1.png
Before Width: | Height: | Size: 132 B After Width: | Height: | Size: 134 B |
BIN
tmp/cool/1_2.png
Before Width: | Height: | Size: 138 B After Width: | Height: | Size: 138 B |
BIN
tmp/cool/1_3.png
Before Width: | Height: | Size: 138 B After Width: | Height: | Size: 135 B |
BIN
tmp/cool/1_4.png
Before Width: | Height: | Size: 137 B After Width: | Height: | Size: 149 B |
BIN
tmp/cool/1_5.png
Before Width: | Height: | Size: 151 B After Width: | Height: | Size: 154 B |
BIN
tmp/cool/1_6.png
Before Width: | Height: | Size: 135 B After Width: | Height: | Size: 142 B |
BIN
tmp/cool/1_7.png
Before Width: | Height: | Size: 137 B After Width: | Height: | Size: 141 B |
BIN
tmp/cool/1_8.png
Before Width: | Height: | Size: 135 B After Width: | Height: | Size: 142 B |
BIN
tmp/cool/1_9.png
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 144 B |
@ -1,10 +1,10 @@
|
||||
1:0.76171875
|
||||
2:0.0078125
|
||||
3:0.00390625
|
||||
4:0.044921875
|
||||
5:0.0185546875
|
||||
6:0.2919921875
|
||||
7:0.00390625
|
||||
8:0.34375
|
||||
9:0.037109375
|
||||
0:0.99609375
|
||||
1:0.96484375
|
||||
2:0.005859375
|
||||
3:0.005859375
|
||||
4:0.04296875
|
||||
5:0.0166015625
|
||||
6:0.7333984375
|
||||
7:0.001953125
|
||||
8:0.83203125
|
||||
9:0.04296875
|
||||
0:0.34765625
|
||||
|
BIN
tmp/cool/2_0.png
Before Width: | Height: | Size: 122 B After Width: | Height: | Size: 127 B |
BIN
tmp/cool/2_1.png
Before Width: | Height: | Size: 125 B After Width: | Height: | Size: 122 B |
BIN
tmp/cool/2_2.png
Before Width: | Height: | Size: 129 B After Width: | Height: | Size: 124 B |
BIN
tmp/cool/2_3.png
Before Width: | Height: | Size: 133 B After Width: | Height: | Size: 122 B |
BIN
tmp/cool/2_4.png
Before Width: | Height: | Size: 126 B After Width: | Height: | Size: 121 B |
BIN
tmp/cool/2_5.png
Before Width: | Height: | Size: 121 B After Width: | Height: | Size: 124 B |
BIN
tmp/cool/2_6.png
Before Width: | Height: | Size: 124 B After Width: | Height: | Size: 134 B |
BIN
tmp/cool/2_7.png
Before Width: | Height: | Size: 126 B After Width: | Height: | Size: 125 B |
BIN
tmp/cool/2_8.png
Before Width: | Height: | Size: 129 B After Width: | Height: | Size: 126 B |
BIN
tmp/cool/2_9.png
Before Width: | Height: | Size: 137 B After Width: | Height: | Size: 124 B |
BIN
tmp/cool/img.png
Before Width: | Height: | Size: 237 B After Width: | Height: | Size: 251 B |
@ -1,10 +1,10 @@
|
||||
1:0.984375
|
||||
2:0.005859375
|
||||
3:0.005859375
|
||||
4:0.04296875
|
||||
5:0.0166015625
|
||||
6:0.7392578125
|
||||
7:0.001953125
|
||||
8:0.8359375
|
||||
9:0.04296875
|
||||
0:0.34765625
|
||||
1:0.705078125
|
||||
2:0.046875
|
||||
3:0.8671875
|
||||
4:0.033203125
|
||||
5:0.0693359375
|
||||
6:0.037109375
|
||||
7:0.0126953125
|
||||
8:0.029296875
|
||||
9:0.064453125
|
||||
0:0.048828125
|
||||
|
BIN
tmp/fine/0_0.png
Before Width: | Height: | Size: 122 B After Width: | Height: | Size: 126 B |
BIN
tmp/fine/0_1.png
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 126 B |
BIN
tmp/fine/0_2.png
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 132 B |
BIN
tmp/fine/0_3.png
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 149 B |
BIN
tmp/fine/0_4.png
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 138 B |
BIN
tmp/fine/0_5.png
Before Width: | Height: | Size: 121 B After Width: | Height: | Size: 129 B |
BIN
tmp/fine/0_6.png
Before Width: | Height: | Size: 124 B After Width: | Height: | Size: 120 B |
BIN
tmp/fine/0_7.png
Before Width: | Height: | Size: 119 B After Width: | Height: | Size: 125 B |
BIN
tmp/fine/0_8.png
Before Width: | Height: | Size: 123 B After Width: | Height: | Size: 130 B |
BIN
tmp/fine/0_9.png
Before Width: | Height: | Size: 122 B After Width: | Height: | Size: 143 B |
@ -1,10 +1,10 @@
|
||||
1:0.748046875
|
||||
2:0.0078125
|
||||
3:0.00390625
|
||||
4:0.04296875
|
||||
5:0.0185546875
|
||||
6:0.2861328125
|
||||
7:0.00390625
|
||||
8:0.33203125
|
||||
9:0.0390625
|
||||
0:0.947265625
|
||||
1:0.72265625
|
||||
2:0.05859375
|
||||
3:0.865234375
|
||||
4:0.03515625
|
||||
5:0.0849609375
|
||||
6:0.052734375
|
||||
7:0.0087890625
|
||||
8:0.044921875
|
||||
9:0.068359375
|
||||
0:0.064453125
|
||||
|
BIN
tmp/fine/1_0.png
Before Width: | Height: | Size: 125 B After Width: | Height: | Size: 129 B |
BIN
tmp/fine/1_1.png
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 129 B |
BIN
tmp/fine/1_2.png
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 138 B |
BIN
tmp/fine/1_3.png
Before Width: | Height: | Size: 126 B After Width: | Height: | Size: 144 B |
BIN
tmp/fine/1_4.png
Before Width: | Height: | Size: 121 B After Width: | Height: | Size: 138 B |
BIN
tmp/fine/1_5.png
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 133 B |
BIN
tmp/fine/1_6.png
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 129 B |
BIN
tmp/fine/1_7.png
Before Width: | Height: | Size: 122 B After Width: | Height: | Size: 129 B |
BIN
tmp/fine/1_8.png
Before Width: | Height: | Size: 126 B After Width: | Height: | Size: 133 B |
BIN
tmp/fine/1_9.png
Before Width: | Height: | Size: 125 B After Width: | Height: | Size: 141 B |
@ -1,10 +0,0 @@
|
||||
1:0.7802734375
|
||||
2:0.0078125
|
||||
3:0.00390625
|
||||
4:0.044921875
|
||||
5:0.8310546875
|
||||
6:0.0673828125
|
||||
7:0.00390625
|
||||
8:0.0673828125
|
||||
9:0.8623046875
|
||||
0:0.091796875
|
BIN
tmp/fine/2_0.png
Before Width: | Height: | Size: 125 B |
BIN
tmp/fine/2_1.png
Before Width: | Height: | Size: 130 B |