Exemplo n.º 1
0
 def populate_collection(self):
     for track in self.db.get_master():
         track_path = self.mountpoint + track["ipod_path"].replace(":", "/")
         if is_valid_track(track_path):
             track_object = Track(track_path)
             if track_object:
                 self.collection.add(track_object)
Exemplo n.º 2
0
 def populate_collection(self):
     for track in self.db.get_master():
        track_path = self.mountpoint + track["ipod_path"].replace(":", "/")
        if is_valid_track(track_path):
            track_object = Track(track_path)
            if track_object:
                self.collection.add(track_object)
Exemplo n.º 3
0
 def get_track(self, f):
     """
         Returns a single track from a Gio.File
     """
     uri = f.get_uri()
     if not trax.is_valid_track(uri):
         return None
     tr = trax.Track(uri)
     return tr
Exemplo n.º 4
0
 def get_track(self, f):
     """
         Returns a single track from a Gio.File
     """
     uri = f.get_uri()
     if not trax.is_valid_track(uri):
         return None
     tr = trax.Track(uri)
     return tr
Exemplo n.º 5
0
    def _handle_unknown_drag_data(self, loc):
        """
            Handles unknown drag data that has been recieved by
            drag_data_received.  Unknown drag data is classified as
            any loc (location) that is not in the collection of tracks
            (i.e. a new song, or a new playlist)

            @param loc:
                the location of the unknown drag data

            @returns: a 2 tuple in which the first part is a list of tracks
                and the second is a list of playlist
        """
        filetype = None
        info = urlparse.urlparse(loc)

        # don't use gio to test the filetype if it's a non-local file
        # (otherwise gio will try to connect to every remote url passed in and
        # cause the gui to hang)
        if info.scheme in ('file', ''):
            try:
                filetype = (
                    Gio.File.new_for_uri(loc)
                    .query_info('standard::type', Gio.FileQueryInfoFlags.NONE, None)
                    .get_file_type()
                )
            except GLib.Error:
                filetype = None

        if trax.is_valid_track(loc) or info.scheme not in ('file', ''):
            new_track = trax.Track(loc)
            return ([new_track], [])
        elif xl_playlist.is_valid_playlist(loc):
            # User is dragging a playlist into the playlist list
            # so we add all of the songs in the playlist
            # to the list
            new_playlist = xl_playlist.import_playlist(loc)
            return ([], [new_playlist])
        elif filetype == Gio.FileType.DIRECTORY:
            return (trax.get_tracks_from_uri(loc), [])
        else:  # We don't know what they dropped
            return ([], [])