From c07c1b8416f7656e88c1671610cbbb0de51f2918 Mon Sep 17 00:00:00 2001 From: Yuval Adam Date: Sat, 23 Apr 2016 18:49:59 +0300 Subject: Basic POC working --- .gitignore | 2 ++ static/vids/.keep | 0 templates/index.html | 22 ++++++++++++++++++++++ yaas.py | 25 ++++++++++++++++++++++--- 4 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 .gitignore create mode 100644 static/vids/.keep create mode 100644 templates/index.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..00c4beb --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +static/vids/* +!static/vids/.keep diff --git a/static/vids/.keep b/static/vids/.keep new file mode 100644 index 0000000..e69de29 diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..7437fc4 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,22 @@ + + + + + + + YaaS + + +

YaaS

+

Paste a valid youtube URL

+
+ + +
+ + + diff --git a/yaas.py b/yaas.py index 7fad1a7..b98d97a 100644 --- a/yaas.py +++ b/yaas.py @@ -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() -- cgit v1.3.1