def handle(self, *args, **options): exists = 0 update = 0 insert = 0 if len(args) > 0: dirpath = abspath(args[0]) else: return "missing path, please add path to lookup\n" if not isdir(dirpath): return "path %s does not exists\n" % dirpath for fpath in importdir(dirpath): tags = checkid3(fpath) if tags is not None: sig = sigfile(fpath) exsong = Song.objects.filter(uniq=sig) if len(exsong) > 0: if exsong[0].filename != fpath: self._updatesong(exsong[0], fpath) update += 1 else: self._donothing(exsong[0]) exists += 1 else: self._createsong(tags, sig, fpath) insert += 1 self.stdout.write("%d songs already present db\n" % exists) self.stdout.write("%d songs path updated in db\n" % update) self.stdout.write("%d songs inserted in db\n" % insert)
def test_sigfile(self): """ Sigfile """ first = path.join(path.dirname(__file__), 'samples', 'first', 'test.ogg') datas = sigfile(first) self.assertEqual(datas, '4c5a7fec7bfea8b4e44188918c5b68f4c90b955e')