-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
44 lines (32 loc) · 1.03 KB
/
app.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from flask import Flask, render_template, request, send_from_directory
from Downloader import Downloader
from mp4tomp3 import m4tm3
app = Flask(__name__)
name = ""
@app.route("/")
def index():
return render_template('index.html')
@app.route("/downloader/")
def downloader():
return render_template('downloader.html')
@app.route("/process", methods=['POST'])
def process():
print("fetching...")
url = request.form['inputUrl']
global name
name = Downloader.getname(url)
# Downloader.getdata(url)
res = '360p'
print("downloading...")
Downloader.download(url, res)
print("converting...")
m4tm3('./files/dump/', './files/fresh/')
return "Done!"
@app.route("/downloader/processed")
def processed():
global name
print("returning file as mp3: {0}".format(name))
return send_from_directory('./files/fresh', '{0}.mp3'.format(name),
as_attachment=True, attachment_filename=name + '.mp3')
if __name__ == "__main__":
app.run(debug=True, host='0.0.0.0')