Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87bf8d0574 | ||
|
|
d313ed0712 |
@@ -1,12 +1,12 @@
|
|||||||
# DecyphArr
|
# Decypharr
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
**DecyphArr** is an implementation of QbitTorrent with **Multiple Debrid service support**, written in Go.
|
**Decypharr** is an implementation of QbitTorrent with **Multiple Debrid service support**, written in Go.
|
||||||
|
|
||||||
## What is DecyphArr?
|
## What is Decypharr?
|
||||||
|
|
||||||
DecyphArr combines the power of QBittorrent with popular Debrid services to enhance your media management. It provides a familiar interface for Sonarr, Radarr, and other \*Arr applications while leveraging the capabilities of Debrid providers.
|
Decypharr combines the power of QBittorrent with popular Debrid services to enhance your media management. It provides a familiar interface for Sonarr, Radarr, and other \*Arr applications while leveraging the capabilities of Debrid providers.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
|||||||
@@ -193,9 +193,9 @@ func (q *QBit) ProcessSymlink(torrent *Torrent) (string, error) {
|
|||||||
}
|
}
|
||||||
pending[file.Path] = file
|
pending[file.Path] = file
|
||||||
}
|
}
|
||||||
|
|
||||||
ticker := time.NewTicker(200 * time.Millisecond)
|
ticker := time.NewTicker(200 * time.Millisecond)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
|
||||||
timeout := time.After(30 * time.Minute)
|
timeout := time.After(30 * time.Minute)
|
||||||
filePaths := make([]string, 0, len(pending))
|
filePaths := make([]string, 0, len(pending))
|
||||||
|
|
||||||
@@ -300,70 +300,6 @@ func (q *QBit) createSymlinksWebdav(debridTorrent *debridTypes.Torrent, rclonePa
|
|||||||
return symlinkPath, nil
|
return symlinkPath, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *QBit) createSymlinks(debridTorrent *debridTypes.Torrent, rclonePath, torrentFolder string) (string, error) {
|
|
||||||
files := debridTorrent.Files
|
|
||||||
symlinkPath := filepath.Join(q.DownloadFolder, debridTorrent.Arr.Name, torrentFolder) // /mnt/symlinks/{category}/MyTVShow/
|
|
||||||
err := os.MkdirAll(symlinkPath, os.ModePerm)
|
|
||||||
if err != nil {
|
|
||||||
return "", fmt.Errorf("failed to create directory: %s: %v", symlinkPath, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
remainingFiles := make(map[string]debridTypes.File)
|
|
||||||
for _, file := range files {
|
|
||||||
remainingFiles[file.Path] = file
|
|
||||||
}
|
|
||||||
|
|
||||||
ticker := time.NewTicker(100 * time.Millisecond)
|
|
||||||
defer ticker.Stop()
|
|
||||||
timeout := time.After(30 * time.Minute)
|
|
||||||
filePaths := make([]string, 0, len(files))
|
|
||||||
|
|
||||||
for len(remainingFiles) > 0 {
|
|
||||||
select {
|
|
||||||
case <-ticker.C:
|
|
||||||
entries, err := os.ReadDir(rclonePath)
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check which files exist in this batch
|
|
||||||
for _, entry := range entries {
|
|
||||||
filename := entry.Name()
|
|
||||||
if file, exists := remainingFiles[filename]; exists {
|
|
||||||
fullFilePath := filepath.Join(rclonePath, filename)
|
|
||||||
fileSymlinkPath := filepath.Join(symlinkPath, file.Name)
|
|
||||||
|
|
||||||
if err := os.Symlink(fullFilePath, fileSymlinkPath); err != nil && !os.IsExist(err) {
|
|
||||||
q.logger.Debug().Msgf("Failed to create symlink: %s: %v", fileSymlinkPath, err)
|
|
||||||
} else {
|
|
||||||
filePaths = append(filePaths, fileSymlinkPath)
|
|
||||||
delete(remainingFiles, filename)
|
|
||||||
q.logger.Info().Msgf("File is ready: %s", file.Name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case <-timeout:
|
|
||||||
q.logger.Warn().Msgf("Timeout waiting for files, %d files still pending", len(remainingFiles))
|
|
||||||
return symlinkPath, fmt.Errorf("timeout waiting for files")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if q.SkipPreCache {
|
|
||||||
return symlinkPath, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
|
|
||||||
if err := q.preCacheFile(debridTorrent.Name, filePaths); err != nil {
|
|
||||||
q.logger.Error().Msgf("Failed to pre-cache file: %s", err)
|
|
||||||
} else {
|
|
||||||
q.logger.Trace().Msgf("Pre-cached %d files", len(filePaths))
|
|
||||||
}
|
|
||||||
}() // Pre-cache the files in the background
|
|
||||||
return symlinkPath, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *QBit) getTorrentPath(rclonePath string, debridTorrent *debridTypes.Torrent) (string, error) {
|
func (q *QBit) getTorrentPath(rclonePath string, debridTorrent *debridTypes.Torrent) (string, error) {
|
||||||
for {
|
for {
|
||||||
torrentPath, err := debridTorrent.GetMountFolder(rclonePath)
|
torrentPath, err := debridTorrent.GetMountFolder(rclonePath)
|
||||||
|
|||||||
Reference in New Issue
Block a user