mirror of https://gitlab.com/bashrc2/epicyon
Move function
parent
76d1769787
commit
7380eaeede
|
@ -103,7 +103,6 @@ from utils import user_agent_domain
|
||||||
from utils import local_network_host
|
from utils import local_network_host
|
||||||
from utils import permitted_dir
|
from utils import permitted_dir
|
||||||
from utils import has_users_path
|
from utils import has_users_path
|
||||||
from utils import media_file_mime_type
|
|
||||||
from utils import replace_users_with_at
|
from utils import replace_users_with_at
|
||||||
from utils import remove_id_ending
|
from utils import remove_id_ending
|
||||||
from utils import local_actor_url
|
from utils import local_actor_url
|
||||||
|
@ -115,6 +114,7 @@ from utils import get_nickname_from_actor
|
||||||
from utils import get_json_content_from_accept
|
from utils import get_json_content_from_accept
|
||||||
from utils import check_bad_path
|
from utils import check_bad_path
|
||||||
from utils import decoded_host
|
from utils import decoded_host
|
||||||
|
from formats import media_file_mime_type
|
||||||
from mitm import detect_mitm
|
from mitm import detect_mitm
|
||||||
from person import get_person_notes_endpoint
|
from person import get_person_notes_endpoint
|
||||||
from person import get_account_pub_key
|
from person import get_account_pub_key
|
||||||
|
|
|
@ -17,8 +17,8 @@ from httpcodes import http_404
|
||||||
from daemon_utils import has_accept
|
from daemon_utils import has_accept
|
||||||
from daemon_utils import etag_exists
|
from daemon_utils import etag_exists
|
||||||
from utils import get_config_param
|
from utils import get_config_param
|
||||||
from utils import media_file_mime_type
|
|
||||||
from utils import binary_is_image
|
from utils import binary_is_image
|
||||||
|
from formats import media_file_mime_type
|
||||||
|
|
||||||
|
|
||||||
def get_favicon(self, calling_domain: str,
|
def get_favicon(self, calling_domain: str,
|
||||||
|
|
|
@ -20,8 +20,8 @@ from httpcodes import http_404
|
||||||
from httpheaders import set_headers_etag
|
from httpheaders import set_headers_etag
|
||||||
from utils import data_dir
|
from utils import data_dir
|
||||||
from utils import get_nickname_from_actor
|
from utils import get_nickname_from_actor
|
||||||
from utils import media_file_mime_type
|
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
|
from formats import media_file_mime_type
|
||||||
from formats import get_image_mime_type
|
from formats import get_image_mime_type
|
||||||
from formats import get_image_extensions
|
from formats import get_image_extensions
|
||||||
from flags import is_image_file
|
from flags import is_image_file
|
||||||
|
|
|
@ -11,7 +11,7 @@ import os
|
||||||
import datetime
|
import datetime
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
from flags import is_image_file
|
from flags import is_image_file
|
||||||
from utils import media_file_mime_type
|
from formats import media_file_mime_type
|
||||||
from utils import data_dir
|
from utils import data_dir
|
||||||
from utils import string_contains
|
from utils import string_contains
|
||||||
from utils import decoded_host
|
from utils import decoded_host
|
||||||
|
|
35
formats.py
35
formats.py
|
@ -107,3 +107,38 @@ def get_media_formats() -> str:
|
||||||
media_formats += ', '
|
media_formats += ', '
|
||||||
media_formats += '.' + ext
|
media_formats += '.' + ext
|
||||||
return media_formats
|
return media_formats
|
||||||
|
|
||||||
|
|
||||||
|
def media_file_mime_type(filename: str) -> str:
|
||||||
|
"""Given a media filename return its mime type
|
||||||
|
"""
|
||||||
|
if '.' not in filename:
|
||||||
|
return 'image/png'
|
||||||
|
extensions = {
|
||||||
|
'json': 'application/json',
|
||||||
|
'png': 'image/png',
|
||||||
|
'jpg': 'image/jpeg',
|
||||||
|
'jxl': 'image/jxl',
|
||||||
|
'jpeg': 'image/jpeg',
|
||||||
|
'gif': 'image/gif',
|
||||||
|
'svg': 'image/svg+xml',
|
||||||
|
'webp': 'image/webp',
|
||||||
|
'avif': 'image/avif',
|
||||||
|
'heic': 'image/heic',
|
||||||
|
'ico': 'image/x-icon',
|
||||||
|
'mp3': 'audio/mpeg',
|
||||||
|
'ogg': 'audio/ogg',
|
||||||
|
'audio/wav': 'wav',
|
||||||
|
'audio/x-wav': 'wav',
|
||||||
|
'audio/x-pn-wave': 'wav',
|
||||||
|
'wav': 'audio/vnd.wave',
|
||||||
|
'opus': 'audio/opus',
|
||||||
|
'spx': 'audio/speex',
|
||||||
|
'flac': 'audio/flac',
|
||||||
|
'mp4': 'video/mp4',
|
||||||
|
'ogv': 'video/ogv'
|
||||||
|
}
|
||||||
|
file_ext = filename.split('.')[-1]
|
||||||
|
if not extensions.get(file_ext):
|
||||||
|
return 'image/png'
|
||||||
|
return extensions[file_ext]
|
||||||
|
|
35
utils.py
35
utils.py
|
@ -2507,41 +2507,6 @@ def get_file_case_insensitive(path: str) -> str:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def media_file_mime_type(filename: str) -> str:
|
|
||||||
"""Given a media filename return its mime type
|
|
||||||
"""
|
|
||||||
if '.' not in filename:
|
|
||||||
return 'image/png'
|
|
||||||
extensions = {
|
|
||||||
'json': 'application/json',
|
|
||||||
'png': 'image/png',
|
|
||||||
'jpg': 'image/jpeg',
|
|
||||||
'jxl': 'image/jxl',
|
|
||||||
'jpeg': 'image/jpeg',
|
|
||||||
'gif': 'image/gif',
|
|
||||||
'svg': 'image/svg+xml',
|
|
||||||
'webp': 'image/webp',
|
|
||||||
'avif': 'image/avif',
|
|
||||||
'heic': 'image/heic',
|
|
||||||
'ico': 'image/x-icon',
|
|
||||||
'mp3': 'audio/mpeg',
|
|
||||||
'ogg': 'audio/ogg',
|
|
||||||
'audio/wav': 'wav',
|
|
||||||
'audio/x-wav': 'wav',
|
|
||||||
'audio/x-pn-wave': 'wav',
|
|
||||||
'wav': 'audio/vnd.wave',
|
|
||||||
'opus': 'audio/opus',
|
|
||||||
'spx': 'audio/speex',
|
|
||||||
'flac': 'audio/flac',
|
|
||||||
'mp4': 'video/mp4',
|
|
||||||
'ogv': 'video/ogv'
|
|
||||||
}
|
|
||||||
file_ext = filename.split('.')[-1]
|
|
||||||
if not extensions.get(file_ext):
|
|
||||||
return 'image/png'
|
|
||||||
return extensions[file_ext]
|
|
||||||
|
|
||||||
|
|
||||||
def camel_case_split(text: str) -> str:
|
def camel_case_split(text: str) -> str:
|
||||||
""" Splits CamelCase into "Camel Case"
|
""" Splits CamelCase into "Camel Case"
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -13,7 +13,7 @@ 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 flags import is_float
|
from flags import is_float
|
||||||
from utils import media_file_mime_type
|
from formats import media_file_mime_type
|
||||||
from utils import replace_strings
|
from utils import replace_strings
|
||||||
from utils import get_image_file
|
from utils import get_image_file
|
||||||
from utils import data_dir
|
from utils import data_dir
|
||||||
|
|
Loading…
Reference in New Issue