diff --git a/app.py b/app.py index 2552df2..9c178f0 100644 --- a/app.py +++ b/app.py @@ -55,6 +55,10 @@ def loadDownloadQueue(dz, interface=None): remove(path.join(getConfigFolder(), 'queue.json')) restoreQueue(qd['queue'], qd['queueComplete'], qd['queueList'], dz, interface) +def getDownloadFolder(): + global settings + return settings['downloadLocation'] + def get_charts(dz): global chartsList if len(chartsList) == 0: diff --git a/server.py b/server.py index 1778d82..af5f3e2 100644 --- a/server.py +++ b/server.py @@ -1,6 +1,7 @@ #!/usr/env/bin python3 import logging import sys +import subprocess from os import path from flask import Flask, render_template, request, session @@ -244,6 +245,16 @@ def update_userArtists(): def update_userTracks(): emit('updated_userTracks', app.updateUserTracks(session['dz'])) +@socketio.on('openDownloadsFolder') +def openDownloadsFolder(): + folder = app.getDownloadFolder() + if sys.platform == 'darwin': + subprocess.check_call(['open', folder]) + elif sys.platform == 'linux': + subprocess.check_call(['xdg-open', folder]) + elif sys.platform == 'win32': + subprocess.check_call(['explorer', folder]) + def run_server(port): print("Starting server at http://127.0.0.1:" + str(port)) socketio.run(server, host='0.0.0.0', port=port)