summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFéry Mathieu (Mathius) <ferymathieuy@gmail.com>2022-02-22 01:34:19 +0100
committerFéry Mathieu (Mathius) <ferymathieuy@gmail.com>2022-02-22 01:34:19 +0100
commitf109d812a1d8ea92a4ebdeb7ce03ad93bcbd9a91 (patch)
tree4a8e53ead336f592a92a996c81585f901a1d131c /src
parent5d2f2690e287d4fc1275dd9d3dc283e607117c0e (diff)
downloadinvidious-f109d812a1d8ea92a4ebdeb7ce03ad93bcbd9a91.tar.gz
invidious-f109d812a1d8ea92a4ebdeb7ce03ad93bcbd9a91.tar.bz2
invidious-f109d812a1d8ea92a4ebdeb7ce03ad93bcbd9a91.zip
Move TimeSpanConverter with another Converters
Follow indications : https://github.com/iv-org/invidious/pull/2915#discussion_r811373953
Diffstat (limited to 'src')
-rw-r--r--src/invidious/config.cr2
-rw-r--r--src/invidious/helpers/utils.cr14
-rw-r--r--src/invidious/user/preferences.cr16
3 files changed, 16 insertions, 16 deletions
diff --git a/src/invidious/config.cr b/src/invidious/config.cr
index 158a05cc..cf705d21 100644
--- a/src/invidious/config.cr
+++ b/src/invidious/config.cr
@@ -59,7 +59,7 @@ class Config
# Number of threads to use for crawling videos from channels (for updating subscriptions)
property channel_threads : Int32 = 1
# Time between two jobs for crawling videos from channels
- @[YAML::Field(converter: TimeSpanConverter)]
+ @[YAML::Field(converter: Preferences::TimeSpanConverter)]
property channel_refresh_interval : Time::Span = 30.minutes
# Number of threads to use for updating feeds
property feed_threads : Int32 = 1
diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr
index 2702c5e9..22575c57 100644
--- a/src/invidious/helpers/utils.cr
+++ b/src/invidious/helpers/utils.cr
@@ -18,20 +18,6 @@ def elapsed_text(elapsed)
"#{(millis * 1000).round(2)}µs"
end
-module TimeSpanConverter
- def self.to_yaml(value : Time::Span, yaml : YAML::Nodes::Builder)
- return yaml.scalar recode_length_seconds(value.total_seconds.to_i32)
- end
-
- def self.from_yaml(ctx : YAML::ParseContext, node : YAML::Nodes::Node) : Time::Span
- if node.is_a?(YAML::Nodes::Scalar)
- return decode_time_span(node.value)
- else
- node.raise "Expected scalar, not #{node.class}"
- end
- end
-end
-
def decode_time_span(string : String) : Time::Span
time_span = string.gsub(/[^0-9:]/, "")
return Time::Span.new(seconds: 0) if time_span.empty?
diff --git a/src/invidious/user/preferences.cr b/src/invidious/user/preferences.cr
index bf7ea401..c01bdd82 100644
--- a/src/invidious/user/preferences.cr
+++ b/src/invidious/user/preferences.cr
@@ -256,4 +256,18 @@ struct Preferences
cookies
end
end
-end
+
+ module TimeSpanConverter
+ def self.to_yaml(value : Time::Span, yaml : YAML::Nodes::Builder)
+ return yaml.scalar recode_length_seconds(value.total_seconds.to_i32)
+ end
+
+ def self.from_yaml(ctx : YAML::ParseContext, node : YAML::Nodes::Node) : Time::Span
+ if node.is_a?(YAML::Nodes::Scalar)
+ return decode_time_span(node.value)
+ else
+ node.raise "Expected scalar, not #{node.class}"
+ end
+ end
+ end
+end \ No newline at end of file