mirror of
https://github.com/urbanguacamole/torrent-paradise.git
synced 2022-02-03 00:44:15 +03:00
Seed/leech counts are fetched from all trackers for every torrent and data from the tracker with most seeds for a given torrent is used. I also got rid of SQLite which was previously used for generating the index. It was replaced by a simple CSV file. KISS Some minor bugfixes and tweaks also included (sorry for not breaking them up into more commits).
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
const ipfsearch = require("ipfsearch-index")
|
|
const parse = require("csv-parse")
|
|
const fs = require("fs")
|
|
|
|
let indexer = new ipfsearch.Indexer()
|
|
let i = 0
|
|
|
|
const parser = parse()
|
|
fs.createReadStream("dump.csv").pipe(parser)
|
|
|
|
parser.on('readable', function () {
|
|
let record
|
|
while (record = parser.read()) {
|
|
if (parseInt(record[3]) > 0) {
|
|
indexer.addToIndex(new Torrent(record[0], record[1], parseInt(record[2]), parseInt(record[3]), parseInt(record[4]), parseInt(record[5])))
|
|
i++
|
|
}
|
|
}
|
|
})
|
|
|
|
parser.on('error', function (err) {
|
|
console.error(err.message)
|
|
})
|
|
|
|
parser.on('end', function () {
|
|
console.log("Read all " + i + " records. Persisting.");
|
|
indexer.persist("../website/generated/inv", "../website/generated/inx", "Urban Guacamole", "Torrent Paradise index", "", 1000);
|
|
|
|
})
|
|
|
|
class Torrent extends ipfsearch.Document {
|
|
len: number
|
|
s: number
|
|
l: number
|
|
c: number
|
|
|
|
constructor(id: string, text: string, size: number, seeders: number, leechers: number, completed: number) {
|
|
super(id, text)
|
|
this.len = size
|
|
this.s = seeders
|
|
this.l = leechers
|
|
this.c = completed
|
|
}
|
|
} |