示例#1
0
文件: dump.py 项目: davekilian/rapi
def handle(trackid, outdir, sess):
    print trackid,
    flush()

    try:
        track = Track.read(sess, trackid)
    except AttributeError:
        # This usually happens because the server returned an
        # HTTPInterfaceException, perhaps because the file wasn't found.
        # We'll just move on.
        print "not found on server"
        return

    print track.name,
    flush()

    if not track.albumid in albums:
        album = Album.read(sess, track.albumid)
        albums[album.id] = album
    else:
        album = albums[track.albumid]
    print "on", album.name,
    flush()

    if not track.artistid in artists:
        artist = Artist.read(sess, track.artistid, False)
        artists[artist.id] = artist
    else:
        artist = artists[track.artistid]
    print "by", artist.name, "...",
    flush()

    songdir = "%s/%s/%s" % (outdir, safepath(artist.name), safepath(
        album.name))
    flush()
    if not os.path.exists(songdir):
        os.makedirs(songdir)

    path = "%s/%d - %s.m4a" % (songdir, track.number, safepath(track.name))
    outfile = open(path, "w+")

    content = track.stream(sess, rapi.FORMAT_AAC_192).read()
    outfile.write(content)
    outfile.close()

    retag(path, artist, album, track)

    print "done"
    flush()
示例#2
0
文件: dump.py 项目: davekilian/rapi
def handle(trackid, outdir, sess):
    print trackid,
    flush()

    try:
        track = Track.read(sess, trackid)
    except AttributeError:
        # This usually happens because the server returned an 
        # HTTPInterfaceException, perhaps because the file wasn't found. 
        # We'll just move on.
        print "not found on server"
        return

    print track.name, 
    flush()

    if not track.albumid in albums:
        album = Album.read(sess, track.albumid)
        albums[album.id] = album
    else:
        album = albums[track.albumid]
    print "on", album.name,
    flush()

    if not track.artistid in artists:
        artist = Artist.read(sess, track.artistid, False)
        artists[artist.id] = artist
    else:
        artist = artists[track.artistid]
    print "by", artist.name, "...",
    flush()

    songdir = "%s/%s/%s" % (outdir, safepath(artist.name), safepath(album.name))
    flush()
    if not os.path.exists(songdir):
        os.makedirs(songdir)
    
    path = "%s/%d - %s.m4a" % (songdir, track.number, safepath(track.name))
    outfile = open(path, "w+")

    content = track.stream(sess, rapi.FORMAT_AAC_192).read()
    outfile.write(content)
    outfile.close()

    retag(path, artist, album, track)

    print "done"
    flush()
示例#3
0
文件: test.py 项目: davekilian/rapi
    print 
    print

    alb = Album.read(sess, sample_album)
    print alb.id
    print alb.artistid
    print alb.name
    print alb.art
    print alb.year
    print alb.numDiscs
    for tra in alb.trackids:
        print tra, " ",
    print
    print

    track = Track.read(sess, sample_track)
    print track.id
    print track.artistid
    print track.albumid
    print track.name
    print track.number
    print track.duration
    print track.genre
    print track.disc
    print

    library = rapi.library(sess)
    print "Your library has %d tracks" % len(library)
    for i in range(10):
        print library[i], " ",
    print
示例#4
0
    print
    print

    alb = Album.read(sess, sample_album)
    print alb.id
    print alb.artistid
    print alb.name
    print alb.art
    print alb.year
    print alb.numDiscs
    for tra in alb.trackids:
        print tra, " ",
    print
    print

    track = Track.read(sess, sample_track)
    print track.id
    print track.artistid
    print track.albumid
    print track.name
    print track.number
    print track.duration
    print track.genre
    print track.disc
    print

    library = rapi.library(sess)
    print "Your library has %d tracks" % len(library)
    for i in range(10):
        print library[i], " ",
    print