=Fixed Bug #10 GetSauce command incorrect output
Fixed multiple issues, stemming from change of E6 API
This commit is contained in:
@@ -23,7 +23,7 @@ public class CommandGetSauce extends Command
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
res.send(sauce.getSauce(input.args));
|
||||
res.send(sauce.getSauce(input.args).output());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -92,14 +92,12 @@ public class NetworkE6
|
||||
// tag by default. User-provided tags, therefore, will override it.
|
||||
// If order:score is provided, that will be honored over order:random.
|
||||
String res = HTTPUtils.sendGETRequest(API_ROOT + "tags=order:random%20" + input + "&limit=" + maxSearchResults_);
|
||||
|
||||
System.out.println("LOOK HERE: " + res);
|
||||
if(res != null)
|
||||
{
|
||||
|
||||
// Use class evaluation on an array of the response imageObject to be able to hold multiple.
|
||||
System.out.println("Still");
|
||||
E6ResponseObject imageObj = jsonParser_.fromJson(res, E6ResponseObject.class);
|
||||
System.out.println("Broken");
|
||||
// For now, we really just wanna display images and their source.
|
||||
// Append them all separately to a response string w/ some flavor text.
|
||||
if(imageObj.posts.length < 1)
|
||||
@@ -110,6 +108,7 @@ public class NetworkE6
|
||||
{
|
||||
for(int i = 0; i < imageObj.posts.length; ++i)
|
||||
{
|
||||
System.out.println(imageObj.posts.length);
|
||||
String [] TagsList = imageObj.posts[i].tags.general;
|
||||
blacklisted = false;
|
||||
for(int j = 0; j < blacklist.length; j++)
|
||||
@@ -133,9 +132,9 @@ public class NetworkE6
|
||||
image.editPostURL("https://e621.net/posts/" + imageObj.posts[i].id);
|
||||
if(imageObj.posts[i].tags.artist.length > 0)
|
||||
{
|
||||
String artists = "";
|
||||
for(int j = 0; j < imageObj.posts[i].tags.artist.length; j++)
|
||||
artists += imageObj.posts[i].tags.artist[j];
|
||||
String artists = imageObj.posts[i].tags.artist[0];
|
||||
for(int j = 1; j < imageObj.posts[i].tags.artist.length; j++)
|
||||
artists += ", " + imageObj.posts[i].tags.artist[j];
|
||||
image.editArtist(artists);
|
||||
}
|
||||
else
|
||||
@@ -190,6 +189,8 @@ public class NetworkE6
|
||||
|
||||
if(image.output().authorText != null)
|
||||
{
|
||||
System.out.println(image);
|
||||
System.out.println(image.toString());
|
||||
return image;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import dataStructures.GenericImage;
|
||||
import offline.Ref;
|
||||
import utils.HTTPUtils;
|
||||
|
||||
@@ -27,7 +28,7 @@ public class NetworkSauceNAO
|
||||
String [] ext_urls;
|
||||
}
|
||||
|
||||
public String getSauce(String input)
|
||||
public GenericImage getSauce(String input)
|
||||
{
|
||||
input = input.trim();
|
||||
input = input.replace("+", "%2B");
|
||||
@@ -39,11 +40,11 @@ public class NetworkSauceNAO
|
||||
String sauceUrl = sauce.results.get(0).data.ext_urls[0];
|
||||
if(sauceUrl.startsWith("https://e621.net/post/show/"))
|
||||
{
|
||||
System.out.println("id:" + sauceUrl.substring(26));
|
||||
System.out.println("HERE");
|
||||
return e6Sauce.getE6("id:" + sauceUrl.substring(27)).toString();
|
||||
return e6Sauce.getE6("id:" + sauceUrl.substring(27));
|
||||
}
|
||||
return sauce.results.get(0).data.ext_urls[0];
|
||||
GenericImage unknown = new GenericImage("", "","");
|
||||
return unknown;
|
||||
// return sauce.results.get(0).data.ext_urls[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user