1
0
mirror of https://github.com/akaessens/NoFbEventScraper synced 2025-06-05 23:29:13 +02:00

switch to m.facebook scraping

more descriptive toolbar button string
update unit tests
This commit is contained in:
akaessens
2020-08-26 16:45:33 +02:00
parent 98ab900b3d
commit d60717f0b7
4 changed files with 9 additions and 16 deletions

View File

@ -36,7 +36,7 @@ public class MainActivityUnitTest {
mInstrumentation.removeMonitor(monitor); mInstrumentation.removeMonitor(monitor);
final String exp = "https://www.facebook.com/events/261145401687844"; final String exp = "https://m.facebook.com/events/261145401687844";
String url = "https://www.facebook.com/events/261145401687844"; String url = "https://www.facebook.com/events/261145401687844";
String act = mainActivity.checkURI(url); String act = mainActivity.checkURI(url);
@ -53,6 +53,10 @@ public class MainActivityUnitTest {
url = "https://www.facebook.com/events/261145401687844/?active_tab=discussion"; url = "https://www.facebook.com/events/261145401687844/?active_tab=discussion";
act = mainActivity.checkURI(url); act = mainActivity.checkURI(url);
assertEquals(exp, act); assertEquals(exp, act);
url = "https://www.facebook.com/events/261145401687844?reflink_something";
act = mainActivity.checkURI(url);
assertEquals(exp, act);
} }
@Test @Test

View File

@ -202,18 +202,6 @@ public class MainActivity extends AppCompatActivity {
return null; return null;
} }
public static boolean isNumeric(String strNum) {
if (strNum == null) {
return false;
}
try {
double d = Double.parseDouble(strNum);
} catch (NumberFormatException e) {
//e.printStackTrace();
return false;
}
return true;
}
String checkURI(String str) String checkURI(String str)
{ {
try { try {
@ -223,7 +211,7 @@ public class MainActivity extends AppCompatActivity {
if (str.matches(".*(facebook.com/events/[0-9]*).*")) { if (str.matches(".*(facebook.com/events/[0-9]*).*")) {
return str.replaceAll(".*(facebook.com/events/[0-9]*).*", return str.replaceAll(".*(facebook.com/events/[0-9]*).*",
"https://www.$1"); "https://m.$1");
} }
else { else {
error("Error: Invalid URL"); error("Error: Invalid URL");

View File

@ -11,7 +11,7 @@
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar" android:id="@+id/app_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="200dp" android:layout_height="180dp"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
@ -58,7 +58,7 @@
app:layout_anchor="@id/app_bar" app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|end" app:layout_anchorGravity="bottom|end"
app:icon="@drawable/ic_content_paste" app:icon="@drawable/ic_content_paste"
android:text="@android:string/paste"/> android:text="@string/paste_button"/>
<include layout="@layout/content_main" /> <include layout="@layout/content_main" />

View File

@ -5,6 +5,7 @@
<string name="add_link_hint">Event link</string> <string name="add_link_hint">Event link</string>
<string name="add_link_helper">Paste facebook link to the event.</string> <string name="add_link_helper">Paste facebook link to the event.</string>
<string name="add_to_calendar">Add to calendar</string> <string name="add_to_calendar">Add to calendar</string>
<string name="paste_button">Paste from clipboard</string>
<string name="description_heading">Description</string> <string name="description_heading">Description</string>
<string name="description_text">This application was developed to be used without a facebook account. <string name="description_text">This application was developed to be used without a facebook account.