From 14405bc439bc246dba0a4386c8f053e2c7207436 Mon Sep 17 00:00:00 2001 From: Pablo Gonzalez Date: Sat, 6 Sep 2014 17:18:30 +0000 Subject: [PATCH] Create app.js --- YTS-720p.stm/app.js | 53 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 YTS-720p.stm/app.js diff --git a/YTS-720p.stm/app.js b/YTS-720p.stm/app.js new file mode 100644 index 0000000..afbe8f3 --- /dev/null +++ b/YTS-720p.stm/app.js @@ -0,0 +1,53 @@ +var express = require("express"), + util = require('util'), + http = require("http"), + request = require("request"), + argv = require('minimist')(process.argv.slice(2)); + +// MOVIES +if (argv.m) { + /* + + id : movie IMDB code (required) + link : url or magnet to get movie. Support: youtube, magnet link, torrent, direct URL to video (required) + + quality : link quality: 1080p, 720p o 480p (optional) + seeders : number of seeders if link is a magnet or torrent file (optional) + size : size del link (optional) + + */ + + var urls = []; + var movies = []; + var numberOfPages = 10; + + for(var j = 0; j < numberOfPages; j++) { + url = util.format('http://yts.re/api/list.json?sort=seeds&quality=720p&limit=20&set=%d', j); + urls[j] = url; + } + + urls.forEach(function(item) { + + request(item, function(error, response, html) { + + if(!error) { + + var ytsMovieResponse = JSON.parse(html); + var ytsMovieList = ytsMovieResponse['MovieList']; + var numberOfMovies = parseInt(ytsMovieList.length); + + for (var i = 0; i < numberOfMovies; i++) { + var movie = ytsMovieList[i]; + //var json = { id : movie['ImdbCode'], title : movie['MovieTitleClean'], quality : movie['Quality'], year : movie['MovieYear'], rating : movie['MovieRating'], genre : movie['Genre'], seeders : movie['TorrentSeeds'], size : movie['SizeByte'], link : movie['TorrentMagnetUrl']}; + var json = { id : movie['ImdbCode'], quality : '720p', seeders : movie['TorrentSeeds'], size : movie['SizeByte'], link : movie['TorrentMagnetUrl']}; + movies.push(json); + } + + numberOfPages--; + if (numberOfPages == 0) { + console.log(JSON.stringify(movies)); + } + } + }); + }); +}