YT Audio Encoding

This commit is contained in:
2026-01-07 04:34:24 +00:00
parent abceb1be7b
commit d548bd6fde
6 changed files with 299 additions and 5 deletions

View File

@@ -102,16 +102,21 @@ def generate_art():
@app.route('/api/hide', methods=['POST'])
def hide_data():
if 'data' not in request.files or 'host' not in request.files:
return jsonify({"error": "Requires 'data' and 'host' files"}), 400
return jsonify({"error": "Missing files"}), 400
data_file = request.files['data']
host_file = request.files['host']
data_path = None
host_path = None
try:
data_path = save_upload(request.files['data'])
host_path = save_upload(request.files['host'])
data_path = save_upload(data_file)
host_path = save_upload(host_file)
output_path = processor.encode_stego(data_path, host_path)
return send_file(output_path, mimetype='image/png')
stego_path = processor.encode_stego(data_path, host_path)
return send_file(stego_path, mimetype='image/png')
except ValueError as e:
return jsonify({"error": str(e)}), 400
except Exception as e:
@@ -124,6 +129,41 @@ def hide_data():
try: os.remove(host_path)
except: pass
import youtube_utils
@app.route('/api/hide-yt', methods=['POST'])
def hide_yt_data():
if 'url' not in request.form or 'host' not in request.files:
return jsonify({"error": "Missing URL or Host Image"}), 400
youtube_url = request.form['url']
host_file = request.files['host']
audio_path = None
host_path = None
try:
# Download Audio
audio_path = youtube_utils.download_audio(youtube_url, app.config['UPLOAD_FOLDER'])
# Save Host
host_path = save_upload(host_file)
# Encode
output_path = processor.encode_stego(audio_path, host_path)
return send_file(output_path, mimetype='image/png')
except Exception as e:
return jsonify({"error": str(e)}), 500
finally:
# Cleanup
if audio_path and os.path.exists(audio_path):
try: os.remove(audio_path)
except: pass
if host_path and os.path.exists(host_path):
try: os.remove(host_path)
except: pass
@app.route('/api/decode', methods=['POST'])
def decode():
if 'image' not in request.files: