-
-
Notifications
You must be signed in to change notification settings - Fork 124
/
feed.go
86 lines (74 loc) · 2.81 KB
/
feed.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright (c) 2021 - 2023, Ludvig Lundgren and the autobrr contributors.
// SPDX-License-Identifier: GPL-2.0-or-later
package domain
import (
"context"
"time"
)
type FeedCacheRepo interface {
Get(bucket string, key string) ([]byte, error)
GetByBucket(ctx context.Context, bucket string) ([]FeedCacheItem, error)
GetCountByBucket(ctx context.Context, bucket string) (int, error)
Exists(bucket string, key string) (bool, error)
Put(bucket string, key string, val []byte, ttl time.Time) error
Delete(ctx context.Context, bucket string, key string) error
DeleteBucket(ctx context.Context, bucket string) error
}
type FeedRepo interface {
FindByID(ctx context.Context, id int) (*Feed, error)
FindByIndexerIdentifier(ctx context.Context, indexer string) (*Feed, error)
Find(ctx context.Context) ([]Feed, error)
GetLastRunDataByID(ctx context.Context, id int) (string, error)
Store(ctx context.Context, feed *Feed) error
Update(ctx context.Context, feed *Feed) error
UpdateLastRun(ctx context.Context, feedID int) error
UpdateLastRunWithData(ctx context.Context, feedID int, data string) error
ToggleEnabled(ctx context.Context, id int, enabled bool) error
Delete(ctx context.Context, id int) error
}
type Feed struct {
ID int `json:"id"`
Name string `json:"name"`
Indexer string `json:"indexer"`
Type string `json:"type"`
Enabled bool `json:"enabled"`
URL string `json:"url"`
Interval int `json:"interval"`
Timeout int `json:"timeout"` // seconds
MaxAge int `json:"max_age"` // seconds
Capabilities []string `json:"capabilities"`
ApiKey string `json:"api_key"`
Cookie string `json:"cookie"`
Settings *FeedSettingsJSON `json:"settings"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
IndexerID int `json:"indexer_id,omitempty"`
Indexerr FeedIndexer `json:"-"`
LastRun time.Time `json:"last_run"`
LastRunData string `json:"last_run_data"`
}
type FeedSettingsJSON struct {
DownloadType FeedDownloadType `json:"download_type"`
}
type FeedIndexer struct {
ID int `json:"id"`
Name string `json:"name"`
Identifier string `json:"identifier"`
}
type FeedType string
const (
FeedTypeTorznab FeedType = "TORZNAB"
FeedTypeNewznab FeedType = "NEWZNAB"
FeedTypeRSS FeedType = "RSS"
)
type FeedDownloadType string
const (
FeedDownloadTypeMagnet FeedDownloadType = "MAGNET"
FeedDownloadTypeTorrent FeedDownloadType = "TORRENT"
)
type FeedCacheItem struct {
Bucket string `json:"bucket"`
Key string `json:"key"`
Value []byte `json:"value"`
TTL time.Time `json:"ttl"`
}