from distutils.spawn import find_executable
from subprocess import call
import logging
from flask import Flask
from flask import jsonify
app = Flask(__name__)

logging.basicConfig(format='%(asctime)s %(levelname)-8s %(message)s',
                    datefmt='%d-%m-%Y:%H:%M:%S',
                    level=logging.DEBUG)
logger = logging.getLogger('server')

playlistfromsong = find_executable("playlistfromsong")


@app.route('/download/<n>/<song>')
def download(n, song):
    cmd = "python3 -m pip install --upgrade playlistfromsong"
    call(cmd.split())
    cmd = [playlistfromsong, "-s", song, "-n", n]
    logger.info(" ".join(cmd))
    call(cmd)
    return jsonify({'success': True})


if __name__ == "__main__":
    from waitress import serve
    serve(app, listen='*:5001')

@@ -80,16 +80,53 @@
 logging%0A
+from argparse import ArgumentParser%0A%0A
 from fla
@@ -167,16 +167,44 @@
 jsonify%0A
+from waitress import serve%0A%0A
 app = Fl
@@ -471,16 +471,42 @@
 msong%22)%0A
+folder_to_save_data = %22.%22%0A
 %0A%0A@app.r
@@ -689,16 +689,43 @@
  %22-n%22, n
+, %22-f%22, folder_to_save_data
 %5D%0A    lo
@@ -838,34 +838,272 @@
     
-from waitress import serve
+parser = ArgumentParser()%0A    parser.add_argument('--folder', help='folder to save data')%0A    args = parser.parse_args()%0A    if args.folder is not None:%0A        folder_to_save_data = args.folder%0A    print(%22Starting server, saving data to %25s%22 %25 folder_to_save_data)
 %0A   

Update webhook