Example #1
0
 def search_rating_interval(db):
     # Grades are 1 at most, so this includes all songs with ratings:
     q_all = "rating..1"
     # Unfortunately, this also includes all songs with ratings,
     # since the only rating any song has is 0.6
     q_high = "rating0.2..1"
     songs_all = search(db, q_all)
     songs_high = search(db, q_high)
     assert len(songs_all) == 4
     assert len(songs_high) == 4
Example #2
0
def add_ebm(dbpath):
    from db.xapian_music import add_tag
    from db.xapian_music import search

    q = 'artist:"VNV Nation"'
    tag = "ebm"
    add_tag(dbpath, q, tag)

    for song in search(dbpath, q):
        assert tag in song["data"]["tags"]
        assert len(search(dbpath, q)) == len(search(dbpath, "tag:%s" % tag))
Example #3
0
    def remove_ebm(dbpath):
        from db.xapian_music import add_tag
        from db.xapian_music import search

        q = 'artist:"VNV Nation"'
        tag = "ebm"

        remove_tag(dbpath, q, tag)
        assert not search(dbpath, "tag:ebm")
        for song in search(dbpath, q):
            assert tag not in song["data"]["tags"]
Example #4
0
 def search_interval_year(db):
     q_all = "year..3000"
     q_2010 = "year..2010"
     q_1999 = "year..1999"
     q_early_00s = "year1999..2004"
     songs_all = search(db, q_all)
     songs_2010 = search(db, q_2010)
     songs_1999 = search(db, q_1999)
     songs_early_00s = search(db, q_early_00s)
     assert len(songs_all) == 6
     assert len(songs_2010) == 5
     assert len(songs_1999) == 0
     assert len(songs_early_00s) == 2
Example #5
0
 def search_album(db):
     q = 'album:"Automatic"'
     songs = search(db, q)
     assert len(songs) == 1
     song_data = songs[0]["data"]
     assert song_data["title"] == "Streamline"
     assert song_data["path"] == os.path.join(TESTDIR, "music_dir/06-streamline.mp3")
Example #6
0
def main(args):
    start_time = time.time()
    
    db.index(datapath = MUSIC_DIR, dbpath = DBPATH)
    
    #db.tag(dbpath=DBPATH, querystring=" ".join(args[1:]), tags=["inbox", "fisk"])
    
    matches = db.search(dbpath=DBPATH, querystring=" ".join(args[1:]))
    for match in matches:
        print u"{tracknumber} {artist} – »{title}« from {album} {year} ({length} s). Last modified {mtime}. Tagged {tags}.".format(**match['data'])
    print "N: Found %i tracks in  in %f ms.\n" % (len(matches), (time.time() - start_time)*1000)
Example #7
0
  def add_tags(db):
    q = 'artist:"VNV Nation"'
    tag = "ebm"
    add_tag(db, q, tag)
    
    for song in search(db, q):
      assert tag in song['data']['tags']

    print search(db, q)
    print search(db, "tag:ebm")
    assert len(search(db, q)) == len(search(db, "tag:%s" % tag))
Example #8
0
 def search_genre(db):
     songs = search(dbpath=db, querystring="genre:electronic")
     print [s["data"]["genre"] for s in songs]
Example #9
0
 def sort_test_fn(db):
     songs = search(db, q, order=key)
     values = [s["data"][key] for s in songs]
Example #10
0
 def search_false(db):
     false_search = search(dbpath=db, querystring="gurka")
     assert len(false_search) == 0
Example #11
0
 def search_kent(db):
     kent_artist = search(dbpath=db, querystring="artist:Kent")
     assert len(kent_artist) == 1
Example #12
0
 def search_vnv(db):
     vnv_nation_artist = search(dbpath=db, querystring='artist:"VNV Nation"')
     assert len(vnv_nation_artist) == 2
     vnv_nation_plain = search(dbpath=db, querystring="VNV Nation")
     assert len(vnv_nation_plain) == 2
     assert vnv_nation_plain[0]["data"]["artist"] == "VNV Nation"