summaryrefslogtreecommitdiff
path: root/searx/utils.py
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2016-08-16 10:37:17 +0200
committerGitHub <noreply@github.com>2016-08-16 10:37:17 +0200
commit13bed1f8727683c74d04c52396fabbfab99df76f (patch)
tree6ef9b75de5e1886a72f9544072bd55a30742f759 /searx/utils.py
parentacfe843ecd038ee3518f2afcee68bfedf4366366 (diff)
parentd320dd0efc44f178da5156fa152b8337f2e11281 (diff)
Merge pull request #639 from kvch/digbt-engine
add digbt engine - fixes #638
Diffstat (limited to 'searx/utils.py')
-rw-r--r--searx/utils.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/searx/utils.py b/searx/utils.py
index aa8ce92a1..744142e36 100644
--- a/searx/utils.py
+++ b/searx/utils.py
@@ -237,3 +237,21 @@ def list_get(a_list, index, default=None):
return a_list[index]
else:
return default
+
+
+def get_torrent_size(filesize, filesize_multiplier):
+ try:
+ filesize = float(filesize)
+
+ if filesize_multiplier == 'TB':
+ filesize = int(filesize * 1024 * 1024 * 1024 * 1024)
+ elif filesize_multiplier == 'GB':
+ filesize = int(filesize * 1024 * 1024 * 1024)
+ elif filesize_multiplier == 'MB':
+ filesize = int(filesize * 1024 * 1024)
+ elif filesize_multiplier == 'KB':
+ filesize = int(filesize * 1024)
+ except:
+ filesize = None
+
+ return filesize