mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
[scraper] add tpb fake torrent removal
This commit is contained in:
@@ -170,7 +170,11 @@ function getTorrent(torrent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getTorrentsBasedOnTitle(titleQuery, type) {
|
function getTorrentsBasedOnTitle(titleQuery, type) {
|
||||||
return Torrent.findAll({ where: { title: { [Op.regexp]: `${titleQuery}` }, type: type } });
|
return getTorrentsBasedOnQuery({ title: { [Op.regexp]: `${titleQuery}` }, type: type });
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTorrentsBasedOnQuery(where) {
|
||||||
|
return Torrent.findAll({ where: where });
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTorrentsWithoutSize() {
|
function getTorrentsWithoutSize() {
|
||||||
@@ -219,6 +223,10 @@ function setTorrentSeeders(torrent, seeders) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteTorrent(torrent) {
|
||||||
|
return Torrent.destroy({ where: { infoHash: torrent.infoHash } })
|
||||||
|
}
|
||||||
|
|
||||||
function createFile(file) {
|
function createFile(file) {
|
||||||
if (file.id) {
|
if (file.id) {
|
||||||
return (file.dataValues ? file.save() : File.upsert(file))
|
return (file.dataValues ? file.save() : File.upsert(file))
|
||||||
@@ -304,6 +312,8 @@ module.exports = {
|
|||||||
setTorrentSeeders,
|
setTorrentSeeders,
|
||||||
getTorrent,
|
getTorrent,
|
||||||
getTorrentsBasedOnTitle,
|
getTorrentsBasedOnTitle,
|
||||||
|
getTorrentsBasedOnQuery,
|
||||||
|
deleteTorrent,
|
||||||
getUpdateSeedersTorrents,
|
getUpdateSeedersTorrents,
|
||||||
getNoContentsTorrents,
|
getNoContentsTorrents,
|
||||||
createFile,
|
createFile,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
const thepiratebayScraper = require('../scrapers/thepiratebay/thepiratebay_scraper');
|
const thepiratebayScraper = require('../scrapers/thepiratebay/thepiratebay_scraper');
|
||||||
|
const thepiratebayFakeRemoval = require('../scrapers/thepiratebay/thepiratebay_fakes_removal');
|
||||||
const ytsScraper = require('../scrapers/yts/yts_scraper');
|
const ytsScraper = require('../scrapers/yts/yts_scraper');
|
||||||
const eztvScraper = require('../scrapers/eztv/eztv_scraper');
|
const eztvScraper = require('../scrapers/eztv/eztv_scraper');
|
||||||
const leetxScraper = require('../scrapers/1337x/1337x_scraper');
|
const leetxScraper = require('../scrapers/1337x/1337x_scraper');
|
||||||
@@ -17,6 +18,7 @@ module.exports = [
|
|||||||
{ scraper: rarbgScraper, name: rarbgScraper.NAME, cron: '0 0 */1 ? * *' },
|
{ scraper: rarbgScraper, name: rarbgScraper.NAME, cron: '0 0 */1 ? * *' },
|
||||||
{ scraper: rutorScraper, name: rutorScraper.NAME, cron: '0 0 */4 ? * *' },
|
{ scraper: rutorScraper, name: rutorScraper.NAME, cron: '0 0 */4 ? * *' },
|
||||||
{ scraper: thepiratebayScraper, name: thepiratebayScraper.NAME, cron: '0 0 */2 ? * *' },
|
{ scraper: thepiratebayScraper, name: thepiratebayScraper.NAME, cron: '0 0 */2 ? * *' },
|
||||||
|
{ scraper: thepiratebayFakeRemoval, name: thepiratebayFakeRemoval.NAME, cron: '0 30 1 ? * * *' },
|
||||||
{ scraper: torrentGalaxyScraper, name: torrentGalaxyScraper.NAME, cron: '0 0 */4 ? * *' },
|
{ scraper: torrentGalaxyScraper, name: torrentGalaxyScraper.NAME, cron: '0 0 */4 ? * *' },
|
||||||
{ scraper: leetxScraper, name: leetxScraper.NAME, cron: '0 0 */4 ? * *' },
|
{ scraper: leetxScraper, name: leetxScraper.NAME, cron: '0 0 */4 ? * *' },
|
||||||
// { scraper: kickassScraper, name: kickassScraper.NAME, cron: '0 0 */4 ? * *' },
|
// { scraper: kickassScraper, name: kickassScraper.NAME, cron: '0 0 */4 ? * *' },
|
||||||
|
|||||||
42
scraper/scrapers/thepiratebay/thepiratebay_fakes_removal.js
Normal file
42
scraper/scrapers/thepiratebay/thepiratebay_fakes_removal.js
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
const moment = require('moment');
|
||||||
|
const { Sequelize } = require('sequelize');
|
||||||
|
const thepiratebay = require('./thepiratebay_api.js');
|
||||||
|
const { Type } = require('../../lib/types');
|
||||||
|
const repository = require('../../lib/repository');
|
||||||
|
const Promises = require('../../lib/promises');
|
||||||
|
|
||||||
|
const NAME = 'ThePirateBay';
|
||||||
|
const EMPTY_HASH = '0000000000000000000000000000000000000000';
|
||||||
|
|
||||||
|
const Op = Sequelize.Op;
|
||||||
|
|
||||||
|
async function scrape() {
|
||||||
|
console.log(`Starting ${NAME} fake removal...`);
|
||||||
|
const startCreatedAt = moment().subtract(14, 'day');
|
||||||
|
const endCreatedAt = moment().subtract(1, 'day');
|
||||||
|
const whereQuery = {
|
||||||
|
provider: NAME,
|
||||||
|
type: Type.MOVIE,
|
||||||
|
createdAt: { [Op.between]: [startCreatedAt, endCreatedAt] }
|
||||||
|
};
|
||||||
|
return repository.getTorrentsBasedOnQuery(whereQuery)
|
||||||
|
.then(torrents => {
|
||||||
|
console.log(`Checking for ${NAME} fake entries in ${torrents.length} torrents`);
|
||||||
|
return Promises.sequence(torrents.map(torrent => () => removeIfFake(torrent)))
|
||||||
|
})
|
||||||
|
.then(results => {
|
||||||
|
const removed = results.filter(result => result);
|
||||||
|
console.log(`Finished ${NAME} fake removal with ${removed.length} removals in ${results.length} torrents`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function removeIfFake(torrent) {
|
||||||
|
const tpbTorrentInfo = await thepiratebay.torrent(torrent.torrentId).catch(() => null);
|
||||||
|
if (tpbTorrentInfo && tpbTorrentInfo.infoHash === EMPTY_HASH) {
|
||||||
|
console.log(`Removing ${NAME} fake torrent [${torrent.torrentId}][${torrent.infoHash}] ${torrent.title}`);
|
||||||
|
return repository.deleteTorrent(torrent).catch(() => null);
|
||||||
|
}
|
||||||
|
return Promise.resolve(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { scrape, NAME };
|
||||||
Reference in New Issue
Block a user