Add Top torrents view by seed count
parent
ecb40c54cf
commit
2e386bd45a
@ -0,0 +1,55 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"encoding/csv"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"sort"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
type torrent struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Text string `json:"text"`
|
||||||
|
Len int `json:"len"`
|
||||||
|
S int `json:"s"`
|
||||||
|
L int `json:"l"`
|
||||||
|
C int `json:"c"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// https://www.dotnetperls.com/csv-go
|
||||||
|
f, err := os.Open("index-generator/dump.csv") // expects that you will run it from the parent dir
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
records, err := csv.NewReader(bufio.NewReader(f)).ReadAll()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
sort.Slice(records, func(i, j int) bool {
|
||||||
|
return toInt(records[i][3]) > toInt(records[j][3])
|
||||||
|
})
|
||||||
|
var topResults [500]torrent
|
||||||
|
for i, record := range records {
|
||||||
|
if i < 500 {
|
||||||
|
topResults[i] = torrent{string(record[0]), string(record[1]), toInt(record[2]), toInt(record[3]), toInt(record[4]), toInt(record[5])}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out, err := json.Marshal(topResults)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
fmt.Println(string(out))
|
||||||
|
}
|
||||||
|
|
||||||
|
func toInt(s string) int {
|
||||||
|
i, err := strconv.Atoi(s)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
return i
|
||||||
|
}
|
@ -1,3 +1,3 @@
|
|||||||
<p>ads are here to fund the server, there are no ads if you use IPFS</p>
|
<p>ads are here to fund the server, there are no ads if you use IPFS</p>
|
||||||
<iframe data-aa='1098421' src='//acceptable.a-ads.com/1098421' scrolling='no' style='border:0px; padding:0; overflow:hidden' allowtransparency='true'></iframe>
|
<iframe data-aa='1104268' src='//acceptable.a-ads.com/1104268' scrolling='no' style='border:0px; padding:0; overflow:hidden' allowtransparency='true'></iframe>
|
||||||
</body></html>
|
</body></html>
|
@ -0,0 +1,61 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<meta name="description" content="Decentralized Torrent Search site">
|
||||||
|
<title>Torrent Paradise</title>
|
||||||
|
<link rel="stylesheet" href="assets/bulma.min.css">
|
||||||
|
<script defer src="assets/fa.js"></script>
|
||||||
|
<style>
|
||||||
|
#resultPage {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<nav class="navbar is-warning" role="navigation" aria-label="main navigation">
|
||||||
|
<div class="navbar-brand">
|
||||||
|
<a class="is-light navbar-item" href="index.html">
|
||||||
|
<i class="fas fa-sun"></i>
|
||||||
|
</a>
|
||||||
|
<a class="navbar-item" href="about.html">
|
||||||
|
About
|
||||||
|
</a>
|
||||||
|
<a class="navbar-item" href="top.html">
|
||||||
|
Top torrents
|
||||||
|
</a>
|
||||||
|
<a class="navbar-item" href="ipfs.html">
|
||||||
|
IPFS
|
||||||
|
</a>
|
||||||
|
<a class="navbar-item" href="copyright.html">
|
||||||
|
Copyright
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<br>
|
||||||
|
<div id="app" class="container content">
|
||||||
|
<h1 class="title">Top torrents</h1>
|
||||||
|
<iframe v-bind:style="{height: resultPageHeight + 'px'}" id="resultPage" scrolling="no" frameBorder="0" seamless="seamless" v-bind:src="resultPage"></iframe>
|
||||||
|
<script src="assets/vue-v2.6.8.js"></script>
|
||||||
|
<script src="view.js"></script>
|
||||||
|
</div>
|
||||||
|
<script>app.resultPage = "resultpage"
|
||||||
|
|
||||||
|
|
||||||
|
fetch("generated/top.json").then((s) => {
|
||||||
|
return s.text()
|
||||||
|
}).then((top) => {
|
||||||
|
let resultPageIframe = document.getElementById("resultPage");
|
||||||
|
resultPageIframe.onload = () => {
|
||||||
|
resultPageIframe.contentWindow.postMessage({
|
||||||
|
type: "results",
|
||||||
|
results: top
|
||||||
|
}, '*');
|
||||||
|
}
|
||||||
|
})</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
@ -1,15 +1,17 @@
|
|||||||
app = new Vue({
|
app = new Vue({
|
||||||
el: '#app',
|
el: '#app',
|
||||||
data: {showsearchbox: false, error: "", resultPage: "", resultPageHeight: 1, entries: -1}
|
data: { showsearchbox: false, error: "", resultPage: "", resultPageHeight: 1, entries: -1 }
|
||||||
})
|
})
|
||||||
window.addEventListener("message", receiveMessage, false);
|
window.addEventListener("message", receiveMessage, false);
|
||||||
|
|
||||||
function receiveMessage(event){
|
function receiveMessage(event) {
|
||||||
app.resultPageHeight = event.data
|
app.resultPageHeight = event.data
|
||||||
}
|
}
|
||||||
|
searchbox = document.getElementById('searchbox')
|
||||||
document.getElementById('searchbox').onkeydown = function(event) {
|
if (searchbox != null) {
|
||||||
if (event.keyCode == 13) {
|
searchbox.onkeydown = function (event) {
|
||||||
searchTriggered()
|
if (event.keyCode == 13) {
|
||||||
|
searchTriggered()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue