mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
fix(releases): max downloads per hour (#883)
* fix(releases): max downloads per hour * refactor: release processing * compare apples to apples (#884) * from rocketships back to apples * Update internal/database/filter.go * cast me to the * keep your eye on the case --------- Co-authored-by: Kyle Sanderson <kyle.leet@gmail.com>
This commit is contained in:
parent
da5492febb
commit
ef3445cbed
7 changed files with 139 additions and 107 deletions
|
@ -19,7 +19,7 @@ https://autodl-community.github.io/autodl-irssi/configuration/filter/
|
|||
|
||||
type FilterRepo interface {
|
||||
FindByID(ctx context.Context, filterID int) (*Filter, error)
|
||||
FindByIndexerIdentifier(indexer string) ([]Filter, error)
|
||||
FindByIndexerIdentifier(ctx context.Context, indexer string) ([]Filter, error)
|
||||
Find(ctx context.Context, params FilterQueryParams) ([]Filter, error)
|
||||
ListFilters(ctx context.Context) ([]Filter, error)
|
||||
Store(ctx context.Context, filter Filter) (*Filter, error)
|
||||
|
@ -30,6 +30,7 @@ type FilterRepo interface {
|
|||
StoreIndexerConnection(ctx context.Context, filterID int, indexerID int) error
|
||||
StoreIndexerConnections(ctx context.Context, filterID int, indexers []Indexer) error
|
||||
DeleteIndexerConnections(ctx context.Context, filterID int) error
|
||||
GetDownloadsByFilterId(ctx context.Context, filterID int) (*FilterDownloads, error)
|
||||
}
|
||||
|
||||
type FilterDownloads struct {
|
||||
|
|
|
@ -30,7 +30,7 @@ type ReleaseRepo interface {
|
|||
GetIndexerOptions(ctx context.Context) ([]string, error)
|
||||
GetActionStatusByReleaseID(ctx context.Context, releaseID int64) ([]ReleaseActionStatus, error)
|
||||
Stats(ctx context.Context) (*ReleaseStats, error)
|
||||
StoreReleaseActionStatus(ctx context.Context, actionStatus *ReleaseActionStatus) error
|
||||
StoreReleaseActionStatus(ctx context.Context, status *ReleaseActionStatus) error
|
||||
Delete(ctx context.Context) error
|
||||
CanDownloadShow(ctx context.Context, title string, season int, episode int) (bool, error)
|
||||
}
|
||||
|
@ -105,6 +105,21 @@ type ReleaseActionStatus struct {
|
|||
ReleaseID int64 `json:"-"`
|
||||
}
|
||||
|
||||
func NewReleaseActionStatus(action *Action, release *Release) *ReleaseActionStatus {
|
||||
return &ReleaseActionStatus{
|
||||
ID: 0,
|
||||
Status: ReleasePushStatusPending,
|
||||
Action: action.Name,
|
||||
Type: action.Type,
|
||||
Client: action.Client.Name,
|
||||
Filter: release.Filter.Name,
|
||||
FilterID: int64(release.Filter.ID),
|
||||
Rejections: []string{},
|
||||
Timestamp: time.Now(),
|
||||
ReleaseID: release.ID,
|
||||
}
|
||||
}
|
||||
|
||||
type DownloadTorrentFileResponse struct {
|
||||
MetaInfo *metainfo.MetaInfo
|
||||
TmpFileName string
|
||||
|
@ -121,11 +136,10 @@ type ReleaseStats struct {
|
|||
type ReleasePushStatus string
|
||||
|
||||
const (
|
||||
ReleasePushStatusPending ReleasePushStatus = "PENDING" // Initial status
|
||||
ReleasePushStatusApproved ReleasePushStatus = "PUSH_APPROVED"
|
||||
ReleasePushStatusRejected ReleasePushStatus = "PUSH_REJECTED"
|
||||
ReleasePushStatusErr ReleasePushStatus = "PUSH_ERROR"
|
||||
|
||||
//ReleasePushStatusPending ReleasePushStatus = "PENDING" // Initial status
|
||||
)
|
||||
|
||||
func (r ReleasePushStatus) String() string {
|
||||
|
@ -571,12 +585,12 @@ func (r *Release) MapVars(def *IndexerDefinition, varMap map[string]string) erro
|
|||
//log.Debug().Msgf("bad freeleechPercent var: %v", year)
|
||||
}
|
||||
|
||||
if (freeleechPercentInt > 0) {
|
||||
if freeleechPercentInt > 0 {
|
||||
r.Freeleech = true
|
||||
r.FreeleechPercent = freeleechPercentInt
|
||||
|
||||
|
||||
r.Bonus = append(r.Bonus, "Freeleech")
|
||||
|
||||
|
||||
switch freeleechPercentInt {
|
||||
case 25:
|
||||
r.Bonus = append(r.Bonus, "Freeleech25")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue