- def set_tags(cls, audiobook, file_name):
- tags = getattr(audiobook, "get_%s_tags" % cls.prefix)()['tags']
- if not tags.get('flac_sha1'):
- tags['flac_sha1'] = audiobook.get_source_sha1()
+ def set_tags(cls, tags, file_name):
"%s_published" % cls.prefix: datetime.now(),
'%s_status' % cls.prefix: None,
}
"%s_published" % cls.prefix: datetime.now(),
'%s_status' % cls.prefix: None,
}
@classmethod
def put(cls, user, audiobook, path):
@classmethod
def put(cls, user, audiobook, path):
'part_name': audiobook.part_name,
'part_index': audiobook.index,
'parts_count': audiobook.parts_count,
'source_sha1': audiobook.source_sha1,
'part_name': audiobook.part_name,
'part_index': audiobook.index,
'parts_count': audiobook.parts_count,
'source_sha1': audiobook.source_sha1,
}
with open(path, 'rb') as f:
api_call(user, UPLOAD_URL, data=data, files={
}
with open(path, 'rb') as f:
api_call(user, UPLOAD_URL, data=data, files={
def run(self, uid, aid, publish=True):
aid = int(aid)
audiobook = Audiobook.objects.get(id=aid)
def run(self, uid, aid, publish=True):
aid = int(aid)
audiobook = Audiobook.objects.get(id=aid)
- out_file = NamedTemporaryFile(delete=False, prefix='%d-' % aid, suffix='.%s' % self.ext)
+ out_file = NamedTemporaryFile(
+ delete=False, prefix='%d-' % aid, suffix='.%s' % self.ext,
+ dir=settings.FILE_UPLOAD_TEMP_DIR
+ )
self.set_status(aid, status.SENDING)
if publish:
self.put(user, audiobook, out_file.name)
self.set_status(aid, status.SENDING)
if publish:
self.put(user, audiobook, out_file.name)
else:
self.set_status(aid, None)
self.save(audiobook, out_file.name)
else:
self.set_status(aid, None)
self.save(audiobook, out_file.name)
def on_failure(self, exc, task_id, args, kwargs, einfo):
aid = (args[0], kwargs.get('aid'))[0]
self.set_status(aid, None)
def on_failure(self, exc, task_id, args, kwargs, einfo):
aid = (args[0], kwargs.get('aid'))[0]
self.set_status(aid, None)
# 44.1kHz 64kbps mono MP3
subprocess.check_call(['ffmpeg',
'-i', in_path.encode('utf-8'),
# 44.1kHz 64kbps mono MP3
subprocess.check_call(['ffmpeg',
'-i', in_path.encode('utf-8'),
- def set_tags(cls, audiobook, file_name):
- mp3_tags = audiobook.get_mp3_tags()['tags']
- if not mp3_tags.get('flac_sha1'):
- mp3_tags['flac_sha1'] = audiobook.get_source_sha1()
+ def set_tags(cls, tags, file_name):
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:]))
# 44.1kHz 64kbps mono Ogg Vorbis
subprocess.check_call(['ffmpeg',
'-i', in_path.encode('utf-8'),
# 44.1kHz 64kbps mono Ogg Vorbis
subprocess.check_call(['ffmpeg',
'-i', in_path.encode('utf-8'),