Change order of html data and status code
This commit is contained in:
parent
b1cb9f7777
commit
b675618b95
2 changed files with 7 additions and 7 deletions
|
@ -715,13 +715,13 @@ async def get_content(url):
|
||||||
try:
|
try:
|
||||||
document = Document(result[0])
|
document = Document(result[0])
|
||||||
content = document.summary()
|
content = document.summary()
|
||||||
info = [code, content]
|
info = [content, code]
|
||||||
except:
|
except:
|
||||||
logging.warning(
|
logging.warning(
|
||||||
"Install package readability.")
|
"Install package readability.")
|
||||||
info = result
|
info = result
|
||||||
else:
|
else:
|
||||||
info = [code, None]
|
info = [None, code]
|
||||||
return info
|
return info
|
||||||
# TODO Either adapt it to filename
|
# TODO Either adapt it to filename
|
||||||
# or change it to something else
|
# or change it to something else
|
||||||
|
|
|
@ -83,7 +83,7 @@ async def message(self, message):
|
||||||
|
|
||||||
# BOTE This is an exceptional case in which we treat
|
# BOTE This is an exceptional case in which we treat
|
||||||
# type groupchat the same as type chat.
|
# type groupchat the same as type chat.
|
||||||
if (message_text.lower().startswith("http")) and(
|
if (message_text.lower().startswith("http") and
|
||||||
message_text.lower().endswith(".opml")):
|
message_text.lower().endswith(".opml")):
|
||||||
url = message_text
|
url = message_text
|
||||||
await task.clean_tasks_xmpp(
|
await task.clean_tasks_xmpp(
|
||||||
|
@ -472,8 +472,8 @@ async def message(self, message):
|
||||||
url = uri.remove_tracking_parameters(url)
|
url = uri.remove_tracking_parameters(url)
|
||||||
url = (uri.replace_hostname(url, "link")) or url
|
url = (uri.replace_hostname(url, "link")) or url
|
||||||
info = await action.get_content(url)
|
info = await action.get_content(url)
|
||||||
content = info[1]
|
content = info[0]
|
||||||
status = info[0]
|
status = info[1]
|
||||||
if content:
|
if content:
|
||||||
try:
|
try:
|
||||||
match ext:
|
match ext:
|
||||||
|
@ -487,8 +487,6 @@ async def message(self, message):
|
||||||
self, jid, filename)
|
self, jid, filename)
|
||||||
await send_oob_message(
|
await send_oob_message(
|
||||||
self, jid, url)
|
self, jid, url)
|
||||||
await task.start_tasks_xmpp(
|
|
||||||
self, jid, ["status"])
|
|
||||||
except:
|
except:
|
||||||
logging.warning(
|
logging.warning(
|
||||||
"Check that packages html2text, pdfkit "
|
"Check that packages html2text, pdfkit "
|
||||||
|
@ -496,6 +494,8 @@ async def message(self, message):
|
||||||
response = (
|
response = (
|
||||||
"Failed to export to {}"
|
"Failed to export to {}"
|
||||||
).format(ext)
|
).format(ext)
|
||||||
|
await task.start_tasks_xmpp(
|
||||||
|
self, jid, ["status"])
|
||||||
else:
|
else:
|
||||||
response = (
|
response = (
|
||||||
"Failed to fetch resource. Reason: {}"
|
"Failed to fetch resource. Reason: {}"
|
||||||
|
|
Loading…
Reference in a new issue