doti3/bar/src/rss.php

40 lines
657 B
PHP
Executable File

#!/usr/bin/php7.1
<?php
require __DIR__.'/base/block.php';
$rss = $argv[1] ?? null;
$client = $argv[2] ?? null;
if (empty($rss)) {
die;
}
$content = @file_get_contents($rss);
if (empty($content)) {
die;
}
preg_match_all('/<entry/isU', $content, $matches, PREG_SET_ORDER);
$title = pemoji(0xf09e);
$count = count($matches);
if ($count > 0) {
$title .= ' +'.$count;
}
$fullText = span($title, $count ? color('normal') : color('info'), '#333');
if ($client && (int) getenv('BLOCK_BUTTON') === 1) {
shell_exec(sprintf('xdg-open %s', escapeshellarg($client)));
}
echo block(
'rss',
[
'full_text' => $fullText,
]
);