fixed errors on parsing text due to JSON legacy compatibilities process in the REDDIT JSON API.
from https://www.reddit.com/dev/api : "response body encoding For legacy reasons, all JSON response bodies currently have <, >, and & replaced with <, >, and &, respectively. If you wish to opt out of this behaviour, add a raw_json=1 parameter to your request."
This commit is contained in:
parent
f2259f82d7
commit
b0e6f33b87
@ -1,4 +1,4 @@
|
|||||||
#Mon, 15 Jul 2019 21:54:15 +0200
|
#Tue, 06 Aug 2019 11:12:49 +0200
|
||||||
|
|
||||||
|
|
||||||
C\:\\Users\\louis\\Documents\\GitHub\\twitter_techsupportgore_bot\\reddit_reposter_bot=
|
C\:\\Users\\louis\\Documents\\GitHub\\twitter_techsupportgore_bot\\reddit_reposter_bot=
|
||||||
|
@ -67,8 +67,8 @@ public final class ConfigFileReader {
|
|||||||
/**
|
/**
|
||||||
* Read the config file.
|
* Read the config file.
|
||||||
*
|
*
|
||||||
* @throws TwitterTechSupportGoreBot.exceptions.NotSufficientRights
|
* @throws RedditReposterBot.exceptions.NoSuchFile
|
||||||
* @throws TwitterTechSupportGoreBot.exceptions.NoSuchFile
|
* @throws RedditReposterBot.exceptions.NotSufficientRights
|
||||||
*/
|
*/
|
||||||
public void readConfigFile() throws NoSuchFile, NotSufficientRights {
|
public void readConfigFile() throws NoSuchFile, NotSufficientRights {
|
||||||
if (!new File(CONFIGFILE).exists()) {
|
if (!new File(CONFIGFILE).exists()) {
|
||||||
@ -93,8 +93,7 @@ public final class ConfigFileReader {
|
|||||||
*
|
*
|
||||||
* @param id the property id.
|
* @param id the property id.
|
||||||
* @return the properties.
|
* @return the properties.
|
||||||
*
|
* @throws RedditReposterBot.exceptions.NoSuchProperty
|
||||||
* @throws TwitterTechSupportGoreBot.exceptions.NoSuchProperty
|
|
||||||
*/
|
*/
|
||||||
public String getProperties(String id) throws NoSuchProperty {
|
public String getProperties(String id) throws NoSuchProperty {
|
||||||
if (!this.prop.containsKey(id)) {
|
if (!this.prop.containsKey(id)) {
|
||||||
|
@ -129,12 +129,12 @@ public class Hypervisor {
|
|||||||
* @return the instance.
|
* @return the instance.
|
||||||
*
|
*
|
||||||
* @throws java.lang.ClassNotFoundException
|
* @throws java.lang.ClassNotFoundException
|
||||||
* @throws TwitterTechSupportGoreBot.exceptions.NotSufficientRights
|
* @throws RedditReposterBot.exceptions.NotSufficientRights
|
||||||
* @throws java.sql.SQLException
|
* @throws java.sql.SQLException
|
||||||
* @throws java.io.IOException
|
* @throws java.io.IOException
|
||||||
* @throws TwitterTechSupportGoreBot.exceptions.NoSuchFile
|
* @throws RedditReposterBot.exceptions.NoSuchFile
|
||||||
* @throws TwitterTechSupportGoreBot.exceptions.NoSuchProperty
|
* @throws RedditReposterBot.exceptions.NoSuchProperty
|
||||||
* @throws TwitterTechSupportGoreBot.exceptions.NoSuchOrder
|
* @throws RedditReposterBot.exceptions.NoSuchOrder
|
||||||
*/
|
*/
|
||||||
public static Hypervisor getSingleton()
|
public static Hypervisor getSingleton()
|
||||||
throws ClassNotFoundException, NotSufficientRights,
|
throws ClassNotFoundException, NotSufficientRights,
|
||||||
@ -399,8 +399,7 @@ public class Hypervisor {
|
|||||||
* Set working directory.
|
* Set working directory.
|
||||||
*
|
*
|
||||||
* @param tempDir the path to the working directory.
|
* @param tempDir the path to the working directory.
|
||||||
*
|
* @throws RedditReposterBot.exceptions.NotSufficientRights
|
||||||
* @throws TwitterTechSupportGoreBot.exceptions.NotSufficientRights
|
|
||||||
*/
|
*/
|
||||||
public void setWorkDir(String tempDir) throws NotSufficientRights {
|
public void setWorkDir(String tempDir) throws NotSufficientRights {
|
||||||
this.workingDirectory = tempDir;
|
this.workingDirectory = tempDir;
|
||||||
|
@ -34,7 +34,7 @@ public class RedditReposterBot {
|
|||||||
/**
|
/**
|
||||||
* Version of the application.
|
* Version of the application.
|
||||||
*/
|
*/
|
||||||
private static final String VERSION = "0.9.1";
|
private static final String VERSION = "1.0.1";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launch the Hypervisor.
|
* Launch the Hypervisor.
|
||||||
|
@ -157,9 +157,17 @@ public final class RedditExtractor {
|
|||||||
String title = childData.get("title") != null
|
String title = childData.get("title") != null
|
||||||
? childData.get("title").toString()
|
? childData.get("title").toString()
|
||||||
: this.sub.getName();
|
: this.sub.getName();
|
||||||
title = title.replace("\"", "").replace("\\", "\"");
|
title = title
|
||||||
|
.replace("\"", "")
|
||||||
|
.replace("\\", "\"")
|
||||||
|
.replace("<", "<")
|
||||||
|
.replace(">", ">")
|
||||||
|
.replace("&", "&");
|
||||||
String author = childData.get("author") != null
|
String author = childData.get("author") != null
|
||||||
? childData.get("author").toString() : "anonymous";
|
? childData.get("author").toString()
|
||||||
|
.replace("<", "<")
|
||||||
|
.replace(">", ">")
|
||||||
|
.replace("&", "&") : "anonymous";
|
||||||
author = author.replace("\"", "");
|
author = author.replace("\"", "");
|
||||||
boolean quarantine = childData.get("quarantine")
|
boolean quarantine = childData.get("quarantine")
|
||||||
.getAsBoolean();
|
.getAsBoolean();
|
||||||
@ -178,7 +186,7 @@ public final class RedditExtractor {
|
|||||||
.get(0).toString()).getAsJsonObject();
|
.get(0).toString()).getAsJsonObject();
|
||||||
JsonObject urlSrc = new JsonParser().parse(source
|
JsonObject urlSrc = new JsonParser().parse(source
|
||||||
.get("source").toString()).getAsJsonObject();
|
.get("source").toString()).getAsJsonObject();
|
||||||
url = urlSrc.get("url").toString().replace("amp;", "")
|
url = urlSrc.get("url").toString().replace("&", "&")
|
||||||
.replace("\"", "");
|
.replace("\"", "");
|
||||||
} catch (NullPointerException n) {
|
} catch (NullPointerException n) {
|
||||||
url = childData.get("url").getAsString();
|
url = childData.get("url").getAsString();
|
||||||
|
Loading…
Reference in New Issue
Block a user