Created
December 21, 2016 15:50
-
-
Save ghostwords/f6469841f88183599c25bbfecd087fce to your computer and use it in GitHub Desktop.
WIP Quod Libet plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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