@@ -41,7 +41,7 @@ def __init__(self) -> None:
4141 },
4242 "aiff_high" : {
4343 "codec" : 'pcm_s24be' , # 24 Bit PCM Big Endian
44- "sampling_rate" : '96000 ' , # 96 kHz
44+ "sampling_rate" : '48000 ' , # 48 kHz
4545 "bit_rate" : None ,
4646 "custom" : [],
4747 },
@@ -53,14 +53,14 @@ def __init__(self) -> None:
5353 },
5454 "wav_high" : {
5555 "codec" : 'pcm_s24le' , # 24 Bit PCM Little Endian
56- "sampling_rate" : '96000 ' , # 96 kHz
56+ "sampling_rate" : '48000 ' , # 48 kHz
5757 "bit_rate" : None ,
5858 "custom" : [],
5959 },
6060 }
6161
6262 # all ffmpeg arguments: https://gist.github.com/tayvano/6e2d456a9897f55025e25035478a3a50
63- def generate_ffmpeg_arguments (self , in_audio : PureWindowsPath , out_audio : PureWindowsPath , in_cover : PureWindowsPath or None = None , quality = 'normal' , verbose = False ) -> list :
63+ def generate_ffmpeg_arguments (self , in_audio : Path , out_audio : Path , in_cover : Path or None = None , quality = 'normal' , verbose = False ) -> list :
6464 in_format = in_audio .suffix .replace ('.' , '' )
6565 out_format = out_audio .suffix .replace ('.' , '' )
6666 if out_format not in self .allowed_formats :
@@ -114,52 +114,60 @@ def save_print(self, s):
114114 self .output += "\n "
115115 print (s )
116116
117- def generate_file_tree (self , path , mirror_file_structure = True ):
118- root_path_parent = str (Path (path ).parent .resolve ())
119- root_target_folder_name = path [len (root_path_parent )+ 1 :]
120- converted_files_dir_abs = f"{ root_path_parent } /{ root_target_folder_name } _{ self .settings ['converted_files_dir_name' ]} -{ int (datetime .utcnow ().timestamp ())} "
121- Path (converted_files_dir_abs ).mkdir (parents = True , exist_ok = True )
122-
123- summary = {
124- "skipped" : 0 ,
125- "converted" : 0 ,
126- "errors" : 0 ,
127- "total" : 0
128- }
129-
130- for root , subdirs , files in os .walk (path ):
131- abs_root = Path (root )
132- relative_root = root .replace (path , '' )
133- converted_files_subdir_abs = f"{ converted_files_dir_abs } /{ relative_root } "
134- Path (converted_files_subdir_abs ).mkdir (parents = True , exist_ok = True )
135- self .save_print (
136- f"INFO: created: { converted_files_subdir_abs } , path includes { len (files )} target files" )
137-
138- if files and len (files ) > 0 :
139- for file in files :
140- summary ["total" ] += 1
141- if self .is_file_type_correct (file ):
142- self .save_print (f"\t * { file } " )
143- if (self .settings ['native_ffmpeg' ]):
144- converted_without_errors = self .convert_file_to_wav_with_ffmpeg (
145- Path .joinpath (abs_root , file ), converted_files_subdir_abs )
146- else :
147- converted_without_errors = self .convert_file_to_wav_with_pydub (
148- Path .joinpath (abs_root , file ), converted_files_subdir_abs )
117+ def generate_file_tree (self , path , mirror_file_structure = True , is_file = True ):
118+ root_path_parent = Path (path ).parent .resolve ()
119+ root_target_folder_name = path [len (str (root_path_parent ))+ 1 :]
120+ if is_file :
121+ file = Path (path ).name
122+ self .save_print (f"\t * { file } " )
123+ if self .is_file_type_correct (file ):
124+ converted_without_errors = self .convert_file_to_wav_with_ffmpeg (Path (path ), str (root_path_parent ))
125+ else :
126+ self .save_print (f"\t INFO: ignoring file { file } " )
127+ else :
128+ converted_files_dir_abs = f"{ root_path_parent } /{ root_target_folder_name } _{ self .settings ['converted_files_dir_name' ]} -{ int (datetime .utcnow ().timestamp ())} "
129+ Path (converted_files_dir_abs ).mkdir (parents = True , exist_ok = True )
130+
131+ summary = {
132+ "skipped" : 0 ,
133+ "converted" : 0 ,
134+ "errors" : 0 ,
135+ "total" : 0 ,
136+ }
149137
150- if converted_without_errors :
151- summary ["converted" ] += 1
138+ for root , subdirs , files in os .walk (path ):
139+ abs_root = Path (root )
140+ relative_root = str (root ).replace (path , '' )
141+ converted_files_subdir_abs = f"{ converted_files_dir_abs } /{ relative_root } "
142+ Path (converted_files_subdir_abs ).mkdir (parents = True , exist_ok = True )
143+ self .save_print (
144+ f"INFO: created: { converted_files_subdir_abs } , path includes { len (files )} target files" )
145+
146+ if files and len (files ) > 0 :
147+ for file in files :
148+ summary ["total" ] += 1
149+ if self .is_file_type_correct (file ):
150+ self .save_print (f"\t * { file } " )
151+ if (self .settings ['native_ffmpeg' ]):
152+ converted_without_errors = self .convert_file_to_wav_with_ffmpeg (
153+ Path .joinpath (abs_root , file ), converted_files_subdir_abs )
154+ else :
155+ converted_without_errors = self .convert_file_to_wav_with_pydub (
156+ Path .joinpath (abs_root , file ), converted_files_subdir_abs )
157+
158+ if converted_without_errors :
159+ summary ["converted" ] += 1
160+ else :
161+ summary ["errors" ] += 1
152162 else :
153- summary ["errors" ] += 1
154- else :
155- self .save_print (f"\t INFO: ignoring file { file } " )
156- summary ["skipped" ] += 1
157-
158- # out file save
159- with open (f'{ converted_files_dir_abs } /summary.txt' , mode = 'w' , encoding = "utf-8" ) as f :
160- f .write (
161- f"---------------SUMMARY----------------\n { summary } \n DATE: { datetime .utcnow ()} \n -------------SUMMARY END--------------\n \n { self .output } " )
162- print (f'{ converted_files_dir_abs } /summary.txt' )
163+ self .save_print (f"\t INFO: ignoring file { file } " )
164+ summary ["skipped" ] += 1
165+
166+ # out file save
167+ with open (f'{ converted_files_dir_abs } /summary.txt' , mode = 'w' , encoding = "utf-8" ) as f :
168+ f .write (
169+ f"---------------SUMMARY----------------\n { summary } \n DATE: { datetime .utcnow ()} \n -------------SUMMARY END--------------\n \n { self .output } " )
170+ print (f'{ converted_files_dir_abs } /summary.txt' )
163171
164172 def is_file_type_correct (self , file ) -> bool :
165173 file_str = str (file )
0 commit comments