Skip to content

Commit f14e989

Browse files
committed
fix scraper
1 parent 9e16c94 commit f14e989

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

.idea/caches/build_file_checksums.ser

0 Bytes
Binary file not shown.

app/release/app-release.apk

-13 Bytes
Binary file not shown.

app/src/main/java/com/stuffbox/webscraper/scrapers/NewScraper.java

+24-6
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
import com.stuffbox.webscraper.models.Quality;
66

77

8+
import org.json.JSONArray;
89
import org.json.JSONObject;
910
import org.jsoup.Jsoup;
1011
import org.jsoup.nodes.Document;
12+
import org.jsoup.nodes.Element;
1113

1214
import java.util.ArrayList;
15+
import java.util.regex.Matcher;
16+
import java.util.regex.Pattern;
1317

1418
public class NewScraper extends Scraper{
1519
private Document gogoAnimePageDocument ;
@@ -23,14 +27,28 @@ public ArrayList<Quality> getQualityUrls() {
2327
Log.i("newScraperRunning","running");
2428
String vidStreamUrl = gogoAnimePageDocument.getElementsByClass("play-video").get(0).getElementsByTag("iframe").get(0).attr("src");
2529
Log.i("vidsteramurl is",vidStreamUrl);
26-
vidStreamUrl = vidStreamUrl.replaceAll("streaming.php","ajax.php");
30+
ArrayList<Quality> qualities = new ArrayList<>();
31+
32+
vidStreamUrl = vidStreamUrl.replaceAll("streaming.php","loadserver.php");
2733
try {
2834
Document page = Jsoup.connect(vidStreamUrl).ignoreContentType(true).get();
29-
JSONObject jsonObject = new JSONObject(page.text());
30-
String qualityUrl = ((JSONObject)jsonObject.getJSONArray("source").get(0)).getString("file");
31-
String quality = "HD P";
32-
ArrayList<Quality> qualities = new ArrayList<>();
33-
qualities.add(new Quality(quality,qualityUrl));
35+
// JSONObject jsonObject = new JSONObject(page.text());
36+
for(Element element: page.getElementsByTag("script")) {
37+
if(element.outerHtml().contains("playerInstance.setup"))
38+
{
39+
Pattern pattern = Pattern.compile("\\[\\.*.*");
40+
Matcher matcher = pattern.matcher(element.outerHtml());
41+
if (matcher.find())
42+
{
43+
Log.i("matched text is",element.outerHtml().substring(matcher.start(),matcher.end()));
44+
String text = element.outerHtml().substring(matcher.start(),matcher.end()).replace("file","'file'").replace("label","'label'");
45+
JSONArray array = new JSONArray(text);
46+
String url = array.getJSONObject(0).getString("file");
47+
String label = array.getJSONObject(0).getString("label");
48+
qualities.add(new Quality(label,url));
49+
}
50+
}
51+
}
3452
return qualities;
3553

3654
} catch (Exception e) {

0 commit comments

Comments
 (0)