Package: telemeta
Architecture: any
-Depends: ${python:Depends}, python-xml, python-mutagen, python-django (>= 1.0-1), python-imaging (>= 1.1.6), sox, vorbis-tools, flac, normalize-audio, python-mysqldb, mysql-server, octave2.9, python-tk, libgd2-xpm, libsndfile1 (>= 1.0.17), python-numpy, python-ctypes (>= 1.0.1), python-scikits-audiolab (>= 0.7)
+Depends: ${python:Depends}, python-xml, python-mutagen, python-django (>= 1.0-1), python-imaging (>= 1.1.6), sox (>= 14.2.0-1), vorbis-tools, flac, normalize-audio, python-mysqldb, mysql-server, octave2.9, python-tk, libgd2-xpm, libsndfile1 (>= 1.0.17), python-numpy, python-ctypes (>= 1.0.1), python-scikits-audiolab (>= 0.7)
Recommends: lame, vamp-examples
Suggests: ecasound, festival, par2
Description: web frontend to backup, transcode and publish any audio content with metadata
import os
import re
+import md5
import string
import subprocess
import mutagen
except IOError:
return 'Exporter error: Cannot get the wav length...'
- def compare_md5_key(self):
- """ Compare 2 files wih md5 method """
- in1, in2 = os.popen4('md5sum -b "'+self.source+'"')
- out1, out2 = os.popen4('md5sum -b "'+self.dest+'"')
- for line in in2.readlines():
- line1 = line.split('*')[0]
- for line in out2.readlines():
- line2 = line.split('*')[0]
- return line1 == line2
+ def compare_md5_key(self, source, dest):
+ """ Compare source and dest files wih md5 method """
+ f_source = open(source).read()
+ f_dest = open(dest).read()
+ return md5.new(f_source).digest() == md5.new(f_dest).digest()
def write_metadata_xml(self,path):
doc = xml.dom.minidom.Document()
def post_process(self, item_id, source, metadata, ext,
cache_dir, options=None):
""" Post processing : write tags, print infos, etc..."""
- self.write_tags()
+ #self.write_tags()
if not options is None:
if 'verbose' in self.options and self.options['verbose'] != '0':
print self.dest
from telemeta.export.core import *
from telemeta.export.api import IExporter
from mutagen.flac import FLAC
+from tempfile import NamedTemporaryFile
class FlacExporter(ExporterCore):
"""Defines methods to export to FLAC"""
self.quality_default = '5'
self.info = []
self.buffer_size = 0xFFFF
-
+
def get_format(self):
return 'FLAC'
except IOError:
return 'ExporterError [2]: decoder not compatible.'
- def write_tags(self):
- media = FLAC(self.dest)
+ def write_tags(self, file):
+ media = FLAC(file)
for tag in self.metadata.keys():
if tag == 'COMMENT':
media['DESCRIPTION'] = str(self.metadata[tag])
self.args = self.get_args(options)
self.ext = self.get_file_extension()
self.args = ' '.join(self.args)
- self.command = 'sox "%s" -q -w -r 44100 -t wav -c2 - | flac %s -c -' % (self.source, self.args)
-
+ self.command = 'sox "%s" -s -q -r 44100 -t wav -c2 - | flac %s -c -' % (self.source, self.args)
+ tmp_file_name = NamedTemporaryFile(suffix = '.' + self.ext).name
+ tmp_file = open(tmp_file_name, 'w')
+
# Pre-proccessing
self.dest = self.pre_process(self.item_id,
self.source,
# Processing (streaming + cache writing)
stream = self.core_process(self.command, self.buffer_size, self.dest)
for chunk in stream:
+ tmp_file.write(chunk)
+
+ tmp_file.close()
+ self.write_tags(tmp_file)
+ tmp_file = open(tmp_file_name.name, 'r')
+
+ while True:
+ chunk = tmp_file.read(self.buffer_size)
+ if len(chunk) == 0:
+ break
yield chunk
-
+
+ tmp_file.close()
+
# Post-proccessing
- self.post_process(self.item_id,
- self.source,
- self.metadata,
- self.ext,
- self.cache_dir,
- self.options)
+ #self.post_process(self.item_id,
+ #self.source,
+ #self.metadata,
+ #self.ext,
+ #self.cache_dir,
+ #self.options)
def decode(self):
try:
- os.system('sox "'+self.source+'" -w -r 44100 -t wav "' \
+ os.system('sox "'+self.source+'" -s -q -r 44100 -t wav "' \
+self.cache_dir+os.sep+self.item_id+'"')
return self.cache_dir+os.sep+self.item_id+'.wav'
except IOError:
self.args = self.get_args(options)
self.ext = self.get_file_extension()
self.args = ' '.join(self.args)
- self.command = 'sox "%s" -q -w -r 44100 -t wav -c2 - | lame %s -' % (self.source, self.args)
+ self.command = 'sox "%s" -s -q -r 44100 -t wav -c2 - | lame %s -' % (self.source, self.args)
#self.command = 'lame %s "%s" -' % (self.args, self.source)
# Pre-proccessing
yield chunk
# Post-proccessing
- self.post_process(self.item_id,
- self.source,
- self.metadata,
- self.ext,
- self.cache_dir,
- self.options)
+ #self.post_process(self.item_id,
+ #self.source,
+ #self.metadata,
+ #self.ext,
+ #self.cache_dir,
+ #self.options)
self.args = self.get_args(options)
self.ext = self.get_file_extension()
self.args = ' '.join(self.args)
- self.command = 'sox "%s" -q -w -r 44100 -t wav -c2 - | oggenc %s -' % (self.source, self.args)
+ self.command = 'sox "%s" -s -q -r 44100 -t wav -c2 - | oggenc %s -' % (self.source, self.args)
# Pre-proccessing
self.dest = self.pre_process(self.item_id,
yield chunk
# Post-proccessing
- self.post_process(self.item_id,
- self.source,
- self.metadata,
- self.ext,
- self.cache_dir,
- self.options)
+ #self.post_process(self.item_id,
+ #self.source,
+ #self.metadata,
+ #self.ext,
+ #self.cache_dir,
+ #self.options)
try:
file_name, ext = get_file_name(self.source)
dest = self.cache_dir+os.sep+file_name+'.wav'
- os.system('sox "'+self.source+'" -w -r 44100 -t wav -c2 "'+ \
+ os.system('sox "'+self.source+'" -s -r 44100 -t wav -c2 "'+ \
dest+'.wav"')
self.source = dest
return dest
# Create the par2 key
#if 'par2' in self.metadata and self.metadata['par2']:
- self.create_par_key()
+ #self.create_par_key()
# Pre-proccessing
self.post_process(self.item_id,