mirror of
https://github.com/searxng/searxng.git
synced 2025-07-15 01:09:21 +02:00
[feat] videos template: support for view count
This commit is contained in:
parent
3f22dbb68a
commit
304ddd8114
6 changed files with 23 additions and 2 deletions
|
@ -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():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue