Skip to content

Commit

Permalink
Merge pull request #1851 from glensc/ignore-client
Browse files Browse the repository at this point in the history
Feature: Add ignore_clients watch config
  • Loading branch information
glensc authored Mar 7, 2024
2 parents 2817bc8 + 5b6bc42 commit 20d6358
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions plextraktsync/config.default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ watch:
username_filter: true
# Show the progress bar of played media in terminal
media_progressbar: true
# Clients to ignore when listening Play events
ignore_clients: ~

xbmc-providers:
movies: imdb
Expand Down
8 changes: 8 additions & 0 deletions plextraktsync/watch/WatchStateUpdater.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def username_filter(self):
self.logger.warning("No permission to access sessions, disabling username filter")
return None

@cached_property
def ignore_clients(self):
return self.config["watch"]["ignore_clients"] or []

@cached_property
def progressbar(self):
if not self.config["watch"]["media_progressbar"]:
Expand Down Expand Up @@ -170,6 +174,10 @@ def on_play(self, event: PlaySessionStateNotification):
self.logger.debug(f"Scrobbled: {scrobbled}")

def can_scrobble(self, event: PlaySessionStateNotification):
if self.ignore_clients:
if event.client_identifier in self.ignore_clients:
return False

if not self.username_filter:
return True

Expand Down
4 changes: 4 additions & 0 deletions plextraktsync/watch/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ def state(self):
def session_key(self):
return self["sessionKey"]

@property
def client_identifier(self):
return self["clientIdentifier"]


class Setting(Event):
pass
Expand Down

0 comments on commit 20d6358

Please sign in to comment.