コード例 #1
0
ファイル: fred.py プロジェクト: albins/music-tools
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)
コード例 #2
0
ファイル: test.py プロジェクト: krl/music-tools
def with_index(f):
  from db.xapian_music import index
  from shutil import rmtree as remove
  
  MUSIC_DIR = os.path.join(TESTDIR, "music_dir") 
  DBPATH = os.path.join(TESTDIR, "music.db")

  index(MUSIC_DIR, DBPATH)
  
  try:
    f(DBPATH)
  finally:
    remove(DBPATH)