Exemple #1
0
    def remove_track_gpod(self, track):
        filename = gpod.itdb_filename_on_ipod(track)

        try:
            gpod.itdb_playlist_remove_track(self.podcasts_playlist, track)
        except:
            logger.info('Track %s not in playlist', track.title)

        gpod.itdb_track_unlink(track)
        util.delete_file(filename)
Exemple #2
0
    def remove_track_gpod(self, track):
        filename = gpod.itdb_filename_on_ipod(track)

        try:
            gpod.itdb_playlist_remove_track(self.podcasts_playlist, track)
        except:
            logger.info('Track %s not in playlist', track.title)

        gpod.itdb_track_unlink(track)
        util.delete_file(filename)
Exemple #3
0
    def remove_track(self, track):
        self.notify('status', _('Removing %s') % track.title)
        track=track.libgpodtrack
        filename=gpod.itdb_filename_on_ipod(track)

        try:
            gpod.itdb_playlist_remove_track(self.podcasts_playlist, track)
        except:
            log('Track %s not in playlist', track.title, sender=self)

        gpod.itdb_track_unlink(track)
        util.delete_file(filename)
Exemple #4
0
    def remove(self, item, harddisk=False, ipod=True, quiet=False):
        """Remove a playlist or track from a database.

        item is either a playlist or track object.

        If harddisk is True the item will be removed from the the hard drive.

        If ipod is True the item will be removed from the iPod.

        If quiet is True no message will be printed for removed tracks

        """

        if isinstance(item, Playlist):
            if ipod or harddisk:
                # remove all the tracks that were in this playlist
                for track in item:
                    self.remove(track, ipod=ipod, harddisk=harddisk)
            if gpod.itdb_playlist_exists(self._itdb, item._pl):
                gpod.itdb_playlist_remove(item._pl)
            else:
                raise DatabaseException("Playlist %s was not in %s" %
                                        (item, self))
        elif isinstance(item, Track):
            for pl in self.Playlists:
                if item in pl:
                    pl.remove(item)
            if harddisk:
                try:
                    filename = item._userdata_into_default_locale('filename')
                except KeyError, e:
                    raise TrackException(
                        "Unable to remove %s from hard disk, no filename available."
                        % item)
                os.unlink(filename)
            if ipod:
                filename = item.ipod_filename()
                if filename and os.path.exists(filename):
                    os.unlink(filename)
                    if not quiet:
                        print "unlinked %s" % filename
            gpod.itdb_track_unlink(item._track)
Exemple #5
0
    def remove(self, item, harddisk=False, ipod=True, quiet=False):
        """Remove a playlist or track from a database.

        item is either a playlist or track object.

        If harddisk is True the item will be removed from the the hard drive.

        If ipod is True the item will be removed from the iPod.

        If quiet is True no message will be printed for removed tracks

        """

        if isinstance(item, Playlist):
            if ipod or harddisk:
                # remove all the tracks that were in this playlist
                for track in item:
                    self.remove(track, ipod=ipod, harddisk=harddisk)
            if gpod.itdb_playlist_exists(self._itdb, item._pl):
                gpod.itdb_playlist_remove(item._pl)
            else:
                raise DatabaseException("Playlist %s was not in %s" % (item, self))
        elif isinstance(item, Track):
            for pl in self.Playlists:
                if item in pl:
                    pl.remove(item)
            if harddisk:
                try:
                    filename = item._userdata_into_default_locale('filename')
                except KeyError, e:
                    raise TrackException("Unable to remove %s from hard disk, no filename available." % item)
                os.unlink(filename)
            if ipod:
                filename = item.ipod_filename()
                if filename and os.path.exists(filename):
                    os.unlink(filename)
                    if not quiet:
                        print "unlinked %s" % filename
            gpod.itdb_track_unlink(item._track)
Exemple #6
0
    print track.artist
    print track.tracklen
    print track.size
    if track.artist == "Placebo":
        print u"%-25s %-20s %-20s %-30s %s" % (track.title,
                                               track.album,
                                               track.artist,
                                               gpod.itdb_filename_on_ipod(track),
                                               repr(u",".join([l.name for l in lists])))

        if gpod.itdb_track_set_thumbnail(track,"/tmp/placebo.jpg") != 0:
            print "Failed to save image thumbnail"
        print track.orig_image_filename

    if track.title == remove_track:
        print "Removing track.."
        print "..disk"
        os.unlink(gpod.itdb_filename_on_ipod(track))
        for l in lists:
            print u"..playlist %s" % l.name
            gpod.itdb_playlist_remove_track(l, track)
        print "..db"
        gpod.itdb_track_unlink(track)
        print "Track removed."

gpod.itdb_write(itdb, None)
print "Saved db"