mirror of
https://github.com/iv-org/invidious.git
synced 2025-08-07 14:02:37 -04:00
set a global MAX_LOOKBACK
This commit is contained in:
parent
d6485b2291
commit
8e4df821a7
1 changed files with 5 additions and 4 deletions
|
@ -67,6 +67,7 @@ SOFTWARE = {
|
||||||
}
|
}
|
||||||
|
|
||||||
YT_POOL = YoutubeConnectionPool.new(YT_URL, capacity: CONFIG.pool_size, timeout: 2.0, use_quic: CONFIG.use_quic)
|
YT_POOL = YoutubeConnectionPool.new(YT_URL, capacity: CONFIG.pool_size, timeout: 2.0, use_quic: CONFIG.use_quic)
|
||||||
|
MAX_LOOKBACK = 20
|
||||||
|
|
||||||
# CLI
|
# CLI
|
||||||
Kemal.config.extra_options do |parser|
|
Kemal.config.extra_options do |parser|
|
||||||
|
@ -2463,9 +2464,8 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
# includes into the playlist a maximum of 20 videos, before the offset
|
# includes into the playlist a maximum of 20 videos, before the offset
|
||||||
lookback = 20
|
|
||||||
if offset > 0
|
if offset > 0
|
||||||
lookback = offset < lookback ? offset : lookback
|
lookback = offset < MAX_LOOKBACK ? offset : MAX_LOOKBACK
|
||||||
response = playlist.to_json(offset - lookback, locale)
|
response = playlist.to_json(offset - lookback, locale)
|
||||||
json_response = JSON.parse(response)
|
json_response = JSON.parse(response)
|
||||||
else
|
else
|
||||||
|
@ -2474,12 +2474,13 @@ end
|
||||||
# First we find the actual offset, and then we lookback
|
# First we find the actual offset, and then we lookback
|
||||||
# it shouldn't happen often though
|
# it shouldn't happen often though
|
||||||
|
|
||||||
|
lookback = 0
|
||||||
response = playlist.to_json(offset, locale, continuation: continuation)
|
response = playlist.to_json(offset, locale, continuation: continuation)
|
||||||
json_response = JSON.parse(response)
|
json_response = JSON.parse(response)
|
||||||
|
|
||||||
if json_response["videos"].as_a[0]["index"] != offset
|
if json_response["videos"].as_a[0]["index"] != offset
|
||||||
offset = json_response["videos"].as_a[0]["index"].as_i
|
offset = json_response["videos"].as_a[0]["index"].as_i
|
||||||
lookback = offset < 50 ? offset : 50
|
lookback = offset < MAX_LOOKBACK ? offset : MAX_LOOKBACK
|
||||||
response = playlist.to_json(offset - lookback, locale)
|
response = playlist.to_json(offset - lookback, locale)
|
||||||
json_response = JSON.parse(response)
|
json_response = JSON.parse(response)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue