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:
parent
370e9a33ba
commit
70d3382282
25
index-generator/fix-metajson.py
Normal file
25
index-generator/fix-metajson.py
Normal 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"))
|
@ -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 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);"
|
sqlite3 index-generator/db.sqlite3 "CREATE TABLE torrent( infohash char(40), name varchar, length bigint, added timestamp);"
|
||||||
echo """Do the following:
|
echo """Do the following:
|
||||||
$ sqlite3 index-generator/db.sqlite3
|
|
||||||
|
|
||||||
sqlite> BEGIN;
|
sqlite> BEGIN;
|
||||||
sqlite> .read index-generator/dump.sql
|
sqlite> .read index-generator/dump.sql
|
||||||
sqlite> END;"""
|
sqlite> END;"""
|
||||||
bash
|
sqlite3 index-generator/db.sqlite3
|
||||||
echo "Generating index now..."
|
echo "Generating index now..."
|
||||||
(cd index-generator; node --max-old-space-size=10000 main.js)
|
(cd index-generator; node --max-old-space-size=10000 main.js)
|
||||||
echo "Check meta.json, add resultPage:'resultpage', fix invURLBase, inxURLBase"
|
python3 index-generator/fix-metajson.py website/generated/inx
|
||||||
nano website/generated/inx.meta.json
|
|
||||||
echo "Uploading website"
|
echo "Uploading website"
|
||||||
cd website
|
cd website
|
||||||
scp -r . user@server:/www/torrent-paradise.ml
|
scp -r . root@server:/www/torrent-paradise.ml #todo use rsync https://superuser.com/a/1405020/373473
|
||||||
echo "Finished uploading website to server."
|
|
||||||
|
@ -142,6 +142,7 @@ async function loadMeta(metaURL) {
|
|||||||
app.showsearchbox = true;
|
app.showsearchbox = true;
|
||||||
app.indexAuthor = meta.author;
|
app.indexAuthor = meta.author;
|
||||||
app.indexName = meta.name;
|
app.indexName = meta.name;
|
||||||
|
app.entries = meta.entries;
|
||||||
let ts = new Date(meta.created);
|
let ts = new Date(meta.created);
|
||||||
app.indexTimestamp = ts.getDate().toString() + "/" + (ts.getMonth()+1).toString() + "/" + ts.getFullYear().toString();
|
app.indexTimestamp = ts.getDate().toString() + "/" + (ts.getMonth()+1).toString() + "/" + ts.getFullYear().toString();
|
||||||
if (meta.resultPage == undefined) {
|
if (meta.resultPage == undefined) {
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
<iframe v-bind:style="{height: resultPageHeight + 'px'}" id="resultPage" scrolling="no" frameBorder="0"
|
<iframe v-bind:style="{height: resultPageHeight + 'px'}" id="resultPage" scrolling="no" frameBorder="0"
|
||||||
seamless="seamless" v-bind:src="resultPage"></iframe>
|
seamless="seamless" v-bind:src="resultPage"></iframe>
|
||||||
<p v-if="showsearchbox">Last index update: {{indexTimestamp}}</p>
|
<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="bundle.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
|
||||||
<script src="view.js"></script>
|
<script src="view.js"></script>
|
@ -1,6 +1,6 @@
|
|||||||
app = new Vue({
|
app = new Vue({
|
||||||
el: '#app',
|
el: '#app',
|
||||||
data: {showsearchbox: false, error: "", resultPage: "", resultPageHeight: 1}
|
data: {showsearchbox: false, error: "", resultPage: "", resultPageHeight: 1, entries: -1}
|
||||||
})
|
})
|
||||||
window.addEventListener("message", receiveMessage, false);
|
window.addEventListener("message", receiveMessage, false);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user