mirror of
https://github.com/idanoo/autobrr
synced 2025-07-22 08:19:12 +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
|
||||
}
|
||||
|
|
76
internal/indexer/definitions/t66y.yaml
Normal file
76
internal/indexer/definitions/t66y.yaml
Normal file
|
@ -0,0 +1,76 @@
|
|||
---
|
||||
#id: t66y
|
||||
name: T66y
|
||||
identifier: t66y
|
||||
description: T66y is an indexer for the Caoliu Community.
|
||||
language: en-us
|
||||
urls:
|
||||
- https://t66y.com/
|
||||
privacy: public
|
||||
protocol: torrent
|
||||
supports:
|
||||
- irc
|
||||
#source: custom
|
||||
|
||||
irc:
|
||||
network: Rizon
|
||||
server: irc.rizon.net
|
||||
port: 6697
|
||||
tls: true
|
||||
channels:
|
||||
- '#t66y'
|
||||
announcers:
|
||||
- 'ty'
|
||||
settings:
|
||||
- name: nick
|
||||
type: text
|
||||
required: true
|
||||
label: Nick
|
||||
help: Bot nick. Eg. user_bot
|
||||
|
||||
- name: auth.account
|
||||
type: text
|
||||
required: false
|
||||
label: NickServ Account
|
||||
help: NickServ account. Make sure to group your main user and bot.
|
||||
|
||||
- name: auth.password
|
||||
type: secret
|
||||
required: false
|
||||
label: NickServ Password
|
||||
help: NickServ password
|
||||
|
||||
parse:
|
||||
type: single
|
||||
lines:
|
||||
- tests:
|
||||
- line: '6769288 28 f3df71e5bdf2ca66168be7c1390e5685742bf6a8 [MP4/3.81G]JUR-274【破壊版】会社の地味な人妻経理を≪濃厚マゾ潮≫吹き散らかす、俺専用の愛人に仕立て上げた―。 椎名ゆな'
|
||||
expect:
|
||||
postId: 6769288
|
||||
category: 28
|
||||
torrentHash: f3df71e5bdf2ca66168be7c1390e5685742bf6a8
|
||||
torrentName: '[MP4/3.81G]JUR-274【破壊版】会社の地味な人妻経理を≪濃厚マゾ潮≫吹き散らかす、俺専用の愛人に仕立て上げた―。 椎名ゆな'
|
||||
|
||||
- line: '6768519 4 39d9edb94572e82dd534547b785c98fe2df7ea51 [MP4/FHD]RARBG1023625-第一视角催情SPA性交'
|
||||
expect:
|
||||
postId: 6768519
|
||||
category: 4
|
||||
torrentHash: 39d9edb94572e82dd534547b785c98fe2df7ea51
|
||||
torrentName: '[MP4/FHD]RARBG1023625-第一视角催情SPA性交'
|
||||
|
||||
- line: '6768127 2 81c758d0eca5372d59e43879ecf2e2bce33a06c4 [MP4/3.83G]fc2-ppv-3270070 幼さが残る18才の黒髪清楚の女の子。 夢の為にAV撮影、はじめての中出しまで'
|
||||
expect:
|
||||
postId: 6768127
|
||||
category: 2
|
||||
torrentHash: 81c758d0eca5372d59e43879ecf2e2bce33a06c4
|
||||
torrentName: '[MP4/3.83G]fc2-ppv-3270070 幼さが残る18才の黒髪清楚の女の子。 夢の為にAV撮影、はじめての中出しまで'
|
||||
|
||||
pattern: '(\d+)\ (\d+)\ ([a-z0-9]{40})\ (.*)'
|
||||
vars:
|
||||
- postId
|
||||
- category
|
||||
- torrentHash
|
||||
- torrentName
|
||||
|
||||
match:
|
||||
magneturi: 'magnet:?xt=urn:btih:{{ .torrentHash }}&dn={{ urlquery .torrentName }}'
|
Loading…
Add table
Add a link
Reference in a new issue