from apiclient import api_call
from archive.constants import status
from archive.models import Audiobook
from apiclient import api_call
from archive.constants import status
from archive.models import Audiobook
@classmethod
def set_status(cls, aid, status):
Audiobook.objects.filter(pk=aid).update(
@classmethod
def set_status(cls, aid, status):
Audiobook.objects.filter(pk=aid).update(
getattr(audiobook, field).save(
"%d.%s" % (audiobook.pk, cls.ext),
ExistingFile(file_name),
getattr(audiobook, field).save(
"%d.%s" % (audiobook.pk, cls.ext),
ExistingFile(file_name),
- "%s_published_tags" % cls.ext: F("%s_tags" % cls.ext),
- "%s_tags" % cls.ext: None,
- "%s_published" % cls.ext: datetime.now(),
- '%s_status' % cls.ext: None,
+ "%s_published_tags" % cls.prefix: F("%s_tags" % cls.prefix),
+ "%s_tags" % cls.prefix: None,
+ "%s_published" % cls.prefix: datetime.now(),
+ '%s_status' % cls.prefix: None,
}
Audiobook.objects.filter(pk=aid).update(**kwargs)
@classmethod
def put(cls, user, audiobook, path):
}
Audiobook.objects.filter(pk=aid).update(**kwargs)
@classmethod
def put(cls, user, audiobook, path):
'part_index': audiobook.index,
'parts_count': audiobook.parts_count,
'source_sha1': audiobook.source_sha1,
'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, dir=BUILD_PATH)
+ out_file = NamedTemporaryFile(
+ delete=False, prefix='%d-' % aid, suffix='.%s' % self.ext,
+ dir=settings.FILE_UPLOAD_TEMP_DIR
+ )
self.set_status(aid, status.TAGGING)
self.set_tags(audiobook, out_file.name)
self.set_status(aid, status.SENDING)
self.set_status(aid, status.TAGGING)
self.set_tags(audiobook, out_file.name)
self.set_status(aid, status.SENDING)
def on_failure(self, exc, task_id, args, kwargs, einfo):
aid = (args[0], kwargs.get('aid'))[0]
self.set_status(aid, None)
class Mp3Task(AudioFormatTask):
def on_failure(self, exc, task_id, args, kwargs, einfo):
aid = (args[0], kwargs.get('aid'))[0]
self.set_status(aid, None)
class Mp3Task(AudioFormatTask):
# 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'),
# 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'),