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