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
|
// GetTorrents returns all torrents, paginated
|
||||||
// if customLimit is 0, the default limit of 500 is used
|
// if customLimit is 0, the default limit of 500 is used
|
||||||
func (rd *RealDebrid) GetTorrents(customLimit int, active bool) ([]Torrent, int, error) {
|
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"
|
baseURL := "https://api.real-debrid.com/rest/1.0/torrents"
|
||||||
var allTorrents []Torrent
|
var allTorrents []Torrent
|
||||||
page := 1
|
page := 1
|
||||||
@@ -136,7 +136,7 @@ func (rd *RealDebrid) GetTorrents(customLimit int, active bool) ([]Torrent, int,
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
results := make(chan fetchResult, 4) // Channel to collect results from goroutines
|
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) {
|
go func(p int) {
|
||||||
params := url.Values{}
|
params := url.Values{}
|
||||||
params.Set("page", fmt.Sprintf("%d", p))
|
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
|
// Collect results from all goroutines
|
||||||
for i := 0; i < GET_PARALLEL; i++ {
|
for i := 0; i < MAX_PARALLEL; i++ {
|
||||||
result := <-results
|
result := <-results
|
||||||
if result.err != nil {
|
if result.err != nil {
|
||||||
return nil, 0, result.err
|
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
|
// 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
|
// Break loop if all torrents fetched or the limit is reached
|
||||||
if len(allTorrents) >= totalCount || (customLimit != 0 && len(allTorrents) >= customLimit) {
|
if len(allTorrents) >= totalCount || (customLimit != 0 && len(allTorrents) >= customLimit) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
# When zurg detects changes, it can trigger this script IF your config.yml contains
|
# When zurg detects changes, it can trigger this script IF your config.yml contains
|
||||||
# on_library_update: sh plex_update.sh "$@"
|
# on_library_update: sh plex_update.sh "$@"
|
||||||
|
|
||||||
dockerip=$(/sbin/ip route|awk '/default/ { print $3 }') # if zurg is running inside a Docker container
|
# dockerip=$(/sbin/ip route|awk '/default/ { print $3 }') # if zurg is running inside a Docker container
|
||||||
localip="localhost" # if zurg is running on the host machine, and Plex is running on the same machine
|
localip="localhost" # if zurg is running on the host machine, and Plex is running on the same machine
|
||||||
external="plexdomain.com" # if Plex is running on a different machine
|
external="plexdomain.com" # if Plex is running on a different machine
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user