Add add_samples to available flags
This commit is contained in:
@@ -27,6 +27,7 @@ type Debrid struct {
|
||||
CheckCached bool `json:"check_cached,omitempty"`
|
||||
RateLimit string `json:"rate_limit,omitempty"` // 200/minute or 10/second
|
||||
Proxy string `json:"proxy,omitempty"`
|
||||
AddSamples bool `json:"add_samples,omitempty"`
|
||||
|
||||
UseWebDav bool `json:"use_webdav,omitempty"`
|
||||
WebDav
|
||||
|
||||
@@ -27,7 +27,8 @@ type AllDebrid struct {
|
||||
|
||||
MountPath string
|
||||
logger zerolog.Logger
|
||||
CheckCached bool
|
||||
checkCached bool
|
||||
addSamples bool
|
||||
}
|
||||
|
||||
func New(dc config.Debrid) *AllDebrid {
|
||||
@@ -62,7 +63,8 @@ func New(dc config.Debrid) *AllDebrid {
|
||||
client: client,
|
||||
MountPath: dc.Folder,
|
||||
logger: logger.New(dc.Name),
|
||||
CheckCached: dc.CheckCached,
|
||||
checkCached: dc.CheckCached,
|
||||
addSamples: dc.AddSamples,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +122,7 @@ func getAlldebridStatus(statusCode int) string {
|
||||
}
|
||||
}
|
||||
|
||||
func flattenFiles(torrentId string, files []MagnetFile, parentPath string, index *int) map[string]types.File {
|
||||
func (ad *AllDebrid) flattenFiles(torrentId string, files []MagnetFile, parentPath string, index *int) map[string]types.File {
|
||||
result := make(map[string]types.File)
|
||||
|
||||
cfg := config.Get()
|
||||
@@ -133,7 +135,7 @@ func flattenFiles(torrentId string, files []MagnetFile, parentPath string, index
|
||||
|
||||
if f.Elements != nil {
|
||||
// This is a folder, recurse into it
|
||||
subFiles := flattenFiles(torrentId, f.Elements, currentPath, index)
|
||||
subFiles := ad.flattenFiles(torrentId, f.Elements, currentPath, index)
|
||||
for k, v := range subFiles {
|
||||
if _, ok := result[k]; ok {
|
||||
// File already exists, use path as key
|
||||
@@ -147,7 +149,7 @@ func flattenFiles(torrentId string, files []MagnetFile, parentPath string, index
|
||||
fileName := filepath.Base(f.Name)
|
||||
|
||||
// Skip sample files
|
||||
if utils.IsSampleFile(f.Name) {
|
||||
if !ad.addSamples && utils.IsSampleFile(f.Name) {
|
||||
continue
|
||||
}
|
||||
if !cfg.IsAllowedFile(fileName) {
|
||||
@@ -207,7 +209,7 @@ func (ad *AllDebrid) GetTorrent(torrentId string) (*types.Torrent, error) {
|
||||
if status == "downloaded" {
|
||||
t.Progress = 100
|
||||
index := -1
|
||||
files := flattenFiles(t.Id, data.Files, "", &index)
|
||||
files := ad.flattenFiles(t.Id, data.Files, "", &index)
|
||||
t.Files = files
|
||||
} else {
|
||||
t.Progress = float64(data.Downloaded) / float64(data.Size) * 100
|
||||
@@ -245,7 +247,7 @@ func (ad *AllDebrid) UpdateTorrent(t *types.Torrent) error {
|
||||
if status == "downloaded" {
|
||||
t.Progress = 100
|
||||
index := -1
|
||||
files := flattenFiles(t.Id, data.Files, "", &index)
|
||||
files := ad.flattenFiles(t.Id, data.Files, "", &index)
|
||||
t.Files = files
|
||||
} else {
|
||||
t.Progress = float64(data.Downloaded) / float64(data.Size) * 100
|
||||
@@ -373,7 +375,7 @@ func (ad *AllDebrid) GetDownloadLink(t *types.Torrent, file *types.File) (*types
|
||||
}
|
||||
|
||||
func (ad *AllDebrid) GetCheckCached() bool {
|
||||
return ad.CheckCached
|
||||
return ad.checkCached
|
||||
}
|
||||
|
||||
func (ad *AllDebrid) GetTorrents() ([]*types.Torrent, error) {
|
||||
|
||||
@@ -27,7 +27,8 @@ type DebridLink struct {
|
||||
|
||||
MountPath string
|
||||
logger zerolog.Logger
|
||||
CheckCached bool
|
||||
checkCached bool
|
||||
addSamples bool
|
||||
}
|
||||
|
||||
func (dl *DebridLink) GetName() string {
|
||||
@@ -327,7 +328,7 @@ func (dl *DebridLink) GetDownloadingStatus() []string {
|
||||
}
|
||||
|
||||
func (dl *DebridLink) GetCheckCached() bool {
|
||||
return dl.CheckCached
|
||||
return dl.checkCached
|
||||
}
|
||||
|
||||
func (dl *DebridLink) GetDownloadUncached() bool {
|
||||
@@ -367,7 +368,8 @@ func New(dc config.Debrid) *DebridLink {
|
||||
client: client,
|
||||
MountPath: dc.Folder,
|
||||
logger: logger.New(dc.Name),
|
||||
CheckCached: dc.CheckCached,
|
||||
checkCached: dc.CheckCached,
|
||||
addSamples: dc.AddSamples,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,8 @@ type RealDebrid struct {
|
||||
|
||||
MountPath string
|
||||
logger zerolog.Logger
|
||||
CheckCached bool
|
||||
checkCached bool
|
||||
addSamples bool
|
||||
}
|
||||
|
||||
func New(dc config.Debrid) *RealDebrid {
|
||||
@@ -87,7 +88,8 @@ func New(dc config.Debrid) *RealDebrid {
|
||||
currentDownloadKey: currentDownloadKey,
|
||||
MountPath: dc.Folder,
|
||||
logger: logger.New(dc.Name),
|
||||
CheckCached: dc.CheckCached,
|
||||
checkCached: dc.CheckCached,
|
||||
addSamples: dc.AddSamples,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,14 +130,14 @@ func getSelectedFiles(t *types.Torrent, data torrentInfo) map[string]types.File
|
||||
// getTorrentFiles returns a list of torrent files from the torrent info
|
||||
// validate is used to determine if the files should be validated
|
||||
// if validate is false, selected files will be returned
|
||||
func getTorrentFiles(t *types.Torrent, data torrentInfo) map[string]types.File {
|
||||
func (r *RealDebrid) getTorrentFiles(t *types.Torrent, data torrentInfo) map[string]types.File {
|
||||
files := make(map[string]types.File)
|
||||
cfg := config.Get()
|
||||
idx := 0
|
||||
|
||||
for _, f := range data.Files {
|
||||
name := filepath.Base(f.Path)
|
||||
if utils.IsSampleFile(f.Path) {
|
||||
if !r.addSamples && utils.IsSampleFile(f.Path) {
|
||||
// Skip sample files
|
||||
continue
|
||||
}
|
||||
@@ -296,7 +298,7 @@ func (r *RealDebrid) GetTorrent(torrentId string) (*types.Torrent, error) {
|
||||
Debrid: r.Name,
|
||||
MountPath: r.MountPath,
|
||||
}
|
||||
t.Files = getTorrentFiles(t, data) // Get selected files
|
||||
t.Files = r.getTorrentFiles(t, data) // Get selected files
|
||||
return t, nil
|
||||
}
|
||||
|
||||
@@ -367,7 +369,7 @@ func (r *RealDebrid) CheckStatus(t *types.Torrent, isSymlink bool) (*types.Torre
|
||||
t.Debrid = r.Name
|
||||
t.MountPath = r.MountPath
|
||||
if status == "waiting_files_selection" {
|
||||
t.Files = getTorrentFiles(t, data)
|
||||
t.Files = r.getTorrentFiles(t, data)
|
||||
if len(t.Files) == 0 {
|
||||
return t, fmt.Errorf("no video files found")
|
||||
}
|
||||
@@ -581,7 +583,7 @@ func (r *RealDebrid) GetDownloadLink(t *types.Torrent, file *types.File) (*types
|
||||
}
|
||||
|
||||
func (r *RealDebrid) GetCheckCached() bool {
|
||||
return r.CheckCached
|
||||
return r.checkCached
|
||||
}
|
||||
|
||||
func (r *RealDebrid) getTorrents(offset int, limit int) (int, []*types.Torrent, error) {
|
||||
|
||||
@@ -33,7 +33,8 @@ type Torbox struct {
|
||||
|
||||
MountPath string
|
||||
logger zerolog.Logger
|
||||
CheckCached bool
|
||||
checkCached bool
|
||||
addSamples bool
|
||||
}
|
||||
|
||||
func New(dc config.Debrid) *Torbox {
|
||||
@@ -70,7 +71,8 @@ func New(dc config.Debrid) *Torbox {
|
||||
client: client,
|
||||
MountPath: dc.Folder,
|
||||
logger: _log,
|
||||
CheckCached: dc.CheckCached,
|
||||
checkCached: dc.CheckCached,
|
||||
addSamples: dc.AddSamples,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +218,7 @@ func (tb *Torbox) GetTorrent(torrentId string) (*types.Torrent, error) {
|
||||
cfg := config.Get()
|
||||
for _, f := range data.Files {
|
||||
fileName := filepath.Base(f.Name)
|
||||
if utils.IsSampleFile(f.AbsolutePath) {
|
||||
if !tb.addSamples && utils.IsSampleFile(f.AbsolutePath) {
|
||||
// Skip sample files
|
||||
continue
|
||||
}
|
||||
@@ -277,7 +279,7 @@ func (tb *Torbox) UpdateTorrent(t *types.Torrent) error {
|
||||
cfg := config.Get()
|
||||
for _, f := range data.Files {
|
||||
fileName := filepath.Base(f.Name)
|
||||
if utils.IsSampleFile(f.AbsolutePath) {
|
||||
if !tb.addSamples && utils.IsSampleFile(f.AbsolutePath) {
|
||||
// Skip sample files
|
||||
continue
|
||||
}
|
||||
@@ -431,7 +433,7 @@ func (tb *Torbox) GetDownloadingStatus() []string {
|
||||
}
|
||||
|
||||
func (tb *Torbox) GetCheckCached() bool {
|
||||
return tb.CheckCached
|
||||
return tb.checkCached
|
||||
}
|
||||
|
||||
func (tb *Torbox) GetTorrents() ([]*types.Torrent, error) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/sirrobot01/decypharr/internal/config"
|
||||
"github.com/sirrobot01/decypharr/internal/logger"
|
||||
"github.com/sirrobot01/decypharr/internal/utils"
|
||||
"github.com/sirrobot01/decypharr/pkg/arr"
|
||||
@@ -88,26 +87,6 @@ type File struct {
|
||||
Generated time.Time `json:"generated"`
|
||||
}
|
||||
|
||||
func (f *File) IsValid() bool {
|
||||
cfg := config.Get()
|
||||
name := filepath.Base(f.Path)
|
||||
if utils.IsSampleFile(f.Path) {
|
||||
return false
|
||||
}
|
||||
|
||||
if !cfg.IsAllowedFile(name) {
|
||||
return false
|
||||
}
|
||||
if !cfg.IsSizeAllowed(f.Size) {
|
||||
return false
|
||||
}
|
||||
|
||||
if f.Link == "" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (t *Torrent) Cleanup(remove bool) {
|
||||
if remove {
|
||||
err := os.Remove(t.Filename)
|
||||
|
||||
@@ -341,21 +341,28 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-3">
|
||||
<div class="form-check me-3">
|
||||
<input type="checkbox" class="form-check-input" name="debrid[${index}].download_uncached" id="debrid[${index}].download_uncached">
|
||||
<label class="form-check-label" for="debrid[${index}].download_uncached">Download Uncached</label>
|
||||
</div>
|
||||
<small class="form-text text-muted">Download uncached files from the debrid service</small>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-3">
|
||||
<div class="form-check me-3">
|
||||
<input type="checkbox" class="form-check-input" name="debrid[${index}].check_cached" id="debrid[${index}].check_cached">
|
||||
<label class="form-check-label" for="debrid[${index}].check_cached" disabled>Check Cached</label>
|
||||
</div>
|
||||
<small class="form-text text-muted">Check if the file is cached before downloading(Disabled)</small>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-3">
|
||||
<div class="form-check me-3">
|
||||
<input type="checkbox" class="form-check-input addSamples" name="debrid[${index}].add_samples" id="debrid[${index}].add_samples">
|
||||
<label class="form-check-label" for="debrid[${index}].add_samples">Add Samples</label>
|
||||
</div>
|
||||
<small class="form-text text-muted">Add samples, extras etc when adding torrent to debrid(disabled by default)</small>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-check me-3">
|
||||
<input type="checkbox" class="form-check-input useWebdav" name="debrid[${index}].use_webdav" id="debrid[${index}].use_webdav">
|
||||
<label class="form-check-label" for="debrid[${index}].use_webdav">Enable WebDav Server</label>
|
||||
@@ -1074,6 +1081,7 @@
|
||||
rate_limit: document.querySelector(`[name="debrid[${i}].rate_limit"]`).value,
|
||||
download_uncached: document.querySelector(`[name="debrid[${i}].download_uncached"]`).checked,
|
||||
check_cached: document.querySelector(`[name="debrid[${i}].check_cached"]`).checked,
|
||||
add_samples: document.querySelector(`[name="debrid[${i}].add_samples"]`).checked,
|
||||
use_webdav: document.querySelector(`[name="debrid[${i}].use_webdav"]`).checked
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user