Make music directory configurable in development
This commit is contained in:
parent
1672230f39
commit
3f3d6d88d6
|
@ -61,7 +61,7 @@ class Command(BaseCommand):
|
||||||
if options['recursive']:
|
if options['recursive']:
|
||||||
glob_kwargs['recursive'] = True
|
glob_kwargs['recursive'] = True
|
||||||
try:
|
try:
|
||||||
matching = glob.glob(options['path'], **glob_kwargs)
|
matching = sorted(glob.glob(options['path'], **glob_kwargs))
|
||||||
except TypeError:
|
except TypeError:
|
||||||
raise Exception('You need Python 3.5 to use the --recursive flag')
|
raise Exception('You need Python 3.5 to use the --recursive flag')
|
||||||
|
|
||||||
|
@ -110,13 +110,13 @@ class Command(BaseCommand):
|
||||||
if options['async']:
|
if options['async']:
|
||||||
message = 'Successfully launched import for {} tracks'
|
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:
|
if len(errors) > 0:
|
||||||
self.stderr.write(
|
self.stderr.write(
|
||||||
'{} tracks could not be imported:'.format(len(errors)))
|
'{} tracks could not be imported:'.format(len(errors)))
|
||||||
|
|
||||||
for path, error in errors:
|
for path, error in errors:
|
||||||
self.stderr('- {}: {}'.format(path, error))
|
self.stderr.write('- {}: {}'.format(path, error))
|
||||||
self.stdout.write(
|
self.stdout.write(
|
||||||
"For details, please refer to import batch #{}".format(batch.pk))
|
"For details, please refer to import batch #{}".format(batch.pk))
|
||||||
|
|
||||||
|
@ -130,8 +130,8 @@ class Command(BaseCommand):
|
||||||
skipped = set(matching) & existing
|
skipped = set(matching) & existing
|
||||||
result = {
|
result = {
|
||||||
'initial': matching,
|
'initial': matching,
|
||||||
'skipped': list(skipped),
|
'skipped': list(sorted(skipped)),
|
||||||
'new': list(set(matching) - skipped)
|
'new': list(sorted(set(matching) - skipped)),
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ class Command(BaseCommand):
|
||||||
batch = user.imports.create(source='shell')
|
batch = user.imports.create(source='shell')
|
||||||
total = len(paths)
|
total = len(paths)
|
||||||
errors = []
|
errors = []
|
||||||
for i, path in enumerate(paths):
|
for i, path in list(enumerate(paths)):
|
||||||
try:
|
try:
|
||||||
self.stdout.write(
|
self.stdout.write(
|
||||||
message.format(path=path, i=i+1, total=len(paths)))
|
message.format(path=path, i=i+1, total=len(paths)))
|
||||||
|
@ -157,7 +157,7 @@ class Command(BaseCommand):
|
||||||
m = 'Error while importing {}: {} {}'.format(
|
m = 'Error while importing {}: {} {}'.format(
|
||||||
path, e.__class__.__name__, e)
|
path, e.__class__.__name__, e)
|
||||||
self.stderr.write(m)
|
self.stderr.write(m)
|
||||||
errors.append((m, path))
|
errors.append((path, '{} {}'.format(e.__class__.__name__, e)))
|
||||||
return batch, errors
|
return batch, errors
|
||||||
|
|
||||||
def import_file(self, path, batch, import_handler, options):
|
def import_file(self, path, batch, import_handler, options):
|
||||||
|
|
|
@ -2,12 +2,14 @@ import acoustid
|
||||||
import os
|
import os
|
||||||
import datetime
|
import datetime
|
||||||
from django.core.files import File
|
from django.core.files import File
|
||||||
|
from django.db import transaction
|
||||||
|
|
||||||
from funkwhale_api.taskapp import celery
|
from funkwhale_api.taskapp import celery
|
||||||
from funkwhale_api.providers.acoustid import get_acoustid_client
|
from funkwhale_api.providers.acoustid import get_acoustid_client
|
||||||
from funkwhale_api.music import models, metadata
|
from funkwhale_api.music import models, metadata
|
||||||
|
|
||||||
|
|
||||||
|
@transaction.atomic
|
||||||
def import_track_data_from_path(path):
|
def import_track_data_from_path(path):
|
||||||
data = metadata.Metadata(path)
|
data = metadata.Metadata(path)
|
||||||
artist = models.Artist.objects.get_or_create(
|
artist = models.Artist.objects.get_or_create(
|
||||||
|
@ -45,6 +47,7 @@ def import_track_data_from_path(path):
|
||||||
def import_metadata_with_musicbrainz(path):
|
def import_metadata_with_musicbrainz(path):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@celery.app.task(name='audiofile.from_path')
|
@celery.app.task(name='audiofile.from_path')
|
||||||
def from_path(path):
|
def from_path(path):
|
||||||
acoustid_track_id = None
|
acoustid_track_id = None
|
||||||
|
|
4
dev.yml
4
dev.yml
|
@ -65,7 +65,7 @@ services:
|
||||||
- "CACHE_URL=redis://redis:6379/0"
|
- "CACHE_URL=redis://redis:6379/0"
|
||||||
volumes:
|
volumes:
|
||||||
- ./api:/app
|
- ./api:/app
|
||||||
- ./data/music:/music
|
- "${MUSIC_DIRECTORY-./data/music}:/music"
|
||||||
networks:
|
networks:
|
||||||
- internal
|
- internal
|
||||||
api:
|
api:
|
||||||
|
@ -78,7 +78,7 @@ services:
|
||||||
command: python /app/manage.py runserver 0.0.0.0:12081
|
command: python /app/manage.py runserver 0.0.0.0:12081
|
||||||
volumes:
|
volumes:
|
||||||
- ./api:/app
|
- ./api:/app
|
||||||
- ./data/music:/music
|
- "${MUSIC_DIRECTORY-./data/music}:/music"
|
||||||
environment:
|
environment:
|
||||||
- "FUNKWHALE_HOSTNAME=${FUNKWHALE_HOSTNAME-localhost}"
|
- "FUNKWHALE_HOSTNAME=${FUNKWHALE_HOSTNAME-localhost}"
|
||||||
- "FUNKWHALE_HOSTNAME_SUFFIX=funkwhale.test"
|
- "FUNKWHALE_HOSTNAME_SUFFIX=funkwhale.test"
|
||||||
|
|
Loading…
Reference in New Issue