Compare commits
3 Commits
292a464f11
...
2e56e8b6ee
Author | SHA1 | Date |
---|---|---|
Matthias Portzel | 2e56e8b6ee | |
Matthias Portzel | 93d7966db5 | |
Matthias Portzel | 58dc4d62b0 |
|
@ -29,7 +29,7 @@ def index(request):
|
||||||
|
|
||||||
@app.route("/about", strict_trailing_slash=False)
|
@app.route("/about", strict_trailing_slash=False)
|
||||||
def about(request):
|
def about(request):
|
||||||
return Response(Status.SUCCESS, "text/gemini", render_to_string("whispermaphone/about.gmi"))
|
return Response(Status.SUCCESS, "text/gemini", render_to_string("thoughts/about.gmi"))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -55,7 +55,9 @@ ALLOWED_MEDIA_TYPES = {
|
||||||
"image/png": "png",
|
"image/png": "png",
|
||||||
"image/jpeg": "jpeg",
|
"image/jpeg": "jpeg",
|
||||||
"audio/x-m4a": "m4a",
|
"audio/x-m4a": "m4a",
|
||||||
"audio/mp3": "mp3",
|
"audio/mpegaudio/mpeg": "mp3",
|
||||||
|
"audio/mpeg": "mp3",
|
||||||
|
"audio/x-hx-aac-adts": "aac",
|
||||||
"video/mp4": "mp4",
|
"video/mp4": "mp4",
|
||||||
"video/quicktime": "mov",
|
"video/quicktime": "mov",
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ def post(request):
|
||||||
|
|
||||||
thought.media.name = f"{thought.uuid}.{ALLOWED_MEDIA_TYPES[media_type]}"
|
thought.media.name = f"{thought.uuid}.{ALLOWED_MEDIA_TYPES[media_type]}"
|
||||||
|
|
||||||
if media_type == "audio/x-m4a":
|
if media_type == "audio/x-m4a" or media_type == "audio/x-hx-aac-adts":
|
||||||
# This is a hack-fix because I want to be able to upload audio
|
# This is a hack-fix because I want to be able to upload audio
|
||||||
# In the future, this should be refactored to convert file types
|
# In the future, this should be refactored to convert file types
|
||||||
# using ffmpeg.js on the client side (so there are 0 security concerns)
|
# using ffmpeg.js on the client side (so there are 0 security concerns)
|
||||||
|
@ -142,11 +142,11 @@ def post(request):
|
||||||
thought.save() # Save so that we have a file to work with
|
thought.save() # Save so that we have a file to work with
|
||||||
subprocess.run(["ffmpeg",
|
subprocess.run(["ffmpeg",
|
||||||
"-i", thought.media.path,
|
"-i", thought.media.path,
|
||||||
"-codec:a", "aac", "-vn",
|
"-codec:a", "mp3", "-vn",
|
||||||
os.path.join(settings.MEDIA_ROOT, f"{thought.uuid}.aac")
|
os.path.join(settings.MEDIA_ROOT, f"{thought.uuid}.mp3")
|
||||||
], check=True)
|
], check=True)
|
||||||
os.remove(os.path.join(settings.MEDIA_ROOT, f"{thought.uuid}.m4a")) # Remove the original file
|
os.remove(os.path.join(settings.MEDIA_ROOT, thought.media.name)) # Remove the original file
|
||||||
thought.media.name = f"{thought.uuid}.aac" # Update the file in the DB
|
thought.media.name = f"{thought.uuid}.mp3" # Update the file in the DB
|
||||||
|
|
||||||
# We need to make sure that if we remove an image, the alt text is removed with it
|
# We need to make sure that if we remove an image, the alt text is removed with it
|
||||||
if not thought.media:
|
if not thought.media:
|
||||||
|
|
Loading…
Reference in New Issue