Skip to content

Commit

Permalink
torrent:RenameFile
Browse files Browse the repository at this point in the history
  • Loading branch information
NullpointerW committed Jun 19, 2023
1 parent 24593a2 commit 5d437fa
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
19 changes: 16 additions & 3 deletions apiv2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,21 +182,34 @@ func TestDelTorr(t *testing.T) {
if err != nil {
panic(err)
}
err = cli.DelTorrentsFs("79d4e6885d8c796c114ce912b1e612c0a97b01e9","940c46c2ba144ba90fa95278f8dbc12dd52036c0")
err = cli.DelTorrentsFs("79d4e6885d8c796c114ce912b1e612c0a97b01e9", "940c46c2ba144ba90fa95278f8dbc12dd52036c0")
if err != nil {
fmt.Printf("%+v\n", err)
t.FailNow()
}
}

func TestDelTags(t *testing.T){
func TestDelTags(t *testing.T) {
cli, err := NewCli("http://localhost:8991")
if err != nil {
panic(err)
}
err = cli.DelTags("123","456")
err = cli.DelTags("123", "456")
if err != nil {
fmt.Printf("%+v\n", err)
t.FailNow()
}
}

func TestRenameFile(t *testing.T) {
cli, err := NewCli("http://localhost:8991")
if err != nil {
panic(err)
}
err = cli.RenameFile("385191f125783e4dc16689f0ed7b5cf00961155d",
"[UHA-WINGS][Tengoku Daimakyou][06][x264 1080p][CHS].mp4",
"es103.mp4")
if err != nil {
t.Error(err)
}
}
15 changes: 15 additions & 0 deletions torrents.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,18 @@ func (c *Client) DelTags(tags ...string) error {
ignrBody(resp.Body)
return nil
}

func (c *Client) RenameFile(hash, old, new string) error {
opt := Optional{
"hash": hash,
"oldPath": old,
"newPath": new,
}
resp, err := c.postXwwwFormUrlencoded("torrents/renameFile", opt)
err = RespOk(resp, err)
if err != nil {
return err
}
ignrBody(resp.Body)
return nil
}

0 comments on commit 5d437fa

Please sign in to comment.