Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Commit

Permalink
movie/show regex editable in advanced config
Browse files Browse the repository at this point in the history
  • Loading branch information
itsToggle authored Oct 10, 2022
1 parent 4819ea9 commit f88df7b
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions backend/realdebrid/realdebrid.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ func init() {
Help: `please choose wether files should be grouped in torrent folders, or all files should be displayed in the root directory. For all files in root type "files", for folder structure type "folders". Default: "folders"`,
Advanced: true,
Default: "folders",
}, {
Name: "regex_shows",
Help: `please define the regex definition that will determine if a torrent should be classified as a show. Default: "(?i)(S[0-9]{2}|SEASON|COMPLETE|[0-9]+-[0-9]+)"`,
Advanced: true,
Default: "(?i)(S[0-9]{2}|SEASON|COMPLETE|[0-9]+-[0-9]+)",
}, {
Name: "regex_movies",
Help: `please define the regex definition that will determine if a torrent should be classified as a movie. Default: "(?i)(19|20)([0-9]{2} ?\.?)"`,
Advanced: true,
Default: `(?i)(19|20)([0-9]{2} ?\.?)`,
}, {
Name: config.ConfigEncoding,
Help: config.ConfigEncodingHelp,
Expand All @@ -115,6 +125,8 @@ func init() {

// Options defines the configuration for this backend
type Options struct {
RegexShows string `config:"regex_shows"`
RegexMovies string `config:"regex_movies"`
SharedFolder string `config:"folder_mode"`
RootFolderID string `config:"download_mode"`
APIKey string `config:"api_key"`
Expand Down Expand Up @@ -589,7 +601,7 @@ func (f *Fs) listAll(ctx context.Context, dirID string, directoriesOnly bool, fi
} else if f.opt.SharedFolder == "folders" && (dirID == "shows" || dirID == "movies" || dirID == "default") {
var artificialType []api.Item
if dirID == "shows" {
r, _ := regexp.Compile("(?i)(S[0-9]{2}|SEASON|COMPLETE)")
r, _ := regexp.Compile(f.opt.RegexShows) //(?i)(S[0-9]{2}|SEASON|COMPLETE)
for _, torrent := range torrents {
match := r.MatchString(torrent.Name)
if match {
Expand All @@ -598,8 +610,8 @@ func (f *Fs) listAll(ctx context.Context, dirID string, directoriesOnly bool, fi
}
result = artificialType
} else if dirID == "movies" {
r, _ := regexp.Compile(`(?i)([0-9]{4} ?\.?)`)
nr, _ := regexp.Compile("(?i)(S[0-9]{2}|SEASON|COMPLETE)")
r, _ := regexp.Compile(f.opt.RegexMovies) //`(?i)([0-9]{4} ?\.?)`
nr, _ := regexp.Compile(f.opt.RegexShows)
for _, torrent := range torrents {
match := r.MatchString(torrent.Name)
exclude := nr.MatchString(torrent.Name)
Expand All @@ -609,8 +621,8 @@ func (f *Fs) listAll(ctx context.Context, dirID string, directoriesOnly bool, fi
}
result = artificialType
} else {
r, _ := regexp.Compile(`(?i)([0-9]{4} ?\.?)`)
nr, _ := regexp.Compile("(?i)(S[0-9]{2}|SEASON|COMPLETE)")
r, _ := regexp.Compile(f.opt.RegexMovies)
nr, _ := regexp.Compile(f.opt.RegexShows)
for _, torrent := range torrents {
match := r.MatchString(torrent.Name)
exclude := nr.MatchString(torrent.Name)
Expand Down

0 comments on commit f88df7b

Please sign in to comment.