def compress_project(self, set_hash=True): Log("Compressing project..", "notice") # Clean out temp project if it exists Log("Cleaning out temp folder") Folder.delete(self.get_temp_dir()) # Extract cache if it exists if self.is_cached(): Tar.extract(filepath=self.get_cache_file(), destination=self.get_temp_dir().parent) else: Folder.create(self.get_temp_dir()) # Create folders if they dont exist self.create_required_folders(temp=True, clean=False) # Copy from 'extracted_songs' to 'temp' if not self.move_extracted_song_to_temp(): Log("Could not move project from 'extracted_songs' to 'temp'..", "warning") Log.press_enter() return False # Compress project to *.lof Tar.compress(folderpath=self.get_temp_dir(), destination=self.get_cache_file()) if set_hash: # Set new local hash Hash.set_project_hash(self, Hash.create_hash_from_project(self)) return True
def create_required_folders(self, temp=False, clean=True): # 'temp=True' will focus on the temp/<song> directory # 'temp=False' will focus on the extracted_songs/<song> directory # 'clean=True' will delete the folders first, then recreate them # Need to make sure these folders exist Log("Creating necessary folders") if temp: # Clean out temp dir if clean: Folder.delete(self.get_temp_dir()) Folder.create(self.get_temp_dir()) else: # Create new extracted dir, remove if exists if clean: Folder.delete(self.get_root_dir()) Folder.create(self.get_root_dir()) for location in ["Media", "Bounces", "Mixdown"]: if temp: Folder.create(self.get_temp_dir() / location) Folder.create(self.get_root_dir() / location) return True
def to_wav(self, folderpath): folderpath = Path(folderpath) Folder.create(folderpath) mp3 = self.filepath wav = Path(f'{folderpath.absolute()}/{mp3.stem}.wav') stem, num, ext = File.split_name(wav.name) if wav.is_file(): # File already exists locally, do not do anything Log(f'File "{wav.name}" already exists, keeping local file.') return True Run.ffmpeg(args="-i", source=mp3.absolute(), destination=wav.absolute(), codec="-c:a pcm_s24le") return True
def folder_to_mp3(folderpath, destination): folderpath = Path(folderpath) destination = Path(destination) wavs = glob(f"{folderpath.absolute()}/*.wav") username_ignore = False Folder.create(destination) for wav in wavs: result = Audio(wav).to_mp3(folderpath=destination, username_ignore=username_ignore) if isinstance(result, dict): username_ignore = result["username_ignore"] else: if not result: return False return True
import traceback,sys from src.Slack import Slack from src.Update import Update from src.Settings import Settings from src.TERMGUI.Log import Log from src.FileManagement.Folder import Folder from src.menus.menu_main import menu_main # MAIN FUNCTION if __name__ == '__main__': # Create file structure if it doesn't exist Folder.create("compressed_songs") Folder.create("extracted_songs") Folder.create("temp") Folder.create("templates") # Create settings file if it doesn't exist Settings.create() # Start main menu try: menu_main() except Exception as e: Log(traceback.format_exc(),"warning") # 0 = there was a problem # 1 = exit gracefully sys.exit(0)