mirror of
https://github.com/ParisNeo/lollms.git
synced 2025-02-01 00:45:29 +00:00
added mimetypes extraction
This commit is contained in:
parent
0a008b8529
commit
a626d99b8b
@ -36,6 +36,27 @@ import os
|
||||
import sys
|
||||
import git
|
||||
|
||||
import mimetypes
|
||||
|
||||
def get_media_type(file_path):
|
||||
"""
|
||||
Determines the media type of a file based on its file extension.
|
||||
|
||||
Args:
|
||||
file_path (str): The path to the media file.
|
||||
|
||||
Returns:
|
||||
str: The media type of the file in the format "type/subtype".
|
||||
Returns "Unknown" if the media type cannot be determined.
|
||||
"""
|
||||
media_type, _ = mimetypes.guess_type(file_path)
|
||||
|
||||
if media_type is None:
|
||||
return "Unknown"
|
||||
else:
|
||||
return media_type
|
||||
|
||||
|
||||
def discussion_path_2_url(path:str|Path):
|
||||
path = str(path)
|
||||
return path[path.index('discussion_databases'):].replace('discussion_databases','discussions')
|
||||
|
Loading…
x
Reference in New Issue
Block a user