def _compils(self): compils = [x.track for x in search.search_tracks_from_string( ex.exaile().collection, '! %s==__null__' % self['artist'])] if len(compils)>0: return self.get_cds_html([x.track for x in search.search_tracks_from_string( ex.exaile().collection, ('album=="%s"' % compil for compil in compils), ['album', 'tracknumber'])]) return ''
def get_cds_html(self, tracks): list = [] html = '' cd = '' for tr in tracks: if get_track_tag(tr, 'album', 'unknown').lower() != cd.lower(): if cd != '': html+='<tr><td colspan=3><hr noshade="noshade"/></td></tr></table>' html+='<table class="cd-table">' cd=get_track_tag(tr, 'album', 'unknown') if cd== 'unknown': track_nbr = len([x.track for x in search.search_tracks_from_string( ex.exaile().collection, 'album==__null__')]) else: track_nbr = len([x.track for x in search.search_tracks_from_string( ex.exaile().collection, 'album=="%s"' % cd)]) cover = get_track_cover(tr) cover_data = get_image_data(cover, (60, 60)) html+='''<tr class="cd-tr">\ <td><a href="album://%s"><img class="cd-img" src="%s"/></a></td>\ <td class="cd-title-td"><a href="album://%s"><b>%s</b><br/>%s</a></td>\ <td class="cd-right-td">%s tracks</td>\ </tr><tr><td colspan=3><hr noshade="noshade"/></td></tr>''' % \ (cd, cover_data, cd, cd, get_track_tag(tr, 'date', ''), track_nbr) anchor = self.get_track_anchor_from_track(tr, img=True) html+='''<tr class="cd-track-tr">\ <td colspan=3 class='tracktd'>%s</td>\ </tr>''' % anchor html+='</table>' return html
def get_selected_tracks(self): tmp = self.hover.split('://', 1)[1] if self.hover.split('://')[0] == 'track': return [ self.currentpage.tracks[int(self.hover.split('://', 1)[1])] ] if self.hover.split('://')[0] == 'artist': return [ x.track for x in search.search_tracks_from_string( ex.exaile().collection, ('artist=="%s"' % tmp), keyword_tags=['album', 'tracknumber']) ] if self.hover.split('://')[0] == 'album': return [ x.track for x in search.search_tracks_from_string( ex.exaile().collection, ('artist=="%s"' % tmp), keyword_tags=['tracknumber']) ] if self.hover.split('://')[0] == 'tag': return [ x.track for x in search.search_tracks_from_string( ex.exaile().collection, ('genre=="%s"' % tmp), keyword_tags=['artist', 'album', 'tracknumber']) ] return []
def __init__(self, preferences, builder): """ Initializes the manager """ self.preferences = preferences builder.connect_signals(self) self.plugins = main.exaile().plugins self.message = dialogs.MessageBar( parent=builder.get_object('preferences_pane'), buttons=Gtk.ButtonsType.CLOSE) self.message.connect('response', self.on_messagebar_response) self.list = builder.get_object('plugin_tree') self.enabled_cellrenderer = builder.get_object('enabled_cellrenderer') if main.exaile().options.Debug: reload_cellrenderer = common.ClickableCellRendererPixbuf() reload_cellrenderer.props.icon_name = 'view-refresh' reload_cellrenderer.props.xalign = 1 reload_cellrenderer.connect('clicked', self.on_reload_cellrenderer_clicked) name_column = builder.get_object('name_column') name_column.pack_start(reload_cellrenderer, True) name_column.add_attribute(reload_cellrenderer, 'visible', 3) self.version_label = builder.get_object('version_label') self.author_label = builder.get_object('author_label') self.name_label = builder.get_object('name_label') self.description = builder.get_object('description_view') self.model = builder.get_object('model') self.filter_model = self.model.filter_new() self.show_incompatible_cb = builder.get_object('show_incompatible_cb') self.show_broken_cb = builder.get_object('show_broken_cb') self.filter_model.set_visible_func(self._model_visible_func) self.status_column = builder.get_object('status_column') self._set_status_visible() selection = self.list.get_selection() selection.connect('changed', self.on_selection_changed) self._load_plugin_list() self._evt_rm1 = event.add_ui_callback(self.on_plugin_event, 'plugin_enabled', None, True) self._evt_rm2 = event.add_ui_callback(self.on_plugin_event, 'plugin_disabled', None, False) self.list.connect('destroy', self.on_destroy) GLib.idle_add(selection.select_path, (0, )) GLib.idle_add(self.list.grab_focus)
def __init__(self, preferences, builder): """ Initializes the manager """ self.preferences = preferences builder.connect_signals(self) self.plugins = main.exaile().plugins self.message = dialogs.MessageBar( parent=builder.get_object('preferences_pane'), buttons=Gtk.ButtonsType.CLOSE ) self.message.connect('response', self.on_messagebar_response) self.list = builder.get_object('plugin_tree') self.enabled_cellrenderer = builder.get_object('enabled_cellrenderer') if main.exaile().options.Debug: reload_cellrenderer = common.ClickableCellRendererPixbuf() reload_cellrenderer.props.icon_name = 'view-refresh' reload_cellrenderer.props.xalign = 1 reload_cellrenderer.connect('clicked', self.on_reload_cellrenderer_clicked) name_column = builder.get_object('name_column') name_column.pack_start(reload_cellrenderer, True) name_column.add_attribute(reload_cellrenderer, 'visible', 3) self.version_label = builder.get_object('version_label') self.author_label = builder.get_object('author_label') self.name_label = builder.get_object('name_label') self.description = builder.get_object('description_view') self.model = builder.get_object('model') self.filter_model = self.model.filter_new() self.show_incompatible_cb = builder.get_object('show_incompatible_cb') self.show_broken_cb = builder.get_object('show_broken_cb') self.filter_model.set_visible_func(self._model_visible_func) self.status_column = builder.get_object('status_column') self._set_status_visible() selection = self.list.get_selection() selection.connect('changed', self.on_selection_changed) self._load_plugin_list() self._evt_rm1 = event.add_ui_callback(self.on_plugin_event, 'plugin_enabled', None, True) self._evt_rm2 = event.add_ui_callback(self.on_plugin_event, 'plugin_disabled', None, False) self.list.connect('destroy', self.on_destroy) GLib.idle_add(selection.select_path, (0,)) GLib.idle_add(self.list.grab_focus)
def _compils(self): compils = [ x.track for x in search.search_tracks_from_string( ex.exaile().collection, '! %s==__null__' % self['artist']) ] if len(compils) > 0: return self.get_cds_html([ x.track for x in search.search_tracks_from_string( ex.exaile().collection, ( 'album=="%s"' % compil for compil in compils), ['album', 'tracknumber']) ]) return ''
def _lyrics(self): try: l = ex.exaile().lyrics.find_lyrics(self.track) l = "%s <br/><br/>from %s" % (l[0].replace('\n', '<br/>'), l[1]) except: l = 'No lyrics found' return l
def _saveas_playlist_cb(widget, name, page, context): exaile = main.exaile() name = dialogs.ask_for_playlist_name(exaile.playlists, "") if name is not None: pl = playlist.Playlist(name, page.playlist[:]) exaile.playlists.save_playlist(pl) page.container.create_tab_from_playlist(pl)
def track_in_collection(artist, title): tracks = [x.track for x in search.search_tracks_from_string( ex.exaile().collection, ('artist=="%s" title=="%s"' % (artist, title)))] if len(tracks)>0: return tracks[0] else: return None
def get_top_artists(field, limit): artists = [ x.artist for x in search.search_tracks_from_string( ex.exaile().collection, '! %s==__null__' % field) ] artists = util.sort_tracks([field], artists, True) return artists[:limit]
def page_leave(preferences_dialog): """ Hides the OSD preview """ OSDWINDOW = exaile().plugins.enabled_plugins["osd"].OSDWINDOW OSDWINDOW.props.autohide = True OSDWINDOW.hide()
def page_leave(preferences_dialog): """ Hides the OSD preview """ OSDWINDOW = exaile().plugins.enabled_plugins['osd'].OSDWINDOW OSDWINDOW.props.autohide = True OSDWINDOW.hide()
def get_top_albums(field, limit): albums = [ x.track for x in search.search_tracks_from_string( ex.exaile().collection, '! %s==__null__' % field) ] albums = util.sort_tracks([field], albums, True) return albums[:limit]
def on_saveas(self): exaile = main.exaile() name = dialogs.ask_for_playlist_name(exaile.gui.main.window, exaile.playlists) if name is not None: pl = playlist.Playlist(name, self.playlist[:]) exaile.playlists.save_playlist(pl) self.plcontainer.create_tab_from_playlist(pl)
def _lyrics(self): try: l = ex.exaile().lyrics.find_lyrics(self.track) l = "%s <br/><br/>from %s" % (l[0].replace('\n', '<br/>'), l[1]) except: l='No lyrics found' return l
def on_message_response(self, widget, response): """ Restarts Exaile if requested """ widget.hide() if response == Gtk.ResponseType.ACCEPT: GLib.idle_add(main.exaile().quit, True)
def on_message_response(self, widget, response): """ Restarts Exaile if requested """ widget.hide() if response == gtk.RESPONSE_ACCEPT: glib.idle_add(main.exaile().quit, True)
def track_in_collection(self, artist, title): if artist == self['artist']: tracks = [x.track for x in search.search_tracks_from_string( ex.exaile().collection, ('artist=="%s" title=="%s"' % (artist, title)))] if len(tracks)>0: return tracks[0] else: return None else: return ContextPage.track_in_collection(self, artist, title)
def _albums(self): if len(self.artist_tracks) == 0: return '' else: return self.get_cds_html(ex.exaile().collection.search( '__compilation==__null__', tracks=self.artist_tracks, sort_fields=['album', 'tracknumber']))
def on_saveas(self): exaile = main.exaile() name = dialogs.ask_for_playlist_name( exaile.gui.main.window, exaile.playlists) if name is not None: pl = playlist.Playlist(name, self.playlist[:]) exaile.playlists.save_playlist(pl) self.plcontainer.create_tab_from_playlist(pl)
def get_selected_tracks(self): tmp = self.hover.split('://', 1)[1] if self.hover.split('://')[0]=='track': return [self.currentpage.tracks[int(self.hover.split('://', 1)[1])]] if self.hover.split('://')[0]=='artist': return [x.track for x in search.search_tracks_from_string( ex.exaile().collection, ('artist=="%s"' % tmp), keyword_tags=['album', 'tracknumber'])] if self.hover.split('://')[0]=='album': return [x.track for x in search.search_tracks_from_string( ex.exaile().collection, ('artist=="%s"' % tmp), keyword_tags=['tracknumber'])] if self.hover.split('://')[0]=='tag': return [x.track for x in search.search_tracks_from_string( ex.exaile().collection, ('genre=="%s"' % tmp), keyword_tags=['artist', 'album', 'tracknumber'])] return []
def __init__(self, preferences, builder): """ Initializes the manager """ self.preferences = preferences builder.connect_signals(self) self.plugins = main.exaile().plugins self.message = dialogs.MessageBar(parent=builder.get_object("preferences_pane"), buttons=gtk.BUTTONS_CLOSE) self.message.connect("response", self.on_messagebar_response) self.list = builder.get_object("plugin_tree") self.enabled_cellrenderer = builder.get_object("enabled_cellrenderer") if main.exaile().options.Debug: reload_cellrenderer = common.ClickableCellRendererPixbuf() reload_cellrenderer.props.stock_id = gtk.STOCK_REFRESH reload_cellrenderer.props.xalign = 1 reload_cellrenderer.connect("clicked", self.on_reload_cellrenderer_clicked) name_column = builder.get_object("name_column") name_column.pack_start(reload_cellrenderer) name_column.add_attribute(reload_cellrenderer, "visible", 3) self.version_label = builder.get_object("version_label") self.author_label = builder.get_object("author_label") self.name_label = builder.get_object("name_label") self.description = builder.get_object("description_view") self.model = builder.get_object("model") self.filter_model = self.model.filter_new() self.show_incompatible_cb = builder.get_object("show_incompatible_cb") self.show_broken_cb = builder.get_object("show_broken_cb") self.filter_model.set_visible_func(self._model_visible_func) self.status_column = builder.get_object("status_column") self._set_status_visible() selection = self.list.get_selection() selection.connect("changed", self.on_selection_changed) self._load_plugin_list() glib.idle_add(selection.select_path, (0,)) glib.idle_add(self.list.grab_focus)
def page_enter(preferences_dialog): """ Shows a preview of the OSD """ # XXX: Ugly but the only way to get the proper # instance, just plugins.osd.OSDWINDOW is always None OSDWINDOW = exaile().plugins.enabled_plugins["osd"].OSDWINDOW OSDWINDOW.props.autohide = False OSDWINDOW.show()
def page_enter(preferences_dialog): """ Shows a preview of the OSD """ # XXX: Ugly but the only way to get the proper # instance, just plugins.osd.OSDWINDOW is always None OSDWINDOW = exaile().plugins.enabled_plugins['osd'].OSDWINDOW OSDWINDOW.props.autohide = False OSDWINDOW.show()
def track_in_collection(artist, title): tracks = [ x.track for x in search.search_tracks_from_string(ex.exaile().collection, ( 'artist=="%s" title=="%s"' % (artist, title))) ] if len(tracks) > 0: return tracks[0] else: return None
def _most_played_albums(self, limit=5): cds = get_top_albums('__playcount', int(limit)) if len(cds) > 0: return self.get_cds_html([ x.track for x in search.search_tracks_from_string( ex.exaile().collection, ( 'album=="%s"' % cd for cd in cds), ['album', 'tracknumber']) ]) return ''
def track_in_collection(self, artist, title): if artist == self['artist']: tracks = [ x.track for x in search.search_tracks_from_string( ex.exaile().collection, ('artist=="%s" title=="%s"' % (artist, title))) ] if len(tracks) > 0: return tracks[0] else: return None else: return ContextPage.track_in_collection(self, artist, title)
def get_local_colors(self): n = ex.exaile().gui.panel_notebook n.realize() style=n.get_style() l=[gtk.STATE_NORMAL,gtk.STATE_ACTIVE,gtk.STATE_PRELIGHT,gtk.STATE_SELECTED,gtk.STATE_INSENSITIVE] s=['normal', 'active', 'prelight', 'selected', 'insensitive'] colors = {} for t in ['base', 'text', 'fg', 'bg']: for i, j in zip(l, s): colors["%s-%s" % (t,j)] = self.to_hex_color(getattr(style, t)[i]) return colors
def _lfm_top_albums(self, period='overall', limit=10): if self.get_lfm_user(): cds = [album.get_item().get_title() for album in self.get_lfm_user().get_top_albums(period,int(limit))] tracks = [] if len(cds)>0: for cd in cds: tracks+= [x.track for x in search.search_tracks_from_string( ex.exaile().collection, ('album=="%s"' % cd), ['tracknumber'])] return self.get_cds_html(tracks) return "" return "Enter your username in the settings"
def get_cds_html(self, tracks): list = [] html = '' cd = '' for tr in tracks: if get_track_tag(tr, 'album', 'unknown').lower() != cd.lower(): if cd != '': html += '<tr><td colspan=3><hr noshade="noshade"/></td></tr></table>' html += '<table class="cd-table">' cd = get_track_tag(tr, 'album', 'unknown') if cd == 'unknown': track_nbr = len([ x.track for x in search.search_tracks_from_string( ex.exaile().collection, 'album==__null__') ]) else: track_nbr = len([ x.track for x in search.search_tracks_from_string( ex.exaile().collection, 'album=="%s"' % cd) ]) cover = get_track_cover(tr) cover_data = get_image_data(cover, (60, 60)) html+='''<tr class="cd-tr">\ <td><a href="album://%s"><img class="cd-img" src="%s"/></a></td>\ <td class="cd-title-td"><a href="album://%s"><b>%s</b><br/>%s</a></td>\ <td class="cd-right-td">%s tracks</td>\ </tr><tr><td colspan=3><hr noshade="noshade"/></td></tr>''' % \ (cd, cover_data, cd, cd, get_track_tag(tr, 'date', ''), track_nbr) anchor = self.get_track_anchor_from_track(tr, img=True) html += '''<tr class="cd-track-tr">\ <td colspan=3 class='tracktd'>%s</td>\ </tr>''' % anchor html += '</table>' return html
def get_local_colors(self): n = ex.exaile().gui.panel_notebook n.realize() style = n.get_style() l = [ gtk.STATE_NORMAL, gtk.STATE_ACTIVE, gtk.STATE_PRELIGHT, gtk.STATE_SELECTED, gtk.STATE_INSENSITIVE ] s = ['normal', 'active', 'prelight', 'selected', 'insensitive'] colors = {} for t in ['base', 'text', 'fg', 'bg']: for i, j in zip(l, s): colors["%s-%s" % (t, j)] = self.to_hex_color( getattr(style, t)[i]) return colors
def __init__(self): """ Initializes the somafm radio station """ self.user_agent = main.exaile().get_user_agent_string('somafm') self.somafm_url = 'https://somafm.com/' self.channels_xml_url = self.somafm_url + 'channels.xml' self.cache_file = os.path.join(xdg.get_cache_dir(), 'somafm.cache') self.channelist = '' self.data = {} self._load_cache() self.subs = {} self.playlists = {} self.playlist_id = 0 logger.debug(self.user_agent)
def __init__(self): """ Initializes the somafm radio station """ self.user_agent = main.exaile().get_user_agent_string('somafm') self.somafm_url = 'http://somafm.com/' self.channels_xml_url = self.somafm_url + 'channels.xml' self.cache_file = os.path.join(xdg.get_cache_dir(),'somafm.cache') self.channelist = '' self.data = {} self._load_cache() self.subs = {} self.playlists = {} self.playlist_id = 0 logger.debug(self.user_agent)
def _lfm_top_albums(self, period='overall', limit=10): if self.get_lfm_user(): cds = [ album.get_item().get_title() for album in self.get_lfm_user().get_top_albums( period, int(limit)) ] tracks = [] if len(cds) > 0: for cd in cds: tracks += [ x.track for x in search.search_tracks_from_string( ex.exaile().collection, ('album=="%s"' % cd), ['tracknumber']) ] return self.get_cds_html(tracks) return "" return "Enter your username in the settings"
def on_refresh_page(self, widget=None,param=None): track = ex.exaile().player._get_current() self.load_wikipedia_page(track)
def quit_cb(*args): from xl import main main.exaile().quit()
def artist_in_collection(artist): return len([ x.track for x in search.search_tracks_from_string(ex.exaile().collection, ('artist=="%s"' % artist)) ]) > 0
def get_track_cover(track): return ex.exaile().covers.get_cover(track, set_only=True, use_default=True)
def _most_played_albums(self, limit=5): cds = get_top_albums('__playcount', int(limit)) if len(cds)>0: return self.get_cds_html([x.track for x in search.search_tracks_from_string( ex.exaile().collection, ('album=="%s"' % cd for cd in cds), ['album', 'tracknumber'])]) return ''
def tag_in_collection(tag): return len([ x.track for x in search.search_tracks_from_string(ex.exaile().collection, ('genre=="%s"' % tag)) ]) > 0
def album_in_collection(artist, album): return len([x.track for x in search.search_tracks_from_string( ex.exaile().collection, ('artist=="%s" album=="%s"' % (artist, album)))])>0
def tag_in_collection(tag): return len([x.track for x in search.search_tracks_from_string( ex.exaile().collection, ('genre=="%s"' % tag))])>0
def artist_in_collection(artist): return len([x.track for x in search.search_tracks_from_string( ex.exaile().collection, ('artist=="%s"' % artist))])>0
def _albums(self): if len(self.artist_tracks) == 0: return '' else: return self.get_cds_html(ex.exaile().collection.search('__compilation==__null__', tracks=self.artist_tracks, sort_fields=['album', 'tracknumber']))
def _show_artist(self, widget): ex.exaile().gui.panels['collection'].filter.set_text( 'artist=%s' % self.hover.split('://')[1]) ex.exaile().gui.panel_notebook.set_current_page(0)
def get_collection_count(self): """ Retrieves the collection count """ return _('%d in collection') % main.exaile().collection.get_count()
def __init__(self): playlists = [] playlists.extend(main.exaile().smart_playlists.list_playlists()) playlists.extend(main.exaile().playlists.list_playlists()) playlists.sort() ComboEntryField.__init__(self, playlists)
def get_artist_tracks(artist): return [x.track for x in search.search_tracks_from_string( ex.exaile().collection, 'artist=="%s"'%artist.lower().replace('"', ''))]
def on_refresh_page(self, widget=None, param=None): track = ex.exaile().player._get_current() self.load_wikipedia_page(track)
def get_top_albums(field, limit): albums = [x.track for x in search.search_tracks_from_string( ex.exaile().collection, '! %s==__null__' % field)] albums = util.sort_tracks([field], albums, True) return albums[:limit]
def album_in_collection(artist, album): return len([ x.track for x in search.search_tracks_from_string(ex.exaile().collection, ( 'artist=="%s" album=="%s"' % (artist, album))) ]) > 0
def get_top_artists(field, limit): artists = [x.artist for x in search.search_tracks_from_string( ex.exaile().collection, '! %s==__null__' % field)] artists = util.sort_tracks([field], artists, True) return artists[:limit]
def get_artist_tracks(artist): return [ x.track for x in search.search_tracks_from_string( ex.exaile().collection, 'artist=="%s"' % artist.lower().replace('"', '')) ]