コード例 #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 sess.cobrandId
    print sess.token
    print sess.userGuid
    print

    art = Artist.read(sess, sample_artist)
    print art.id
    print art.name
    print art.image
    for alb in art.albumids:
        print alb, " ",
    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
コード例 #4
0
    print sess.cobrandId
    print sess.token
    print sess.userGuid
    print

    art = Artist.read(sess, sample_artist)
    print art.id
    print art.name
    print art.image
    for alb in art.albumids:
        print alb, " ",
    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