def open(self): Device.open(self) if not gpod_available: logger.error( 'Please install the gpod module to sync with an iPod device.') return False if not os.path.isdir(self.mountpoint): return False self.notify('status', _('Opening iPod database')) self.itdb = gpod.itdb_parse(self.mountpoint, None) if self.itdb is None: return False self.itdb.mountpoint = self.mountpoint self.podcasts_playlist = gpod.itdb_playlist_podcasts(self.itdb) self.master_playlist = gpod.itdb_playlist_mpl(self.itdb) if self.podcasts_playlist: self.notify('status', _('iPod opened')) # build the initial tracks_list self.tracks_list = self.get_all_tracks() return True else: return False
def import_file(self, filename): """Import a file. filename is added to the end of the master playlist. """ track = Track(filename) track.copy_to_ipod() gpod.itdb_playlist_add_track(gpod.itdb_playlist_mpl(self._itdb), track._track, -1) track.__database = self # so the db doesn't get gc'd
def import_file(self, filename): """Import a file. filename is added to the end of the master playlist. """ track = Track(filename) track.copy_to_ipod() gpod.itdb_playlist_add_track(gpod.itdb_playlist_mpl(self._itdb), track._track, -1) track.__database = self # so the db doesn't get gc'd
def open(self): Device.open(self) if not gpod_available or not os.path.isdir(self.mountpoint): return False self.notify('status', _('Opening iPod database')) self.itdb = gpod.itdb_parse(self.mountpoint, None) if self.itdb is None: return False self.itdb.mountpoint = self.mountpoint self.podcasts_playlist = gpod.itdb_playlist_podcasts(self.itdb) self.master_playlist = gpod.itdb_playlist_mpl(self.itdb) if self.podcasts_playlist: self.notify('status', _('iPod opened')) # build the initial tracks_list self.tracks_list = self.get_all_tracks() return True else: return False
def get_master(self): """Get the Master playlist.""" return Playlist(self, proxied_playlist=gpod.itdb_playlist_mpl(self._itdb))
def get_master(self): """Get the Master playlist.""" return Playlist(self,proxied_playlist=gpod.itdb_playlist_mpl(self._itdb))
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: print "Error reading '" + full_local_filepath + "'" continue