Speed up uTorrent

Source

To speed up uTorrent it is important to add more trackers to the torrent that you are downloading (as per Wikipedia "a tracker is a server that assists in the communication between peers using the BT protocol").

To add more trackers press the right button on the torrent you are downloading, select Properties from the menu and in the General tab add your trackers.

But wait a minute! Where can you find these trackers? Well, in this post I will show you a simple program in Java/Swing that retrieves and parses (using Jsoup - please look at this article) a list of trackers from a website called btsnoop.com.

Please note that this article only has the intent to show you how simple it is extracting information in Java from remote websites. Remember that downloading copyrighted or illegal material is against the law in every country around the world and I would ask you to ensure you have the right to download the files you select.

When the data is fetched using Jsoup's connect API, it is converted in org.jsoup.nodes.Document:

doc = Jsoup.connect("http://bitsnoop.com/trackers/")   
              .userAgent("Mozilla").cookie("auth", "token")   
              .timeout(10000).get();

and finally parsed (always using Jsoup):

 private static String extractUrls(Document doc) {   
       StringBuffer sb = new StringBuffer();   
       Element content = doc.getElementById("text");   
       Element table = content.getElementsByTag("table").first();   
       Elements trs = table.getElementsByTag("tr");   
       for (int i = 1; i < trs.size(); i++) {   
         Element td = trs.get(i).getElementsByTag("td").get(1);   
         sb.append(td.text() + "\n\n");   
       }   
       return sb.toString();   
    }   

A list of urls relative to the trackers will be displayed. At this point the only thing you have to do is to press the "Copy All" button and paste the list in the uTorrent General Tab as above described (of course from this list you can select only the trackers that you consider ok). That's it :)
To compile and run the application follow these instructions:

  • Download Jsoup's core-library from here and save it in a folder (I used the version 1.6.3)
  • In the same folder open with a text editor (or Eclipse/NetBeans/Intellij if you prefer) a file called BTSnooper.java and paste the code below
  • Compile the code with: javac -cp jsoup-1.6.3.jar BTSnooper.java
  • And finally run the application with: java -cp .:jsoup-1.6.3.jar BTSnooper

 import java.awt.GridBagConstraints;  
 import java.awt.GridBagLayout;  
 import java.awt.event.ActionEvent;  
 import java.awt.event.ActionListener;  
 import java.io.IOException;  
 import javax.swing.JButton;  
 import javax.swing.JFrame;  
 import javax.swing.JPanel;  
 import javax.swing.JScrollPane;  
 import javax.swing.JTextArea;  
 import javax.swing.SwingUtilities;  
 import org.jsoup.Jsoup;  
 import org.jsoup.nodes.Document;  
 import org.jsoup.nodes.Element;  
 import org.jsoup.select.Elements;  


 public class BTSnooper {  

      private static JTextArea textArea;  

      public static void main(String[] args) {  

           JFrame.setDefaultLookAndFeelDecorated(true);  

           JFrame frame = new JFrame("BTSnooper");  

           JPanel panel = new JPanel(new GridBagLayout());  
           frame.add(panel);  
           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  

           textArea = new JTextArea(40, 40);  
           textArea.setEditable(false);  

           JScrollPane scrollPane = new JScrollPane(textArea,  
                     JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,  
                     JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);  
           textArea.setLineWrap(true);  

           JButton button = new JButton("Refresh");  
           button.addActionListener(new ActionListener() {  
                @Override  
                public void actionPerformed(ActionEvent e) {  
                     refresh();  
                }  
           });  

           JButton button2 = new JButton("Copy All");  
           button2.addActionListener(new ActionListener() {  
                @Override  
                public void actionPerformed(ActionEvent e) {  
                     textArea.selectAll();  
                     textArea.copy();  
                }  
           });  

           SwingUtilities.invokeLater(new Runnable() {  
                public void run() {  
                     textArea.setCaretPosition(0);  
                }  
           });  

           GridBagConstraints c = new GridBagConstraints();  
           c.fill = GridBagConstraints.HORIZONTAL;  
           c.gridx = 0;  
           c.gridy = 0;  
           panel.add(button, c);  
           c.gridy = 1;  
           panel.add(button2, c);  
           c.gridy = 2;  
           panel.add(scrollPane, c);  
           frame.pack();  
           frame.setVisible(true);  
           refresh();  
      }  

      private static void refresh() {  
           textArea.setText("Loading...");  
           textArea.setText(fetchData());  
      }  

      private static String fetchData() {  

           Document doc = null;  

           try {  
                doc = Jsoup.connect("http://bitsnoop.com/trackers/")  
                          .userAgent("Mozilla").cookie("auth", "token")  
                          .timeout(10000).get();  
           } catch (IOException e) {  
                e.printStackTrace();  
           }  
           return extractUrls(doc);  
      }  

      private static String extractUrls(Document doc) {  

           StringBuffer sb = new StringBuffer();  

           Element content = doc.getElementById("text");  

           Element table = content.getElementsByTag("table").first();  

           Elements trs = table.getElementsByTag("tr");  

           for (int i = 1; i < trs.size(); i++) {  
                Element td = trs.get(i).getElementsByTag("td").get(1);  
                sb.append(td.text() + "\n\n");  
           }  

           return sb.toString();  
      }  
 }  

More by this Author

  • How To Parse Html In Java - Part 2
    0

    In the first article we saw how to parse html in Java using the libraries: Jsoup HtmlCleaner Internal Swing SDK parser This time we will see other useful libraries to parse html like: TagSoup HTML Parser...

  • How to Create a Chat Room in Java
    0

    A quick and easy way to build your free and personal chat room in Java.

  • How To Parse Html In Java
    7

    Examples and information about how to parse html in Java using: Jsoup, HtmlCleaner, Internal Swing SDK parser, TagSoup, HTML Parser, JTidy, NekoHtml, Cobra, HotSAX and Jerico HTML Parser.


Comments

No comments yet.

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working