Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Cette révision appartient à :
ayame-git 2017-05-03 09:58:06 +03:00
Parent 8989978b42
révision a3a64a0c02
2 fichiers modifiés avec 32 ajouts et 10 suppressions

Voir le fichier

@ -18,6 +18,17 @@
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<style>
.remake {
background-color: #f0b0b0;
}
.trusted {
background-color: #98d9a8;
}
.aplus {
background-color: #60b0f0;
}
</style>
<body>
<nav class="navbar navbar-default">
<div class="container">
@ -71,8 +82,10 @@
<th>Links</th>
</tr>
{{ range .Records}}
<tr>
<td>{{.Name}}</td>
<tr {{if eq .Status 2}}class="remake"{{end}}
{{if eq .Status 3}}class="trusted"{{end}}
{{if eq .Status 4}}class="aplus"{{end}}>
<td>{{.Name}}</td>
<td>{{.Hash}}</td>
<td><a href="{{.Magnet}}"><span class="glyphicon glyphicon-magnet" aria-hidden="true"></span></a>
<a href="http://torcache.net/torrent/{{.Hash}}.torrent"><span class="glyphicon glyphicon-floppy-save" aria-hidden="true"></span></a>

25
main.go
Voir le fichier

@ -30,6 +30,7 @@ type Record struct {
type Records struct {
Id string `json: "id"`
Name string `json: "name"`
Status int `json: "status"`
Hash string `json: "hash"`
Magnet string `json: "magnet"`
}
@ -53,14 +54,16 @@ func apiHandler(w http.ResponseWriter, r *http.Request) {
page := vars["page"]
pagenum, _ := strconv.Atoi(html.EscapeString(page))
b := Record{Records: []Records{}}
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents ORDER BY torrent_id DESC LIMIT 50 offset ?", 50*pagenum-1)
rows, err := dbHandle.Query("select torrent_id, torrent_name, status_id, torrent_hash from torrents ORDER BY torrent_id DESC LIMIT 50 offset ?", 50*pagenum-1)
for rows.Next() {
var id, name, hash, magnet string
rows.Scan(&id, &name, &hash)
var status int
rows.Scan(&id, &name, &status, &hash)
magnet = "magnet:?xt=urn:btih:" + hash + "&dn=" + url.QueryEscape(name) + "&tr=udp://tracker.openbittorrent.com"
res := Records{
Id: id,
Name: name,
Status: status,
Hash: hash,
Magnet: magnet}
@ -83,14 +86,16 @@ func singleapiHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
id := vars["id"]
b := Record{Records: []Records{}}
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents where torrent_id = ? ORDER BY torrent_id DESC", html.EscapeString(id))
rows, err := dbHandle.Query("select torrent_id, torrent_name, status_id, torrent_hash from torrents where torrent_id = ? ORDER BY torrent_id DESC", html.EscapeString(id))
for rows.Next() {
var id, name, hash, magnet string
rows.Scan(&id, &name, &hash)
var status int
rows.Scan(&id, &name, &status, &hash)
magnet = "magnet:?xt=urn:btih:" + hash + "&dn=" + url.QueryEscape(name) + "&tr=udp://tracker.openbittorrent.com"
res := Records{
Id: id,
Name: name,
Status: status,
Hash: hash,
Magnet: magnet}
@ -118,17 +123,19 @@ func searchHandler(w http.ResponseWriter, r *http.Request) {
param2 := strings.Split(cat, "_")[0]
param3 := strings.Split(cat, "_")[1]
b := Record{Category: cat, Records: []Records{}}
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents "+
rows, err := dbHandle.Query("select torrent_id, torrent_name, status_id, torrent_hash from torrents "+
"where torrent_name LIKE ? AND category_id LIKE ? AND sub_category_id LIKE ? "+
"ORDER BY torrent_id DESC LIMIT 50 offset ?",
"%"+html.EscapeString(param1)+"%", html.EscapeString(param2)+"%", html.EscapeString(param3)+"%", 50*pagenum-1)
for rows.Next() {
var id, name, hash, magnet string
rows.Scan(&id, &name, &hash)
var status int
rows.Scan(&id, &name, &status, &hash)
magnet = "magnet:?xt=urn:btih:" + hash + "&dn=" + url.QueryEscape(name) + "&tr=udp://tracker.openbittorrent.com"
res := Records{
Id: id,
Name: name,
Status: status,
Hash: hash,
Magnet: magnet}
@ -148,14 +155,16 @@ func rootHandler(w http.ResponseWriter, r *http.Request) {
page := vars["page"]
pagenum, _ := strconv.Atoi(html.EscapeString(page))
b := Record{Category: "_", Records: []Records{}}
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents ORDER BY torrent_id DESC LIMIT 50 offset ?", 50*pagenum-1)
rows, err := dbHandle.Query("select torrent_id, torrent_name, status_id, torrent_hash from torrents ORDER BY torrent_id DESC LIMIT 50 offset ?", 50*pagenum-1)
for rows.Next() {
var id, name, hash, magnet string
rows.Scan(&id, &name, &hash)
var status int
rows.Scan(&id, &name, &status, &hash)
magnet = "magnet:?xt=urn:btih:" + hash + "&dn=" + url.QueryEscape(name) + "&tr=udp://tracker.openbittorrent.com"
res := Records{
Id: id,
Name: name,
Status: status,
Hash: hash,
Magnet: magnet}