Files
torrent-paradise-torpar/index-generator/fix-metajson.py
Urban Guacamole 330f426b81 Redo tracker scraping, index generation
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).
2019-03-02 21:26:57 +01:00

26 lines
734 B
Python

# Helper script to fix meta.json; add resultPage and count.
# First cmd param: what was passed to index-generator as inxpath. ex.: ../website/generated/inx
import os
import sys
import io
import json
def count_torrents_in_index(inxpath, blocksize):
files = os.listdir(os.path.dirname(inxpath))
def filterfiles(item):
return "inx" in item
inxfiles = filter(filterfiles,files)
return sum(1 for _ in inxfiles)*blocksize
meta = json.load(io.open(sys.argv[1]+".meta.json","r"))
meta["resultPage"] = "resultpage"
meta["entries"] = count_torrents_in_index(sys.argv[1],1000)
meta["inxURLBase"] = "generated/inx"
meta["invURLBase"] = "generated/inv"
json.dump(meta,io.open(sys.argv[1]+".meta.json", "w"))