From 4e30dd540446b859e881721483ba9b416009cd09 Mon Sep 17 00:00:00 2001 From: lordwelch Date: Sat, 6 Jan 2018 23:33:08 -0700 Subject: [PATCH] Add credentials Sort mkv files to top Set seed ratio --- main.go | 19 ++++++++++++++++++- type.go | 17 ++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 42821d7..c2a0ad9 100644 --- a/main.go +++ b/main.go @@ -96,6 +96,21 @@ func download() { } } } + time.Sleep(time.Second * 30) + tmap, _ := Transmission.GetTorrentMap() + for _, s := range CurrentTorrents { + for _, se := range s { + for _, ep := range se { + v, ok := tmap[ep.Ep[0].Meta.Hash] + if ok { + v.Set(transmission.SetTorrentArg{ + SeedRatioMode: 1, + SeedRatioLimit: 1.0, + }) + } + } + } + } } @@ -216,7 +231,9 @@ func initialize() { } Transmission, err = transmission.New(transmission.Config{ - Address: "http://timmy:9091/transmission/rpc", + User: "lordwelch", + Password: "hello", + Address: "http://timmy:9091/transmission/rpc", HTTPClient: &http.Client{ Transport: &http.Transport{ TLSClientConfig: &tls.Config{ diff --git a/type.go b/type.go index 44f7e07..922c849 100644 --- a/type.go +++ b/type.go @@ -113,6 +113,21 @@ func (Vt SceneVideoTorrent) String() string { return Vt.Torrent.Meta.FilePath } +func (Et *EpisodeTorrent) ByExt(i, j int) bool { + var ( + ii int + ij int + ) + + if filepath.Ext(Et.Ep[i].Meta.Info.Name) != "mkv" { + ii = 1 + } + if filepath.Ext(Et.Ep[j].Meta.Info.Name) != "mkv" { + ij = 1 + } + return ii < ij +} + func (Et *EpisodeTorrent) ByRelease(i, j int) bool { var ( ii int @@ -184,7 +199,7 @@ func (Et *EpisodeTorrent) Swap(i, j int) { } func (Et *EpisodeTorrent) Less(i, j int) bool { - return OrderedBy(Et.ByRelease, Et.ByRes, Et.ByTag)(i, j) + return OrderedBy(Et.ByExt, Et.ByRelease, Et.ByRes, Et.ByTag)(i, j) } func (Et *EpisodeTorrent) Add(Vt *SceneVideoTorrent) {