mirror of
https://github.com/correl/dejavu.git
synced 2024-11-23 11:09:52 +00:00
change to print song_name and file_sha1 with 'utf8' encoding correctly
This commit is contained in:
parent
b52b8ef7bd
commit
bfe0003551
4 changed files with 7 additions and 5 deletions
|
@ -88,6 +88,7 @@ if __name__ == '__main__':
|
|||
song = djv.recognize(MicrophoneRecognizer, seconds=opt_arg)
|
||||
elif source == 'file':
|
||||
song = djv.recognize(FileRecognizer, opt_arg)
|
||||
print(song)
|
||||
decoded_song = repr(song).decode('string_escape')
|
||||
print(decoded_song)
|
||||
|
||||
sys.exit(0)
|
||||
|
|
|
@ -155,11 +155,11 @@ class Dejavu(object):
|
|||
fingerprint.DEFAULT_OVERLAP_RATIO, 5)
|
||||
song = {
|
||||
Dejavu.SONG_ID : song_id,
|
||||
Dejavu.SONG_NAME : songname,
|
||||
Dejavu.SONG_NAME : songname.encode("utf8"),
|
||||
Dejavu.CONFIDENCE : largest_count,
|
||||
Dejavu.OFFSET : int(largest),
|
||||
Dejavu.OFFSET_SECS : nseconds,
|
||||
Database.FIELD_FILE_SHA1 : song.get(Database.FIELD_FILE_SHA1, None),}
|
||||
Database.FIELD_FILE_SHA1 : song.get(Database.FIELD_FILE_SHA1, None).encode("utf8"),}
|
||||
return song
|
||||
|
||||
def recognize(self, recognizer, *options, **kwoptions):
|
||||
|
|
|
@ -214,7 +214,7 @@ class SQLDatabase(Database):
|
|||
"""
|
||||
Return songs that have the fingerprinted flag set TRUE (1).
|
||||
"""
|
||||
with self.cursor(cursor_type=DictCursor) as cur:
|
||||
with self.cursor(cursor_type=DictCursor, charset="utf8") as cur:
|
||||
cur.execute(self.SELECT_SONGS)
|
||||
for row in cur:
|
||||
yield row
|
||||
|
@ -223,7 +223,7 @@ class SQLDatabase(Database):
|
|||
"""
|
||||
Returns song by its ID.
|
||||
"""
|
||||
with self.cursor(cursor_type=DictCursor) as cur:
|
||||
with self.cursor(cursor_type=DictCursor, charset="utf8") as cur:
|
||||
cur.execute(self.SELECT_SONG, (sid,))
|
||||
return cur.fetchone()
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# encoding: utf-8
|
||||
import dejavu.fingerprint as fingerprint
|
||||
import dejavu.decoder as decoder
|
||||
import numpy as np
|
||||
|
|
Loading…
Reference in a new issue