mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
85cc2eb22d
commit
a9f49879ce
|
@ -10,6 +10,7 @@ __module_group__ = "Core"
|
||||||
import os
|
import os
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
|
from utils import string_contains
|
||||||
from utils import get_instance_url
|
from utils import get_instance_url
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,9 +122,7 @@ def _set_headers_base(self, file_format: str, length: int, cookie: str,
|
||||||
calling_domain: str, permissive: bool) -> None:
|
calling_domain: str, permissive: bool) -> None:
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.send_header('Content-type', file_format)
|
self.send_header('Content-type', file_format)
|
||||||
if 'image/' in file_format or \
|
if string_contains(file_format, ('image/', 'audio/', 'video/')):
|
||||||
'audio/' in file_format or \
|
|
||||||
'video/' in file_format:
|
|
||||||
cache_control = 'public, max-age=84600, immutable'
|
cache_control = 'public, max-age=84600, immutable'
|
||||||
self.send_header('Cache-Control', cache_control)
|
self.send_header('Cache-Control', cache_control)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -8,6 +8,7 @@ __status__ = "Production"
|
||||||
__module_group__ = "API"
|
__module_group__ = "API"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from utils import string_contains
|
||||||
from utils import get_url_from_post
|
from utils import get_url_from_post
|
||||||
from utils import load_json
|
from utils import load_json
|
||||||
from utils import get_config_param
|
from utils import get_config_param
|
||||||
|
@ -346,12 +347,9 @@ def masto_api_v1_response(path: str, calling_domain: str,
|
||||||
path_nickname = get_nickname_from_masto_api_v1id(masto_id)
|
path_nickname = get_nickname_from_masto_api_v1id(masto_id)
|
||||||
if path_nickname:
|
if path_nickname:
|
||||||
original_path = path
|
original_path = path
|
||||||
if '/followers?' in path or \
|
if string_contains(path,
|
||||||
'/following?' in path or \
|
('/followers?', '/following?', '/streaming/',
|
||||||
'/streaming/' in path or \
|
'/search?', '/relationships?', '/statuses?')):
|
||||||
'/search?' in path or \
|
|
||||||
'/relationships?' in path or \
|
|
||||||
'/statuses?' in path:
|
|
||||||
path = path.split('?')[0]
|
path = path.split('?')[0]
|
||||||
if '/streaming/' in path:
|
if '/streaming/' in path:
|
||||||
streaming_msg = \
|
streaming_msg = \
|
||||||
|
|
|
@ -19,6 +19,7 @@ from datetime import timezone
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from utils import valid_post_date
|
from utils import valid_post_date
|
||||||
from categories import set_hashtag_category
|
from categories import set_hashtag_category
|
||||||
|
from utils import string_contains
|
||||||
from utils import image_mime_types_dict
|
from utils import image_mime_types_dict
|
||||||
from utils import resembles_url
|
from utils import resembles_url
|
||||||
from utils import get_url_from_post
|
from utils import get_url_from_post
|
||||||
|
@ -667,9 +668,9 @@ def xml_podcast_to_dict(base_dir: str, xml_item: str, xml_str: str) -> {}:
|
||||||
podcast_properties['image'] = podcast_episode_image
|
podcast_properties['image'] = podcast_episode_image
|
||||||
podcast_properties['categories'] = podcast_categories
|
podcast_properties['categories'] = podcast_categories
|
||||||
|
|
||||||
if '<itunes:explicit>Y' in xml_item or \
|
if string_contains(xml_item,
|
||||||
'<itunes:explicit>T' in xml_item or \
|
('<itunes:explicit>Y', '<itunes:explicit>T',
|
||||||
'<itunes:explicit>1' in xml_item:
|
'<itunes:explicit>1')):
|
||||||
podcast_properties['explicit'] = True
|
podcast_properties['explicit'] = True
|
||||||
else:
|
else:
|
||||||
podcast_properties['explicit'] = False
|
podcast_properties['explicit'] = False
|
||||||
|
|
18
posts.py
18
posts.py
|
@ -34,6 +34,7 @@ from webfinger import webfinger_handle
|
||||||
from httpsig import create_signed_header
|
from httpsig import create_signed_header
|
||||||
from siteactive import site_is_active
|
from siteactive import site_is_active
|
||||||
from languages import understood_post_language
|
from languages import understood_post_language
|
||||||
|
from utils import string_contains
|
||||||
from utils import get_post_attachments
|
from utils import get_post_attachments
|
||||||
from utils import is_premium_account
|
from utils import is_premium_account
|
||||||
from utils import contains_private_key
|
from utils import contains_private_key
|
||||||
|
@ -793,12 +794,7 @@ def _update_word_frequency(content: str, word_frequency: {}) -> None:
|
||||||
if word_len < 4:
|
if word_len < 4:
|
||||||
if word.upper() != word:
|
if word.upper() != word:
|
||||||
continue
|
continue
|
||||||
if '&' in word or \
|
if string_contains(word, ('&', '"', '@', "'", "--", '//')):
|
||||||
'"' in word or \
|
|
||||||
'@' in word or \
|
|
||||||
"'" in word or \
|
|
||||||
"--" in word or \
|
|
||||||
'//' in word:
|
|
||||||
continue
|
continue
|
||||||
if word.lower() in common_words:
|
if word.lower() in common_words:
|
||||||
continue
|
continue
|
||||||
|
@ -4447,13 +4443,9 @@ def _add_post_string_to_timeline(post_str: str, boxname: str,
|
||||||
""" is this a valid timeline post?
|
""" is this a valid timeline post?
|
||||||
"""
|
"""
|
||||||
# must be a recognized ActivityPub type
|
# must be a recognized ActivityPub type
|
||||||
if ('"Note"' in post_str or
|
if (string_contains(post_str,
|
||||||
'"EncryptedMessage"' in post_str or
|
('"Note"', '"EncryptedMessage"', '"ChatMessage"',
|
||||||
'"ChatMessage"' in post_str or
|
'"Event"', '"Article"', '"Patch"', '"Announce"')) or
|
||||||
'"Event"' in post_str or
|
|
||||||
'"Article"' in post_str or
|
|
||||||
'"Patch"' in post_str or
|
|
||||||
'"Announce"' in post_str or
|
|
||||||
('"Question"' in post_str and
|
('"Question"' in post_str and
|
||||||
('"Create"' in post_str or '"Update"' in post_str))):
|
('"Create"' in post_str or '"Update"' in post_str))):
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ from shutil import copyfile
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from session import get_json
|
from session import get_json
|
||||||
from session import get_json_valid
|
from session import get_json_valid
|
||||||
|
from utils import string_contains
|
||||||
from utils import get_post_attachments
|
from utils import get_post_attachments
|
||||||
from utils import image_mime_types_dict
|
from utils import image_mime_types_dict
|
||||||
from utils import get_url_from_post
|
from utils import get_url_from_post
|
||||||
|
@ -2338,9 +2339,7 @@ def get_buy_links(post_json_object: str, translate: {}, buy_sites: {}) -> {}:
|
||||||
if remove_html(item_name) != item_name:
|
if remove_html(item_name) != item_name:
|
||||||
continue
|
continue
|
||||||
# there should be no html in the link
|
# there should be no html in the link
|
||||||
if '<' in item['href'] or \
|
if string_contains(item['href'], ('<', '://', ' ')):
|
||||||
'://' not in item['href'] or \
|
|
||||||
' ' in item['href']:
|
|
||||||
continue
|
continue
|
||||||
if item.get('rel'):
|
if item.get('rel'):
|
||||||
if isinstance(item['rel'], str):
|
if isinstance(item['rel'], str):
|
||||||
|
|
Loading…
Reference in New Issue