def _do_trash_songs(parent, songs, librarian): dialog = TrashDialog.for_songs(parent, songs) resp = dialog.run() if resp != TrashDialog.RESPONSE_TRASH: return window_title = _("Moving %(current)d/%(total)d.") w = WaitLoadWindow(parent, len(songs), window_title) w.show() ok = [] failed = [] for song in songs: filename = song("~filename") try: trash.trash(filename) except trash.TrashError as e: print_w("Couldn't trash file (%s)" % e) failed.append(song) else: ok.append(song) w.step() w.destroy() if failed: ErrorMessage(parent, _("Unable to move to trash"), _("Moving one or more files to the trash failed.")).run() if ok: librarian.remove(ok)
def __create_playlist(name, source_dir, files, library): playlist = FileBackedPlaylist.new(PLAYLISTS, name, library=library) print_d("Created playlist %s" % playlist) songs = [] win = WaitLoadWindow( None, len(files), _("Importing playlist.\n\n%(current)d/%(total)d songs added.")) win.show() for i, filename in enumerate(files): if not uri_is_valid(filename): # Plain filename. songs.append(_af_for(filename, library, source_dir)) else: try: filename = uri2fsn(filename) except ValueError: # Who knows! Hand it off to GStreamer. songs.append(formats.remote.RemoteFile(filename)) else: # URI-encoded local filename. songs.append(_af_for(filename, library, source_dir)) if win.step(): break win.destroy() playlist.extend(list(filter(None, songs))) return playlist
def __parse_playlist(name, plfilename, files, library): playlist = Playlist.new(PLAYLISTS, name, library=library) songs = [] win = WaitLoadWindow(None, len(files), _("Importing playlist.\n\n%(current)d/%(total)d songs added.")) win.show() for i, filename in enumerate(files): try: uri = URI(filename) except ValueError: if os.name == "nt": filename = filename.decode("utf-8", "replace") # Plain filename. filename = os.path.realpath(os.path.join(os.path.dirname(plfilename), filename)) if library and filename in library: songs.append(library[filename]) else: songs.append(formats.MusicFile(filename)) else: if uri.scheme == "file": # URI-encoded local filename. filename = os.path.realpath(os.path.join(os.path.dirname(plfilename), uri.filename)) if library and filename in library: songs.append(library[filename]) else: songs.append(formats.MusicFile(filename)) else: # Who knows! Hand it off to GStreamer. songs.append(formats.remote.RemoteFile(uri)) if win.step(): break win.destroy() playlist.extend(filter(None, songs)) return playlist
def _do_delete_files(parent, paths): dialog = DeleteDialog.for_files(parent, paths) resp = dialog.run() if resp != DeleteDialog.RESPONSE_DELETE: return window_title = _("Deleting %(current)d/%(total)d.") w = WaitLoadWindow(parent, len(paths), window_title) w.show() ok = [] failed = [] for path in paths: try: os.unlink(path) except EnvironmentError: failed.append(path) else: ok.append(path) w.step() w.destroy() if failed: ErrorMessage(parent, _("Unable to delete files"), _("Deleting one or more files failed.")).run()
def _do_delete_songs(parent, songs, librarian): dialog = DeleteDialog.for_songs(parent, songs) resp = dialog.run() if resp != DeleteDialog.RESPONSE_DELETE: return window_title = _("Deleting %(current)d/%(total)d.") w = WaitLoadWindow(parent, len(songs), window_title) w.show() ok = [] failed = [] for song in songs: filename = song("~filename") try: os.unlink(filename) except EnvironmentError: failed.append(song) else: ok.append(song) w.step() w.destroy() if failed: ErrorMessage(parent, _("Unable to delete files"), _("Deleting one or more files failed.")).run() if ok: librarian.remove(ok)
def _do_delete_files(parent, paths): dialog = DeleteDialog.for_files(parent, paths) resp = dialog.run() if resp != DeleteDialog.RESPONSE_DELETE: return window_title = _("Deleting %(current)d/%(total)d.") w = WaitLoadWindow(parent, len(paths), window_title) w.show() ok = [] failed = [] for path in paths: try: os.unlink(path) except EnvironmentError: failed.append(path) else: ok.append(path) w.step() w.destroy() if failed: ErrorMessage(parent, _("Unable to delete files"), _("Deleting one or more files failed.") ).run()
def _do_trash_files(parent, paths): dialog = TrashDialog.for_files(parent, paths) resp = dialog.run() if resp != TrashDialog.RESPONSE_TRASH: return window_title = _("Moving %(current)d/%(total)d.") w = WaitLoadWindow(parent, len(paths), window_title) w.show() ok = [] failed = [] for path in paths: try: trash.trash(path) except trash.TrashError: failed.append(path) else: ok.append(path) w.step() w.destroy() if failed: ErrorMessage(parent, _("Unable to move to trash"), _("Moving one or more files to the trash failed.") ).run()
def _do_delete_songs(parent, songs, librarian): dialog = DeleteDialog.for_songs(parent, songs) resp = dialog.run() if resp != DeleteDialog.RESPONSE_DELETE: return window_title = _("Deleting %(current)d/%(total)d.") w = WaitLoadWindow(parent, len(songs), window_title) w.show() ok = [] failed = [] for song in songs: filename = song("~filename") try: os.unlink(filename) except EnvironmentError: failed.append(song) else: ok.append(song) w.step() w.destroy() if failed: ErrorMessage(parent, _("Unable to delete files"), _("Deleting one or more files failed.") ).run() if ok: librarian.remove(ok)
def _do_trash_songs(parent, songs, librarian): dialog = TrashDialog.for_songs(parent, songs) resp = dialog.run() if resp != TrashDialog.RESPONSE_TRASH: return window_title = _("Moving %(current)d/%(total)d.") w = WaitLoadWindow(parent, len(songs), window_title) w.show() ok = [] failed = [] for song in songs: filename = song("~filename") try: trash.trash(filename) except trash.TrashError: failed.append(song) else: ok.append(song) w.step() w.destroy() if failed: ErrorMessage(parent, _("Unable to move to trash"), _("Moving one or more files to the trash failed.") ).run() if ok: librarian.remove(ok)
def __parse_playlist(name, plfilename, files, library): playlist = FileBackedPlaylist.new(PLAYLISTS, name, library=library) songs = [] win = WaitLoadWindow( None, len(files), _("Importing playlist.\n\n%(current)d/%(total)d songs added.")) win.show() for i, filename in enumerate(files): if not uri_is_valid(filename): # Plain filename. filename = os.path.realpath(os.path.join( os.path.dirname(plfilename), filename)) if library and filename in library: songs.append(library[filename]) else: songs.append(formats.MusicFile(filename)) else: try: filename = uri2fsn(filename) except ValueError: # Who knows! Hand it off to GStreamer. songs.append(formats.remote.RemoteFile(filename)) else: # URI-encoded local filename. filename = os.path.realpath(os.path.join( os.path.dirname(plfilename), filename)) if library and filename in library: songs.append(library[filename]) else: songs.append(formats.MusicFile(filename)) if win.step(): break win.destroy() playlist.extend(filter(None, songs)) return playlist
def __create_playlist(name, source_dir, files, library): playlist = FileBackedPlaylist.new(PLAYLISTS, name, library=library) print_d("Created playlist %s" % playlist) songs = [] win = WaitLoadWindow( None, len(files), _("Importing playlist.\n\n%(current)d/%(total)d songs added.")) win.show() for i, filename in enumerate(files): if not uri_is_valid(filename): # Plain filename. songs.append(_af_for(filename, library, source_dir)) else: try: filename = uri2fsn(filename) except ValueError: # Who knows! Hand it off to GStreamer. songs.append(formats.remote.RemoteFile(filename)) else: # URI-encoded local filename. songs.append(_af_for(filename, library, source_dir)) if win.step(): break win.destroy() playlist.extend(list(filter(None, songs))) return playlist
def _do_trash_files(parent, paths): dialog = TrashDialog.for_files(parent, paths) resp = dialog.run() if resp != TrashDialog.RESPONSE_TRASH: return window_title = _("Moving %(current)d/%(total)d.") w = WaitLoadWindow(parent, len(paths), window_title) w.show() ok = [] failed = [] for path in paths: try: trash.trash(path) except trash.TrashError: failed.append(path) else: ok.append(path) w.step() w.destroy() if failed: ErrorMessage(parent, _("Unable to move to trash"), _("Moving one or more files to the trash failed.")).run()
def __parse_playlist(name, plfilename, files, library): playlist = Playlist.new(PLAYLISTS, name, library=library) songs = [] win = WaitLoadWindow( None, len(files), _("Importing playlist.\n\n%(current)d/%(total)d songs added.")) win.show() for i, filename in enumerate(files): try: uri = URI(filename) except ValueError: # Plain filename. filename = os.path.realpath( os.path.join(os.path.dirname(plfilename), filename)) if library and filename in library: songs.append(library[filename]) else: songs.append(formats.MusicFile(filename)) else: if uri.scheme == "file": # URI-encoded local filename. filename = os.path.realpath( os.path.join(os.path.dirname(plfilename), uri.filename)) if library and filename in library: songs.append(library[filename]) else: songs.append(formats.MusicFile(filename)) else: # Who knows! Hand it off to GStreamer. songs.append(formats.remote.RemoteFile(uri)) if win.step(): break win.destroy() playlist.extend(filter(None, songs)) return playlist
def plugin_songs(self, songs): if os.system("ifp typestring"): qltk.ErrorMessage( None, _("No iFP device found"), _("Unable to contact your iFP device. Check " "that the device is powered on and plugged " "in, and that you have ifp-line " "(http://ifp-driver.sf.net) installed.")).run() return True self.__madedir = [] w = WaitLoadWindow( None, len(songs), _("Uploading %(current)d/%(total)d")) w.show() for i, song in enumerate(songs): if self.__upload(song) or w.step(): w.destroy() return True else: w.destroy()
def plugin_songs(self, songs): if os.system("ifp typestring"): qltk.ErrorMessage( None, _("No iFP device found"), _("Unable to contact your iFP device. Check " "that the device is powered on and plugged " "in, and that you have ifp-line " "(http://ifp-driver.sf.net) installed.")).run() return True self.__madedir = [] w = WaitLoadWindow( None, len(songs), _("Uploading %(current)d/%(total)d")) w.show() for i, song in enumerate(songs): if self.__upload(song) or w.step(): w.destroy() return True else: w.destroy()
def __create_playlist(name, source_dir, files, songs_lib, pl_lib): songs = [] win = WaitLoadWindow( None, len(files), _("Importing playlist.\n\n%(current)d/%(total)d songs added.")) win.show() for i, filename in enumerate(files): song = None if not uri_is_valid(filename): # Plain filename. song = _af_for(filename, songs_lib, source_dir) else: try: filename = uri2fsn(filename) except ValueError: # Who knows! Hand it off to GStreamer. song = formats.remote.RemoteFile(filename) else: # URI-encoded local filename. song = _af_for(filename, songs_lib, source_dir) # Only add existing (not None) files to the playlist. # Otherwise multiple errors are thrown when the files are accessed # to update the displayed track infos. if song is not None: songs.append(song) elif (os.path.exists(filename) or os.path.exists(os.path.join(source_dir, filename))): print_w("Can't add file to playlist:" f" Unsupported file format. '{filename}'") else: print_w( f"Can't add file to playlist: File not found. '{filename}'") if win.step(): break win.destroy() return pl_lib.create_from_songs(songs)
def __create_playlist(name, source_dir, files, songs_lib, pl_lib): songs = [] win = WaitLoadWindow( None, len(files), _("Importing playlist.\n\n%(current)d/%(total)d songs added.")) win.show() for i, filename in enumerate(files): if not uri_is_valid(filename): # Plain filename. songs.append(_af_for(filename, songs_lib, source_dir)) else: try: filename = uri2fsn(filename) except ValueError: # Who knows! Hand it off to GStreamer. songs.append(formats.remote.RemoteFile(filename)) else: # URI-encoded local filename. songs.append(_af_for(filename, songs_lib, source_dir)) if win.step(): break win.destroy() return pl_lib.create_from_songs(songs)
def __parse_playlist(name, plfilename, files, library): playlist = FileBackedPlaylist.new(PLAYLISTS, name, library=library) songs = [] win = WaitLoadWindow( None, len(files), _("Importing playlist.\n\n%(current)d/%(total)d songs added.")) win.show() for i, filename in enumerate(files): if not uri_is_valid(filename): if os.name == "nt": filename = filename.decode("utf-8", "replace") # Plain filename. filename = os.path.realpath(os.path.join( os.path.dirname(plfilename), filename)) if library and filename in library: songs.append(library[filename]) else: songs.append(formats.MusicFile(filename)) else: try: filename = uri_to_path(filename) except ValueError: # Who knows! Hand it off to GStreamer. songs.append(formats.remote.RemoteFile(filename)) else: # URI-encoded local filename. filename = os.path.realpath(os.path.join( os.path.dirname(plfilename), filename)) if library and filename in library: songs.append(library[filename]) else: songs.append(formats.MusicFile(filename)) if win.step(): break win.destroy() playlist.extend(filter(None, songs)) return playlist