Verified Commit 3f3d6d88 authored by Eliot Berriot's avatar Eliot Berriot 💬

Make music directory configurable in development

parent 1672230f
......@@ -61,7 +61,7 @@ class Command(BaseCommand):
if options['recursive']:
glob_kwargs['recursive'] = True
try:
matching = glob.glob(options['path'], **glob_kwargs)
matching = sorted(glob.glob(options['path'], **glob_kwargs))
except TypeError:
raise Exception('You need Python 3.5 to use the --recursive flag')
......@@ -110,13 +110,13 @@ class Command(BaseCommand):
if options['async']:
message = 'Successfully launched import for {} tracks'
self.stdout.write(message.format(len(matching)))
self.stdout.write(message.format(len(filtered['new'])))
if len(errors) > 0:
self.stderr.write(
'{} tracks could not be imported:'.format(len(errors)))
for path, error in errors:
self.stderr('- {}: {}'.format(path, error))
self.stderr.write('- {}: {}'.format(path, error))
self.stdout.write(
"For details, please refer to import batch #{}".format(batch.pk))
......@@ -130,8 +130,8 @@ class Command(BaseCommand):
skipped = set(matching) & existing
result = {
'initial': matching,
'skipped': list(skipped),
'new': list(set(matching) - skipped)
'skipped': list(sorted(skipped)),
'new': list(sorted(set(matching) - skipped)),
}
return result
......@@ -146,7 +146,7 @@ class Command(BaseCommand):
batch = user.imports.create(source='shell')
total = len(paths)
errors = []
for i, path in enumerate(paths):
for i, path in list(enumerate(paths)):
try:
self.stdout.write(
message.format(path=path, i=i+1, total=len(paths)))
......@@ -157,7 +157,7 @@ class Command(BaseCommand):
m = 'Error while importing {}: {} {}'.format(
path, e.__class__.__name__, e)
self.stderr.write(m)
errors.append((m, path))
errors.append((path, '{} {}'.format(e.__class__.__name__, e)))
return batch, errors
def import_file(self, path, batch, import_handler, options):
......
......@@ -2,12 +2,14 @@ import acoustid
import os
import datetime
from django.core.files import File
from django.db import transaction
from funkwhale_api.taskapp import celery
from funkwhale_api.providers.acoustid import get_acoustid_client
from funkwhale_api.music import models, metadata
@transaction.atomic
def import_track_data_from_path(path):
data = metadata.Metadata(path)
artist = models.Artist.objects.get_or_create(
......@@ -45,6 +47,7 @@ def import_track_data_from_path(path):
def import_metadata_with_musicbrainz(path):
pass
@celery.app.task(name='audiofile.from_path')
def from_path(path):
acoustid_track_id = None
......
......@@ -65,7 +65,7 @@ services:
- "CACHE_URL=redis://redis:6379/0"
volumes:
- ./api:/app
- ./data/music:/music
- "${MUSIC_DIRECTORY-./data/music}:/music"
networks:
- internal
api:
......@@ -78,7 +78,7 @@ services:
command: python /app/manage.py runserver 0.0.0.0:12081
volumes:
- ./api:/app
- ./data/music:/music
- "${MUSIC_DIRECTORY-./data/music}:/music"
environment:
- "FUNKWHALE_HOSTNAME=${FUNKWHALE_HOSTNAME-localhost}"
- "FUNKWHALE_HOSTNAME_SUFFIX=funkwhale.test"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment