mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
37_plex.pm: better controllable detection (by Risiko) (correckt version :)
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@11599 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
276a0f0630
commit
e361cfae29
@ -1040,7 +1040,7 @@ plex_Set($$@)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$list .= 'playMedia ' if( !$hash->{controllable} || $hash->{controllable} =~ m/\bplayPause\b/ );
|
$list .= 'playMedia ' if( !$hash->{controllable} || $hash->{controllable} =~ m/\bplayPause\b/ );
|
||||||
$list .= 'play ' if( defined($hash->{protocolCapabilities}) && $hash->{protocolCapabilities} =~ m/\bplayqueues\b/ );
|
$list .= 'play ' if( $hash->{protocolCapabilities} && $hash->{protocolCapabilities} =~ m/\bplayqueues\b/ );
|
||||||
$list .= 'resume:noArg ' if( !$hash->{controllable} || $hash->{controllable} =~ m/\bplayPause\b/ );
|
$list .= 'resume:noArg ' if( !$hash->{controllable} || $hash->{controllable} =~ m/\bplayPause\b/ );
|
||||||
$list .= 'pause:noArg ' if( $hash->{controllable} && $hash->{controllable} =~ m/\bplayPause\b/ );;
|
$list .= 'pause:noArg ' if( $hash->{controllable} && $hash->{controllable} =~ m/\bplayPause\b/ );;
|
||||||
$list .= 'stop:noArg ' if( $hash->{controllable} && $hash->{controllable} =~ m/\bstop\b/ );;
|
$list .= 'stop:noArg ' if( $hash->{controllable} && $hash->{controllable} =~ m/\bstop\b/ );;
|
||||||
@ -1764,9 +1764,7 @@ plex_getToken($)
|
|||||||
};
|
};
|
||||||
|
|
||||||
$param->{callback} = \&plex_parseHttpAnswer;
|
$param->{callback} = \&plex_parseHttpAnswer;
|
||||||
my($err,$data) = HttpUtils_NonblockingGet( $param );
|
HttpUtils_NonblockingGet( $param );
|
||||||
|
|
||||||
Log3 $name, 2, "$name: http request ($url) failed: $err" if( $err );
|
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -1801,9 +1799,7 @@ plex_getPinForToken($)
|
|||||||
$param->{cl} = $hash->{CL} if( ref($hash->{CL}) eq 'HASH' );
|
$param->{cl} = $hash->{CL} if( ref($hash->{CL}) eq 'HASH' );
|
||||||
|
|
||||||
$param->{callback} = \&plex_parseHttpAnswer;
|
$param->{callback} = \&plex_parseHttpAnswer;
|
||||||
my($err,$data) = HttpUtils_NonblockingGet( $param );
|
HttpUtils_NonblockingGet( $param );
|
||||||
|
|
||||||
Log3 $name, 2, "$name: http request ($url) failed: $err" if( $err );
|
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -1841,9 +1837,7 @@ plex_getTokenOfPin($)
|
|||||||
};
|
};
|
||||||
|
|
||||||
$param->{callback} = \&plex_parseHttpAnswer;
|
$param->{callback} = \&plex_parseHttpAnswer;
|
||||||
my($err,$data) = HttpUtils_NonblockingGet( $param );
|
HttpUtils_NonblockingGet( $param );
|
||||||
|
|
||||||
Log3 $name, 2, "$name: http request ($url) failed: $err" if( $err );
|
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -1911,12 +1905,7 @@ plex_sendApiCmd($$$;$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$param->{callback} = \&plex_parseHttpAnswer;
|
$param->{callback} = \&plex_parseHttpAnswer;
|
||||||
my($err,$data) = HttpUtils_NonblockingGet( $param );
|
HttpUtils_NonblockingGet( $param );
|
||||||
|
|
||||||
if( $err ) {
|
|
||||||
Log3 $name, 2, "$name: http request ($url) failed: $err" if( $err );
|
|
||||||
return $err;
|
|
||||||
}
|
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -1931,7 +1920,7 @@ plex_play($$$$)
|
|||||||
$key =~ s/[^0-9]//g;
|
$key =~ s/[^0-9]//g;
|
||||||
$url = "http://$server->{address}:$server->{port}/playQueues?type=&playlistID=$key";
|
$url = "http://$server->{address}:$server->{port}/playQueues?type=&playlistID=$key";
|
||||||
$url .= "&shuffle=0&repeat=0&includeChapters=1&includeRelated=1";
|
$url .= "&shuffle=0&repeat=0&includeChapters=1&includeRelated=1";
|
||||||
} else { # play album or single track
|
} else { # play album or single track
|
||||||
$key = "/library/metadata/$key" if( $key !~ '^/' );
|
$key = "/library/metadata/$key" if( $key !~ '^/' );
|
||||||
my $xml = plex_sendApiCmd( $hash, "http://$server->{address}:$server->{port}$key", '#raw', 1 );
|
my $xml = plex_sendApiCmd( $hash, "http://$server->{address}:$server->{port}$key", '#raw', 1 );
|
||||||
#Log 1, Dumper $xml;
|
#Log 1, Dumper $xml;
|
||||||
@ -1983,9 +1972,7 @@ plex_play($$$$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$param->{callback} = \&plex_parseHttpAnswer;
|
$param->{callback} = \&plex_parseHttpAnswer;
|
||||||
my($err,$data) = HttpUtils_NonblockingGet( $param );
|
HttpUtils_NonblockingGet( $param );
|
||||||
|
|
||||||
Log3 $name, 2, "$name: http request ($url) failed: $err" if( $err );
|
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -2048,9 +2035,7 @@ plex_addToPlaylist($$$$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$param->{callback} = \&plex_parseHttpAnswer;
|
$param->{callback} = \&plex_parseHttpAnswer;
|
||||||
my($err,$data) = HttpUtils_NonblockingGet( $param );
|
HttpUtils_NonblockingGet( $param );
|
||||||
|
|
||||||
Log3 $name, 2, "$name: http request ($url) failed: $err" if( $err );
|
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -2385,10 +2370,10 @@ plex_parseTimeline($$$)
|
|||||||
readingsBeginUpdate($chash);
|
readingsBeginUpdate($chash);
|
||||||
plex_readingsBulkUpdateIfChanged($chash, 'location', $xml->{location} );
|
plex_readingsBulkUpdateIfChanged($chash, 'location', $xml->{location} );
|
||||||
my $state;
|
my $state;
|
||||||
|
my $controllable;
|
||||||
delete $chash->{time};
|
delete $chash->{time};
|
||||||
delete $chash->{seekRange};
|
delete $chash->{seekRange};
|
||||||
delete $chash->{controllable};
|
delete $chash->{controllable};
|
||||||
my $controllable;
|
|
||||||
foreach my $entry (@{$xml->{Timeline}}) {
|
foreach my $entry (@{$xml->{Timeline}}) {
|
||||||
next if( !$entry->{state} );
|
next if( !$entry->{state} );
|
||||||
|
|
||||||
@ -2410,7 +2395,7 @@ plex_parseTimeline($$$)
|
|||||||
if( $entry->{type} && $entry->{controllable}) {
|
if( $entry->{type} && $entry->{controllable}) {
|
||||||
$controllable->{ $entry->{type} } = $entry->{controllable};
|
$controllable->{ $entry->{type} } = $entry->{controllable};
|
||||||
}
|
}
|
||||||
|
|
||||||
if( $entry->{time} ) {
|
if( $entry->{time} ) {
|
||||||
# if( !$chash->{helper}{time} || abs($entry->{time} - $chash->{helper}{time}) > 2000 ) {
|
# if( !$chash->{helper}{time} || abs($entry->{time} - $chash->{helper}{time}) > 2000 ) {
|
||||||
# plex_readingsBulkUpdateIfChanged($chash, 'time', plex_sec2hms($entry->{time}/1000) );
|
# plex_readingsBulkUpdateIfChanged($chash, 'time', plex_sec2hms($entry->{time}/1000) );
|
||||||
@ -2435,7 +2420,7 @@ plex_parseTimeline($$$)
|
|||||||
|
|
||||||
if( $state =~ '(\w*):(playing|paused)' ) {
|
if( $state =~ '(\w*):(playing|paused)' ) {
|
||||||
$chash->{currentMediaType} = $1;
|
$chash->{currentMediaType} = $1;
|
||||||
$chash->{controllable} = $controllable->{ $1 };
|
$chash->{controllable} = $controllable->{$1} if( $controllable->{$1} );
|
||||||
} else {
|
} else {
|
||||||
delete $chash->{currentMediaType};
|
delete $chash->{currentMediaType};
|
||||||
}
|
}
|
||||||
@ -3987,9 +3972,7 @@ plex_publishToSonos($$;$)
|
|||||||
$param->{cl} = $hash->{CL} if( ref($hash->{CL}) eq 'HASH' );
|
$param->{cl} = $hash->{CL} if( ref($hash->{CL}) eq 'HASH' );
|
||||||
|
|
||||||
$param->{callback} = \&plex_parseHttpAnswer;
|
$param->{callback} = \&plex_parseHttpAnswer;
|
||||||
my($err,$tmpdata) = HttpUtils_NonblockingGet( $param );
|
HttpUtils_NonblockingGet( $param );
|
||||||
|
|
||||||
Log3 $name, 2, "$name: http request ($url) failed: $err" if( $err );
|
|
||||||
|
|
||||||
++$i;
|
++$i;
|
||||||
}
|
}
|
||||||
@ -4031,9 +4014,7 @@ plex_publishToSonos($$;$)
|
|||||||
$param->{cl} = $hash->{CL} if( ref($hash->{CL}) eq 'HASH' );
|
$param->{cl} = $hash->{CL} if( ref($hash->{CL}) eq 'HASH' );
|
||||||
|
|
||||||
$param->{callback} = \&plex_parseHttpAnswer;
|
$param->{callback} = \&plex_parseHttpAnswer;
|
||||||
my($err,$tmpdata) = HttpUtils_NonblockingGet( $param );
|
HttpUtils_NonblockingGet( $param );
|
||||||
|
|
||||||
Log3 $name, 2, "$name: http request ($url) failed: $err" if( $err );
|
|
||||||
|
|
||||||
++$i;
|
++$i;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user