mediaplayer: add exclude player option
This commit is contained in:
parent
793394c862
commit
3d31e9a22a
|
@ -23,7 +23,7 @@ def signal_handler(sig, frame):
|
||||||
|
|
||||||
|
|
||||||
class PlayerManager:
|
class PlayerManager:
|
||||||
def __init__(self, selected_player=None):
|
def __init__(self, selected_player=None, excluded_player=[]):
|
||||||
self.manager = Playerctl.PlayerManager()
|
self.manager = Playerctl.PlayerManager()
|
||||||
self.loop = GLib.MainLoop()
|
self.loop = GLib.MainLoop()
|
||||||
self.manager.connect(
|
self.manager.connect(
|
||||||
|
@ -35,11 +35,14 @@ class PlayerManager:
|
||||||
signal.signal(signal.SIGTERM, signal_handler)
|
signal.signal(signal.SIGTERM, signal_handler)
|
||||||
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
|
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
|
||||||
self.selected_player = selected_player
|
self.selected_player = selected_player
|
||||||
|
self.excluded_player = excluded_player.split(',') if excluded_player else []
|
||||||
|
|
||||||
self.init_players()
|
self.init_players()
|
||||||
|
|
||||||
def init_players(self):
|
def init_players(self):
|
||||||
for player in self.manager.props.player_names:
|
for player in self.manager.props.player_names:
|
||||||
|
if player.name in self.excluded_player:
|
||||||
|
continue
|
||||||
if self.selected_player is not None and self.selected_player != player.name:
|
if self.selected_player is not None and self.selected_player != player.name:
|
||||||
logger.debug(f"{player.name} is not the filtered player, skipping it")
|
logger.debug(f"{player.name} is not the filtered player, skipping it")
|
||||||
continue
|
continue
|
||||||
|
@ -149,6 +152,8 @@ def parse_arguments():
|
||||||
# Increase verbosity with every occurrence of -v
|
# Increase verbosity with every occurrence of -v
|
||||||
parser.add_argument("-v", "--verbose", action="count", default=0)
|
parser.add_argument("-v", "--verbose", action="count", default=0)
|
||||||
|
|
||||||
|
parser.add_argument("-x", "--exclude", "- Comma-separated list of excluded player")
|
||||||
|
|
||||||
# Define for which player we"re listening
|
# Define for which player we"re listening
|
||||||
parser.add_argument("--player")
|
parser.add_argument("--player")
|
||||||
|
|
||||||
|
@ -174,7 +179,10 @@ def main():
|
||||||
logger.info("Creating player manager")
|
logger.info("Creating player manager")
|
||||||
if arguments.player:
|
if arguments.player:
|
||||||
logger.info(f"Filtering for player: {arguments.player}")
|
logger.info(f"Filtering for player: {arguments.player}")
|
||||||
player = PlayerManager(arguments.player)
|
if arguments.exclude:
|
||||||
|
logger.info(f"Exclude player {arguments.exclude}")
|
||||||
|
|
||||||
|
player = PlayerManager(arguments.player, arguments.exclude)
|
||||||
player.run()
|
player.run()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue