minor videos fix

This commit is contained in:
aneuhmanh 2025-02-23 19:51:29 +02:00
parent 1fa50281da
commit 4f2a867df7
2 changed files with 7 additions and 8 deletions

11
app.py
View File

@ -12,7 +12,7 @@ from sqlalchemy.exc import IntegrityError
from werkzeug.exceptions import BadRequest
from werkzeug.security import generate_password_hash, check_password_hash
from werkzeug.utils import secure_filename
from flask import Flask, render_template, redirect, url_for, request, flash, session, jsonify
from flask import Flask, abort, render_template, redirect, url_for, request, flash, session, jsonify
from flask_sqlalchemy import SQLAlchemy
from flask_bcrypt import Bcrypt
from flask_login import LoginManager, UserMixin, login_user, login_required, logout_user, current_user
@ -636,16 +636,15 @@ async def upload_video():
description = form.description.data
if video_file and video_thumbnail:
if not allowed_file(video_file.filename, app.config['ALLOWED_VIDEO_EXTENSIONS']):
return redirect(url_for('upload_video'))
if not check_file_size(video_file, app.config['MAX_VIDEO_SIZE']):
if not await check_file_size(video_file, app.config['MAX_VIDEO_SIZE']):
return redirect(url_for('upload_video'))
if not allowed_file(video_thumbnail.filename, app.config['ALLOWED_IMAGE_EXTENSIONS']):
return redirect(url_for('upload_video'))
video_filename = generate_unique_filename(video_file.filename, app.config['UPLOAD_FOLDER']['videos'])
thumbnail_filename = generate_unique_filename(video_thumbnail.filename, app.config['UPLOAD_FOLDER']['thumbnails'])
video_filename = await generate_unique_filename(video_file.filename, app.config['UPLOAD_FOLDER']['videos'])
thumbnail_filename = await generate_unique_filename(video_thumbnail.filename, app.config['UPLOAD_FOLDER']['thumbnails'])
video_path = os.path.join(app.config['UPLOAD_FOLDER']['videos'], video_filename)
thumbnail_path = os.path.join(app.config['UPLOAD_FOLDER']['thumbnails'], thumbnail_filename)
@ -1571,4 +1570,4 @@ def buy_item(item_id):
if __name__ == '__main__':
with app.app_context():
db.create_all()
app.run(debug=False)
app.run(debug=True)

View File

@ -22,7 +22,7 @@
<label for="video_thumbnail">Обложка видео</label>
{{ form.video_thumbnail(class="file-input") }}
{% if video.video_thumbnail_file %}
<img src="{{ url_for('static', filename='thumbnails/' + video.video_thumbnail_file) }}" alt="Thumbnail preview" style="display: flex;aligin: center;">
<img src="{{ url_for('static', filename='thumbnails/' + video.video_thumbnail_file) }}" alt="Thumbnail preview" style="display: flex;margin: 0 auto;">
{% endif %}
</div>
@ -42,4 +42,4 @@
<a href="{{ url_for('view', content_type='video', id=video.id) }}" class="button">Cancel</a>
</div>
</body>
</html>
</html>