mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
feat(indexers): add T66y (#2044)
* Adds t66y indexer + irc support for templated infohashes and magnet uris. * Removed trackers from t66y magnets. * No need to templatize the torrenthash. * Fixed tests. * Opps, correct tests again. * Moved torrentHash to mapvars. * Removed field and renamed arg. * feat(indexers): add test parseurls magneturi --------- Co-authored-by: ze0s <ze0s@riseup.net>
This commit is contained in:
parent
5da0ebbe1f
commit
6073480bc4
4 changed files with 111 additions and 2 deletions
|
@ -250,6 +250,7 @@ type IndexerIRCParseLine struct {
|
|||
type IndexerIRCParseMatch struct {
|
||||
TorrentURL string `json:"torrenturl"`
|
||||
TorrentName string `json:"torrentname"`
|
||||
MagnetURI string `json:"magneturi"`
|
||||
InfoURL string `json:"infourl"`
|
||||
Encode []string `json:"encode"`
|
||||
}
|
||||
|
@ -331,6 +332,15 @@ func (p *IndexerIRCParseMatch) ParseURLs(baseURL string, vars map[string]string,
|
|||
rls.DownloadURL = downloadURL.String()
|
||||
}
|
||||
|
||||
if p.MagnetURI != "" {
|
||||
magnetURI, err := parseTemplateURL("magnet:", p.MagnetURI, vars, "magneturi")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rls.MagnetURI = magnetURI.String()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -399,7 +409,7 @@ func (p *IndexerIRCParse) Parse(def *IndexerDefinition, vars map[string]string,
|
|||
return errors.Wrap(err, "could not parse urls for release")
|
||||
}
|
||||
|
||||
// parse torrent var
|
||||
// parse torrent name
|
||||
if err := def.IRC.Parse.Match.ParseTorrentName(mergedVars, rls); err != nil {
|
||||
return errors.Wrap(err, "could not parse release name")
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ func TestIndexerIRCParseMatch_ParseUrls(t *testing.T) {
|
|||
type fields struct {
|
||||
TorrentURL string
|
||||
TorrentName string
|
||||
MagnetURI string
|
||||
InfoURL string
|
||||
Encode []string
|
||||
}
|
||||
|
@ -150,16 +151,34 @@ func TestIndexerIRCParseMatch_ParseUrls(t *testing.T) {
|
|||
DownloadURL: "https://mock.local/rss/?action=download&key=KEY&token=TOKEN&hash=240860011&title=The+Show+2019+S03E08+2160p+DV+WEBRip+6CH+x265+HEVC-GROUP",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "magnet_uri",
|
||||
fields: fields{
|
||||
MagnetURI: "magnet:?xt=urn:btih:{{ .torrentHash }}&dn={{ urlquery .torrentName }}",
|
||||
},
|
||||
args: args{
|
||||
vars: map[string]string{
|
||||
"torrentHash": "81c758d0eca5372d59e43879ecf2e2bce33a06c4",
|
||||
"torrentName": "The Show 2019 S03E08 2160p DV WEBRip 6CH x265 HEVC-GROUP",
|
||||
},
|
||||
rls: &Release{},
|
||||
},
|
||||
want: &Release{
|
||||
MagnetURI: "magnet:?xt=urn:btih:81c758d0eca5372d59e43879ecf2e2bce33a06c4&dn=The+Show+2019+S03E08+2160p+DV+WEBRip+6CH+x265+HEVC-GROUP",
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
p := &IndexerIRCParseMatch{
|
||||
TorrentURL: tt.fields.TorrentURL,
|
||||
TorrentName: tt.fields.TorrentName,
|
||||
MagnetURI: tt.fields.MagnetURI,
|
||||
InfoURL: tt.fields.InfoURL,
|
||||
Encode: tt.fields.Encode,
|
||||
}
|
||||
p.ParseURLs(tt.args.baseURL, tt.args.vars, tt.args.rls)
|
||||
err := p.ParseURLs(tt.args.baseURL, tt.args.vars, tt.args.rls)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, tt.want, tt.args.rls)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -964,6 +964,10 @@ func (r *Release) MapVars(def *IndexerDefinition, varMap map[string]string) erro
|
|||
r.TorrentName = html.UnescapeString(torrentName)
|
||||
}
|
||||
|
||||
if torrentHash, err := getStringMapValue(varMap, "torrentHash"); err == nil {
|
||||
r.TorrentHash = torrentHash
|
||||
}
|
||||
|
||||
if torrentID, err := getStringMapValue(varMap, "torrentId"); err == nil {
|
||||
r.TorrentID = torrentID
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue