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