-
Notifications
You must be signed in to change notification settings - Fork 16
Only scrobble episodes viewed by a specific user
Philipp Spieß edited this page Sep 29, 2015
·
1 revision
In order to only scrobble views by a specific Plex user (e.g. you share your server with others), we need to have a look at multiple lines. Here's a quick git diff
of a possible approach:
diff --git a/plex_tvst_scrobbler/plex_monitor.py b/plex_tvst_scrobbler/plex_monitor.py
index 1e5734c..3ea3053 100755
--- a/plex_tvst_scrobbler/plex_monitor.py
+++ b/plex_tvst_scrobbler/plex_monitor.py
@@ -20,14 +20,14 @@ def parse_line(log_line):
logger = logging.getLogger(__name__)
REGEX = [
- re.compile('.*Updated play state for /library/metadata/([0-9]+).*')
+ re.compile('.*philipp-spiess.*Updated play state for /library/metadata/([0-9]+).*', re.DOTALL)
]
for regex in REGEX:
m = regex.match(log_line)
if m:
- logger.info('Found played TV show and extracted library id \'{l_id}\' from plex log '.format(l_id=m.group(1)))
+ logger.info('Found played TV show by philipp-spiess and extracted library id \'{l_id}\' from plex log '.format(l_id=m.group(1)))
return m.group(1)
@@ -126,9 +126,10 @@ def monitor_log(config):
f.seek(0, 2)
st_mtime = int(os.fstat(f.fileno()).st_mtime)
- line = f.readline()
+ lines = f.readlines(2000)
+ line = ''.join(map(str, lines))
# read all new lines starting at the end. We attempt to match
# based on a regex value. If we have a match, extract the media file
# id and send it off to tvshowtime.com for scrobble.
if line: