add meteo
This commit is contained in:
parent
fcc31cdba8
commit
5786e6841c
1 changed files with 37 additions and 0 deletions
37
bar/src/meteo.php
Executable file
37
bar/src/meteo.php
Executable file
|
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/php7.1
|
||||
<?php
|
||||
|
||||
require __DIR__.'/base/block.php';
|
||||
|
||||
$url = 'https://fr.wttr.in/?format=%l+%c+%t+%m';
|
||||
|
||||
$command = sprintf('curl %s', escapeshellarg($url));
|
||||
$output = trim(shell_exec($command));
|
||||
|
||||
if (!empty($output)) {
|
||||
if (preg_match('/Unknow location/', $output)) {
|
||||
$output = 'Météo HS';
|
||||
}
|
||||
|
||||
if (preg_match('/mesure de faire de nouvelles/', $output)) {
|
||||
$output = 'Météo HS';
|
||||
}
|
||||
|
||||
try {
|
||||
$city = explode(', ', $output)[0];
|
||||
|
||||
echo block(
|
||||
'meteo',
|
||||
[
|
||||
'full_text' => pspan($output, '#fff'),
|
||||
]
|
||||
);
|
||||
} catch(\Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (getenv('BLOCK_BUTTON') === '1') {
|
||||
$url = 'https://fr.wttr.in/';
|
||||
$command = sprintf('xdg-open %s', escapeshellarg($url));
|
||||
shell_exec($command);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue