Modified:
trunk/autoqueue.py
trunk/mirage.py
trunk/mirage_miximize.py
trunk/mirage_songs.py
Log:
made work with sqlite3 in jaunty
Modified: trunk/autoqueue.py
==============================================================================
--- trunk/autoqueue.py (original)
+++ trunk/autoqueue.py Tue Mar 24 17:08:41 2009
@@ -308,9 +308,12 @@
if self.connection:
return self.connection
self.connection = sqlite3.connect(":memory:")
+ self.connection.text_factory = str
return self.connection
- return sqlite3.connect(
+ connection = sqlite3.connect(
self.get_db_path(), timeout=5.0, isolation_level="immediate")
+ connection.text_factory = str
+ return connection
def disallowed(self, song):
if song.get_artist() in self.get_blocked_artists():
Modified: trunk/mirage.py
==============================================================================
--- trunk/mirage.py (original)
+++ trunk/mirage.py Tue Mar 24 17:08:41 2009
@@ -372,9 +372,12 @@
if self.dbpath == ':memory:':
if not self.connection:
self.connection = sqlite3.connect(':memory:')
+ self.connection.text_factory = str
return self.connection
- return sqlite3.connect(
+ connection = sqlite3.connect(
self.dbpath, timeout=5.0, isolation_level="immediate")
+ connection.text_factory = str
+ return connection
def add_track(self, trackid, scms):
connection = self.get_database_connection()
Modified: trunk/mirage_miximize.py
==============================================================================
--- trunk/mirage_miximize.py (original)
+++ trunk/mirage_miximize.py Tue Mar 24 17:08:41 2009
@@ -26,7 +26,7 @@
super(MirageMiximizePlugin, self).__init__(*args)
self.mir = Mir()
self.dbpath =
os.path.join(self.player_get_userdir(), "similarity.db")
-
+
def player_get_userdir(self):
"""get the application user directory to store files"""
try:
@@ -77,11 +77,12 @@
for cluster in clusterer.clusters:
qsongs.extend([c for id, c in cluster])
self.player_enqueue(qsongs)
-
+
def get_track(self, artist_name, title):
"""get track information from the database"""
connection = sqlite3.connect(
- self.dbpath, timeout=5.0, isolation_level="immediate")
+ self.dbpath, timeout=5.0, isolation_level="immediate")
+ connection.text_factory = str
title = title.encode("UTF-8")
artist_id = self.get_artist(artist_name)[0]
rows = connection.execute(
@@ -100,11 +101,12 @@
connection.close()
return row
connection.close()
-
+
def get_artist(self, artist_name):
"""get artist information from the database"""
connection = sqlite3.connect(
- self.dbpath, timeout=5.0, isolation_level="immediate")
+ self.dbpath, timeout=5.0, isolation_level="immediate")
+ connection.text_factory = str
artist_name = artist_name.encode("UTF-8")
rows = connection.execute(
"SELECT * FROM artists WHERE name = ?", (artist_name,))
@@ -123,6 +125,7 @@
def get_artist_tracks(self, artist_id):
connection = sqlite3.connect(
self.dbpath, timeout=5.0, isolation_level="immediate")
+ connection.text_factory = str
rows = connection.execute(
"SELECT tracks.id FROM tracks INNER JOIN artists"
" ON tracks.artist = artists.id WHERE artists.id = ?",
@@ -138,13 +141,13 @@
if song1 in cluster:
index = cluster.index(song1)
if index > 0 and index < len(cluster) - 1:
- return True
+ return True
if song2 in cluster:
index = cluster.index(song2)
if index > 0 and index < len(cluster) - 1:
- return True
+ return True
return False
-
+
def at_the_ends(song1, song2, cluster):
return (cluster[0] == song1 and cluster[-1] == song2) or (
cluster[-1] == song1 and cluster[0] == song2)
@@ -163,7 +166,7 @@
def songs(self):
return [self.song1, self.song2]
-
+
def __cmp__(self, other):
if self.score < other.score:
return -1
@@ -178,7 +181,7 @@
self.similarities = []
self.build_similarity_matrix(songs, comparison_function)
self.build_clusters()
-
+
def build_similarity_matrix(self, songs, comparison_function):
for song in songs:
for song2 in songs[songs.index(song) + 1:]:
@@ -199,7 +202,7 @@
result = cluster1[:-1] + cluster2
self.clean_similarities(result)
return result
-
+
def merge_clusters(self):
new = []
clusters = self.clusters
Modified: trunk/mirage_songs.py
==============================================================================
--- trunk/mirage_songs.py (original)
+++ trunk/mirage_songs.py Tue Mar 24 17:08:41 2009
@@ -25,7 +25,7 @@
def __init__(self, *args):
super(MirageSongsPlugin, self).__init__(*args)
self.mir = Mir()
- self.dbpath =
os.path.join(self.player_get_userdir(), "similarity.db")
+ self.dbpath =
os.path.join(self.player_get_userdir(), "similarity.db")
def player_get_userdir(self):
"""get the application user directory to store files"""
@@ -56,7 +56,7 @@
yield
yield
print "done"
-
+
def plugin_songs(self, songs):
fid = "mirage_songs" + str(datetime.now())
copool.add(self.do_stuff, songs, funcid=fid)
@@ -64,7 +64,8 @@
def get_track(self, artist_name, title):
"""get track information from the database"""
connection = sqlite3.connect(
- self.dbpath, timeout=5.0, isolation_level="immediate")
+ self.dbpath, timeout=5.0, isolation_level="immediate")
+ connection.text_factory = str
title = title.encode("UTF-8")
artist_id = self.get_artist(artist_name)[0]
rows = connection.execute(
@@ -83,11 +84,12 @@
connection.close()
return row
connection.close()
-
+
def get_artist(self, artist_name):
"""get artist information from the database"""
connection = sqlite3.connect(
- self.dbpath, timeout=5.0, isolation_level="immediate")
+ self.dbpath, timeout=5.0, isolation_level="immediate")
+ connection.text_factory = str
artist_name = artist_name.encode("UTF-8")
rows = connection.execute(
"SELECT * FROM artists WHERE name = ?", (artist_name,))