def get_playlists(playlists):
    ret = True

    if playlists is None:
         playlists = []

    for playlist in gpod.sw_get_playlists(itdb):
        playlists.append(playlist)

    return ret 
Beispiel #2
0
#dbname = os.path.join(os.environ['HOME'],".gtkpod/iTunesDB")
#dbname = os.path.join(os.environ['HOME'],".gtkpod/local_0.itdb")
dbname = os.path.join(ipod_mount,"iPod_Control/iTunes/iTunesDB")

#itdb = gpod.itdb_parse_file(dbname, None)
# the image related functions require us to use parse and give it the
# mount point; and they won't work without an actual ipod.
itdb = gpod.itdb_parse(ipod_mount, None)
if not itdb:
    print "Failed to read %s" % dbname
    sys.exit(2)
itdb.mountpoint = ipod_mount

if True:
    for playlist in gpod.sw_get_playlists(itdb):
        print playlist.name
        print type(playlist.name)
        print gpod.itdb_playlist_tracks_number(playlist)
        for track in gpod.sw_get_playlist_tracks(playlist):
            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
Beispiel #3
0
                    deleted_files.append(full_ipod_filepath[len(mp):].replace('/',':'))

### 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: