diff --git a/pluginInfo.json b/pluginInfo.json index 9e38004..07efcaf 100644 --- a/pluginInfo.json +++ b/pluginInfo.json @@ -1,17 +1,17 @@ { - "repoName": "show-on-demand", - "name": "Show On Demand", - "author": "Joe Harrison (joeharrison714)", + "repoName": "show-on-demand-edit", + "name": "Show On Demand-Edit", + "author": "Joe Harrison (joeharrison714), edited by 104Zero for randomization", "description": "This allows the show to be started on demand via text message", - "homeURL": "https://github.com/joeharrison714/show-on-demand-plugin", - "srcURL": "https://github.com/joeharrison714/show-on-demand-plugin.git", + "homeURL": "https://github.com/104Zero/show-on-demand-plugin", + "srcURL": "https://github.com/104Zero/show-on-demand-plugin.git", "bugURL": "https://github.com/joeharrison714/show-on-demand-plugin/issues", "allowUpdates": 1, "versions": [ { "minFPPVersion": "4.0", "maxFPPVersion": "0", - "branch": "master", + "branch": "RandomItem", "sha": "", "dependencies": { "plugins": [ diff --git a/scripts/postStart.sh b/scripts/postStart.sh index 785683a..6a5dc14 100644 --- a/scripts/postStart.sh +++ b/scripts/postStart.sh @@ -1,3 +1,3 @@ #!/bin/sh -/usr/bin/php /home/fpp/media/plugins/show-on-demand/show_on_demand_bg.php & +/usr/bin/php /home/fpp/media/plugins/show-on-demand-edit/show_on_demand_bg.php & diff --git a/show_on_demand.php b/show_on_demand.php index b3de63c..18324ca 100644 --- a/show_on_demand.php +++ b/show_on_demand.php @@ -49,6 +49,12 @@ $madeChange = true; } +#Add code for addition of Random Playlist Item selection +if (strlen(urldecode($pluginSettings['random_playlist_item']))<1){ + WriteSettingToFile("random_playlist_item",urlencode("false"),$pluginName); + $madeChange = true; +} + if ($madeChange) { $pluginSettings = parse_ini_file($pluginConfigFile); } @@ -159,6 +165,17 @@ + + + Select Random Item from Playlist + + + + + diff --git a/show_on_demand_bg.php b/show_on_demand_bg.php index 7a673e4..e8bc703 100644 --- a/show_on_demand_bg.php +++ b/show_on_demand_bg.php @@ -12,6 +12,10 @@ $sodEnabled = $pluginSettings['show_on_demand_enabled']; $sodEnabled = $sodEnabled == "true" ? true : false; +#Add code to allow selection of a random item from the playlist +$randomItemEnabled = $pluginSettings['random_playlist_item']; +$randomItemEnabled = $randomItemEnabled == "true" ? true : false; + $api_base_path = "https://voip.ms/api/v1"; $oldest_message_age = 180; @@ -53,6 +57,9 @@ throw new Exception('No start command specified.'); } + #Add code to print if "random item" is selected + logEntry("Random Item " . $randomItemEnabled); + logEntry("Success message: " . $messageSuccess); logEntry("Not-started message: " . $messageNotStarted); @@ -116,9 +123,17 @@ function startShow(){ global $mainPlaylist; - + global $randomItemEnabled; - $url = "http://127.0.0.1/api/command/Insert Playlist Immediate/" . $mainPlaylist ."/0/0/true"; + #Code to adjust the API request depending on if random item is selected or not + if ($randomItemEnabled == 1){ + $url = "http://127.0.0.1/api/command/Insert Random Item From Playlist/" . $mainPlaylist ."/true"; + logEntry("Selecting Random Item from Playlist"); + } + else{ + $url = "http://127.0.0.1/api/command/Insert Playlist Immediate/" . $mainPlaylist ."/0/0/true"; + } + $url = str_replace(' ', '%20', $url); logEntry("Triggering main playlist: " . $url);