Additional playable extensions
This commit is contained in:
@@ -30,40 +30,38 @@ type ConfigInterface interface {
|
||||
GetRateLimitSleepSecs() int
|
||||
ShouldDeleteRarFiles() bool
|
||||
GetDownloadsEveryMins() int
|
||||
GetPlayableExtensions() []string
|
||||
}
|
||||
|
||||
type ZurgConfig struct {
|
||||
Version string `yaml:"zurg" json:"-"`
|
||||
Token string `yaml:"token" json:"-"`
|
||||
|
||||
Host string `yaml:"host" json:"host"`
|
||||
Port string `yaml:"port" json:"port"`
|
||||
Username string `yaml:"username" json:"username"`
|
||||
Password string `yaml:"password" json:"password"`
|
||||
Proxy string `yaml:"proxy" json:"proxy"`
|
||||
NumOfWorkers int `yaml:"concurrent_workers" json:"concurrent_workers"`
|
||||
RefreshEverySecs int `yaml:"check_for_changes_every_secs" json:"check_for_changes_every_secs"`
|
||||
RepairEveryMins int `yaml:"repair_every_mins" json:"repair_every_mins"`
|
||||
DownloadsEveryMins int `yaml:"downloads_every_mins" json:"downloads_every_mins"`
|
||||
|
||||
IgnoreRenames bool `yaml:"ignore_renames" json:"ignore_renames"`
|
||||
RetainRDTorrentName bool `yaml:"retain_rd_torrent_name" json:"retain_rd_torrent_name"`
|
||||
RetainFolderNameExtension bool `yaml:"retain_folder_name_extension" json:"retain_folder_name_extension"`
|
||||
|
||||
CanRepair bool `yaml:"enable_repair" json:"enable_repair"`
|
||||
DeleteRarFiles bool `yaml:"auto_delete_rar_torrents" json:"auto_delete_rar_torrents"`
|
||||
|
||||
ApiTimeoutSecs int `yaml:"api_timeout_secs" json:"api_timeout_secs"`
|
||||
DownloadTimeoutSecs int `yaml:"download_timeout_secs" json:"download_timeout_secs"`
|
||||
DownloadMount bool `yaml:"enable_download_mount" json:"enable_download_mount"`
|
||||
RateLimitSleepSecs int `yaml:"rate_limit_sleep_secs" json:"rate_limit_sleep_secs"`
|
||||
RetriesUntilFailed int `yaml:"retries_until_failed" json:"retries_until_failed"`
|
||||
NetworkBufferSize int `yaml:"network_buffer_size" json:"network_buffer_size"`
|
||||
ServeFromRclone bool `yaml:"serve_from_rclone" json:"serve_from_rclone"`
|
||||
VerifyDownloadLink bool `yaml:"verify_download_link" json:"verify_download_link"`
|
||||
ForceIPv6 bool `yaml:"force_ipv6" json:"force_ipv6"`
|
||||
|
||||
OnLibraryUpdate string `yaml:"on_library_update" json:"on_library_update"`
|
||||
ApiTimeoutSecs int `yaml:"api_timeout_secs" json:"api_timeout_secs"`
|
||||
CanRepair bool `yaml:"enable_repair" json:"enable_repair"`
|
||||
DeleteRarFiles bool `yaml:"auto_delete_rar_torrents" json:"auto_delete_rar_torrents"`
|
||||
DownloadMount bool `yaml:"enable_download_mount" json:"enable_download_mount"`
|
||||
DownloadsEveryMins int `yaml:"downloads_every_mins" json:"downloads_every_mins"`
|
||||
DownloadTimeoutSecs int `yaml:"download_timeout_secs" json:"download_timeout_secs"`
|
||||
ForceIPv6 bool `yaml:"force_ipv6" json:"force_ipv6"`
|
||||
Host string `yaml:"host" json:"host"`
|
||||
IgnoreRenames bool `yaml:"ignore_renames" json:"ignore_renames"`
|
||||
NetworkBufferSize int `yaml:"network_buffer_size" json:"network_buffer_size"`
|
||||
NumOfWorkers int `yaml:"concurrent_workers" json:"concurrent_workers"`
|
||||
OnLibraryUpdate string `yaml:"on_library_update" json:"on_library_update"`
|
||||
Password string `yaml:"password" json:"password"`
|
||||
PlayableExtensions []string `yaml:"addl_playable_extensions" json:"addl_playable_extensions"`
|
||||
Port string `yaml:"port" json:"port"`
|
||||
Proxy string `yaml:"proxy" json:"proxy"`
|
||||
RateLimitSleepSecs int `yaml:"rate_limit_sleep_secs" json:"rate_limit_sleep_secs"`
|
||||
RefreshEverySecs int `yaml:"check_for_changes_every_secs" json:"check_for_changes_every_secs"`
|
||||
RepairEveryMins int `yaml:"repair_every_mins" json:"repair_every_mins"`
|
||||
RetainFolderNameExtension bool `yaml:"retain_folder_name_extension" json:"retain_folder_name_extension"`
|
||||
RetainRDTorrentName bool `yaml:"retain_rd_torrent_name" json:"retain_rd_torrent_name"`
|
||||
RetriesUntilFailed int `yaml:"retries_until_failed" json:"retries_until_failed"`
|
||||
ServeFromRclone bool `yaml:"serve_from_rclone" json:"serve_from_rclone"`
|
||||
Username string `yaml:"username" json:"username"`
|
||||
VerifyDownloadLink bool `yaml:"verify_download_link" json:"verify_download_link"`
|
||||
}
|
||||
|
||||
func (z *ZurgConfig) GetConfig() ZurgConfig {
|
||||
@@ -202,3 +200,10 @@ func (z *ZurgConfig) GetRateLimitSleepSecs() int {
|
||||
func (z *ZurgConfig) ShouldDeleteRarFiles() bool {
|
||||
return z.DeleteRarFiles
|
||||
}
|
||||
|
||||
func (z *ZurgConfig) GetPlayableExtensions() []string {
|
||||
if len(z.PlayableExtensions) == 0 {
|
||||
return []string{}
|
||||
}
|
||||
return z.PlayableExtensions
|
||||
}
|
||||
|
||||
@@ -319,14 +319,14 @@ func checkArithmeticSequenceInFilenames(files []string) bool {
|
||||
}
|
||||
r := regexp.MustCompile(`\d+`)
|
||||
for _, file := range files {
|
||||
if !utils.IsStreamable(file) {
|
||||
if !utils.IsPlayable(file) {
|
||||
continue
|
||||
}
|
||||
matches := r.FindAllStringIndex(file, -1)
|
||||
for _, match := range matches {
|
||||
numSet := make(map[int]struct{})
|
||||
for _, file := range files {
|
||||
if !utils.IsStreamable(file) {
|
||||
if !utils.IsPlayable(file) {
|
||||
continue
|
||||
}
|
||||
if match[0] >= 0 && match[1] <= len(file) {
|
||||
|
||||
1
internal/torrent/rclone mount flags.txt
Normal file
1
internal/torrent/rclone mount flags.txt
Normal file
@@ -0,0 +1 @@
|
||||
dir-cache-time=10s --vfs-cache-mode full --vfs-read-chunk-size 64M --vfs-read-chunk-size-limit 2G --buffer-size 52M --vfs-cache-max-age 150h --vfs-cache-max-size 370G --vfs-fast-fingerprint
|
||||
@@ -321,7 +321,7 @@ func (t *TorrentManager) assignedDirectoryCb(tor *Torrent, cb func(string)) {
|
||||
tor.SelectedFiles.IterCb(func(key string, file *File) {
|
||||
filenames = append(filenames, filepath.Base(file.Path))
|
||||
fileSizes = append(fileSizes, file.Bytes)
|
||||
if unplayable && utils.IsStreamable(file.Path) {
|
||||
if unplayable && (utils.IsPlayable(file.Path) || t.IsPlayable(file.Path)) {
|
||||
unplayable = false
|
||||
}
|
||||
})
|
||||
@@ -343,3 +343,14 @@ func (t *TorrentManager) assignedDirectoryCb(tor *Torrent, cb func(string)) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TorrentManager) IsPlayable(filePath string) bool {
|
||||
filePath = strings.ToLower(filePath)
|
||||
playableExts := t.Config.GetPlayableExtensions()
|
||||
for _, ext := range playableExts {
|
||||
if strings.HasSuffix(filePath, fmt.Sprintf(".%s", ext)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
15
pkg/utils/playable.go
Normal file
15
pkg/utils/playable.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package utils
|
||||
|
||||
import "strings"
|
||||
|
||||
func IsPlayable(filePath string) bool {
|
||||
filePath = strings.ToLower(filePath)
|
||||
return strings.HasSuffix(filePath, ".avi") ||
|
||||
strings.HasSuffix(filePath, ".m2ts") ||
|
||||
strings.HasSuffix(filePath, ".m4v") ||
|
||||
strings.HasSuffix(filePath, ".mkv") ||
|
||||
strings.HasSuffix(filePath, ".mp4") ||
|
||||
strings.HasSuffix(filePath, ".mpg") ||
|
||||
strings.HasSuffix(filePath, ".ts") ||
|
||||
strings.HasSuffix(filePath, ".wmv")
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package utils
|
||||
|
||||
import "strings"
|
||||
|
||||
func IsStreamable(filePath string) bool {
|
||||
filePath = strings.ToLower(filePath)
|
||||
return strings.HasSuffix(filePath, ".mkv") ||
|
||||
strings.HasSuffix(filePath, ".mp4") ||
|
||||
strings.HasSuffix(filePath, ".avi") ||
|
||||
strings.HasSuffix(filePath, ".wmv") ||
|
||||
strings.HasSuffix(filePath, ".m4v") ||
|
||||
strings.HasSuffix(filePath, ".ts")
|
||||
}
|
||||
Reference in New Issue
Block a user