Merge branch 'master' of https://github.com/ewhal/nyaa
Cette révision appartient à :
révision
6d4af2d239
3 fichiers modifiés avec 33 ajouts et 14 suppressions
13
main.go
13
main.go
|
@ -1,6 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"compress/zlib"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/gorilla/feeds"
|
"github.com/gorilla/feeds"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
@ -8,6 +10,7 @@ import (
|
||||||
_ "github.com/jinzhu/gorm/dialects/sqlite"
|
_ "github.com/jinzhu/gorm/dialects/sqlite"
|
||||||
"html"
|
"html"
|
||||||
"html/template"
|
"html/template"
|
||||||
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -36,6 +39,16 @@ func checkErr(err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func unZlib(description []byte) string {
|
||||||
|
b := bytes.NewReader(description)
|
||||||
|
z, err := zlib.NewReader(b)
|
||||||
|
checkErr(err)
|
||||||
|
defer z.Close()
|
||||||
|
p, err := ioutil.ReadAll(z)
|
||||||
|
checkErr(err)
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
func apiHandler(w http.ResponseWriter, r *http.Request) {
|
func apiHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
|
|
|
@ -73,6 +73,7 @@ type TorrentsJson struct {
|
||||||
Hash string `json: "hash"`
|
Hash string `json: "hash"`
|
||||||
Date int `json: "date"`
|
Date int `json: "date"`
|
||||||
Filesize string `json: "filesize"`
|
Filesize string `json: "filesize"`
|
||||||
|
Description string `json: "description"`
|
||||||
Magnet template.URL `json: "magnet"`
|
Magnet template.URL `json: "magnet"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,6 +203,7 @@ func (t *Torrents) toJson() TorrentsJson {
|
||||||
Hash: t.Hash,
|
Hash: t.Hash,
|
||||||
Date: t.Date,
|
Date: t.Date,
|
||||||
Filesize: t.Filesize,
|
Filesize: t.Filesize,
|
||||||
|
Description: unZlib(t.Description),
|
||||||
Magnet: safe(magnet)}
|
Magnet: safe(magnet)}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,6 +124,10 @@
|
||||||
<a href="https://itorrents.org/torrent/{{.Hash}}.torrent" title="Torrent file"><span class="glyphicon glyphicon-floppy-save" aria-hidden="true"></span></a>
|
<a href="https://itorrents.org/torrent/{{.Hash}}.torrent" title="Torrent file"><span class="glyphicon glyphicon-floppy-save" aria-hidden="true"></span></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Description</td>
|
||||||
|
<td>{{.Description}}</td>
|
||||||
|
</tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
Référencer dans un nouveau ticket