def open_file(pl_widget_h): fileName = QtWidgets.QFileDialog.getOpenFileName( None, "Choose Song", "~", "Audio Files (*.mp3 *.wav *.m4a)") if len(fileName[0]) == 0: return current_playlist = pl_widget_h.get_current_pl_name() print(current_playlist) main_model.add_files((fileName[0], ), current_playlist)
def playlist_dir(): directory = QtWidgets.QFileDialog.getExistingDirectory( None, "Open Directory", "/home", QtWidgets.QFileDialog.ShowDirsOnly | QtWidgets.QFileDialog.DontResolveSymlinks) playlist_name = os.path.basename(directory) main_model.add_playlist(playlist_name) def path_generator(): for root, dirs, files in os.walk(directory, topdown=True): path_directory = pathlib.Path(root) for file in files: new_path = path_directory / file if new_path.suffix in allowed_suffixes: yield str(new_path) path_gen = path_generator() main_model.add_files(path_gen, playlist_name)
def add_songs(self,item): songs = self.get_songs(item.text()) main_model.add_files(songs,"Now Playing"); self.accept();