Selaa lähdekoodia

Correctly capture the play state

Zachary Kotlarek 12 vuotta sitten
vanhempi
sitoutus
6b95bdb71c

+ 5 - 9
plexMonitor/launchd/com.uberzach.plexMonitor.gui.plist → plexMonitor/launchd/com.uberzach.plex.plist

@@ -7,28 +7,24 @@
 	<key>LimitLoadToHosts</key>
 	<array>
 		<string>Beddy.local</string>
-		<string>Loki.local</string>
 		<string>beddy.uberzach.com</string>
+		<string>Loki.local</string>
 		<string>loki.uberzach.com</string>
+		<string>Heady.local</string>
+		<string>heady.uberzach.com</string>
 	</array>
 	<key>RunAtLoad</key>
 	<true/>
 	<key>Label</key>
-	<string>com.uberzach.plexMonitor.gui</string>
+	<string>com.uberzach.plexMonitor</string>
 	<key>KeepAlive</key>
 	<dict>
 		<key>NetworkState</key>
 		<true/>
-		<key>OtherJobEnabled</key>
-		<dict>
-			<key>com.uberzach.plexMonitor</key>
-			<true/>
-		</dict>
 	</dict>
 	<key>ProgramArguments</key>
 	<array>
-		<string>/Users/tv/bin/video/plexMonitor/plexMonitor-gui</string>
-		<string>0.25</string>
+		<string>/Users/tv/bin/video/plexMonitor/plexHelper.sh</string>
 	</array>
 </dict>
 </plist>

+ 0 - 34
plexMonitor/launchd/com.uberzach.plexMonitor.playing.plist

@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>LimitLoadToSessionType</key>
-	<string>Aqua</string>
-	<key>LimitLoadToHosts</key>
-	<array>
-		<string>Beddy.local</string>
-		<string>Loki.local</string>
-		<string>beddy.uberzach.com</string>
-		<string>loki.uberzach.com</string>
-	</array>
-	<key>RunAtLoad</key>
-	<true/>
-	<key>Label</key>
-	<string>com.uberzach.plexMonitor.playing</string>
-	<key>KeepAlive</key>
-	<dict>
-		<key>NetworkState</key>
-		<true/>
-		<key>OtherJobEnabled</key>
-		<dict>
-			<key>com.uberzach.plexMonitor</key>
-			<true/>
-		</dict>
-	</dict>
-	<key>ProgramArguments</key>
-	<array>
-		<string>/Users/tv/bin/video/plexMonitor/plexMonitor-playing</string>
-		<string>0.25</string>
-	</array>
-</dict>
-</plist>

+ 9 - 5
plexMonitor/launchd/com.uberzach.plexMonitor.plist

@@ -7,24 +7,28 @@
 	<key>LimitLoadToHosts</key>
 	<array>
 		<string>Beddy.local</string>
-		<string>beddy.uberzach.com</string>
 		<string>Loki.local</string>
+		<string>beddy.uberzach.com</string>
 		<string>loki.uberzach.com</string>
-		<string>Heady.local</string>
-		<string>heady.uberzach.com</string>
 	</array>
 	<key>RunAtLoad</key>
 	<true/>
 	<key>Label</key>
-	<string>com.uberzach.plexMonitor</string>
+	<string>com.uberzach.plexMonitor.playing</string>
 	<key>KeepAlive</key>
 	<dict>
 		<key>NetworkState</key>
 		<true/>
+		<key>OtherJobEnabled</key>
+		<dict>
+			<key>com.uberzach.plexMonitor</key>
+			<true/>
+		</dict>
 	</dict>
 	<key>ProgramArguments</key>
 	<array>
-		<string>/Users/tv/bin/video/plexMonitor/plexHelper.sh</string>
+		<string>/Users/tv/bin/video/plexMonitor/plexMonitor-playing</string>
+		<string>0.25</string>
 	</array>
 </dict>
 </plist>

+ 7 - 4
plexMonitor/plexMonitor-json.pl

@@ -80,13 +80,12 @@ do {
 	# See if anything is playing
 	my $result = xbmcJSON('Player.GetActivePlayers', undef());
 	if (defined($result) && exists($result->{'playerid'})) {
-		$data{'playing'}  = 1;
 		$data{'playerid'} = $result->{'playerid'} + 0;
 	}
 
-	# Get details about the playing item
-	if ($data{'playing'}) {
-		$result = xbmcJSON('Player.GetProperties', { 'playerid' => $data{'playerid'}, 'properties' => [ 'time', 'type' ] });
+	# Get details about the player
+	if ($data{'playerid'}) {
+		$result = xbmcJSON('Player.GetProperties', { 'playerid' => $data{'playerid'}, 'properties' => [ 'time', 'type', 'speed' ] });
 		if (defined($result)) {
 			if (exists($result->{'time'})) {
 				$data{'time'} = 0;
@@ -103,11 +102,15 @@ do {
 					$data{'time'} += ($result->{'time'}->{'milliseconds'} / 1000);
 				}
 			}
+			if (exists($result->{'speed'}) && $result->{'speed'} > 0) {
+				$data{'playing'} = 1;
+			}
 			if (exists($result->{'type'})) {
 				$data{'type'} = $result->{'type'};
 			}
 		}
 
+		# Get details about the playing item
 		$result = xbmcJSON(
 			'Player.GetItem',
 			{