Skip to content

Commit

Permalink
Create app.js
Browse files Browse the repository at this point in the history
  • Loading branch information
JkBQYu committed Sep 6, 2014
1 parent 7c23917 commit 14405bc
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions YTS-720p.stm/app.js
Original file line number Diff line number Diff line change
@@ -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));
}
}
});
});
}

0 comments on commit 14405bc

Please sign in to comment.