feat(strategies): 1337 strategie

This commit is contained in:
Alexey Kasyanchuk
2018-12-23 00:24:05 +03:00
parent 9453ab8ba8
commit 44a800dbbb
7 changed files with 87 additions and 4 deletions

View File

@ -0,0 +1,59 @@
const fetch = require('node-fetch')
const cheerio = require('cheerio')
module.exports = class Stragegie
{
get name() { return '1337x' }
async findHash(hash)
{
let html;
try {
html = await fetch(`https://1337x.to/srch?search=${hash}`)
} catch(err) {
return
}
if(!html)
return
html = await html.textConverted()
const $ = cheerio.load(html)
this.href = $($('.table-list tr td a').get(1)).attr('href')
if(this.href)
this.id = this.href.match(/\/torrent\/([0-9]+)\//)[1];
return await this.parse();
}
async parse()
{
let html;
try {
html = await fetch('https://1337x.to' + this.href)
} catch(err) {
return
}
if(!html)
return
html = await html.textConverted()
const $ = cheerio.load(html)
const topicTitle = $('h1').text()
if(!topicTitle)
return
let contentCategory;
try {
contentCategory = $('.torrent-category-detail .list li').first().find('span').text()
} catch(er) {}
return {
name: topicTitle.trim(),
poster: $('#description img').attr('data-original'),
description: $('#description').text(),
x1337ThreadId: parseInt(this.id),
x1337Href: this.href,
contentCategory
}
}
}

View File

@ -3,7 +3,7 @@ const cheerio = require('cheerio')
module.exports = class Nyaa
{
name() { return 'nyaa' }
get name() { return 'nyaa' }
async findHash(hash)
{

View File

@ -18,7 +18,7 @@ module.exports = class Rutor
t.unref()
}
name() { return 'rutor' }
get name() { return 'rutor' }
async findHash(hash)
{

View File

@ -4,7 +4,7 @@ const cheerio = require('cheerio')
module.exports = class Rutracker
{
name() { return 'rutracker' }
get name() { return 'rutracker' }
async findHash(hash)
{