Add support for rar extraction

This commit is contained in:
Ben Adrian Sarmiento
2024-06-05 09:20:40 +02:00
parent f977abc052
commit 62e6143e06
9 changed files with 112 additions and 46 deletions

View File

@@ -28,7 +28,7 @@ type ConfigInterface interface {
GetDownloadTimeoutSecs() int
GetRetriesUntilFailed() int
GetRateLimitSleepSecs() int
ShouldDeleteRarFiles() bool
GetRarAction() string
GetDownloadsEveryMins() int
GetDumpTorrentsEveryMins() int
GetPlayableExtensions() []string
@@ -41,7 +41,6 @@ type ZurgConfig struct {
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"`
DownloadsEveryMins int `yaml:"downloads_every_mins" json:"downloads_every_mins"`
DownloadsLimit int `yaml:"downloads_limit" json:"downloads_limit"`
DumpTorrentsEveryMins int `yaml:"dump_torrents_every_mins" json:"dump_torrents_every_mins"`
@@ -65,6 +64,7 @@ type ZurgConfig struct {
ServeFromRclone bool `yaml:"serve_from_rclone" json:"serve_from_rclone"`
TorrentsCount int `yaml:"get_torrents_count" json:"get_torrents_count"`
Username string `yaml:"username" json:"username"`
RarAction string `yaml:"rar_action" json:"rar_action"`
}
func (z *ZurgConfig) GetConfig() ZurgConfig {
@@ -205,8 +205,15 @@ func (z *ZurgConfig) GetRateLimitSleepSecs() int {
return z.RateLimitSleepSecs
}
func (z *ZurgConfig) ShouldDeleteRarFiles() bool {
return z.DeleteRarFiles
// GetRarAction returns the action to take when a rar'ed torrent is found
// none: do nothing (mark as unrepairable)
// extract: extract the rar'ed torrent
// delete: delete the rar'ed torrent
func (z *ZurgConfig) GetRarAction() string {
if z.RarAction == "" {
return "none"
}
return z.RarAction
}
func (z *ZurgConfig) GetPlayableExtensions() []string {