mirror of
https://github.com/akaessens/NoFbEventScraper
synced 2025-06-05 23:29:13 +02:00
@ -17,7 +17,6 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.google.android.material.textfield.TextInputLayout;
|
import com.google.android.material.textfield.TextInputLayout;
|
||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
@ -30,7 +29,6 @@ import java.time.format.DateTimeFormatter;
|
|||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private Button paste_button;
|
private Button paste_button;
|
||||||
private Button cancel_button;
|
|
||||||
private Button ok_button;
|
private Button ok_button;
|
||||||
|
|
||||||
private TextInputEditText field_uri_input;
|
private TextInputEditText field_uri_input;
|
||||||
@ -200,37 +198,22 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
// check for a valid uri
|
// check for a valid uri
|
||||||
new URL(str).toURI();
|
new URL(str).toURI();
|
||||||
|
|
||||||
String eventId = null;
|
if (str.matches(".*(facebook.com/events/[0-9]*).*")) {
|
||||||
|
return str.replaceAll(".*(facebook.com/events/[0-9]*).*",
|
||||||
// check for facebook uri
|
"https://www.$1");
|
||||||
if (str.contains("facebook.com/events/")) {
|
|
||||||
|
|
||||||
// find event id
|
|
||||||
String[] separated = str.split("/");
|
|
||||||
for (int i = 0; i < separated.length; i++) {
|
|
||||||
if (separated[i].length() > 8 && isNumeric(separated[i])) {
|
|
||||||
eventId = separated[i];
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
error("Error: Invalid URL");
|
||||||
|
clear(false);
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
if (eventId == null) // no event id found
|
|
||||||
{
|
|
||||||
throw new Exception();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new Exception();
|
|
||||||
}
|
|
||||||
|
|
||||||
String input_uri = "https://www.facebook.com/events/" + eventId;
|
|
||||||
str = input_uri;
|
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
clear(false);
|
|
||||||
error("Error: Invalid URL");
|
error("Error: Invalid URL");
|
||||||
str = "";
|
clear(false);
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startScraping() {
|
public void startScraping() {
|
||||||
@ -251,7 +234,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
clear(false);
|
|
||||||
error("Error: Invalid URL");
|
error("Error: Invalid URL");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user