def ev_populate_listmenu(self, rootmenu): selection = self.pyjama.window.tvList.get_selection() model, tmpIter = selection.get_selected() if tmpIter is None: return path = model.get_path(tmpIter) ret = self.pyjama.window.tvList.get_item(path) track = Track() track.id = ret[self.pyjama.window.tvList.COLUMN_TRACKID] if track.id < 0: return url = "track/id/track/data/json/%s?tri=lyrics_text" % track.id ret = self.pyjama.jamendo.queryold( url, raise_query_event=False ) txt = ret[0]['lyrics_text'] if txt is None: txt = "" mnu = gtk.ImageMenuItem(_("Show Lyrics")) rootmenu.append(mnu) try: img = gtk.Image() pix = gtk.gdk.pixbuf_new_from_file_at_size(os.path.join(functions.install_dir(), "plugins", "lyrics", "lyrics.png"), 16, 16) img.set_from_pixbuf(pix) mnu.set_image(img) except: print ("Image not found or corrupt") mnu.show() mnu.connect("activate", self.cb_show_lyrics_activate, txt, track.id) if len(txt) < 10: mnu.set_sensitive(False)
def ev_populate_listmenu(self, rootmenu): selection = self.pyjama.window.tvList.get_selection() model, tmpIter = selection.get_selected() if tmpIter is None: return path = model.get_path(tmpIter) ret = self.pyjama.window.tvList.get_item(path) track = Track() track.id = ret[self.pyjama.window.tvList.COLUMN_TRACKID] if track.id < 0: return mnu = gtk.ImageMenuItem("Add track to playlist") rootmenu.append(mnu) try: img = gtk.Image() pix = gtk.gdk.pixbuf_new_from_file_at_size( os.path.join(functions.install_dir(), "images", "playlist.png"), 16, 16 ) img.set_from_pixbuf(pix) mnu.set_image(img) except: print ("Playlist image not found or corrupt") submenu = gtk.Menu() addnew = gtk.ImageMenuItem("Create new playlist") addnew.connect("activate", self.cb_addnew_playlist_activate, track) img = gtk.Image() img.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_MENU) addnew.set_image(img) addnew.show() submenu.append(addnew) sep = gtk.SeparatorMenuItem() sep.show() submenu.append(sep) # if self.pyjama.settings.section_exists("Playlists"): # playlists = self.pyjama.settings.config.items("Playlists") sql = "SELECT option, value FROM settings WHERE section='playlists'" playlists = self.pyjama.settingsdb.query(sql) if playlists: for name, ids in playlists: tmp = gtk.ImageMenuItem(name.replace("_", "__")) tmp.connect("activate", self.cb_append_to_playlist, name, track) submenu.append(tmp) tmp.show() mnu.set_submenu(submenu) submenu.show() mnu.show()
def ev_populate_listmenu(self, rootmenu): selection = self.pyjama.window.tvList.get_selection() model, tmpIter = selection.get_selected() if tmpIter is None: return track = Track() path = model.get_path(tmpIter) ret = self.pyjama.window.tvList.get_item(path) track.id = ret[self.pyjama.window.tvList.COLUMN_TRACKID] if track.id < 0: return mnu = gtk.ImageMenuItem(_("Rate track")) rootmenu.append(mnu) try: img = gtk.Image() pix = gtk.gdk.pixbuf_new_from_file_at_size(os.path.join(functions.install_dir(), "plugins", "rating", "rating.png"), 16, 16) img.set_from_pixbuf(pix) mnu.set_image(img) except: print ("Star image not found or corrupt") submenu = gtk.Menu() for rating in range(5,0,-1): tmp = MyMenuItem(rating) tmp.connect("activate", self.cb_rating, rating, track) submenu.append(tmp) tmp.show() mnu.set_submenu(submenu) submenu.show() mnu.show()
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"), ) self.check_cache(tr) tracks.append(tr) return tracks
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"), ) self.check_cache(tr) 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"), ) self.check_cache(tr) # tracks.append(tr) return tr
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"), ) self.check_cache(tr) tracks.append(tr) return tracks