Add timezone detection and clock correction for weather streams
This commit is contained in:
19
index.js
19
index.js
@@ -11,6 +11,7 @@ const DEFAULT_FPS = parseInt(process.env.DEFAULT_FPS || '30');
|
||||
const SCREENSHOT_FORMAT = process.env.SCREENSHOT_FORMAT || 'jpeg';
|
||||
const SCREENSHOT_QUALITY = parseInt(process.env.SCREENSHOT_QUALITY || '95');
|
||||
const DEBUG_MODE = process.env.DEBUG_MODE === 'true';
|
||||
const LOG_WS4KP_URL = process.env.LOG_WS4KP_URL === 'true';
|
||||
|
||||
/**
|
||||
* Build WS4KP weather URL with given coordinates and settings
|
||||
@@ -167,8 +168,12 @@ app.get('/weather', async (req, res) => {
|
||||
} else {
|
||||
// Toronto default
|
||||
initialUrl = buildWeatherUrl(43.6532, -79.3832, weatherSettings);
|
||||
// Create resolved promise with Toronto data
|
||||
geocodeDataPromise = Promise.resolve({ cityName: 'Toronto' });
|
||||
// Create resolved promise with Toronto data including coordinates
|
||||
geocodeDataPromise = Promise.resolve({
|
||||
cityName: 'Toronto',
|
||||
lat: 43.6532,
|
||||
lon: -79.3832
|
||||
});
|
||||
}
|
||||
|
||||
const startTime = Date.now();
|
||||
@@ -183,8 +188,14 @@ app.get('/weather', async (req, res) => {
|
||||
// Call stream handler with music enabled
|
||||
const { debug = DEBUG_MODE ? 'true' : 'false' } = req.query;
|
||||
|
||||
// Build request path for logging
|
||||
const requestPath = `/weather?city=${encodeURIComponent(city)}`;
|
||||
// Build request path for logging - optionally include full ws4kp URL
|
||||
let requestPath = `/weather?city=${encodeURIComponent(city)}`;
|
||||
if (LOG_WS4KP_URL && initialUrl.startsWith('http')) {
|
||||
requestPath = initialUrl;
|
||||
} else if (LOG_WS4KP_URL && lateGeocodePromise) {
|
||||
// For late geocoded URLs, we'll need to pass a promise that resolves to the URL
|
||||
requestPath = lateGeocodePromise;
|
||||
}
|
||||
|
||||
return streamHandler(req, res, {
|
||||
useMusic: true,
|
||||
|
||||
Reference in New Issue
Block a user