From d46580ed9472d519317a7413990751b866cee3c7 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 23 Jan 2014 09:50:32 +0100 Subject: [PATCH] add prefix to URL item import command --- README.rst | 1 + .../commands/telemeta-import-items-from-url.py | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index e4f55421..6ebf1997 100644 --- a/README.rst +++ b/README.rst @@ -49,6 +49,7 @@ News +++++ * Dratically improve collection zip packaqe streaming thanks to zipstream (NEW deps) + * Add URL field to item so that a external sound can be indexed and streamed * Add minor migrations 1.4.5 diff --git a/telemeta/management/commands/telemeta-import-items-from-url.py b/telemeta/management/commands/telemeta-import-items-from-url.py index 8e12bd3a..d7dc15dd 100644 --- a/telemeta/management/commands/telemeta-import-items-from-url.py +++ b/telemeta/management/commands/telemeta-import-items-from-url.py @@ -9,12 +9,13 @@ import os class Command(BaseCommand): - help = "import media files from a URL directory into a collection" + help = "import media files from a URL directory into a collection with a given prefix" args = "collection_code URL" def handle(self, *args, **options): - collection_code = args[-2] - url = args[-1] + collection_code = args[0] + prefix = args[2] + url = args[3] parser = URLMediaParser(url) urls = parser.get_urls() @@ -32,8 +33,9 @@ class Command(BaseCommand): filename = url.split('/')[-1] name, ext = os.path.splitext(filename) items = MediaItem.objects.filter(code=name) - if not items: - item = MediaItem(collection=collection, code=name) + if not items and prefix in name: + code = collection.code + '_' + name + item = MediaItem(collection=collection, code=code) item.title = name item.url = url item.public_access = 'full' -- 2.39.5