Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the correct url to the video file from an embedded video?

I want to get the actual Video File Url from an embedded video on any website. It essentially is not YouTube. It can be any website. I am coding for android on Java.

For Example : The thing I want to do is same as this IDM button does :

IDM "Download this video" Button

[Actually not the same because the button there captures a network stream when it gets started by the player. But I want to get the file straight from the player.] Is there a way to attain this? Can Any external Library [e.g. Jsoup] do this?

I am already using Jsoup to get some other contents of the page but I have no idea how to do this.

like image 753
Writwick Avatar asked Jun 17 '13 03:06

Writwick


1 Answers

If your using jsoup you can get the url quite easily. Just use jsoup to select all the possible video tags (<iframe>, <videos>, <embed>, etc). Then get the src attribute and store that where you want it:

Example

//Standard Jsoup search
Elements iframes = body.select("iframe");

/*Gets the src of all the iframes or other tag, and if you have
multiple videos you might have to do this in a for loop.*/    
String videoURL = iframes.attr("src");
like image 125
David Liaw Avatar answered Oct 16 '22 14:10

David Liaw