Skip to content

Instantly share code, notes, and snippets.

@ghostwords
Created December 21, 2016 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghostwords/f6469841f88183599c25bbfecd087fce to your computer and use it in GitHub Desktop.
Save ghostwords/f6469841f88183599c25bbfecd087fce to your computer and use it in GitHub Desktop.
WIP Quod Libet plugin
from gi.repository import Gtk
try:
_
except NameError:
from quodlibet import _
from quodlibet import app
from quodlibet.plugins import PluginConfig
from quodlibet.plugins.events import EventPlugin
from quodlibet.qltk import Icons
def get_config():
pc = PluginConfig("skip_low_rated")
defaults = pc.defaults
defaults.set("skip_one_star", False)
return pc
pconfig = get_config()
class SkipLowRated(EventPlugin):
PLUGIN_ID = "skip_low_rated"
PLUGIN_NAME = _("Skip Low-Rated Tracks")
PLUGIN_DESC = _("Skips tracks rated zero stars.")
PLUGIN_ICON = Icons.USER_BOOKMARKS
# TODO on song ended instead? lets you manually play w/e song you want then
def plugin_on_song_started(self, song):
if song is None:
return
threshold = 0.25 if pconfig.getboolean("skip_one_star") else 0
if song("~#rating") <= threshold:
app.player.next()
@classmethod
def PluginPreferences(self, win):
vb = Gtk.VBox()
ccb = pconfig.ConfigCheckButton(
_("Also skip one star tracks"), "skip_one_star", populate=True
)
vb.pack_start(ccb, True, True, 0)
return vb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment