This commit is contained in:
Alexey Kasyanchuk
2019-05-03 00:25:50 +03:00
parent e552b491a8
commit 356db94dff
7 changed files with 165 additions and 165 deletions

View File

@ -4,60 +4,60 @@ const cheerio = require('cheerio')
module.exports = class Stragegie
{
get name() { return '1337x' }
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)
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];
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();
}
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
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) {}
let contentCategory;
try {
contentCategory = $('.torrent-category-detail .list li').first().find('span').text()
} catch(er) {}
let poster = $('.torrent-image img').attr('src') || $('#description img').attr('data-original');
if(poster)
poster = poster.replace(/^\/\//, 'https://');
let poster = $('.torrent-image img').attr('src') || $('#description img').attr('data-original');
if(poster)
poster = poster.replace(/^\/\//, 'https://');
return {
name: topicTitle.trim(),
poster,
description: $('#description').text(),
x1337ThreadId: parseInt(this.id),
x1337Href: this.href,
contentCategory
}
}
return {
name: topicTitle.trim(),
poster,
description: $('#description').text(),
x1337ThreadId: parseInt(this.id),
x1337Href: this.href,
contentCategory
}
}
}