Skip to content

Commit

Permalink
fix scraper
Browse files Browse the repository at this point in the history
  • Loading branch information
balvinderz committed Jun 19, 2021
1 parent 9e16c94 commit f14e989
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
Binary file modified app/release/app-release.apk
Binary file not shown.
30 changes: 24 additions & 6 deletions app/src/main/java/com/stuffbox/webscraper/scrapers/NewScraper.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
import com.stuffbox.webscraper.models.Quality;


import org.json.JSONArray;
import org.json.JSONObject;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class NewScraper extends Scraper{
private Document gogoAnimePageDocument ;
Expand All @@ -23,14 +27,28 @@ public ArrayList<Quality> getQualityUrls() {
Log.i("newScraperRunning","running");
String vidStreamUrl = gogoAnimePageDocument.getElementsByClass("play-video").get(0).getElementsByTag("iframe").get(0).attr("src");
Log.i("vidsteramurl is",vidStreamUrl);
vidStreamUrl = vidStreamUrl.replaceAll("streaming.php","ajax.php");
ArrayList<Quality> qualities = new ArrayList<>();

vidStreamUrl = vidStreamUrl.replaceAll("streaming.php","loadserver.php");
try {
Document page = Jsoup.connect(vidStreamUrl).ignoreContentType(true).get();
JSONObject jsonObject = new JSONObject(page.text());
String qualityUrl = ((JSONObject)jsonObject.getJSONArray("source").get(0)).getString("file");
String quality = "HD P";
ArrayList<Quality> qualities = new ArrayList<>();
qualities.add(new Quality(quality,qualityUrl));
// JSONObject jsonObject = new JSONObject(page.text());
for(Element element: page.getElementsByTag("script")) {
if(element.outerHtml().contains("playerInstance.setup"))
{
Pattern pattern = Pattern.compile("\\[\\.*.*");
Matcher matcher = pattern.matcher(element.outerHtml());
if (matcher.find())
{
Log.i("matched text is",element.outerHtml().substring(matcher.start(),matcher.end()));
String text = element.outerHtml().substring(matcher.start(),matcher.end()).replace("file","'file'").replace("label","'label'");
JSONArray array = new JSONArray(text);
String url = array.getJSONObject(0).getString("file");
String label = array.getJSONObject(0).getString("label");
qualities.add(new Quality(label,url));
}
}
}
return qualities;

} catch (Exception e) {
Expand Down

0 comments on commit f14e989

Please sign in to comment.