]> git.parisson.com Git - telemaster.git/commitdiff
expand
authoryomguy <yomguy@353fd7da-fb10-4236-9bec-1a49139083f2>
Sun, 11 Jan 2009 23:27:25 +0000 (23:27 +0000)
committeryomguy <yomguy@353fd7da-fb10-4236-9bec-1a49139083f2>
Sun, 11 Jan 2009 23:27:25 +0000 (23:27 +0000)
git-svn-id: http://svn.parisson.org/svn/telemaster/trunk@3 353fd7da-fb10-4236-9bec-1a49139083f2

audio_marking.py
audio_tools.py
collection.py
consts.py
default_options.py
default_tags.py
install.py
tag_tools.py
telemaster.py

index b9ce93c8e7d90dc67bee4cb4533d1c5d6b7094b5..a24ba7f7027521251df17e83710b9c5a392afd6c 100644 (file)
@@ -22,42 +22,42 @@ import tag_tools
 from audio_tools import *
 
 def make_auto_mark(dir_in,file_in):
-       media_in = dir_in+file_in
-       artist_no_ = string.replace(tag_tools.get_tag_value('ARTIST'),'_',' ')
-       title_no_ = string.replace(tag_tools.get_tag_value('TITLE'),'_',' ')
-       description_no_ = string.replace(tag_tools.get_tag_value('COMMENT'),'_',' ')
-       os.system('echo "This is: '+title_no_+'. By '+artist_no_+'. It is '+description_no_+'" | text2wave -f 44100 -o "'+media_in+'_mark.tmp"')
-       #os.system('normalize-audio "'+media_in+'_mark.tmp"')
-       os.system('sox "'+media_in+'_mark.tmp" -t wav -c2 "'+media_in+'_mark.wav" vol 10.0 dB compand 50,20 -80,-80,-25,-35,-15,-27,-5,-19,0,-15 15')
-       os.system('rm '+dir_in+'*.tmp')
+    media_in = dir_in+file_in
+    artist_no_ = string.replace(tag_tools.get_tag_value('ARTIST'),'_',' ')
+    title_no_ = string.replace(tag_tools.get_tag_value('TITLE'),'_',' ')
+    description_no_ = string.replace(tag_tools.get_tag_value('COMMENT'),'_',' ')
+    os.system('echo "This is: '+title_no_+'. By '+artist_no_+'. It is '+description_no_+'" | text2wave -f 44100 -o "'+media_in+'_mark.tmp"')
+    #os.system('normalize-audio "'+media_in+'_mark.tmp"')
+    os.system('sox "'+media_in+'_mark.tmp" -t wav -c2 "'+media_in+'_mark.wav" vol 10.0 dB compand 50,20 -80,-80,-25,-35,-15,-27,-5,-19,0,-15 15')
+    os.system('rm '+dir_in+'*.tmp')
 
 def mark_audio(dir_in,file_in,audio_marking_file,audio_marking_timeline):
-       media_in = dir_in+file_in
-       file_length_sec = audio_length_sec(media_in)
-       audio_mark_length_sec = audio_length_sec(audio_marking_file)
-       ecasound_phrase = ''
-       audio_gain = str(100+100*len(audio_marking_timeline))
+    media_in = dir_in+file_in
+    file_length_sec = audio_length_sec(media_in)
+    audio_mark_length_sec = audio_length_sec(audio_marking_file)
+    ecasound_phrase = ''
+    audio_gain = str(100+100*len(audio_marking_timeline))
 
-       for timeline in audio_marking_timeline:
-               audio_marking_ecasound_filename = file_in+'_'+timeline+'.ewf'
-               audio_marking_ecasound_path = dir_in+file_in+'_'+timeline+'.ewf'
-               audio_marking_ecasound_file=open(audio_marking_ecasound_path,'w')
-               audio_marking_ecasound_file.write('-- '+audio_marking_ecasound_filename+' --\n')
-               audio_marking_ecasound_file.write('source = '+audio_marking_file+'\n')
-               if timeline == 'b':
-                       mark_offset = '0'
-                       ecasound_phrase = '-a:2 -i:"'+audio_marking_ecasound_path+'" -ea:'+audio_gain+' '
-               if timeline == 'm':
-                       mark_offset = str(file_length_sec/2)
-                       ecasound_phrase = ecasound_phrase+'-a:3 -i:"'+audio_marking_ecasound_path+'" -ea:'+audio_gain+' '
-               if timeline == 'e':
-                       mark_offset = str(file_length_sec-audio_mark_length_sec)
-                       ecasound_phrase = ecasound_phrase+'-a:4 -i:"'+audio_marking_ecasound_path+'" -ea:'+audio_gain+' '
-               audio_marking_ecasound_file.write('offset = '+mark_offset+'.0\n')
-               audio_marking_ecasound_file.write('start-position = 0.0\n')
-               audio_marking_ecasound_file.write('length = '+str(audio_mark_length_sec)+'.0\n')
-               audio_marking_ecasound_file.write('looping = false\n')
-               audio_marking_ecasound_file.write('--cut--\n')
-               audio_marking_ecasound_file.close()
-       os.system('ecasound -a:1 -i:"'+media_in+'" -ea:'+audio_gain+' '+ecasound_phrase+' -a:all -o "'+dir_in+'marked_'+file_in+'"')
+    for timeline in audio_marking_timeline:
+        audio_marking_ecasound_filename = file_in+'_'+timeline+'.ewf'
+        audio_marking_ecasound_path = dir_in+file_in+'_'+timeline+'.ewf'
+        audio_marking_ecasound_file=open(audio_marking_ecasound_path,'w')
+        audio_marking_ecasound_file.write('-- '+audio_marking_ecasound_filename+' --\n')
+        audio_marking_ecasound_file.write('source = '+audio_marking_file+'\n')
+        if timeline == 'b':
+            mark_offset = '0'
+            ecasound_phrase = '-a:2 -i:"'+audio_marking_ecasound_path+'" -ea:'+audio_gain+' '
+        if timeline == 'm':
+            mark_offset = str(file_length_sec/2)
+            ecasound_phrase = ecasound_phrase+'-a:3 -i:"'+audio_marking_ecasound_path+'" -ea:'+audio_gain+' '
+        if timeline == 'e':
+            mark_offset = str(file_length_sec-audio_mark_length_sec)
+            ecasound_phrase = ecasound_phrase+'-a:4 -i:"'+audio_marking_ecasound_path+'" -ea:'+audio_gain+' '
+        audio_marking_ecasound_file.write('offset = '+mark_offset+'.0\n')
+        audio_marking_ecasound_file.write('start-position = 0.0\n')
+        audio_marking_ecasound_file.write('length = '+str(audio_mark_length_sec)+'.0\n')
+        audio_marking_ecasound_file.write('looping = false\n')
+        audio_marking_ecasound_file.write('--cut--\n')
+        audio_marking_ecasound_file.close()
+    os.system('ecasound -a:1 -i:"'+media_in+'" -ea:'+audio_gain+' '+ecasound_phrase+' -a:all -o "'+dir_in+'marked_'+file_in+'"')
 
index 37ac4ca12ad4ea1bac8e3d6889744616eddc9dbc..b0b052ea4ade5b9aa433f9d659ba9c4693f4d237 100644 (file)
@@ -22,159 +22,159 @@ import tag_tools
 from audio_tools import *
 
 def encode(enc_type,dir_in,file_in,dir_out,file_out):
-       media_in = dir_in+file_in
-       media_out = dir_out+file_out
+    media_in = dir_in+file_in
+    media_out = dir_out+file_out
 
-       if enc_type == 'flac' :
-               quality = tag_tools.get_opt_value(enc_type+'_quality')
-               os.system('flac -f -V -q '+quality+' -o "'+media_out+'" "'+media_in+'"')
+    if enc_type == 'flac' :
+        quality = tag_tools.get_opt_value(enc_type+'_quality')
+        os.system('flac -f -V -q '+quality+' -o "'+media_out+'" "'+media_in+'"')
 
-       if enc_type == 'ogg':
-               bitrate = tag_tools.get_opt_value(enc_type+'_bitrate')
-               os.system('oggenc -b '+bitrate+' -o "'+media_out+'" "'+media_in+'"')
+    if enc_type == 'ogg':
+        bitrate = tag_tools.get_opt_value(enc_type+'_bitrate')
+        os.system('oggenc -b '+bitrate+' -o "'+media_out+'" "'+media_in+'"')
 
-       if enc_type == 'mp3':
-               bitrate = tag_tools.get_opt_value(enc_type+'_bitrate')
-               tag='temp'
-               os.system('lame -b '+bitrate+' --ta "'+tag+'" --tt "'+tag+'" --tl "'+tag+'" --ty '+tag+' --tg "Other" --tc "'+tag+'" "'+media_in+'" "'+media_out+'"')
+    if enc_type == 'mp3':
+        bitrate = tag_tools.get_opt_value(enc_type+'_bitrate')
+        tag='temp'
+        os.system('lame -b '+bitrate+' --ta "'+tag+'" --tt "'+tag+'" --tl "'+tag+'" --ty '+tag+' --tg "Other" --tc "'+tag+'" "'+media_in+'" "'+media_out+'"')
 
-       if enc_type == 'wav':
-               if iswav16(media_in):
-                       os.system('cp -a "'+media_in+'" "'+media_out+'"')
-               else:
-                       os.system('sox "'+media_in+'" -w -r 44100 -t wav -c2 "'+media_out+'"')
+    if enc_type == 'wav':
+        if iswav16(media_in):
+            os.system('cp -a "'+media_in+'" "'+media_out+'"')
+        else:
+            os.system('sox "'+media_in+'" -w -r 44100 -t wav -c2 "'+media_out+'"')
 
-#      if enc_type == 'ogg' and ismp3(media_in):
+#   if enc_type == 'ogg' and ismp3(media_in):
 #                os.system('mp32ogg --verbose "'+file_in+'" "'+file_out+'"')
 
 def decode(media_in,file_ext):
-       if ismp3(media_in) or file_ext == 'mp3':
-               os.system('mpg123 -q -s "'+media_in+'" -w "'+media_in+'.wav"')
-       if isogg(media_in) or file_ext == 'ogg':
-               os.system('oggdec -o "'+media_in+'.wav" "'+media_in+'"')
-       if isflac(media_in) or file_ext == 'flac':
-               os.system('flac -d "'+media_in+'"')
-       if iswav(media_in) or file_ext == 'wav':
-               os.system('sox "'+media_in+'" -w -r 44100 -t wav -c2 "'+media_in+'.wav"')
-       if isaiff(media_in) or file_ext == 'aiff':
-               os.system('sox "'+media_in+'" -w -r 44100 -t aiff -c2 "'+media_in+'.wav"')
+    if ismp3(media_in) or file_ext == 'mp3':
+        os.system('mpg123 -q -s "'+media_in+'" -w "'+media_in+'.wav"')
+    if isogg(media_in) or file_ext == 'ogg':
+        os.system('oggdec -o "'+media_in+'.wav" "'+media_in+'"')
+    if isflac(media_in) or file_ext == 'flac':
+        os.system('flac -d "'+media_in+'"')
+    if iswav(media_in) or file_ext == 'wav':
+        os.system('sox "'+media_in+'" -w -r 44100 -t wav -c2 "'+media_in+'.wav"')
+    if isaiff(media_in) or file_ext == 'aiff':
+        os.system('sox "'+media_in+'" -w -r 44100 -t aiff -c2 "'+media_in+'.wav"')
 
 def normalize(media_in):
-       os.system('normalize-audio "'+media_in+'"')
+    os.system('normalize-audio "'+media_in+'"')
 
 def create_md5_key(dir_in,file_in):
-       media_in = dir_in+file_in
-       os.system('md5sum -b "'+media_in+'" "'+media_in+'.md5"')
+    media_in = dir_in+file_in
+    os.system('md5sum -b "'+media_in+'" "'+media_in+'.md5"')
 
 def check_md5_key(dir_in,file_in):
-       media_in = dir_in+file_in
-       md5_log = os.popen4('md5sum -c "'+media_in+'" "'+media_in+'.md5"')
-       if 'OK' in md5_log.split(':'):
-               return True
-       else:
-               return False
+    media_in = dir_in+file_in
+    md5_log = os.popen4('md5sum -c "'+media_in+'" "'+media_in+'.md5"')
+    if 'OK' in md5_log.split(':'):
+        return True
+    else:
+        return False
 
 def compare_md5_key(file_in,file_out):
-       media_in = file_in
-       media_out = file_out
-       if not os.path.exists(media_in):
-               return False
-       else:
-               print 'Checking md5sums...'
-               file_in_in, file_in_out = os.popen4('md5sum -b "'+media_in+'"')
-               file_out_in, file_out_out = os.popen4('md5sum -b "'+media_out+'"')
-               for line in file_in_out.readlines():
-                       line = line.split('*')
-                       line = line[0]
-                       #print line
-                       for file_out_out_line in file_out_out.readlines():
-                               file_out_out_line= file_out_out_line.split('*')
-                               file_out_out_line= file_out_out_line[0]
-                               #print file_out_out_line        
-                               if line == file_out_out_line:
-                                       print 'Files are equal...\n'
-                                       return True
-                                       exit
-                               else:
-                                       print 'Files are different...\n'
-                                       return False
-                                       exit
-               
+    media_in = file_in
+    media_out = file_out
+    if not os.path.exists(media_in):
+        return False
+    else:
+        print 'Checking md5sums...'
+        file_in_in, file_in_out = os.popen4('md5sum -b "'+media_in+'"')
+        file_out_in, file_out_out = os.popen4('md5sum -b "'+media_out+'"')
+        for line in file_in_out.readlines():
+            line = line.split('*')
+            line = line[0]
+            #print line
+            for file_out_out_line in file_out_out.readlines():
+                file_out_out_line= file_out_out_line.split('*')
+                file_out_out_line= file_out_out_line[0]
+                #print file_out_out_line    
+                if line == file_out_out_line:
+                    print 'Files are equal...\n'
+                    return True
+                    exit
+                else:
+                    print 'Files are different...\n'
+                    return False
+                    exit
+        
 def create_par_key(dir_in,file_in):
-       media_in = dir_in+file_in
-       os.system('par2 c -n1 "'+media_in+'"')
+    media_in = dir_in+file_in
+    os.system('par2 c -n1 "'+media_in+'"')
 
 def recover_par_key(dir_in):
-       for file in os.listdir(dir_in):
-               media_in = dir_in+file
-               if iswav(media_in):
-                       os.system('par2 r "'+media_in+'"')
+    for file in os.listdir(dir_in):
+        media_in = dir_in+file
+        if iswav(media_in):
+            os.system('par2 r "'+media_in+'"')
 
 def verify_par_key(media_in):
-       os.system('par2 v "'+media_in+'.par2"')
+    os.system('par2 v "'+media_in+'.par2"')
 
 def clean_directory(dir_in,type_list):
-       for enc_type in type_list:
-               if os.path.exists(dir_in+enc_type):
-                       print 'Removing '+dir_in+enc_type
-                       os.system('rm -rf "'+dir_in+enc_type+'"')
+    for enc_type in type_list:
+        if os.path.exists(dir_in+enc_type):
+            print 'Removing '+dir_in+enc_type
+            os.system('rm -rf "'+dir_in+enc_type+'"')
 
 def audio_length_sec(file) :
-       file_in, file_out = os.popen4('wavinfo "'+file+'" | grep wavDataSize')
-       for line in file_out.readlines():
-               line_split = line.split(':')
-               value = int(int(line_split[1])/(4*44100))
-               return value
+    file_in, file_out = os.popen4('wavinfo "'+file+'" | grep wavDataSize')
+    for line in file_out.readlines():
+        line_split = line.split(':')
+        value = int(int(line_split[1])/(4*44100))
+        return value
 
 def ext_is_audio(file):
-       file_name_woext, file_ext = tag_tools.filename_split(file)
-       return file_ext == "mp3" or file_ext == "ogg" or file_ext == "flac" or file_ext == "wav" or file_ext == "aif" or file_ext == "aiff" or file_ext == "WAV" or file_ext == "AIFF" or file_ext == "AIF" or file_ext == "MP3" or file_ext == "OGG" or file_ext == "FLAC"
+    file_name_woext, file_ext = tag_tools.filename_split(file)
+    return file_ext == "mp3" or file_ext == "ogg" or file_ext == "flac" or file_ext == "wav" or file_ext == "aif" or file_ext == "aiff" or file_ext == "WAV" or file_ext == "AIFF" or file_ext == "AIF" or file_ext == "MP3" or file_ext == "OGG" or file_ext == "FLAC"
 
 def isaudio(file) :
-       file_in, file_out = os.popen4('file "'+file+'"')
-       for line in file_out.readlines():
-               line_split = line.split(' ')
-               return (iswav16(file) or iswav(file) or ismp3(file) or isogg(file) or isflac(file) or isaiff(file) or isaiff16(file))
+    file_in, file_out = os.popen4('file "'+file+'"')
+    for line in file_out.readlines():
+        line_split = line.split(' ')
+        return (iswav16(file) or iswav(file) or ismp3(file) or isogg(file) or isflac(file) or isaiff(file) or isaiff16(file))
 
 def iswav(file) :
-       file_in, file_out = os.popen4('file "'+file+'"')
-       for line in file_out.readlines():
-               line_split = line.split(' ')
-               return ('WAVE' in line_split)
+    file_in, file_out = os.popen4('file "'+file+'"')
+    for line in file_out.readlines():
+        line_split = line.split(' ')
+        return ('WAVE' in line_split)
 
 def iswav16(file) :
-       file_in, file_out = os.popen4('file "'+file+'"')
-       for line in file_out.readlines():
-               line_split = line.split(' ')
-               return ('WAVE' in line_split) and ('16' in line_split)
+    file_in, file_out = os.popen4('file "'+file+'"')
+    for line in file_out.readlines():
+        line_split = line.split(' ')
+        return ('WAVE' in line_split) and ('16' in line_split)
 
 def isaiff(file) :
-       file_in, file_out = os.popen4('file "'+file+'"')
-       for line in file_out.readlines():
-               line_split = line.split(' ')
-               return ('AIFF' in line_split)
+    file_in, file_out = os.popen4('file "'+file+'"')
+    for line in file_out.readlines():
+        line_split = line.split(' ')
+        return ('AIFF' in line_split)
 
 def isaiff16(file) :
-       file_in, file_out = os.popen4('file "'+file+'"')
-       for line in file_out.readlines():
-               line_split = line.split(' ')
-               return ('AIFF' in line_split) and ('16' in line_split)
+    file_in, file_out = os.popen4('file "'+file+'"')
+    for line in file_out.readlines():
+        line_split = line.split(' ')
+        return ('AIFF' in line_split) and ('16' in line_split)
 
 def ismp3(file) :
-       file_in, file_out = os.popen4('file "'+file+'"')
-       for line in file_out.readlines():
-               line_split_space = line.split(' ')
-               line_split_comma = line.split(',')
-               return (('MPEG' in line_split_space and ' layer III' in line_split_comma) or 'MP3' in line_split_space)
+    file_in, file_out = os.popen4('file "'+file+'"')
+    for line in file_out.readlines():
+        line_split_space = line.split(' ')
+        line_split_comma = line.split(',')
+        return (('MPEG' in line_split_space and ' layer III' in line_split_comma) or 'MP3' in line_split_space)
 
 def isogg(file) :
-       file_in, file_out = os.popen4('file "'+file+'"')
-       for line in file_out.readlines():
-               line_split = line.split(',')
-               return (' Vorbis audio' in line_split)
+    file_in, file_out = os.popen4('file "'+file+'"')
+    for line in file_out.readlines():
+        line_split = line.split(',')
+        return (' Vorbis audio' in line_split)
 
 def isflac(file) :
-       file_in, file_out = os.popen4('file "'+file+'"')
-       for line in file_out.readlines():
-               line_split = line.split(' ')
-               return ('FLAC' in line_split)
+    file_in, file_out = os.popen4('file "'+file+'"')
+    for line in file_out.readlines():
+        line_split = line.split(' ')
+        return ('FLAC' in line_split)
index 2885ffd26d92ca3b2ffaa0fca9f3f40ab12ba9c1..951816032fb319589b97c195343fb4fd64e3d96f 100644 (file)
@@ -21,16 +21,16 @@ import os, string
 
 class Collection :
 
-       def __init__(self) :
-               self.collection_name = 'telemaster_default'
-               self.collection_dir = '/home/'+os.environ["USER"]+'/telemaster/'
-               self.user_dir = '/home/'+os.environ["USER"]+'/.telemaster/'
-               self.user_tag_xml = '/home/'+os.environ["USER"]+'/.telemaster/default_tags.xml'
-               self.user_collection_xml = '/home/'+os.environ["USER"]+'/.telemaster/default_collection.xml'
-               self.tag_table = 'ARTIST,TITLE,ALBUM,DATE,GENRE,SOURCE,ENCODER,COMMENT'
-               self.type_list = 'mp3,ogg,flac,wav,aiff'
-               self.net_backup_host = 'domain.com'
-               self.net_backup_dir = '/home/'+os.environ["USER"]+'/telemaster/'
+    def __init__(self) :
+        self.collection_name = 'telemaster_default'
+        self.collection_dir = '/home/'+os.environ["USER"]+'/telemaster/'
+        self.user_dir = '/home/'+os.environ["USER"]+'/.telemaster/'
+        self.user_tag_xml = '/home/'+os.environ["USER"]+'/.telemaster/default_tags.xml'
+        self.user_collection_xml = '/home/'+os.environ["USER"]+'/.telemaster/default_collection.xml'
+        self.tag_table = 'ARTIST,TITLE,ALBUM,DATE,GENRE,SOURCE,ENCODER,COMMENT'
+        self.type_list = 'mp3,ogg,flac,wav,aiff'
+        self.net_backup_host = 'domain.com'
+        self.net_backup_dir = '/home/'+os.environ["USER"]+'/telemaster/'
 
 #option_table=['enc_types','flac_bitrate','ogg_bitrate','mp3_bitrate','audio_marking','auto_audio_marking','audio_marking_file','audio_marking_timeline']
 
index 3b0a9e34391b6d15379437fee2e018f887fa5aa9..ee01db8244764e307408d3c73077e49d847bdd5e 100644 (file)
--- a/consts.py
+++ b/consts.py
@@ -21,16 +21,16 @@ import os, string
 
 class Collection :
 
-       def __init__(self) :
-               self.collection_name = 'telemaster_default'
-               self.collection_dir = '/home/'+os.environ["USER"]+'/telemaster_default/'
-               self.user_dir = '/home/'+os.environ["USER"]+'/.telemaster/'
-               self.default_tag_xml = '/home/'+os.environ["USER"]+'/.telemaster/default_tags.xml'
-               self.default_collection_xml = '/home/'+os.environ["USER"]+'/.telemaster/default_collection.xml'
-               self.tag_table = 'ARTIST,TITLE,ALBUM,DATE,GENRE,SOURCE,ENCODER,COMMENT'
-               self.type_list = 'mp3,ogg,flac,wav,aiff'
-               self.net_backup_host = 'domain.com'
-               self.net_backup_dir = '/home/'+os.environ["USER"]+'/telemaster/'
+    def __init__(self) :
+        self.collection_name = 'telemaster_default'
+        self.collection_dir = '/home/'+os.environ["USER"]+'/telemaster_default/'
+        self.user_dir = '/home/'+os.environ["USER"]+'/.telemaster/'
+        self.default_tag_xml = '/home/'+os.environ["USER"]+'/.telemaster/default_tags.xml'
+        self.default_collection_xml = '/home/'+os.environ["USER"]+'/.telemaster/default_collection.xml'
+        self.tag_table = 'ARTIST,TITLE,ALBUM,DATE,GENRE,SOURCE,ENCODER,COMMENT'
+        self.type_list = 'mp3,ogg,flac,wav,aiff'
+        self.net_backup_host = 'domain.com'
+        self.net_backup_dir = '/home/'+os.environ["USER"]+'/telemaster/'
 
 #option_table=['enc_types','flac_bitrate','ogg_bitrate','mp3_bitrate','audio_marking','auto_audio_marking','audio_marking_file','audio_marking_timeline']
 
index 065e97b7fdab771f50296525c006b1875bfd289d..f03f966571c40e9de20fee3ad90f60665dbe56f8 100644 (file)
 
 class Options :
 
-       def __init__(self) :
-               self.collection = 'Unknown'
-               self.enc_types = 'flac, ogg, mp3'
-               self.ogg_bitrate ='192'
-               self.mp3_bitrate = '192'
-               self.flac_quality = '5'
-               self.audio_marking = False
-               self.auto_audio_marking = True
-               self.audio_marking_file = '/path/to/file'
-               self.audio_marking_timeline = 'b, m, e'
-               self.par_key = True
-               self.normalize = False
+    def __init__(self) :
+        self.collection = 'Unknown'
+        self.enc_types = 'flac, ogg, mp3'
+        self.ogg_bitrate ='192'
+        self.mp3_bitrate = '192'
+        self.flac_quality = '5'
+        self.audio_marking = False
+        self.auto_audio_marking = True
+        self.audio_marking_file = '/path/to/file'
+        self.audio_marking_timeline = 'b, m, e'
+        self.par_key = True
+        self.normalize = False
index a03c6207658ecff14d87bff27149fe18d925fed4..8cec9410c745ec511678dc9199618cdb602fbf0d 100644 (file)
 
 class Tags :
 
-       def __init__(self) :
-               self.COLLECTION = 'Unknown'
-               self.ARTIST = 'Unknown'
-               self.TITLE = 'Unknown'
-               self.ALBUM = 'Unknown'
-               self.GENRE = 'Other'
-               self.DATE = '1900'
-               self.SOURCE = 'Here'
-               self.ENCODER = 'me@domain.com'
-               self.COMMENT = 'No comment'
-               self.ORIGINAL_MEDIA = '1/4" tape'
+    def __init__(self) :
+        self.COLLECTION = 'Unknown'
+        self.ARTIST = 'Unknown'
+        self.TITLE = 'Unknown'
+        self.ALBUM = 'Unknown'
+        self.GENRE = 'Other'
+        self.DATE = '1900'
+        self.SOURCE = 'Here'
+        self.ENCODER = 'me@domain.com'
+        self.COMMENT = 'No comment'
+        self.ORIGINAL_MEDIA = '1/4" tape'
 
index 0bfba58b6cd10e4ec8b664b56633ee9e31949082..01bb83f34ab21ff452b5e51848d3bf12426bd63a 100755 (executable)
 import os, sys
 
 if len(sys.argv) == 1:
-       install_dir = '/usr/share/telemaster/'
+    install_dir = '/usr/share/telemaster/'
 elif len(sys.argv) > 2:
-       sys.exit('Give just one directory to install Telemeta, or none.')
+    sys.exit('Give just one directory to install Telemeta, or none.')
 else:
-       install_dir = sys.argv[1]
+    install_dir = sys.argv[1]
 
 if not os.path.exists(install_dir):
-       os.mkdir(install_dir)
+    os.mkdir(install_dir)
 
 os.system('cp -ra ./* '+install_dir+os.sep)
 os.system('rm -rf '+install_dir+os.sep+'debian')
 
 if os.path.exists('/usr/bin/telemaster'):
-       os.system('rm -r /usr/bin/telemaster')
+    os.system('rm -r /usr/bin/telemaster')
 
 os.system('ln -s '+install_dir+os.sep+'telemaster.py '+'/usr/bin/telemaster')
 
index 25733d79a93d315c505f159345e483840c1c4f8d..cf0c9d0b6a12a02cc50686650affa99a7d44b7bf 100644 (file)
@@ -38,272 +38,272 @@ collection = consts.Collection()
 # ============
 
 def write_collection_consts(fic):
-       doc = xml.dom.minidom.Document()
-       root = doc.createElement('telemaster')
-       doc.appendChild(root)
-       for data in collection.__dict__.keys() :
-               value = collection.__dict__[data]
-               node = doc.createElement('data')
-               node.setAttribute('name', data)
-               node.setAttribute('value', str(value))
-               node.setAttribute('type', typeToolBox.getType(value))
-               root.appendChild(node)
-       file_object = open(fic, "w")
-       xml.dom.ext.PrettyPrint(doc, file_object)
-       file_object.close()
+    doc = xml.dom.minidom.Document()
+    root = doc.createElement('telemaster')
+    doc.appendChild(root)
+    for data in collection.__dict__.keys() :
+        value = collection.__dict__[data]
+        node = doc.createElement('data')
+        node.setAttribute('name', data)
+        node.setAttribute('value', str(value))
+        node.setAttribute('type', typeToolBox.getType(value))
+        root.appendChild(node)
+    file_object = open(fic, "w")
+    xml.dom.ext.PrettyPrint(doc, file_object)
+    file_object.close()
 
 def get_collection_consts(doc):
-       for data in doc.documentElement.getElementsByTagName('data') :
-               name = data.getAttribute('name')
-               value = typeToolBox.cast(data.getAttribute('value'), data.getAttribute('type'))
-               collection.__dict__[name] = value
+    for data in doc.documentElement.getElementsByTagName('data') :
+        name = data.getAttribute('name')
+        value = typeToolBox.cast(data.getAttribute('value'), data.getAttribute('type'))
+        collection.__dict__[name] = value
 
 def ask_write_collection(name):
-       global collection
-       for data in collection.__dict__.keys() :
-               if data == 'collection_name' :
-                       def_value = name
-                       type_def_value = typeToolBox.getType(def_value)
-                       value = raw_input(data+' ? ['+str(def_value)+']: ')
-               elif data == 'default_collection_xml' :
-                       collection_xml = '/home/'+os.environ["USER"]+'/.telemaster/'+name+'.xml'
-                       type_def_collection = typeToolBox.getType(collection_xml)
-                       collection_tmp = typeToolBox.cast(collection_xml,type_def_collection)
-                       collection.__dict__[data] = collection_tmp
-                       value = collection.__dict__[data]
-               elif data == 'collection_dir' :
-                       collection_dir = '/home/'+os.environ["USER"]+'/'+name
-                       type_def_collection_dir = typeToolBox.getType(collection_dir)
-                       collection_tmp = typeToolBox.cast(collection_dir,type_def_collection_dir)
-                       collection.__dict__[data] = collection_tmp
-                       def_value = collection.__dict__[data]
-                       value = raw_input(data+' ? ['+str(def_value)+']: ')
-               elif data == 'user_dir' :
-                       def_value = '/home/'+os.environ["USER"]+'/.telemaster/'
-                       type_def_value = typeToolBox.getType(def_value)
-                       value = def_value
-               elif data == 'default_tag_xml' :
-                       def_value = '/home/'+os.environ["USER"]+'/.telemaster/default_tags.xml'
-                       type_def_value = typeToolBox.getType(def_value)
-                       value = def_value
-               else :
-                       def_value = collection.__dict__[data]
-                       type_def_value = typeToolBox.getType(def_value)
-                       value = raw_input(data+' ? ['+str(def_value)+']: ')
-               if not value == '' :
-                       value = typeToolBox.cast(value,type_def_value)
-                       #value = string.replace(in_float,' ','')
-                       collection.__dict__[data] = value
+    global collection
+    for data in collection.__dict__.keys() :
+        if data == 'collection_name' :
+            def_value = name
+            type_def_value = typeToolBox.getType(def_value)
+            value = raw_input(data+' ? ['+str(def_value)+']: ')
+        elif data == 'default_collection_xml' :
+            collection_xml = '/home/'+os.environ["USER"]+'/.telemaster/'+name+'.xml'
+            type_def_collection = typeToolBox.getType(collection_xml)
+            collection_tmp = typeToolBox.cast(collection_xml,type_def_collection)
+            collection.__dict__[data] = collection_tmp
+            value = collection.__dict__[data]
+        elif data == 'collection_dir' :
+            collection_dir = '/home/'+os.environ["USER"]+'/'+name
+            type_def_collection_dir = typeToolBox.getType(collection_dir)
+            collection_tmp = typeToolBox.cast(collection_dir,type_def_collection_dir)
+            collection.__dict__[data] = collection_tmp
+            def_value = collection.__dict__[data]
+            value = raw_input(data+' ? ['+str(def_value)+']: ')
+        elif data == 'user_dir' :
+            def_value = '/home/'+os.environ["USER"]+'/.telemaster/'
+            type_def_value = typeToolBox.getType(def_value)
+            value = def_value
+        elif data == 'default_tag_xml' :
+            def_value = '/home/'+os.environ["USER"]+'/.telemaster/default_tags.xml'
+            type_def_value = typeToolBox.getType(def_value)
+            value = def_value
+        else :
+            def_value = collection.__dict__[data]
+            type_def_value = typeToolBox.getType(def_value)
+            value = raw_input(data+' ? ['+str(def_value)+']: ')
+        if not value == '' :
+            value = typeToolBox.cast(value,type_def_value)
+            #value = string.replace(in_float,' ','')
+            collection.__dict__[data] = value
 
 def get_consts_value(data):
-       value = collection.__dict__[data]
-       type_value = typeToolBox.getType(value)
-       return value
+    value = collection.__dict__[data]
+    type_value = typeToolBox.getType(value)
+    return value
 
 # TAGS
 # =====
 
 def write_tags(enc_type,dir_out,file_out):
-       media_out = dir_out+file_out
-
-       if enc_type == 'flac':
-               audio = FLAC(media_out)
-               for tag in tags.__dict__.keys():
-                       if tag == 'COMMENT':
-                               audio['DESCRIPTION'] = tags.__dict__[tag]
-                       else:
-                               audio[tag] = tags.__dict__[tag]
-               audio.save()
-
-       if enc_type == 'ogg':
-               audio = OggVorbis(media_out)
-               for tag in tags.__dict__.keys():
-                       audio[tag] = tags.__dict__[tag]
-               audio.save()
-
-       if enc_type == 'mp3':
-               audio = ID3(media_out)
-               #tags = ['ALBUM','DATE','GENRE','SOURCE','ENCODER','COMMENT']
-               tag = tags.__dict__['TITLE']
-               audio.add(TIT2(encoding=3, text=tag))
-               tag = tags.__dict__['ARTIST']
-               audio.add(TP1(encoding=3, text=tag))
-               tag = tags.__dict__['ALBUM']
-               audio.add(TAL(encoding=3, text=tag))
-               tag = tags.__dict__['DATE']
-               audio.add(TDA(encoding=3, text=tag))
-               tag = tags.__dict__['GENRE']
-               audio.add(TCO(encoding=3, text=tag))
-               tag = tags.__dict__['COMMENT']
-               audio.add(COM(encoding=3, text=tag))
-               audio.save()
+    media_out = dir_out+file_out
+
+    if enc_type == 'flac':
+        audio = FLAC(media_out)
+        for tag in tags.__dict__.keys():
+            if tag == 'COMMENT':
+                audio['DESCRIPTION'] = tags.__dict__[tag]
+            else:
+                audio[tag] = tags.__dict__[tag]
+        audio.save()
+
+    if enc_type == 'ogg':
+        audio = OggVorbis(media_out)
+        for tag in tags.__dict__.keys():
+            audio[tag] = tags.__dict__[tag]
+        audio.save()
+
+    if enc_type == 'mp3':
+        audio = ID3(media_out)
+        #tags = ['ALBUM','DATE','GENRE','SOURCE','ENCODER','COMMENT']
+        tag = tags.__dict__['TITLE']
+        audio.add(TIT2(encoding=3, text=tag))
+        tag = tags.__dict__['ARTIST']
+        audio.add(TP1(encoding=3, text=tag))
+        tag = tags.__dict__['ALBUM']
+        audio.add(TAL(encoding=3, text=tag))
+        tag = tags.__dict__['DATE']
+        audio.add(TDA(encoding=3, text=tag))
+        tag = tags.__dict__['GENRE']
+        audio.add(TCO(encoding=3, text=tag))
+        tag = tags.__dict__['COMMENT']
+        audio.add(COM(encoding=3, text=tag))
+        audio.save()
 
 def write_def_tags(fic):
-       doc = xml.dom.minidom.Document()
-       root = doc.createElement('telemaster')
-       doc.appendChild(root)
-       for tag in tags.__dict__.keys() :
-               value = tags.__dict__[tag]
-               node = doc.createElement('tag')
-               node.setAttribute('name', tag)
-               node.setAttribute('value', str(value))
-               node.setAttribute('type', typeToolBox.getType(value))
-               root.appendChild(node)
-       for opt in options.__dict__.keys() :
-               value = options.__dict__[opt]
-               node = doc.createElement('opt')
-               node.setAttribute('name', opt)
-               node.setAttribute('value', str(value))
-               node.setAttribute('type', typeToolBox.getType(value))
-               root.appendChild(node)
-       file_object = open(fic, "w")
-       xml.dom.ext.PrettyPrint(doc, file_object)
-       file_object.close()
+    doc = xml.dom.minidom.Document()
+    root = doc.createElement('telemaster')
+    doc.appendChild(root)
+    for tag in tags.__dict__.keys() :
+        value = tags.__dict__[tag]
+        node = doc.createElement('tag')
+        node.setAttribute('name', tag)
+        node.setAttribute('value', str(value))
+        node.setAttribute('type', typeToolBox.getType(value))
+        root.appendChild(node)
+    for opt in options.__dict__.keys() :
+        value = options.__dict__[opt]
+        node = doc.createElement('opt')
+        node.setAttribute('name', opt)
+        node.setAttribute('value', str(value))
+        node.setAttribute('type', typeToolBox.getType(value))
+        root.appendChild(node)
+    file_object = open(fic, "w")
+    xml.dom.ext.PrettyPrint(doc, file_object)
+    file_object.close()
 
 def ask_write_tag():
-       global tags
-       global options
-       for tag in tags.__dict__.keys() :
-               def_value = tags.__dict__[tag]
-               type_def_value = typeToolBox.getType(def_value)
-               value = raw_input(tag+' ? ['+str(def_value)+']: ')
-               if not value == '' :
-                       value = typeToolBox.cast(value,type_def_value)
-                       #value = string.replace(in_float,' ','')
-                       tags.__dict__[tag] = value
-       for opt in options.__dict__.keys() :
-               def_value = options.__dict__[opt]
-               type_def_value = typeToolBox.getType(def_value)
-               value = raw_input(opt+' ? ['+str(def_value)+']: ')
-               if not value == '' :
-                       value = typeToolBox.cast(value,type_def_value)
-                       #value = string.replace(in_float,' ','')
-                       options.__dict__[opt] = value
+    global tags
+    global options
+    for tag in tags.__dict__.keys() :
+        def_value = tags.__dict__[tag]
+        type_def_value = typeToolBox.getType(def_value)
+        value = raw_input(tag+' ? ['+str(def_value)+']: ')
+        if not value == '' :
+            value = typeToolBox.cast(value,type_def_value)
+            #value = string.replace(in_float,' ','')
+            tags.__dict__[tag] = value
+    for opt in options.__dict__.keys() :
+        def_value = options.__dict__[opt]
+        type_def_value = typeToolBox.getType(def_value)
+        value = raw_input(opt+' ? ['+str(def_value)+']: ')
+        if not value == '' :
+            value = typeToolBox.cast(value,type_def_value)
+            #value = string.replace(in_float,' ','')
+            options.__dict__[opt] = value
 
 def get_def_tags(doc):
-       for tag in doc.documentElement.getElementsByTagName('tag') :
-               name = tag.getAttribute('name')
-               value = typeToolBox.cast(tag.getAttribute('value'), tag.getAttribute('type'))
-               tags.__dict__[name] = value
-       for opt in doc.documentElement.getElementsByTagName('opt') :
-               name = opt.getAttribute('name')
-               value = typeToolBox.cast(opt.getAttribute('value'), opt.getAttribute('type'))
-               options.__dict__[name] = value
+    for tag in doc.documentElement.getElementsByTagName('tag') :
+        name = tag.getAttribute('name')
+        value = typeToolBox.cast(tag.getAttribute('value'), tag.getAttribute('type'))
+        tags.__dict__[name] = value
+    for opt in doc.documentElement.getElementsByTagName('opt') :
+        name = opt.getAttribute('name')
+        value = typeToolBox.cast(opt.getAttribute('value'), opt.getAttribute('type'))
+        options.__dict__[name] = value
 
 def rename_tag(old_tag,new_tag):
-       tag_list = tags.__dict__.keys()
-       if old_tag in tag_list:
-               tag_index = tag_list.index(old_tag)
-               tag_list.remove(old_tag)
-               tag_list.insert(tag_index,new_tag)
+    tag_list = tags.__dict__.keys()
+    if old_tag in tag_list:
+        tag_index = tag_list.index(old_tag)
+        tag_list.remove(old_tag)
+        tag_list.insert(tag_index,new_tag)
 
 def get_tag_value(tag):
-       value = tags.__dict__[tag]
-       type_value = typeToolBox.getType(value)
-       return value
+    value = tags.__dict__[tag]
+    type_value = typeToolBox.getType(value)
+    return value
 
 def get_opt_value(opt):
-       value = options.__dict__[opt]
-       type_value = typeToolBox.getType(value)
-       return value
+    value = options.__dict__[opt]
+    type_value = typeToolBox.getType(value)
+    return value
 
 def add_tag(tag,value):
-       tag_list = tags.__dict__.keys()
-       tag_list.insert(0,tag)
-       tags.__dict__[tag] = value
+    tag_list = tags.__dict__.keys()
+    tag_list.insert(0,tag)
+    tags.__dict__[tag] = value
 
 def add_opt(opt,value):
-       opt_list = options.__dict__.keys()
-       opt_list.insert(0,opt)
-       options.__dict__[opt] = value
+    opt_list = options.__dict__.keys()
+    opt_list.insert(0,opt)
+    options.__dict__[opt] = value
 
 def rename_file(src_dir,file,file_name):
-       if (file_name != "" and file_name != file):
-               print "Renaming: %s -> %s\n" % (file,file_name)
-               os.rename(src_dir+file, src_dir+file_name)
+    if (file_name != "" and file_name != file):
+        print "Renaming: %s -> %s\n" % (file,file_name)
+        os.rename(src_dir+file, src_dir+file_name)
 
 def filename_split(file_name):
-       filename_split = file_name.split('.')
-       if len(filename_split) > 0:
-               file_ext = filename_split[len(filename_split)-1]
-       else:
-               file_ext = ''
-       file_name_woext = '.'.join(filename_split[:-1])
-       return file_name_woext, file_ext
+    filename_split = file_name.split('.')
+    if len(filename_split) > 0:
+        file_ext = filename_split[len(filename_split)-1]
+    else:
+        file_ext = ''
+    file_name_woext = '.'.join(filename_split[:-1])
+    return file_name_woext, file_ext
 
 #def check_ext():
-       #if not ext_is_audio(file):
-               #file_name_woext = file_name
-               #if iswav(src_dir+file) :
-                       #file_ext = "wav"
-               #if isaiff(src_dir+file) :
-                       #file_ext = "aiff"
-               #if ismp3(src_dir+file) :
-                       #file_ext = "mp3"
-               #if isogg(src_dir+file) :
-                       #file_ext = "ogg"
-               #if isflac(src_dir+file) :
-                       #file_ext = "flac"
+    #if not ext_is_audio(file):
+        #file_name_woext = file_name
+        #if iswav(src_dir+file) :
+            #file_ext = "wav"
+        #if isaiff(src_dir+file) :
+            #file_ext = "aiff"
+        #if ismp3(src_dir+file) :
+            #file_ext = "mp3"
+        #if isogg(src_dir+file) :
+            #file_ext = "ogg"
+        #if isflac(src_dir+file) :
+            #file_ext = "flac"
 
 def clean_filename(file_name) :
-       file_name = re.sub("^[^\w]+","",filename) #trim the beginning
-       file_name = re.sub("[^\w]+$","",file_name) #trim the end
-       file_name = string.replace(file_name,' ','_')
-       file_name = re.sub("_+","_",file_name) #squeeze continuous _ to one _
-       file_name = re.sub("^[^\w]+","",file_name) #trim the beginning _
-       #file_name = string.capitalize(file_name)
-       return file_name
+    file_name = re.sub("^[^\w]+","",filename) #trim the beginning
+    file_name = re.sub("[^\w]+$","",file_name) #trim the end
+    file_name = string.replace(file_name,' ','_')
+    file_name = re.sub("_+","_",file_name) #squeeze continuous _ to one _
+    file_name = re.sub("^[^\w]+","",file_name) #trim the beginning _
+    #file_name = string.capitalize(file_name)
+    return file_name
 
 def name2tag(src_dir,file_name_woext,file_ext):
-       # get main tag
-       tag_list = file_name_woext.split('-')
-       tag_list_new = range(len(tag_list))
-
-       #for num_t in tag_list[0]:
-       #       if num_t == str(int(num_t)):
-       #               i_t = 1
-       #       else:
-
-       # computing main tags if many tags
-       if len(tag_list) > 1 :
-               i_t = 0
-               artist_tmp = string.replace(tag_list[i_t],' ','_')
-               artist_tmp = artist_tmp.split('_')
-               i = 0
-               for artist_word in artist_tmp :
-                       artist_tmp[i] = string.capitalize(artist_word)
-                       i = i+1
-               artist = '_'.join(artist_tmp[:])
-               artist = re.sub("[\_]+$","",artist) #trim the end
-               tag_list_new[i_t] = artist
-               artist = string.replace(artist,'_',' ')
-
-               i_t = i_t + 1
-               title = string.replace(tag_list[i_t],' ','_')
-               title = re.sub("^[\_]+","",title) #trim the beginning
-               title = re.sub("[\_]+$","",title) #trim the end
-               title_tmp = title.split('_')
-               title_tmp[0] = string.capitalize(title_tmp[0])
-               title = '_'.join(title_tmp[:])
-               tag_list_new[i_t] = title
-               title = string.replace(title,'_',' ')
-
-       # computing main tag if only one tag
-       if len(tag_list) == 1 :
-               artist = get_tag_value('ARTIST')
-               i_t = 0
-               title = string.replace(tag_list[i_t],' ','_')
-               title = re.sub("^[\_]+","",title) #trim the beginning
-               title = re.sub("[\_]+$","",title) #trim the end
-               title_tmp = title.split('_')
-               title_tmp[0] = string.capitalize(title_tmp[0])
-               title = '_'.join(title_tmp[:])
-               tag_list_new[i_t] = title
-               title = string.replace(title,'_',' ')
-
-       file_name_new = '-'.join(tag_list_new[:])
-
-       # renaming main source file
-       file_name = file_name_new+'.'+file_ext
-
-       return title,artist,file_name_new
+    # get main tag
+    tag_list = file_name_woext.split('-')
+    tag_list_new = range(len(tag_list))
+
+    #for num_t in tag_list[0]:
+    #   if num_t == str(int(num_t)):
+    #       i_t = 1
+    #   else:
+
+    # computing main tags if many tags
+    if len(tag_list) > 1 :
+        i_t = 0
+        artist_tmp = string.replace(tag_list[i_t],' ','_')
+        artist_tmp = artist_tmp.split('_')
+        i = 0
+        for artist_word in artist_tmp :
+            artist_tmp[i] = string.capitalize(artist_word)
+            i = i+1
+        artist = '_'.join(artist_tmp[:])
+        artist = re.sub("[\_]+$","",artist) #trim the end
+        tag_list_new[i_t] = artist
+        artist = string.replace(artist,'_',' ')
+
+        i_t = i_t + 1
+        title = string.replace(tag_list[i_t],' ','_')
+        title = re.sub("^[\_]+","",title) #trim the beginning
+        title = re.sub("[\_]+$","",title) #trim the end
+        title_tmp = title.split('_')
+        title_tmp[0] = string.capitalize(title_tmp[0])
+        title = '_'.join(title_tmp[:])
+        tag_list_new[i_t] = title
+        title = string.replace(title,'_',' ')
+
+    # computing main tag if only one tag
+    if len(tag_list) == 1 :
+        artist = get_tag_value('ARTIST')
+        i_t = 0
+        title = string.replace(tag_list[i_t],' ','_')
+        title = re.sub("^[\_]+","",title) #trim the beginning
+        title = re.sub("[\_]+$","",title) #trim the end
+        title_tmp = title.split('_')
+        title_tmp[0] = string.capitalize(title_tmp[0])
+        title = '_'.join(title_tmp[:])
+        tag_list_new[i_t] = title
+        title = string.replace(title,'_',' ')
+
+    file_name_new = '-'.join(tag_list_new[:])
+
+    # renaming main source file
+    file_name = file_name_new+'.'+file_ext
+
+    return title,artist,file_name_new
index 2bd4da0323e631bffbcdc740943b3fab69e41fa9..460e620257bb222b9ca0751fceb48c53c9028789 100755 (executable)
@@ -42,75 +42,75 @@ from audio_tools import *
 # Info, error
 # ===========
 if len(sys.argv) == 1 :
-       print "telemaster v"+str(version)+" (c) 2006-2008 Guillaume Pellerin <yomguy@altern.org>>"
-       print "version: "+str(version)
-       print "depends: python, python-xml, python-mutagen, sox, oggenc, flac, lame, normalize-audio, ecasound, wavbreaker, festival"
-       print "distributed under the terms of the GNU Public License v2.\n"
-       print """   This program is distributed in the hope that it will be useful,
+    print "telemaster v"+str(version)+" (c) 2006-2008 Guillaume Pellerin <yomguy@altern.org>>"
+    print "version: "+str(version)
+    print "depends: python, python-xml, python-mutagen, sox, oggenc, flac, lame, normalize-audio, ecasound, wavbreaker, festival"
+    print "distributed under the terms of the GNU Public License v2.\n"
+    print """   This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.\n"""
-       sys.exit('Type telemaster --help for help !\n')
+    sys.exit('Type telemaster --help for help !\n')
 
 elif sys.argv[1] == '--help':
-       print "TELEMETA:"
-       print "         backups, transcodes, tags and marks any audio content with metadata\n"
-       print "VERSION:"
-       print "         "+str(version)+'\n'
-       print "DEPENDS:"
-       print "         python, python-xml, python-mutagen, sox, oggenc, flac, lame, normalize-audio, ecasound, wavbreaker, festival\n"
-       print "COPYRIGHT:"
-       print "         Copyright (c) 2006-2008 Guillaume Pellerin <yomguy@altern.org>\n"
-       print "LICENSE:"
-       print "         distributed under the terms of the GNU Public License v2.\n"
-       print "USAGE:"
-       print "         telemaster [OPTIONS] COLLECTION [OPTIONS] [MEDIA] \n"
-       print "COLLECTION:"
-       print "         - the name of collection you want to create"
-       print "         - the name of collection you want to backup or process into\n"
-       print "MEDIA:"
-       print "         - an audio file"
-       print "         - a directory when the --album option is given\n"
-       print "OPTIONS:"
-       print "         --create       creates a collection repository"
-       print "         --backup       backups and transcodes wave files to a collection"
-       print "         --album        proccesses an entire directory (one shot album)"
-       print "         --from-xml     takes tags and opts in original xml source"
-       print "         --force        forces file conversion"
-       print "         --add-tag      add a tag to a collection"
-       print '         --par2         forces security "par2" key creation'
-       print "         --all-default  chooses default argument for all question"
-       print '         --recover      check an repair the backuped media with the previously created "par2" security key'
-       print "         --rsync        synchronizes a collection with a remote server repository (ssh+rsync)"
-       print "         --erase        erases a collection (flac, ogg, mp3 only !)"
-       print "         --version      gives the program version"
-       print "         --help         gives help page\n"
-       print "EXAMPLES:"       
-       print "         telemaster --create my_collection"
-       print "         telemaster --backup my_collection file.wav"
-       print "         telemaster --backup my_collection --album /path/to/directory/"
-       print "         telemaster --backup my_collection --album --par2 --rsync /path/to/directory/"
-       print "         telemaster --backup my_collection --album --par2 --rsync --force /path/to/directory/\n"
-       print "AUTHOR:"
-       print "         Guillaume Pellerin <yomguy@altern.org>\n"
-       print "URL:"
-       print "         http://svn.parisson.org/telemaster\n"
-       print 'IMPORTANT:'
-       print "         With the '--album' option, it supposed that all your wav files in the directory are named respectively to this scheme :"
-       print "            artist-title[-album-date-genre-description][.wav]"
-       print "         where the 'artist' and 'title' tags are necessary needed."
-       print "         Tags between [] are optional main tags.\n"
-       print "FOR MORE INFORMATIONS :"
-       print "         - read the README file"
-       print "         - go to http://svn.parisson.org/telemaster"
-       sys.exit('         - email me !\n')
+    print "TELEMETA:"
+    print "         backups, transcodes, tags and marks any audio content with metadata\n"
+    print "VERSION:"
+    print "         "+str(version)+'\n'
+    print "DEPENDS:"
+    print "         python, python-xml, python-mutagen, sox, oggenc, flac, lame, normalize-audio, ecasound, wavbreaker, festival\n"
+    print "COPYRIGHT:"
+    print "         Copyright (c) 2006-2008 Guillaume Pellerin <yomguy@altern.org>\n"
+    print "LICENSE:"
+    print "         distributed under the terms of the GNU Public License v2.\n"
+    print "USAGE:"
+    print "         telemaster [OPTIONS] COLLECTION [OPTIONS] [MEDIA] \n"
+    print "COLLECTION:"
+    print "         - the name of collection you want to create"
+    print "         - the name of collection you want to backup or process into\n"
+    print "MEDIA:"
+    print "         - an audio file"
+    print "         - a directory when the --album option is given\n"
+    print "OPTIONS:"
+    print "         --create       creates a collection repository"
+    print "         --backup       backups and transcodes wave files to a collection"
+    print "         --album        proccesses an entire directory (one shot album)"
+    print "         --from-xml     takes tags and opts in original xml source"
+    print "         --force        forces file conversion"
+    print "         --add-tag      add a tag to a collection"
+    print '         --par2         forces security "par2" key creation'
+    print "         --all-default  chooses default argument for all question"
+    print '         --recover      check an repair the backuped media with the previously created "par2" security key'
+    print "         --rsync        synchronizes a collection with a remote server repository (ssh+rsync)"
+    print "         --erase        erases a collection (flac, ogg, mp3 only !)"
+    print "         --version      gives the program version"
+    print "         --help         gives help page\n"
+    print "EXAMPLES:"   
+    print "         telemaster --create my_collection"
+    print "         telemaster --backup my_collection file.wav"
+    print "         telemaster --backup my_collection --album /path/to/directory/"
+    print "         telemaster --backup my_collection --album --par2 --rsync /path/to/directory/"
+    print "         telemaster --backup my_collection --album --par2 --rsync --force /path/to/directory/\n"
+    print "AUTHOR:"
+    print "         Guillaume Pellerin <yomguy@altern.org>\n"
+    print "URL:"
+    print "         http://svn.parisson.org/telemaster\n"
+    print 'IMPORTANT:'
+    print "         With the '--album' option, it supposed that all your wav files in the directory are named respectively to this scheme :"
+    print "            artist-title[-album-date-genre-description][.wav]"
+    print "         where the 'artist' and 'title' tags are necessary needed."
+    print "         Tags between [] are optional main tags.\n"
+    print "FOR MORE INFORMATIONS :"
+    print "         - read the README file"
+    print "         - go to http://svn.parisson.org/telemaster"
+    sys.exit('         - email me !\n')
 
 elif sys.argv[1] == '--version':
-       sys.exit('Version: '+str(version))
+    sys.exit('Version: '+str(version))
 
 else :
-       print "telemaster v"+str(version)+" (c) 2006-2007 Guillaume Pellerin <yomguy@altern.org>"
-       print """   This program is distributed in the hope that it will be useful,
+    print "telemaster v"+str(version)+" (c) 2006-2007 Guillaume Pellerin <yomguy@altern.org>"
+    print """   This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.\n"""
@@ -127,128 +127,128 @@ collection = consts.Collection()
 
 # Get arguments
 if '--recover' in argv :
-       index = argv.index('--recover')
-       audio_tools.recover_par_key(argv[index+1]+os.sep)
-       sys.exit('Directory successfully recovered !')
+    index = argv.index('--recover')
+    audio_tools.recover_par_key(argv[index+1]+os.sep)
+    sys.exit('Directory successfully recovered !')
 
 if '--erase' in argv :
-       type_list = tag_tools.get_consts_value('type_list')
-       type_list = type_list.split(',')
-       index = argv.index('--erase')
-       audio_tools.clean_directory(argv[index+1],type_list)
-       sys.exit('Media directories successfully cleaned !')
+    type_list = tag_tools.get_consts_value('type_list')
+    type_list = type_list.split(',')
+    index = argv.index('--erase')
+    audio_tools.clean_directory(argv[index+1],type_list)
+    sys.exit('Media directories successfully cleaned !')
 
 if '--force' in argv :
-       print 'Warning: forcing file transfert and conversion (no audio test) !\n'
-       mode_force = True
+    print 'Warning: forcing file transfert and conversion (no audio test) !\n'
+    mode_force = True
 else :
-       mode_force = False
+    mode_force = False
 
 if '--album' in argv :
-       print 'Warning: album (recusive) mode...\n'
-       mode_album = True
+    print 'Warning: album (recusive) mode...\n'
+    mode_album = True
 else :
-       mode_album = False
+    mode_album = False
 
 if '--backup' in argv :
-       print 'Warning: backup mode...\n'
-       mode_backup = True
+    print 'Warning: backup mode...\n'
+    mode_backup = True
 else :
-       mode_backup = False
+    mode_backup = False
 
 if '--tags' in argv :
-       print 'Warning: making tags...\n'
-       mode_tags = True
+    print 'Warning: making tags...\n'
+    mode_tags = True
 else :
-       mode_tags = False
+    mode_tags = False
 
 if '--add-tag' in argv :
-       print 'Warning: adding tags...\n'
-       mode_add_tag = True
+    print 'Warning: adding tags...\n'
+    mode_add_tag = True
 else :
-       mode_add_tag = False
+    mode_add_tag = False
 
 if '--from-xml' in argv :
-       print 'Warning: processing from XML...\n'
-       mode_from_xml = True
+    print 'Warning: processing from XML...\n'
+    mode_from_xml = True
 else :
-       mode_from_xml = False
+    mode_from_xml = False
 
 if '--clean-strings' in argv :
-       print 'Warning: Cleaning strings...\n'
-       mode_clean = True
+    print 'Warning: Cleaning strings...\n'
+    mode_clean = True
 else :
-       mode_clean = False
+    mode_clean = False
 
 if '--all-default' in argv :
-       print 'Warning: default mode enabled...\n'
-       mode_default = True
+    print 'Warning: default mode enabled...\n'
+    mode_default = True
 else :
-       mode_default = False
+    mode_default = False
 
 if '--par2' in argv :
-       print 'Warning: creates par2 security keys...\n'
-       mode_par2 = True
+    print 'Warning: creates par2 security keys...\n'
+    mode_par2 = True
 else :
-       mode_par2 = False
+    mode_par2 = False
 
 if '--rsync' in argv :
-       print 'Warning: synchronize with remote host...\n'
-       mode_rsync = True
+    print 'Warning: synchronize with remote host...\n'
+    mode_rsync = True
 else :
-       mode_rsync = False
+    mode_rsync = False
 
 if '--create' in argv :
-       print 'Warning: creating a telemaster collection...\n'
-       mode_create = True
+    print 'Warning: creating a telemaster collection...\n'
+    mode_create = True
 else :
-       mode_create = False
+    mode_create = False
 
 # Creates user default dir
 user_dir = tag_tools.get_consts_value('user_dir')
 if not os.path.exists(user_dir):
-       os.mkdir(user_dir)
+    os.mkdir(user_dir)
 
 # Create or check the databse config
 default_collection_xml = tag_tools.get_consts_value('default_collection_xml')
 if not os.access(default_collection_xml, os.F_OK) :
-       tag_tools.write_collection_consts(default_collection_xml)
+    tag_tools.write_collection_consts(default_collection_xml)
 
 # Create the collection
 if mode_create :
-       if len(argv) == 3 :
-               index = argv.index('--create')
-               collection_name = argv[index+1]
-               tag_tools.ask_write_collection(collection_name)
-               default_collection_xml = tag_tools.get_consts_value('default_collection_xml')
-               collection_dir = tag_tools.get_consts_value('collection_dir')
-               if not os.path.exists(collection_dir):
-                       os.mkdir(collection_dir)
-               else :
-                               sys.exit('ERROR: the collection '+collection_name+' already exists')
-               tag_tools.write_collection_consts(default_collection_xml)
-               tag_tools.write_collection_consts(collection_dir+os.sep+collection_name+'.xml')
-               # Parses collection data
-               sys.exit("\nCollection created ! You can now --backup media in it...")
-       else :
-               sys.exit("ERROR: no collection name given... : give a name for your collection.")
+    if len(argv) == 3 :
+        index = argv.index('--create')
+        collection_name = argv[index+1]
+        tag_tools.ask_write_collection(collection_name)
+        default_collection_xml = tag_tools.get_consts_value('default_collection_xml')
+        collection_dir = tag_tools.get_consts_value('collection_dir')
+        if not os.path.exists(collection_dir):
+            os.mkdir(collection_dir)
+        else :
+                sys.exit('ERROR: the collection '+collection_name+' already exists')
+        tag_tools.write_collection_consts(default_collection_xml)
+        tag_tools.write_collection_consts(collection_dir+os.sep+collection_name+'.xml')
+        # Parses collection data
+        sys.exit("\nCollection created ! You can now --backup media in it...")
+    else :
+        sys.exit("ERROR: no collection name given... : give a name for your collection.")
 # Backup into the collection
 elif mode_backup :
-       # Check syntax
-       if not os.path.exists(sys.argv[len(sys.argv)-1]) :
-               sys.exit("ERROR: no such media... : give a directory or a file as last argument.")
-       index = argv.index('--backup')
-       collection_name = argv[index+1]
-       collection_xml = user_dir+os.sep+collection_name+'.xml'
-       if not os.path.exists(collection_xml) :
-               sys.exit("This collection doesn't exists. Create it first ! (--create)")
-       else :
-               doc = xml.dom.minidom.parse(user_dir+os.sep+collection_name+'.xml')
-               print "Parsing collection XML file..."
-               tag_tools.get_collection_consts(doc)
-               collection_dir = tag_tools.get_consts_value('collection_dir')
-               print "OK\n"
-       
+    # Check syntax
+    if not os.path.exists(sys.argv[len(sys.argv)-1]) :
+        sys.exit("ERROR: no such media... : give a directory or a file as last argument.")
+    index = argv.index('--backup')
+    collection_name = argv[index+1]
+    collection_xml = user_dir+os.sep+collection_name+'.xml'
+    if not os.path.exists(collection_xml) :
+        sys.exit("This collection doesn't exists. Create it first ! (--create)")
+    else :
+        doc = xml.dom.minidom.parse(user_dir+os.sep+collection_name+'.xml')
+        print "Parsing collection XML file..."
+        tag_tools.get_collection_consts(doc)
+        collection_dir = tag_tools.get_consts_value('collection_dir')
+        print "OK\n"
+    
 
 # Creates source dir
 src_dir = collection_dir+os.sep+'src'+os.sep
@@ -258,7 +258,7 @@ if not os.path.exists(src_dir) :
 # Creates user default tag/opt file and parse it
 default_tag_xml = tag_tools.get_consts_value('default_tag_xml')
 if not os.access(default_tag_xml, os.F_OK) :
-       tag_tools.write_def_tags(default_tag_xml)
+    tag_tools.write_def_tags(default_tag_xml)
 
 # Parses tag data
 doc = xml.dom.minidom.parse(default_tag_xml)
@@ -269,192 +269,192 @@ file_master_list = range(1)
 
 # File listing for album mode
 if mode_album :
-       master_dir = argv[len_argv-1]+os.sep
-       if os.path.isdir(master_dir):
-               file_master_list = os.listdir(master_dir)
-       else:
-               sys.exit('Please give a directory path for the last argument (album mode)...')
+    master_dir = argv[len_argv-1]+os.sep
+    if os.path.isdir(master_dir):
+        file_master_list = os.listdir(master_dir)
+    else:
+        sys.exit('Please give a directory path for the last argument (album mode)...')
 # File listing in normal mode
 else :
-       master_dir = argv[len_argv-1]
-       if os.path.isdir(master_dir):
-               file_master_list = os.listdir(master_dir)
-       elif os.path.isfile(master_dir):
-               master_dir = os.getcwd()+os.sep
-               file_master_list[0] = str(argv[len_argv-1])
-       else:
-               sys.exit('Please give a directory or a file path for the last argument...')
+    master_dir = argv[len_argv-1]
+    if os.path.isdir(master_dir):
+        file_master_list = os.listdir(master_dir)
+    elif os.path.isfile(master_dir):
+        master_dir = os.getcwd()+os.sep
+        file_master_list[0] = str(argv[len_argv-1])
+    else:
+        sys.exit('Please give a directory or a file path for the last argument...')
 
 # Asks tags if mode album
 if mode_album and not mode_from_xml :
-       tag_tools.ask_write_tag()
-       tag_tools.write_def_tags(default_tag_xml)
+    tag_tools.ask_write_tag()
+    tag_tools.write_def_tags(default_tag_xml)
 
 
 # Main loop
 # =========
 
 for file in file_master_list :
-       if isaudio(master_dir+os.sep+file) or (mode_force and ext_is_audio(master_dir+os.sep+file)):
-               print '\n'
-               print '+------------------------------------------------------------------------------------'
-               print '| Processing '+master_dir+file
-               print '+------------------------------------------------------------------------------------'
-
-               # Init
-               file_name = file
-               file_in = file
-               dir_in = src_dir
-
-               # Backup mode
-               if mode_backup :
-                       album_dir_tmp = tag_tools.get_tag_value('ALBUM')
-                       album_dir = collection_dir+os.sep+'src'+os.sep+album_dir_tmp+os.sep
-                       if not os.path.exists(album_dir) :
-                               os.mkdir(album_dir)
-                       if isaudio(master_dir+file) and ( not audio_tools.compare_md5_key(master_dir+file,album_dir+file) or mode_force ) :
-                               print 'Copying files into: '+album_dir+''
-                               os.system('cp -ra "'+master_dir+file+'" '+album_dir)
-                               print 'OK\n'
-                       #else:
-                       #       sys.exit(master_dir+file+' is not an audio file...')
-                       src_dir = album_dir
-                       dir_in = src_dir
-               else :
-                       dir_in = master_dir
-
-               # Creating par2 key
-               par_key_value = tag_tools.get_opt_value('par_key')
-               if mode_par2 and par_key_value :
-                       # Creating "par2" security keys
-                       print 'Creating "par2" security keys...'
-                       audio_tools.create_par_key(dir_in,file)
-
-               # Name, extension
-               file_name_woext, file_ext = tag_tools.filename_split(file)
-               tag_tools.add_tag('ORIGINAL_FILENAME',file)
-               tag_tools.add_tag('ORIGINAL_TYPE',file_ext)
-
-               # Get original XML
-               if mode_from_xml :
-                       doc = xml.dom.minidom.parse(dir_in+file_name+'.xml')
-                       tag_tools.get_def_tags(doc)
-
-               # Album mode
-               if mode_album :
-                       # Getting file main tags
-                       title,artist,file_name_new = tag_tools.name2tag(dir_in,file_name_woext,file_ext)
-                       tag_tools.add_tag('ARTIST',artist)
-                       tag_tools.add_tag('TITLE',title)
-                       print "Artist: "+artist
-                       print "Title: "+title+'\n'
-                       #tag_tools.write_def_tags(default_tag_xml)
-
-               # Asks for new metadata and write default user tags/options
-               if not mode_default and not mode_from_xml and not mode_album:
-                       tag_tools.ask_write_tag()
-               tag_tools.write_def_tags(default_tag_xml)
-
-
-
-               # Clean mode
-               if mode_clean :
-                       file_name = tag_tools.clean_filename(file_name)
-                       # Renaming backup source file
-                       tag_tools.rename_file(dir_in,dir_out,file,file_name)
-
-               # Writing xml data
-               if not mode_from_xml :
-                       print 'Writing xml data...'
-                       tag_tools.write_def_tags(dir_in+file_name+'.xml')
-
-               # Getting encoding types
-               enc_types = tag_tools.get_opt_value('enc_types')
-               enc_types = string.replace(enc_types,' ','').split(',')
-
-               # Checking existing file
-               for enc_type in enc_types:
-                       dir_out = master_dir+enc_type+os.sep
-                       file_out = file_name_woext+'.'+enc_type
-                       if not os.path.exists(dir_out+file_out):
-                               new_track = True
-                       else :
-                               new_track = False
-
-               # Decoding to a new 16 bits wav file if needed
-               if not iswav16(dir_in+file_in) and new_track:
-                       print "Decoding to wav 16 bits..."
-                       audio_tools.decode(dir_in+file_in,file_ext)
-                       # Important !
-                       type_list = tag_tools.get_consts_value('type_list')
-                       type_list = type_list.split(',')
-                       if not file_ext in type_list :
-                               file_in=file_in+'.wav'
-
-               # Normalize file if needed
-               normalize_value = tag_tools.get_opt_value('normalize')
-               if normalize_value:
-                       print 'Normalizing...'
-                       audio_tools.normalize(dir_in+file_in)
-
-               # Marking
-               audio_marking_value = tag_tools.get_opt_value('audio_marking')
-               auto_audio_marking = tag_tools.get_opt_value('auto_audio_marking')
-               audio_marking_file = tag_tools.get_opt_value('audio_marking_file')
-               audio_marking_timeline = tag_tools.get_opt_value('audio_marking_timeline')
-               audio_marking_timeline = string.replace(audio_marking_timeline,' ','').split(',')
-               if audio_marking_value and new_track:
-                       if auto_audio_marking:
-                               print 'Creating track audio mark...'
-                               audio_marking.make_auto_mark(dir_in,file_in)
-                               audio_marking_file = dir_in+file_in+'_mark.wav'
-                       print 'Marking '+file_in+' with '+audio_marking_file+'...'
-                       audio_marking.mark_audio(dir_in,file_in,audio_marking_file,audio_marking_timeline)
-                       file_in = 'marked_'+file_in
-
-               # Encoding loop
-               for enc_type in enc_types:
-                       dir_out = collection_dir+os.sep+enc_type+os.sep
-                       if not os.path.exists(dir_out):
-                               os.mkdir(dir_out)
-                       album = tag_tools.get_tag_value('ALBUM')
-                       dir_out = collection_dir+os.sep+enc_type+os.sep+album+os.sep
-                       if not os.path.exists(dir_out):
-                               os.mkdir(dir_out)
-                       file_out = file_name_woext+'.'+enc_type
-
-                       if not os.path.exists(dir_out+file_out) or mode_force :
-                               print 'Converting '+dir_in+file_name+' to '+enc_type+'...'
-                               # Encoding
-                               print 'Encoding file...'
-                               audio_tools.encode(enc_type,dir_in,file_in,dir_out,file_out)
-                               print 'Writing tags to encoded file...'
-                               tag_tools.write_tags(enc_type,dir_out,file_out)
-
-                       else :
-                               print dir_out+file_out+' already exists !'
-                               if mode_tags :
-                                       print 'But writing tags to encoded file...'
-                                       tag_tools.write_tags(enc_type,dir_out,file_out)
-
-               # Remove tmp files
-               file_list = os.listdir(src_dir)
-               for file in file_list:
-                       if 'marked_' in file or '.ewf' in file or '_mark.wav' in file or file_ext+'.wav' in file:
-                               os.system('rm "'+dir_in+file+'"')
-
-       else :
-               print file+" is not an audio file !"
+    if isaudio(master_dir+os.sep+file) or (mode_force and ext_is_audio(master_dir+os.sep+file)):
+        print '\n'
+        print '+------------------------------------------------------------------------------------'
+        print '| Processing '+master_dir+file
+        print '+------------------------------------------------------------------------------------'
+
+        # Init
+        file_name = file
+        file_in = file
+        dir_in = src_dir
+
+        # Backup mode
+        if mode_backup :
+            album_dir_tmp = tag_tools.get_tag_value('ALBUM')
+            album_dir = collection_dir+os.sep+'src'+os.sep+album_dir_tmp+os.sep
+            if not os.path.exists(album_dir) :
+                os.mkdir(album_dir)
+            if isaudio(master_dir+file) and ( not audio_tools.compare_md5_key(master_dir+file,album_dir+file) or mode_force ) :
+                print 'Copying files into: '+album_dir+''
+                os.system('cp -ra "'+master_dir+file+'" '+album_dir)
+                print 'OK\n'
+            #else:
+            #   sys.exit(master_dir+file+' is not an audio file...')
+            src_dir = album_dir
+            dir_in = src_dir
+        else :
+            dir_in = master_dir
+
+        # Creating par2 key
+        par_key_value = tag_tools.get_opt_value('par_key')
+        if mode_par2 and par_key_value :
+            # Creating "par2" security keys
+            print 'Creating "par2" security keys...'
+            audio_tools.create_par_key(dir_in,file)
+
+        # Name, extension
+        file_name_woext, file_ext = tag_tools.filename_split(file)
+        tag_tools.add_tag('ORIGINAL_FILENAME',file)
+        tag_tools.add_tag('ORIGINAL_TYPE',file_ext)
+
+        # Get original XML
+        if mode_from_xml :
+            doc = xml.dom.minidom.parse(dir_in+file_name+'.xml')
+            tag_tools.get_def_tags(doc)
+
+        # Album mode
+        if mode_album :
+            # Getting file main tags
+            title,artist,file_name_new = tag_tools.name2tag(dir_in,file_name_woext,file_ext)
+            tag_tools.add_tag('ARTIST',artist)
+            tag_tools.add_tag('TITLE',title)
+            print "Artist: "+artist
+            print "Title: "+title+'\n'
+            #tag_tools.write_def_tags(default_tag_xml)
+
+        # Asks for new metadata and write default user tags/options
+        if not mode_default and not mode_from_xml and not mode_album:
+            tag_tools.ask_write_tag()
+        tag_tools.write_def_tags(default_tag_xml)
+
+
+
+        # Clean mode
+        if mode_clean :
+            file_name = tag_tools.clean_filename(file_name)
+            # Renaming backup source file
+            tag_tools.rename_file(dir_in,dir_out,file,file_name)
+
+        # Writing xml data
+        if not mode_from_xml :
+            print 'Writing xml data...'
+            tag_tools.write_def_tags(dir_in+file_name+'.xml')
+
+        # Getting encoding types
+        enc_types = tag_tools.get_opt_value('enc_types')
+        enc_types = string.replace(enc_types,' ','').split(',')
+
+        # Checking existing file
+        for enc_type in enc_types:
+            dir_out = master_dir+enc_type+os.sep
+            file_out = file_name_woext+'.'+enc_type
+            if not os.path.exists(dir_out+file_out):
+                new_track = True
+            else :
+                new_track = False
+
+        # Decoding to a new 16 bits wav file if needed
+        if not iswav16(dir_in+file_in) and new_track:
+            print "Decoding to wav 16 bits..."
+            audio_tools.decode(dir_in+file_in,file_ext)
+            # Important !
+            type_list = tag_tools.get_consts_value('type_list')
+            type_list = type_list.split(',')
+            if not file_ext in type_list :
+                file_in=file_in+'.wav'
+
+        # Normalize file if needed
+        normalize_value = tag_tools.get_opt_value('normalize')
+        if normalize_value:
+            print 'Normalizing...'
+            audio_tools.normalize(dir_in+file_in)
+
+        # Marking
+        audio_marking_value = tag_tools.get_opt_value('audio_marking')
+        auto_audio_marking = tag_tools.get_opt_value('auto_audio_marking')
+        audio_marking_file = tag_tools.get_opt_value('audio_marking_file')
+        audio_marking_timeline = tag_tools.get_opt_value('audio_marking_timeline')
+        audio_marking_timeline = string.replace(audio_marking_timeline,' ','').split(',')
+        if audio_marking_value and new_track:
+            if auto_audio_marking:
+                print 'Creating track audio mark...'
+                audio_marking.make_auto_mark(dir_in,file_in)
+                audio_marking_file = dir_in+file_in+'_mark.wav'
+            print 'Marking '+file_in+' with '+audio_marking_file+'...'
+            audio_marking.mark_audio(dir_in,file_in,audio_marking_file,audio_marking_timeline)
+            file_in = 'marked_'+file_in
+
+        # Encoding loop
+        for enc_type in enc_types:
+            dir_out = collection_dir+os.sep+enc_type+os.sep
+            if not os.path.exists(dir_out):
+                os.mkdir(dir_out)
+            album = tag_tools.get_tag_value('ALBUM')
+            dir_out = collection_dir+os.sep+enc_type+os.sep+album+os.sep
+            if not os.path.exists(dir_out):
+                os.mkdir(dir_out)
+            file_out = file_name_woext+'.'+enc_type
+
+            if not os.path.exists(dir_out+file_out) or mode_force :
+                print 'Converting '+dir_in+file_name+' to '+enc_type+'...'
+                # Encoding
+                print 'Encoding file...'
+                audio_tools.encode(enc_type,dir_in,file_in,dir_out,file_out)
+                print 'Writing tags to encoded file...'
+                tag_tools.write_tags(enc_type,dir_out,file_out)
+
+            else :
+                print dir_out+file_out+' already exists !'
+                if mode_tags :
+                    print 'But writing tags to encoded file...'
+                    tag_tools.write_tags(enc_type,dir_out,file_out)
+
+        # Remove tmp files
+        file_list = os.listdir(src_dir)
+        for file in file_list:
+            if 'marked_' in file or '.ewf' in file or '_mark.wav' in file or file_ext+'.wav' in file:
+                os.system('rm "'+dir_in+file+'"')
+
+    else :
+        print file+" is not an audio file !"
 
 # Sync to the remote server
 if mode_rsync :
-       net_backup_host = tag_tools.get_consts_value('net_backup_host')
-       net_backup_dir = tag_tools.get_consts_value('net_backup_dir')
-       print '+------------------------------------------------------------------------------------'
-       print '| Synchronizing with '+net_backup_host
-       print '+------------------------------------------------------------------------------------'
-       os.system('rsync -avzLp --delete --rsh="ssh -l '+os.environ["USER"]+'" '+collection_dir+' '+os.environ["USER"]+'@'+net_backup_host+':'+net_backup_dir)
-       print "Collection Synchronized !"
+    net_backup_host = tag_tools.get_consts_value('net_backup_host')
+    net_backup_dir = tag_tools.get_consts_value('net_backup_dir')
+    print '+------------------------------------------------------------------------------------'
+    print '| Synchronizing with '+net_backup_host
+    print '+------------------------------------------------------------------------------------'
+    os.system('rsync -avzLp --delete --rsh="ssh -l '+os.environ["USER"]+'" '+collection_dir+' '+os.environ["USER"]+'@'+net_backup_host+':'+net_backup_dir)
+    print "Collection Synchronized !"
 
 
 # End