Ejemplo n.º 1
0
    def send_file_to_ipod(self, itdb, fname, tags):
        if not os.path.exists(fname):
            logger.error("File '%s' does not exist" % fname)
            return False

        logger.debug("Copying file '%s' to iPod..." % fname)
        podcasts = gpod.itdb_playlist_podcasts(itdb)
        track = gpod.itdb_track_new()
        track.visible = 1
        track.filetype = "mp3"
        track.ipod_path = fname
        track.album = str(tags['album'])
        track.artist = str(tags['artist'])
        track.title = str(tags['title'])
        track.genre = str(tags['genre'])
        track.tracklen = tags['length']
        track.playcount = 0
        gpod.itdb_track_add(itdb, track, -1)
        gpod.itdb_playlist_add_track(podcasts, track, -1)
        is_copied = gpod.itdb_cp_track_to_ipod(track, fname, None)
        if is_copied:
            logger.info("File '%s' has been successfully copied to iPod" % fname)
        else:
            # roll back
            logger.error("File '%s' could not be copied to iPod" % fname)
            gpod.itdb_playlist_remove_track(podcasts, track)
            gpod.itdb_track_remove(track)
        track = None
        gpod.itdb_write(itdb, None)
        return is_copied
Ejemplo n.º 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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
    def remove(self, track):
        """Remove a track from the playlist.

        track is a track object to remove.

        """

        if self.__contains__(track):
            gpod.itdb_playlist_remove_track(self._pl, track._track)
        else:
            raise DatabaseException("Playlist %s does not contain %s" % (self, track))
Ejemplo n.º 5
0
    def remove(self, track):
        """Remove a track from the playlist.

        track is a track object to remove.

        """

        if self.__contains__(track):
            gpod.itdb_playlist_remove_track(self._pl, track._track)
        else:
            raise DatabaseException("Playlist %s does not contain %s" %
                                    (self, track))
Ejemplo n.º 6
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)
Ejemplo n.º 7
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"



Ejemplo n.º 8
0
### Done syncing the music directory with the ipod. Now let's rebuild the database with
### the new changes.

db = gpod.itdb_parse(mp, None)

### First delete the removed/modified files from ipod database. This is an annoying part because we can only lookup track by id
### but we don't have an id, so we basically need to check every track to see if its been deleted/modified
if deleted_files:   
    print "Removing deleted & outdated tracks from the ipod database"
    tracks = gpod.sw_get_tracks(db)
    for track in tracks:
        if track.ipod_path in deleted_files:
        # Remove it from any playlists it might be on
            for pl in gpod.sw_get_playlists(db):
                if gpod.itdb_playlist_contains_track(pl, track):
                    gpod.itdb_playlist_remove_track(pl, track)
    
            # Remove it from the master playlist
            gpod.itdb_playlist_remove_track(gpod.itdb_playlist_mpl(db), track)
    
            # Remove it from the database
            gpod.itdb_track_remove(track)
    
### Now lets add everything new/modified from our music directory
### We'll use the local files to get the metadata to speed things up....
print "Updating the database with new/modified tracks..."
for full_local_filepath, full_ipod_filepath in new_files:
    
    try:
        f = MediaFile(full_local_filepath)
    except: