Skip to content

Instantly share code, notes, and snippets.

@ghostwords
Created December 21, 2016 15:50
Show Gist options
  • Save ghostwords/f6469841f88183599c25bbfecd087fce to your computer and use it in GitHub Desktop.
Save ghostwords/f6469841f88183599c25bbfecd087fce to your computer and use it in GitHub Desktop.

Revisions

  1. ghostwords created this gist Dec 21, 2016.
    48 changes: 48 additions & 0 deletions skip_low_rated.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    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