Esempio n. 1
0
def _store_source(track_id, ftype, session_key, source=False):
    tr = Track.objects.get(pk=track_id)
    print 'starting to store %s for %s from %s' % (ftype, track_id,
                                                   tr.temp_path)
    if filetype(tr.temp_path) != ftype:
        raise ValueError('%s is not of type %s' % (tr.temp_path, ftype))
    s3.move_local_file_into_s3_dir(tr.temp_path,
                                   tr.s3_url(ftype),
                                   make_public=False,
                                   make_protected=True,
                                   unlink_source=False)
    TrackFile.from_file(tr, tr.temp_path, session_key, source=source)
    print '%s stored for %s' % (ftype, track_id)
Esempio n. 2
0
def _store_source(track_id, ftype, session_key, source=False):
    tr = Track.objects.get(pk=track_id)
    print 'starting to store %s for %s from %s' % (ftype, track_id,
                                                   tr.temp_path)
    if filetype(tr.temp_path) != ftype:
        raise ValueError('%s is not of type %s' % (tr.temp_path, ftype))
    s3.move_local_file_into_s3_dir(tr.temp_path,
                                   tr.s3_url(ftype),
                                   make_public=False,
                                   make_protected=True,
                                   unlink_source=False)
    TrackFile.from_file(tr, tr.temp_path, session_key, source=source)
    print '%s stored for %s' % (ftype, track_id)
Esempio n. 3
0
def store_ogg(track_id, session_key, source=False, **kw):
    print 'starting to transcode and store ogg for %s' % track_id
    tr = Track.objects.get(pk=track_id)
    with tempfile.NamedTemporaryFile('wb', delete=False,
                                     suffix='.ogg') as outfile:
        dest = outfile.name
    sp = subprocess.Popen(['ffmpeg', '-i',
                           tr.temp_path,
                           '-vn', '-acodec', 'vorbis', '-aq', '60', '-strict',
                           'experimental', '-loglevel', 'quiet', '-y', dest])
    ret = sp.wait()
    if ret != 0:
        raise RuntimeError('ffmpeg source->ogg failed')

    s3.move_local_file_into_s3_dir(dest,
                                   tr.s3_url('ogg'),
                                   make_public=False,
                                   make_protected=True,
                                   unlink_source=False,
                                   headers={'Content-Type':
                                                'application/ogg'})
    tf = TrackFile.from_file(tr, dest, session_key, source=source)
    # The temp ogg file is no longer needed.
    os.unlink(dest)
    print 'stored %s for %s' % (tf.s3_url, track_id)
Esempio n. 4
0
def store_ogg(track_id, session_key, source=False, **kw):
    print 'starting to transcode and store ogg for %s' % track_id
    tr = Track.objects.get(pk=track_id)
    with tempfile.NamedTemporaryFile('wb', delete=False,
                                     suffix='.ogg') as outfile:
        dest = outfile.name
    sp = subprocess.Popen([
        'ffmpeg', '-i', tr.temp_path, '-vn', '-acodec', 'vorbis', '-aq', '60',
        '-strict', 'experimental', '-loglevel', 'quiet', '-y', dest
    ])
    ret = sp.wait()
    if ret != 0:
        raise RuntimeError('ffmpeg source->ogg failed')

    s3.move_local_file_into_s3_dir(dest,
                                   tr.s3_url('ogg'),
                                   make_public=False,
                                   make_protected=True,
                                   unlink_source=False,
                                   headers={'Content-Type': 'application/ogg'})
    tf = TrackFile.from_file(tr, dest, session_key, source=source)
    # The temp ogg file is no longer needed.
    os.unlink(dest)
    print 'stored %s for %s' % (tf.s3_url, track_id)