From 82f6f7c2d248c8db5432e327d37448d47b4ec63d Mon Sep 17 00:00:00 2001 From: deltaaa00 Date: Fri, 13 Nov 2026 22:05:53 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Modernize=20Map=20&=20Video=20Studio=20UI?= =?UTF-8?q?=20and=20add=201-30s=20audio=20cut=20duration=20/=20=D0=9E?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=BE=20=D1=96=D0=BD=D1=82?= =?UTF-8?q?=D0=B5=D1=80=D1=84=D0=B5=D0=B9=D1=81=20Map=20&=20Video=20Studio?= =?UTF-8?q?=20=D1=82=D0=B0=20=D0=B4=D0=BE=D0=B4=D0=B0=D0=BD=D0=BE=20=D0=B2?= =?UTF-8?q?=D0=B8=D0=B1=D1=96=D1=80=20=D1=82=D1=80=D0=B8=D0=B2=D0=B0=D0=BB?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=96=20=D0=BD=D0=B0=D1=80=D1=96=D0=B7=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=B0=D1=83=D0=B4=D1=96=D0=BE=201-30=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 46 +- templates/index.html | 1305 ++++++++++++++++++++++++++++++++++-------- templates/video.html | 1072 +++++++++++++++++++++++++++------- yt-dlp_serv.py | 61 +- 4 files changed, 1991 insertions(+), 493 deletions(-) diff --git a/main.py b/main.py index 4ead169..d8e13b2 100644 --- a/main.py +++ b/main.py @@ -221,20 +221,11 @@ def music_download(): @app.route('/api/music_cut', methods=['POST']) @app.route('/api/music_cut/', methods=['POST']) -def cut_audio(): +def cut_audio() -> tuple[object, int]: """Cut a previously downloaded track via the downstream render service. Request JSON: - { "start_time": "00:01:30", "title": "" } - - Response JSON (passthrough from the downstream service): - { "status": "success", "file": "", "title": "" } - { "status": "error", "error": "" } - """ - """Cut a previously downloaded track via the downstream render service. - - Request JSON: - { "start_time": "00:01:30", "title": "" } + { "start_time": "00:01:30", "title": "", "duration": 8 } Response JSON (passthrough from the downstream service): { "status": "success", "file": "", "title": "" } @@ -242,17 +233,28 @@ def cut_audio(): """ import requests - data = request.get_json(silent=True) or {} - start_time = (data.get('start_time') or '').strip() - title = (data.get('title') or '').strip() + data: dict[str, object] = request.get_json(silent=True) or {} + start_time = str(data.get('start_time') or '').strip() + title = str(data.get('title') or '').strip() if not title: return jsonify({"status": "error", "error": "Missing 'title' in request body."}), 400 + raw_duration = data.get('duration', 8) + try: + duration = int(raw_duration) if raw_duration is not None else 8 + except (TypeError, ValueError): + duration = 8 + duration = max(1, min(30, duration)) + # Another service downloads music from YouTube and converts it to mp3. try: response = requests.post( "http://yt-dlp-worker:8080/api/music_cut/", - json={"start_time": start_time, "title": title}, + json={ + "start_time": start_time, + "title": title, + "duration": duration, + }, timeout=40, ) @@ -269,9 +271,10 @@ def cut_audio(): # Pass the downstream payload/status straight through. return jsonify(payload), response.status_code + @app.route('/api/render_video', methods=['POST']) @app.route('/api/render_video/', methods=['POST']) -def make_video(): +def make_video() -> tuple[object, int]: """Render a video via the downstream render service. Request JSON: @@ -279,7 +282,8 @@ def make_video(): "map_file": "", "background_video": "", "video_title": "", - "codec": "libx264" + "codec": "libx264", + "duration": 8 } Response JSON (passthrough from the downstream service): @@ -288,14 +292,15 @@ def make_video(): """ import requests - data = request.get_json(silent=True) or {} + data: dict[str, object] = request.get_json(silent=True) or {} # The frontend sends base64 strings; keep them as-is (default to empty string). map_b64 = data.get('map_file') or '' background_b64 = data.get('background_video') or '' # Frontend field is "video_title"; accept legacy "title" as a fallback. - title = (data.get('video_title') or data.get('title') or '').strip() - codec = (data.get('codec') or 'libx264').strip() + title = str(data.get('video_title') or data.get('title') or '').strip() + codec = str(data.get('codec') or 'libx264').strip() + duration = data.get('duration') try: response = requests.post( @@ -305,6 +310,7 @@ def make_video(): "background_video": background_b64, "video_title": title, "codec": codec, + "duration": duration, }, # Video rendering (moviepy/ffmpeg) can take a while - allow more time. timeout=300, diff --git a/templates/index.html b/templates/index.html index ae65eed..36584fa 100644 --- a/templates/index.html +++ b/templates/index.html @@ -3,13 +3,13 @@ <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <title>AutoMap-CLI + AutoMap Studio — AI Cartographic Engine & CLI Dashboard - - + + - - + +