Guest User

Untitled

a guest
Dec 14th, 2019
340
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package org.videoScrap;
  2.  
  3. import java.io.BufferedInputStream;
  4. import java.io.File;
  5. import java.io.FileOutputStream;
  6. import java.io.IOException;
  7. import java.net.URL;
  8. import java.util.Arrays;
  9. import java.util.List;
  10. import java.util.stream.Collectors;
  11. import org.jsoup.Jsoup;
  12. import org.jsoup.nodes.Document;
  13. import org.jsoup.nodes.Element;
  14.  
  15. public class App {
  16. public static void main(String[] args) {
  17. for (int i = Integer.parseInt(args[0]); i >= 1; i--) {
  18. System.out.println(String.format("Page: %s", i));
  19. String url = String.format("https://sexycandidgirls.com/page/%s", i);
  20. try {
  21. Document document = Jsoup.connect(url).get();
  22. for (Element aTag : document.select(".g1-frame")) {
  23. Document doc = Jsoup.connect(aTag.attr("href")).get();
  24. for (Element iFrame : doc.select("iframe")) {
  25. if (iFrame.hasAttr("data-lazy-src")) {
  26. String lastUrl = iFrame.absUrl("data-lazy-src");
  27. Document videoDoc = Jsoup.connect(lastUrl).get();
  28. List<String> data = Arrays
  29. .asList(videoDoc.select("script").get(11).toString().split("\\|"));
  30.  
  31. String id = data.stream().filter(word -> word.length() == 60)
  32. .collect(Collectors.joining(""));
  33. String fs = data.stream().filter(word -> word.startsWith("fs"))
  34. .collect(Collectors.joining(""));
  35.  
  36. if (!checkIfAlreadyExists(id)) {
  37. System.out.println("Does not exists");
  38. String videoUrl = String.format("https://%s.gounlimited.to/%s/v.mp4", fs, id);
  39. BufferedInputStream bufferedInputStream = new BufferedInputStream(
  40. new URL(videoUrl).openStream());
  41. FileOutputStream fileOutputStream = new FileOutputStream(String
  42. .format("C:/Users/Haphk/Desktop/Coding/Java/video-scrap/videos/%s.mp4", id));
  43.  
  44. int count = 0;
  45. byte[] b = new byte[1024];
  46.  
  47. while ((count = bufferedInputStream.read(b)) != -1) {
  48. fileOutputStream.write(b, 0, count);
  49. }
  50.  
  51. fileOutputStream.flush();
  52. fileOutputStream.close();
  53. } else {
  54. System.out.println("Already exists");
  55. }
  56. }
  57. }
  58. }
  59. } catch (
  60.  
  61. IOException e) {
  62. e.printStackTrace();
  63. }
  64. }
  65. }
  66.  
  67. public static Boolean checkIfAlreadyExists(String input) {
  68. File folder = new File("C:/Users/Haphk/Desktop/Coding/Java/video-scrap/videos/");
  69. File[] listOfFiles = folder.listFiles();
  70. List<String> currentFileNames = Arrays.asList(listOfFiles).stream()
  71. .map(file -> file.getName().substring(0, file.getName().length() - 13)).collect(Collectors.toList());
  72. return currentFileNames.stream().anyMatch(id -> id.trim().equals(input.substring(0, input.length() - 9)));
  73. }
  74. }
RAW Paste Data