コード例 #1
0
ファイル: dump.py プロジェクト: davekilian/rapi
def main():
    if len(sys.argv) < 2:
        usage()
        return

    outdir = sys.argv[1]
    if not os.path.exists(outdir):
        os.makedirs(outdir)

    if len(sys.argv) > 2:
        username = sys.argv[2]
    else:
        f = open("./.username")
        username = f.read()

    if len(sys.argv) > 3:
        password = sys.argv[3]
    else:
        f = open("./.password")
        password = f.read()

    print "Loading manifest...",
    load_manifest(outdir)
    print "%d track(s)" % len(manifest)

    print "Authenticating as %s..." % username,
    flush()
    sess = rapi.auth(username, password)
    print "ok"

    print "Listing library contents...",
    flush()
    lib = rapi.library(sess)
    print "%d tracks" % len(lib)
    flush()

    for i in range(len(lib)):
        print "[%d of %d]" % (i + 1, len(lib)),
        if lib[i] in manifest:
            print "skipped (in manifest)"
        else:
            try:
                handle(lib[i], outdir, sess)
                append_manifest(outdir, lib[i])
            except:
                print "error"
コード例 #2
0
ファイル: dump.py プロジェクト: davekilian/rapi
def main():
    if len(sys.argv) < 2:
        usage()
        return

    outdir = sys.argv[1]
    if not os.path.exists(outdir):
        os.makedirs(outdir)

    if len(sys.argv) > 2:
        username = sys.argv[2]
    else:
        f = open("./.username")
        username = f.read()

    if len(sys.argv) > 3:
        password = sys.argv[3]
    else:
        f = open("./.password")
        password = f.read()

    print "Loading manifest...",
    load_manifest(outdir)
    print "%d track(s)" % len(manifest)

    print "Authenticating as %s..." % username,
    flush()
    sess = rapi.auth(username, password)
    print "ok"

    print "Listing library contents...",
    flush()
    lib = rapi.library(sess)
    print "%d tracks" % len(lib)
    flush()

    for i in range(len(lib)):
        print "[%d of %d]" % (i + 1, len(lib)),
        if lib[i] in manifest:
            print "skipped (in manifest)"
        else:
            try:
                handle(lib[i], outdir, sess)
                append_manifest(outdir, lib[i])
            except:
                print "error"
コード例 #3
0
ファイル: test.py プロジェクト: davekilian/rapi
    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
    print

    stream = track.stream(sess, rapi.FORMAT_AAC_192)
    # XXX does this treat the strings as text and modify the content?
    content = stream.read()
    dump = open("test.m4a", "w+")
    dump.write(content)
    dump.close()

コード例 #4
0
    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
    print

    stream = track.stream(sess, rapi.FORMAT_AAC_192)
    # XXX does this treat the strings as text and modify the content?
    content = stream.read()
    dump = open("test.m4a", "w+")
    dump.write(content)
    dump.close()