I want to download videos from you tube in android by programmatically..Still now i can able to stream these you tube videos.I searched in Internet..But there is no perfect solution for me..Please suggest that possible solutions for that issue..Thanks
Asked
Active
Viewed 6,443 times
3
-
1Please give me that some idea regards to that issue – Kalai Sep 26 '12 at 10:06
-
What have you tried? Where do you get stuck? Have you tried to do some research regarding this issue? Show us some code. Stackoverflow isn't a place for asking people to code your application **for** you. – Tobias Moe Thorstensen Sep 26 '12 at 10:32
-
Pretty sure this is against YouTube's TOS – MikeIsrael Jul 29 '13 at 12:22
1 Answers
4
Check this out. I use this function to extract the direct download links from a youtube video (it returns an array with links). All you need to do is to get the html code of the video (not the mobile version!) using this:
// url = youtube link (e.g. http://www.youtube.com/watch?v=fJ9rUzIMcZQ)
public String DownloadText(String url) throws IOException{
String userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0.1)";
HttpClient client = new DefaultHttpClient();
client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, userAgent);
HttpGet request = new HttpGet(url);
HttpResponse response = client.execute(request);
String html = "";
InputStream in = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder str = new StringBuilder();
String line = null;
while((line = reader.readLine()) != null)
{
str.append(line);
}
in.close();
html = str.toString();
return html;
}
-
Which tag should i use to download the video? I mean in which tag i can find the direct download url? – Mitesh Shah Apr 08 '15 at 10:21
-
Unfortunately, there is no tag that holds the direct link. The flash object holds all of the needed parameters, and you need to extract them and reproduce the direct link. – eviabs Apr 10 '15 at 23:12
-
Ok. Thank you. I got it. I needed to create the new link from the different tags. Finally, i have make it – Mitesh Shah Apr 15 '15 at 06:13
-
-
@MiteshShah Bro, i am also in need of help to find direct link to download with download manager from youtube link, please please help me all of you guys – Pir Fahim Shah Sep 15 '17 at 10:37