forked from abhint/youtube-downloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
24 lines (19 loc) · 819 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import re
import os
from flask import Flask, render_template, request
from utils import REGEX, get_youtube_extract
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def _index():
if 'POST' in request.method:
youtube_url = request.form.get('youtube_url')
if re.match(REGEX, youtube_url):
user_dict = get_youtube_extract(youtube_url)
audio = user_dict['audio_formats']
return render_template('result.html',
audio_dict=audio,
thumbnail=user_dict['thumbnail'],
video_dict=user_dict['video_formats'],
video_title=user_dict['title'],
)
return render_template('home.html')