diff options
| author | Yuval Adam <yuval@y3xz.com> | 2016-04-23 18:49:59 +0300 |
|---|---|---|
| committer | Yuval Adam <yuval@y3xz.com> | 2016-04-23 18:49:59 +0300 |
| commit | c07c1b8416f7656e88c1671610cbbb0de51f2918 (patch) | |
| tree | c6ac7feefe8b0f0f38f6613845426f351200feb4 /yaas.py | |
| parent | 313467142882a48405e764b3beee9ba8653e012f (diff) | |
Basic POC working
Diffstat (limited to 'yaas.py')
| -rw-r--r-- | yaas.py | 25 |
1 files changed, 22 insertions, 3 deletions
@@ -1,9 +1,28 @@ -from flask import Flask +import os +import youtube_dl + +from flask import Flask, redirect, request, render_template + app = Flask(__name__) @app.route('/') -def hello(): - return 'Hello World!' +def index(): + vids = os.listdir('static/vids') + return render_template('index.html', vids=vids) + + +@app.route('/upload', methods=['POST']) +def upload(): + url = request.form['url'] + if url: + ydl_opts = { + 'outtmpl': 'static/vids/%(id)s.%(ext)s' + } + with youtube_dl.YoutubeDL(ydl_opts) as ydl: + info_dict = ydl.extract_info(url, download=False) + ydl.download([url]) + + return redirect('/') if __name__ == '__main__': app.run() |
