31 lines
1.2 KiB
Python
31 lines
1.2 KiB
Python
from flask import Flask, render_template, request
|
|
from main import get_auto_transcript, get_video_id, create_and_stream
|
|
|
|
app = Flask(__name__, static_folder="website/static", template_folder="website")
|
|
|
|
@app.route('/')
|
|
def home():
|
|
return render_template('index.html')
|
|
|
|
@app.route('/process_url', methods=['POST'])
|
|
def process_url():
|
|
url = request.form['url']
|
|
|
|
# Extract the video ID from the URL
|
|
video_id = get_video_id(url) # Modify this function to accept the URL
|
|
if not video_id:
|
|
return "Couldn't parse video ID from URL. (Are you sure you entered a valid YouTube.com or YouTu.be URL?)"
|
|
|
|
# Get the transcript for that video ID
|
|
transcript = get_auto_transcript(video_id)
|
|
if (not transcript):
|
|
return "Successfully parsed video ID from URL, however the ID was either invalid, the transcript was disabled by the video owner, or some other error was raised because of YouTube."
|
|
|
|
# Process the transcript and stream the result.
|
|
stream = create_and_stream(transcript)
|
|
|
|
# Return a response
|
|
return stream # Add more detailed output if needed
|
|
|
|
if __name__ == '__main__': # Change this line to properly check for main
|
|
app.run(debug=True) |