From 2354721cd91f7ea8a6f7dd4fd335444c631e0ece Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Sun, 4 Mar 2018 18:14:37 +0100 Subject: [PATCH 1/2] Fixed import crashing when no acoustid found --- api/funkwhale_api/music/tasks.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/api/funkwhale_api/music/tasks.py b/api/funkwhale_api/music/tasks.py index cb4a737c9..9aac55515 100644 --- a/api/funkwhale_api/music/tasks.py +++ b/api/funkwhale_api/music/tasks.py @@ -33,11 +33,10 @@ def _do_import(import_job, replace): # we try to deduce mbid from acoustid client = get_acoustid_client() match = client.get_best_match(import_job.audio_file.path) - if not match: - raise ValueError('Cannot get match') - duration = match['recordings'][0]['duration'] - mbid = match['recordings'][0]['id'] - acoustid_track_id = match['id'] + if match: + duration = match['recordings'][0]['duration'] + mbid = match['recordings'][0]['id'] + acoustid_track_id = match['id'] if mbid: track, _ = models.Track.get_or_create_from_api(mbid=mbid) else: From d1d06ce760662f6c3221dab53a2a2cc7ee2b3fbb Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Sun, 4 Mar 2018 18:15:30 +0100 Subject: [PATCH 2/2] Bash script to setup / reload the demo, fix #29 --- api/demo/load-demo-data.sh | 4 ++-- demo/setup.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 demo/setup.sh diff --git a/api/demo/load-demo-data.sh b/api/demo/load-demo-data.sh index c09c5075e..fab0de8b3 100755 --- a/api/demo/load-demo-data.sh +++ b/api/demo/load-demo-data.sh @@ -6,8 +6,8 @@ python manage.py migrate --noinput echo "Creating demo user..." -cat demo/demo-user.py | python manage.py shell --plain +cat demo/demo-user.py | python manage.py shell -i python echo "Importing demo tracks..." -python manage.py import_files "/music/**/*.ogg" --recursive --noinput +python manage.py import_files "/music/**/*.ogg" --recursive --noinput --username demo diff --git a/demo/setup.sh b/demo/setup.sh new file mode 100644 index 000000000..599ca33ba --- /dev/null +++ b/demo/setup.sh @@ -0,0 +1,29 @@ +#!/bin/bash -eux +version="develop" +music_path="/usr/share/music" +demo_path="/srv/funkwhale-demo/demo" + +echo 'Cleaning everything...' +docker-compose down -v || echo 'Nothing to stop' +rm -rf /srv/funkwhale-demo/demo* +mkdir -p $demo_path +cd $demo_path +echo 'Downloading demo files...' +curl -L -o docker-compose.yml "https://code.eliotberriot.com/funkwhale/funkwhale/raw/$version/deploy/docker-compose.yml" +curl -L -o .env "https://code.eliotberriot.com/funkwhale/funkwhale/raw/$version/deploy/env.prod.sample" + +mkdir data/ +cp -r $music_path data/music + +curl -L -o front.zip "https://code.eliotberriot.com/funkwhale/funkwhale/-/jobs/artifacts/$version/download?job=build_front" +unzip front.zip + +echo "FUNKWHALE_URL=https://demo.funkwhale.audio/" >> .env +echo "DJANGO_SECRET_KEY=demo" >> .env +echo "DJANGO_ALLOWED_HOSTS=demo.funkwhale.audio" >> .env +echo "FUNKWHALE_VERSION=$version" >> .env +echo "FUNKWHALE_API_PORT=5001" >> .env + +docker-compose pull +docker-compose run --rm api "sleep 5; demo/load-demo-data.sh" +docker-compose up -d