fix(indexers): btn api client (#71)

What:

*  Api key and torrentId in wrong order
*  Set hardcoded ID in jsonrpc request object
*  ParsetorrentId from url

Fixes #68
This commit is contained in:
Ludvig Lundgren 2022-01-08 15:48:18 +01:00 committed by GitHub
parent e03eac24ba
commit dcd1d458cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 2 deletions

View file

@ -85,9 +85,10 @@ parse:
- preTime - preTime
- test: - test:
- "[ https://XXXXXXXXX/torrents.php?id=7338 / https://XXXXXXXXX/torrents.php?action=download&id=9116 ]" - "[ https://XXXXXXXXX/torrents.php?id=7338 / https://XXXXXXXXX/torrents.php?action=download&id=9116 ]"
pattern: ^\[ .* \/ (https?:\/\/.*id=\d+) \] pattern: ^\[ .* \/ (https?:\/\/.*id=(\d+)) \]
vars: vars:
- baseUrl - baseUrl
- torrentId
match: match:
torrenturl: "{{ .baseUrl }}&authkey={{ .authkey }}&torrent_pass={{ .torrent_pass }}" torrenturl: "{{ .baseUrl }}&authkey={{ .authkey }}&torrent_pass={{ .torrent_pass }}"

View file

@ -30,7 +30,7 @@ func (c *Client) GetTorrentByID(torrentID string) (*domain.TorrentBasic, error)
return nil, fmt.Errorf("btn client: must have torrentID") return nil, fmt.Errorf("btn client: must have torrentID")
} }
res, err := c.rpcClient.Call("getTorrentById", [2]string{torrentID, c.APIKey}) res, err := c.rpcClient.Call("getTorrentById", [2]string{c.APIKey, torrentID})
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -98,6 +98,7 @@ func NewClientWithOpts(endpoint string, opts *ClientOpts) Client {
func (c *rpcClient) Call(method string, params ...interface{}) (*RPCResponse, error) { func (c *rpcClient) Call(method string, params ...interface{}) (*RPCResponse, error) {
request := RPCRequest{ request := RPCRequest{
ID: 1,
JsonRPC: "2.0", JsonRPC: "2.0",
Method: method, Method: method,
Params: Params(params...), Params: Params(params...),