#817: audiobooks, daisy collections
[wolnelektury.git] / apps / catalogue / management / commands / importbooks.py
index cead75f..ffe0de8 100644 (file)
@@ -44,7 +44,7 @@ class Command(BaseCommand):
             if not os.path.isdir(dir_name):
                 print self.style.ERROR("%s: Not a directory. Skipping." % dir_name)
             else:
-                for file_name in os.listdir(dir_name):
+                for file_name in sorted(os.listdir(dir_name)):
                     file_path = os.path.join(dir_name, file_name)
                     file_base, ext = os.path.splitext(file_path)
 
@@ -87,6 +87,10 @@ class Command(BaseCommand):
                             book.ogg_file.save('%s.ogg' % book.slug, File(file(os.path.join(dir_name, book.slug + '.ogg'))))
                             if verbose:
                                 print "Importing %s.ogg" % book.slug
+                        if os.path.isfile(os.path.join(dir_name, book.slug + '.daisy.zip')):
+                            book.ogg_file.save('%s.daisy.zip' % book.slug, File(file(os.path.join(dir_name, book.slug + '.daisy.zip'))))
+                            if verbose:
+                                print "Importing %s.daisy.zip" % book.slug
 
                         book.save()