From 24f4b8d32fc08623d21a567611d2dbdb5122538e Mon Sep 17 00:00:00 2001 From: till Date: Sun, 2 Aug 2020 11:53:34 +0200 Subject: [PATCH] remove now redundant backend and make gts more stable --- Backend/Dockerfile | 13 ------------- Backend/docker-compose.yml | 9 --------- Backend/requirements.txt | 2 -- Backend/server.py | 28 ---------------------------- lib/widgets/audio_visualization.dart | 14 ++++++++++++-- 5 files changed, 12 insertions(+), 54 deletions(-) delete mode 100644 Backend/Dockerfile delete mode 100644 Backend/docker-compose.yml delete mode 100644 Backend/requirements.txt delete mode 100644 Backend/server.py diff --git a/Backend/Dockerfile b/Backend/Dockerfile deleted file mode 100644 index c3cea38..0000000 --- a/Backend/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM rcarmo/ubuntu-python:onbuild - -RUN apt update && apt-get install software-properties-common --no-install-recommends -y && add-apt-repository ppa:chris-needham/ppa -y \ - && apt-get update -y \ - && apt-get install audiowaveform -y - -WORKDIR /home/src/ - -ADD server.py /home/src/server.py - -EXPOSE 3000 - -CMD ["python", "server.py"] \ No newline at end of file diff --git a/Backend/docker-compose.yml b/Backend/docker-compose.yml deleted file mode 100644 index c81fa81..0000000 --- a/Backend/docker-compose.yml +++ /dev/null @@ -1,9 +0,0 @@ -version: "2.4" - -services: - handler: - build: . - command: python server.py - working_dir: /home/src - ports: - - 3000:3000 \ No newline at end of file diff --git a/Backend/requirements.txt b/Backend/requirements.txt deleted file mode 100644 index 5eaf725..0000000 --- a/Backend/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -flask -requests \ No newline at end of file diff --git a/Backend/server.py b/Backend/server.py deleted file mode 100644 index f6c6d42..0000000 --- a/Backend/server.py +++ /dev/null @@ -1,28 +0,0 @@ -from flask import Flask, request, Response -import subprocess -import requests - -app = Flask(__name__) - - -@app.route('/') -def a(): - sp_id = request.args.get("id") - url = f"https://p.scdn.co/mp3-preview/{sp_id}" - - with requests.get(url) as g: - print(g.status_code) - pipe = subprocess.Popen( - ["audiowaveform", "--input-format", "mp3", "--output-format", - "json"], - stdout=subprocess.PIPE, stdin=subprocess.PIPE, - stderr=subprocess.STDOUT) - - stdout, error = pipe.communicate(input=g.content) - - stdout = b'{"' + stdout.split(b'{"')[1].split(B"Done")[0] - - return Response(stdout) - - -app.run("0.0.0.0", 3000) diff --git a/lib/widgets/audio_visualization.dart b/lib/widgets/audio_visualization.dart index eeaace9..4b6e4e0 100644 --- a/lib/widgets/audio_visualization.dart +++ b/lib/widgets/audio_visualization.dart @@ -12,18 +12,28 @@ class SoundData { List data; SoundData(String jsonData) { - dynamic jsonObject = json.decode(jsonData); + assert (false); + assert(jsonData != null); + assert(jsonData != "{}"); + dynamic jsonObject; + try { + jsonObject = json.decode(jsonData); + } on FormatException { + throw new Exception("Error while parsing."); + } channels = jsonObject["channels"]; sampleRate = jsonObject["sample_rate"]; samplesPerPixel = jsonObject["samples_per_pixel"]; bits = jsonObject["bits"]; length = jsonObject["length"]; List temp = jsonObject["data"]; + if (temp == null) { + print(""); + } data = List(); for (int i = 0; i < temp.length; i++) { data.add(temp[i] as int); } - print(""); } Size savedSize;