updated player deploy and config

This commit is contained in:
ske087
2026-07-01 19:21:59 +03:00
parent 4f4e017ad2
commit 2c91a5666e
3 changed files with 183 additions and 5 deletions
+80
View File
@@ -267,6 +267,86 @@ def add_content_to_playlist(playlist_id: int):
return redirect(url_for('content.manage_playlist_content', playlist_id=playlist_id))
@content_bp.route('/add-weblink', methods=['POST'])
@login_required
def add_weblink():
"""Create a web link content item from the Upload Media page.
Optionally adds it directly to a playlist if playlist_id is supplied.
Returns JSON when the request carries Accept: application/json, otherwise
redirects back to the upload page.
"""
use_json = 'application/json' in request.accept_mimetypes.best or \
request.headers.get('X-Requested-With') == 'XMLHttpRequest'
try:
web_url = (request.form.get('url') or '').strip()
duration = request.form.get('duration', type=int, default=30)
description = (request.form.get('description') or '').strip() or None
playlist_id = request.form.get('playlist_id', type=int)
parsed = urlparse(web_url)
if parsed.scheme.lower() not in ('http', 'https') or not parsed.netloc:
if use_json:
return jsonify({'success': False, 'error': 'Please enter a valid http:// or https:// web address.'}), 400
flash('Please enter a valid http:// or https:// web address.', 'warning')
return redirect(url_for('content.upload_media_page'))
if not duration or duration < 1:
duration = 30
content = Content(
filename=f'weblink-{uuid.uuid4().hex[:12]}',
content_type='weblink',
url=web_url,
duration=duration,
description=description or web_url,
uploaded_at=datetime.utcnow(),
)
db.session.add(content)
db.session.flush()
if playlist_id:
playlist = Playlist.query.get(playlist_id)
if playlist:
from sqlalchemy import select, func
max_pos = db.session.execute(
select(func.max(playlist_content.c.position)).where(
playlist_content.c.playlist_id == playlist_id
)
).scalar() or 0
db.session.execute(
playlist_content.insert().values(
playlist_id=playlist_id,
content_id=content.id,
position=max_pos + 1,
duration=duration,
)
)
playlist.increment_version()
log_action('info', f'Web link "{web_url}" added to playlist "{playlist.name}"')
else:
log_action('warning', f'Web link "{web_url}" created; playlist {playlist_id} not found')
else:
log_action('info', f'Web link "{web_url}" added to media library')
db.session.commit()
cache.clear()
if use_json:
return jsonify({'success': True, 'content_id': content.id, 'message': 'Web link added successfully.'})
flash('Web link added successfully.', 'success')
except Exception as e:
db.session.rollback()
log_action('error', f'Error adding web link: {str(e)}')
if use_json:
return jsonify({'success': False, 'error': 'Failed to add web link.'}), 500
flash('Error adding web link.', 'danger')
return redirect(url_for('content.upload_media_page'))
@content_bp.route('/playlist/<int:playlist_id>/add-weblink', methods=['POST'])
@login_required
def add_weblink_to_playlist(playlist_id: int):