Merge pull request #24 from tsynik/fix-info

fix info and shrink m3u
This commit is contained in:
YouROK
2020-11-06 09:45:09 +03:00
committed by GitHub
3 changed files with 11 additions and 4 deletions

View File

@@ -13,6 +13,11 @@ func AddInfo(hash, info string) error {
return err return err
} }
infoe := GetInfo(hash)
if infoe != "{}" {
return nil // already filled
}
hash = strings.ToUpper(hash) hash = strings.ToUpper(hash)
return db.Update(func(tx *bolt.Tx) error { return db.Update(func(tx *bolt.Tx) error {
dbt, err := tx.CreateBucketIfNotExists([]byte(dbInfosName)) dbt, err := tx.CreateBucketIfNotExists([]byte(dbInfosName))

View File

@@ -672,7 +672,8 @@ func getTorrentJS(tor *settings.Torrent) (*TorrentJsonResponse, error) {
if err == nil && len(tor.Name) < len(mag.DisplayName) { if err == nil && len(tor.Name) < len(mag.DisplayName) {
js.Name = mag.DisplayName js.Name = mag.DisplayName
} }
mag.Trackers = []string{} //Remove retrackers for small link size mag.Trackers = []string{} // remove retrackers for small link size
mag.DisplayName = "" // clear dn from link - long query params may fail in QueryParam("link")
js.Magnet = tor.Magnet js.Magnet = tor.Magnet
js.Hash = tor.Hash js.Hash = tor.Hash
js.AddTime = tor.Timestamp js.AddTime = tor.Timestamp
@@ -684,8 +685,8 @@ func getTorrentJS(tor *settings.Torrent) (*TorrentJsonResponse, error) {
tf := TorFile{ tf := TorFile{
Name: f.Name, Name: f.Name,
Link: "/torrent/view/" + js.Hash + "/" + utils.CleanFName(f.Name), Link: "/torrent/view/" + js.Hash + "/" + utils.CleanFName(f.Name),
Play: "/torrent/play/" + utils.CleanFName(f.Name) + "?link=" + mag.String() + "&file=" + fmt.Sprint(f.Id), Play: "/torrent/play/" + utils.CleanFName(f.Name) + "?link=" + url.QueryEscape(mag.String()) + "&file=" + fmt.Sprint(f.Id),
Preload: "/torrent/play/" + utils.CleanFName(f.Name) + "?link=" + mag.String() + "&file=" + fmt.Sprint(f.Id) + "&preload=true", Preload: "/torrent/play/" + utils.CleanFName(f.Name) + "?link=" + url.QueryEscape(mag.String()) + "&file=" + fmt.Sprint(f.Id) + "&preload=true",
Size: f.Size, Size: f.Size,
Viewed: settings.GetViewed(tor.Hash, f.Name), Viewed: settings.GetViewed(tor.Hash, f.Name),
} }

View File

@@ -19,7 +19,8 @@ func MakeM3ULists(torrents []*settings.Torrent, host string) string {
magnet := t.Magnet magnet := t.Magnet
mag, _, err := GetMagnet(magnet) mag, _, err := GetMagnet(magnet)
if err == nil { if err == nil {
mag.Trackers = []string{} //Remove retrackers for small link size mag.Trackers = []string{} // remove retrackers for small link size
mag.DisplayName = "" // clear dn from link - long query params may fail in QueryParam("link")
magnet = mag.String() magnet = mag.String()
} }
m3u += host + "/torrent/play?link=" + url.QueryEscape(magnet) + "&m3u=true\n" m3u += host + "/torrent/play?link=" + url.QueryEscape(magnet) + "&m3u=true\n"