def get_tracks_from_uri(uri): """ Returns all valid tracks located at uri :param uri: the uri to retrieve the tracks from :type uri: string :returns: the retrieved tracks :rtype: list of :class:`xl.trax.Track` """ tracks = [] gloc = gio.File(uri) # don't do advanced checking on streaming-type uris as it can fail or # otherwise be terribly slow. # TODO: move uri definition somewhere more common for easy reuse? if gloc.get_uri_scheme() in ('http', 'mms', 'cdda'): return [Track(uri)] try: file_type = gloc.query_info("standard::type").get_file_type() except gio.Error: # E.g. cdda file_type = None if file_type == gio.FILE_TYPE_DIRECTORY: # TODO: refactor Library so we dont need the collection obj from xl.collection import Library, Collection tracks = Collection('scanner') lib = Library(uri) lib.set_collection(tracks) lib.rescan() tracks = tracks.get_tracks() else: tracks = [Track(uri)] return tracks
def collection_manager(self, *e): """ Invokes the collection manager dialog """ from xl.collection import Library from xlgui.collection import CollectionManagerDialog dialog = CollectionManagerDialog(self.main.window, self.exaile.collection) result = dialog.run() dialog.hide() if result == Gtk.ResponseType.APPLY: collection = self.exaile.collection collection.freeze_libraries() collection_libraries = sorted([ (l.location, l.monitored, l.startup_scan) for l in collection.libraries.itervalues() ]) new_libraries = sorted(dialog.get_items()) if collection_libraries != new_libraries: collection_locations = [ location for location, monitored, startup_scan in collection_libraries ] new_locations = [ location for location, monitored, startup_scan in new_libraries ] if collection_locations != new_locations: for location in new_locations: if location not in collection_locations: collection.add_library(Library(location)) removals = [] for location, library in collection.libraries.iteritems(): if location not in new_locations: removals += [library] map(collection.remove_library, removals) self.on_rescan_collection() for location, monitored, startup_scan in new_libraries: collection.libraries[location].monitored = monitored collection.libraries[location].startup_scan = startup_scan collection.thaw_libraries() dialog.destroy()
def __init__(self, exaile, uris): Gtk.Window.__init__(self, transient_for=exaile.gui.main.window) self.init_template() self.exaile = exaile self.collection = Collection("GT Import Collection") for uri in uris: self.collection.add_library(Library(uri)) self.manager = ProgressManager(self.content_area) self.rescan_thread = CollectionScanThread(self.collection) self.rescan_thread.connect('done', self._on_rescan_done) self.import_thread = None self.manager.add_monitor(self.rescan_thread, _("Importing tracks"), Gtk.STOCK_REFRESH)
def __init__(self, exaile, uris): self.exaile = exaile self._init_builder() self.collection = Collection("GT Import Collection") for uri in uris: self.collection.add_library(Library(uri)) self.manager = ProgressManager(self.content_area) self.rescan_thread = CollectionScanThread(self.collection) self.rescan_thread.connect( 'done', lambda t: glib.idle_add(self._on_rescan_done)) self.update_thread = None self.import_thread = None self.manager.add_monitor(self.rescan_thread, _("Importing tracks"), gtk.STOCK_REFRESH)