Hotfixes
This commit is contained in:
@@ -20,5 +20,7 @@ RUN CGO_ENABLED=0 GOOS=$(echo $TARGETPLATFORM | cut -d '/' -f1) GOARCH=$(echo $T
|
|||||||
FROM scratch
|
FROM scratch
|
||||||
COPY --from=builder /blackhole /blackhole
|
COPY --from=builder /blackhole /blackhole
|
||||||
|
|
||||||
|
EXPOSE 8181
|
||||||
|
|
||||||
# Run
|
# Run
|
||||||
# CMD ["/blackhole", "--config", "/app/config.json"]
|
CMD ["/blackhole", "--config", "/app/config.json"]
|
||||||
@@ -126,12 +126,12 @@ func StartArr(conf *debrid.Arr, db debrid.Service) {
|
|||||||
log.Printf("Watching: %s", conf.WatchFolder)
|
log.Printf("Watching: %s", conf.WatchFolder)
|
||||||
w, err := fsnotify.NewWatcher()
|
w, err := fsnotify.NewWatcher()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
defer func(w *fsnotify.Watcher) {
|
defer func(w *fsnotify.Watcher) {
|
||||||
err := w.Close()
|
err := w.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
}(w)
|
}(w)
|
||||||
events := make(map[string]time.Time)
|
events := make(map[string]time.Time)
|
||||||
|
|||||||
14
cmd/proxy.go
14
cmd/proxy.go
@@ -13,6 +13,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -203,7 +204,7 @@ func ProcessXMLResponse(resp *http.Response, deb debrid.Service) *http.Response
|
|||||||
var rss RSS
|
var rss RSS
|
||||||
err = xml.Unmarshal(body, &rss)
|
err = xml.Unmarshal(body, &rss)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error unmarshalling XML: %v", err)
|
log.Printf("Error unmarshalling XML: %v", err)
|
||||||
return resp
|
return resp
|
||||||
}
|
}
|
||||||
newItems := &SafeItems{}
|
newItems := &SafeItems{}
|
||||||
@@ -220,7 +221,9 @@ func ProcessXMLResponse(resp *http.Response, deb debrid.Service) *http.Response
|
|||||||
}(item)
|
}(item)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
rss.Channel.Items = newItems.Get()
|
items := newItems.Get()
|
||||||
|
log.Printf("Report: %d/%d items are cached", len(items), len(rss.Channel.Items))
|
||||||
|
rss.Channel.Items = items
|
||||||
|
|
||||||
// rss.Channel.Items = newItems
|
// rss.Channel.Items = newItems
|
||||||
modifiedBody, err := xml.MarshalIndent(rss, "", " ")
|
modifiedBody, err := xml.MarshalIndent(rss, "", " ")
|
||||||
@@ -230,11 +233,6 @@ func ProcessXMLResponse(resp *http.Response, deb debrid.Service) *http.Response
|
|||||||
}
|
}
|
||||||
modifiedBody = append([]byte(xml.Header), modifiedBody...)
|
modifiedBody = append([]byte(xml.Header), modifiedBody...)
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Error marshalling XML: %v", err)
|
|
||||||
return resp
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the modified body back to the response
|
// Set the modified body back to the response
|
||||||
resp.Body = io.NopCloser(bytes.NewReader(modifiedBody))
|
resp.Body = io.NopCloser(bytes.NewReader(modifiedBody))
|
||||||
resp.ContentLength = int64(len(modifiedBody))
|
resp.ContentLength = int64(len(modifiedBody))
|
||||||
@@ -266,7 +264,7 @@ func StartProxy(config *common.Config, deb debrid.Service) {
|
|||||||
return ProcessResponse(resp, deb)
|
return ProcessResponse(resp, deb)
|
||||||
})
|
})
|
||||||
|
|
||||||
port := cmp.Or(cfg.Port, "8181")
|
port := cmp.Or(os.Getenv("PORT"), cfg.Port, "8181")
|
||||||
proxy.Verbose = cfg.Debug
|
proxy.Verbose = cfg.Debug
|
||||||
port = fmt.Sprintf(":%s", port)
|
port = fmt.Sprintf(":%s", port)
|
||||||
log.Printf("Starting proxy server on %s\n", port)
|
log.Printf("Starting proxy server on %s\n", port)
|
||||||
|
|||||||
@@ -31,8 +31,13 @@ func (r *RealDebrid) Process(arr *Arr, magnet string) (*Torrent, error) {
|
|||||||
if !r.IsAvailable(torrent.Magnet) {
|
if !r.IsAvailable(torrent.Magnet) {
|
||||||
return torrent, fmt.Errorf("torrent is not cached")
|
return torrent, fmt.Errorf("torrent is not cached")
|
||||||
}
|
}
|
||||||
|
log.Printf("Torrent: %s is cached", torrent.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
torrent, err = r.SubmitMagnet(torrent)
|
||||||
|
if err != nil || torrent.Id == "" {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return r.CheckStatus(torrent)
|
return r.CheckStatus(torrent)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,10 +54,8 @@ func (r *RealDebrid) IsAvailable(magnet *common.Magnet) bool {
|
|||||||
}
|
}
|
||||||
hosters, exists := data[strings.ToLower(magnet.InfoHash)]
|
hosters, exists := data[strings.ToLower(magnet.InfoHash)]
|
||||||
if !exists || len(hosters) < 1 {
|
if !exists || len(hosters) < 1 {
|
||||||
log.Printf("Torrent: %s not cached", magnet.Name)
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
log.Printf("Torrent: %s is cached", magnet.Name)
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user