forked from vitiko98/qobuz-dl
-
Notifications
You must be signed in to change notification settings - Fork 2
/
qbdl_gui.py
47 lines (38 loc) · 1.53 KB
/
qbdl_gui.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
45
46
47
from flask import Flask, render_template, request, session, jsonify
import logging
from qobuz_dl import QobuzDL
logging.basicConfig(level=logging.INFO)
app = Flask(__name__)
app.secret_key = 'YOUR_SECRET_KEY'
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
email = request.form['email']
password = request.form['password']
url = request.form['url']
download_location = request.form['download_location']
quality = int(request.form['quality'])
remember = request.form.get('rememberMe')
try:
qobuz = QobuzDL(
directory=download_location,
quality=quality
)
qobuz.get_tokens()
qobuz.initialize_client(email, password, qobuz.app_id, qobuz.secrets)
qobuz.handle_url(url)
except Exception as e:
logging.error("An error occurred: " + str(e))
return jsonify(status='error', message=str(e)), 500
if remember == 'on':
session['email'] = email
session['password'] = password
session['download_location'] = download_location
session['quality'] = quality
return jsonify(status='completed')
email = session.get('email', '')
download_location = session.get('download_location', '')
quality = session.get('quality', 7)
return render_template('index.html', email=email, download_location=download_location, quality=quality)
if __name__ == '__main__':
app.run(host='0.0.0.0')