}
if ($cronmin % 5 == 0) {
cronPing($cronmin);
- cronSeen($cronmin);
cronMediaLibrary($cronmin);
cronTmdb($cronmin);
}
checkPlanetarium();
}
-function cronSeen($cronmin)
-{
- global $devices;
-
- $seen = [];
-
- $omxdevices = ['salon', 'bureau', 'litvincent', 'litjerome', 'sdb'];
- foreach ($omxdevices as $omxdevice) {
- if (!isAlive($omxdevice)) {
- continue;
- }
- try {
- $res = httpRequest('http://' . $devices[$omxdevice]['host'] . ':4321/', 'post', ['action' => 'filelist']);
- } catch (Exception $e) {
- continue;
- }
- if (!$res) {
- continue;
- }
- $all = json_decode($res->getBody(), true);
- foreach ($all as $item) {
- if ($item['seen']) {
- $seen[str_replace('/nas/', '/volume1/Share/', $item['path'])] = true;
- }
- }
- }
-
- $cache = ROOT . '/cache/seen.json';
- if (file_exists($cache)) {
- $seen = array_merge($seen, json_decode(file_get_contents($cache), true));
- }
- file_put_contents($cache, json_encode($seen));
- connectRedis()->igbset('mediaseen', $seen);
-}
-
function cronMediaLibrary($cronmin)
{
global $directories;
}
+ addSeen($movie);
$res = VLCPlay($movie, $device);
mediaRaspPostPlay($device);
return $res;
}
+function addSeen($movie)
+{
+ $redis = connectRedis();
+
+ try {
+ $seen = $redis->igbget('mediaseen');
+ } catch (Exception $e) {
+ $seen = [];
+ }
+
+ if (!is_array($seen)) {
+ $seen = [];
+ }
+
+ $cacheFile = ROOT . '/cache/seen.json';
+ if (!count($seen)) {
+ $seen = json_decode(file_get_contents($cacheFile));
+ }
+
+ $seen[str_replace('/nas/', '/volume1/Share/', $movie)] = true;
+ $redis->igbset('mediaseen', $seen);
+
+ file_put_contents($cacheFile, json_encode($seen));
+}
+
function mediaRaspCommons($device)
{
global $squeezeboxPlayers;