]> git.parisson.com Git - telemeta.git/commitdiff
add prefix to URL item import command
authorGuillaume Pellerin <yomguy@parisson.com>
Thu, 23 Jan 2014 08:50:32 +0000 (09:50 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Thu, 23 Jan 2014 08:50:32 +0000 (09:50 +0100)
README.rst
telemeta/management/commands/telemeta-import-items-from-url.py

index e4f55421a0f208a466ef841d018632c6bd153346..6ebf1997f5f8e101fbb7402ec5505e9ff9398a9e 100644 (file)
@@ -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
index 8e12bd3aabe76fe0b545ee70800f9292c825b78c..d7dc15dd072b214e7d4be56ebfd6a9251c253380 100644 (file)
@@ -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'