diff --git a/content.py b/content.py index c1b2ff418..32858c926 100644 --- a/content.py +++ b/content.py @@ -973,9 +973,16 @@ def saveMediaInFormPOST(mediaBytes, debug: bool, os.remove(possibleOtherFormat) fd = open(filename, 'wb') + if not fd: + return None, None fd.write(mediaBytes[startPos:]) fd.close() + if not os.path.isfile(filename): + print('WARN: Media file could not be written to file: ' + filename) + return None, None + print('Uploaded media file written: ' + filename) + return filename, attachmentMediaType diff --git a/daemon.py b/daemon.py index ccf9b446e..cfefb8300 100644 --- a/daemon.py +++ b/daemon.py @@ -12673,7 +12673,9 @@ class PubServer(BaseHTTPRequestHandler): postImageFilename) else: if os.path.isfile(filename): - os.rename(filename, filename.replace('.temp', '')) + newFilename = filename.replace('.temp', '') + os.rename(filename, newFilename) + filename = newFilename fields = \ extractTextFieldsInPOST(postBytes, boundary, diff --git a/epicyon-profile.css b/epicyon-profile.css index 6ef938ec7..8b2efc23a 100644 --- a/epicyon-profile.css +++ b/epicyon-profile.css @@ -184,6 +184,19 @@ body, html { image-rendering: var(--rendering); } +video { + width: 100%; +} + +figure { + padding-left: 0; + margin-left: 0; + padding-right: 0; + margin-right: 0; + margin-top: 0; + height: auto; +} + .cw { font-style: var(--cw-style); font-weight: var(--cw-weight); diff --git a/media.py b/media.py index eb0df3d43..358c98932 100644 --- a/media.py +++ b/media.py @@ -54,6 +54,11 @@ def removeMetaData(imageFilename: str, outputFilename: str) -> None: def _isMedia(imageFilename: str) -> bool: + """Is the given file a media file? + """ + if not os.path.isfile(imageFilename): + print('WARN: Media file does not exist ' + imageFilename) + return False permittedMedia = getMediaExtensions() for m in permittedMedia: if imageFilename.endswith('.' + m): diff --git a/posts.py b/posts.py index a2340eaa1..33959a7cc 100644 --- a/posts.py +++ b/posts.py @@ -3055,7 +3055,10 @@ def _addPostStringToTimeline(postStr: str, boxname: str, return False elif boxname == 'tlmedia': if '"Create"' in postStr: - if 'mediaType' not in postStr or 'image/' not in postStr: + if ('mediaType' not in postStr or + ('image/' not in postStr and + 'video/' not in postStr and + 'audio/' not in postStr)): return False # add the post to the dictionary postsInBox.append(postStr) diff --git a/webapp_media.py b/webapp_media.py index f837e9c20..576c3c9fd 100644 --- a/webapp_media.py +++ b/webapp_media.py @@ -220,8 +220,7 @@ def _addEmbeddedAudio(translate: {}, content: str) -> str: return content -def _addEmbeddedVideo(translate: {}, content: str, - width=400, height=300) -> str: +def _addEmbeddedVideo(translate: {}, content: str) -> str: """Adds embedded video for mp4/webm/ogv """ if not ('.mp4' in content or '.webm' in content or '.ogv' in content): @@ -258,14 +257,16 @@ def _addEmbeddedVideo(translate: {}, content: str, continue url = w content += \ - '