aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/lib/utils.py
diff options
context:
space:
mode:
authorFrançois Schmidts <francois.schmidts@gmail.com>2015-08-03 14:36:13 +0200
committerFrançois Schmidts <francois.schmidts@gmail.com>2015-08-03 15:50:41 +0200
commit0caffceec8b58bc3f78c0d8ea36d2f7e9da668ec (patch)
tree25ede52ae4b02a2377ae40d2c146c7ed2e9abe2a /pyaggr3g470r/lib/utils.py
parentensuring the icon isn't empty and redoing a bit of logging (diff)
downloadnewspipe-0caffceec8b58bc3f78c0d8ea36d2f7e9da668ec.tar.gz
newspipe-0caffceec8b58bc3f78c0d8ea36d2f7e9da668ec.tar.bz2
newspipe-0caffceec8b58bc3f78c0d8ea36d2f7e9da668ec.zip
sqlalchemy was requesting icons everytime feed where listed
so i choosed to move the icons into their own table
Diffstat (limited to 'pyaggr3g470r/lib/utils.py')
-rw-r--r--pyaggr3g470r/lib/utils.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/pyaggr3g470r/lib/utils.py b/pyaggr3g470r/lib/utils.py
index b937b5a9..aa552a12 100644
--- a/pyaggr3g470r/lib/utils.py
+++ b/pyaggr3g470r/lib/utils.py
@@ -1,6 +1,5 @@
import types
import urllib
-import base64
import logging
import requests
from hashlib import md5
@@ -40,7 +39,7 @@ def rebuild_url(url, base_split):
return urllib.parse.urlunsplit(new_split)
-def try_get_b64icon(url, *splits):
+def try_get_icon_url(url, *splits):
for split in splits:
if split is None:
continue
@@ -49,10 +48,10 @@ def try_get_b64icon(url, *splits):
# if html in content-type, we assume it's a fancy 404 page
content_type = response.headers.get('content-type', '')
if response.ok and 'html' not in content_type and response.content:
- return content_type + (
- '\n%s' % base64.b64encode(response.content).decode('utf8'))
+ return response.url
return None
def to_hash(text):
- return md5(text.encode('utf8')).hexdigest()
+ return md5(text.encode('utf8') if hasattr(text, 'encode') else text)\
+ .hexdigest()
bgstack15