Small differences in between py2 and py3
This commit is contained in:
parent
f311de7043
commit
9ab00fdded
@ -69,6 +69,9 @@ def download(url):
|
||||
socket.socket = socks.socksocket
|
||||
try:
|
||||
r = urlopen(url)
|
||||
try:
|
||||
size = int(dict(r.info())['content-length'].strip())
|
||||
except KeyError:
|
||||
try:
|
||||
size = int(dict(r.info())['Content-Length'].strip())
|
||||
except KeyError:
|
||||
@ -87,10 +90,18 @@ def download(url):
|
||||
else:
|
||||
break
|
||||
contenttype = False
|
||||
contenttype_req = None
|
||||
try:
|
||||
if 'pdf' in dict(r.info())['Content-Type']:
|
||||
contenttype_req = dict(r.info())['content-type']
|
||||
except KeyError:
|
||||
try:
|
||||
contenttype_req = dict(r.info())['Content-Type']
|
||||
except KeyError:
|
||||
continue
|
||||
try:
|
||||
if 'pdf' in contenttype_req:
|
||||
contenttype = 'pdf'
|
||||
elif 'djvu' in dict(r.info())['Content-Type']:
|
||||
elif 'djvu' in contenttype_req:
|
||||
contenttype = 'djvu'
|
||||
except KeyError:
|
||||
pass
|
||||
@ -245,6 +256,12 @@ def doi2Bib(doi):
|
||||
try:
|
||||
r = urlopen(req)
|
||||
|
||||
try:
|
||||
if dict(r.info())['content-type'] == 'application/x-bibtex':
|
||||
return r.read().decode('utf-8')
|
||||
else:
|
||||
return ''
|
||||
except KeyError:
|
||||
try:
|
||||
if dict(r.info())['Content-Type'] == 'application/x-bibtex':
|
||||
return r.read().decode('utf-8')
|
||||
|
Loading…
Reference in New Issue
Block a user