Spaces:
Build error
Build error
File size: 559 Bytes
4564216 9cb3fae 4564216 9cb3fae 4564216 9cb3fae f9037f8 4564216 f9037f8 4564216 f9037f8 4564216 f9037f8 4564216 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
from pytubefix import YouTube
from pytubefix.cli import on_progress
from flask import Flask
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
@app.route('/')
def index():
return "Hello, World!"
@app.route('/api/video/<id>')
def video_id(id):
url = f"https://www.youtube.com/watch?v={id}"
yt = YouTube(url, on_progress_callback=on_progress)
ys = yt.streams.get_highest_resolution()
return {
"title": yt.title,
"url": ys.url,
"thumbnail": yt.thumbnail_url,
"description": yt.description
} |