minor fixes
This commit is contained in:
@@ -8,16 +8,15 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/anacrolix/torrent/metainfo"
|
"github.com/anacrolix/torrent/metainfo"
|
||||||
|
"github.com/sirrobot01/decypharr/internal/logger"
|
||||||
"github.com/sirrobot01/decypharr/internal/request"
|
"github.com/sirrobot01/decypharr/internal/request"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -41,6 +40,7 @@ func (m *Magnet) IsTorrent() bool {
|
|||||||
func stripTrackersFromMagnet(mi metainfo.Magnet, fileType string) metainfo.Magnet {
|
func stripTrackersFromMagnet(mi metainfo.Magnet, fileType string) metainfo.Magnet {
|
||||||
originalTrackerCount := len(mi.Trackers)
|
originalTrackerCount := len(mi.Trackers)
|
||||||
if len(mi.Trackers) > 0 {
|
if len(mi.Trackers) > 0 {
|
||||||
|
log := logger.Default()
|
||||||
mi.Trackers = nil
|
mi.Trackers = nil
|
||||||
log.Printf("Removed %d tracker URLs from %s", originalTrackerCount, fileType)
|
log.Printf("Removed %d tracker URLs from %s", originalTrackerCount, fileType)
|
||||||
}
|
}
|
||||||
@@ -109,21 +109,6 @@ func GetMagnetFromBytes(torrentData []byte, rmTrackerUrls bool) (*Magnet, error)
|
|||||||
return magnet, nil
|
return magnet, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func OpenMagnetFile(filePath string) string {
|
|
||||||
file, err := os.Open(filePath)
|
|
||||||
if err != nil {
|
|
||||||
log.Println("Error opening file:", err)
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
defer func(file *os.File) {
|
|
||||||
err := file.Close()
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}(file) // Ensure the file is closed after the function ends
|
|
||||||
return ReadMagnetFile(file)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ReadMagnetFile(file io.Reader) string {
|
func ReadMagnetFile(file io.Reader) string {
|
||||||
scanner := bufio.NewScanner(file)
|
scanner := bufio.NewScanner(file)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
@@ -135,6 +120,7 @@ func ReadMagnetFile(file io.Reader) string {
|
|||||||
|
|
||||||
// Check for any errors during scanning
|
// Check for any errors during scanning
|
||||||
if err := scanner.Err(); err != nil {
|
if err := scanner.Err(); err != nil {
|
||||||
|
log := logger.Default()
|
||||||
log.Println("Error reading file:", err)
|
log.Println("Error reading file:", err)
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user