wraps up duplicate names implementation
This commit is contained in:
@@ -27,6 +27,7 @@ DecyphArr includes several advanced features that extend its capabilities:
|
||||
|
||||
- [Repair Worker](repair-worker.md): Identifies and fixes issues with your media files
|
||||
- [WebDAV Server](webdav.md): Provides direct access to your Debrid files
|
||||
- [Using with Rclone](rclone.md): Mount the WebDAV server locally for easier access
|
||||
|
||||
## Supported Debrid Providers
|
||||
|
||||
|
||||
@@ -32,12 +32,11 @@ services:
|
||||
image: cy01/blackhole:latest # or cy01/blackhole:beta
|
||||
container_name: decypharr
|
||||
ports:
|
||||
- "8282:8282" # qBittorrent
|
||||
- "8181:8181" # Proxy
|
||||
- "8282:8282"
|
||||
user: "1000:1000"
|
||||
volumes:
|
||||
- /mnt/:/mnt
|
||||
- ./configs/:/app # config.json must be in this directory
|
||||
- ./config/:/app # config.json must be in this directory
|
||||
environment:
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
@@ -65,7 +64,31 @@ Create a configuration file (see Configuration)
|
||||
Run the binary:
|
||||
```bash
|
||||
chmod +x decypharr
|
||||
./decypharr --config /path/to/config
|
||||
./decypharr --config /path/to/config/folder
|
||||
```
|
||||
|
||||
The config directory should contain your config.json file.
|
||||
|
||||
## config.json
|
||||
|
||||
The `config.json` file is where you configure DecyphArr. You can find a sample configuration file in the `configs` directory of the repository.
|
||||
|
||||
```json
|
||||
{
|
||||
"debrids": [
|
||||
{
|
||||
"name": "realdebrid",
|
||||
"api_key": "your_api_key_here",
|
||||
"folder": "/mnt/remote/realdebrid/__all__/",
|
||||
"use_webdav": true
|
||||
}
|
||||
],
|
||||
"qbittorrent": {
|
||||
"download_folder": "/mnt/symlinks/",
|
||||
"categories": ["sonarr", "radarr"]
|
||||
},
|
||||
"use_auth": false,
|
||||
"log_level": "info",
|
||||
"port": "8282"
|
||||
}
|
||||
```
|
||||
@@ -122,7 +122,7 @@ func getAlldebridStatus(statusCode int) string {
|
||||
}
|
||||
}
|
||||
|
||||
func flattenFiles(files []MagnetFile, parentPath string, index *int) map[string]types.File {
|
||||
func flattenFiles(torrentId string, files []MagnetFile, parentPath string, index *int) map[string]types.File {
|
||||
result := make(map[string]types.File)
|
||||
|
||||
cfg := config.Get()
|
||||
@@ -135,7 +135,7 @@ func flattenFiles(files []MagnetFile, parentPath string, index *int) map[string]
|
||||
|
||||
if f.Elements != nil {
|
||||
// This is a folder, recurse into it
|
||||
subFiles := flattenFiles(f.Elements, currentPath, index)
|
||||
subFiles := flattenFiles(torrentId, f.Elements, currentPath, index)
|
||||
for k, v := range subFiles {
|
||||
if _, ok := result[k]; ok {
|
||||
// File already exists, use path as key
|
||||
@@ -162,11 +162,12 @@ func flattenFiles(files []MagnetFile, parentPath string, index *int) map[string]
|
||||
|
||||
*index++
|
||||
file := types.File{
|
||||
Id: strconv.Itoa(*index),
|
||||
Name: fileName,
|
||||
Size: f.Size,
|
||||
Path: currentPath,
|
||||
Link: f.Link,
|
||||
TorrentId: torrentId,
|
||||
Id: strconv.Itoa(*index),
|
||||
Name: fileName,
|
||||
Size: f.Size,
|
||||
Path: currentPath,
|
||||
Link: f.Link,
|
||||
}
|
||||
result[file.Name] = file
|
||||
}
|
||||
@@ -203,7 +204,7 @@ func (ad *AllDebrid) UpdateTorrent(t *types.Torrent) error {
|
||||
if status == "downloaded" {
|
||||
t.Progress = 100
|
||||
index := -1
|
||||
files := flattenFiles(data.Files, "", &index)
|
||||
files := flattenFiles(t.Id, data.Files, "", &index)
|
||||
t.Files = files
|
||||
} else {
|
||||
t.Progress = float64(data.Downloaded) / float64(data.Size) * 100
|
||||
|
||||
@@ -223,6 +223,7 @@ func (c *Cache) load() (map[string]*CachedTorrent, error) {
|
||||
if len(ct.Files) != 0 {
|
||||
// Check if all files are valid, if not, delete the file.json and remove from cache.
|
||||
for _, f := range ct.Files {
|
||||
f.TorrentId = ct.Id
|
||||
if f.Link == "" {
|
||||
isComplete = false
|
||||
break
|
||||
|
||||
@@ -134,7 +134,9 @@ func (c *Cache) reInsertTorrent(ct *CachedTorrent) (*CachedTorrent, error) {
|
||||
torrent, err = c.client.CheckStatus(torrent, true)
|
||||
if err != nil && torrent != nil {
|
||||
// Torrent is likely uncached, delete it
|
||||
_ = c.client.DeleteTorrent(torrent.Id) // Delete the newly added un-cached torrent
|
||||
if err := c.client.DeleteTorrent(torrent.Id); err != nil {
|
||||
c.logger.Error().Err(err).Str("torrentId", torrent.Id).Msg("Failed to delete torrent")
|
||||
} // Delete the newly added un-cached torrent
|
||||
return ct, fmt.Errorf("failed to check status: %w", err)
|
||||
}
|
||||
if torrent == nil {
|
||||
|
||||
@@ -137,10 +137,11 @@ func (dl *DebridLink) UpdateTorrent(t *types.Torrent) error {
|
||||
continue
|
||||
}
|
||||
file := types.File{
|
||||
Id: f.ID,
|
||||
Name: f.Name,
|
||||
Size: f.Size,
|
||||
Path: f.Name,
|
||||
TorrentId: t.Id,
|
||||
Id: f.ID,
|
||||
Name: f.Name,
|
||||
Size: f.Size,
|
||||
Path: f.Name,
|
||||
DownloadLink: &types.DownloadLink{
|
||||
Filename: f.Name,
|
||||
Link: f.DownloadURL,
|
||||
@@ -189,11 +190,12 @@ func (dl *DebridLink) SubmitMagnet(t *types.Torrent) (*types.Torrent, error) {
|
||||
t.Debrid = dl.Name
|
||||
for _, f := range data.Files {
|
||||
file := types.File{
|
||||
Id: f.ID,
|
||||
Name: f.Name,
|
||||
Size: f.Size,
|
||||
Path: f.Name,
|
||||
Link: f.DownloadURL,
|
||||
TorrentId: t.Id,
|
||||
Id: f.ID,
|
||||
Name: f.Name,
|
||||
Size: f.Size,
|
||||
Path: f.Name,
|
||||
Link: f.DownloadURL,
|
||||
DownloadLink: &types.DownloadLink{
|
||||
Filename: f.Name,
|
||||
Link: f.DownloadURL,
|
||||
@@ -370,10 +372,11 @@ func (dl *DebridLink) getTorrents(page, perPage int) ([]*types.Torrent, error) {
|
||||
continue
|
||||
}
|
||||
file := types.File{
|
||||
Id: f.ID,
|
||||
Name: f.Name,
|
||||
Size: f.Size,
|
||||
Path: f.Name,
|
||||
TorrentId: torrent.Id,
|
||||
Id: f.ID,
|
||||
Name: f.Name,
|
||||
Size: f.Size,
|
||||
Path: f.Name,
|
||||
DownloadLink: &types.DownloadLink{
|
||||
Filename: f.Name,
|
||||
Link: f.DownloadURL,
|
||||
|
||||
@@ -111,10 +111,11 @@ func getSelectedFiles(t *types.Torrent, data torrentInfo) map[string]types.File
|
||||
if f.Selected == 1 {
|
||||
name := filepath.Base(f.Path)
|
||||
file := types.File{
|
||||
Name: name,
|
||||
Path: name,
|
||||
Size: f.Bytes,
|
||||
Id: strconv.Itoa(f.ID),
|
||||
TorrentId: t.Id,
|
||||
Name: name,
|
||||
Path: name,
|
||||
Size: f.Bytes,
|
||||
Id: strconv.Itoa(f.ID),
|
||||
}
|
||||
selectedFiles = append(selectedFiles, file)
|
||||
}
|
||||
@@ -153,10 +154,11 @@ func getTorrentFiles(t *types.Torrent, data torrentInfo) map[string]types.File {
|
||||
}
|
||||
|
||||
file := types.File{
|
||||
Name: name,
|
||||
Path: name,
|
||||
Size: f.Bytes,
|
||||
Id: strconv.Itoa(f.ID),
|
||||
TorrentId: t.Id,
|
||||
Name: name,
|
||||
Path: name,
|
||||
Size: f.Bytes,
|
||||
Id: strconv.Itoa(f.ID),
|
||||
}
|
||||
files[name] = file
|
||||
idx++
|
||||
|
||||
@@ -220,10 +220,11 @@ func (tb *Torbox) UpdateTorrent(t *types.Torrent) error {
|
||||
continue
|
||||
}
|
||||
file := types.File{
|
||||
Id: strconv.Itoa(f.Id),
|
||||
Name: fileName,
|
||||
Size: f.Size,
|
||||
Path: fileName,
|
||||
TorrentId: t.Id,
|
||||
Id: strconv.Itoa(f.Id),
|
||||
Name: fileName,
|
||||
Size: f.Size,
|
||||
Path: fileName,
|
||||
}
|
||||
t.Files[fileName] = file
|
||||
}
|
||||
|
||||
@@ -183,9 +183,9 @@ func (h *Handler) OpenFile(ctx context.Context, name string, flag int, perm os.F
|
||||
// Torrent file level
|
||||
filename := strings.Join(parts[2:], "/")
|
||||
if file, ok := cachedTorrent.Files[filename]; ok {
|
||||
fi := &File{
|
||||
return &File{
|
||||
cache: h.cache,
|
||||
torrentId: cachedTorrent.Id,
|
||||
torrentId: file.TorrentId,
|
||||
fileId: file.Id,
|
||||
isDir: false,
|
||||
name: file.Name,
|
||||
@@ -193,8 +193,7 @@ func (h *Handler) OpenFile(ctx context.Context, name string, flag int, perm os.F
|
||||
link: file.Link,
|
||||
metadataOnly: metadataOnly,
|
||||
modTime: cachedTorrent.AddedOn,
|
||||
}
|
||||
return fi, nil
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user