From 643917939be551fb801b2b72f43cda6e82717302 Mon Sep 17 00:00:00 2001 From: TheBeastLT Date: Sun, 5 Jan 2020 18:59:30 +0100 Subject: [PATCH] small cleanup --- horrible_subs_mapping.json | 42 ++++++++--------- index.js | 2 - lib/torrent.js | 89 ------------------------------------ package-lock.json | 2 +- scrapers/api/thepiratebay.js | 6 +-- 5 files changed, 25 insertions(+), 116 deletions(-) diff --git a/horrible_subs_mapping.json b/horrible_subs_mapping.json index a4e82e2..b0e1d43 100644 --- a/horrible_subs_mapping.json +++ b/horrible_subs_mapping.json @@ -185,7 +185,7 @@ }, "Bokura wa Minna Kawaisou": { "showId": "46", - "kitsu_id": "8536" + "kitsu_id": "8094" }, "Bonjour Sweet Love Patisserie": { "showId": "47", @@ -385,7 +385,7 @@ }, "Denpa Kyoushi": { "showId": "96", - "kitsu_id": "8791" + "kitsu_id": "10235" }, "Detective Conan": { "showId": "97", @@ -764,7 +764,7 @@ }, "Highschool DxD BorN": { "showId": "190", - "kitsu_id": "11598" + "kitsu_id": "8514" }, "Hiiro no Kakera": { "showId": "191", @@ -1036,7 +1036,7 @@ }, "Kyoukai no Rinne": { "showId": "258", - "kitsu_id": "8461" + "kitsu_id": [ "10018", "11366", "12561" ] }, "Kyoukai Senjou no Horizon S2": { "showId": "259", @@ -1596,7 +1596,7 @@ }, "Rokujouma no Shinryakusha": { "showId": "398", - "kitsu_id": "9063" + "kitsu_id": "8336" }, "Rowdy Sumo Wrestler Matsutaro": { "showId": "399", @@ -1740,7 +1740,7 @@ }, "Seraph of the End S2": { "showId": "434", - "kitsu_id": "10881" + "kitsu_id": "10082" }, "Servant x Service": { "showId": "435", @@ -2380,7 +2380,7 @@ }, "Mobile Suit Gundam Thunderbolt": { "showId": "602", - "kitsu_id": "11476" + "kitsu_id": ["11476", "12755"] }, "Durarara!!": { "showId": "603", @@ -2696,7 +2696,7 @@ }, "Big Order": { "showId": "688", - "kitsu_id": "10672" + "kitsu_id": "11455" }, "Cardfight!! Vanguard G Stride Gate": { "showId": "689", @@ -2712,7 +2712,7 @@ }, "Yowamushi Pedal Re RIDE": { "showId": "691", - "kitsu_id": "7693" + "kitsu_id": "8657" }, "Yowamushi Pedal Re ROAD": { "showId": "691", @@ -2900,7 +2900,7 @@ }, "Mob Pyscho 100 OVA": { "showId": "741", - "kitsu_id": "42416" + "kitsu_id": "41073" }, "Mahou Shoujo Naria Girls": { "showId": "742", @@ -3020,7 +3020,7 @@ }, "Nobunaga no Shinobi": { "showId": "773", - "kitsu_id": "11871" + "kitsu_id": [ "11871", "13303", "14207" ] }, "Zutto Mae kara Suki deshita": { "showId": "774", @@ -3152,7 +3152,7 @@ }, "Shelter": { "showId": "807", - "kitsu_id": "9215" + "imdb_id": "tt6443118" }, "3-Nen D-Gumi Glass no Kamen": { "showId": "808", @@ -3380,7 +3380,7 @@ }, "THE iDOLM@STER CINDERELLA GIRLS Theater (TV)": { "showId": "866", - "kitsu_id": "12671" + "kitsu_id": [ "12671","13895", "41377", "42229" ] }, "THE iDOLM@STER CINDERELLA GIRLS Theater (Web)": { "showId": "866", @@ -3812,7 +3812,7 @@ }, "Yuki Yuna wa Yusha de Aru - Washio Sumi no Shou": { "showId": "976", - "kitsu_id": "12678" + "kitsu_id": [ "12678", "14029" ] }, "ID-0": { "showId": "978", @@ -3860,7 +3860,7 @@ }, "Houseki no Kuni": { "showId": "989", - "kitsu_id": "8774" + "kitsu_id": "13521" }, "Kekkai Sensen & Beyond": { "showId": "990", @@ -3868,7 +3868,7 @@ }, "Hozuki no Reitetsu S2": { "showId": "991", - "kitsu_id": "13226" + "kitsu_id": [ "13226", "14157" ] }, "Cardfight!! Vanguard G Z": { "showId": "992", @@ -4080,7 +4080,7 @@ }, "Beatless": { "showId": "1047", - "kitsu_id": "13939" + "kitsu_id": [ "13939", "41407" ] }, "Zoku Touken Ranbu - Hanamaru": { "showId": "1048", @@ -4140,7 +4140,7 @@ }, "Souten no Ken Re-Genesis": { "showId": "1062", - "kitsu_id": "13983" + "kitsu_id": [ "13983", "41953" ] }, "Gundam Build Divers": { "showId": "1063", @@ -4256,7 +4256,7 @@ }, "Chi's Sweet Adventure S2": { "showId": "1089", - "kitsu_id": "12154" + "kitsu_id": "13906" }, "Golden Kamuy": { "showId": "1090", @@ -4372,7 +4372,7 @@ }, "Ongaku Shoujo": { "showId": "1119", - "kitsu_id": "10422" + "kitsu_id": "41066" }, "Yami Shibai - Japanese Ghost Stories 6": { "showId": "1121", @@ -4864,7 +4864,7 @@ }, "Fairy Gone": { "showId": "1250", - "kitsu_id": "42130" + "kitsu_id": [ "42130", "42358" ] }, "Shoumetsu Toshi": { "showId": "1251", diff --git a/index.js b/index.js index 01a1b39..c094954 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,6 @@ require('dotenv').config(); const express = require("express"); const server = express(); -const { init } = require('./lib/torrent'); const { connect } = require('./lib/repository'); const tpbDump = require('./scrapers/piratebay_dump'); const horribleSubsScraper = require('./scrapers/horiblesubs_scraper'); @@ -19,7 +18,6 @@ server.post('/scrape', function(req, res) { server.listen(7000, async function () { await connect(); - await init(); console.log('Scraper started'); scrape(); }); \ No newline at end of file diff --git a/lib/torrent.js b/lib/torrent.js index 591a536..d6ae5cf 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -1,49 +1,18 @@ const torrentStream = require('torrent-stream'); -const cheerio = require('cheerio'); const needle = require('needle'); const parseTorrent = require('parse-torrent'); -const Tracker = require("peer-search/tracker"); const { retrieveTorrentFiles } = require('./cache'); const MAX_PEER_CONNECTIONS = process.env.MAX_PEER_CONNECTIONS || 20; const EXTENSIONS = ["3g2", "3gp", "avi", "flv", "mkv", "mov", "mp2", "mp4", "mpe", "mpeg", "mpg", "mpv", "webm", "wmv"]; -let TRACKERS = []; - -module.exports.init = async function() { - TRACKERS = await getTrackerList(); -}; module.exports.torrentFiles = function(torrent) { return filesFromTorrentFile(torrent) - .catch(() => filesFromKat(torrent.infoHash)) .catch(() => filesFromTorrentStream(torrent)) .catch(() => filesFromCache(torrent.infoHash)) .then((files) => files.filter((file) => isVideo(file))); }; -module.exports.currentSeeders = function (torrent) { - if (!torrent.infoHash) { - return Promise.reject(new Error("no infoHash")); - } - return new Promise((resolve) => - Promise.all(TRACKERS.map((tracker) => new Promise((resolve) => { - const t = new Tracker(tracker, { }, torrent.infoHash); - t.run(); - t.on("info", (inf) => resolve([inf.seeders, inf.leechers])); - setTimeout(() => resolve([0, 0]), 1000); - })) - ).then((results) => resolve(results.reduce((seeders, next) => seeders + next[0], 0))) - ); -}; - -// async function filesFromBtSeeds(infoHash) { -// const url = `https://www.btseed.net/show/${infoHash}`; -// return needle('get', url, { open_timeout: 2000 }) -// .then((response) => response.body) -// .then((body) => body.match(/