Browse Source

Fix some queries and formatting

master
Alec Murphy 5 years ago
parent
commit
5fe4ab849c
  1. 6
      Uriel.HC
  2. 20
      uriel.py

6
Uriel.HC

@ -32,7 +32,7 @@ U0 U_InsertThumb(U8 *anchor, U8 *indent, U8 *outdent, U8 *url)
HGExec(URIEL_THUMB);
ReadParamBuf;
size = Str2I64(HGBD_PARAM_BUF);
if (size==-1) {
if (size<1) {
PopUpOk("Error loading image.");
return;
};
@ -66,7 +66,7 @@ U0 U_Browser(U8 *url)
HGExec(URIEL_GETPAGE);
ReadParamBuf;
size = Str2I64(HGBD_PARAM_BUF);
if (size==-1) {
if (size<1) {
PopUpOk("Bad URL.");
return;
};
@ -132,7 +132,7 @@ U0 U_HistNav(I64 index)
if (index==1) { HGExec(URIEL_NAVFWD); };
ReadParamBuf;
size = Str2I64(HGBD_PARAM_BUF);
if (size==-1) {
if (size<1) {
PopUpOk("Bad URL.");
return;
};

20
uriel.py

@ -67,6 +67,8 @@ def UrielGetPage():
post_scheme = netloc + "/" + urllib.quote(path)
post_scheme = post_scheme.replace('//','/')
if url_comp.query != '':
post_scheme += '?'+url_comp.query
url = scheme + "://" + post_scheme
pagedata = subprocess.Popen('wget -q -O - -U "' + Uriel.user_agent + '" "' + url + '" 2>/dev/null', shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0]
filedata = UrielPreProcess(pagedata, url)
@ -149,6 +151,8 @@ def UrielNavBack():
post_scheme = netloc + "/" + urllib.quote(path)
post_scheme = post_scheme.replace('//','/')
if url_comp.query != '':
post_scheme += '?'+url_comp.query
url = scheme + "://" + post_scheme
filesize = len(filedata)
if filesize>0:
@ -203,6 +207,8 @@ def UrielNavFwd():
post_scheme = netloc + "/" + urllib.quote(path)
post_scheme = post_scheme.replace('//','/')
if url_comp.query != '':
post_scheme += '?'+url_comp.query
url = scheme + "://" + post_scheme
filesize = len(filedata)
if filesize>0:
@ -260,6 +266,8 @@ def UrielThumb():
post_scheme = netloc + "/" + urllib.quote(path)
post_scheme = post_scheme.replace('//','/')
if url_comp.query != '':
post_scheme += '?'+url_comp.query
url = scheme + "://" + post_scheme
tmp_thumb = '/tmp/' + str(uuid.uuid4()) + '.bmp'
while os.path.exists(tmp_thumb):
@ -290,9 +298,13 @@ def UrielPreProcess(htm1, l_url):
title_text = ''
hb_header = '$WW,1$$BLACK$$MA+LIS,"[Close]",LM="U_CloseBrowser;"$ $MA+LIS,"[Back]",LM="U_HistNav(0);"$ $MA+LIS,"[Fwd]",LM="U_HistNav(1);"$ $MA+LIS,"[Go]",LM="U_Browser(GetStr(\\"\nURL> \\"));"$ ' + title_text + '\n\n'
if htm1.upper().find('<HTML') == -1:
dl_link = '$AN,"",A="BINARY"$Click $MA+LIS,"[Here]",LM="U_Download(\\"' + l_url + '\\");"$ to download the file:\n\n' + l_url
return hb_header + dl_link
doc_detect = False
if htm1.upper().find('<HTML') != -1:
doc_detect = True
if htm1.upper().find('<!DOCTYPE HTML') != -1:
doc_detect = True
if doc_detect == False:
return '$AN,"",A="BINARY"$'
htm1 = htm1[htm1.upper().find('<HTML'):]
htm1 = htm1.replace('$', '$$')
@ -331,7 +343,7 @@ def UrielPreProcess(htm1, l_url):
if tag.name.upper() != 'IMG':
tag.decompose()
remove_tags = [ 'svg', 'embed', 'head', 'noscript', 'object', 'param', 'script', 'option' ]
remove_tags = [ 'style', 'svg', 'embed', 'head', 'noscript', 'object', 'param', 'script', 'option' ]
for tag in remove_tags:
[s.extract() for s in soup1(tag)]

Loading…
Cancel
Save