Fix AllDebrid symlink bug
This commit is contained in:
13
README.md
13
README.md
@@ -39,8 +39,7 @@ services:
|
||||
user: "1000:1000"
|
||||
volumes:
|
||||
- ./logs:/app/logs
|
||||
- ~/plex/media:/media
|
||||
- ~/plex/media/symlinks/:/media/symlinks/
|
||||
- /mnt/:/mnt
|
||||
- ~/plex/configs/blackhole/config.json:/app/config.json # Config file, see below
|
||||
environment:
|
||||
- PUID=1000
|
||||
@@ -92,7 +91,7 @@ This is the default config file. You can create a `config.json` file in the root
|
||||
"name": "torbox",
|
||||
"host": "https://api.torbox.app/v1",
|
||||
"api_key": "torbox_api_key",
|
||||
"folder": "data/torbox/torrents/",
|
||||
"folder": "/mnt/remote/torbox/torrents/",
|
||||
"rate_limit": "250/minute",
|
||||
"download_uncached": false,
|
||||
"check_cached": true
|
||||
@@ -101,7 +100,7 @@ This is the default config file. You can create a `config.json` file in the root
|
||||
"name": "realdebrid",
|
||||
"host": "https://api.real-debrid.com/rest/1.0",
|
||||
"api_key": "realdebrid_key",
|
||||
"folder": "data/realdebrid/torrents/",
|
||||
"folder": "/mnt/remote/realdebrid/__all__/",
|
||||
"rate_limit": "250/minute",
|
||||
"download_uncached": false,
|
||||
"check_cached": false
|
||||
@@ -110,7 +109,7 @@ This is the default config file. You can create a `config.json` file in the root
|
||||
"name": "debridlink",
|
||||
"host": "https://debrid-link.com/api/v2",
|
||||
"api_key": "debridlink_key",
|
||||
"folder": "data/debridlink/torrents/",
|
||||
"folder": "/mnt/remote/debridlink/torrents/",
|
||||
"rate_limit": "250/minute",
|
||||
"download_uncached": false,
|
||||
"check_cached": false
|
||||
@@ -119,7 +118,7 @@ This is the default config file. You can create a `config.json` file in the root
|
||||
"name": "alldebrid",
|
||||
"host": "http://api.alldebrid.com/v4.1",
|
||||
"api_key": "alldebrid_key",
|
||||
"folder": "/media/remote/alldebrid/magnet/",
|
||||
"folder": "/mnt/remote/alldebrid/magnet/",
|
||||
"rate_limit": "600/minute",
|
||||
"download_uncached": false,
|
||||
"check_cached": false
|
||||
@@ -136,7 +135,7 @@ This is the default config file. You can create a `config.json` file in the root
|
||||
"max_cache_size": 1000,
|
||||
"qbittorrent": {
|
||||
"port": "8282",
|
||||
"download_folder": "/media/symlinks/",
|
||||
"download_folder": "/mnt/symlinks/",
|
||||
"categories": ["sonarr", "radarr"],
|
||||
"refresh_interval": 5,
|
||||
"log_level": "info"
|
||||
|
||||
@@ -112,7 +112,9 @@ func (as *Storage) GetAll() []*Arr {
|
||||
defer as.mu.RUnlock()
|
||||
arrs := make([]*Arr, 0, len(as.Arrs))
|
||||
for _, arr := range as.Arrs {
|
||||
arrs = append(arrs, arr)
|
||||
if arr.Host != "" && arr.Token != "" {
|
||||
arrs = append(arrs, arr)
|
||||
}
|
||||
}
|
||||
return arrs
|
||||
}
|
||||
|
||||
@@ -133,27 +133,30 @@ func (r *AllDebrid) GetTorrent(id string) (*Torrent, error) {
|
||||
return torrent, err
|
||||
}
|
||||
data := res.Data.Magnets
|
||||
status := getAlldebridStatus(data.StatusCode)
|
||||
name := data.Filename
|
||||
torrent.Id = id
|
||||
torrent.Name = name
|
||||
torrent.Bytes = data.Size
|
||||
torrent.Folder = name
|
||||
torrent.Progress = float64((data.Downloaded / data.Size) * 100)
|
||||
torrent.Status = getAlldebridStatus(data.StatusCode)
|
||||
torrent.Speed = data.DownloadSpeed
|
||||
torrent.Seeders = data.Seeders
|
||||
torrent.Status = status
|
||||
torrent.Filename = name
|
||||
torrent.OriginalFilename = name
|
||||
index := -1
|
||||
files := flattenFiles(data.Files, "", &index)
|
||||
parentFolder := data.Filename
|
||||
torrent.Folder = name
|
||||
if status == "downloaded" {
|
||||
torrent.Bytes = data.Size
|
||||
|
||||
if data.NbLinks == 1 {
|
||||
// All debrid doesn't return the parent folder for single file torrents
|
||||
parentFolder = ""
|
||||
torrent.Progress = float64((data.Downloaded / data.Size) * 100)
|
||||
torrent.Speed = data.DownloadSpeed
|
||||
torrent.Seeders = data.Seeders
|
||||
index := -1
|
||||
files := flattenFiles(data.Files, "", &index)
|
||||
parentFolder := data.Filename
|
||||
if data.NbLinks == 1 {
|
||||
// All debrid doesn't return the parent folder for single file torrents
|
||||
parentFolder = ""
|
||||
}
|
||||
torrent.OriginalFilename = parentFolder
|
||||
torrent.Files = files
|
||||
}
|
||||
torrent.OriginalFilename = parentFolder
|
||||
torrent.Files = files
|
||||
torrent.Debrid = r
|
||||
return torrent, nil
|
||||
}
|
||||
|
||||
@@ -134,6 +134,7 @@ func (r *DebridLink) GetTorrent(id string) (*Torrent, error) {
|
||||
Id: f.ID,
|
||||
Name: f.Name,
|
||||
Size: f.Size,
|
||||
Path: f.Name,
|
||||
}
|
||||
}
|
||||
torrent.Files = files
|
||||
@@ -178,6 +179,7 @@ func (r *DebridLink) SubmitMagnet(torrent *Torrent) (*Torrent, error) {
|
||||
Id: f.ID,
|
||||
Name: f.Name,
|
||||
Size: f.Size,
|
||||
Path: f.Name,
|
||||
Link: f.DownloadURL,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,5 +248,11 @@ func (u *uiHandler) handleDeleteTorrent(w http.ResponseWriter, r *http.Request)
|
||||
|
||||
func (u *uiHandler) handleGetConfig(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
common.JSONResponse(w, common.CONFIG, http.StatusOK)
|
||||
config := common.CONFIG
|
||||
arrCfgs := make([]common.ArrConfig, 0)
|
||||
for _, a := range u.qbit.Arrs.GetAll() {
|
||||
arrCfgs = append(arrCfgs, common.ArrConfig{Host: a.Host, Name: a.Name, Token: a.Token})
|
||||
}
|
||||
config.Arrs = arrCfgs
|
||||
common.JSONResponse(w, config, http.StatusOK)
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ func (q *QBit) createSymLink(path string, torrentMountPath string, file debrid.T
|
||||
// Combine the directory and filename to form a full path
|
||||
fullPath := filepath.Join(path, file.Name) // /mnt/symlinks/{category}/MyTVShow/MyTVShow.S01E01.720p.mkv
|
||||
// Create a symbolic link if file doesn't exist
|
||||
torrentFilePath := filepath.Join(torrentMountPath, file.Name) // debridFolder/MyTVShow/MyTVShow.S01E01.720p.mkv
|
||||
torrentFilePath := filepath.Join(torrentMountPath, file.Path) // debridFolder/MyTVShow/MyTVShow.S01E01.720p.mkv
|
||||
err := os.Symlink(torrentFilePath, fullPath)
|
||||
if err != nil {
|
||||
q.logger.Info().Msgf("Failed to create symlink: %s: %v", fullPath, err)
|
||||
|
||||
Reference in New Issue
Block a user