-
-
Save druzn3k/7945451 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env ruby | |
# This is my current blacklist when playing spotify in radio mode with "heavy metal". | |
blacklist = ['Nickelback', 'Scorpions', 'Watain', 'Mayhem', 'Guns N\' Roses'] | |
# gem install ruby-dbus | |
require "dbus" | |
session_bus = DBus::SessionBus.instance | |
# Get in touch with the Spotify service | |
spotify = session_bus.service("org.mpris.MediaPlayer2.spotify") | |
# Get the object from this service | |
player = spotify.object("/org/mpris/MediaPlayer2") | |
# Introspect it | |
player.introspect | |
if player.has_iface? "org.mpris.MediaPlayer2.Player" | |
player_iface = player["org.mpris.MediaPlayer2.Player"] | |
end | |
# Main loop | |
loop do | |
artist = player_iface["Metadata"]["xesam:artist"] | |
if blacklist.include?(artist) | |
t = Time.now | |
puts t.strftime("(%H:%M) #{artist} is blacklisted, switching to next track") | |
player_iface.Next | |
end | |
sleep(3) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment