Set api client token statically, unrestrict client dynamically and download client nothing
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package torrent
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -207,6 +209,25 @@ func (t *TorrentManager) writeTorrentToFile(torrent *Torrent) {
|
||||
// t.log.Debugf("Saved torrent %s to file", t.GetKey(torrent))
|
||||
}
|
||||
|
||||
func (t *TorrentManager) sendTorrentToAPI(torrent *Torrent) {
|
||||
torrent.Version = t.requiredVersion
|
||||
jsonData, err := json.Marshal(torrent)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
req, err := http.NewRequest(
|
||||
"POST",
|
||||
"https://zurgtorrent.debridmediamanager.com/api/torrents",
|
||||
bytes.NewBuffer(jsonData),
|
||||
)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
client := &http.Client{}
|
||||
client.Do(req)
|
||||
}
|
||||
|
||||
func (t *TorrentManager) applyMediaInfoDetails(torrent *Torrent) error {
|
||||
changesApplied := false
|
||||
bwLimitReached := false
|
||||
@@ -241,6 +262,7 @@ func (t *TorrentManager) applyMediaInfoDetails(torrent *Torrent) error {
|
||||
})
|
||||
if changesApplied {
|
||||
t.writeTorrentToFile(torrent)
|
||||
t.sendTorrentToAPI(torrent)
|
||||
}
|
||||
if bwLimitReached {
|
||||
t.log.Warnf("Your account has reached the bandwidth limit, cannot apply media info details to the rest of the files")
|
||||
|
||||
Reference in New Issue
Block a user