0

I wanted to ask if there is a java code to directly extract a embedded video from a streaming site.

With some research I managed to find this solution: How to get direct link of remote video from embedded url within a url in Android using JSoup?

but in this solution there are errors in code, for example:

String url = "https://www.wunderground.com/webcams/cadot1/902/video.html";
int timeout = 100 * 1000;
// Extract video URL
 Document doc = Jsoup.connect(url).timeout(timeout).get();
Element script = doc.getElementById("inner-content")
    .getElementsByTag("script").last();
String content = script.data();
int indexOfUrl = content.indexOf("url");
int indexOfComma = content.indexOf(',', indexOfUrl);
String videoUrl = "https:" + content.substring(indexOfUrl + 6, indexOfComma 
- 1);
System.out.println(videoUrl);

I cant get last element:

    .getElementsByTag("script").last();

There is a tutorial or something that explain how to get embedded video url?

For expample this is the urlvideo: https://openload.co/embed/MB6RMqNrvp0/Episodio_017.mkv.mp4

and this is the embeddedvideourl: https://1fiag5y.oloadcdn.net/dl/l/9pL6teltc-w0jPxJ/MB6RMqNrvp0/Episodio_017.mkv.mp4?mime=true //I need this

Tnks.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
francesco bocci
  • 69
  • 2
  • 11

1 Answers1

0

It seems to me that you are trying to compare the DOM model that you have in browser developer tools and one retrieved by JSoup and they don't match.

Please note that developer tools will show you DOM as it is at the moment of inspection after all DHTML modifications applied by page JavaScript. JSoup loads page contents as they are loaded initially (equivalent to view page source in browser) and is not capable for JavaScript evaluation. So these two DOM models can be significantly different.

You should verify how to get your data against initial page state.

Aleh Maksimovich
  • 2,622
  • 8
  • 19