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 :
[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.
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");
As you may know that different website have different video downloading strategies, some might give a real url in html file for directly download, others may just return video stream while click button or touch screen.
while so many different strategies on video download its really hard for you to find a universal way to fetch a real url to start a download task. But here I have an idea, not so smart, it can be very dumb:
1.play a video in the background(to let browser download that video in browser cache).
2.find that cache file and extract video file which you want.
for myself, I usually have some videos that I want but can not be downloaded straightly, thus I will use IE to play that video and find that video in IE temporary folder.
wish I could help you!