Fix naming to accurately depict zurg

This commit is contained in:
Mukhtar Akere
2025-03-19 05:31:36 +01:00
parent 0d178992ef
commit 50c775ca74
3 changed files with 9 additions and 3 deletions

View File

@@ -37,6 +37,7 @@ func RemoveInvalidChars(value string) string {
} }
func RemoveExtension(value string) string { func RemoveExtension(value string) string {
value = RemoveInvalidChars(value)
re := regexp.MustCompile(VIDEOMATCH + "|" + SAMPLEMATCH + "|" + MUSICMATCH) re := regexp.MustCompile(VIDEOMATCH + "|" + SAMPLEMATCH + "|" + MUSICMATCH)
// Find the last index of the matched extension // Find the last index of the matched extension

View File

@@ -173,7 +173,7 @@ func (r *RealDebrid) UpdateTorrent(t *torrent.Torrent) error {
if err != nil { if err != nil {
return err return err
} }
name := utils.RemoveInvalidChars(data.OriginalFilename) name := utils.RemoveExtension(data.OriginalFilename)
t.Name = name t.Name = name
t.Bytes = data.Bytes t.Bytes = data.Bytes
t.Folder = name t.Folder = name
@@ -379,7 +379,7 @@ func (r *RealDebrid) getTorrents(offset int, limit int) (int, []*torrent.Torrent
} }
torrents = append(torrents, &torrent.Torrent{ torrents = append(torrents, &torrent.Torrent{
Id: t.Id, Id: t.Id,
Name: t.Filename, Name: utils.RemoveInvalidChars(t.Filename),
Bytes: t.Bytes, Bytes: t.Bytes,
Progress: t.Progress, Progress: t.Progress,
Status: t.Status, Status: t.Status,

View File

@@ -8,6 +8,7 @@ import (
"github.com/goccy/go-json" "github.com/goccy/go-json"
"github.com/rs/zerolog" "github.com/rs/zerolog"
"github.com/sirrobot01/debrid-blackhole/internal/logger" "github.com/sirrobot01/debrid-blackhole/internal/logger"
"github.com/sirrobot01/debrid-blackhole/internal/utils"
"github.com/sirrobot01/debrid-blackhole/pkg/debrid/debrid" "github.com/sirrobot01/debrid-blackhole/pkg/debrid/debrid"
"os" "os"
"path/filepath" "path/filepath"
@@ -108,7 +109,10 @@ func (c *Cache) refreshListings() {
} }
func (c *Cache) GetListing() []os.FileInfo { func (c *Cache) GetListing() []os.FileInfo {
return c.listings.Load().([]os.FileInfo) if v, ok := c.listings.Load().([]os.FileInfo); ok {
return v
}
return nil
} }
func (c *Cache) setTorrents(torrents map[string]*CachedTorrent) { func (c *Cache) setTorrents(torrents map[string]*CachedTorrent) {
@@ -249,6 +253,7 @@ func (c *Cache) load() (map[string]*CachedTorrent, error) {
if len(ct.Files) != 0 { if len(ct.Files) != 0 {
// We can assume the torrent is complete // We can assume the torrent is complete
ct.IsComplete = true ct.IsComplete = true
ct.Torrent.Name = utils.RemoveExtension(ct.Torrent.Filename) // Update the name
torrents[ct.Id] = &ct torrents[ct.Id] = &ct
} }
} }