https://wakeslow.kumpf.cc/go/?lat=40.31&lon=-83.03&activity=none&fademin=5 // PARAMS: lat, lon, celsius, activity, fademin $pLat = 40.29; if($_GET["lat"]){$pLat=floatval($_GET["lat"]);} $pLon = -83.07; if($_GET["lon"]){$pLon=floatval($_GET["lon"]);} $pCelsius = false; if($_GET["celsius"]){$pCelsius=boolval($_GET["celsius"]);} $pActivity = "none"; if($_GET["activity"] && $_GET["activity"] == "breakfast"){$pActivity = "breakfast";} // could be expanded to more options! $pFadeMin = 5; if($_GET["fademin"]){$fm = intval($_GET["fademin"]); $pFadeMin=(($fm==5||$fm==5)?$fm:$pFadeMin);} // could be expanded to more options! // ----------------------------------------------------------------------------- $apiKey = "ENTER_YOUR_API_KEY_HERE"; // OPENWEATHERMAP API KEY $openWeatherApiUrl = "https://api.openweathermap.org/data/2.5/weather?lat=".$pLat."&lon=".$pLon."&units=".($pCelsius?"metric":"imperial")."&appid=".$apiKey; $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $openWeatherApiUrl); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_VERBOSE, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response); $currentTime = time(); $weatherDayNight = "day"; // [day,night] --> fallback if data is not found/available. $weatherType = "sun"; // [sun,clouds,rain] --> fallback if data is not found/available. $weatherDesc = "Sunny"; $weatherTemp = $pCelsius?23:72; $weatherLoc = "Mystery Location"; if(property_exists($data,"weather") && is_array($data->weather) && count($data->weather) > 0){ $dataWeather = $data->weather[0]; if(property_exists($dataWeather,"icon")){ $weatherIcon = $dataWeather->icon; if(strlen($weatherIcon)==3){ $wicon = substr($weatherIcon,0,2); $wdn = substr($weatherIcon,2,1); if($wdn == "n") $weatherDayNight = "night"; if($wicon == "03" || $wicon == "04") $weatherType = "clouds"; if($wicon == "09" || $wicon == "10" || $wicon == "11") $weatherType = "rain"; if($wicon == "50" || $wicon == "13") $weatherType = "wind"; // 50 = fog, dust, smoke, haze, mist; 13 = snow } } if(property_exists($dataWeather,"main")){ $weatherDesc = $dataWeather->main; } } if(property_exists($data,"main") && property_exists($data->main,"temp")){ $weatherTemp = round($data->main->temp); } if(property_exists($data,"name")){ $weatherLoc = $data->name; } // ----------------------------------------------------------------------------- $m3ustr = "#EXTM3U\n"; $m3ustr .= "#PLAYLIST:WakeSlow Playlist\n"; $m3ustr .= "#EXTINF:-1 tvg-logo=\"http://wakeslow.kumpf.cc/img/albumart.jpg\" group-title=\"WakeSlow\", ".$weatherTemp."°".($pCelsius?"C":"F")." ".$weatherDesc." in ".$weatherLoc."\n"; $m3ustr .= "https://wakeslow.kumpf.cc/audio/weather_".$weatherType."_day_activity_".$pActivity."_fade_".$pFadeMin.".mp3\n"; $alarmNames = ["lang_april_kisses","nork_baby","nork_jazz_it_blues","nork_maple_leaf_rag","nork_ostrich_walk","nork_panama","nork_san_antonio_shout","nork_sensation_rag","nork_since_we_fell","nork_sweet_lovin_man","acehole","bluerose","Bucktown_5_Hot_Mittens","buglcall","buttonup","CA_Ramblers_Animal_Crackers","Eubie_Blake-Charleston_Rag","Eubie_Blake-Chevy_Chase","goldleaf","Henpecked_Blues","hotmama","paleste2","Parham-Washboard_Wiggles","Raderman_Jazz_Orch-Dardanella","Ragtimers-Sister_Kate","The_Georgians-You_Tell_Her_I_Stutter","train","urbones","yestrday","zulublue.mp3"]; // see: http://www.openmusicarchive.org/ and http://www.jazz-on-line.com/ and https://archive.org/details/Free_20s_Jazz_Collection for ($x = 0; $x <= 64; $x++) { $m3ustr .= "#EXTINF:-1, WakeSlow Alarm!\n"; $m3ustr .= "https://wakeslow.kumpf.cc/audio/alarm_".$alarmNames[array_rand($alarmNames)].".mp3\n"; } header("Content-Type: audio/mpegurl"); header("Content-Disposition: attachment; filename=wakeslow.m3u"); echo $m3ustr; ?>