コード例 #1
0
ファイル: spectrals.py プロジェクト: karamanolev/WhatManager2
 def _generate_temp_spectral(self, track, filenames):
     assert len(filenames) == 2
     track_path = os.path.join(self.temp_dir, track.temp_filename)
     logger.info('Generating spectrals for {0}'.format(track.temp_filename))
     full_title = '{0} Full'.format(os.path.splitext(track.filename)[0])
     zoom_title = '{0} Zoom'.format(os.path.splitext(track.filename)[0])
     ensure_file_dir_exists(filenames[0])
     ensure_file_dir_exists(filenames[0])
     args = [
         'sox', track_path, '-n', 'remix', '1', 'spectrogram', '-x', '3000', '-y', '513', '-w',
         'Kaiser', '-t', full_title, '-o', filenames[0]
     ]
     if self.high_color:
         args.append('-h')
     if call([q_enc(a) for a in args]) != 0:
         raise Exception('sox returned non-zero')
     assert track.duration >= 4, 'Track is shorter than 4 seconds'
     zoom_start = time_text(min(40, track.duration - 4))
     args = [
         'sox', track_path, '-n', 'remix', '1', 'spectrogram', '-x', '3000', '-y', '513', '-w',
         'Kaiser', '-S', zoom_start, '-d', '0:04', '-t', zoom_title, '-o', filenames[1]
     ]
     if self.high_color:
         args.append('-h')
     if call([q_enc(a) for a in args]) != 0:
         raise Exception('sox returned non-zero')
コード例 #2
0
 def _generate_temp_spectral(self, track, filenames):
     assert len(filenames) == 2
     track_path = os.path.join(self.temp_dir, track.temp_filename)
     logger.info('Generating spectrals for {0}'.format(track.temp_filename))
     full_title = '{0} Full'.format(os.path.splitext(track.filename)[0])
     zoom_title = '{0} Zoom'.format(os.path.splitext(track.filename)[0])
     ensure_file_dir_exists(filenames[0])
     ensure_file_dir_exists(filenames[0])
     args = [
         'sox', track_path, '-n', 'remix', '1', 'spectrogram', '-x', '3000',
         '-y', '513', '-w', 'Kaiser', '-t', full_title, '-o', filenames[0]
     ]
     if self.high_color:
         args.append('-h')
     if call([q_enc(a) for a in args]) != 0:
         raise Exception('sox returned non-zero')
     assert track.duration >= 4, 'Track is shorter than 4 seconds'
     zoom_start = time_text(min(40, track.duration - 4))
     args = [
         'sox', track_path, '-n', 'remix', '1', 'spectrogram', '-x', '3000',
         '-y', '513', '-w', 'Kaiser', '-S', zoom_start, '-d', '0:04', '-t',
         zoom_title, '-o', filenames[1]
     ]
     if self.high_color:
         args.append('-h')
     if call([q_enc(a) for a in args]) != 0:
         raise Exception('sox returned non-zero')
コード例 #3
0
def stream_download(destination, response):
    ensure_file_dir_exists(destination)
    with open(q_enc(destination), 'wb') as f:
        for chunk in response.iter_content(4096):
            f.write(chunk)
コード例 #4
0
ファイル: download.py プロジェクト: karamanolev/WhatManager2
def stream_download(destination, response):
    ensure_file_dir_exists(destination)
    with open(q_enc(destination), 'wb') as f:
        for chunk in response.iter_content(4096):
            f.write(chunk)