def do_process(self, artist_title): artist, title = artist_title LOGGER.debug('artist={a} title={t} ({v})'.format( a=artist, t=title, v=plyr.version() )) qry = plyr.Query( get_type='lyrics', artist=artist, title=title, database=self.database, parallel=4, timeout=5 ) items = qry.commit() if items: first = items[0] # This item was cached on failure: if first.rating is -1: return None try: return (first.data.decode('utf-8'), ) except UnicodeDecodeError: pass if self._cache_failures: dummy = self.database.make_dummy() self.database.insert(qry, dummy) return None
There more for testing if the actual function passthrough works. """ class TestMisc(unittest.TestCase): @unittest.expectedFailure def test_download(self): google_com = plyr.download('www.google.de') self.assertTrue(len(google_com.data) > 0) self.assertEqual(len(google_com.data), google_com.size) def test_VERSION(self): self.assertTrue(len(plyr.VERSION) == 3) def test_levenshtein_cmp(self): self.assertEqual(plyr.levenshtein_cmp('abc', 'zaab'), 3) def test_levenshtein_normcmp(self): self.assertEqual(plyr.levenshtein_normcmp('Akrea(CD 01)', '</a> akrea </a>'), 0) def test_type_is_image(self): self.assertTrue(plyr.type_is_image('cover')) self.assertTrue(plyr.type_is_image('backdrops')) self.assertFalse(plyr.type_is_image('')) self.assertFalse(plyr.type_is_image('blarghherhetr')) self.assertFalse(plyr.type_is_image('lyrics')) if __name__ == '__main__': print(plyr.version()) unittest.main()
def print_version(): """Print version information.""" import plyr print('Lyvi %s, using libglyr %s' % (__version__, plyr.version().split()[1]))