Change constant name
This commit is contained in:
@@ -118,7 +118,7 @@ func (rd *RealDebrid) UnrestrictLink(link string, checkFirstByte bool) (*Downloa
|
||||
// GetTorrents returns all torrents, paginated
|
||||
// if customLimit is 0, the default limit of 500 is used
|
||||
func (rd *RealDebrid) GetTorrents(customLimit int, active bool) ([]Torrent, int, error) {
|
||||
const GET_PARALLEL = 4
|
||||
const MAX_PARALLEL = 4
|
||||
baseURL := "https://api.real-debrid.com/rest/1.0/torrents"
|
||||
var allTorrents []Torrent
|
||||
page := 1
|
||||
@@ -136,7 +136,7 @@ func (rd *RealDebrid) GetTorrents(customLimit int, active bool) ([]Torrent, int,
|
||||
|
||||
for {
|
||||
results := make(chan fetchResult, 4) // Channel to collect results from goroutines
|
||||
for i := 0; i < GET_PARALLEL; i++ { // Launch GET_PARALLEL concurrent fetches
|
||||
for i := 0; i < MAX_PARALLEL; i++ { // Launch GET_PARALLEL concurrent fetches
|
||||
go func(p int) {
|
||||
params := url.Values{}
|
||||
params.Set("page", fmt.Sprintf("%d", p))
|
||||
@@ -180,7 +180,7 @@ func (rd *RealDebrid) GetTorrents(customLimit int, active bool) ([]Torrent, int,
|
||||
}
|
||||
|
||||
// Collect results from all goroutines
|
||||
for i := 0; i < GET_PARALLEL; i++ {
|
||||
for i := 0; i < MAX_PARALLEL; i++ {
|
||||
result := <-results
|
||||
if result.err != nil {
|
||||
return nil, 0, result.err
|
||||
@@ -192,7 +192,7 @@ func (rd *RealDebrid) GetTorrents(customLimit int, active bool) ([]Torrent, int,
|
||||
}
|
||||
|
||||
// Increment page by GET_PARALLEL for the next iteration of GET_PARALLEL concurrent fetches
|
||||
page += GET_PARALLEL
|
||||
page += MAX_PARALLEL
|
||||
|
||||
// Break loop if all torrents fetched or the limit is reached
|
||||
if len(allTorrents) >= totalCount || (customLimit != 0 && len(allTorrents) >= customLimit) {
|
||||
|
||||
Reference in New Issue
Block a user