def test_rhythmbox_db_get_songs(): from db import rhythmbox as rb TEST_DB = os.path.join(TESTDIR, "rhythmdb.xml") songs = rb.get_songs(TEST_DB) for song in songs: assert len(song) == 3 assert not None in song assert song != None
def test_match(): from playlist import match from playlist import transport as ts from db import rhythmbox as rb from playlist.m3u import parse REFERENCE_PLAYLIST = os.path.join(TESTDIR, "reference.json") REFERENCE_PLAYLIST_COMPILED_M3U = os.path.join(TESTDIR, "reference.m3u") TEST_DB = os.path.join(TESTDIR, "rhythmdb.xml") playlist = ts.load(REFERENCE_PLAYLIST) songs = rb.get_songs(TEST_DB) # This is som preliminary testing that the playlist is actually sane # (i.e. contains no missed matches and is the right size. matched = match.match_transport(playlist, songs) assert len(matched) == len(playlist["playlist"]) assert not None in matched # Here we compare the matched playlist to a hand-compiled m3u list. compiled_playlist = parse(REFERENCE_PLAYLIST_COMPILED_M3U) for i in xrange(len(matched)): assert matched[i] == compiled_playlist[i]
from db import rhythmbox as rb from db import dirtree RB_DB = os.path.expanduser('~/.local/share/rhythmbox/rhythmdb.xml') CURRENT_DIR = os.path.dirname(__file__) if len(sys.argv) > 1 and not len(sys.argv) > 2: playlist = ts.load(sys.argv[1]) else: sys.stderr.write("Usage: plc <playlist file> <optional output file>. " "If no output file is given, print to stdout.\n") sys.exit() start_time = time.time() songs = match_transport(playlist, rb.get_songs(RB_DB)) for i, song in enumerate(songs): if song == None: sys.stderr.write("E: couldn't find %d: %s by %s.\n" % ((i+1), playlist["playlist"][i]["title"], playlist["playlist"][i]["artist"])) m3u_list = m3u.M3UList(songs, name=playlist['description'], comments=[playlist['comment']]) target = sys.stdout if len(sys.argv) > 2: target = sys.argv[2]