1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
theorangeone.net-legacy/plugins/filters.py

21 lines
499 B
Python
Raw Normal View History

2016-05-27 15:42:29 +01:00
import iso8601
2016-05-27 23:19:03 +01:00
from bs4 import BeautifulSoup
2016-05-27 15:42:29 +01:00
def format_datetime(value):
2016-05-27 15:56:08 +01:00
return iso8601.parse_date(str(value)).strftime("%x %-H:%M")
2016-05-27 23:19:03 +01:00
def html_to_raw(html):
soup = BeautifulSoup(html, "html.parser")
for script in soup(["script", "style"]): # Remove script / style tags
script.extract()
return soup.get_text()
def category_find(categories, name):
for category_name, articles in categories:
if category_name == name:
return articles
return []