diff --git a/README.md b/README.md index 2a8df97..35c397f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A cli tool for searching torrent sites and streaming using peerflix. -It currently supports kickasstorrents, 1337x, seedpeer, Rarbg, The Pirate Bay, YTS, Extratorrent, Limetorrents, nyaa.se, tokyotosho & Cpasbien. +It currently supports kickasstorrents, 1337x, seedpeer, Rarbg, The Pirate Bay, YTS, Extratorrent, Limetorrents, nyaa.se, tokyotosho, Cpasbien & eztv. Want more ? Create an issue with a request, Alternatively you can contribute your own scrapers. diff --git a/lib/cli.js b/lib/cli.js index f9aa746..f53cdcc 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -98,6 +98,7 @@ conf.set("nyaa_url", "http://www.nyaa.se"); conf.set("tokyotosho_url", "https://www.tokyotosho.info"); conf.set("cpasbien_url", "http://www.cpasbien.pw"); + conf.set("eztv_url", "https://www.eztv.ag"); conf.set("rarbg_api_url", "https://torrentapi.org"); conf.set("peerflix_player", "--vlc"); conf.set("peerflix_player_args", ""); @@ -121,6 +122,10 @@ conf.set("cpasbien_url", "http://www.cpasbien.pw"); } + if(!conf.get("eztv_url")){ + conf.set("eztv_url", "https://www.eztv.ag"); + } + if(!conf.get("peerflix_path")){ conf.set("peerflix_path", ""); } diff --git a/lib/eztv.js b/lib/eztv.js new file mode 100644 index 0000000..b5b6c55 --- /dev/null +++ b/lib/eztv.js @@ -0,0 +1,74 @@ +var Q = require('q'); +var request = require("request"); +var cheerio = require('cheerio'); +var moment = require('moment'); +var util = require('util'); +var fs = require('fs'); + +module.exports = { + search: function(query, eztv_url) { + + var torrent_search = query; + var search_query = torrent_search.split(' ').join('-'); + var search_url = eztv_url + "/search/" + search_query; + var count = 1; + var deferred = Q.defer(); + var data_content = {}; + var torrent_content = []; + + request({ url: search_url, headers:{ "User-Agent": "request"}}, function(err, response, body){ + +// fs.writeFileSync("/home/serge/torrentsearch/out2.html", body); +// fs.readFile("/home/serge/torrentsearch/out.html", function(err, body){ +// var response = { statusCode: 200 }; + try { + + if(!err && response.statusCode === 200){ + + var eztv_link, torrent_title, torrent_size, torrent_seeds, torrent_leech, date_added; + $ = cheerio.load(body); + if($("tr.forum_header_border").length > 0) { + + $("tr.forum_header_border").each(function(index, torrent){ + eztv_link = $(torrent).find("a.magnet").attr('href'); + torrent_title = $(torrent).find("a.epinfo").text(); + torrent_size = $(torrent).find("a.epinfo").attr("title").match(/\([^)]+\)$/)[0].slice(1,-1); + //torrent_seeds = $(torrent).find(".seed").text(); + //torrent_leech = $(torrent).find(".leech").text(); + date_added = $("td.forum_thread_post_end", torrent).prev().text(); + + data_content = { + torrent_num: count, + title: torrent_title, + category: "", + seeds: torrent_seeds, + leechs: torrent_leech, + size: torrent_size, + torrent_link: eztv_link, + date_added: date_added + }; + + torrent_content.push(data_content); + + deferred.resolve(torrent_content); + count++; + }); + + } else { + deferred.reject("No torrents found"); + } + + } else { + deferred.reject("There was a problem loading Eztv"); + } + + } catch(e) { + deferred.reject(e.toString()); + } + + }); + + return deferred.promise; + + } +}; diff --git a/lib/main.js b/lib/main.js index baf3c42..b792ced 100755 --- a/lib/main.js +++ b/lib/main.js @@ -19,6 +19,7 @@ var nyaa = require('./nyaa.js'); var tokyotosho = require('./tokyotosho.js'); var cpasbien = require('./cpasbien.js'); + var eztv = require('./eztv.js'); var tparse = require('./torrent_parse.js'); var language = require('../lang.js'); var chalk = require('chalk'); @@ -65,6 +66,7 @@ btdigg_url = config_object.btdigg_url; tokyotosho_url = config_object.tokyotosho_url; cpasbien_url = config_object.cpasbien_url; + eztv_url = config_object.eztv_url; strike_url = config_object.strike_url; peerflix_player = config_object.peerflix_player; peerflix_player_arg = config_object.peerflix_player_args; @@ -124,6 +126,9 @@ if(cpasbien_url){ sites.push({'key': "cpasbien", name: chalk.magenta('Cpasbien'), value: "cpasbien"}); } + if(eztv_url){ + sites.push({'key': "eztv", name: chalk.magenta('Eztv'), value: "eztv"}); + } if(history === "true"){ sites.push({'key': "print history", name: chalk.blue('Print history'), value: "print history"}); } @@ -191,6 +196,8 @@ tokyotoshoSearch(search); } else if(site === "cpasbien"){ cpasbienSearch(search); + } else if(site === "eztv"){ + eztvSearch(search); } } @@ -322,6 +329,15 @@ }); } + function eztvSearch(query){ + eztv.search(query, eztv_url).then( + function (data) { + onResolve(data); + }, function (err) { + onReject(err); + }); + } + function onResolve(data) { for (var idx in data) { var torrent = data[idx];