Friday, August 23, 2013

How to find the torrent for the legend you've got at opensubtitles.org using Isohunt web API

after getting the subtitle (see http://leonotepad.blogspot.com.br/2013/08/how-to-search-and-retrieve-subtitle.html), now it's time to find the torrent.

Isohunt has some nice web API.

package movies.backend;

import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;

import flexjson.JSONDeserializer;

public class IsohuntTorrentSearch {

    /**
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        URL url = new URL("http://ca.isohunt.com/js/json.php?ihq="+URLEncoder.encode("True.Blood.S06E01.Who.Are.You.Really.720p","UTF-8")+"&start=21&rows=20&sort=seeds");
        Map json = (Map)new JSONDeserializer().deserialize(new InputStreamReader(url.openStream()));
        Map items = (Map)json.get("items");
        List list = (List)items.get("list");
        System.out.println(list.get(0));
        Map item = (Map)list.get(0);
        System.out.println(item.get("tracker_url"));
    }
}

No comments:

Post a Comment