Use body reader
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package realdebrid
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -31,8 +30,8 @@ func (rd *RealDebrid) UnrestrictCheck(link string) (*Download, error) {
|
||||
data := url.Values{}
|
||||
data.Set("link", link)
|
||||
|
||||
dataBytes := bytes.NewBufferString(data.Encode())
|
||||
requestBody := io.NopCloser(dataBytes)
|
||||
bodyReader := strings.NewReader(data.Encode())
|
||||
requestBody := io.NopCloser(bodyReader)
|
||||
|
||||
req, err := http.NewRequest("POST", "https://api.real-debrid.com/rest/1.0/unrestrict/check", requestBody)
|
||||
if err != nil {
|
||||
@@ -69,8 +68,8 @@ func (rd *RealDebrid) UnrestrictLink(link string, checkFirstByte bool) (*Downloa
|
||||
data := url.Values{}
|
||||
data.Set("link", link)
|
||||
|
||||
dataBytes := bytes.NewBufferString(data.Encode())
|
||||
requestBody := io.NopCloser(dataBytes)
|
||||
bodyReader := strings.NewReader(data.Encode())
|
||||
requestBody := io.NopCloser(bodyReader)
|
||||
|
||||
req, err := http.NewRequest("POST", "https://api.real-debrid.com/rest/1.0/unrestrict/link", requestBody)
|
||||
if err != nil {
|
||||
@@ -220,8 +219,8 @@ func (rd *RealDebrid) SelectTorrentFiles(id string, files string) error {
|
||||
data := url.Values{}
|
||||
data.Set("files", files)
|
||||
|
||||
dataBytes := bytes.NewBufferString(data.Encode())
|
||||
requestBody := io.NopCloser(dataBytes)
|
||||
bodyReader := strings.NewReader(data.Encode())
|
||||
requestBody := io.NopCloser(bodyReader)
|
||||
|
||||
reqURL := fmt.Sprintf("https://api.real-debrid.com/rest/1.0/torrents/selectFiles/%s", id)
|
||||
req, err := http.NewRequest("POST", reqURL, requestBody)
|
||||
@@ -271,8 +270,8 @@ func (rd *RealDebrid) AddMagnetHash(magnet string) (*MagnetResponse, error) {
|
||||
data := url.Values{}
|
||||
data.Set("magnet", fmt.Sprintf("magnet:?xt=urn:btih:%s", magnet))
|
||||
|
||||
dataBytes := bytes.NewBufferString(data.Encode())
|
||||
requestBody := io.NopCloser(dataBytes)
|
||||
bodyReader := strings.NewReader(data.Encode())
|
||||
requestBody := io.NopCloser(bodyReader)
|
||||
|
||||
// Construct request URL
|
||||
reqURL := "https://api.real-debrid.com/rest/1.0/torrents/addMagnet"
|
||||
|
||||
Reference in New Issue
Block a user