Add music from funkwhale/catalog to gitpod instance
This commit is contained in:
parent
d56fd3e11e
commit
271c74e6d2
16
.gitpod.yml
16
.gitpod.yml
|
@ -28,8 +28,22 @@ tasks:
|
||||||
docker-compose run --rm api python manage.py createsuperuser --no-input --username gitpod --email gitpod@example.com
|
docker-compose run --rm api python manage.py createsuperuser --no-input --username gitpod --email gitpod@example.com
|
||||||
docker-compose run --rm api python manage.py fw users set --password "gitpod" gitpod --no-input
|
docker-compose run --rm api python manage.py fw users set --password "gitpod" gitpod --no-input
|
||||||
|
|
||||||
# Compile frontent
|
# Compile frontend locales
|
||||||
docker-compose run --rm front yarn run i18n-compile
|
docker-compose run --rm front yarn run i18n-compile
|
||||||
|
|
||||||
|
# Login with cURL to create actors
|
||||||
|
docker-compose up -d nginx
|
||||||
|
gp ports await 8000
|
||||||
|
python .gitpod/init_actor.py
|
||||||
|
|
||||||
|
# Import music
|
||||||
|
git clone https://dev.funkwhale.audio/funkwhale/catalog.git
|
||||||
|
sudo mv catalog/music data
|
||||||
|
sudo chown -R root:root data/music
|
||||||
|
rm -rf catalog
|
||||||
|
LIBRARY_ID=`cat .gitpod/create_library.py | docker-compose run --rm -T api python manage.py shell -i python`
|
||||||
|
docker-compose run --rm api python manage.py import_files $LIBRARY_ID "/music/" --recursive --noinput --in-place
|
||||||
|
docker-compose stop
|
||||||
command: |
|
command: |
|
||||||
docker-compose up -d nginx
|
docker-compose up -d nginx
|
||||||
docker-compose up front api
|
docker-compose up front api
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
from funkwhale_api.music.models import Library
|
||||||
|
from django.contrib.auth import get_user_model
|
||||||
|
|
||||||
|
actor = get_user_model().objects.get(username='gitpod').actor
|
||||||
|
|
||||||
|
try:
|
||||||
|
library = Library.objects.get(actor=actor)
|
||||||
|
except:
|
||||||
|
# Create library
|
||||||
|
library = Library()
|
||||||
|
library.actor = actor
|
||||||
|
library.description = 'Libre music to build a starter catalog for your instance'
|
||||||
|
library.name = 'funkwhale/catalog'
|
||||||
|
library.privacy_level = 'everyone'
|
||||||
|
library.save()
|
||||||
|
|
||||||
|
print(str(library.uuid))
|
|
@ -0,0 +1,20 @@
|
||||||
|
import subprocess
|
||||||
|
import requests
|
||||||
|
|
||||||
|
INSTANCE_URL = subprocess.check_output(['gp', 'url', '8000']).decode()[:-1]
|
||||||
|
|
||||||
|
# Login to initialize user actor
|
||||||
|
req = requests.Session()
|
||||||
|
|
||||||
|
res = req.get(INSTANCE_URL + '/login')
|
||||||
|
token = res.cookies['csrftoken']
|
||||||
|
|
||||||
|
req.post(INSTANCE_URL + '/api/v1/users/login', data={
|
||||||
|
'username': 'gitpod',
|
||||||
|
'password': 'gitpod'
|
||||||
|
}, headers={
|
||||||
|
'Referer': INSTANCE_URL + '/login',
|
||||||
|
'X-CSRFTOKEN': token
|
||||||
|
})
|
||||||
|
|
||||||
|
req.get(INSTANCE_URL)
|
Loading…
Reference in New Issue