new fields: part name, index, parts count
[audio.git] / apps / archive / tasks.py
index 1b2be74..a46b79c 100644 (file)
@@ -46,8 +46,11 @@ class AudioFormatTask(Task):
 
     @classmethod
     def set_tags(cls, audiobook, file_name):
 
     @classmethod
     def set_tags(cls, audiobook, file_name):
+        tags = getattr(audiobook, "%s_tags" % cls.ext)['tags']
+        if not tags.get('flac_sha1'):
+            tags['flac_sha1'] = audiobook.get_source_sha1()
         audio = File(file_name)
         audio = File(file_name)
-        for k, v in getattr(audiobook, "%s_tags" % cls.ext)['tags'].items():
+        for k, v in tags.items():
             audio[k] = v
         audio.save()
 
             audio[k] = v
         audio.save()
 
@@ -78,10 +81,13 @@ class AudioFormatTask(Task):
         tags = getattr(audiobook, "%s_tags" % cls.ext)
         prefix, slug = tags['url'].rstrip('/').rsplit('/', 1)
         name = tags['name']
         tags = getattr(audiobook, "%s_tags" % cls.ext)
         prefix, slug = tags['url'].rstrip('/').rsplit('/', 1)
         name = tags['name']
-        command = UPLOAD_CMD + (u' %s %s %s > output.txt' % (
+        command = UPLOAD_CMD + (u' %s %s %s %s %s %s > output.txt' % (
             pipes.quote(os.path.join(UPLOAD_PATH, os.path.basename(path))),
             pipes.quote(slug),
             pipes.quote(os.path.join(UPLOAD_PATH, os.path.basename(path))),
             pipes.quote(slug),
-            pipes.quote(name)
+            pipes.quote(name),
+            pipes.quote(audiobook.part_name),
+            audiobook.index,
+            audiobook.parts_count,
             )).encode('utf-8')
         try:
             api.put(path, UPLOAD_PATH)
             )).encode('utf-8')
         try:
             api.put(path, UPLOAD_PATH)
@@ -173,8 +179,11 @@ class Mp3Task(AudioFormatTask):
 
     @classmethod
     def set_tags(cls, audiobook, file_name):
 
     @classmethod
     def set_tags(cls, audiobook, file_name):
+        mp3_tags = audiobook.mp3_tags['tags']
+        if not mp3_tags.get('flac_sha1'):
+            mp3_tags['flac_sha1'] = audiobook.get_source_sha1()
         audio = id3.ID3(file_name)
         audio = id3.ID3(file_name)
-        for k, v in audiobook.mp3_tags['tags'].items():
+        for k, v in mp3_tags.items():
             factory_tuple = cls.TAG_MAP[k]
             factory, tagtype = factory_tuple[:2]
             audio.add(factory(tagtype, v, *factory_tuple[2:]))
             factory_tuple = cls.TAG_MAP[k]
             factory, tagtype = factory_tuple[:2]
             audio.add(factory(tagtype, v, *factory_tuple[2:]))