mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
feat(indexers): update PTP announce to new format (#1738)
* feat(indexers): update PTP to new format * fix: update expect line * feat: use unique key for dl link * feat: update pattern * fix: definition tests * feat: rename var * feat: add custom vars map * feat: start mapCustomVars * Update internal/indexer/definitions/ptp.yaml Co-authored-by: nuxen <felix.schubert1998@gmail.com> * feat(indexers): map custom indexer vars * feat: support upload unix epoch time * feat(releases): update mapvars * feat(indexers): remove ptp api init * feat(indexers): update ptp category mapping * feat(releases): show announce type in details * feat(releases): mapvars announcetype --------- Co-authored-by: nuxen <felix.schubert1998@gmail.com>
This commit is contained in:
parent
f644b3a4d6
commit
24f31574e5
6 changed files with 342 additions and 108 deletions
|
@ -375,3 +375,107 @@ func TestIRCParserOrpheus_Parse(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestIndexerIRCParse_MapCustomVariables1(t *testing.T) {
|
||||
type fields struct {
|
||||
Type string
|
||||
ForceSizeUnit string
|
||||
Lines []IndexerIRCParseLine
|
||||
Match IndexerIRCParseMatch
|
||||
Mappings map[string]map[string]map[string]string
|
||||
}
|
||||
type args struct {
|
||||
vars map[string]string
|
||||
expectVars map[string]string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
args args
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "",
|
||||
fields: fields{
|
||||
Mappings: map[string]map[string]map[string]string{
|
||||
"announceType": {
|
||||
"0": map[string]string{
|
||||
"announceType": "NEW",
|
||||
},
|
||||
"1": map[string]string{
|
||||
"announceType": "PROMO",
|
||||
},
|
||||
},
|
||||
"categoryEnum": {
|
||||
"0": map[string]string{
|
||||
"category": "Feature Film",
|
||||
},
|
||||
"1": map[string]string{
|
||||
"category": "Short Film",
|
||||
},
|
||||
"2": map[string]string{
|
||||
"category": "Miniseries",
|
||||
},
|
||||
"3": map[string]string{
|
||||
"category": "Stand-up Comedy",
|
||||
},
|
||||
"4": map[string]string{
|
||||
"category": "Live Performance",
|
||||
},
|
||||
"5": map[string]string{
|
||||
"category": "Movie Collection",
|
||||
},
|
||||
},
|
||||
"freeleechEnum": {
|
||||
"0": map[string]string{
|
||||
"downloadVolumeFactor": "1.0",
|
||||
"uploadVolumeFactor": "1.0",
|
||||
},
|
||||
"1": map[string]string{
|
||||
"downloadVolumeFactor": "0",
|
||||
"uploadVolumeFactor": "1.0",
|
||||
},
|
||||
"2": map[string]string{
|
||||
"downloadVolumeFactor": "0.5",
|
||||
"uploadVolumeFactor": "1.0",
|
||||
},
|
||||
"3": map[string]string{
|
||||
"downloadVolumeFactor": "0",
|
||||
"uploadVolumeFactor": "0",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
args: args{
|
||||
vars: map[string]string{
|
||||
"announceType": "1",
|
||||
"categoryEnum": "0",
|
||||
"freeleechEnum": "1",
|
||||
},
|
||||
expectVars: map[string]string{
|
||||
"announceType": "PROMO",
|
||||
"category": "Feature Film",
|
||||
"categoryEnum": "0",
|
||||
"freeleechEnum": "1",
|
||||
"downloadVolumeFactor": "0",
|
||||
"uploadVolumeFactor": "1.0",
|
||||
},
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
p := &IndexerIRCParse{
|
||||
Type: tt.fields.Type,
|
||||
ForceSizeUnit: tt.fields.ForceSizeUnit,
|
||||
Lines: tt.fields.Lines,
|
||||
Match: tt.fields.Match,
|
||||
Mappings: tt.fields.Mappings,
|
||||
}
|
||||
err := p.MapCustomVariables(tt.args.vars)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, tt.args.expectVars, tt.args.vars)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue