summaryrefslogtreecommitdiff
path: root/ishtar_common/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r--ishtar_common/utils.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py
index 7c77fc3d1..b2ba2bc24 100644
--- a/ishtar_common/utils.py
+++ b/ishtar_common/utils.py
@@ -23,6 +23,7 @@ from itertools import chain
import hashlib
import os
import random
+import requests
import shutil
import subprocess
import tempfile
@@ -73,6 +74,20 @@ class MultiValueDict(BaseMultiValueDict):
return lst
+def is_downloadable(url):
+ """
+ Does the url contain a downloadable resource
+ """
+ h = requests.head(url, allow_redirects=True)
+ header = h.headers
+ content_type = header.get('content-type')
+ if 'text' in content_type.lower():
+ return False
+ if 'html' in content_type.lower():
+ return False
+ return True
+
+
def get_current_year():
return datetime.datetime.now().year