mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
feat(filters): add support for multiple external filters (#1030)
* feat(filters): add support for multiple ext filters * refactor(filters): crud and check * feat(filters): add postgres migrations * fix(filters): field array types * fix(filters): formatting * fix(filters): formatting * feat(filters): external webhook improve logs
This commit is contained in:
parent
db209319da
commit
dde0d0ed61
15 changed files with 1514 additions and 478 deletions
|
@ -21,10 +21,11 @@ https://autodl-community.github.io/autodl-irssi/configuration/filter/
|
|||
*/
|
||||
|
||||
type FilterRepo interface {
|
||||
ListFilters(ctx context.Context) ([]Filter, error)
|
||||
Find(ctx context.Context, params FilterQueryParams) ([]Filter, error)
|
||||
FindByID(ctx context.Context, filterID int) (*Filter, error)
|
||||
FindByIndexerIdentifier(ctx context.Context, indexer string) ([]Filter, error)
|
||||
Find(ctx context.Context, params FilterQueryParams) ([]Filter, error)
|
||||
ListFilters(ctx context.Context) ([]Filter, error)
|
||||
FindExternalFiltersByID(ctx context.Context, filterId int) ([]FilterExternal, error)
|
||||
Store(ctx context.Context, filter Filter) (*Filter, error)
|
||||
Update(ctx context.Context, filter Filter) (*Filter, error)
|
||||
UpdatePartial(ctx context.Context, filter FilterUpdate) error
|
||||
|
@ -32,6 +33,7 @@ type FilterRepo interface {
|
|||
Delete(ctx context.Context, filterID int) error
|
||||
StoreIndexerConnection(ctx context.Context, filterID int, indexerID int) error
|
||||
StoreIndexerConnections(ctx context.Context, filterID int, indexers []Indexer) error
|
||||
StoreFilterExternal(ctx context.Context, filterID int, externalFilters []FilterExternal) error
|
||||
DeleteIndexerConnections(ctx context.Context, filterID int) error
|
||||
GetDownloadsByFilterId(ctx context.Context, filterID int) (*FilterDownloads, error)
|
||||
}
|
||||
|
@ -63,84 +65,109 @@ type FilterQueryParams struct {
|
|||
}
|
||||
|
||||
type Filter struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Enabled bool `json:"enabled"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
MinSize string `json:"min_size,omitempty"`
|
||||
MaxSize string `json:"max_size,omitempty"`
|
||||
Delay int `json:"delay,omitempty"`
|
||||
Priority int32 `json:"priority"`
|
||||
MaxDownloads int `json:"max_downloads,omitempty"`
|
||||
MaxDownloadsUnit FilterMaxDownloadsUnit `json:"max_downloads_unit,omitempty"`
|
||||
MatchReleases string `json:"match_releases,omitempty"`
|
||||
ExceptReleases string `json:"except_releases,omitempty"`
|
||||
UseRegex bool `json:"use_regex,omitempty"`
|
||||
MatchReleaseGroups string `json:"match_release_groups,omitempty"`
|
||||
ExceptReleaseGroups string `json:"except_release_groups,omitempty"`
|
||||
Scene bool `json:"scene,omitempty"`
|
||||
Origins []string `json:"origins,omitempty"`
|
||||
ExceptOrigins []string `json:"except_origins,omitempty"`
|
||||
Bonus []string `json:"bonus,omitempty"`
|
||||
Freeleech bool `json:"freeleech,omitempty"`
|
||||
FreeleechPercent string `json:"freeleech_percent,omitempty"`
|
||||
SmartEpisode bool `json:"smart_episode"`
|
||||
Shows string `json:"shows,omitempty"`
|
||||
Seasons string `json:"seasons,omitempty"`
|
||||
Episodes string `json:"episodes,omitempty"`
|
||||
Resolutions []string `json:"resolutions,omitempty"` // SD, 480i, 480p, 576p, 720p, 810p, 1080i, 1080p.
|
||||
Codecs []string `json:"codecs,omitempty"` // XviD, DivX, x264, h.264 (or h264), mpeg2 (or mpeg-2), VC-1 (or VC1), WMV, Remux, h.264 Remux (or h264 Remux), VC-1 Remux (or VC1 Remux).
|
||||
Sources []string `json:"sources,omitempty"` // DSR, PDTV, HDTV, HR.PDTV, HR.HDTV, DVDRip, DVDScr, BDr, BD5, BD9, BDRip, BRRip, DVDR, MDVDR, HDDVD, HDDVDRip, BluRay, WEB-DL, TVRip, CAM, R5, TELESYNC, TS, TELECINE, TC. TELESYNC and TS are synonyms (you don't need both). Same for TELECINE and TC
|
||||
Containers []string `json:"containers,omitempty"`
|
||||
MatchHDR []string `json:"match_hdr,omitempty"`
|
||||
ExceptHDR []string `json:"except_hdr,omitempty"`
|
||||
MatchOther []string `json:"match_other,omitempty"`
|
||||
ExceptOther []string `json:"except_other,omitempty"`
|
||||
Years string `json:"years,omitempty"`
|
||||
Artists string `json:"artists,omitempty"`
|
||||
Albums string `json:"albums,omitempty"`
|
||||
MatchReleaseTypes []string `json:"match_release_types,omitempty"` // Album,Single,EP
|
||||
ExceptReleaseTypes string `json:"except_release_types,omitempty"`
|
||||
Formats []string `json:"formats,omitempty"` // MP3, FLAC, Ogg, AAC, AC3, DTS
|
||||
Quality []string `json:"quality,omitempty"` // 192, 320, APS (VBR), V2 (VBR), V1 (VBR), APX (VBR), V0 (VBR), q8.x (VBR), Lossless, 24bit Lossless, Other
|
||||
Media []string `json:"media,omitempty"` // CD, DVD, Vinyl, Soundboard, SACD, DAT, Cassette, WEB, Other
|
||||
PerfectFlac bool `json:"perfect_flac,omitempty"`
|
||||
Cue bool `json:"cue,omitempty"`
|
||||
Log bool `json:"log,omitempty"`
|
||||
LogScore int `json:"log_score,omitempty"`
|
||||
MatchCategories string `json:"match_categories,omitempty"`
|
||||
ExceptCategories string `json:"except_categories,omitempty"`
|
||||
MatchUploaders string `json:"match_uploaders,omitempty"`
|
||||
ExceptUploaders string `json:"except_uploaders,omitempty"`
|
||||
MatchLanguage []string `json:"match_language,omitempty"`
|
||||
ExceptLanguage []string `json:"except_language,omitempty"`
|
||||
Tags string `json:"tags,omitempty"`
|
||||
ExceptTags string `json:"except_tags,omitempty"`
|
||||
TagsAny string `json:"tags_any,omitempty"`
|
||||
ExceptTagsAny string `json:"except_tags_any,omitempty"`
|
||||
TagsMatchLogic string `json:"tags_match_logic,omitempty"`
|
||||
ExceptTagsMatchLogic string `json:"except_tags_match_logic,omitempty"`
|
||||
MatchReleaseTags string `json:"match_release_tags,omitempty"`
|
||||
ExceptReleaseTags string `json:"except_release_tags,omitempty"`
|
||||
UseRegexReleaseTags bool `json:"use_regex_release_tags,omitempty"`
|
||||
MatchDescription string `json:"match_description,omitempty"`
|
||||
ExceptDescription string `json:"except_description,omitempty"`
|
||||
UseRegexDescription bool `json:"use_regex_description,omitempty"`
|
||||
ExternalScriptEnabled bool `json:"external_script_enabled,omitempty"`
|
||||
ExternalScriptCmd string `json:"external_script_cmd,omitempty"`
|
||||
ExternalScriptArgs string `json:"external_script_args,omitempty"`
|
||||
ExternalScriptExpectStatus int `json:"external_script_expect_status,omitempty"`
|
||||
ExternalWebhookEnabled bool `json:"external_webhook_enabled,omitempty"`
|
||||
ExternalWebhookHost string `json:"external_webhook_host,omitempty"`
|
||||
ExternalWebhookData string `json:"external_webhook_data,omitempty"`
|
||||
ExternalWebhookExpectStatus int `json:"external_webhook_expect_status,omitempty"`
|
||||
ActionsCount int `json:"actions_count"`
|
||||
Actions []*Action `json:"actions,omitempty"`
|
||||
Indexers []Indexer `json:"indexers"`
|
||||
Downloads *FilterDownloads `json:"-"`
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Enabled bool `json:"enabled"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
MinSize string `json:"min_size,omitempty"`
|
||||
MaxSize string `json:"max_size,omitempty"`
|
||||
Delay int `json:"delay,omitempty"`
|
||||
Priority int32 `json:"priority"`
|
||||
MaxDownloads int `json:"max_downloads,omitempty"`
|
||||
MaxDownloadsUnit FilterMaxDownloadsUnit `json:"max_downloads_unit,omitempty"`
|
||||
MatchReleases string `json:"match_releases,omitempty"`
|
||||
ExceptReleases string `json:"except_releases,omitempty"`
|
||||
UseRegex bool `json:"use_regex,omitempty"`
|
||||
MatchReleaseGroups string `json:"match_release_groups,omitempty"`
|
||||
ExceptReleaseGroups string `json:"except_release_groups,omitempty"`
|
||||
Scene bool `json:"scene,omitempty"`
|
||||
Origins []string `json:"origins,omitempty"`
|
||||
ExceptOrigins []string `json:"except_origins,omitempty"`
|
||||
Bonus []string `json:"bonus,omitempty"`
|
||||
Freeleech bool `json:"freeleech,omitempty"`
|
||||
FreeleechPercent string `json:"freeleech_percent,omitempty"`
|
||||
SmartEpisode bool `json:"smart_episode"`
|
||||
Shows string `json:"shows,omitempty"`
|
||||
Seasons string `json:"seasons,omitempty"`
|
||||
Episodes string `json:"episodes,omitempty"`
|
||||
Resolutions []string `json:"resolutions,omitempty"` // SD, 480i, 480p, 576p, 720p, 810p, 1080i, 1080p.
|
||||
Codecs []string `json:"codecs,omitempty"` // XviD, DivX, x264, h.264 (or h264), mpeg2 (or mpeg-2), VC-1 (or VC1), WMV, Remux, h.264 Remux (or h264 Remux), VC-1 Remux (or VC1 Remux).
|
||||
Sources []string `json:"sources,omitempty"` // DSR, PDTV, HDTV, HR.PDTV, HR.HDTV, DVDRip, DVDScr, BDr, BD5, BD9, BDRip, BRRip, DVDR, MDVDR, HDDVD, HDDVDRip, BluRay, WEB-DL, TVRip, CAM, R5, TELESYNC, TS, TELECINE, TC. TELESYNC and TS are synonyms (you don't need both). Same for TELECINE and TC
|
||||
Containers []string `json:"containers,omitempty"`
|
||||
MatchHDR []string `json:"match_hdr,omitempty"`
|
||||
ExceptHDR []string `json:"except_hdr,omitempty"`
|
||||
MatchOther []string `json:"match_other,omitempty"`
|
||||
ExceptOther []string `json:"except_other,omitempty"`
|
||||
Years string `json:"years,omitempty"`
|
||||
Artists string `json:"artists,omitempty"`
|
||||
Albums string `json:"albums,omitempty"`
|
||||
MatchReleaseTypes []string `json:"match_release_types,omitempty"` // Album,Single,EP
|
||||
ExceptReleaseTypes string `json:"except_release_types,omitempty"`
|
||||
Formats []string `json:"formats,omitempty"` // MP3, FLAC, Ogg, AAC, AC3, DTS
|
||||
Quality []string `json:"quality,omitempty"` // 192, 320, APS (VBR), V2 (VBR), V1 (VBR), APX (VBR), V0 (VBR), q8.x (VBR), Lossless, 24bit Lossless, Other
|
||||
Media []string `json:"media,omitempty"` // CD, DVD, Vinyl, Soundboard, SACD, DAT, Cassette, WEB, Other
|
||||
PerfectFlac bool `json:"perfect_flac,omitempty"`
|
||||
Cue bool `json:"cue,omitempty"`
|
||||
Log bool `json:"log,omitempty"`
|
||||
LogScore int `json:"log_score,omitempty"`
|
||||
MatchCategories string `json:"match_categories,omitempty"`
|
||||
ExceptCategories string `json:"except_categories,omitempty"`
|
||||
MatchUploaders string `json:"match_uploaders,omitempty"`
|
||||
ExceptUploaders string `json:"except_uploaders,omitempty"`
|
||||
MatchLanguage []string `json:"match_language,omitempty"`
|
||||
ExceptLanguage []string `json:"except_language,omitempty"`
|
||||
Tags string `json:"tags,omitempty"`
|
||||
ExceptTags string `json:"except_tags,omitempty"`
|
||||
TagsAny string `json:"tags_any,omitempty"`
|
||||
ExceptTagsAny string `json:"except_tags_any,omitempty"`
|
||||
TagsMatchLogic string `json:"tags_match_logic,omitempty"`
|
||||
ExceptTagsMatchLogic string `json:"except_tags_match_logic,omitempty"`
|
||||
MatchReleaseTags string `json:"match_release_tags,omitempty"`
|
||||
ExceptReleaseTags string `json:"except_release_tags,omitempty"`
|
||||
UseRegexReleaseTags bool `json:"use_regex_release_tags,omitempty"`
|
||||
MatchDescription string `json:"match_description,omitempty"`
|
||||
ExceptDescription string `json:"except_description,omitempty"`
|
||||
UseRegexDescription bool `json:"use_regex_description,omitempty"`
|
||||
//ExternalScriptEnabled bool `json:"external_script_enabled,omitempty"`
|
||||
//ExternalScriptCmd string `json:"external_script_cmd,omitempty"`
|
||||
//ExternalScriptArgs string `json:"external_script_args,omitempty"`
|
||||
//ExternalScriptExpectStatus int `json:"external_script_expect_status,omitempty"`
|
||||
//ExternalWebhookEnabled bool `json:"external_webhook_enabled,omitempty"`
|
||||
//ExternalWebhookHost string `json:"external_webhook_host,omitempty"`
|
||||
//ExternalWebhookData string `json:"external_webhook_data,omitempty"`
|
||||
//ExternalWebhookExpectStatus int `json:"external_webhook_expect_status,omitempty"`
|
||||
ActionsCount int `json:"actions_count"`
|
||||
Actions []*Action `json:"actions,omitempty"`
|
||||
External []FilterExternal `json:"external,omitempty"`
|
||||
Indexers []Indexer `json:"indexers"`
|
||||
Downloads *FilterDownloads `json:"-"`
|
||||
}
|
||||
|
||||
type FilterExternal struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Index int `json:"index"`
|
||||
Type FilterExternalType `json:"type"`
|
||||
Enabled bool `json:"enabled"`
|
||||
ExecCmd string `json:"exec_cmd,omitempty"`
|
||||
ExecArgs string `json:"exec_args,omitempty"`
|
||||
ExecExpectStatus int `json:"exec_expect_status,omitempty"`
|
||||
WebhookHost string `json:"webhook_host,omitempty"`
|
||||
WebhookMethod string `json:"webhook_method,omitempty"`
|
||||
WebhookData string `json:"webhook_data,omitempty"`
|
||||
WebhookHeaders string `json:"webhook_headers,omitempty"`
|
||||
WebhookExpectStatus int `json:"webhook_expect_status,omitempty"`
|
||||
FilterId int `json:"-"`
|
||||
}
|
||||
|
||||
type FilterExternalType string
|
||||
|
||||
const (
|
||||
ExternalFilterTypeExec FilterExternalType = "EXEC"
|
||||
ExternalFilterTypeWebhook FilterExternalType = "WEBHOOK"
|
||||
)
|
||||
|
||||
type FilterUpdate struct {
|
||||
ID int `json:"id"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue