コード例 #1
0
    def get_all_tracks(self):
        tracks = []
        for track in gpod.sw_get_playlist_tracks(self.podcasts_playlist):
            filename = gpod.itdb_filename_on_ipod(track)

            if filename is None:
                # This can happen if the episode is deleted on the device
                logger.info('Episode has no file: %s', track.title)
                self.remove_track_gpod(track)
                continue

            length = util.calculate_size(filename)
            timestamp = util.file_modification_timestamp(filename)
            modified = util.format_date(timestamp)
            try:
                released = gpod.itdb_time_mac_to_host(track.time_released)
                released = util.format_date(released)
            except ValueError, ve:
                # timestamp out of range for platform time_t (bug 418)
                logger.info('Cannot convert track time: %s', ve)
                released = 0

            t = SyncTrack(track.title,
                          length,
                          modified,
                          modified_sort=timestamp,
                          libgpodtrack=track,
                          playcount=track.playcount,
                          released=released,
                          podcast=track.artist)
            tracks.append(t)
コード例 #2
0
def copyInfo(mp):
    "Copy all info from iPod Database to a local file"
    import gpod
    artists = dict()
    i_itdb = gpod.itdb_parse(mp, None)
    for track in gpod.sw_get_tracks(i_itdb):
        album = track.album
        artist = track.artist
        song = dict()
        song['file'] = gpod.itdb_filename_on_ipod(track)
        song['title'] = track.title
        song['track number'] = track.track_nr
        if artist not in artists:
            artists[artist] = dict()
            artists[artist]['name'] = artist
            artists[artist]['albums'] = dict()
        if album not in artists[artist]['albums']:
            artists[artist]['albums'][album] = dict()
            artists[artist]['albums'][album]['title'] = album
            artists[artist]['albums'][album]['songs'] = list()
        artists[artist]['albums'][album]['songs'].append(song)
    pass
    d = shelve.open(ipodDB)
    d[mp] = artists
    d.close()
コード例 #3
0
ファイル: sync.py プロジェクト: boyska/gpodder
    def get_all_tracks(self):
        tracks = []
        for track in gpod.sw_get_playlist_tracks(self.podcasts_playlist):
            filename = gpod.itdb_filename_on_ipod(track)

            if filename is None:
                # This can happen if the episode is deleted on the device
                logger.info('Episode has no file: %s', track.title)
                self.remove_track_gpod(track)
                continue

            length = util.calculate_size(filename)
            timestamp = util.file_modification_timestamp(filename)
            modified = util.format_date(timestamp)
            try:
                released = gpod.itdb_time_mac_to_host(track.time_released)
                released = util.format_date(released)
            except ValueError, ve:
                # timestamp out of range for platform time_t (bug 418)
                logger.info('Cannot convert track time: %s', ve)
                released = 0

            t = SyncTrack(track.title, length, modified,
                    modified_sort=timestamp,
                    libgpodtrack=track,
                    playcount=track.playcount,
                    released=released,
                    podcast=track.artist)
            tracks.append(t)
コード例 #4
0
ファイル: iPod.py プロジェクト: stafio/XBMC-iPod-plugin
def copyInfo(mp):
    "Copy all info from iPod Database to a local file"
    import gpod
    artists = dict()
    i_itdb = gpod.itdb_parse(mp,None)
    for track in gpod.sw_get_tracks(i_itdb):
        album = track.album
        artist = track.artist
        song = dict()
        song['file']=gpod.itdb_filename_on_ipod(track)
        song['title']=track.title
        song['track number']=track.track_nr
        if artist not in artists:
            artists[artist]=dict()
            artists[artist]['name']=artist
            artists[artist]['albums']=dict()
        if album not in artists[artist]['albums']:
            artists[artist]['albums'][album]=dict()
            artists[artist]['albums'][album]['title']=album
            artists[artist]['albums'][album]['songs']=list()
        artists[artist]['albums'][album]['songs'].append(song)
    pass
    d = shelve.open(ipodDB)
    d[mp]=artists
    d.close()
コード例 #5
0
 def purge(self):
     for track in gpod.sw_get_playlist_tracks(self.podcasts_playlist):
         if gpod.itdb_filename_on_ipod(track) is None:
             logger.info('Episode has no file: %s', track.title)
             # self.remove_track_gpod(track)
         elif track.playcount > 0 and not track.rating:
             logger.info('Purging episode: %s', track.title)
             self.remove_track_gpod(track)
コード例 #6
0
ファイル: sync.py プロジェクト: boyska/gpodder
 def purge(self):
     for track in gpod.sw_get_playlist_tracks(self.podcasts_playlist):
         if gpod.itdb_filename_on_ipod(track) is None:
             logger.info('Episode has no file: %s', track.title)
             # self.remove_track_gpod(track)
         elif track.playcount > 0  and not track.rating:
             logger.info('Purging episode: %s', track.title)
             self.remove_track_gpod(track)
コード例 #7
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)
コード例 #8
0
ファイル: sync.py プロジェクト: boyska/gpodder
    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)
コード例 #9
0
    def ipod_filename(self):
        """Get the full path to the track on the iPod.

        Note (from the libgpod documentation): This code works around
        a problem on some systems and might return a filename with
        different case than the original filename. Don't copy it back
        to track unless you must.

        """

        return gpod.itdb_filename_on_ipod(self._track)
コード例 #10
0
ファイル: ipod.py プロジェクト: Babl0lka/libgpod
    def ipod_filename(self):
        """Get the full path to the track on the iPod.

        Note (from the libgpod documentation): This code works around
        a problem on some systems and might return a filename with
        different case than the original filename. Don't copy it back
        to track unless you must.

        """

        return gpod.itdb_filename_on_ipod(self._track)
コード例 #11
0
ファイル: sync.py プロジェクト: uberchicgeekchick/alacast
    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)
コード例 #12
0
ファイル: sync.py プロジェクト: timabell/gpodder
    def get_all_tracks(self):
        tracks = []
        for track in gpod.sw_get_playlist_tracks(self.podcasts_playlist):
            filename = gpod.itdb_filename_on_ipod(track)
            length = util.calculate_size(filename)

            timestamp = util.file_modification_timestamp(filename)
            modified = util.format_date(timestamp)
            released = gpod.itdb_time_mac_to_host(track.time_released)
            released = util.format_date(released)

            t = SyncTrack(track.title, length, modified, modified_sort=timestamp, libgpodtrack=track, playcount=track.playcount, released=released, podcast=track.artist)
            tracks.append(t)
        return tracks        
コード例 #13
0
itdb = gpod.itdb_parse( IPOD_MOUNT, None)

if not itdb:
    print 'Cannot open iPod at %s' % ( IPOD_MOUNT )
    sys.exit( 2)

# just for some stats..
counter_upd = 0
counter_left = 0

for track in gpod.sw_get_tracks( itdb):
    if track.artist is None or track.title is None or track.album is None:
        # silently ignore
        continue

    filename = gpod.itdb_filename_on_ipod( track)
    try:
        mp3 = mutagen.mp3.MP3(filename)
        if not mp3.tags:
            print ''
            print '%s has no id3 tags' % ( filename )
            print 'iTDB says: AR = %s, TI = %s, AL = %s' % ( track.artist, track.title, track.album )
            mp3.add_tags() # create header
            mp3.tags.add(mutagen.id3.TPE1(3,track.artist))
            mp3.tags.add(mutagen.id3.TALB(3,track.album))
            mp3.tags.add(mutagen.id3.TIT2(3,track.title))
            mp3.tags.add(mutagen.id3.TXXX(3,"Taggger","tagged from itdb with libgpod"))
            mp3.save()
            counter_upd += 1
            print 'wrote tags to: %s' % ( filename )
        else:
コード例 #14
0
ファイル: toy_around.py プロジェクト: eggpi/mc723
            print track.title
    
for track in gpod.sw_get_tracks(itdb):
    lists = []
    for playlist in gpod.sw_get_playlists(itdb):
        if gpod.itdb_playlist_contains_track(playlist, track):
            lists.append(playlist)

    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)
コード例 #15
0
itdb = gpod.itdb_parse(IPOD_MOUNT, None)

if not itdb:
    print 'Cannot open iPod at %s' % (IPOD_MOUNT)
    sys.exit(2)

# just for some stats..
counter_upd = 0
counter_left = 0

for track in gpod.sw_get_tracks(itdb):
    if track.artist is None or track.title is None or track.album is None:
        # silently ignore
        continue

    filename = gpod.itdb_filename_on_ipod(track)
    try:
        mp3 = mutagen.mp3.MP3(filename)
        if not mp3.tags:
            print ''
            print '%s has no id3 tags' % (filename)
            print 'iTDB says: AR = %s, TI = %s, AL = %s' % (
                track.artist, track.title, track.album)
            mp3.add_tags()  # create header
            mp3.tags.add(mutagen.id3.TPE1(3, track.artist))
            mp3.tags.add(mutagen.id3.TALB(3, track.album))
            mp3.tags.add(mutagen.id3.TIT2(3, track.title))
            mp3.tags.add(
                mutagen.id3.TXXX(3, "Taggger",
                                 "tagged from itdb with libgpod"))
            mp3.save()