def upload_project(self): # Make sure our project is the most up-to-date if not self.is_up_to_date(): Log( "There are updates for this project on the cloud!.. can not upload!", "warning") Log.press_enter() return False # Make sure we set the category if it's never been uploaded before if not self.is_remote(): self.change_category(back=False) if not Dev.get("NO_OPEN_STUDIO_ONE"): if self.dialog_remove_unused_audio_files(): if not self.open_studio_one(): return False # Create folder for mixdowns on cloud if it doesnt exist if not Drive.get_id(self.entry.name): Drive.mkdir(self.entry.name) # We will need to set the local hash on our own incase of failure # to upload if not self.compress_project(set_hash=False): return False # Upload compressed project Log("Uploading.. please be patient", "notice") if not Dev.get("NO_LOF_UPLOAD"): result = Drive.upload(filepath=self.get_cache_file(), mimeType=Drive.mimeType['zip']) if not result: Log("Drive upload could not complete..", "warning") Log.press_enter() return False # Update local hash Hash.set_project_hash(self, Hash.create_hash_from_project(self)) # Update remote hash if file was successfully uploaded self.entry.data["id"] = result self.entry.data["hash"] = Hash.get_project_hash(self) self.entry.update() Slack( f'{Slack.get_nice_username()} uploaded a new version of {Slack.make_nice_project_name(self.entry.name)}' ) # Remove name from dirty list self.remove_dirty() # Since we successfully uploaded to the drive, we can now get # rid of the *original song file File.recursive_overwrite(self.get_song_file(), self.get_song_file(version="original")) Log("Compression and upload complete!", "notice") return True
def create_database(): with open(FILEPATH_LOCAL, "w") as f: json.dump(DEFAULT_DATABASE, f, indent=4) return Drive.upload(FILEPATH_LOCAL, Drive.mimeType["json"])
def move_extracted_song_to_temp(self): # Make sure we don't have any dummy files self.remove_dummy_files() for location in ["Media", "Bounces"]: # Remove unused cached audio from location # Garbage collector for unused audio files mp3s = Folder.ls_files(self.get_temp_dir() / location, "mp3") wav_names = [ x.stem for x in Folder.ls_files(self.get_root_dir() / location, "wav") ] for mp3 in mp3s: if mp3.stem not in wav_names: File.delete(mp3) # Convert and move wavs to mp3s Log(f'Converting "{location}" wav\'s to mp3\'s') if not Audio.folder_to_mp3(self.get_root_dir() / location, self.get_temp_dir() / location): return False # Copy over dummy.json Log(f'Copying over "{location}" dummy.json') if self.get_dummy_db(location, temp=False).exists(): File.recursive_overwrite( self.get_dummy_db(location, temp=False), self.get_dummy_db(location, temp=True), ) # Upload scratch files and mixdowns to the cloud mp3s = Folder.ls_files(self.get_temp_dir() / "Media", "mp3", "Scratch*") mp3s.extend( Folder.ls_files(self.get_temp_dir() / "Media", "mp3", "SCRATCH*")) mp3s.extend(Folder.ls_files(self.get_root_dir() / "Mixdown", "mp3")) for mp3 in mp3s: mix_folder_id = Drive.get_id(self.entry.name) if not Drive.get_id(mp3.name, mix_folder_id): Log(f'Uploading "{mp3.name}" to the cloud', "sub") mp3_id = Drive.upload(filepath=mp3, mimeType=Drive.mimeType["mp3"], parent=mix_folder_id) audio_type = "Scratch" if mp3.parent.name == "Media" else "#MIXDOWN#" Slack.send_link( link_name= f'{audio_type} for {self.entry.name}, "{mp3.name}"', ID=mp3_id) else: Log(f'Audio file "{mp3.name}" already exists on the cloud!', "sub") # Copy over mixdowns to temp Log("Copying over 'Mixdown' mp3's") Folder.copy(self.get_root_dir() / "Mixdown", self.get_temp_dir() / "Mixdown") # Lastly, copy over the song file File.recursive_overwrite(self.get_song_file(temp=False), self.get_song_file(temp=True)) return True
def push(): if FILEPATH_LOCAL.exists(): return Drive.upload(FILEPATH_LOCAL, Drive.mimeType["json"]) return False