class Plugin: def __init__(self): self.path = os.path.dirname(__file__) clementine.player.connect("SongChangeRequestProcessed(QUrl, bool)", self.Nostalgia) self.action = QAction("Nostalgia-ize!", None) self.action.setCheckable(True) self.action.connect("changed()", self.Nostalgia) clementine.ui.AddAction("extras_menu", self.action) self.title = "Never Gonna' Give You Up" self.artist = "Rick Astley" self.album = "Whenever You Need Somebody" self.image = QImage(os.path.join(self.path, "nostalgia.jpg")) def Nostalgia(self): if self.action.isChecked(): for item in clementine.playlists.current().GetAllItems(): temp = clementine.Song(item.Metadata()) temp.set_title(self.title) temp.set_artist(self.artist) temp.set_album(self.album) temp.set_image(self.image) item.SetTemporaryMetadata(temp) else: for item in clementine.playlists.current().GetAllItems(): item.ClearTemporaryMetadata() clementine.playlists.current().PlaylistChanged()
class RainbowizerScript(QObject): PRIORITY = 1 def __init__(self): QObject.__init__(self) # Generate colors self.colors = [] for hue in xrange(0, 255, 30): self.colors.append(QColor.fromHsv(hue, 255, 255, 96)) self.action = QAction("rainbowize_playlist", self) self.action.setText("Rainbowize!") self.action.setCheckable(True) self.action.connect("changed()", self.rainbowize) clementine.ui.AddAction('playlist_menu', self.action) def rainbowize(self): for playlist in clementine.playlists.GetAllPlaylists(): if self.action.isChecked(): for i, item in enumerate(playlist.GetAllItems()): item.SetBackgroundColor(self.PRIORITY, self.colors[i % len(self.colors)]) else: # undo all rainbow colors for item in playlist.GetAllItems(): item.RemoveBackgroundColor(self.PRIORITY)
class Plugin: def __init__(self): self.enabled = False clementine.player.connect("PlaylistFinished()", self.PlaylistFinished) self.action = QAction("Shutdown at end", None) self.action.setCheckable(True) self.action.connect("triggered(bool)", self.Enabled) clementine.ui.AddAction("playlist_menu", self.action) def PlaylistFinished(self): if self.enabled: LOGGER.info("Reached the end of the playlist - shutting down") sys.exit(0) def Enabled(self, enabled): LOGGER.info("Shutdown at end of playlist enabled: %s" % str(enabled)) self.enabled = enabled