feat(indexers): add External Identifier to map with ARR indexers (#1534)

* feat(indexers): add External Identifier to map with ARR indexers

* fix: web build

* fix: tests

* feat: set identifier for manual processing
This commit is contained in:
ze0s 2024-05-04 12:37:01 +02:00 committed by GitHub
parent ad6ef228ec
commit 0016228d89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 254 additions and 197 deletions

View file

@ -26,40 +26,43 @@ type IndexerRepo interface {
}
type Indexer struct {
ID int64 `json:"id"`
Name string `json:"name"`
Identifier string `json:"identifier"`
Enabled bool `json:"enabled"`
Implementation string `json:"implementation"`
BaseURL string `json:"base_url,omitempty"`
Settings map[string]string `json:"settings,omitempty"`
ID int64 `json:"id"`
Name string `json:"name"`
Identifier string `json:"identifier"`
IdentifierExternal string `json:"identifier_external"`
Enabled bool `json:"enabled"`
Implementation string `json:"implementation"`
BaseURL string `json:"base_url,omitempty"`
Settings map[string]string `json:"settings,omitempty"`
}
type IndexerMinimal struct {
ID int `json:"id"`
Name string `json:"name"`
Identifier string `json:"identifier"`
ID int `json:"id"`
Name string `json:"name"`
Identifier string `json:"identifier"`
IdentifierExternal string `json:"identifier_external"`
}
type IndexerDefinition struct {
ID int `json:"id,omitempty"`
Name string `json:"name"`
Identifier string `json:"identifier"`
Implementation string `json:"implementation"`
BaseURL string `json:"base_url,omitempty"`
Enabled bool `json:"enabled"`
Description string `json:"description"`
Language string `json:"language"`
Privacy string `json:"privacy"`
Protocol string `json:"protocol"`
URLS []string `json:"urls"`
Supports []string `json:"supports"`
Settings []IndexerSetting `json:"settings,omitempty"`
SettingsMap map[string]string `json:"-"`
IRC *IndexerIRC `json:"irc,omitempty"`
Torznab *Torznab `json:"torznab,omitempty"`
Newznab *Newznab `json:"newznab,omitempty"`
RSS *FeedSettings `json:"rss,omitempty"`
ID int `json:"id,omitempty"`
Name string `json:"name"`
Identifier string `json:"identifier"`
IdentifierExternal string `json:"identifier_external"`
Implementation string `json:"implementation"`
BaseURL string `json:"base_url,omitempty"`
Enabled bool `json:"enabled"`
Description string `json:"description"`
Language string `json:"language"`
Privacy string `json:"privacy"`
Protocol string `json:"protocol"`
URLS []string `json:"urls"`
Supports []string `json:"supports"`
Settings []IndexerSetting `json:"settings,omitempty"`
SettingsMap map[string]string `json:"-"`
IRC *IndexerIRC `json:"irc,omitempty"`
Torznab *Torznab `json:"torznab,omitempty"`
Newznab *Newznab `json:"newznab,omitempty"`
RSS *FeedSettings `json:"rss,omitempty"`
}
type IndexerImplementation string

View file

@ -254,7 +254,7 @@ func TestIRCParserGazelleGames_Parse(t *testing.T) {
{
name: "",
args: args{
rls: NewRelease(IndexerMinimal{0, "GazelleGames", "ggn"}),
rls: NewRelease(IndexerMinimal{0, "GazelleGames", "ggn", "GazelleGames"}),
vars: map[string]string{
"torrentName": "Trouble.in.Paradise-GROUP in Trouble in Paradise",
},
@ -267,7 +267,7 @@ func TestIRCParserGazelleGames_Parse(t *testing.T) {
{
name: "",
args: args{
rls: NewRelease(IndexerMinimal{0, "GazelleGames", "ggn"}),
rls: NewRelease(IndexerMinimal{0, "GazelleGames", "ggn", "GazelleGames"}),
vars: map[string]string{
"torrentName": "F.I.L.F. Game Walkthrough v.0.18 in F.I.L.F.",
},
@ -280,7 +280,7 @@ func TestIRCParserGazelleGames_Parse(t *testing.T) {
{
name: "",
args: args{
rls: NewRelease(IndexerMinimal{0, "GazelleGames", "ggn"}),
rls: NewRelease(IndexerMinimal{0, "GazelleGames", "ggn", "GazelleGames"}),
vars: map[string]string{
"torrentName": "Ni no Kuni: Dominion of the Dark Djinn in Ni no Kuni: Dominion of the Dark Djinn",
},
@ -293,7 +293,7 @@ func TestIRCParserGazelleGames_Parse(t *testing.T) {
{
name: "",
args: args{
rls: NewRelease(IndexerMinimal{0, "GazelleGames", "ggn"}),
rls: NewRelease(IndexerMinimal{0, "GazelleGames", "ggn", "GazelleGames"}),
vars: map[string]string{
"torrentName": "Year 2 Remastered by Insaneintherainmusic",
"category": "OST",
@ -332,7 +332,7 @@ func TestIRCParserOrpheus_Parse(t *testing.T) {
{
name: "",
args: args{
rls: NewRelease(IndexerMinimal{0, "Orpheus", "ops"}),
rls: NewRelease(IndexerMinimal{0, "Orpheus", "ops", "Orpheus"}),
vars: map[string]string{
"torrentName": "Busta Rhymes BEACH BALL (feat. BIA) [2023] [Single] WEB/FLAC/24bit Lossless",
"title": "Busta Rhymes BEACH BALL (feat. BIA)",
@ -348,7 +348,7 @@ func TestIRCParserOrpheus_Parse(t *testing.T) {
{
name: "",
args: args{
rls: NewRelease(IndexerMinimal{0, "Orpheus", "ops"}),
rls: NewRelease(IndexerMinimal{0, "Orpheus", "ops", "Orpheus"}),
vars: map[string]string{
"torrentName": "Busta Rhymes BEACH BALL (feat. BIA) [2023] [Single] CD/FLAC/Lossless",
"title": "Busta Rhymes BEACH BALL (feat. BIA)",

View file

@ -16,84 +16,86 @@ import (
)
type Macro struct {
TorrentName string
TorrentPathName string
TorrentHash string
TorrentID string
TorrentUrl string
TorrentDataRawBytes []byte
MagnetURI string
Group string
GroupID string
DownloadUrl string
InfoUrl string
Indexer string
IndexerName string
IndexerIdentifier string
Title string
Type string
Category string
Categories []string
Resolution string
Source string
HDR string
FilterID int
FilterName string
Size uint64
SizeString string
Season int
Episode int
Year int
CurrentYear int
CurrentMonth int
CurrentDay int
CurrentHour int
CurrentMinute int
CurrentSecond int
Tags string
Artists string
TorrentName string
TorrentPathName string
TorrentHash string
TorrentID string
TorrentUrl string
TorrentDataRawBytes []byte
MagnetURI string
Group string
GroupID string
DownloadUrl string
InfoUrl string
Indexer string
IndexerName string
IndexerIdentifier string
IndexerIdentifierExternal string
Title string
Type string
Category string
Categories []string
Resolution string
Source string
HDR string
FilterID int
FilterName string
Size uint64
SizeString string
Season int
Episode int
Year int
CurrentYear int
CurrentMonth int
CurrentDay int
CurrentHour int
CurrentMinute int
CurrentSecond int
Tags string
Artists string
}
func NewMacro(release Release) Macro {
currentTime := time.Now()
ma := Macro{
TorrentName: release.TorrentName,
TorrentUrl: release.DownloadURL,
TorrentPathName: release.TorrentTmpFile,
TorrentDataRawBytes: release.TorrentDataRawBytes,
TorrentHash: release.TorrentHash,
TorrentID: release.TorrentID,
MagnetURI: release.MagnetURI,
Group: release.Group,
GroupID: release.GroupID,
InfoUrl: release.InfoURL,
DownloadUrl: release.DownloadURL,
Indexer: release.Indexer.Identifier,
IndexerName: release.Indexer.Name,
IndexerIdentifier: release.Indexer.Identifier,
Title: release.Title,
Type: release.Type,
Category: release.Category,
Categories: release.Categories,
Resolution: release.Resolution,
Source: release.Source,
HDR: strings.Join(release.HDR, ", "),
FilterID: release.FilterID,
FilterName: release.FilterName,
Size: release.Size,
SizeString: humanize.Bytes(release.Size),
Season: release.Season,
Episode: release.Episode,
Year: release.Year,
CurrentYear: currentTime.Year(),
CurrentMonth: int(currentTime.Month()),
CurrentDay: currentTime.Day(),
CurrentHour: currentTime.Hour(),
CurrentMinute: currentTime.Minute(),
CurrentSecond: currentTime.Second(),
Tags: strings.Join(release.Tags, ", "),
Artists: release.Artists,
TorrentName: release.TorrentName,
TorrentUrl: release.DownloadURL,
TorrentPathName: release.TorrentTmpFile,
TorrentDataRawBytes: release.TorrentDataRawBytes,
TorrentHash: release.TorrentHash,
TorrentID: release.TorrentID,
MagnetURI: release.MagnetURI,
Group: release.Group,
GroupID: release.GroupID,
InfoUrl: release.InfoURL,
DownloadUrl: release.DownloadURL,
Indexer: release.Indexer.Identifier,
IndexerName: release.Indexer.Name,
IndexerIdentifier: release.Indexer.Identifier,
IndexerIdentifierExternal: release.Indexer.IdentifierExternal,
Title: release.Title,
Type: release.Type,
Category: release.Category,
Categories: release.Categories,
Resolution: release.Resolution,
Source: release.Source,
HDR: strings.Join(release.HDR, ", "),
FilterID: release.FilterID,
FilterName: release.FilterName,
Size: release.Size,
SizeString: humanize.Bytes(release.Size),
Season: release.Season,
Episode: release.Episode,
Year: release.Year,
CurrentYear: currentTime.Year(),
CurrentMonth: int(currentTime.Month()),
CurrentDay: currentTime.Day(),
CurrentHour: currentTime.Hour(),
CurrentMinute: currentTime.Minute(),
CurrentSecond: currentTime.Second(),
Tags: strings.Join(release.Tags, ", "),
Artists: release.Artists,
}
return ma

View file

@ -36,7 +36,7 @@ func TestMacros_Parse(t *testing.T) {
release: Release{
TorrentName: "This movie 2021",
TorrentTmpFile: "/tmp/a-temporary-file.torrent",
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1", "Mock Indexer"},
},
args: args{text: "Print mee {{.TorrentPathName}}"},
want: "Print mee /tmp/a-temporary-file.torrent",
@ -47,7 +47,7 @@ func TestMacros_Parse(t *testing.T) {
release: Release{
TorrentName: "This movie 2021",
TorrentTmpFile: "/tmp/a-temporary-file.torrent",
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1", "Mock Indexer"},
},
args: args{text: "Print mee {{TorrentPathName}}"},
want: "",
@ -58,7 +58,7 @@ func TestMacros_Parse(t *testing.T) {
release: Release{
TorrentName: "This movie 2021",
TorrentTmpFile: "/tmp/a-temporary-file.torrent",
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1", "Mock Indexer"},
},
args: args{text: "add {{.TorrentPathName}} --category test"},
want: "add /tmp/a-temporary-file.torrent --category test",
@ -68,7 +68,7 @@ func TestMacros_Parse(t *testing.T) {
name: "test_program_arg_bad",
release: Release{
TorrentTmpFile: "/tmp/a-temporary-file.torrent",
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1", "Mock Indexer"},
},
args: args{text: "add {{.TorrenttPathName}} --category test"},
want: "",
@ -79,7 +79,7 @@ func TestMacros_Parse(t *testing.T) {
release: Release{
TorrentName: "This movie 2021",
TorrentTmpFile: "/tmp/a-temporary-file.torrent",
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1", "Mock Indexer"},
},
args: args{text: "add {{.TorrentPathName}} --category test --other {{.TorrentName}}"},
want: "add /tmp/a-temporary-file.torrent --category test --other This movie 2021",
@ -90,7 +90,7 @@ func TestMacros_Parse(t *testing.T) {
release: Release{
TorrentName: "This movie 2021",
DownloadURL: "https://some.site/download/fakeid",
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1", "Mock Indexer"},
},
args: args{text: "{{.TorrentName}} {{.TorrentUrl}} SOME_LONG_TOKEN"},
want: "This movie 2021 https://some.site/download/fakeid SOME_LONG_TOKEN",
@ -101,7 +101,7 @@ func TestMacros_Parse(t *testing.T) {
release: Release{
TorrentName: "This movie 2021",
DownloadURL: "https://some.site/download/fakeid",
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1", "Mock Indexer"},
},
args: args{text: "{{.Indexer}} {{.TorrentName}} {{.TorrentUrl}} SOME_LONG_TOKEN"},
want: "mock1 This movie 2021 https://some.site/download/fakeid SOME_LONG_TOKEN",
@ -112,7 +112,7 @@ func TestMacros_Parse(t *testing.T) {
release: Release{
TorrentName: "This movie 2021",
DownloadURL: "https://some.site/download/fakeid",
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1", "Mock Indexer"},
},
args: args{text: "{{.Indexer}}-race"},
want: "mock1-race",
@ -123,7 +123,7 @@ func TestMacros_Parse(t *testing.T) {
release: Release{
TorrentName: "This movie 2021",
DownloadURL: "https://some.site/download/fakeid",
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1", "Mock Indexer"},
},
args: args{text: "{{.Indexer}}-{{.CurrentYear}}-race"},
want: fmt.Sprintf("mock1-%v-race", currentTime.Year()),
@ -134,7 +134,7 @@ func TestMacros_Parse(t *testing.T) {
release: Release{
TorrentName: "This movie 2021",
DownloadURL: "https://some.site/download/fakeid",
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1", "Mock Indexer"},
Resolution: "2160p",
HDR: []string{"DV"},
},
@ -147,7 +147,7 @@ func TestMacros_Parse(t *testing.T) {
release: Release{
TorrentName: "This movie 2021",
DownloadURL: "https://some.site/download/fakeid",
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1", "Mock Indexer"},
Resolution: "2160p",
HDR: []string{"HDR"},
},
@ -160,7 +160,7 @@ func TestMacros_Parse(t *testing.T) {
release: Release{
TorrentName: "This movie 2021",
DownloadURL: "https://some.site/download/fakeid",
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1", "Mock Indexer"},
Resolution: "2160p",
HDR: []string{"HDR"},
Year: 2021,
@ -220,7 +220,7 @@ func TestMacros_Parse(t *testing.T) {
TorrentName: "This movie 2021",
DownloadURL: "https://some.site/download/fakeid",
Group: "thisgrp",
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1", "Mock Indexer"},
Year: 2021,
},
args: args{text: "movies-{{.Group}}"},
@ -266,7 +266,7 @@ func TestMacros_Parse(t *testing.T) {
{
name: "test_args_indexer",
release: Release{
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1", "Mock Indexer"},
},
args: args{text: "indexer={{.IndexerName}}"},
want: fmt.Sprintf("indexer=Mock Indexer"),