Youtube Video Downloader

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • EYE4U
    Banned
    New Member
    • Oct 2008
    • 76

    Youtube Video Downloader

    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
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    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 ;)

    Comment

    • dmjpro
      Top Contributor
      • Jan 2007
      • 2476

      #3
      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.

      Code:
      import java.io.BufferedInputStream;
      import java.io.BufferedOutputStream;
      import java.io.FileOutputStream;
      import java.net.InetAddress;
      import java.net.InetSocketAddress;
      import java.net.Proxy;
      import java.net.SocketAddress;
      import java.net.URL;
      
      /*
       * To change this template, choose Tools | Templates
       * and open the template in the editor.
       */
      import java.net.URLConnection;
      
      /**
       *
       * @author Admin
       */
      public class SWfDowloader {
          public static void main(String a[]) throws Exception{
              String swf_path = "http://s.ytimg.com/yt/swf/watch_v8-vfl87635.swf";
              URL swf_url = new URL(swf_path);
              byte address[] = {(byte)144,(byte)16,(byte)192,(byte)245};
              SocketAddress socket_address = new InetSocketAddress(InetAddress.getByAddress(address),8080);
              Proxy proxy = new Proxy(Proxy.Type.HTTP,socket_address);
              URLConnection url_conn = swf_url.openConnection(proxy);
              url_conn.connect();
              BufferedInputStream swf_in_stream = new BufferedInputStream(url_conn.getInputStream());
              FileOutputStream swf_file = new FileOutputStream("d:/test.swf");
              BufferedOutputStream swf_out_stream = new BufferedOutputStream(swf_file);
              byte bytes[] = new byte[512];
              int read_bytes = 0;
              while((read_bytes=swf_in_stream.read(bytes))!=-1)
                  swf_out_stream.write(bytes, 0,read_bytes);
              
              swf_in_stream.close();
              swf_file.close();
              swf_out_stream.close();
          }
      }
      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 ;)

      Comment

      • EYE4U
        Banned
        New Member
        • Oct 2008
        • 76

        #4
        The swf file you are downloading is the flv player while we need the flv file not the swf file...

        ARUZ

        Comment

        • N002213F
          New Member
          • Sep 2007
          • 38

          #5
          they have a Java API; http://code.google.com/apis/youtube/...uide_java.html

          Comment

          • EYE4U
            Banned
            New Member
            • Oct 2008
            • 76

            #6
            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....

            Comment

            • dmjpro
              Top Contributor
              • Jan 2007
              • 2476

              #7
              Originally posted by EYE4U
              The swf file you are downloading is the flv player while we need the flv file not the swf file...

              ARUZ
              I didn't get you what you meant ;)
              What you need ..Flash View Player?

              Comment

              • EYE4U
                Banned
                New Member
                • Oct 2008
                • 76

                #8
                I need to download videos from youtube.. this is what i want.
                I didnt want to build a youtube client application...

                Comment

                • dmjpro
                  Top Contributor
                  • Jan 2007
                  • 2476

                  #9
                  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 ;)

                  Comment

                  • dmjpro
                    Top Contributor
                    • Jan 2007
                    • 2476

                    #10
                    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?

                    Comment

                    • dmjpro
                      Top Contributor
                      • Jan 2007
                      • 2476

                      #11
                      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?

                      Comment

                      • Alex434
                        New Member
                        • Sep 2025
                        • 1

                        #12
                        Если вы хотите сохранить видео с YouTube для просмотра без интернета, отличный вариант — использовать онлайн-сервис https://easytube.pro/. Это удобный и абсолютно бесплатный инструмент, с которым справится даже новичок. Всё, что нужно — скопировать ссылку на нужное видео, вставить её в специальное поле на сайте, выбрать формат (MP4, MP3 и другие) и нужное качество, после чего нажать кнопку скачивания. Через несколько секунд файл будет готов к загрузке.

                        Comment

                        Working...