473,396 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Youtube Video Downloader

75
Hi all,
I m going to make a Youtube Video Downloader in JAVA, but i dont know where to start and how to do this... i have googled a lot to find any help in this case but i didn't find any helpful material...

Thanx
ARUZ
Apr 5 '09 #1
10 18275
dmjpro
2,476 2GB
First you need to have the swf file then use URL class API then i think you can get the help.
If you want to incorporate the Java file with the Youtube player then i think it's not possible ;)
Ok i m also trying, let's see what happens with URL class ;)
Apr 6 '09 #2
dmjpro
2,476 2GB
See i tested this code but i could not able to download ..i able to save the SWF file but it's not playing and even not saying that this is an invalid file.
My code goes here.

Expand|Select|Wrap|Line Numbers
  1.  
  2. import java.io.BufferedInputStream;
  3. import java.io.BufferedOutputStream;
  4. import java.io.FileOutputStream;
  5. import java.net.InetAddress;
  6. import java.net.InetSocketAddress;
  7. import java.net.Proxy;
  8. import java.net.SocketAddress;
  9. import java.net.URL;
  10.  
  11. /*
  12.  * To change this template, choose Tools | Templates
  13.  * and open the template in the editor.
  14.  */
  15. import java.net.URLConnection;
  16.  
  17. /**
  18.  *
  19.  * @author Admin
  20.  */
  21. public class SWfDowloader {
  22.     public static void main(String a[]) throws Exception{
  23.         String swf_path = "http://s.ytimg.com/yt/swf/watch_v8-vfl87635.swf";
  24.         URL swf_url = new URL(swf_path);
  25.         byte address[] = {(byte)144,(byte)16,(byte)192,(byte)245};
  26.         SocketAddress socket_address = new InetSocketAddress(InetAddress.getByAddress(address),8080);
  27.         Proxy proxy = new Proxy(Proxy.Type.HTTP,socket_address);
  28.         URLConnection url_conn = swf_url.openConnection(proxy);
  29.         url_conn.connect();
  30.         BufferedInputStream swf_in_stream = new BufferedInputStream(url_conn.getInputStream());
  31.         FileOutputStream swf_file = new FileOutputStream("d:/test.swf");
  32.         BufferedOutputStream swf_out_stream = new BufferedOutputStream(swf_file);
  33.         byte bytes[] = new byte[512];
  34.         int read_bytes = 0;
  35.         while((read_bytes=swf_in_stream.read(bytes))!=-1)
  36.             swf_out_stream.write(bytes, 0,read_bytes);
  37.  
  38.         swf_in_stream.close();
  39.         swf_file.close();
  40.         swf_out_stream.close();
  41.     }
  42. }
  43.  
I think the part of the SWF file downloaded.you know when you play a video in Youtube then it takes time to play the full one ...but i am not sure that the whole content i am getting here .. you also try ...i also keep searching. Le's see what happens ;)
Apr 6 '09 #3
EYE4U
75
The swf file you are downloading is the flv player while we need the flv file not the swf file...

ARUZ
Apr 6 '09 #4
EYE4U
75
but they havnt included the feature for download :)
I have a youtube downloader on vb i m thinking to convert that into java.... may be that logic works for java too....
Apr 6 '09 #6
dmjpro
2,476 2GB
@EYE4U
I didn't get you what you meant ;)
What you need ..Flash View Player?
Apr 6 '09 #7
EYE4U
75
I need to download videos from youtube.. this is what i want.
I didnt want to build a youtube client application...
Apr 6 '09 #8
dmjpro
2,476 2GB
How do you incorporate your Java code into the Youtube player?
What i did that's not downloading the full one.
Let's try with another file..what my code says ;)
Apr 7 '09 #9
dmjpro
2,476 2GB
See..Just now i tried with one link.
"http://www.java2s.com/Code/JavaDownload/EJB-servlet-stateless-ear.zip"
I tried to download it using my code.
But it's not working :(
When i tried to unzip it then it said "unexpected end of archive" but it shown me the proper file structure.
Could anyone tell me what happened? ;)

One more thing .. The file was 17K and my calculations was also 17.48 K on the basis of read bytes :) I don't what went wrong?
Apr 7 '09 #10
dmjpro
2,476 2GB
I tried with one more link "http://www.prototypejs.org/assets/2008/1/25/prototype-1.6.0.2.js"
That's the plain text file so that i could check the easily how much left to download.
Right now i saw that some of the bytes left to download ... the same thing happened with ZIP file ;) What would be the reason? Where i did wrong so that it behaved like this?
Apr 7 '09 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: kn0ckturnal | last post by:
when i try to view video on youtube or other type video, it wont load and it saids: (from youtube) Hello, you either have JavaScript turned off or an old version of Macromedia's Flash Player....
2
by: anil2005 | last post by:
Hi Everyone, i am developing one portal, in which i need to integrate youtube website's video. youtube is providing one ifame code if i use that , i can successfully emmebed the video's in...
5
by: kevin | last post by:
If you go here http://www.youtube.com/ how do they put the plus button over the image? Also is it possible to include more the one button. Thanks... ----== Posted via Newsfeeds.Com -...
2
by: Jassim Rahma | last post by:
is there anyway to download the youtube videos into windows media format using c#?
0
by: ahmad | last post by:
New youtube video http://www.youtube.com/watch?v=2R31xnFeL2Q http://www.youtube.com/watch?v=tWxFZRgh664 http://www.youtube.com/watch?v=K20FaUQpCEk ...
7
by: alexus | last post by:
what's the best way to "extract" videos from youtube?
7
by: jeddiki | last post by:
Hi, As I am in Turkey at present, I can not see vidoes on youtube. So I have tried a few proxies but keep finding them slow or not working. So I have installed myphpProxy on my server under...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.