summaryrefslogtreecommitdiff
path: root/searx/utils.py
diff options
context:
space:
mode:
authorBnyro <bnyro@tutanota.com>2024-07-20 21:27:12 +0200
committerMarkus Heiser <markus.heiser@darmarIT.de>2024-07-27 11:49:58 +0200
commit304ddd8114e12f4fdd5057dc933a2981bd9e1ec7 (patch)
tree036c00c01e08e1dd1eb1a6ee136f88d8d5871848 /searx/utils.py
parent3f22dbb68ab1b1effa84048e15651c5b2e6aa160 (diff)
downloadsearxng-304ddd8114e12f4fdd5057dc933a2981bd9e1ec7.tar.gz
searxng-304ddd8114e12f4fdd5057dc933a2981bd9e1ec7.zip
[feat] videos template: support for view count
Diffstat (limited to 'searx/utils.py')
-rw-r--r--searx/utils.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/searx/utils.py b/searx/utils.py
index 191161bde..407d44cd0 100644
--- a/searx/utils.py
+++ b/searx/utils.py
@@ -334,6 +334,18 @@ def humanize_bytes(size, precision=2):
return "%.*f %s" % (precision, size, s[p])
+def humanize_number(size, precision=0):
+ """Determine the *human readable* value of a decimal number."""
+ s = ['', 'K', 'M', 'B', 'T']
+
+ x = len(s)
+ p = 0
+ while size > 1000 and p < x:
+ p += 1
+ size = size / 1000.0
+ return "%.*f%s" % (precision, size, s[p])
+
+
def convert_str_to_int(number_str: str) -> int:
"""Convert number_str to int or 0 if number_str is not a number."""
if number_str.isdigit():