Skip to content

Commit fd0ac3a

Browse files
committed
Update management of channel_refresh_interval
Follow indications: #2915 (comment)
1 parent f109d81 commit fd0ac3a

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

config/config.example.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,10 @@ channel_threads: 1
317317
##
318318
## Time between two jobs for crawling videos from channels
319319
##
320-
## Accepted values: a valid time interval (hours:min:seconds)
321-
## Default: 00:30:00
320+
## Accepted values: a valid time interval (like 1h30m or 90min)
321+
## Default: 30m
322322
##
323-
channel_refresh_interval: 00:30:00
323+
channel_refresh_interval: 30min
324324

325325
##
326326
## Forcefully dump and re-download the entire list of uploaded

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ services:
2525
INVIDIOUS_CONFIG: |
2626
log_level: Info
2727
channel_threads: 1
28-
channel_refresh_interval: 00:30:00
28+
channel_refresh_interval: 30m
2929
check_tables: true
3030
feed_threads: 1
3131
db:

src/invidious/helpers/utils.cr

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,24 @@ def recode_length_seconds(time : Int32) : String
5353
end
5454
end
5555

56+
def decode_interval(string : String) : Time::Span
57+
rawMinutes = string.try &.to_i32?
58+
59+
if !rawMinutes
60+
hours = /(?<hours>\d+)h/.match(string).try &.["hours"].try &.to_i32
61+
hours ||= 0
62+
63+
minutes = /(?<minutes>\d+)m(?!s)/.match(string).try &.["minutes"].try &.to_i32
64+
minutes ||= 0
65+
66+
time = Time::Span.new(hours: hours, minutes: minutes)
67+
else
68+
time = Time::Span.new(minutes: rawMinutes)
69+
end
70+
71+
return time
72+
end
73+
5674
def decode_time(string)
5775
time = string.try &.to_f?
5876

src/invidious/user/preferences.cr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,15 @@ struct Preferences
259259

260260
module TimeSpanConverter
261261
def self.to_yaml(value : Time::Span, yaml : YAML::Nodes::Builder)
262-
return yaml.scalar recode_length_seconds(value.total_seconds.to_i32)
262+
return yaml.scalar value.total_minutes.to_i32
263263
end
264264

265265
def self.from_yaml(ctx : YAML::ParseContext, node : YAML::Nodes::Node) : Time::Span
266266
if node.is_a?(YAML::Nodes::Scalar)
267-
return decode_time_span(node.value)
267+
return decode_interval(node.value)
268268
else
269269
node.raise "Expected scalar, not #{node.class}"
270270
end
271271
end
272272
end
273-
end
273+
end

0 commit comments

Comments
 (0)