2
0
mirror of https://github.com/urbanguacamole/torrent-paradise synced 2024-10-31 21:20:13 +00:00

Further automate index updates

This commit is contained in:
Urban Guacamole 2019-02-22 15:21:13 +01:00
parent 370e9a33ba
commit 70d3382282
5 changed files with 32 additions and 7 deletions

View File

@ -0,0 +1,25 @@
# 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"] = "website/generated/inx"
meta["invUrlBase"] = "website/generated/inv"
json.dump(meta,io.open(sys.argv[1]+".meta.json", "w"))

View File

@ -14,17 +14,15 @@ echo "Preparing sqlite DB"
sqlite3 index-generator/db.sqlite3 "CREATE TABLE peercount ( infohash char(40), tracker varchar, seeders int, leechers int, completed int, scraped timestamp, ws boolean);"
sqlite3 index-generator/db.sqlite3 "CREATE TABLE torrent( infohash char(40), name varchar, length bigint, added timestamp);"
echo """Do the following:
$ sqlite3 index-generator/db.sqlite3
sqlite> BEGIN;
sqlite> .read index-generator/dump.sql
sqlite> END;"""
bash
sqlite3 index-generator/db.sqlite3
echo "Generating index now..."
(cd index-generator; node --max-old-space-size=10000 main.js)
echo "Check meta.json, add resultPage:'resultpage', fix invURLBase, inxURLBase"
nano website/generated/inx.meta.json
python3 index-generator/fix-metajson.py website/generated/inx
echo "Uploading website"
cd website
scp -r . user@server:/www/torrent-paradise.ml
echo "Finished uploading website to server."
scp -r . root@server:/www/torrent-paradise.ml #todo use rsync https://superuser.com/a/1405020/373473

View File

@ -142,6 +142,7 @@ async function loadMeta(metaURL) {
app.showsearchbox = true;
app.indexAuthor = meta.author;
app.indexName = meta.name;
app.entries = meta.entries;
let ts = new Date(meta.created);
app.indexTimestamp = ts.getDate().toString() + "/" + (ts.getMonth()+1).toString() + "/" + ts.getFullYear().toString();
if (meta.resultPage == undefined) {

View File

@ -41,6 +41,7 @@
<iframe v-bind:style="{height: resultPageHeight + 'px'}" id="resultPage" scrolling="no" frameBorder="0"
seamless="seamless" v-bind:src="resultPage"></iframe>
<p v-if="showsearchbox">Last index update: {{indexTimestamp}}</p>
<p v-if="showsearchbox">Torrents in index: {{entries}}</p>
<script src="bundle.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="view.js"></script>

View File

@ -1,6 +1,6 @@
app = new Vue({
el: '#app',
data: {showsearchbox: false, error: "", resultPage: "", resultPageHeight: 1}
data: {showsearchbox: false, error: "", resultPage: "", resultPageHeight: 1, entries: -1}
})
window.addEventListener("message", receiveMessage, false);