Changed method of adding http:// sot URLS
This commit is contained in:
parent
240440ac13
commit
36dcf308d3
2 changed files with 2 additions and 4 deletions
|
@ -8,7 +8,7 @@ def get_title(url):
|
||||||
url = urlnorm.normalize(url.encode('utf-8'))
|
url = urlnorm.normalize(url.encode('utf-8'))
|
||||||
url = url.decode('utf-8')
|
url = url.decode('utf-8')
|
||||||
# add http if its missing
|
# add http if its missing
|
||||||
if not url.startswith("http"):
|
if not "://" in url:
|
||||||
url = "http://" + url
|
url = "http://" + url
|
||||||
try:
|
try:
|
||||||
# get the title
|
# get the title
|
||||||
|
|
|
@ -14,9 +14,7 @@ class ShortenError(Exception):
|
||||||
|
|
||||||
def bitly(url, user, api_key):
|
def bitly(url, user, api_key):
|
||||||
""" shortens a URL with the bit.ly API """
|
""" shortens a URL with the bit.ly API """
|
||||||
if url[:8] == "https://":
|
if not "://" in url:
|
||||||
pass
|
|
||||||
elif url[:7] != "http://":
|
|
||||||
url = "http://" + url
|
url = "http://" + url
|
||||||
params = urlencode({'longUrl': url, 'login': user, 'apiKey': api_key,
|
params = urlencode({'longUrl': url, 'login': user, 'apiKey': api_key,
|
||||||
'format': 'json'})
|
'format': 'json'})
|
||||||
|
|
Reference in a new issue