mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
37_Spotify: fixed optional fields
git-svn-id: https://svn.fhem.de/fhem/trunk@14426 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
4572cc8582
commit
8e5fdd2482
@ -420,7 +420,7 @@ sub Spotify_playContextByURI($$$$) { # play a context (playlist, album or artist
|
|||||||
my ($hash, $uri, $position, $device_id) = @_;
|
my ($hash, $uri, $position, $device_id) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
return 'wrong syntax: set <name> playContextByURI <album_uri / playlist_uri> [ <nr_of_first_track> ] [ <device_id> ]' if(!defined $uri);
|
return 'wrong syntax: set <name> playContextByURI <album_uri / playlist_uri> [ <nr_of_first_track> ] [ <device_id> ]' if(!defined $uri);
|
||||||
$device_id = $position if(defined $position && $position !~ /^[0-9]+$/ && !defined $device_id);
|
$device_id = $position . (defined $device_id ? " ". $device_id : "") if(defined $position && $position !~ /^[0-9]+$/);
|
||||||
$position = 1 if(!defined $position || $position !~ /^[0-9]+$/);
|
$position = 1 if(!defined $position || $position !~ /^[0-9]+$/);
|
||||||
|
|
||||||
return Spotify_play($hash, undef, $uri, $position, $device_id);
|
return Spotify_play($hash, undef, $uri, $position, $device_id);
|
||||||
@ -518,7 +518,7 @@ sub Spotify_playSavedTracks($$$) { # play users saved tracks
|
|||||||
my ($hash, $first, $device_id) = @_;
|
my ($hash, $first, $device_id) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
$device_id = $first if($first !~ /^[0-9]+$/);
|
$device_id = $first . (defined $device_id ? " " . $device_id : "") if(defined $first && $first !~ /^[0-9]+$/);
|
||||||
$first = 1 if(!defined $first || !$first !~ /^[0-9]+$/);
|
$first = 1 if(!defined $first || !$first !~ /^[0-9]+$/);
|
||||||
|
|
||||||
Spotify_apiRequest($hash, 'me/tracks?limit=50'. ($first > 50 ? '&offset='. int($first/50)-1 : ''), undef, 'GET', 1); # getting saved tracks
|
Spotify_apiRequest($hash, 'me/tracks?limit=50'. ($first > 50 ? '&offset='. int($first/50)-1 : ''), undef, 'GET', 1); # getting saved tracks
|
||||||
@ -542,7 +542,7 @@ sub Spotify_playRandomTrackFromPlaylistByURI($$$$) { # select a random track fro
|
|||||||
my ($user_id, $playlist_id) = $uri =~ m/user:(.*):playlist:(.*)/;
|
my ($user_id, $playlist_id) = $uri =~ m/user:(.*):playlist:(.*)/;
|
||||||
return 'invalid playlist_uri' if(!defined $user_id || !defined $playlist_id);
|
return 'invalid playlist_uri' if(!defined $user_id || !defined $playlist_id);
|
||||||
|
|
||||||
$device_id = $limit if(!defined $device_id && $limit !~ /^[0-9]+$/);
|
$device_id = $limit . (defined $device_id ? " " . $device_id : "") if(defined $limit && $limit !~ /^[0-9]+$/);
|
||||||
$limit = undef if($limit !~ /^[0-9]+$/);
|
$limit = undef if($limit !~ /^[0-9]+$/);
|
||||||
|
|
||||||
Spotify_apiRequest($hash, "users/$user_id/playlists/$playlist_id/tracks?fields=items(track(name,uri))". (defined $limit ? "&limit=$limit" : ""), undef, 'GET', 1);
|
Spotify_apiRequest($hash, "users/$user_id/playlists/$playlist_id/tracks?fields=items(track(name,uri))". (defined $limit ? "&limit=$limit" : ""), undef, 'GET', 1);
|
||||||
@ -585,7 +585,7 @@ sub Spotify_volumeFade($$$$$) { # fade the volume of a device
|
|||||||
return 'wrong syntax: set <name> volumeFade <target_volume> [ <duration_s> <percent_per_step> ] [ <device_id> ]' if(!defined $targetVolume);
|
return 'wrong syntax: set <name> volumeFade <target_volume> [ <duration_s> <percent_per_step> ] [ <device_id> ]' if(!defined $targetVolume);
|
||||||
|
|
||||||
Spotify_updateDevices($hash, 1); # make sure devices are up to date (a valid start volume is required)
|
Spotify_updateDevices($hash, 1); # make sure devices are up to date (a valid start volume is required)
|
||||||
$device_id = $duration if(defined $duration && $duration !~ /^[0-9]+$/);
|
$device_id = $duration . (defined $device_id ? " " . $device_id : "") if(defined $duration && $duration !~ /^[0-9]+$/);
|
||||||
my $startVolume = $hash->{helper}{device_active}{volume_percent};
|
my $startVolume = $hash->{helper}{device_active}{volume_percent};
|
||||||
return 'could not get start volume of active device' if(!defined $startVolume);
|
return 'could not get start volume of active device' if(!defined $startVolume);
|
||||||
$step = 5 if(!defined $step); # fall back to default step if not specified
|
$step = 5 if(!defined $step); # fall back to default step if not specified
|
||||||
@ -828,7 +828,7 @@ sub Spotify_dispatch($$$) {
|
|||||||
$hash->{STATE} = 'connected' if(!defined $json->{device});
|
$hash->{STATE} = 'connected' if(!defined $json->{device});
|
||||||
}
|
}
|
||||||
|
|
||||||
if($json->{is_playing} ne 'false') {
|
if($hash->{helper}{is_playing}) {
|
||||||
if(!defined $hash->{helper}{updatePlaybackTimer_next} || $hash->{helper}{updatePlaybackTimer_next} <= gettimeofday()) { # start refresh timer if not already started
|
if(!defined $hash->{helper}{updatePlaybackTimer_next} || $hash->{helper}{updatePlaybackTimer_next} <= gettimeofday()) { # start refresh timer if not already started
|
||||||
my $updateIntervalWhilePlaying = $attr{updateIntervalWhilePlaying};
|
my $updateIntervalWhilePlaying = $attr{updateIntervalWhilePlaying};
|
||||||
$updateIntervalWhilePlaying = 10 if(!defined $updateIntervalWhilePlaying);
|
$updateIntervalWhilePlaying = 10 if(!defined $updateIntervalWhilePlaying);
|
||||||
@ -983,7 +983,7 @@ sub Spotify_isDisabled($) {
|
|||||||
plays an artist using its name (uses search)
|
plays an artist using its name (uses search)
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<i>playContextByURI <context_uri> [ <device_id / device_name> ]</i><br>
|
<i>playContextByURI <context_uri> [ <nr_of_start_track> ] [ <device_id / device_name> ]</i><br>
|
||||||
plays a context (playlist, album or artist) using a Spotify URI
|
plays a context (playlist, album or artist) using a Spotify URI
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@ -991,11 +991,11 @@ sub Spotify_isDisabled($) {
|
|||||||
plays any playlist by providing a name (uses search)
|
plays any playlist by providing a name (uses search)
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<i>playRandomTrackFromPlaylistByURI <track_uri> [ <limit> ] [ <device_id> ]</i><br>
|
<i>playRandomTrackFromPlaylistByURI <track_uri> [ <limit> ] [ <device_id / device_name> ]</i><br>
|
||||||
plays a random track from a playlist (only considering the first <i><limit></i> songs)
|
plays a random track from a playlist (only considering the first <i><limit></i> songs)
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<i>playSavedTracks [ <nr_of_start_track> ] [ <device_id> ]</i><br>
|
<i>playSavedTracks [ <nr_of_start_track> ] [ <device_id / device_name> ]</i><br>
|
||||||
plays the saved tracks (beginning with track <i><nr_of_start_track></i>)
|
plays the saved tracks (beginning with track <i><nr_of_start_track></i>)
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@ -1138,7 +1138,7 @@ sub Spotify_isDisabled($) {
|
|||||||
sucht einen Künstler und spielt dessen Tracks ab
|
sucht einen Künstler und spielt dessen Tracks ab
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<i>playContextByURI <context_uri> [ <device_id / device_name> ]</i><br>
|
<i>playContextByURI <context_uri> [ <nr_of_start_track> ] [ <device_id / device_name> ]</i><br>
|
||||||
spielt einen Context (Playlist, Album oder Künstler) durch Angabe der URI ab
|
spielt einen Context (Playlist, Album oder Künstler) durch Angabe der URI ab
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@ -1146,11 +1146,11 @@ sub Spotify_isDisabled($) {
|
|||||||
sucht eine Playlist und spielt diese ab
|
sucht eine Playlist und spielt diese ab
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<i>playRandomTrackFromPlaylistByURI <track_uri> [ <limit> ] [ <device_id> ]</i><br>
|
<i>playRandomTrackFromPlaylistByURI <track_uri> [ <limit> ] [ <device_id / device_name> ]</i><br>
|
||||||
spielt einen zufälligen Track aus einer Playlist ab (berücksichtigt nur die ersten <i><limit></i> Tracks der Playlist)
|
spielt einen zufälligen Track aus einer Playlist ab (berücksichtigt nur die ersten <i><limit></i> Tracks der Playlist)
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<i>playSavedTracks [ <nr_of_start_track> ] [ <device_id> ]</i><br>
|
<i>playSavedTracks [ <nr_of_start_track> ] [ <device_id / device_name> ]</i><br>
|
||||||
spielt die gespeicherten Tracks ab (beginnend mit Track Nummer <i><nr_of_start_track></i>)
|
spielt die gespeicherten Tracks ab (beginnend mit Track Nummer <i><nr_of_start_track></i>)
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user