convert some left over readUrls to read_url
This commit is contained in:
parent
7ebfdaff30
commit
3a0c35372d
3 changed files with 5 additions and 5 deletions
|
@ -112,7 +112,7 @@ def save_url(url, filename, overwrite=False):
|
||||||
dirname = os.path.dirname(filename)
|
dirname = os.path.dirname(filename)
|
||||||
if not os.path.exists(dirname):
|
if not os.path.exists(dirname):
|
||||||
os.makedirs(dirname)
|
os.makedirs(dirname)
|
||||||
data = readUrl(url)
|
data = read_url(url)
|
||||||
f = open(filename, 'w')
|
f = open(filename, 'w')
|
||||||
f.write(data)
|
f.write(data)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
|
@ -87,7 +87,7 @@ def save_url(url, filename, overwrite=False):
|
||||||
dirname = os.path.dirname(filename)
|
dirname = os.path.dirname(filename)
|
||||||
if not os.path.exists(dirname):
|
if not os.path.exists(dirname):
|
||||||
os.makedirs(dirname)
|
os.makedirs(dirname)
|
||||||
data = readUrl(url)
|
data = read_url(url)
|
||||||
f = open(filename, 'w')
|
f = open(filename, 'w')
|
||||||
f.write(data)
|
f.write(data)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
|
@ -9,7 +9,7 @@ def get_embed_code(url, maxwidth=None, maxheight=None):
|
||||||
embed = {}
|
embed = {}
|
||||||
header = cache.get_headers(url)
|
header = cache.get_headers(url)
|
||||||
if header.get('content-type', '').startswith('text/html'):
|
if header.get('content-type', '').startswith('text/html'):
|
||||||
html = cache.readUrl(url)
|
html = cache.read_url(url)
|
||||||
json_oembed = filter(lambda l: 'json+oembed' in l, re.compile('<link.*?>').findall(html))
|
json_oembed = filter(lambda l: 'json+oembed' in l, re.compile('<link.*?>').findall(html))
|
||||||
xml_oembed = filter(lambda l: 'xml+oembed' in l, re.compile('<link.*?>').findall(html))
|
xml_oembed = filter(lambda l: 'xml+oembed' in l, re.compile('<link.*?>').findall(html))
|
||||||
if json_oembed:
|
if json_oembed:
|
||||||
|
@ -18,14 +18,14 @@ def get_embed_code(url, maxwidth=None, maxheight=None):
|
||||||
oembed_url += '&maxwidth=%d' % maxwidth
|
oembed_url += '&maxwidth=%d' % maxwidth
|
||||||
if maxheight:
|
if maxheight:
|
||||||
oembed_url += '&maxheight=%d' % maxheight
|
oembed_url += '&maxheight=%d' % maxheight
|
||||||
embed = json.loads(cache.readUrl(oembed_url))
|
embed = json.loads(cache.read_url(oembed_url))
|
||||||
elif xml_oembed:
|
elif xml_oembed:
|
||||||
oembed_url = find_re(json_oembed[0], 'href="(.*?)"')
|
oembed_url = find_re(json_oembed[0], 'href="(.*?)"')
|
||||||
if maxwidth:
|
if maxwidth:
|
||||||
oembed_url += '&maxwidth=%d' % maxwidth
|
oembed_url += '&maxwidth=%d' % maxwidth
|
||||||
if maxheight:
|
if maxheight:
|
||||||
oembed_url += '&maxheight=%d' % maxheight
|
oembed_url += '&maxheight=%d' % maxheight
|
||||||
data = cache.readUrl(oembed_url)
|
data = cache.read_url(oembed_url)
|
||||||
for e in ET.fromstring(data):
|
for e in ET.fromstring(data):
|
||||||
embed[e.tag] = e.text
|
embed[e.tag] = e.text
|
||||||
return embed
|
return embed
|
||||||
|
|
Loading…
Reference in a new issue