mirror of
https://github.com/akaessens/NoFbEventScraper
synced 2025-06-05 23:29:13 +02:00
@ -30,27 +30,37 @@ public class FbScraper extends AsyncTask<Void, Void, Void> {
|
|||||||
this.main = main;
|
this.main = main;
|
||||||
|
|
||||||
}
|
}
|
||||||
private String readFromLocJson(String location_json) {
|
private String fixLocation(String location_json) {
|
||||||
|
|
||||||
String name = "";
|
String name = "";
|
||||||
String street_address = "";
|
|
||||||
String postal_code = "";
|
|
||||||
String address_locality = "";
|
|
||||||
try {
|
try {
|
||||||
JSONObject reader = new JSONObject(location_json);
|
JSONObject reader = new JSONObject(location_json);
|
||||||
|
|
||||||
name = reader.getString("name");
|
name = reader.getString("name");
|
||||||
|
|
||||||
JSONObject address = reader.getJSONObject("address");
|
JSONObject address = reader.getJSONObject("address");
|
||||||
street_address = ", " + address.getString("streetAddress");
|
|
||||||
postal_code = ", " + address.getString("postalCode");
|
String type = address.getString("@type");
|
||||||
address_locality = " " + address.getString("addressLocality");
|
|
||||||
|
if (type.equals("PostalAddress"))
|
||||||
|
{
|
||||||
|
String postal_code = address.getString("postalCode");
|
||||||
|
String address_locality = address.getString("addressLocality");
|
||||||
|
String address_country = address.getString("addressCountry");
|
||||||
|
String street_address = address.getString("streetAddress");
|
||||||
|
|
||||||
|
return name + ", " + street_address + ", " + postal_code + " " + address_locality;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return name + street_address + postal_code + address_locality;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String fixTimezone(String time_in) {
|
private String fixTimezone(String time_in) {
|
||||||
@ -63,7 +73,7 @@ public class FbScraper extends AsyncTask<Void, Void, Void> {
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +94,7 @@ public class FbScraper extends AsyncTask<Void, Void, Void> {
|
|||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
@ -105,11 +115,9 @@ public class FbScraper extends AsyncTask<Void, Void, Void> {
|
|||||||
String event_end = fixTimezone(readFromJson(reader, "endDate"));
|
String event_end = fixTimezone(readFromJson(reader, "endDate"));
|
||||||
|
|
||||||
String event_description = fixLinks(readFromJson(reader, "description"));
|
String event_description = fixLinks(readFromJson(reader, "description"));
|
||||||
String location_json = readFromJson(reader, "location");
|
String location = fixLocation(readFromJson(reader, "location"));
|
||||||
|
|
||||||
|
|
||||||
String location = readFromLocJson(location_json);
|
|
||||||
|
|
||||||
if (event_name == null) {
|
if (event_name == null) {
|
||||||
this.event = null;
|
this.event = null;
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
|
Reference in New Issue
Block a user