示例#1
0
    def move_temp_to_extracted_songs(self):
        # Convert mp3's to wav's
        for location in ["Media", "Bounces"]:
            Log(f'Converting "{location}" mp3\'s to wav\'s')
            if not Audio.folder_to_wav(self.get_temp_dir() / location,
                                       self.get_root_dir() / location):
                return False

            # Copy over dummy.json
            Log(f'Copying over "{location}" dummy.json')
            if self.get_dummy_db(location, temp=True).exists():
                File.recursive_overwrite(
                    self.get_dummy_db(location, temp=True),
                    self.get_dummy_db(location, temp=False),
                )

        # Copy over the previous mixdowns
        Log("Copying over 'Mixdown' mp3's")
        Folder.copy(self.get_temp_dir() / "Mixdown",
                    self.get_root_dir() / "Mixdown")

        # Copy over the song file
        Log("Copying over Studio One project file")
        File.recursive_overwrite(self.get_song_file(temp=True),
                                 self.get_song_file(temp=False))
        File.recursive_overwrite(
            self.get_song_file(temp=True),
            self.get_song_file(version="original", temp=False))

        return True
示例#2
0
    def duplicate(self):
        if not self.dialog_copy_confirm():
            return False

        new_name = self.dialog_copy_new_name()
        new_path = self.get_root_dir().parent / new_name

        Log(f'Duplicating "{self.entry.name}" to "{new_name}"..')

        Folder.copy(self.get_root_dir(), new_path)

        Log(f'Renaming song file', 'sub')
        File.rename(new_path / (self.get_song_file().name),
                    new_path / f'{new_name}.song')

        if self.get_song_file(version="original").exists():
            Log(f'Renaming *original song file', 'sub')
            File.rename(
                new_path / (self.get_song_file(version="original").name),
                new_path / f'{new_name}_original.song')

        Menu.notice = f'Created Project "{new_name}"!'

        return True
示例#3
0
    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