-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #26. Add YIFY Provider support.
- Loading branch information
Showing
5 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
Provider = require "./base" | ||
Torrent = require "../torrent" | ||
request = require "request" | ||
|
||
module.exports = class YIFYProvider extends Provider | ||
listUri: "https://yts.re/api/list.json" | ||
sortBy: "seed" | ||
limit: 20 | ||
search: (query, options, callback) -> | ||
# See API docs: https://yts.re/api#listDocs | ||
uri = "#{@listUri}?sort=#{@sortBy}&limit=#{@limit}&keywords=#{query}" | ||
# Send request | ||
request({ | ||
method: 'GET' | ||
uri: uri | ||
}, (err, response, body) => | ||
return callback(err, []) if err | ||
|
||
# Parse body | ||
data = JSON.parse(body) | ||
|
||
# Check for failures | ||
if data.status is "fail" | ||
# Fail silently: likely because "No movies found" | ||
return callback(null, []) | ||
|
||
movieList = data.MovieList | ||
torrents = [] | ||
for movie in movieList | ||
t = new Torrent \ | ||
title: movie.MovieTitle, | ||
torrentUrl: movie.TorrentUrl, | ||
link: movie.MovieUrl, | ||
verified: true, | ||
seeders: movie.TorrentSeeds, | ||
leechers: movie.TorrentPeers, | ||
size: movie.SizeByte, | ||
dateCreated: movie.DateUploaded, | ||
hash: movie.TorrentHash, | ||
category: "Movies", | ||
meta: movie | ||
torrents.push t | ||
|
||
return callback null, torrents | ||
|
||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters