def search_track(self, string): sql = """ SELECT tracks.name, tracks.duration, tracks.numalbum, tracks.id, tracks.license, tracks.id3genre, albums.id, albums.name, artists.id, artists.name, tracks.uid FROM tracks, albums, artists WHERE tracks.name LIKE '%""" + string + """%' and tracks.album_id=albums.id and albums.artist_id=artists.id LIMIT """ + str(self.parent.settings.get_value("PERFORMANCE", "db_search_limit")) ret = self.query(sql) tracks=[] for track in ret: tr = Track() tr.name = track[0] tr.duration = track[1] tr.numalbum = track[2] tr.id = track[3] tr.license = track[4] tr.id3genre = track[5] tr.album_id = track[6] tr.album_name = track[7] tr.artist_id = track[8] tr.artist_name = track[9] tr.uid = track[10] tr.stream = "http://api.jamendo.com/get2/stream/track/redirect/?id=%i&streamencoding=%s" % (track[3], self.parent.settings.get_value("JAMENDO", "format_stream", "mp31")) tracks.append(tr) return tracks
def get_trackinfos2(self, trackid): sql = """ SELECT tracks.name, tracks.duration, tracks.numalbum, tracks.license, tracks.album_id, tracks.artist_id, artists.name, albums.name, tracks.uid, tracks.id3genre, tracks.id FROM tracks, albums, artists WHERE tracks.id=%s and albums.id=tracks.album_id and artists.id=tracks.artist_id """ % str(trackid) ret = self.query(sql) if ret == []: return [] ret = ret[0] tr = Track() tr.name = ret[0] tr.duration = ret[1] tr.numalbum = ret[2] tr.license = ret[3] tr.album_id = ret[4] tr.artist_id = ret[5] tr.artist_name = ret[6] tr.album_name = ret[7] tr.uid = ret[8] tr.id3genre = ret[9] tr.id = ret[10] tr.stream = "http://api.jamendo.com/get2/stream/track/redirect/?id=%i&streamencoding=%s" % (ret[10], self.parent.settings.get_value("JAMENDO", "format_stream", "mp31")) # tracks.append(tr) return tr
def albumtracks(self, id): sql = """ SELECT tracks.name, tracks.duration, tracks.numalbum, tracks.license, tracks.album_id, tracks.artist_id, artists.name, albums.name, tracks.uid, tracks.id3genre, tracks.id FROM tracks, albums, artists WHERE tracks.album_id=%s and albums.id=%s and artists.id=albums.artist_id """ % (str(id), str(id)) ret = self.query(sql) tracks=[] for track in ret: tr = Track() tr.name = track[0] tr.duration = track[1] tr.numalbum = track[2] tr.license = track[3] tr.album_id = track[4] tr.artist_id = track[5] tr.artist_name = track[6] tr.album_name = track[7] tr.uid = track[8] tr.id3genre = track[9] tr.id = track[10] tr.stream = "http://api.jamendo.com/get2/stream/track/redirect/?id=%i&streamencoding=%s" % (track[10], self.parent.settings.get_value("JAMENDO", "format_stream", "mp31")) tracks.append(tr) return tracks
def get_multiple_trackinfos(self, tracks): track_string = "(" for track in tracks: track_string += " tracks.id=%s or" % track track_string = track_string[:-3] + ") and tracks.artist_id=artists.id and albums.id=tracks.album_id" sql = """ SELECT tracks.name, tracks.duration, tracks.numalbum, tracks.license, tracks.album_id, tracks.artist_id, artists.name, albums.name, tracks.uid, tracks.id3genre, tracks.id FROM tracks, artists, albums WHERE %s """ % track_string ret = self.query(sql) tracks=[] for track in ret: tr = Track() tr.name = track[0] tr.duration = track[1] tr.numalbum = track[2] tr.license = track[3] tr.album_id = track[4] tr.artist_id = track[5] tr.artist_name = track[6] tr.album_name = track[7] tr.uid = track[8] tr.id3genre = track[9] tr.id = track[10] tr.stream = "http://api.jamendo.com/get2/stream/track/redirect/?id=%i&streamencoding=%s" % (track[10], self.parent.settings.get_value("JAMENDO", "format_stream", "mp31")) tracks.append(tr) return tracks